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.
MOTION_OverlapByWindow.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 : MOTION_MovingWindow.c 00041 Purpose : Shows how to use simple motion support 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - (x) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 00051 /********************************************************************* 00052 * 00053 * Includes 00054 * 00055 ********************************************************************** 00056 */ 00057 #include "WM.h" 00058 00059 /********************************************************************* 00060 * 00061 * Static data 00062 * 00063 ********************************************************************** 00064 */ 00065 #define OVERLAP 140 00066 #define NUM_PAGES 4 00067 00068 /********************************************************************* 00069 * 00070 * Static code 00071 * 00072 ********************************************************************** 00073 */ 00074 /********************************************************************* 00075 * 00076 * _cbWin 00077 */ 00078 static void _cbWin(WM_MESSAGE * pMsg) { 00079 GUI_RECT Rect; 00080 WM_MOTION_INFO * pInfo; 00081 static int xPos; 00082 int i, xDist, xSize, xMin, xMax, Overlap; 00083 00084 switch (pMsg->MsgId) { 00085 case WM_MOTION: 00086 pInfo = (WM_MOTION_INFO *)pMsg->Data.p; 00087 switch (pInfo->Cmd) { 00088 case WM_MOTION_INIT: 00089 WM_GetClientRectEx(pMsg->hWin, &Rect); 00090 // 00091 // Enable motion support 00092 // 00093 pInfo->Flags = WM_CF_MOTION_X | WM_MOTION_MANAGE_BY_WINDOW; 00094 pInfo->SnapX = Rect.x1 + 1; 00095 // 00096 // Allow overlapping 00097 // 00098 pInfo->Overlap = OVERLAP; 00099 break; 00100 case WM_MOTION_MOVE: 00101 // 00102 // Move 'content' of window 00103 // 00104 xSize = LCD_GetXSize(); 00105 xPos += pInfo->dx; 00106 // 00107 // Use 'IsDragging' for determining if PID is pressed 00108 // 00109 if (pInfo->IsDragging) { 00110 pInfo->IsOutside = ((xPos < -((xSize * (NUM_PAGES - 1)))) || (xPos > 0)) ? 1 : 0; 00111 Overlap = pInfo->Overlap; 00112 } else { 00113 Overlap = pInfo->Overlap * pInfo->IsOutside; 00114 } 00115 // 00116 // Determine if dragging operation is 'outside' 00117 // 00118 xMin = (int)(((xSize * (NUM_PAGES - 1)) + Overlap) * -1); 00119 xMax = Overlap; 00120 if (xPos < xMin) { 00121 xPos = xMin; 00122 pInfo->StopMotion = pInfo->IsDragging ^ 1; 00123 } else if (xPos > xMax) { 00124 xPos = xMax; 00125 pInfo->StopMotion = pInfo->IsDragging ^ 1; 00126 } 00127 // 00128 // Make sure window will be repainted 00129 // 00130 WM_InvalidateWindow(pMsg->hWin); 00131 break; 00132 case WM_MOTION_GETPOS: 00133 pInfo->xPos = xPos; 00134 break; 00135 } 00136 break; 00137 case WM_PAINT: 00138 // 00139 // Draw 'content' of window 00140 // 00141 GUI_Clear(); 00142 WM_GetClientRect(&Rect); 00143 xDist = Rect.x1 + 1; 00144 for (i = 0; i < NUM_PAGES; i++) { 00145 GUI_DrawRect(i * xDist + xPos, 0, (i + 1) * xDist + xPos - 1, Rect.y1); 00146 GUI_SetFont(GUI_FONT_32B_ASCII); 00147 GUI_DispStringAt("Page #", i * xDist + xPos + 40, Rect.y1 / 2 - 16); 00148 GUI_DispDecMin(i); 00149 } 00150 break; 00151 default: 00152 WM_DefaultProc(pMsg); 00153 } 00154 } 00155 00156 /********************************************************************* 00157 * 00158 * Public code 00159 * 00160 ********************************************************************** 00161 */ 00162 /********************************************************************* 00163 * 00164 * MainTask 00165 */ 00166 void MainTask(void) { 00167 int xSize, ySize; 00168 00169 #if GUI_SUPPORT_MEMDEV 00170 WM_SetCreateFlags(WM_CF_MEMDEV); 00171 #endif 00172 GUI_Init(); 00173 // 00174 // Limit desktop window to physical display size 00175 // 00176 xSize = LCD_GetXSize(); 00177 ySize = LCD_GetYSize(); 00178 WM_SetSize(WM_HBKWIN, xSize, ySize); 00179 // 00180 // Make sure background is black 00181 // 00182 WM_SetDesktopColor(GUI_BLACK); 00183 // 00184 // Enable motion support 00185 // 00186 WM_MOTION_Enable(1); 00187 // 00188 // Create window without motion support... 00189 // 00190 WM_CreateWindowAsChild(0, 0, xSize, ySize, WM_HBKWIN, WM_CF_SHOW, _cbWin, 0); 00191 // 00192 // ...and keep demo alive 00193 // 00194 while (1) { 00195 GUI_Delay(100); 00196 } 00197 } 00198 00199 /*************************** End of file ****************************/
Generated on Thu Jul 14 2022 12:58:42 by
