Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
WM_Video.c
00001 /********************************************************************* 00002 * SEGGER Microcontroller GmbH * 00003 * Solutions for real time microcontroller applications * 00004 ********************************************************************** 00005 * * 00006 * (c) 1996 - 2018 SEGGER Microcontroller GmbH * 00007 * * 00008 * Internet: www.segger.com Support: support@segger.com * 00009 * * 00010 ********************************************************************** 00011 00012 ** emWin V5.48 - Graphical user interface for embedded applications ** 00013 All Intellectual Property rights in the Software belongs to SEGGER. 00014 emWin is protected by international copyright laws. Knowledge of the 00015 source code may not be used to write a similar product. This file may 00016 only be used in accordance with the following terms: 00017 00018 The software has been licensed to Cypress Semiconductor Corporation, 00019 whose registered office is situated at 198 Champion Ct. San Jose, CA 00020 95134 USA solely for the purposes of creating libraries for Cypress 00021 PSoC3 and PSoC5 processor-based devices, sublicensed and distributed 00022 under the terms and conditions of the Cypress End User License 00023 Agreement. 00024 Full source code is available at: www.segger.com 00025 00026 We appreciate your understanding and fairness. 00027 ---------------------------------------------------------------------- 00028 Licensing information 00029 Licensor: SEGGER Microcontroller Systems LLC 00030 Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA 00031 Licensed SEGGER software: emWin 00032 License number: GUI-00319 00033 License model: Services and License Agreement, signed June 10th, 2009 00034 Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) 00035 ---------------------------------------------------------------------- 00036 Support and Update Agreement (SUA) 00037 SUA period: 2009-06-12 - 2022-07-27 00038 Contact to extend SUA: sales@segger.com 00039 ---------------------------------------------------------------------- 00040 File : WM_Video.c 00041 Purpose : The sample shows how to find out if a window is 00042 completely visible and/or covered. 00043 Requirements: WindowManager - (x) 00044 MemoryDevices - ( ) 00045 AntiAliasing - ( ) 00046 VNC-Server - ( ) 00047 PNG-Library - ( ) 00048 TrueTypeFonts - ( ) 00049 ---------------------------------------------------------------------- 00050 */ 00051 00052 #include <stddef.h> 00053 #include <stdio.h> 00054 00055 #include "WM.h" 00056 #include "GUI.h" 00057 #include "FRAMEWIN.h" 00058 #include "BUTTON.h" 00059 #include "TEXT.h" 00060 00061 static void _cbFrameWinTest(WM_MESSAGE * pMsg); 00062 00063 /********************************************************************* 00064 * 00065 * Defines 00066 * 00067 ********************************************************************** 00068 */ 00069 #define MAX_WINDOWS 50 00070 00071 // 00072 // Recommended memory to run the sample with adequate performance 00073 // 00074 #define RECOMMENDED_MEMORY (1024L * 5) 00075 00076 /********************************************************************* 00077 * 00078 * Static data 00079 * 00080 ********************************************************************** 00081 */ 00082 00083 static WM_HWIN _ahWin[MAX_WINDOWS]; 00084 static char _IsCompletelyVis; 00085 00086 /********************************************************************* 00087 * 00088 * Static code 00089 * 00090 ********************************************************************** 00091 */ 00092 /********************************************************************* 00093 * 00094 * _CreateWindow 00095 */ 00096 static void _CreateWindow(void) { 00097 unsigned i; 00098 WM_HWIN hWin; 00099 char ac[32]; 00100 int j; 00101 00102 for (i = 0; i < MAX_WINDOWS; i++) { 00103 if (_ahWin[i] == 0) { 00104 j = i + 1; 00105 sprintf(ac, "Test window %d", j); 00106 hWin = FRAMEWIN_CreateEx(5 + 10 * i, 135 + 10 * i, 120, 60, 0, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, ac, _cbFrameWinTest); 00107 FRAMEWIN_SetClientColor(hWin, GUI_INVALID_COLOR); 00108 _ahWin[i] = hWin; 00109 break; 00110 } 00111 } 00112 } 00113 00114 /********************************************************************* 00115 * 00116 * _DeleteWindow 00117 */ 00118 static void _DeleteWindow(void) { 00119 unsigned i; 00120 00121 for (i = 0; i < MAX_WINDOWS; i++) { 00122 if (WM_IsVisible(_ahWin[i])) { 00123 WM_DeleteWindow(_ahWin[i]); 00124 _ahWin[i] = 0; 00125 break; 00126 } 00127 } 00128 } 00129 00130 /********************************************************************* 00131 * 00132 * _ShowWindow 00133 */ 00134 static void _ShowWindow(void) { 00135 unsigned i; 00136 00137 for (i = 0; i < MAX_WINDOWS; i++) { 00138 if (_ahWin[i] != 0) { 00139 if (WM_IsVisible(_ahWin[i]) == 0) { 00140 WM_ShowWindow(_ahWin[i]); 00141 break; 00142 } 00143 } 00144 } 00145 } 00146 00147 /********************************************************************* 00148 * 00149 * _HideWindow 00150 */ 00151 static void _HideWindow(void) { 00152 unsigned i; 00153 00154 for (i = 0; i < MAX_WINDOWS; i++) { 00155 if (WM_IsVisible(_ahWin[i])) { 00156 WM_HideWindow(_ahWin[i]); 00157 break; 00158 } 00159 } 00160 } 00161 00162 /********************************************************************* 00163 * 00164 * Static code, callbacks 00165 * 00166 ********************************************************************** 00167 */ 00168 /********************************************************************* 00169 * 00170 * _cbBkWin 00171 */ 00172 static void _cbBkWin(WM_MESSAGE* pMsg) { 00173 int Id; 00174 00175 switch (pMsg->MsgId) { 00176 case WM_PAINT: 00177 GUI_SetBkColor(GUI_BLACK); 00178 GUI_Clear(); 00179 break; 00180 case WM_NOTIFY_PARENT: 00181 if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { 00182 Id = WM_GetId(pMsg->hWinSrc); 00183 switch (Id) { 00184 case GUI_ID_BUTTON0: 00185 _CreateWindow(); 00186 break; 00187 case GUI_ID_BUTTON1: 00188 _DeleteWindow(); 00189 break; 00190 case GUI_ID_BUTTON2: 00191 _ShowWindow(); 00192 break; 00193 case GUI_ID_BUTTON3: 00194 _HideWindow(); 00195 break; 00196 } 00197 } 00198 break; 00199 default: 00200 WM_DefaultProc(pMsg); 00201 } 00202 } 00203 00204 /********************************************************************* 00205 * 00206 * _cbFrameWinVideo 00207 */ 00208 static void _cbFrameWinVideo(WM_MESSAGE* pMsg) { 00209 WM_HWIN hWin; 00210 WM_HWIN hText; 00211 int IsCompletelyVis; 00212 int IsCompletelyCovered; 00213 00214 switch (pMsg->MsgId) { 00215 case WM_PAINT: 00216 if (_IsCompletelyVis) { 00217 GUI_SetBkColor(GUI_DARKGREEN); 00218 GUI_Clear(); 00219 GUI_SetColor(GUI_WHITE); 00220 GUI_DispStringAt("Completely visible", 5, 5); 00221 } else { 00222 GUI_SetBkColor(GUI_GRAY); 00223 GUI_Clear(); 00224 GUI_SetColor(GUI_WHITE); 00225 GUI_DispStringAt("Not completely visible", 5, 5); 00226 } 00227 break; 00228 case WM_NOTIFY_VIS_CHANGED: 00229 hText = WM_GetDialogItem(WM_HBKWIN, GUI_ID_TEXT1); 00230 hWin = WM_GetClientWindow(pMsg->hWin); 00231 IsCompletelyVis = WM_IsCompletelyVisible(hWin); 00232 IsCompletelyCovered = WM_IsCompletelyCovered(hWin); 00233 if (IsCompletelyCovered) { 00234 TEXT_SetText(hText, "completely\ncovered"); 00235 } else { 00236 TEXT_SetText(hText, "not completely\ncovered"); 00237 } 00238 if (_IsCompletelyVis != IsCompletelyVis) { 00239 _IsCompletelyVis = IsCompletelyVis; 00240 WM_InvalidateWindow(hWin); /* Only required if content changes if partially hidden */ 00241 } 00242 break; 00243 default: 00244 WM_DefaultProc(pMsg); 00245 } 00246 } 00247 00248 /********************************************************************* 00249 * 00250 * _cbFrameWinTest 00251 */ 00252 static void _cbFrameWinTest(WM_MESSAGE* pMsg) { 00253 switch (pMsg->MsgId) { 00254 case WM_PAINT: 00255 GUI_SetBkColor(GUI_DARKRED); 00256 GUI_Clear(); 00257 break; 00258 default: 00259 WM_DefaultProc(pMsg); 00260 } 00261 } 00262 00263 /********************************************************************* 00264 * 00265 * Public code 00266 * 00267 ********************************************************************** 00268 */ 00269 /********************************************************************* 00270 * 00271 * MainTask 00272 */ 00273 void MainTask(void) { 00274 FRAMEWIN_Handle hWinVideo; 00275 BUTTON_Handle hBut; 00276 WM_HWIN hText; 00277 00278 GUI_Init(); 00279 // 00280 // Check if recommended memory for the sample is available 00281 // 00282 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00283 GUI_ErrorOut("Not enough memory available."); 00284 return; 00285 } 00286 WM_SetCallback(WM_HBKWIN, _cbBkWin); 00287 hText = TEXT_CreateEx(240, 85, 80, 26, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TEXT0, "The client\nwindow is"); 00288 TEXT_SetTextColor(hText, GUI_WHITE); 00289 hText = TEXT_CreateEx(240, 111, 80, 26, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_TEXT1, NULL); 00290 TEXT_SetTextColor(hText, GUI_WHITE); 00291 // 00292 // Create buttons 00293 // 00294 hBut = BUTTON_CreateEx(240, 5, 75, 18, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON0); 00295 BUTTON_SetText(hBut, "Create win"); 00296 hBut = BUTTON_CreateEx(240, 25, 75, 18, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON1); 00297 BUTTON_SetText(hBut, "Delete win"); 00298 hBut = BUTTON_CreateEx(240, 45, 75, 18, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON2); 00299 BUTTON_SetText(hBut, "Show win"); 00300 hBut = BUTTON_CreateEx(240, 65, 75, 18, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON3); 00301 BUTTON_SetText(hBut, "Hide win"); 00302 // 00303 // Create framewin video 00304 // 00305 hWinVideo = FRAMEWIN_CreateEx(5, 5, 170, 120, 0, WM_CF_SHOW, FRAMEWIN_CF_MOVEABLE, 0, "Video window", _cbFrameWinVideo); 00306 FRAMEWIN_SetClientColor(hWinVideo, GUI_INVALID_COLOR); 00307 // 00308 // Create test windows 00309 // 00310 _CreateWindow(); 00311 _CreateWindow(); 00312 _CreateWindow(); 00313 while (1) { 00314 GUI_Delay(1000); 00315 } 00316 } 00317 00318 /*************************** End of file ****************************/ 00319
Generated on Thu Jul 14 2022 12:58:44 by
