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.
WIDGET_ProgbarCustomSkin.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 : WIDGET_ProgbarCustomSkin.c 00041 Purpose : Example demonstrating the LISTBOX widget 00042 Requirements: WindowManager - (x) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 #include "DIALOG.h" 00051 00052 /********************************************************************* 00053 * 00054 * Defines 00055 * 00056 ********************************************************************** 00057 */ 00058 #define RR_ADD 1 // Value which needs to substracted of a rounded rect to fit into a window 00059 #define RADIUS 20 // Radius used for the rounded rects 00060 00061 /********************************************************************* 00062 * 00063 * Static code 00064 * 00065 ********************************************************************** 00066 */ 00067 /********************************************************************* 00068 * 00069 * _CustomSkin 00070 * 00071 * Function description 00072 * This function handles the drawing of the PROGBAR widget. 00073 * 00074 * Parameters 00075 * pDrawItemInfo - A WIDGET_ITEM_DRAW_INFO structure which contains 00076 * information about the window which should be drawn, 00077 * which part and the properties of this part. 00078 */ 00079 static int _CustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) { 00080 GUI_RECT Rect; 00081 GUI_RECT UserRect; 00082 00083 switch (pDrawItemInfo->Cmd) { 00084 case WIDGET_ITEM_CREATE: 00085 return PROGBAR_DrawSkinFlex(pDrawItemInfo); 00086 case WIDGET_ITEM_DRAW_BACKGROUND: 00087 // 00088 // Receive the area of the PROGBAR widget 00089 // 00090 WM_GetClientRectEx(pDrawItemInfo->hWin, &Rect); 00091 // 00092 // Adapt the rectangle to be used for rounded rects 00093 // 00094 Rect.x0 += RR_ADD; 00095 Rect.y0 += RR_ADD; 00096 Rect.x1 -= RR_ADD; 00097 Rect.y1 -= RR_ADD; 00098 // 00099 // Draw a green rounded rect over the complete area, this gets (partially) overwritten by a white one 00100 // 00101 GUI_SetColor(GUI_GREEN); 00102 GUI_FillRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, RADIUS); 00103 // 00104 // Set a user cliprect 00105 // 00106 UserRect.x0 = pDrawItemInfo->x0; 00107 UserRect.y0 = pDrawItemInfo->y0; 00108 UserRect.x1 = pDrawItemInfo->x1; 00109 UserRect.y1 = pDrawItemInfo->y1; 00110 WM_SetUserClipRect(&UserRect); 00111 // 00112 // Draw a white rounded rect over the whole PROGBAR area, but the drawing will be visible only in 00113 // the area of the cliprect. The size of the cliprect will decrease over time and the white rect 00114 // will get smaller. 00115 // 00116 GUI_SetColor(GUI_WHITE); 00117 GUI_FillRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, RADIUS); 00118 // 00119 // Very important, restore the the clipping area 00120 // 00121 WM_SetUserClipRect(NULL); 00122 // 00123 // Almost done, just a draw a red frame over the whole area 00124 // 00125 GUI_SetColor(GUI_RED); 00126 GUI_DrawRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, RADIUS); 00127 return 0; 00128 case WIDGET_ITEM_DRAW_FRAME: 00129 // 00130 // We handle the frame on our own, so we return 0 00131 // 00132 return 0; 00133 case WIDGET_ITEM_DRAW_TEXT: 00134 // 00135 // Handle the drawing of the text by the default skinning routine. 00136 // This case could be commented. Just left it here to show this command 00137 // is available. 00138 // 00139 return PROGBAR_DrawSkinFlex(pDrawItemInfo); 00140 default: 00141 // 00142 // Anything not handled here will be handled by the default skinning routine. 00143 // 00144 return PROGBAR_DrawSkinFlex(pDrawItemInfo); 00145 } 00146 } 00147 00148 /********************************************************************* 00149 * 00150 * Public code 00151 * 00152 ********************************************************************** 00153 */ 00154 /********************************************************************* 00155 * 00156 * MainTask 00157 */ 00158 void MainTask(void) { 00159 PROGBAR_Handle hProg; 00160 int Min; 00161 int Max; 00162 int Value; 00163 00164 // 00165 // Set up some variables 00166 // 00167 Min = 0; 00168 Max = 100; 00169 Value = Min; 00170 // 00171 // Enable automatic use of memory devices 00172 // 00173 WM_SetCreateFlags(WM_CF_MEMDEV); 00174 // 00175 // Initialize GUI 00176 // 00177 GUI_Init(); 00178 // 00179 // Set back ground color for the desktop window 00180 // 00181 WM_SetDesktopColor(GUI_BLACK); 00182 // 00183 // Create a progressbar 00184 // 00185 hProg = PROGBAR_CreateEx(10, 10, 150, 100, WM_HBKWIN, WM_CF_SHOW, PROGBAR_CF_HORIZONTAL, 0); 00186 // 00187 // Set minimal and maximal value of the PROGBAR widget 00188 // 00189 PROGBAR_SetMinMax(hProg, Min, Max); 00190 // 00191 // Set a custom skin, see above 00192 // 00193 PROGBAR_SetSkin(hProg, _CustomSkin); 00194 // 00195 // Set back ground of the PROGBAR widget to invisible 00196 // 00197 WM_SetHasTrans(hProg); 00198 while (1) { 00199 PROGBAR_SetValue(hProg, Value); 00200 Value++; 00201 if (Value > Max) { 00202 Value = Min; 00203 } 00204 GUI_Delay(50); 00205 } 00206 } 00207 00208 /*************************** End of file ****************************/
Generated on Thu Jul 14 2022 12:58:43 by
