Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WM_Sample.c Source File

WM_Sample.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_Sample.c
00041 Purpose     : Demonstrates the window manager
00042 Requirements: WindowManager - (x)
00043               MemoryDevices - ( )
00044               AntiAliasing  - ( )
00045               VNC-Server    - ( )
00046               PNG-Library   - ( )
00047               TrueTypeFonts - ( )
00048 ----------------------------------------------------------------------
00049 */
00050 
00051 #include <string.h>
00052 #include "GUI.h"
00053 #include "WM.h"
00054 
00055 /*********************************************************************
00056 *
00057 *       Defines
00058 *
00059 **********************************************************************
00060 */
00061 #define MSG_CHANGE_TEXT (WM_USER + 0)
00062 #define SPEED           1250
00063 
00064 //
00065 // Recommended memory to run the sample with adequate performance
00066 //
00067 #define RECOMMENDED_MEMORY (1024L * 5)
00068 
00069 /*******************************************************************
00070 *
00071 *       Static variables
00072 *
00073 ********************************************************************
00074 */
00075 //
00076 // Text
00077 //
00078 static char _acInfoText[40];
00079 //
00080 // Colors
00081 //
00082 static GUI_COLOR _WindowColor1 = GUI_GREEN;
00083 static GUI_COLOR _FrameColor1  = GUI_BLUE;
00084 static GUI_COLOR _WindowColor2 = GUI_RED;
00085 static GUI_COLOR _FrameColor2  = GUI_YELLOW;
00086 static GUI_COLOR _ChildColor   = GUI_YELLOW;
00087 static GUI_COLOR _ChildFrame   = GUI_BLACK;
00088 //
00089 // Callback
00090 //
00091 static WM_CALLBACK * _cbBkWindowOld;
00092 //
00093 // Handles
00094 //
00095 static WM_HWIN _hWindow1;
00096 static WM_HWIN _hWindow2;
00097 static WM_HWIN _hChild;
00098 
00099 /*******************************************************************
00100 *
00101 *       Static code, helper functions
00102 *
00103 ********************************************************************
00104 */
00105 /*******************************************************************
00106 *
00107 *       _ChangeInfoText
00108 *
00109 * Function description
00110 *   Sends a message to the background window and invalidate it, so
00111 *   the callback of the background window display the new text.
00112 */
00113 static void _ChangeInfoText(char * pStr) {
00114   WM_MESSAGE Message;
00115 
00116   Message.MsgId  = MSG_CHANGE_TEXT;
00117   Message.Data.p = pStr;
00118   WM_SendMessage(WM_HBKWIN, &Message);
00119   WM_InvalidateWindow(WM_HBKWIN);
00120 }
00121 
00122 /*******************************************************************
00123 *
00124 *       _DrawInfoText
00125 *
00126 * Function description
00127 *   Drawes the info text directly on the display. This function is for
00128 *   the moments when no callback is set.
00129 */
00130 static void _DrawInfoText(char * pStr) {
00131   GUI_SetColor(GUI_WHITE);
00132   GUI_SetFont(&GUI_Font24_ASCII);
00133   GUI_DispStringHCenterAt("WindowManager - Sample", 160, 5);
00134   GUI_SetFont(&GUI_Font8x16);
00135   GUI_DispStringAtCEOL(pStr, 5, 40);
00136 }
00137 
00138 /*******************************************************************
00139 *
00140 *       _LiftUp
00141 */
00142 static void _LiftUp(int dy) {
00143   int i;
00144   int tm;
00145 
00146   for (i = 0; i < (dy/4); i++) {
00147     tm = GUI_GetTime();
00148     WM_MoveWindow(_hWindow1, 0, -4);
00149     WM_MoveWindow(_hWindow2, 0, -4);
00150     while ((GUI_GetTime() - tm) < 20) {
00151       WM_Exec();
00152     }
00153   }
00154 }
00155 
00156 /*******************************************************************
00157 *
00158 *       _LiftDown
00159 */
00160 static void _LiftDown(int dy) {
00161   int i;
00162   int tm;
00163 
00164   for (i = 0; i < (dy/4); i++) {
00165     tm = GUI_GetTime();
00166     WM_MoveWindow(_hWindow1, 0, 4);
00167     WM_MoveWindow(_hWindow2, 0, 4);
00168     while ((GUI_GetTime() - tm) < 20) {
00169       WM_Exec();
00170     }
00171   }
00172 }
00173 
00174 /*******************************************************************
00175 *
00176 *       Static code, callbacks for windows
00177 *
00178 ********************************************************************
00179 */
00180 /*******************************************************************
00181 *
00182 *       _cbBkWindow
00183 */
00184 static void _cbBkWindow(WM_MESSAGE * pMsg) {
00185   switch (pMsg->MsgId) {
00186   case MSG_CHANGE_TEXT:
00187     strcpy(_acInfoText, (char const *)pMsg->Data.p);
00188   case WM_PAINT:
00189     GUI_SetBkColor(GUI_BLACK);
00190     GUI_Clear();
00191     GUI_SetColor(GUI_WHITE);
00192     GUI_SetFont(&GUI_Font24_ASCII);
00193     GUI_DispStringHCenterAt("WindowManager - Sample", 160, 5);
00194     GUI_SetFont(&GUI_Font8x16);
00195     GUI_DispStringAt(_acInfoText, 5, 40);
00196     break;
00197   default:
00198     WM_DefaultProc(pMsg);
00199   }
00200 }
00201 
00202 /*******************************************************************
00203 *
00204 *       _cbWindow1
00205 */
00206 static void _cbWindow1(WM_MESSAGE * pMsg) {
00207   GUI_RECT Rect;
00208   int      x;
00209   int      y;
00210 
00211   switch (pMsg->MsgId) {
00212   case WM_PAINT:
00213     WM_GetInsideRect(&Rect);
00214     GUI_SetBkColor(_WindowColor1);
00215     GUI_SetColor(_FrameColor1);
00216     GUI_ClearRectEx(&Rect);
00217     GUI_DrawRectEx(&Rect);
00218     GUI_SetColor(GUI_WHITE);
00219     GUI_SetFont(&GUI_Font24_ASCII);
00220     x = WM_GetWindowSizeX(pMsg->hWin);
00221     y = WM_GetWindowSizeY(pMsg->hWin);
00222     GUI_DispStringHCenterAt("Window 1", x / 2, (y / 2) - 12);
00223     break;
00224   default:
00225     WM_DefaultProc(pMsg);
00226   }
00227 }
00228 
00229 /*******************************************************************
00230 *
00231 *       _cbWindow2
00232 */
00233 static void _cbWindow2(WM_MESSAGE * pMsg) {
00234   GUI_RECT Rect;
00235   int      x;
00236   int      y;
00237 
00238   switch (pMsg->MsgId) {
00239   case WM_PAINT:
00240     WM_GetInsideRect(&Rect);
00241     GUI_SetBkColor(_WindowColor2);
00242     GUI_SetColor(_FrameColor2);
00243     GUI_ClearRectEx(&Rect);
00244     GUI_DrawRectEx(&Rect);
00245     GUI_SetColor(GUI_WHITE);
00246     GUI_SetFont(&GUI_Font24_ASCII);
00247     x = WM_GetWindowSizeX(pMsg->hWin);
00248     y = WM_GetWindowSizeY(pMsg->hWin);
00249     GUI_DispStringHCenterAt("Window 2", x / 2, (y / 4) - 12);
00250     break;
00251   default:
00252     WM_DefaultProc(pMsg);
00253   }
00254 }
00255 
00256 /*******************************************************************
00257 *
00258 *       _cbChild
00259 */
00260 static void _cbChild(WM_MESSAGE * pMsg) {
00261   GUI_RECT Rect;
00262   int      x;
00263   int      y;
00264 
00265   switch (pMsg->MsgId) {
00266   case WM_PAINT:
00267     WM_GetInsideRect(&Rect);
00268     GUI_SetBkColor(_ChildColor);
00269     GUI_SetColor(_ChildFrame);
00270     GUI_ClearRectEx(&Rect);
00271     GUI_DrawRectEx(&Rect);
00272     GUI_SetColor(GUI_RED);
00273     GUI_SetFont(&GUI_Font24_ASCII);
00274     x = WM_GetWindowSizeX(pMsg->hWin);
00275     y = WM_GetWindowSizeY(pMsg->hWin);
00276     GUI_DispStringHCenterAt("Child window", x / 2, (y / 2) - 12);
00277     break;
00278   default:
00279     WM_DefaultProc(pMsg);
00280   }
00281 }
00282 
00283 /*******************************************************************
00284 *
00285 *       _cbDemoCallback1
00286 */
00287 static void _cbDemoCallback1(WM_MESSAGE * pMsg) {
00288   int x;
00289   int y;
00290 
00291   switch (pMsg->MsgId) {
00292   case WM_PAINT:
00293     GUI_SetBkColor(GUI_GREEN);
00294     GUI_Clear();
00295     GUI_SetColor(GUI_RED);
00296     GUI_SetFont(&GUI_FontComic18B_1);
00297     x = WM_GetWindowSizeX(pMsg->hWin);
00298     y = WM_GetWindowSizeY(pMsg->hWin);
00299     GUI_DispStringHCenterAt("Window 1\nanother Callback", x / 2, (y / 2) - 18);
00300     break;
00301   default:
00302     WM_DefaultProc(pMsg);
00303   }
00304 }
00305 
00306 /*******************************************************************
00307 *
00308 *       _cbDemoCallback2
00309 */
00310 static void _cbDemoCallback2(WM_MESSAGE * pMsg) {
00311   int x;
00312   int y;
00313 
00314   switch (pMsg->MsgId) {
00315   case WM_PAINT:
00316     GUI_SetBkColor(GUI_MAGENTA);
00317     GUI_Clear();
00318     GUI_SetColor(GUI_YELLOW);
00319     GUI_SetFont(&GUI_FontComic18B_1);
00320     x = WM_GetWindowSizeX(pMsg->hWin);
00321     y = WM_GetWindowSizeY(pMsg->hWin);
00322     GUI_DispStringHCenterAt("Window 2\nanother Callback", x / 2, (y / 4) - 18);
00323     break;
00324   default:
00325     WM_DefaultProc(pMsg);
00326   }
00327 }
00328 
00329 /*******************************************************************
00330 *
00331 *       Static code, functions for demo
00332 *
00333 ********************************************************************
00334 */
00335 /*******************************************************************
00336 *
00337 *       _DemoSetDesktopColor
00338 *
00339 * Function description
00340 *   Demonstrates the use of WM_SetDesktopColor
00341 */
00342 static void _DemoSetDesktopColor(void) {
00343   GUI_SetBkColor(GUI_BLUE);
00344   GUI_Clear();
00345   _DrawInfoText("WM_SetDesktopColor()");
00346   GUI_Delay(SPEED*3/2);
00347   WM_SetDesktopColor(GUI_BLACK);
00348   GUI_Delay(SPEED/2);
00349   //
00350   // Set background color and invalidate desktop color.
00351   // This is needed for the later redrawing demo.
00352   //
00353   GUI_SetBkColor(GUI_BLACK);
00354   WM_SetDesktopColor(GUI_INVALID_COLOR);
00355 }
00356 
00357 /*******************************************************************
00358 *
00359 *       _DemoCreateWindow
00360 *
00361 * Function description
00362 *   Demonstrates the use of WM_CreateWindow
00363 */
00364 static void _DemoCreateWindow(void) {
00365   //
00366   // Set callback for background window
00367   //
00368   _cbBkWindowOld = WM_SetCallback(WM_HBKWIN, _cbBkWindow);
00369   //
00370   // Create windows
00371   //
00372   _ChangeInfoText("WM_CreateWindow()");
00373   GUI_Delay(SPEED);
00374   _hWindow1 = WM_CreateWindow( 50,  70, 165, 100, WM_CF_SHOW | WM_CF_MEMDEV, _cbWindow1, 0);
00375   GUI_Delay(SPEED/3);
00376   _hWindow2 = WM_CreateWindow(105, 125, 165, 100, WM_CF_SHOW | WM_CF_MEMDEV, _cbWindow2, 0);
00377   GUI_Delay(SPEED);
00378 }
00379 
00380 /*******************************************************************
00381 *
00382 *       _DemoCreateWindowAsChild
00383 *
00384 * Function description
00385 *   Demonstrates the use of WM_CreateWindowAsChild
00386 */
00387 static void _DemoCreateWindowAsChild(void) {
00388   //
00389   // Create windows
00390   //
00391   _ChangeInfoText("WM_CreateWindowAsChild()");
00392   GUI_Delay(SPEED);
00393   _hChild = WM_CreateWindowAsChild(10, 50, 145, 40, _hWindow2, WM_CF_SHOW | WM_CF_MEMDEV, _cbChild, 0);
00394   GUI_Delay(SPEED);
00395 }
00396 
00397 /*******************************************************************
00398 *
00399 *       _DemoInvalidateWindow
00400 *
00401 * Function description
00402 *   Demonstrates the use of WM_InvalidateWindow
00403 */
00404 static void _DemoInvalidateWindow(void) {
00405   _ChangeInfoText("WM_InvalidateWindow()");
00406   _WindowColor1 = GUI_BLUE;
00407   _FrameColor1  = GUI_GREEN;
00408   GUI_Delay(SPEED);
00409   WM_InvalidateWindow(_hWindow1);
00410   GUI_Delay(SPEED);
00411 }
00412 
00413 /*******************************************************************
00414 *
00415 *       _DemoBringToTop
00416 *
00417 * Function description
00418 *   Demonstrates the use of WM_BringToTop
00419 */
00420 static void _DemoBringToTop(void) {
00421   _ChangeInfoText("WM_BringToTop()");
00422   GUI_Delay(SPEED);
00423   WM_BringToTop(_hWindow1);    
00424   GUI_Delay(SPEED);
00425 }
00426 
00427 /*******************************************************************
00428 *
00429 *       _DemoMoveTo
00430 *
00431 * Function description
00432 *   Demonstrates the use of WM_MoveTo
00433 */
00434 static void _DemoMoveTo(void) {
00435   int i;
00436   int tm;
00437   int tDiff;
00438 
00439   _ChangeInfoText("WM_MoveTo()");
00440   GUI_Delay(SPEED);
00441   for (i = 1; i < 56; i++) {
00442     tm = GUI_GetTime();
00443     WM_MoveTo(_hWindow1,  50 + i,  70 + i);
00444     WM_MoveTo(_hWindow2, 105 - i, 125 - i);
00445     tDiff = 15 - (GUI_GetTime() - tm);
00446     GUI_Delay(tDiff);
00447   }
00448   for (i = 1; i < 56; i++) {
00449     tm = GUI_GetTime();
00450     WM_MoveTo(_hWindow1, 105 - i, 125 - i);
00451     WM_MoveTo(_hWindow2,  50 + i,  70 + i);
00452     tDiff = 15 - (GUI_GetTime() - tm);
00453     GUI_Delay(tDiff);
00454   }
00455   GUI_Delay(SPEED);
00456 }
00457 
00458 /*******************************************************************
00459 *
00460 *       _DemoBringToBottom
00461 *
00462 * Function description
00463 *   Demonstrates the use of WM_BringToBottom
00464 */
00465 static void _DemoBringToBottom(void) {
00466   _ChangeInfoText("WM_BringToBottom()");
00467   GUI_Delay(SPEED);
00468   WM_BringToBottom(_hWindow1);
00469   GUI_Delay(SPEED);
00470 }
00471 
00472 /*******************************************************************
00473 *
00474 *       _DemoMoveWindow
00475 *
00476 * Function description
00477 *   Demonstrates the use of WM_MoveWindow
00478 */
00479 static void _DemoMoveWindow(void) {
00480   int i;
00481   int tm;
00482   int tDiff;
00483 
00484   _ChangeInfoText("WM_MoveWindow()");
00485   GUI_Delay(SPEED);
00486   for (i = 0; i < 55; i++) {
00487     tm = GUI_GetTime();
00488     WM_MoveWindow(_hWindow1,  1,  1);
00489     WM_MoveWindow(_hWindow2, -1, -1);
00490     tDiff = 15 - (GUI_GetTime() - tm);
00491     GUI_Delay(tDiff);
00492   }
00493   for (i = 0; i < 55; i++) {
00494     tm = GUI_GetTime();
00495     WM_MoveWindow(_hWindow1, -1, -1);
00496     WM_MoveWindow(_hWindow2,  1,  1);
00497     tDiff = 15 - (GUI_GetTime() - tm);
00498     GUI_Delay(tDiff);
00499   }
00500   GUI_Delay(SPEED);
00501 }
00502 
00503 /*******************************************************************
00504 *
00505 *       _DemoHideShowParent
00506 *
00507 * Function description
00508 *   Demonstrates the use of WM_HideWindow and WM_ShowWindow
00509 */
00510 static void _DemoHideShowParent(void) {
00511   _ChangeInfoText("WM_HideWindow(Parent)");
00512   GUI_Delay(SPEED);
00513   WM_HideWindow(_hWindow2);
00514   GUI_Delay(SPEED/3);
00515   WM_HideWindow(_hWindow1);
00516   GUI_Delay(SPEED);
00517   _ChangeInfoText("WM_ShowWindow(Parent)");
00518   GUI_Delay(SPEED);
00519   WM_ShowWindow(_hWindow1);
00520   GUI_Delay(SPEED/3);
00521   WM_ShowWindow(_hWindow2);
00522   GUI_Delay(SPEED);
00523 }
00524 
00525 /*******************************************************************
00526 *
00527 *       _DemoHideShowChild
00528 *
00529 * Function description
00530 *   Demonstrates the use of WM_HideWindow and WM_ShowWindow
00531 */
00532 static void _DemoHideShowChild(void) {
00533   _ChangeInfoText("WM_HideWindow(Child)");
00534   GUI_Delay(SPEED);
00535   WM_HideWindow(_hChild);
00536   GUI_Delay(SPEED);
00537   _ChangeInfoText("WM_ShowWindow(Child)");
00538   GUI_Delay(SPEED);
00539   WM_ShowWindow(_hChild);
00540   GUI_Delay(SPEED);
00541 }
00542 
00543 /*******************************************************************
00544 *
00545 *       _DemoClipping
00546 *
00547 * Function description
00548 *   Demonstrates clipping at parent borders
00549 */
00550 static void _DemoClipping(void) {
00551   int i;
00552   int tm;
00553   int tDiff;
00554 
00555   _ChangeInfoText("Demonstrating clipping of child");
00556   GUI_Delay(SPEED);
00557   for (i = 0; i < 25; i++) {
00558     tm = GUI_GetTime();
00559     WM_MoveWindow(_hChild,  1,  0);
00560     tDiff = 15 - (GUI_GetTime() - tm);
00561     GUI_Delay(tDiff);
00562   }
00563   for (i = 0; i < 25; i++) {
00564     tm = GUI_GetTime();
00565     WM_MoveWindow(_hChild,  0,  1);
00566     tDiff = 15 - (GUI_GetTime() - tm);
00567     GUI_Delay(tDiff);
00568   }
00569   for (i = 0; i < 50; i++) {
00570     tm = GUI_GetTime();
00571     WM_MoveWindow(_hChild, -1,  0);
00572     tDiff = 15 - (GUI_GetTime() - tm);
00573     GUI_Delay(tDiff);
00574   }
00575   for (i = 0; i < 25; i++) {
00576     tm = GUI_GetTime();
00577     WM_MoveWindow(_hChild,  0, -1);
00578     tDiff = 15 - (GUI_GetTime() - tm);
00579     GUI_Delay(tDiff);
00580   }
00581   for (i = 0; i < 25; i++) {
00582     tm = GUI_GetTime();
00583     WM_MoveWindow(_hChild,  1,  0);
00584     tDiff = 15 - (GUI_GetTime() - tm);
00585     GUI_Delay(tDiff);
00586   }
00587   GUI_Delay(SPEED);
00588 }
00589 
00590 /*******************************************************************
00591 *
00592 *       _DemoRedrawing
00593 *
00594 * Function description
00595 *   Demonstrates how useful can be a callback
00596 */
00597 static void _DemoRedrawing(void) {
00598   int i;
00599   int tm;
00600   int tDiff;
00601 
00602   _ChangeInfoText("Demonstrating redrawing");
00603   GUI_Delay(SPEED);
00604   _LiftUp(40);
00605   GUI_Delay(SPEED/3);
00606   _ChangeInfoText("Using a callback for redrawing");
00607   GUI_Delay(SPEED/3);
00608   for (i = 0; i < 55; i++) {
00609     tm = GUI_GetTime();
00610     WM_MoveWindow(_hWindow1,  1,  1);
00611     WM_MoveWindow(_hWindow2, -1, -1);
00612     tDiff = 15 - (GUI_GetTime() - tm);
00613     GUI_Delay(tDiff);
00614   }
00615   for (i = 0; i < 55; i++) {
00616     tm = GUI_GetTime();
00617     WM_MoveWindow(_hWindow1, -1, -1);
00618     WM_MoveWindow(_hWindow2,  1,  1);
00619     tDiff = 15 - (GUI_GetTime() - tm);
00620     GUI_Delay(tDiff);
00621   }
00622   GUI_Delay(SPEED/4);
00623   _LiftDown(30);
00624   GUI_Delay(SPEED/2);
00625   _ChangeInfoText("Without redrawing");
00626   GUI_Delay(SPEED);
00627   _LiftUp(30);
00628   GUI_Delay(SPEED/4);
00629   WM_SetCallback(WM_HBKWIN, _cbBkWindowOld);
00630   for (i = 0; i < 55; i++) {
00631     tm = GUI_GetTime();
00632     WM_MoveWindow(_hWindow1,  1,  1);
00633     WM_MoveWindow(_hWindow2, -1, -1);
00634     tDiff = 15 - (GUI_GetTime() - tm);
00635     GUI_Delay(tDiff);
00636   }
00637   for (i = 0; i < 55; i++) {
00638     tm = GUI_GetTime();
00639     WM_MoveWindow(_hWindow1, -1, -1);
00640     WM_MoveWindow(_hWindow2,  1,  1);
00641     tDiff = 15 - (GUI_GetTime() - tm);
00642     GUI_Delay(tDiff);
00643   }
00644   GUI_Delay(SPEED/3);
00645   WM_SetCallback(WM_HBKWIN, _cbBkWindow);
00646   _LiftDown(40);
00647   GUI_Delay(SPEED);
00648 }
00649 
00650 /*******************************************************************
00651 *
00652 *       _DemoResizeWindow
00653 *
00654 * Function description
00655 *   Demonstrates the use of WM_ResizeWindow
00656 */
00657 static void _DemoResizeWindow(void) {
00658   int i;
00659   int tm;
00660   int tDiff;
00661 
00662   _ChangeInfoText("WM_ResizeWindow()");
00663   GUI_Delay(SPEED);
00664   _LiftUp(30);
00665   for (i = 0; i < 20; i++) {
00666     tm = GUI_GetTime();
00667     WM_ResizeWindow(_hWindow1,  1,  1);
00668     WM_ResizeWindow(_hWindow2, -1, -1);
00669     tDiff = 15 - (GUI_GetTime() - tm);
00670     GUI_Delay(tDiff);
00671   }
00672   for (i = 0; i < 40; i++) {
00673     tm = GUI_GetTime();
00674     WM_ResizeWindow(_hWindow1, -1, -1);
00675     WM_ResizeWindow(_hWindow2,  1,  1);
00676     tDiff = 15 - (GUI_GetTime() - tm);
00677     GUI_Delay(tDiff);
00678   }
00679   for (i = 0; i < 20; i++) {
00680     tm = GUI_GetTime();
00681     WM_ResizeWindow(_hWindow1,  1,  1);
00682     WM_ResizeWindow(_hWindow2, -1, -1);
00683     tDiff = 15 - (GUI_GetTime() - tm);
00684     GUI_Delay(tDiff);
00685   }
00686   _LiftDown(30);
00687   GUI_Delay(SPEED);
00688 }
00689 
00690 /*******************************************************************
00691 *
00692 *       _DemoSetCallback
00693 *
00694 * Function description
00695 *   Demonstrates the use of WM_SetCallback
00696 */
00697 static void _DemoSetCallback(void) {
00698   _ChangeInfoText("WM_SetCallback()");
00699   GUI_Delay(SPEED);
00700   WM_SetCallback(_hWindow1, _cbDemoCallback1);
00701   WM_InvalidateWindow(_hWindow1);
00702   GUI_Delay(SPEED/2);
00703   WM_SetCallback(_hWindow2, _cbDemoCallback2);
00704   WM_InvalidateWindow(_hWindow2);
00705   GUI_Delay(SPEED*3);
00706   WM_SetCallback(_hWindow1, _cbWindow1);
00707   WM_InvalidateWindow(_hWindow1);
00708   GUI_Delay(SPEED/2);
00709   WM_SetCallback(_hWindow2, _cbWindow2);
00710   WM_InvalidateWindow(_hWindow2);
00711   GUI_Delay(SPEED);
00712 }
00713 
00714 /*******************************************************************
00715 *
00716 *       _DemoDeleteWindow
00717 *
00718 * Function description
00719 *   Demonstrates the use of WM_DeleteWindow
00720 */
00721 static void _DemoDeleteWindow(void) {
00722   _ChangeInfoText("WM_DeleteWindow()");
00723   GUI_Delay(SPEED);
00724   WM_DeleteWindow(_hWindow2);
00725   GUI_Delay(SPEED/3);
00726   WM_DeleteWindow(_hWindow1);
00727   GUI_Delay(SPEED);
00728   _ChangeInfoText("");
00729   GUI_Delay(SPEED);
00730   //
00731   // Restore background callback and window colors
00732   //
00733   WM_SetCallback(WM_HBKWIN, _cbBkWindowOld);
00734   _WindowColor1 = GUI_GREEN;
00735   _WindowColor2 = GUI_RED;
00736 }
00737 
00738 /*********************************************************************
00739 *
00740 *       Public code
00741 *
00742 **********************************************************************
00743 */
00744 /*********************************************************************
00745 *
00746 *       MainTask
00747 */
00748 void MainTask(void) {
00749   GUI_Init();
00750   //
00751   // Check if recommended memory for the sample is available
00752   //
00753   if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
00754     GUI_ErrorOut("Not enough memory available."); 
00755     return;
00756   }
00757   GUI_SetBkColor(GUI_BLACK);
00758   WM_SetCreateFlags(WM_CF_MEMDEV);
00759   WM_EnableMemdev(WM_HBKWIN);
00760   while (1) {
00761     _DemoSetDesktopColor();
00762     _DemoCreateWindow();
00763     _DemoCreateWindowAsChild();
00764     _DemoInvalidateWindow();
00765     _DemoBringToTop();
00766     _DemoMoveTo();
00767     _DemoBringToBottom();
00768     _DemoMoveWindow();
00769     _DemoHideShowParent();
00770     _DemoHideShowChild();
00771     _DemoClipping();
00772     _DemoRedrawing();
00773     _DemoResizeWindow();
00774     _DemoSetCallback();
00775     _DemoDeleteWindow();
00776   }
00777 }
00778 
00779 /*************************** End of file ****************************/