uC-GUI User
uC-GUI User
uC-GUI User
Micrim
www.micrium.com Empowering Embedded Systems
Disclaimer
Specifications written in this manual are believed to be accurate, but are not guaranteed to be entirely free of error. Specifications in this manual may be changed for functional or performance improvements without notice. Please make sure your manual is the latest edition. While the information herein is assumed to be accurate, Micrium Technologies Corporation (the distributor) assumes no responsibility for any errors or omissions and makes no warranties. The distributor specifically disclaims any implied warranty of fitness for a particular purpose.
Copyright notice
The latest version of this manual is available as PDF file in the download area of our website at www.micrium.com. You are welcome to copy and distribute the file as well as the printed version. You may not extract portions of this manual or modify the PDF file in any way without the prior written permission of Micrium Technologie Corporation. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license.
2002-2007 Micrium, Weston, Florida 33327-1848, U.S.A.
Trademarks
Names mentioned in this manual may be trademarks of their respective companies. Brand and product names are trademarks or registered trademarks of their respective holders.
Registration
Please register the software via email. This way we can make sure you will receive updates or notifications of updates as soon as they become available. For registration please provide the following information: Your full name and the name of your supervisor Your company name Your job title Your email address and telephone number Company name and address Your company's main phone number Your company's web site address Name and version of the product
Contact address
Micrium Technologies Corporation 949 Crestview Circle Weston, FL 33327-1848 U.S.A. Phone : +1 954 217 2036 FAX : +1 954 217 2037 WEB : www.micrium.com Email : [email protected]
2002-2007 Micrium
Manual versions
This manual describes the latest software version. The software version number can be found in the table Software versions later in this chapter. If any error occurs, please inform us and we will try to help you as soon as possible. For further information on topics or routines not yet specified, please contact us. Print date: October 9, 2007
2002-2007 Micrium
Manual version
Date
By
Explanation
Chapter 7: 2-D Graphic Library - Functions GUI_DrawPie() and GUI_SetPenSize() added. Chapter 10: Bitmap Converter - New 24 bpp format substitutes 888 and M888 format. Chapter 12: Memory Devices - 32bpp memory devices added. Chapter 14: Window manager - Function WM_SendMessageNoPara() added. - Function WM_IsCompletelyCovered() added. Chapter 15: Widgets - EDIT_SetFloatMode: GUI_EDIT_SUPPRESS_LEADING_ZEROES added. - GRAPH: New functions for detaching data and scales added. - FRAMEWIN: New functions for getting bar color and state added. Chapter 21: Sprites (NEW) - Software sprites have been added to C/GUI. Chapter 25: Display Drivers - Support for Epson S1D15E06 added to LCD1611. - Support for Ilitec ILI9161 & ILI9220 added to LCD667XX. - Support for Solomon SSD1848 added to LCD13700. - Support for UltraChip UC1608 added to LCDPage1bpp. - Config option LCD_FIRSTPIXEL0 added to LCD7529. - Config options of LCD6331 reworked. Chapter 29: Performance and Resource Usage - Section Memory requirements reworked. Chapter 7: 2-D Graphic Library - Functions for drawing color gradients added. Chapter 9: Fonts - Rough file format description added. - New font type for using framed fonts added. - Sample how to declare font prototypes added. - XBF format available for extended proportional bitmap fonts. Chapter 10: Bitmap Converter - New function for saving the palette available. - Subchapter Using a custom palette reworked. Chapter 14: Window Manager - Explanation of WM_BroadcastMessage() extended. Chapter 15: Widgets - EDIT_SetTextColor: Meaning of parameter Index changed. Chapter 18: Multi layer / multi display support - Descriptionadded of how to realize run time display rotation. Chapter 23: Foreign Language Support - Character mirroring for RLT aligned text supported. Chapter 24: Display Drivers - Support for Solomon SSD1289, Toshiba JBT6K71, Sharp LCY-A06003, Samsung S6D0129, MagnaChip D54E4PA7551 and Himax HX8312 added to LCD667XX driver. - Support for Ultrachip UC1617 added to LCD13700 driver. - LCD_CONTROLLER configuration changed for Epson S1D13701, Hitachi HD66750 and Hitachi HD66753 - LCDLin: New driver variant available for 32/16/8 bit access. Chapter 27: Low level configuration - Multiple controller configuration reworked. Chapter 28: High level configuration - Explanation of GUI_SUPPORT_CURSOR added.
4.12R0
070920
JE
4.10R1
070801
JE
4.10R0
070511
JE
2002-2007 Micrium
Manual version
Date
By
Explanation
Chapter 7: 2-D Graphic library - Support for general software alpha blending added. - Support for drawing alpha bitmaps on multi layer systems added. Chapter 10: Bitmap converter - Support for creating alpha blending bitmaps added. Chapter 15: Widgets - Blinking cursors added to MULTIEDIT and EDIT widget. - New functions and new notification messages added to MENU widget. Chapter 24: Display drivers - Support for Renesas R61509 and R63401 added to LCD667XX. - 24 and 32 bpp mode added to LCDLin - Support for Sitronix ST7522 added to LCDPage1bpp Chapter 6: Displaying values - Number of digits in GUI_DispDec...() increased to 10. Chapter 8: Displaying bitmap files - BMP files: Support for RLE4, RLE8 and 16bpp format added. Chapter 9: Fonts - Introduction reworked. - TrueType support added. - Explanation of GUI_MAX_XBF_BYTES added. - New fonts added. Chapter 10: Bitmap converter - Description of supported C file formats added. Chapter 11: Colors - New fixed palette mode 5 added. - Table of default fixed palette modes added. Chapter 14: Window manager - Timer message added. - Timer functions added. Chapter 15: Widgets - DROPDOWN: Functions added to manage the disable state of items. Chapter 18: Multi layer support - New functions for managing hardware cursors added. Chapter 24: Display drivers - LCD7529 now works without cache and in 4bpp mode. Chapter 29: Performance and Resource usage - Table of image drawing performance added. Chapter 24: Display drivers - Driver LCD15E05 removed. - Support for Epson S1D15E05 and S1D15719 added to LCD1611 driver. Chapter 15: Widgets - Function added to set the rotation mode of a MULTIPAGE widget.
4.08R0
070131
JE
4.06R0
061006
JE
4.04R1 4.04R0
060519 060505
JE JE
2002-2007 Micrium
Manual version
Date
By
Explanation
Chapter 7: 2-D graphic library - Filling polygons: New config option GUI_FP_MAXCOUNT added. Chapter 8: Displaying bitmap files - BMP subchapter: Support for 32bpp BMP files added. - JPEG subchapter: Adapted to the new decoder. Chapter 9: Fonts - New functions for getting the number of blank pixel columns added. Chapter 10: Bitmap converter - Support for 24bpp and RLE16 format added. Chapter 11: Colors - Fixed palette modes for 24bpp and 32bpp added. - Fixed palette modes for alpha blending added. Chapter 15: Widgets - Support for widget schemes added. - GRAPH: Invalid data can be excluded from drawing YT graphs. - LISTVIEW: Function added to fix one or more columns. - DROPDOWN: Notification WM_NOTIFICATION_SEL_CHANGED added. - MULTIEDIT: New function added to set the text alignment. Chapter 18: Multi layer support - Support for up to 6 layers/displays added. Chapter 24: Display drivers - Support for Sitronix ST7712 added to LCD66772.c - New driver added to support Epson S1D13700 in 2bpp mode. - New driver added to support RAIO 8822 in 2bpp mode. - New driver added to support Sitronix ST7529. - New driver added to support Sitronix ST7920. Chapter 9: Fonts - New functions for using external bitmap fonts added. Chapter 8: Displaying bitmap files - New functions added for drawing GIFs and BMPs without loading them into memory. - New functions added for drawing scaled GIFs and BMPs with and without loading them into memory. - New functions added for getting information about GIFs and BMPs without loading them into memory. Chapter 9: Fonts: - New type of font added. Chapter 15: Widgets - Keyboard support added to MULTIPAGE widget. Chapter 16: Dialogs - Keyboard can be used to move to the previous dialog item. Chapter 23: Foreign language support - Subchapter Arabic support revised. - New subchapter for Thai language support. Chapter 29: Performance and resource usage - Table for image drawing performance added.
4.02R0
060502
JE
4.01R0
060131
JE
4.00R0
051222
JE
2002-2007 Micrium
Manual version
Date
By
Explanation
Chapter 5: Displaying text - New function for showing text with text wrapping support added. Chapter 8: Displaying bitmap files - New functions for drawing animated GIFs added. - New functions for drawing scaled JPEGs added. - New functions added to draw JPEGs without loading them into memory. - Memory requirement of JPEG decompression changed. Chapter 9: Fonts - Subchapter standard font revised. Chapter 12: Memory devices - New function added. Chapter 14: Window manager - New message WM_MOUSEOVER_END added to messages. Chapter 15: Widgets - EDIT: Functions added to get the cursor position and to edit unsigned long values, notification messages added. - FRAMEWIN: Config option added. - GRAPH: Prototype of GRAPH_DATA_XY_SetPenSize() changed. - HEADER: Function for limitiing dragging within the widget area added. - LISTVIEW: Sorting functions added, automatic use of scroll bars added, managing user data added, keyboard support enhanced, new config option added. - MENU: Popup menu added. - MESSAGEBOX: Config option added. - MULTIEDIT: Functions added to get the cursor position. - SCROLLBAR: Config options added. - TEXT: Text wrapping functions added. - Common: Mouse support of widgets explained, config option added. Chapter 21: Cursors - Function added. Chapter 24: Display drivers - LCDSLin: Support for RAIO 8822/8803/8835 added. - LCD667XX: Support for Sharp LR38825 and Samsung S6D0117 added. - LCDPage1bpp: Support for UltraChip UC1601 added. Chapter 7: 2-D Graphic Library - New function GUI_GetDrawMode() added. Chapter 8: Displaying bitmap files - Mentioned, that JPEG package is only part of color version. Chapter 9: Fonts - Antialiased SIF fonts added. Chapter 12: Memory devices - New function GUI_MEMDEV_WriteEx() added. - New function GUI_MEMDEV_WriteExAt() added. Chapter 14: Window manager - New function WM_GetCallback() added. Chapter 15: Widgets - Interface of SCROLLBAR_SetColor() changed. - Explanation added, how to determine the type of a widget. - New GRAPH widget added. - New function BUTTON_GetBitmap() added. - New function CHECKBOX_GetText() added. - New function DROPDOWN_SetColor() added. - New function DROPDOWN_SetDefaultColor() added. - New function DROPDOWN_SetDefaultScrollbarColor() added. - New function DROPDOWN_SetScrollbarColor() added. - New function LISTBOX_SetScrollbarColor() added. - New function RADIO_GetText() added. Chapter 24: Display drivers - LCD667XX driver: Support for Samsung S6D0110A added. - LCD07X1 driver: Support for Sitronix ST7541 added. - LCD66750 driver: Support for Hitachi HD66753 added.
3.98R0
051109
JE
3.96R0
050719
JE
2002-2007 Micrium
Manual version
3.95R0
Date
By
Explanation
Chapter 23 (Unicode) and 24 (Shift JIS) merged to chapter 23 (Foreign Language Support). Chapter 23: - Arabic support added. New chapter 3: Viewer - Virtual screen support added. Chapter 7: 2-D Graphic Library - New function GUI_SetClipRect() added. Chapter 8: Displaying bitmap files - GIF file support added. Chapter 10: Bitmap converter - GIF file support added. Chapter 11: Colors - Mentioned that custom palettes only available for modes up to 8bpp. Chapter 12: Memory devices - Reworked and support for 1bpp memory devices added. Chapter 14: Window manager - API function classification basic/advanced removed. - New function WM_SetWindowPos() added. - New function WM_GetScrollPosH() added. - New function WM_GetScrollPosV() added. - New function WM_SetScrollPosH() added. - New function WM_SetScrollPosV() added. Chapter 15: Widgets - BUTTON: New function BUTTON_SetDefaultFocusColor. - BUTTON: New function BUTTON_SetFocusColor. - BUTTON: New config option BUTTON_FOCUSCOLOR_DEFAULT. - CHECKBOX: New function CHECKBOX_SetBoxBkColor(). - CHECKBOX: New function CHECKBOX_SetDefaultFocusColor(). - CHECKBOX: New function CHECKBOX_SetFocusColor(). - CHECKBOX: Notification WM_NOTIFICATION_VALUE_CHANGED added. - CHECKBOX: Image of unchecked state can now be set. - EDIT: New function EDIT_SetTextMode() added. - LISTBOX: New function LISTBOX_GetDefaultTextAlign() added. - LISTBOX: New function LISTBOX_GetTextAlign() added. - LISTBOX: New function LISTBOX_SetDefaultTextAlign() added. - LISTBOX: New function LISTBOX_SetTextAlign() added. - LISTBOX: New color index LISTBOX_CI_DISABLED added. - LISTVIEW: New color index LISTVIEW_CI_DISABLED added. - MENU: Keyboard support added. - PROGBAR: Vertical progress bar supported. - RADIO: New function RADIO_SetDefaultFocusColor() added. - RADIO: New function RADIO_SetFocusColor() added. - RADIO: Config options reworked. - SCROLLBAR: New function SCROLLBAR_SetColor() added. - SCROLLBAR: New function SCROLLBAR_SetDefaultColor() added. - SLIDER: New function SLIDER_SetDefaultFocusColor() added. - SLIDER: New function SLIDER_SetFocusColor() added. - Keyboard support explained for each widget. - Widget callback functions added. Chapter 22: Antialiasing - New function GUI_AA_DrawPolyOutlineEx() added. - Limitation of GUI_AA_DrawPolyOutline() explained. Chapter 23: Unicode - New function GUI_UC_ConvertUC2UTF8() added. - New function GUI_UC_ConvertUTF82UC() added.
050701
JE
3.94R0
050329
JE
2002-2007 Micrium
Manual version
Date
By
Explanation
Chapter 25: Display drivers - New driver LCD0323 for Solomon SSD0323 controller added. - New driver LCD1200 for Toppoly C0C0 and C0E0 controller added. - New driver LCD13701 for Epson S1D13701 controller added. - New driver LCDNoritake for Noritake displays added. - New driver LCD667XX for Hitachi HD66772, HD66766 controller added. - New driver LCDXylon added. - LCDLin driver: New config macro LCD_FILL_RECT added. - LCDLin driver: New config macro LCD_LIN_SWAP added. - LCDLin driver: 32 bit version now supports 1 and 2 bpp color depth. Chapter 28: Low level config - LCD_REVERSE_LUT added. Chapter 3: Simulator and Viewer - Subchapter added: Using the source code of the simulator. Chapter 9: Bitmap converter - Saving of bitmaps reworked. Chapter 13: Window manager - New functions added: WM_PaintWindowAndDescs(), WM_Update() and WM_UpdateWindowAndDescs(). Chapter 14: Widgets - Flag GUI_MESSAGEBOX_CF_MODAL added for creating a modal message box. - Notification codes added to MULTIPAGE widget. - New functions added: LISTVIEW_DisableRow(), LISTVIEW_EnableRow() and LISTVIEW_GetItemText(). New Chapter 16: Virtual screens - New functions GUI_GetOrg() and GUI_SetOrg(). Chapter 24: Display driver - Support for Sitronix ST7565 added to Page1bpp driver. - LCDLin driver (8/16 bit): LCD_SET_LUT_ENTRY added. - LCDLin driver (32 bit): Explanation added how to migrate from LCDLin to LCDLin32. Chapter 27: High-Level Configuration - GUI_TRIAL_VERSION added. Chapter 6: 2-D Graphic library - GUI_DrawBitmapEx() does not render RLE-compressed bitmaps. Chapter 13: Window manager - Explanation added, which messages are not send to disabled windows. - New function WM_GetPrevSibling() added. - New message WM_MOUSEOVER added. - New create flag WM_CF_MEMDEV_ON_REDRAW added. - WM_MOVE message: Explanation reworked. Chapter 14: Widgets - MENU widget added. - WM_NOTIFICATION_SCROLL_CHANGED added to DROPDOWN, LISTBOX, LISTVIEW and MULTIEDIT - BUTTON widget: Support for disabled state added. - New functions added: DROPDOWN_SetTextHeight(), DROPDOWN_SetTextAlign(), FRAMEWIN_AddMenu(), FRAMEWIN_SetResizeable(), LISTVIEW_GetBkColor(), LISTVIEW_GetTextColor(), LISTVIEW_SetItemTextColor(), LISTVIEW_SetItemBkColor() Chapter 17: Pointer Input Devices - Explanation of structure GUI_PID_STATE changed. Chapter 23: Display driver - Support for Solomon SSD1815 added to Page1bpp driver Chapter 26: Low-Level Configuration - Real bus interface renamed to Memory mapped interface Chapter 29: Support - Warnings added to subchapter compiler warnings. - Subchapter Contacting support added.
3.92R0
041021
JE
3.90R0
040818
JE
2002-2007 Micrium
10
Manual version
Date
By
Explanation
Chapter 1: Introduction: - ANSI standard described more detailed. Chapter 6: 2-D Graphic Library - Default limitation for drawing bitmaps with 16 bit CPUs added. Chapter 8: Fonts - Fonts added: GUI_FontD48, GUI_FontD64, GUI_FontD80, GUI_FontD37x48, GUI_FontD48x64, GUI_FontD61x80 Chapter 11: Memory devices - Supchapter Memory requirements and Performance added. Chapter 13: Window manager - Functions added: WM_IsCompletelyVisible(), WM_IsEnabled() - Message added: WM_NOTIFY_VIS_CHANGED - Config macro added: WM_SUPPORT_NOTIFY_VIS_CHANGED Chapter 14: Widgets - WM_... functions moved to Chapter 13 - Functions added: BUTTON_GetDefaultTextAlign(), BUTTON_GetDefaultBkColor(), BUTTON_GetDefaultFont(), BUTTON_GetDefaultTextColor(), BUTTON_SetDefaultTextAlign(), BUTTON_SetDefaultBkColor(), BUTTON_SetDefaultFont(), BUTTON_SetDefaultTextColor(), CHECKBOX_GetDefaultBkColor(), CHECKBOX_GetDefaultFont(), CHECKBOX_GetDefaultSpacing(), CHECKBOX_GetDefaultTextAlign(), CHECKBOX_GetDefaultTextColor(), CHECKBOX_GetState(), CHECKBOX_SetBkColor(), CHECKBOX_SetDefaultBkColor(), CHECKBOX_SetDefaultFont(), CHECKBOX_SetDefaultSpacing(), CHECKBOX_SetDefaultTextAlign(), CHECKBOX_SetDefaultTextColor(), CHECKBOX_SetFont(), CHECKBOX_SetNumStates(), CHECKBOX_SetSpacing(), CHECKBOX_SetState(), CHECKBOX_SetText(), CHECKBOX_SetTextAlign(), CHECKBOX_SetTextColor(), LISTBOX_GetDefaultBkColor(), LISTBOX_GetDefaultTextColor(), LISTBOX_SetDefaultBkColor(), LISTBOX_SetDefaultTextColor() - Config macros added: BUTTON_ALIGN_DEFAULT, BUTTON_REACT_ON_LEVEL, CHECKBOX_BKCOLOR_DEFAULT, CHECKBOX_FONT_DEFAULT, CHECKBOX_IMAGE0_DEFAULT, CHECKBOX_IMAGE1_DEFAULT, CHECKBOX_SPACING_DEFAULT, CHECKBOX_TEXTALIGN_DEFAULT, CHECKBOX_TEXTCOLOR_DEFAULT Chapter 15: Dialogs - Explanation of blocking and non blocking improoved. Chapter 23: Display drivers - LCDLin and LCDLin32 merged to one driver. - Support for S1D13A03, S1D13A04, S1D13A05 and S1D15710 added. Chapter 27: High level configuration - GUI_MAXBLOCKS and GUI_SUPPORT_LARGE_BITMAPS added.
3.82R0
040714
JE
2002-2007 Micrium
11
Manual version
Date
By
Explanation
Chapter 3: Simulator & Viewer - SIM_SetMag added. Chapter 13: Window manager - Sample added to WM_PID_STATE_CHANGED message. - WM_SET_FOCUS added - Config subchapter added (WM_SUPPORT_TRANSPARENCY) - WM_SetTransState() added. Chapter 14: Widgets - New functions added: EDIT_GetNumChars(), EDIT_SetSel(), EDIT_SetpfAddKeyEx(), EDIT_SetInsertMode(), EDIT_SetFloatValue(), RADIO_GetDefaultFont(), RADIO_GetDefaultTextColor(), RADIO_SetBkColor(), RADIO_SetDefaultFont(), RADIO_SetDefaultTextColor(), RADIO_SetFont(), RADIO_SetGroupID(), RADIO_SetText(), RADIO_SetTextColor(), SLIDER_SetNumTicks(). - Explanation added how to use snapping with the slider widget. - Information added to CHECKBOX_CreateEx(). - Description of RADIO_CreateEx() reworked. Chapter 23: Display drivers: - New driver LCDPage4bpp added (support for Sitronix ST7528) - New driver LCD1781 added (support for Solomon SSD1781). - Support for Epson S1D13700 added to LCDSlin driver. - Support for Novatec NT7502, Samsung S6B1713 and Philips PCD8544 added to LCDPage1bpp. - Explanation how to use hardware for display orientation added to LCD07X1 and LCDPage1bpp. Chapter 28: LCD driver API - Chapter moved as subchapter to chapter 23. Chapter 12: Execution model - GUI_X_WAIT_EVENT and GUI_X_SIGNAL_EVENT added Chapter 13: Window manager - Message WM_INIT_DIALOG added. Chapter 14: Widgets - Notification codes added to SLIDER and SCROLLBAR - New functions added: EDIT_SetDefaultTextColor(), EDIT_SetDefaultBkColor(), EDIT_GetDefaultTextColor(), EDIT_GetDefaultBkColor(), EDIT_GetDefaultTextAlign(), DROPDOWN_SetScrollbarWidth() and LISTBOX_SetScrollbarWidth(). - WINDOW widget added. - MESSAGEBOX widget added. - MULTIPAGE widget added. - Creation flag DROPDOWN_CF_UP added. - Effect functions added. Chapter 17: Pointer input devices - From an interrupt routine callable functions denoted. Chapter 18: Keyboard input - From an interrupt routine callable functions denoted. Chapter 27: High level configuraton - Limitation for 16 bit CPUs removed. Chapter 29: Performance and resource usage - Memory requirements reworked.
3.80R0
040503
JE
3.76R0
040123
JE
2002-2007 Micrium
12
Manual version
Date
By
Explanation
Chapter 10: Colors: - New predefined color table (colors added) Chapter 11: Memory devices: - New function GUI_MEMDEV_CreateFixed() added. Chapter 13: Window manager: - Message WM_GET_ID added. - Explanation of window invalidation added. - Creation flags added: WM_CF_ANCHOR_LEFT, WM_CF_ANCHOR_TOP, WM_CF_ANCHOR_RIGHT and WM_CF_ANCHOR_BOTTOM. Chapter 14: Widgets: - Screenshots added to overview and FRAMEWIN widget. - FRAMEWIN_CreateButton-functions renamed to FRAMEWIN_AddButton... - TEXT_SetBkColor() and RADIO_SetBkColor() added. Chapter 17: Pointer input devices: - Explanation of runtime calibration added Chapter 26: Low-Level configuration: - Renamed to Low-Level configuration (LCDConf.h). Chapter 27: High-Level configuration: - Renamed to High-Level configuration (GUIConf.h). - Explanation of GUI_ALLOC_SIZE added. Chapter 2: Getting started: - Explanation added how to adapt the library batch files Chapter 4: Displaying text: - GUI_DispStringInRectEx added. Chapter 13: Window Manager: - Message documentation reworked. - Functions WM_SetID and WM_ForEachDesc added. - Explanation added how to react on a WM_PAINT message. Chapter 8: Fonts: - System independent font support added. - Standard fonts moved to this chapter. Chapter 14: Widget library: - BUTTON_SetTextAlign added. - DROPDOWN_SetItemSpacing added. - EDIT_GetFloatValue added. - EDIT_SetFloatMode added. - LISTBOX_SetItemSpacing added. - LISTVIEW_SetLBorder added. - LISTVIEW_SetRBorder added. - LISTVIEW_SetRowHeight added. - RADIO_SetBkColor added. - SLIDER_SetBkColor added. Chapter 17: Pointer input devices: - Devided into pointer input devices and keyboard input - Pointer input device documentation reworked Chapter 21: Unicode: - How to convert UTF-8 text to C strings added. Chapter 23: Display driver: - Support for UltraChip UC1611 and Hitachi HD66750 added. Chapter 30: Support: - Reworked and renamed to Support.
3.74R0
031219
JE
3.72R0
031204
JE
2002-2007 Micrium
13
Manual version
Date
By
Explanation
Chapter 3: Viewer documentation improved. Chapter 10: Fixed palette modes and color index mask added. Chapter 22: Support for the following LCD controllers added: Fujitsu MB86290A (Cremson), Fujitsu MB86291 (Scarlet), Fujitsu MB86292 (Orchid), Fujitsu MB86293 (Coral Q), Fujitsu MB86294 (Coral B), Fujitsu MB86295 (Coral P), Samsung S6B33B1X and UltraChip UC1606. Chapter 22: Driver LCD180S1 renamed to LCD161620. Chapter 22: Hardware interface descriptions added. Chapter 16: Multi layer sample removed. Chapter 25: Configuration of SPI 3, SPI 4 and I2C bus interface added. Chapter 27: Keil 8051 compiler limitation added Chapter 23: Explanation of config options and GUI_VNC_X_StartServer changed. Chapter 13: Message data explained. Chapter 14: <WIDGET>_CreateEx added, <WIDGET>_Create and <WIDGET>_CreateAsChild obsolete. Chapter 14: Interface from some functions changed from int to unsigned int. Chapter 14.4: Functions added: CHECKBOX_SetDefaultImage, CHECKBOX_SetImage Chapter 14.5: Functions added: DROPDOWN_Collapse, DROPROWN_DeleteItem, DROPDOWN_Expand, DROPDOWN_InsertString, DROPDOWN_SetAutoScroll Chapter 14.13: Functions added: RADIO_SetDefaultImage, RADIO_SetImage Chapter 23 added: VNC support. Chapter 24: SED1520-support added, new driver for Fujitsu MB87J2020 and MB87J2120 added. Chapter 14: Explanation of user draw function improved. Chapter 14.3: BUTTON_IsPressed() added Chapter 14: WIDGET_ITEM_GET_YSIZE added to structure WIDGET_ITEM_DRAW_INFO to enable items with different y sizes. Chapter 11: GUI_MEMDEV_GetDataPtr() added Chapter 13: WM_CF_CONST_OUTLINE added Chapter 24.4: Usage of display orientation macros explained. Chapter 22: LCD501 added. Chapter 22: Chapter 22: controllers. Chapter 13: Chapter 25: Chapter 22: Chapter 22: controllers. Chapter 13: Chapter 25: LCD180S1 and LCD444 added. LCD_CONTROLLER macro definition changed for several LCD WM_MakeModal added. AVR support added. LCD180S1 and LCD444 added. LCD_CONTROLLER macro definition changed for several LCD WM_MakeModal added. AVR support added.
3.70R0
031010
JE
3.62R1
030916
JE
3.62R0
030901
JE
RS JE RS RS JE
3.56R0
030626
JE
3.56R0
030626
JE
3.54R0 3.52R0
030603 030516
JE JE
New chapter 7, "Displaying bitmap files" added. Chapter 12: WM_GetFocussedWindow added Chapter 13: LISTVIEW_DeleteRow and LISTVIEW_DeleteColumn added, LISTVIEW_GetNumColums renamed to LISTVIEW_GetNumColumns Chapter Chapter Chapter Chapter added. Chapter Chapter Chapter Chapter 4: GUI_SetTextStyle added. 6: GUI_SetLineStyle, GUI_GetLineStyle added. 12: WM_BroadcastMessage added. 13: MULTIEDIT_SetPasswordMode and MULTIEDIT_GetTextSize 12: WM_SetStayOnTop and WM_GetStayOnTop added. 13.7: FRAMEWIN_SetBorderSize added. 13.11: MULTIEDIT_SetMaxNumChars added. 14: Multi layer support revised.
3.50R0
030515
JE
3.48R0
030415
JE
2002-2007 Micrium
14
Manual version
3.46R0
Date
030404
By
JE
Explanation
New chapter Multi layer support added. Colors: 86661 mode added. Chapter 18: Revised, UTF-8 support added. Chapter 13.9: LISTBOX_GetFont, LISTBOX_GetItemText, LISTBOX_GetMulti and LISTBOX_SetOwnerDraw added.w Chapter 13: New chapter 13.11 for MULTIEDIT widget added. Chapter 6: GUI_SaveContext and GUI_RestoreContext added. Chapter 12: WM_GetInvalidRect and WM_HasFocus added. Chapter 13.7: FRAMEWIN_SetTextColorEx, FRAMEWIN_Get-DefaultTextColor and FRAMEWIN_SetDefaultTextColor added. Chapter 13.9: LISTBOX_GetItemDisabled, LISTBOX_GetScrollStepH, LISTBOX_SetItemDisabled, LIST-BOX_SetItemSel, LISTBOX_SetScrollStepH, LISTBOX_Get-DefaultScrollStepH and LISTBOX_SetDefaultScrollStepH added. Chapter 13.15: TEXT_SetTextColor and TEXT_SetDefaultText-Color added. Chapter 3: Directory structure changed. Chapter 13: Functions added. Chapter Chapter Chapter Chapter 2: Color and gray scale conversion functions marked as optional. 13.3: Functions added. 13.9: Functions added. 13.13: Functions added.
3.44R0 3.42R1
030319 030303
JE JE
3.42R0
030227
JE
3.40R0
030217
JE
3.38R0
030206
JE
3.36R0 3.34R2
030121 021212
JE JE
Chapter 12: Additional functions added. Chapter 13.7: Additional functions added. Chapter 23: Dynamic memory configuration added. Chapter 12: WM_GetClientRectEx and WM_GetWindowRectEx added. Chapter 13: WM_GetInsideRect and WM_GetInsideRectEx added. Chapter Chapter Chapter Chapter Chapter 4: Additional functions added. 6: Additional functions added. 10: Additional functions added. 12: Additional functions added. 13: Additional functions added.
3.34R1
021127
JE
3.34R0 3.32R0
020926 020920
KG KG
Additional functions added to section 13.5 (Edit widget). Additional function added to Chapter 12 (The Window Manager). BMP file support functions added to Chapter 6 (2-D Graphic Library). Chapter 13 (Window Objects): additional functions documented; message notification codes added. Chapter 12 (The Window Manager) restructured slightly; WM_NOTIFY_PARENT documented. Chapter 18 (Input Devices) moved to after Chapter 14 (Dialogs). Chapter 16 (Cursors) added. Additional function added to section 13.8 (Progress bar widget). Additional controller supported by LCD15XX in Chapter 19 (LCD Drivers). Additional function added to Chapter 18 (Input Devices). EDIT widget: Additional info on flags added. Additional functions added to Chapter 3 (Simulator). Starter kit "Berni" added to section 1.7 (Starter kits). Additional functions added to section 13.7 (List box widget). Headline-level format changes throughout. Modified trial version screen shots in Chapter 3 (Simulator). Chapter 18 (Touch-Screen Support) changed to Input Devices; mouse and keyboard support added; chapter restructured. Slight modifications to section 13.10 (Scroll bar widget). Additional macros added to Chapter 18 (Touch-Screen Support). Chapter 3 (Simulator) modified; addition of use of simulator with trial version of C/GUI. Section 1.7 (Data types) revised.
3.30R1
020919 020912
KG KG KG KG KG RS KG KG KG
3.26R0
020820
KG
3.24R4
020809
KG
2002-2007 Micrium
15
Manual version
3.24R3 3.24R2 3.24R1
Date
020802 020801 020730
By
KG KG KG
Explanation
Additional macros added to sections 22.8 (LCDMem) and 22.9 (LCDMemC); same macros added to Chapter 20 (Low-Level Configuration). Section 2.3 (Creating a library) revised, table and diagram added. Minor changes throughout, including addition of () brackets to all API functions. Chapter 9 (Colors) revised; modes 1, 2, and 444 added. Chapter 11 (Execution Model: Single Task/Multitask) added. Chapter 1 (Introduction to C/GUI) revised. Chapter 2 (Getting Started) revised. Chapter 18 (Time-Related Functions) changed to Timing and ExecutionRelated Functions; GUI_Exec() and GUI_Exec1() added. Small formatting changes throughout. Chapter 18 (C/GUI in Multitasking Environments) merged with Chapter 22 (High-Level Configuration). Chapter 4 (Tutorial) merged with Chapter 2 (Getting Started). Chapter 10 (Colors) revised, color mode table added. GUI_X_ explanations added. Widget description enhanced, screen shots added. Chapter 13 (Window Objects) revised; SCROLLBAR and RADIO widgets added. Chapter 2 (Getting Started) revised. Chapter 14 (Dialogs) revised. Chapter 13 (Window Objects) revised; CHECKBOX, SLIDER and TEXT widgets added. Chapter 14 (Dialogs) added. Chapter 3 (Simulator) revised. Chapter 20 (Low-Level Configuration) revised. Chapter 22 (LCD Drivers) revised. Chapter 12 (The Window Manager) revised. Version control table added. Chapter 11 (Memory Devices) revised. Chapter 14 (Antialiasing) revised. Chapter 9 (Bitmap Converter) revised. Completely revised for language/grammar. Section 1.5 (Typographic conventions) updated. Chapter 8 changed to 7.6 (Font converter). Index revised.
3.24R0
020726
KG
020723 3.22R1 020719 3.22R0 020716 020627 3.20R0 020620 020618 020618 020611 020531 020524 020507 020503
KG
RS KG JE KG KG KG KG KG KG KG KG
3.14R3
3.14R2
3.14R1
020405
KG
2002-2007 Micrium
16
Software versions
Software version Date By Explanation
2-D Graphic Library - Functions GUI_DrawGradientH() and GUI_DrawGradientV() added. Fonts - New font type for using framed fonts added. - XBF format available for extended proportional bitmap fonts. Bitmap Converter - New function for saving the palette available. Foreign Language Support - Character mirroring for RLT aligned text supported. Display Drivers - Support for Solomon SSD1289, Toshiba JBT6K71, Sharp LCYA06003, Samsung S6D0129, MagnaChip D54E4PA7551 and Himax HX8312 added to LCD667XX driver. - Support for Ultrachip UC1617 added to LCD13700 driver. - LCD_CONTROLLER configuration changed for Epson S1D13701, Hitachi HD66750 and Hitachi HD66753 - LCDLin: New driver variant available for 32/16/8 bit access. Low level configuration - Distribution driver added for multiple controller configurations. 2-D Graphic library - New function GUI_SetAlpha() added. - New function GUI_DrawBitmapHWAlpha() added. Bitmap converter - Support for creating alpha blending bitmaps added. Widgets - New functions added: EDIT_EnableBlink(), MULTIEDIT_EnableBlink(), MENU_GetOwner(), MENU_SetSel() - New menu messages added: MENU_ON_ITEMACTIVATE, MENU_ON_ITEMPRESSED Display drivers - Support for Renesas R61509 and R63401 added to LCD667XX. - 24 and 32 bpp mode added to LCDLin - Support for Sitronix ST7522 added to LCDPage1bpp Displaying values - Number of digits in GUI_DispDec...() increased to 10. Fonts - TrueType support added. - New fonts added: GUI_Font20_ASCII, GUI_Font20_1, GUI_Font20B_ASCII added, GUI_Font20B_1. Displaying bitmap files - BMP files: Support for RLE4, RLE8 and 16bpp format added. Colors - New fixed palette mode 5 added. Window manager - New functions added: WM_CreateTimer(), WM_DeleteTimer(), WM_RestartTimer() Widgets - New functions added: DROPDOWN_SetItemDisabled() DROPDOWN_GetItemDisabled() Multi layer support - New functions added: GUI_AssignCursorLayer, GUI_SetLayerAlphaEx(), GUI_SetLayerVisEx(), GUI_SetLayerSizeEx(), GUI_SetLayerPosEx() Display drivers - LCD7529 now works without cache and in 4bpp mode. Widget library: - New function MULTIPAGE_SetRotation() added.
4.10R0
070511
JE
4.08
070131
JE
4.06
061006
JE
4.04
060505
JE
2002-2007 Micrium
17
Software version
Date
By
Explanation
Displaying bitmap files: - Support for 32bpp BMP files added. - New JPEG decoder added. Widget library: - Widget schemes added. - New functions added: LISTVIEW_SetFixed(), MULTIEDIT_SetTextAlign() Colors: _ Fixed palette modes added: 666, M666, 888, M888, 8888, M8888, 84444, 822216, -1 Bitmap converter: - New bitmap formats 888, M888, RLE16 and RLEM16 added. 2-D graphic library: - New functions GUI_GetTrailingBlankCols() and GUI_GetLeadingBlankCols() added. Multi layer support - Support for up to 6 layers/displays added. Display drivers: - New drivers added: LCD13700.c, LCD7529.c, LCD7920.c, LCD8822.c. Fonts: - New functions for using external bitmap fonts added: GUI_XBF_CreateFont(), GUI_XBF_DeleteFont() Displaying bitmap files: - Function GUI_GIF_DrawEx() renamed to GUI_GIF_DrawSub() - New functions added: GUI_BMP_GetYSizeEx(), GUI_BMP_DrawEx(), GUI_BMP_DrawScaled(), GUI_BMP_DrawScaledEx(), GUI_GIF_DrawEx(), GUI_GIF_DrawSubEx(), GUI_GIF_DrawSubScaled(), GUI_GIF_DrawSubScaledEx(), GUI_GIF_GetCommentEx(), GUI_GIF_GetImageInfoEx(), GUI_GIF_GetInfoEx(), GUI_GIF_GetXSizeEx(), GUI_GIF_GetYSizeEx() Widgets: - GUI_KEY_PGUP and GUI_KEY_PGDOWN now can be used to switch to the next / previous page of a MULTIPAGE widget. Dialogs: - GUI_KEY_BACKTAB now can be used to move the input focus to the previous dialog item. Foreign language support: - GUI_SUPPORT_ARABIC has been replaced by GUI_SUPPORT_BIDI Fonts: - New font type with extended character information added.
4.02
060502
JE
4.01
060131
JE
4.00
051222
JE
2002-2007 Micrium
18
Software version
Date
By
Explanation
Displaying text - New function GUI_DispStringInRectWrap() added. Displaying bitmap files - New function GUI_GIF_DrawEx() added. - New function GUI_GIF_GetInfo() added. - New function GUI_JPEG_DrawEx() added. - New function GUI_JPEG_DrawScaled() added. - New function GUI_JPEG_DrawScaledEx() added. - New function GUI_JPEG_GetInfoEx() added. - Memory requirement of JPEG decompression changed. Memory devices - New function GUI_MEMDEV_MarkDirty() added. Window manager - New message WM_MOUSEOVER_END added. Widgets - New function EDIT_GetCursorCharPos() added. - New function EDIT_GetCursorPixelPos() added. - New function EDIT_SetUlongMode() added. - New function GRAPH_DATA_XY_SetLineStyle() added. - New function HEADER_SetDragLimit() added. - New function LISTVIEW_CompareDec() added. - New function LISTVIEW_CompareText() added. - New function LISTVIEW_DisableSort() added. - New function LISTVIEW_EnableSort() added. - New function LISTVIEW_GetSelUnsorted() added. - New function LISTVIEW_GetUserData() added. - New function LISTVIEW_InsertRow() added. - New function LISTVIEW_SetAutoScrollH() added. - New function LISTVIEW_SetAutoScrollV() added. - New function LISTVIEW_SetCompareFunc() added. - New function LISTVIEW_SetSelUnsorted() added. - New function LISTVIEW_SetSort() added. - New function LISTVIEW_SetUserData() added. - New function MENU_Popup() added. - New function MULTIEDIT_GetCursorPixelPos() added. - New function MULTIEDIT_GetCursorCharPos() added. - New function MULTIEDIT_AddText() added. - New function TEXT_SetWrapMode() added. - New function TEXT_SetDefaultWrapMode() added. - New config option LISTVIEW_SCROLLSTEP_H_DEFAULT added. - Keyboard support of LISTVIEW widget enhanced. - New config option WIDGET_USE_PARENT_EFFECT. - New config option GUI_MESSAGEBOX_CF_MOVEABLE. - New config option FRAMEWIN_ALLOW_DRAG_ON_FRAME. - Notification messages added to EDIT widget. - New config option SCROLLBAR_THUMB_SIZE_MIN_DEFAULT. Cursors - New function GUI_CURSOR_GetState() added. Display drivers - LCDSLin: Support for RAIO 8822/8803/8835 added. - LCD667XX: Support for Sharp LR38825 and Samsung S6D0117 added. - LCDPage1bpp: Support for UltraChip UC1601 added.
3.98
051109
JE
2002-2007 Micrium
19
Software version
Date
By
Explanation
2-D Graphic Library - New function GUI_GetDrawMode() added. Fonts - Antialiased SIF fonts added. Memory devices - New function GUI_MEMDEV_WriteEx() added. - New function GUI_MEMDEV_WriteExAt() added. Window manager - New function WM_GetCallback() added. Widgets - Interface of SCROLLBAR_SetColor() changed. - New GRAPH widget added. - New function BUTTON_GetBitmap() added. - New function CHECKBOX_GetText() added. - New function DROPDOWN_SetColor() added. - New function DROPDOWN_SetDefaultColor() added. - New function DROPDOWN_SetDefaultScrollbarColor() added. - New function DROPDOWN_SetScrollbarColor() added. - New function LISTBOX_SetScrollbarColor() added. - New function RADIO_GetText() added. Foreign languages - Arabic support added. Display drivers - LCD667XX driver: Support for Samsung S6D0110A added. - LCD07X1 driver: Support for Sitronix ST7541 added. - LCD66750 driver: Support for Hitachi HD66753 added.
3.96
050719
2002-2007 Micrium
20
Software version
Date
By
Explanation
Viewer - Virtual screen support added. 2-D Graphic Library - New function GUI_SetClipRect() added. Displaying bitmap files - GIF file support added. Bitmap converter - GIF file support added. Memory devices - Support for 1bpp memory devices added. Window manager - New function WM_SetWindowPos() added. - New function WM_GetScrollPosH() added. - New function WM_GetScrollPosV() added. - New function WM_SetScrollPosH() added. - New function WM_SetScrollPosV() added. Widgets - BUTTON: New function BUTTON_SetDefaultFocusColor(). - BUTTON: New function BUTTON_SetFocusColor(). - BUTTON: New config option BUTTON_FOCUSCOLOR_DEFAULT. - CHECKBOX: New function CHECKBOX_SetBoxBkColor(). - CHECKBOX: New function CHECKBOX_SetDefaultFocusColor(). - CHECKBOX: New function CHECKBOX_SetFocusColor(). - CHECKBOX: Notification WM_NOTIFICATION_VALUE_CHANGED added. - CHECKBOX: Image of unchecked state can now be set. - EDIT: New function EDIT_SetTextMode() added. - LISTBOX: New function LISTBOX_GetDefaultTextAlign() added. - LISTBOX: New function LISTBOX_GetTextAlign() added. - LISTBOX: New function LISTBOX_SetDefaultTextAlign() added. - LISTBOX: New function LISTBOX_SetTextAlign() added. - LISTBOX: New color index LISTBOX_CI_DISABLED added. - LISTVIEW: New color index LISTVIEW_CI_DISABLED added. - MENU: Keyboard support added. - PROGBAR: Vertical progress bar supported. - RADIO: New function RADIO_SetDefaultFocusColor() added. - RADIO: New function RADIO_SetFocusColor() added. - RADIO: Config options reworked. - SCROLLBAR: New function SCROLLBAR_SetColor() added. - SCROLLBAR: New function SCROLLBAR_SetDefaultColor() added. - SLIDER: New function SLIDER_SetDefaultFocusColor() added. - SLIDER: New function SLIDER_SetFocusColor() added. - Widget callback functions exported. Antialiasing - New function GUI_AA_DrawPolyOutlineEx() added. Unicode - New function GUI_UC_ConvertUC2UTF8() added. - New function GUI_UC_ConvertUTF82UC() added.
3.94
050329
JE
2002-2007 Micrium
21
Software version
Date
By
Explanation
Display drivers - New driver LCD0323 for Solomon SSD0323 controller added. - New driver LCD1200 for Toppoly C0C0 and C0E0 controller added. - New driver LCD13701 for Epson S1D13701 controller added. - New driver LCDNoritake for Noritake displays added. - New driver LCD667XX for Hitachi HD66772, HD66766 controller added. - New driver LCDXylon added. - LCDLin driver: New config macro LCD_FILL_RECT added. - LCDLin driver: New config macro LCD_LIN_SWAP added. - LCDLin driver: 32 bit version now supports 1 and 2 bpp color depth. Simulator and Viewer - The simulatior now can easily be used with other simulations. Window manager - New functions added: WM_PaintWindowAndDescs(), WM_Update() and WM_UpdateWindowAndDescs(). Widgets - Flag GUI_MESSAGEBOX_CF_MODAL added for creating a modal message box. - Notification codes added to MULTIPAGE widget. - New functions added: LISTVIEW_DisableRow(), LISTVIEW_EnableRow() and LISTVIEW_GetItemText(). Virtual screen support - New functions GUI_GetOrg() and GUI_SetOrg(). Display driver - Support for Sitronix ST7565 added to Page1bpp driver. - LCDLin driver (8/16 bit): LCD_SET_LUT_ENTRY added. Chapter 13: Window manager - New function WM_GetPrevSibling() added. - New message WM_MOUSEOVER added. - New create flag WM_CF_MEMDEV_ON_REDRAW added. Chapter 14: Widgets - MENU widget added. - WM_NOTIFICATION_SCROLL_CHANGED added to DROPDOWN, LISTBOX, LISTVIEW and MULTIEDIT - BUTTON widget: Support for disabled state added. - New functions added: DROPDOWN_SetTextHeight(), DROPDOWN_SetTextAlign(), FRAMEWIN_AddMenu(), FRAMEWIN_SetResizeable(), LISTVIEW_GetBkColor(), LISTVIEW_GetTextColor(), LISTVIEW_SetItemTextColor(), LISTVIEW_SetItemBkColor() Chapter 23: Display driver - Support for Solomon SSD1815 added to Page1bpp driver
3.92
041021
JE
3.90
040818
JE
2002-2007 Micrium
22
Software version
Date
By
Explanation
Chapter 13: Window manager - Functions added: WM_IsCompletelyVisible(), WM_IsEnabled() - Message added: WM_NOTIFY_VIS_CHANGED - Config macro added: WM_SUPPORT_NOTIFY_VIS_CHANGED Chapter 14: Widgets - Functions added: BUTTON_GetDefaultAlign(), BUTTON_GetDefaultBkColor(), BUTTON_GetDefaultFont(), BUTTON_GetDefaultTextColor(), BUTTON_SetDefaultAlign(), BUTTON_SetDefaultBkColor(), BUTTON_SetDefaultFont(), BUTTON_SetDefaultTextColor(), CHECKBOX_GetDefaultBkColor(), CHECKBOX_GetDefaultFont(), CHECKBOX_GetDefaultSpacing(), CHECKBOX_GetDefaultTextAlign(), CHECKBOX_GetDefaultTextColor(), CHECKBOX_GetState(), CHECKBOX_SetBkColor(), CHECKBOX_SetDefaultBkColor(), CHECKBOX_SetDefaultFont(), CHECKBOX_SetDefaultSpacing(), CHECKBOX_SetDefaultTextAlign(), CHECKBOX_SetDefaultTextColor(), CHECKBOX_SetFont(), CHECKBOX_SetNumStates(), CHECKBOX_SetSpacing(), CHECKBOX_SetState(), CHECKBOX_SetText(), CHECKBOX_SetTextAlign(), CHECKBOX_SetTextColor(), LISTBOX_GetDefaultBkColor(), LISTBOX_GetDefaultTextColor(), LISTBOX_SetDefaultBkColor(), LISTBOX_SetDefaultTextColor() - Config macros added: BUTTON_ALIGN_DEFAULT, BUTTON_REACT_ON_LEVEL, CHECKBOX_BKCOLOR_DEFAULT, CHECKBOX_FONT_DEFAULT, CHECKBOX_IMAGE0_DEFAULT, CHECKBOX_IMAGE1_DEFAULT, CHECKBOX_SPACING_DEFAULT, CHECKBOX_TEXTALIGN_DEFAULT, CHECKBOX_TEXTCOLOR_DEFAULT Chapter 23: Display drivers - Support for S1D13A03, S1D13A04 and S1D13A05 added. Simulator & Viewer - SIM_SetMag added. Widgets - New functions added: EDIT_GetNumChars(), EDIT_SetSel(), EDIT_SetpfAddKeyEx(), EDIT_SetInsertMode(), EDIT_SetFloatValue(), RADIO_GetDefaultFont(), RADIO_GetDefaultTextColor(), RADIO_SetBkColor(), RADIO_SetDefaultFont(), RADIO_SetDefaultTextColor(), RADIO_SetFont(), RADIO_SetGroupID(), RADIO_SetText(), RADIO_SetTextColor(), SLIDER_SetNumTicks(). Display drivers: - New driver LCDPage4bpp added (support for Sitronix ST7528) - New driver LCD1781 added (support for Solomon SSD1781). - Support for Novatec NT7502, Samsung S6B1713 and Philips PCD8544 added to LCDPage1bpp. Widgets - Notification codes added to SLIDER and SCROLLBAR - EDIT_SetDefaultTextColor() added. - EDIT_SetDefaultBkColor() added. - EDIT_GetDefaultTextColor() added. - EDIT_GetDefaultBkColor() added. - EDIT_GetDefaultTextAlign() added. - DROPDOWN_SetScrollbarWidth() added. - LISTBOX_SetScrollbarWidth() added. Memory allocation: - Limitation for 16 bit CPUs removed.
3.82
040714
JE
3.80
0040503
JE
3.76
040123
JE
2002-2007 Micrium
23
Software version
Date
By
Explanation
Colors: - GUI_MAGENTA changed from 0x8b008b to 0xFF00FF Memory devices: - New function GUI_MEMDEV_CreateFixed() added. Widgets: - FRAMEWIN_CreateButton-functions renamed to FRAMEWIN_AddButton... - New functions TEXT_SetBkColor() and RADIO_SetBkColor() added. Chapter 4: Displaying text: - GUI_DispStringInRectEx added. Chapter 13: Window Manager: - Functions WM_SetID and WM_ForEachDesc added. Chapter 8: Fonts: - System independent font support added. Chapter 14: Widget library: - BUTTON_SetTextAlign added. - DROPDOWN_SetItemSpacing added. - EDIT_GetFloatValue added. - EDIT_SetFloatMode added. - LISTBOX_SetItemSpacing added. - LISTVIEW_SetLBorder added. - LISTVIEW_SetRBorder added. - LISTVIEW_SetRowHeight added. - RADIO_SetBkColor added. - SLIDER_SetBkColor added. Chapter 23: Display driver: - Support for UltraChip UC1611 and Hitachi HD66750 added. Support for the following LCD controllers added: Fujitsu MB86290A (Cremson), Fujitsu MB86291 (Scarlet), Fujitsu MB86292 (Orchid), Fujitsu MB86293 (Coral Q), Fujitsu MB86294 (Coral B), Fujitsu MB86295 (Coral P), Samsung S6B33B1X and UltraChip UC1606. VNC support added. Functions added to DROPDOWN, CHECKBOX and RADIO widget Support for Epson SED1520 added. Support for Fujitsu MB87J2020 and MB87J2120 added. GUI_MEMDEV_GetDataPtr() added WM_CF_CONST_OUTLINE added JPEG file support added. Functions added to LISTVIEW widget. WM_GetFocussedWindow added to window manager. Core functions added. Functions added to window manager. Functions added to window manager. Functions added to widgets. Multi layer support added. UTF-8 support added MULTIEDIT widget added. User drawn LISTBOX added. Functions added to window manager. Functions added to FRAMEWIN widget. Multi selection mode added to LISTBOX widget. Multi selection mode added to LISTBOX widget. Activation of frame windows changed. Functions added to SCROLLBAR widget, BUTTON widget and LISTBOX widget. Functions added to FRAMEWIN widget and window manager. Dynamic memory support added. EDIT_SetCursorAtChar() and EDIT_SetCursorAtPixel() added.
3.74
031219
JE
3.72
031204
JE
3.70
031010
JE
3.62
030901
JE
RS RS JE RS JE JE JE
JE JE JE JE RS
2002-2007 Micrium
24
Software version
3.32 3.30 3.28
Date
020920 020912 020903
By
RS RS RS
Explanation
WM_SetpfPollPID() added. BMP file support added. Cursor support added. GUI_TOUCH_StoreStateEx() added. Edit widget: flags added. Simulation: additional options for simulation of colored monochrome displays added. SIM_SetLCDColorBlack() and SIM_SetLCDColorWhite() added. New starter kit. LISTBOX_AddString() and LISTBOX_GetNumItems() added. Mouse and keyboard support added. Mouse and keyboard support added. GUI_Exec() and GUI_Exec1() added. Support for 444 color mode added Scrollbars, Radio buttons added. Dialog boxes added. Slider added. Check box added. 3D effects added.
RS RS RS RS RS RS
2002-2007 Micrium
25
Table of Contents
1 Introduction to C/GUI ...................................................................................................31
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 Purpose of this document ......................................................................... 31 Assumptions ........................................................................................... 31 Requirements.......................................................................................... 32 C/GUI features ...................................................................................... 32 Samples and demos................................................................................. 34 How to use this manual ............................................................................ 34 Typographic conventions for syntax ........................................................... 34 Screen and coordinates ............................................................................ 35 How to connect the LCD to the microcontroller ............................................ 35 Data types.............................................................................................. 37
2 Getting Started...............................................................................................................39
2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 Recommended directory structure.............................................................. 40 Adding C/GUI to the target program......................................................... 41 Creating a library..................................................................................... 41 "C" files to include in the project................................................................ 43 Configuring C/GUI.................................................................................. 44 Initializing C/GUI ................................................................................... 45 Using C/GUI with target hardware............................................................ 45 The "Hello world" sample program ............................................................. 45
3 Simulator........................................................................................................................49
3.1 3.2 3.3 Using the simulator.................................................................................. 50 Device simulation .................................................................................... 54 Integrating the C/GUI simulation into an existing simulation ........................ 62
Viewer ...........................................................................................................................69
4.1 Using the viewer...................................................................................... 70
26
Displaying decimal values......................................................................... 92 Displaying floating-point values................................................................. 96 Displaying binary values........................................................................... 99 Displaying hexadecimal values .................................................................100 Version of C/GUI ..................................................................................101
9 Fonts ............................................................................................................................157
9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 9.10 9.11 9.12 9.13 9.14 9.15 Introduction ..........................................................................................158 Font types.............................................................................................158 Font formats..........................................................................................159 Converting a TTF file to C source ............................................................162 Declaring custom fonts ...........................................................................162 Selection of a font ..................................................................................162 Font API................................................................................................163 C file related font functions ....................................................................163 SIF file related font functions..................................................................164 TTF file related font functions .................................................................166 XBF file related font functions.................................................................169 Common font-related functions ................................................................171 Character sets .......................................................................................176 Font converter .......................................................................................179 Standard fonts.......................................................................................180
2002-2007 Micrium
27
10.7 10.8
BmpCvt.exe: Command line usage........................................................... 221 Example of a converted bitmap ............................................................... 222
11 Colors.........................................................................................................................227
11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.10 11.11 Predefined colors ................................................................................... 228 The color bar test routine ....................................................................... 228 Fixed palette modes............................................................................... 230 Default fixed palette modes .................................................................... 232 Detailed fixed palette mode description .................................................... 232 Custom palette modes............................................................................ 243 Modifying the color lookup table at run time .............................................. 243 Color API .............................................................................................. 244 Basic color functions .............................................................................. 244 Index & color conversion ........................................................................ 246 Lookup table (LUT) group ....................................................................... 247
28
15.1 15.2 15.3 15.4 15.5 15.6 15.7 15.8 15.9 15.10 15.11 15.12 15.13 15.14 15.15 15.16 15.17 15.18 15.19 15.20 15.21 15.22
Some basics ..........................................................................................350 Configuration options..............................................................................353 General widget API.................................................................................354 BUTTON: Button widget ..........................................................................359 CHECKBOX: Check box widget .................................................................378 DROPDOWN: Dropdown widget ................................................................394 EDIT: Edit widget ...................................................................................407 FRAMEWIN: Frame window widget............................................................427 GRAPH: Graph widget .............................................................................453 HEADER: Header widget..........................................................................480 LISTBOX: List box widget ........................................................................495 LISTVIEW: Listview widget ......................................................................520 MENU: Menu widget ...............................................................................546 MESSAGEBOX: Message box widget..........................................................567 MULTIEDIT: Multi line text widget.............................................................569 MULTIPAGE: Multiple page widget ............................................................582 PROGBAR: Progress bar widget ................................................................597 RADIO: Radio button widget ....................................................................606 SCROLLBAR: Scroll bar widget .................................................................618 SLIDER: Slider widget.............................................................................626 TEXT: Text widget ..................................................................................633 WINDOW: Window widget .......................................................................639
16 Dialogs .......................................................................................................................641
16.1 16.2 16.3 16.4 16.5 Dialog basics .........................................................................................642 Creating a dialog....................................................................................642 API reference: dialogs.............................................................................646 Dialog boxes..........................................................................................646 Message boxes ......................................................................................648
20 Keyboard Input...........................................................................................................693
User's & reference manual for C/GUI 2002-2007 Micrium
29
20.1
21 Sprites........................................................................................................................697
21.1 21.2 Introducton .......................................................................................... 698 Sprite API............................................................................................. 698
22 Cursors ......................................................................................................................703
22.1 22.2 Available cursors ................................................................................... 704 Cursor API ............................................................................................ 704
23 Antialiasing.................................................................................................................707
23.1 23.2 23.3 23.4 23.5 Introduction.......................................................................................... 708 Antialiasing API ..................................................................................... 711 Control functions ................................................................................... 711 Drawing functions.................................................................................. 712 Examples ............................................................................................. 716
(LCDConf.h) .................................................................845
Available configuration macros ................................................................ 846 General (required) configuration .............................................................. 848 Initialisation of the controller................................................................... 850 Display orientation................................................................................. 851 Color configuration ................................................................................ 854 Magnifying the LCD................................................................................ 855 Simple bus interface configuration ........................................................... 856 3 pin SPI configuration ........................................................................... 859 4 pin SPI configuration ........................................................................... 860 I2C bus interface configuration ................................................................ 862 Full bus interface configuration ................................................................ 864 Virtual display support............................................................................ 868
2002-2007 Micrium
30
LCD controller configuration: COM/SEG lines..............................................869 Configuring multiple display controllers .....................................................871 COM/SEG lookup tables ..........................................................................873 Miscellaneous ........................................................................................874
31 Support ......................................................................................................................897
31.1 31.2 31.3 31.4 31.5 31.6 Problems with tool chain (compiler, linker) ................................................898 Problems with hardware/driver ................................................................899 Problems with API functions.....................................................................900 Problems with the performance ................................................................901 Contacting support .................................................................................901 FAQs ...................................................................................................902
32 Index ..........................................................................................................................905
2002-2007 Micrium
31
1.1
1.2
Assumptions
This guide assumes that you already possess a solid knowledge of the "C" programming language. If you feel that your knowledge of "C" is not sufficient, we recommend The "C" Programming Language by Kernighan and Richie, which describes the programming standard and, in newer editions, also covers the ANSI "C" standard. Knowledge of assembly programming is not required.
2002-2007 Micrium
32
CHAPTER 1
Introduction to C/GUI
1.3 Requirements
A target system is not required in order to develop software with C/GUI; most of the software can be developed using the simulator. However, the final purpose is usually to be able to run the software on a target system.
1.3.1
Your target system must: Have a CPU (8/16/32/64 bits) Have a minimum of RAM and ROM Have a full graphic LCD (any type and any resolution) The memory requirements vary depending on which parts of the software are used and how efficient your target compiler is. It is therefore not possible to specify precise values, but the following apply to typical systems.
Note that ROM requirements will increase if your application uses many fonts. All values are rough estimates and cannot be guaranteed.
1.3.2
The CPU used is of no importance; only an ANSI-compliant "C" compiler covering the international standard ISO/IEC 9899:1990, ISO/IEC 9899:1999 or ANSI/ISO 9899:1990 is required. If your compiler has some limitations, please let us know and we will inform you if these will be a problem when compiling the software. Any compiler for 16/32/64-bit CPUs or DSPs that we know of can be used; most 8-bit compilers can be used as well. A C++ compiler is not required, but can be used. The application program can therefore also be programmed in C++ if desired.
General
Any 8/16/32-bit CPU; only an ANSI "C" compiler is required. Any (monochrome, grayscale or color) LCD with any controller supported (if the right driver is available).
2002-2007 Micrium
33
May work without LCD controller on smaller displays. Any interface supported using configuration macros. Display-size configurable. Characters and bitmaps may be written at any point on the LCD, not just on even-numbered byte addresses. Routines are optimized for both size and speed. Compile time switches allow for different optimizations. For slower LCD controllers, LCD can be cached in memory, reducing access to a minimum and resulting in very high speed. Clear structure. Virtual display support; the virtual display can be larger than the actual display. Bitmaps of different color depths supported. Bitmap converter available. Absolutely no floating-point usage. Fast line/point drawing (without floating-point usage). Very fast drawing of circles/polygons. Different drawing modes. A variety of different fonts are shipped with the basic software: 4*6, 6*8, 6*9, 8*8, 8*9, 8*16, 8*17, 8*18, 24*32, and proportional fonts with pixel-heights of 8, 10, 13, 16. For more information, see Chapter 30: "Standard Fonts". New fonts can be defined and simply linked in. Only the fonts used by the application are actually linked to the resulting executable, resulting in minimum ROM usage. Fonts are fully scalable, separately in X and Y. Font converter available; any font available on your host system (i.e. Microsoft Windows) can be converted. Routines to show values in decimal, binary, hexadecimal, any font. Routines to edit values in decimal, binary, hexadecimal, any font. Complete window management including clipping. Overwriting of areas outside a windows client area is impossible. Windows can be moved and resized. Callback routines supported (usage optional). WM uses minimum RAM (app. 20 bytes per window). Widgets (window objects, also known as controls) are available. They generally operate automatically and are simple to use. For window objects such as the button widget, C/GUI offers touch-screen and mouse support. Simulation plus viewer. Bitmap converter. Font converter.u
Graphic library
Fonts
PC tools
2002-2007 Micrium
34
CHAPTER 1
Introduction to C/GUI
1.5
1.7
Used for
2002-2007 Micrium
35
(0,0)
The horizontal scale is called the X-axis, whereas the vertical scale is called the Yaxis. Coordinates are denoted as a pair consisting of an X- and a Y-value (X, Y). The X-coordinate is always first in routines that require X and Y coordinates. The upper left corner of the display (or a window) has per default the coordinates (0,0). Positive X-values are always to the right; positive Y-values are always down. The above graph illustrates the coordinate system and directions of the X- and Y- axes. All coordinates passed to an API function are always specified in pixels.
36
CHAPTER 1
Introduction to C/GUI
the accesses to the LCD, the LCD update is not slowed down significantly. All that needs to be done is to define routines or macros which set or read the hardware ports/buffers that the LCD is connected to. This type of interface is also supported by different drivers for the different LCD controllers.
2002-2007 Micrium
37
Definition
signed char unsigned char signed short unsigned short signed long unsigned long signed short unsigned short 8-bit signed value 16-bit unsigned value 16-bit signed value 16-bit unsigned value 32-bit signed value 32-bit unsigned value
Explanation
16-bit (or more) signed value 16-bit (or more) unsigned value
For most 16/32-bit controllers, the settings will work fine. However, if you have similar defines in other sections of your program, you might want to change or relocate them. A recommended place is in the configuration file LCDConf.h.
2002-2007 Micrium
38
CHAPTER 1
Introduction to C/GUI
2002-2007 Micrium
39
The following chapter provides an overview of the basic procedures for setting up and configuring C/GUI on your target system. It also includes a simple program example. If you find yourself unsure about certain areas, keep in mind that most topics are treated in greater detail in later chapters. You will most likely need to refer to other parts of the manual before you begin more complicated programming.
2002-2007 Micrium
40
CHAPTER 2
Getting Started
2.1
2.1.1
Subdirectories
Directory Contents
Configuration files Antialiasing support * Color conversion routines used for grayscale displays * Color conversion routines used for color displays * C/GUI core files Font files LCD driver Memory device support * Widget library * Window manager *
Config GUI\AntiAlias GUI\ConvertMono GUI\ConvertColor GUI\Core GUI\Font GUI\LCDDriver GUI\MemDev GUI\Widget GUI\WM
(* = optional)
2.1.2
Include directories
Config GUI\Core GUI\Widget (if using widget library) GUI\WM (if using window manager)
You should make sure that the include path contains the following directories (the order of inclusion is of no importance):
Warning: Always make sure that you have only one version of each file!
It is frequently a major problem when updating to a new version of C/GUI if you have old files included and therefore mix different versions. If you keep C/GUI in the directories as suggested (and only in these), this type of problem cannot occur. When updating to a newer version, you should be able to keep your configuration files and leave them unchanged. For safety reasons, we recommend backing (or at least renaming) the GUI\ directories prior to updating.
2002-2007 Micrium
41
2.2
2.3
Creating a library
Building a library from the sources is a simple procedure. The first step is to copy the batch files (located under Sample\Makelib) into your root directory. Then, make any neccesary changes. There are a total of four batch files which need to be copied, described in the table below. The main file, Makelib.bat, will be the same for all systems and requires no changes. To build a library for your target system, you will normally need to make slight modifcations to the other three smaller files. Finally, start the file Makelib.bat to create the library. The batch files assume that your GUI and Config subdirectories are set up as recommended. The procedure for creating a library is illustrated in the flow chart to the right. The Makelib.bat file first calls Prep.bat to prepare the environment for the tool chain. Then it calls CC.bat for every file to be included in the library. It does this as many times as necessary. CC.bat adds each object file to a list that will be used by lib.bat. When all files to be added to the library have been listed, Makelib.bat then calls lib.bat, which uses a librarian to put the listed object files into the actual library. File
Makelib.bat Prep.bat CC.bat lib.bat
Makelib.bat
Prep.bat
CC.bat
No All files in library?
Yes
lib.bat
Explanation
Main batch file. No modification required. Called by Makelib.bat to prepare environment for the tool chain to be used, Called by Makelib.bat for every file to be added to the library; creates a list of these object files which will then be used in the next step by the librarian in the lib.bat file. Called by Makelib.bat to put the object files listed by CC.bat into a library.
The files as shipped assume that a Microsoft compiler is installed in its default location. If all batch files are copied to the root directory (directly above GUI) and no changes are made at all, a simulation library will be generated for the C/GUI simulation. In order to create a target library, however, it will be necessary to modify Prep.bat, CC.bat, and lib.bat.
2002-2007 Micrium
42
CHAPTER 2
Getting Started
2.3.1
The following will show how to adapt the files by a sample adaptation for a Mitsubishi M32C CPU.
Adapting Prep.bat
Prep.bat is called at the beginning of Makelib.bat. As described above its job is to set the environment variables for the used tools and the environment variable PATH, so that the batch files can call the tools without specifying an absolute path. Assuming the compiler is installed in the folder C:\MTOOL the file Prep.bat could look as follows:
@ECHO OFF SET TOOLPATH=C:\MTOOL REM ****************************************************************** REM Set the variable PATH to be able to call the tools SET PATH=%TOOLPATH%\BIN;%TOOLPATH%\LIB308;%PATH% REM ****************************************************************** REM Set the tool internal used variables SET SET SET SET BIN308=%TOOLPATH%\BIN INC308=%TOOLPATH%\INC308 LIB308=%TOOLPATH%\LIB308 TMP308=%TOOLPATH%\TMP
Adapting CC.bat
The job of CC.bat is to compile the passed source file and adding the file name of the object file to a link list. When starting MakeLib.bat it creates the following subdirectories relative to its position: Directory
Lib Temp\Output Temp\Source
Contents
This folder should contain the library file after the build process. Should contain all the compiler output and the link list file. Will be deleted after the build process.
MakeLib.bat uses this folder to copy all source and header files used for the
build process. Will be deleted after the build process.
The object file should be created (or moved) to Temp\Output. This makes sure all the output will be deleted after the build process. Also the link list should be located in the output folder. The following shows a sample for the Mitsubishi compiler:
@ECHO OFF GOTO START REM ****************************************************************** REM Explanation of the used compiler options: -silent : Suppresses the copyright message display at startup -M82 : Generates object code for M32C/80 Series (Remove this switch for M16C80 targets) -c : Creates a relocatable file (extension .r30) and ends processing -I : Specifies the directory containing the file(s) specified in #include -dir : Specifies the destination directory -OS : Maximum optimization of speed followed by ROM size -fFRAM : Changes the default attribute of RAM data to far -fETI : Performs operation after extending char-type data to the int type (Extended according to ANSI standards) :START REM ******************************************************************
2002-2007 Micrium
43 REM Compile the passed source file with the Mitsubishi NC308 compiler
NC308 -silent -M82 -c -IInc -dir Temp\Output -OS -fFRAM -fETI Temp\Source\%1.c REM ****************************************************************** REM Pause if any problem occurs IF ERRORLEVEL 1 PAUSE REM ****************************************************************** REM Add the file name of the object file to the link list ECHO Temp\Output\%1.R30>>Temp\Output\Lib.dat
Adapting Lib.bat
After all source files have been compiled Lib.bat will be called from MakeLib.bat. The job is to create a library file using the link list created by CC.bat. The destination folder of the library file should be the Lib folder created by MakeLib.bat. The following shows a sample for the Mitsubishi librarian:
@ECHO OFF GOTO START REM ****************************************************************** REM Explanation of the used options: -C : Creates new library file @ : Specifies command file :START REM ****************************************************************** REM Create the first part of the linker command file ECHO -C Lib\GUI>Temp\Output\PARA.DAT REM ****************************************************************** REM Merge the first part with the link list to the linker command file COPY Temp\Output\PARA.DAT+Temp\Output\Lib.dat Temp\Output\LINK.DAT REM ****************************************************************** REM Call the Mitsubishi librarian LB308 @Temp\Output\LINK.DAT REM ****************************************************************** REM Pause if any problem occurs IF ERRORLEVEL 1 PAUSE
2.4
2002-2007 Micrium
44
CHAPTER 2
Getting Started
Antialiasing: all "C" files located in GUI\AntiAlias Memory devices: all "C" files located in GUI\MemDev Widget library: all "C" files located in GUI\Widget Window Manager: all "C" files located in GUI\WM GUI_X.c. A sample file is available as Sample\GUI_X. This file contains the hardware-dependent part of C/GUI and should be modified as described in Chapter 29: "High-Level Configuration".
Target specifics
Be sure that you include GUI.h in all of your source files that access C/GUI.
2.5
Configuring C/GUI
The Config folder should contain the configuration files matching your order. The file LCDConf.h normally contains all the definitions necessary to adopt C/GUI to your LCD, which is the main task when configuring C/GUI. For details, please see Chapter 28: "Low-Level Configuration". If C/GUI is not configured correctly, because you did not select the right display resolution or chose the wrong LCD controller, it will probably not display anything at all or display something that does not resemble what you expected. So take care to tailor LCDConf.h to your needs. If you do not wish to deal with this process, Micrium Technologies Corporation Inc. can do it for you, as well as test C/GUI in your application with your hardware and your LCD. The following types of configuration macros exist:
Alias "A"
A macro which operates like a simple text substitute. An example would be the define U8, in which the preprocessor would replace with unsigned char.
2002-2007 Micrium
45
2.6
Initializing C/GUI
The routine GUI_Init() initializes the LCD and the internal data structures of C/ GUI, and must be called before any other C/GUI function. This is done by placing the following line into the init sequence of your program:
GUI_Init();
If this call is left out, the entire graphics system will not be initialized and will therefore not be ready.
2.7
2.8
2002-2007 Micrium
46
CHAPTER 2
Getting Started
The whole purpose of the program is to write "Hello world" in the upper left corner of the display. In order to be able to do this, the hardware of the application, the LCD and the GUI must first be initialized. C/GUI is initialized by a call to GUI_Init() at the start of the program, as described previously. In this example, we assume that the hardware of your application is already initialized. The Hello world program looks as follows:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : BASIC_HelloWorld.c Purpose : Simple demo drawing "Hello world" ---------------------------------------------------------------------*/ #include "GUI.H" /******************************************************************* * * main * ******************************************************************** */ void main(void) { /* ToDo: Make sure hardware is initilized first!! */ GUI_Init(); GUI_DispString("Hello world!"); while(1); }
2002-2007 Micrium
47 ******************************************************************** */ void main(void) { int i=0; /* ToDo: Make sure hardware is initilized first!! */ GUI_Init(); GUI_DispString("Hello world!"); while(1) { GUI_DispDecAt( i++, 20,20,4); if (i>9999) i=0; } }
2002-2007 Micrium
48
CHAPTER 2
Getting Started
2002-2007 Micrium
49
Chapter 3 Simulator
The PC simulation of C/GUI allows you to compile the same "C" source on your Windows PC using a native (typically Microsoft) compiler and create an executable for your own application. Doing so allows the following: Design of the user interface on your PC (no need for hardware!). Debugging of your user interface program. Creation of demos of your application, which can be used to discuss the user interface.
2002-2007 Micrium
50
CHAPTER 3
Simulator
3.1
3.1.1
The trial version of C/GUI contains a full library which allows you to evaluate all available features of C/GUI. It also includes the C/GUI viewer (used for debugging applications), as well as demo versions of the font converter and the bitmap converter. Keep in mind that, being a trial version, you will not be able to change any configuration settings or view the source code, but you will still be able to become familiar with what C/GUI can do.
Contents
Source of the demo program. configuration files used to build the library. Do not make any changes to these files! Ready-to-use demo program. Library files and include files needed to use the library. Simulation samples and their sources. Files needed for the simulation. The C/GUI viewer, a demo version of the bitmap converter and a demo version of the font converter.
2002-2007 Micrium
51
The demo project will begin to run and may be exited at any time by right-clicking on it and selecting Exit.
2002-2007 Micrium
52
CHAPTER 3
Simulator
3.1.2
Contents
2002-2007 Micrium
53
If you want to start a new project you should make a copy of the Start-folder. It contains all you need for a new project. The subdirectories containing C/GUI program files are in the Start\GUI folder and should contain the exact same files as the directories of the same names which you are using for your target (cross) compiler. You should not make any changes to the GUI subdirectories, as this would make updating to a newer version of C/GUI more difficult. The Start\Config directory contains configuration files which need to be modified in order to reflect your target hardware settings (mainly LCD-size and colors which can be displayed).
2002-2007 Micrium
54
CHAPTER 3
Simulator
3.2
Device simulation
The simulator can show the simulated LCD in a bitmap of your choice, typically your target device. The bitmap can be dragged over the screen and may, in certain applications, be used to simulate the behavior of the entire target device. In order to simulate the appearance of the device, a bitmap is required. This bitmap is usually a photo (top view) of the device, and must be named Device.bmp. It may be a separate file (in the same directory as the executable), or it may be included as a resource in the application by including the following line in the resource file (extension .rc): 145 BITMAP DISCARDABLE "Device.bmp" For more information, please refer to the Win32 documentation. The size of the bitmap should be such that the size of the area in which the LCD will be shown equals the resolution of the simulated LCD. This is best seen in the following example: Device including simulated LCD as visible on screen
The red area is automatically made transparent. The transparent areas do not have to be rectangular; they can have an arbitrary shape (up to a certain complexity which is limited by your operating system, but is normally sufficient). Bright red (0xFF0000) is the default color for transparent areas, mainly because it is not usually contained in most bitmaps. To use a bitmap with bright red, the default transparency color may be changed with the function SIM_SetTransColor().
3.2.1
All of the device simulator API functions must be called in the setup phase. The calls should ideally be done from within the routine SIM_X_Init(), which is located in the file SIM_X.c. The example below calls SIM_SetLCDPos() in the setup:
#include <windows.h> #include <stdio.h>
2002-2007 Micrium
55
#include "SIM.h" void SIM_X_Init() { SIM_SetLCDPos(0,0); } // Define the position of the LCD in the bitmap
The table below lists the available device-simulation-related routines in alphabetical order within their respective categories. Detailed descriptions of the routines follow: Routine SIM_GUI_SetLCDColorBlack() SIM_GUI_SetLCDColorWhite() SIM_GUI_SetLCDPos() SIM_GUI_SetMag() SIM_GUI_SetTransColor() Explanation
Set the color to be used as black (color monochrome displays). Set the color to be used as white (color monochrome displays). Set the position for the simulated LCD within the target device bitmap. Set magnification factors for X and/or Y axis. Set the color to be used for transparent areas (default: 0xFF0000).
SIM_GUI_SetLCDColorBlack(), SIM_GUI_SetLCDColorWhite()
Description
Set the colors to be used as black or white, respectively, on color monochrome displays.
Prototypes
int SIM_GUI_SetLCDColorBlack(int DisplayIndex, int Color); int SIM_GUI_SetLCDColorWhite(int DisplayIndex, int Color); Parameter DisplayIndex Color
Reserved for future use; must be 0. RGB value of the color.
Meaning
Additional information
These functions can be used to simulate the true background color of your display. The default color values are black and white, or 0x000000 and 0xFFFFFF.
2002-2007 Micrium
56
CHAPTER 3
Simulator
SIM_GUI_SetLCDPos()
Description
Sets the position for the simulated LCD within the target device bitmap.
Prototype
void SIM_GUI_SetLCDPos(int x, int y); Parameter x y Meaning
X-position of the upper left corner for the simulated LCD (in pixels). Y-position of the upper left corner for the simulated LCD (in pixels).
Additional information
The X- and Y-positions are relative to the target device bitmap, therefore position (0,0) refers to the upper left corner (origin) of the bitmap and not your actual LCD. Only the origin of the simulated screen needs to be specified; the resolution of your display should already be reflected in the configuration files in the Config directory. The use of this function enables the use of the bitmaps Device.bmp and Device1.bmp. If the use of the device bitmaps should be disabled, omit the call of this function in SIM_X_Init().
SIM_GUI_SetMag()
Description
Sets magnification factors for X and/or Y axis.
Prototype
void SIM_GUI_SetMag(int MagX, int MagY); Parameter MagX MagY
Magnification factor for X axis. Magnification factor for Y axis.
Meaning
Additional information
Per default the simulation uses one pixel on the PC for each pixel of the simulated display. The use of this function makes sense for small displays. If using a device bitmap together with a magnification > 1 the device bitmap needs to be adapted to the magnification. The device bitmap is not magnified automatically.
User's & reference manual for C/GUI 2002-2007 Micrium
57
SIM_GUI_SetTransColor()
Description
Sets the color to be used for transparent areas of device or hardkey bitmaps.
Prototype
I32 SIM_GUI_SetTransColor(I32 Color); Parameter Color Meaning
RGB value of the color in the format 00000000RRRRRRRRGGGGGGGGBBBBBBBB.
Additional information
The default setting for transparency is bright red (0xFF0000). You would typically only need to change this setting if your bitmap contains the same shade of red.
3.2.2
Hardkey simulation
Hardkeys may also be simulated as part of the device, and may be selected with the mouse pointer. The idea is to be able to distinguish whether a key or button on the simulated device is pressed or unpressed. A hardkey is considered "pressed" as long as the mouse button is held down; releasing the mouse button or moving the pointer off of the hardkey "unpresses" the key. A toggle behavior between pressed and unpressed may also be specified with the routine SIM_HARDKEY_SetMode(). In order to simulate hardkeys, you need a second bitmap of the device which is transparent except for the keys themselves (in their pressed state). This bitmap can again be in a separate file in the directory, or included as a resource in the executable. The filename needs to be Device1.bmp, and the following lines would typically be included in the resource file (extension .rc): 145 BITMAP DISCARDABLE "Device.bmp" 146 BITMAP DISCARDABLE "Device1.bmp"
2002-2007 Micrium
58
CHAPTER 3
Simulator
Hardkeys may be any shape, as long as they are exactly the same size in pixels in both Device.bmp and Device1.bmp. The following example illustrates this: Device bitmap: unpressed hardkey state (Device.bmp) Device hardkey bitmap: pressed hardkey state (Device1.bmp)
When a key is "pressed" with the mouse, the corresponding section of the hardkey bitmap (Device1.bmp) will overlay the device bitmap in order to display the key in its pressed state. The keys may be polled periodically to determine if their states (pressed/unpressed) have changed and whether they need to be updated. Alternatively, a callback routine may be set to trigger a particular action to be carried out when the state of a hardkey changes.
2002-2007 Micrium
59
SIM_HARDKEY_GetNum()
Description
Returns the number of available hardkeys.
Prototype
int SIM_HARDKEY_GetNum(void);
Return value
The number of available hardkeys found in the bitmap.
Additional information
The numbering order for hardkeys is standard reading order (left to right, then top to bottom). The topmost pixel of a hardkey is therefore found first, regardless of its horizontal position. In the bitmap below, for example, the hardkeys are labeled as they would be referenced by the KeyIndex parameter in other functions:
It is recommended to call this function in order to verify that a bitmap is properly loaded.
SIM_HARDKEY_GetState()
Description
Returns the state of a specified hardkey.
Prototype
int SIM_HARDKEY_GetState(unsigned int KeyIndex); Parameter KeyIndex Meaning
Index of hardkey (0 = index of first key).
Return value
State of the specified hardkey: 0: unpressed 1: pressed
SIM_HARDKEY_SetCallback()
Description
Sets a callback routine to be executed when the state of a specified hardkey changes.
2002-2007 Micrium
60
CHAPTER 3
Simulator
Prototype
SIM_HARDKEY_CB* SIM_HARDKEY_SetCallback(unsigned int KeyIndex, SIM_HARDKEY_CB* pfCallback); Parameter KeyIndex pfCallback
Pointer to callback routine.
Meaning
Index of hardkey (0 = index of first key).
Return value
Pointer to the previous callback routine.
Additional information
The callback routine must have the following prototype:
Prototype
typedef void SIM_HARDKEY_CB(int KeyIndex, int State); Parameter KeyIndex State Meaning
Index of hardkey (0 = index of first key). State of the specified hardkey (see table below).
SIM_HARDKEY_SetMode()
Description
Sets the behavior for a specified hardkey.
Prototype
int SIM_HARDKEY_SetMode(unsigned int KeyIndex, int Mode); Parameter KeyIndex Mode
Behavior mode (see table below).
Meaning
Index of hardkey (0 = index of first key).
Additional information
Normal (default) hardkey behavior means that a key is considered pressed only as long as the mouse button is held down on it. When the mouse is released or moved off of the hardkey, the key is considered unpressed. With toggle behavior, each click of the mouse toggles the state of a hardkey to pressed or unpressed. That means if you click the mouse on a hardkey and it becomes pressed, it will remain pressed until you click the mouse on it again.
2002-2007 Micrium
61
SIM_HARDKEY_SetState()
Description
Sets the state for a specified hardkey.
Prototype
int SIM_HARDKEY_SetState(unsigned int KeyIndex, int State); Parameter KeyIndex State Meaning
Index of hardkey (0 = index of first key). State of the specified hardkey (see table below).
Additional information
This function is only usable when SIM_HARDKEY_SetMode() is set to 1 (toggle mode).
2002-2007 Micrium
62
CHAPTER 3
Simulator
3.3.1
Directory structure
The subfolder Simulation of the System folder contains the C/GUI simulation. The directory structure is shown on the right. The table below explains the contents of the subfolders:
Directory
Simulation Res SIM_GUI WinMain
Contents
Simulation source and header files to be used with and without the simulation source code. The folder also contains a ready to use simulation library. Resource files. GUI simulation source code (optional). Contains the WinMain routine.
3.3.2
The following steps will show how to use the simulation library to integrate the C/ GUI simulation into an existing simulation:
2002-2007 Micrium
63
2002-2007 Micrium
64
CHAPTER 3 hWndMain = CreateWindow("GUIApplication", "Application window", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE, 0, 0, 328, 267, NULL, NULL, hInstance, NULL); /* Initialize the C/GUI simulation and create a LCD window */ SIM_GUI_Init(hInstance, hWndMain, lpCmdLine, "RTOS - C/GUI Simulation"); SIM_GUI_CreateLCDWindow(hWndMain, 0, 0, 320, 240, 0); /* Create a thread which executes the code to be simulated */ CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)_Thread, NULL, 0, &ThreadID); /* Main message loop */ while (GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } SIM_GUI_Exit(); }
Simulator
2002-2007 Micrium
65
3.3.3
The table below lists the available routines for user defined simulation programms in alphabetical order within their respective categories. The functions are only available with the source code of the C/GUI simulation. Detailed descriptions of the routines follow: Routine SIM_GUI_CreateLCDInfoWindow() SIM_GUI_CreateLCDWindow() SIM_GUI_Exit() SIM_GUI_Init() SIM_GUI_SetLCDWindowHook() Explanation
Creates a window which shows the available colors of the given layer with the given size and position. Creates a LCD window with the given size and position. Stops the GUI simulation. Initializes the GUI simulation. Sets a hook function to be called if the LCD window receives a message.
SIM_GUI_CreateLCDInfoWindow()
Description
Creates a window which shows the available colors for the given layer.
Prototype
HWND SIM_GUI_CreateLCDInfoWindow(HWND hParent, int x, int y, int xSize, int ySize int LayerIndex); Parameter hParent x y xSize ySize LayerIndex
Handle of the parent window. X position in parent coordinates. Y position in parent coordinates. X size in pixel of the new window. Should be 160 if using a color depth between 1 and 8 or 128 if working in high color mode. Y size in pixel of the new window. Should be 160 if using a color depth between 1 and 8 or 128 if working in high color mode. Index of layer to be shown.
Meaning
Additional information
The created color window has no frame, no title bar and no buttons.
2002-2007 Micrium
66
CHAPTER 3
Simulator
Example
SIM_GUI_CreateLCDInfoWindow(hWnd, 0, 0, 160, 160, 0);
Screenshot
SIM_GUI_CreateLCDWindow()
Description
Creates a window which simulates a LCD display with the given size at the given position.
Prototype
HWND SIM_GUI_CreateLCDWindow(HWND hParent, int x, int y, int xSize, int ySize int LayerIndex); Parameter hParent x y xSize ySize LayerIndex
Handle of the parent window. X position in parent coordinates. Y position in parent coordinates. X size in pixel of the new window. Y size in pixel of the new window. Index of layer to be shown.
Meaning
Additional information
All display output to the given layer will be shown in this window. The size of the window should be the same as configured in LCDConf.h. The created simulation window has no frame, no title bar and no buttons.
SIM_GUI_Exit()
Description
The function should be called before the simulation returns to the calling process.
Prototype
void SIM_GUI_Exit(void);
SIM_GUI_Init()
Description
This function initializes the C/GUI simulation and should be called before any other SIM_GUI... function call.
Prototype
int SIM_GUI_Init(HINSTANCE hInst, HWND hWndMain,
2002-2007 Micrium
67
char * pCmdLine, const char * sAppName); Parameter hInst hWndMain pCmdLine sAppName
Handle to current instance passed to Pointer to command line passed to
Meaning WinMain .
Handle of the simulations main window.
WinMain
Additional information
The parameters hWndMain and sAppName are used if a message box should be displayed.
SIM_GUI_SetLCDWindowHook()
Description
Sets a hook function to be called from the simulation if the LCD window receives a message.
Prototype
void SIM_GUI_SetLCDWindowHook(SIM_GUI_tfHook * pfHook); Parameter pfHook
Pointer to hook function.
Meaning
Meaning
Return value
The hook function should return 0 if the message has been processed. In this case the GUI simulation ignores the message.
2002-2007 Micrium
68
CHAPTER 3
Simulator
2002-2007 Micrium
69
Chapter 4 Viewer
If you use the simulator when debugging your application, you cannot see the display output when stepping through the source code. The primary purpose of the viewer is to solve this problem. It shows the contents of the simulated display(s) while debugging in the simulation. The viewer gives you the following additional capabilities: Multiple windows for each layer Watching the whole virtual layer in one window Magnification of each layer window Composite view if using multiple layers
2002-2007 Micrium
70
CHAPTER 4
Viewer
4.1
4.1.1
If you use the simulator when debugging your application, you cannot see the display output when stepping through the source code. This is due to a limitation of Win32: If one thread (the one being debugged) is halted, all other threads of the process are also halted. This includes the thread which outputs the simulated display on the screen. The C/GUI viewer solves this problem by showing the display window and the color window of your simulation in a separate process. It is your choice if you want to start the viewer before debugging your application or while you are debugging. Our suggestion: Step 1: Start the viewer. No display- or color window is shown until the simulation has been started. Step 2: Open the Visual C++ workspace. Step 3: Compile and run the application program. Step 4: Debug the application as described previously.
The advantage is that you can now follow all drawing operations step by step in the LCD window.
2002-2007 Micrium
71
4.1.2
By default the viewer opens one window per layer which shows the visible part of the video RAM, normally the display. If the configured virtual display RAM is larger than the display, the command View/Virtual Layer/Layer (0...4) can be used to show the whole video RAM in one window. When using the function GUI_SetOrg(), the contents of the visible screen will change, but the virtual layer window remains unchanged:
For more information about virtual screens please refer to chapter Virtual Screens.
4.1.3
Always on top
Per default the viewer window is always on top. You can change this behavior by selecting Options\Always on top from the menu.
2002-2007 Micrium
72
CHAPTER 4
Viewer
4.1.4
If you want to show a magnified area of the LCD output or the composite view of a multi layer configuration it could be useful to open more than one output window. You can do this by View/Visible Layer/Layer (1...4), View/Virtual Layer/ Layer (1...4) or View/Composite.
4.1.5
Zooming
Zooming in or out is easy: Right-click on a layer or composite window opens the Zoom popup menu. Choose one of the zoom options:
If you magnify the LCD output >= 300%, you have the choice between showing the output with or without a grid. It is possible to change the color of the grid. This can be done choosing the Menu point Options/Grid color.
2002-2007 Micrium
73
4.1.6
Click onto a LCD window or a composite view with the right mouse key and choose Copy to clipboard. Now you can paste the contents of the clipboard for example into the mspaint application.
4.1.7
If you are working with multiple displays you should set the viewer into Multi display mode by using the command Options/Multi layer/display.
When starting the debugger the viewer will open one display window and one color window for each display:
4.1.8
If you are working with multiple displays you should set the viewer into Multi layer mode by using the command Options/Multi layer/display.
When starting the debugger the viewer will open one LCD window and one color window for each layer and one composite window for the result.
2002-2007 Micrium
74
CHAPTER 4
Viewer
Sample
The sample below shows a screenshot of the viewer with 2 layers. Layer 0 shows color bars with a high color configuration. Layer 1 shows a transparent circle on a white background with colored rectangles. The composite window shows the result which is actually visible on the display
Transparency
The viewer treats pixels with index 0 in a layer above layer 0 as transparent. Therefore in the composite view the pixels of the layers below are visible. The composite window shows the layers one above the other:
Layer 0 Layer 1 No transparency Pixels can be transparent ... Layer n
2002-2007 Micrium
75
It is very easy to display text with C/GUI. Knowledge of only a few routines already allows you to write any text, in any available font, at any point on the display. We first provide a short introduction to displaying text, followed by more detailed explanations of the individual routines that are available.
2002-2007 Micrium
76
CHAPTER 5
Displaying Text
5.1
Basic routines
In order to display text on the LCD, simply call the routine GUI_DispString() with the text you want to display as parameters. For example:
GUI_DispString("Hello world!");
The above code will display the text "Hello world" at the current text position. However, as you will see, there are routines to display text in a different font or in a certain position. In addition, it is possible to write not only strings but also decimal, hexadecimal and binary values to the display. Even though the graphic displays are usually byte-oriented, the text can be positioned at any pixel of the display, not only at byte positions.
Control characters
Control characters are characters with a character code of less than 32. The control characters are defined as part of ASCII. C/GUI ignores all control characters except for the following: Char. Code
10
ASCII code
LF
"C"
Meaning
Line feed. The current text position is changed to the beginning of the next line. Per default, this is: X = 0. Y + =font-distance in pixels (as delivered by GUI_GetFontDistY() ). Carriage return. The current text position is changed to the beginning of the current line. Per default, this is: X = 0.
\n
13
CR
\r
Usage of the control character LF can be very convenient in strings. A line feed can be made part of a string so that a string spanning multiple lines can be displayed with a single routine call.
5.2
Text API
The table below lists the available text-related routines in alphabetical order within their respective categories. Detailed descriptions of the routines can be found in the sections that follow. Routine Routines to display text GUI_DispChar() GUI_DispCharAt() GUI_DispChars() GUI_DispNextLine() GUI_DispString()
Display single character at current position. Display single character at specified position. Display character a specified number of times. Moves the cursor to the beginning of the next line. Display string at current position.
Explanation
2002-2007 Micrium
77
Routine GUI_DispStringAt() GUI_DispStringAtCEOL() GUI_DispStringHCenterAt() GUI_DispStringInRect() GUI_DispStringInRectEx() GUI_DispStringInRectWrap() GUI_DispStringLen() GUI_GetTextMode() GUI_SetTextMode() GUI_SetTextStyle() GUI_GetTextAlign() GUI_SetLBorder() GUI_SetTextAlign() GUI_GotoX() GUI_GotoXY() GUI_GotoY() GUI_GetDispPosX() GUI_GetDispPosY() GUI_Clear() GUI_DispCEOL()
Explanation
Display string at specified position. Display string at specified position, then clear to end of line. Displays string centered horizontaly at the given position. Display string in specified rectangle. Displays string in specified rectangle and optional rotates it. Displays string in specified rectangle with optional wrapping. Display string at current position with specified number of characters.
5.3
GUI_DispChar()
Prototype
void GUI_DispChar(U16 c); Parameter c
Character to display.
Meaning
Additional information
This is the basic routine for displaying a single character. All other display routines (GUI_DispCharAt(), GUI_DispString(), etc.) call this routine to output the individual characters.
2002-2007 Micrium
78
CHAPTER 5
Displaying Text
Which characters are available depends on the selected font. If the character is not available in the current font, nothing is displayed.
Example
Shows a capital A on the display:
GUI_DispChar('A');
Related topics
GUI_DispChars(), GUI_DispCharAt()
GUI_DispCharAt()
Description
Displays a single character at a specified position in the current window using the current font.
Prototype
void GUI_DispCharAt(U16 c, I16P x, I16P y); Parameter c x y
Character to display. X-position to write to in pixels of the client window. Y-position to write to in pixels of the client window.
Meaning
Add information
Displays the character with its upper left corner at the specified (X,Y) position. Writes the character using the routine GUI_DispChar(). If the character is not available in the current font, nothing is displayed.
Example
Shows a capital A on the display in the upper left corner:
GUI_DispCharAt('A',0,0);
Related topics
GUI_DispChar(), GUI_DispChars()
GUI_DispChars()
Description
Displays a character a specified number of times at the current text position in the current window using the current font.
Prototype
void GUI_DispChars(U16 c, int Cnt); Parameter c Cnt
Character to display. Number of repetitions (0 <= Cnt <= 32767).
Meaning
Additional information
Writes the character using the routine GUI_DispChar(). If the character is not available in the current font, nothing is displayed.
2002-2007 Micrium
79
Example
Shows the line "******************************" on the display:
GUI_DispChars('*', 30);
Related topics
GUI_DispChar(), GUI_DispCharAt()
GUI_DispNextLine()
Description
Moves the cursor to the beginning of the next line.
Prototype
void GUI_DispNextLine(void);
Related topics
GUI_SetLBorder()
GUI_DispString()
Description
Displays the string passed as parameter at the current text position in the current window using the current font.
Prototype
void GUI_DispString(const char GUI_FAR *s); Parameter s
String to display.
Meaning
Additional information
The string can contain the control character \n. This control character moves the current text position to the beginning of the next line.
Example
Shows "Hello world" on the display and "Next line" on the next line:
GUI_DispString("Hello world");// Disp text GUI_DispString("\nNext line");// Disp text
Related topics
GUI_DispStringAt(), GUI_DispStringAtCEOL(), GUI_DispStringLen(),
GUI_DispStringAt()
Description
Displays the string passed as parameter at a specified position in the current window using the current font.
2002-2007 Micrium
80
CHAPTER 5
Displaying Text
Prototype
void GUI_DispStringAt(const char GUI_FAR *s, int x, int y); Parameter s x y
String to display. X-position to write to in pixels of the client window. Y-position to write to in pixels of the client window.
Meaning
Example
Shows "Position 50,20" at position 50,20 on the display:
GUI_DispStringAt("Position 50,20", 50, 20);// Disp text
Related topics
GUI_DispString(), GUI_DispStringAtCEOL(), GUI_DispStringLen(),
GUI_DispStringAtCEOL()
Description
This routine uses the exact same parameters as GUI_DispStringAt(). It does the same thing: displays a given string at a specified position. However, after doing so, it clears the remaining part of the line to the end by calling the routine GUI_DispCEOL(). This routine can be handy if one string is to overwrite another, and the overwriting string is or may be shorter than the previous one.
GUI_DispStringHCenterAt()
Description
Displays the string passed as parameter horizontaly centered at a specified position in the current window using the current font.
Prototype
void GUI_DispStringHCenterAt(const char GUI_FAR *s, int x, int y); Meaning
String to display. X-position to write to in pixels of the client window. Y-position to write to in pixels of the client window.
Parameter s x y
GUI_DispStringInRect()
Description
Displays the string passed as parameter at a specified position within a specified rectangle, in the current window using the current font.
Prototype
void GUI_DispStringInRect(const char GUI_FAR *s, const GUI_RECT *pRect,
2002-2007 Micrium
81
Meaning
Example
Shows the word "Text" centered horizontally and vertically in the current window:
GUI_RECT rClient; GUI_GetClientRect(&rClient); GUI_DispStringInRect("Text", &rClient, GUI_TA_HCENTER | GUI_TA_VCENTER);
Additional information
If the specified rectangle is too small, the text will be clipped.
Related topics
GUI_DispString(), GUI_DispStringAtCEOL(), GUI_DispStringLen(),
GUI_DispStringInRectEx()
Description
Displays the string passed as parameter at a specified position within a specified rectangle, in the current window using the current font and (optional) rotates it.
Prototype
void GUI_DispStringInRectEx(const char GUI_UNI_PTR *s, GUI_RECT* pRect, int TextAlign, int MaxLen, const GUI_ROTATION * pLCD_Api); Parameter s pRect TextAlign MaxLen pLCD_Api
String to display. Rectangle to write to in pixels of the client window. Alignment flags; " OR " combinable. A flag for horizontal and a flag for vertical alignment should be combined. Available flags are: GUI_TA_TOP, GUI_TA_BOTTOM, GUI_TA_VCENTER for vertical alignment. GUI_TA_LEFT, GUI_TA_RIGHT, GUI_TA_HCENTER for horizontal alignment. Maximum number of characters to be shown. (see table below)
Meaning
Example
Shows the word "Text" centered horizontally and vertically in the given rectangle:
GUI_RECT Rect = {10, 10, 40, 80}; char acText[] = "Rotated\ntext";
2002-2007 Micrium
82
Displaying Text
Additional information
If the specified rectangle is too small, the text will be clipped.
GUI_DispStringInRectWrap()
Description Description
Displays a string at a specified position within a specified rectangle, in the current window using the current font and (optionaly) wraps the text.
Prototype
void GUI_DispStringInRectWrap(const char GUI_UNI_PTR * s, GUI_RECT * pRect, int TextAlign, GUI_WRAPMODE WrapMode); Parameter s pRect TextAlign WrapMode
String to display. Rectangle to write to in pixels of the client window. Alignment flags; " OR " combinable. A flag for horizontal and a flag for vertical alignment should be combined. Available flags are: GUI_TA_TOP, GUI_TA_BOTTOM, GUI_TA_VCENTER for vertical alignment. GUI_TA_LEFT, GUI_TA_RIGHT, GUI_TA_HCENTER for horizontal alignment. (see table below)
Meaning
Additional information
If word wrapping should be performed and the given rectangle is too small for a word char wrapping is executed at this word.
2002-2007 Micrium
83
Example
Shows a text centered horizontally and vertically in the given rectangle with word wrapping:
int i; char acText[] = "This sample demonstrates text wrapping"; GUI_RECT Rect = {10, 10, 59, 59}; GUI_WRAPMODE aWm[] = {GUI_WRAPMODE_NONE, GUI_WRAPMODE_CHAR, GUI_WRAPMODE_WORD}; GUI_SetTextMode(GUI_TM_TRANS); for (i = 0; i < 3; i++) { GUI_SetColor(GUI_BLUE); GUI_FillRectEx(&Rect); GUI_SetColor(GUI_WHITE); GUI_DispStringInRectWrap(acText, &Rect, GUI_TA_LEFT, aWm[i]); Rect.x0 += 60; Rect.x1 += 60; }
GUI_DispStringLen()
Description
Displays the string passed as parameter with a specified number of characters at the current text position, in the current window using the current font.
Prototype
void GUI_DispStringLen(const char GUI_FAR *s, int Len); Parameter s Len Meaning
String to display. Should be a \0 terminated array of 8-bit character. Passing NULL as parameter is permitted. Number of characters to display.
Additional information
If the string has less characters than specified (is shorter), it is padded with spaces. If the string has more characters than specified (is longer), then only the given number of characters is actually displayed. This function is especially useful if text messages can be displayed in different languages (and will naturally differ in length), but only a certain number of characters can be displayed.
Related topics
GUI_DispString(), GUI_DispStringAt(), GUI_DispStringAtCEOL(),
2002-2007 Micrium
84
CHAPTER 5
Displaying Text
5.4
Normal text
Text can be displayed normally by specifying GUI_TEXTMODE_NORMAL or 0.
Reverse text
Text can be displayed in reverse by specifying GUI_TEXTMODE_REVERSE. What is usually displayed as white on black will be displayed as black on white.
Transparent text
Transparent text means that the text is written on top of whatever is already visible on the display. The difference is that whatever was previously on the screen can still be seen, whereas with normal text the background is erased. Text can be displayed transparently by specifying GUI_TEXTMODE_TRANS.
XOR text
What usually is drawn white (the actual character) is inverted. The effect is identical to that of the default mode (normal text) if the background is black. If the background is white, the output is identical to reverse text. If you use colors, an inverted pixel is calculated as follows: New pixel color = number of colors - actual pixel color - 1.
Example
Displays normal, reverse, transparent, XOR, and transparent reversed text:
GUI_SetFont(&GUI_Font8x16); GUI_SetFont(&GUI_Font8x16); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetPenSize(10); GUI_SetColor(GUI_RED); GUI_DrawLine(80, 10, 240, 90); GUI_DrawLine(80, 90, 240, 10); GUI_SetBkColor(GUI_BLACK); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_NORMAL); GUI_DispStringHCenterAt("GUI_TM_NORMAL" , GUI_SetTextMode(GUI_TM_REV); GUI_DispStringHCenterAt("GUI_TM_REV" , GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringHCenterAt("GUI_TM_TRANS" , GUI_SetTextMode(GUI_TM_XOR); GUI_DispStringHCenterAt("GUI_TM_XOR" , GUI_SetTextMode(GUI_TM_TRANS | GUI_TM_REV); GUI_DispStringHCenterAt("GUI_TM_TRANS | GUI_TM_REV",
160, 10); 160, 26); 160, 42); 160, 58); 160, 74);
2002-2007 Micrium
85
GUI_GetTextMode()
Description
Returns the currently selected text mode.
Prototype
int GUI_GetTextMode(void);
Return value
The currently selected text mode.
GUI_SetTextMode()
Description
Sets the text mode to the parameter specified.
Prototype
int GUI_SetTextMode(int TextMode); Parameter TextMode Meaning
Text mode to set. May be any combination of the TEXTMODE flags.
Permitted values for parameter TextMode (OR-combinable) GUI_TEXTMODE_NORMAL GUI_TEXTMODE_REVERSE GUI_TEXTMODE_TRANSPARENT GUI_TEXTMODE_XOR
Sets normal text. This is the default setting; the value is identical to 0. Sets reverse text. Sets transparent text. Text will be inverted on the display.
Return value
The previous selected text mode.
Example
Shows "The value is" at position 0,0 on the display, shows a value in reverse text, then sets the text mode back to normal:
int i = 20; GUI_DispStringAt("The value is", 0, 0); GUI_SetTextMode(GUI_TEXTMODE_REVERSE); GUI_DispDec(20, 3); GUI_SetTextMode(GUI_TEXTMODE_NORMAL); User's & reference manual for C/GUI 2002-2007 Micrium
86
CHAPTER 5
Displaying Text
GUI_SetTextStyle()
Description
Sets the text style to the parameter specified.
Prototype
char GUI_SetTextStyle(char Style); Parameter Style
Text style to set (see table below).
Meaning
Return value
The previous selected text style.
5.5
GUI_GetTextAlign()
Prototype
int GUI_GetTextAlign(void);
GUI_SetLBorder()
Description
Sets the left border for line feeds in the current window.
Prototype
void GUI_SetLBorder(int x) Parameter x Meaning
New left border (in pixels, 0 is left border).
GUI_SetTextAlign()
Description
Sets the text alignment mode for string output in the current window.
2002-2007 Micrium
87
Prototype
int GUI_SetTextAlign(int TextAlign); Parameter TextAlign Meaning
Text alignment mode to set. May be a combination of a horizontal and a vertical alignment flag.
Permitted values for parameter TextAlign (horizontal and vertical flags are OR-combinable) Horizontal alignment GUI_TA_LEFT GUI_TA_HCENTER GUI_TA_RIGHT GUI_TA_TOP GUI_TA_VCENTER GUI_TA_BOTTOM
Align X-position left (default). Center X-position. Align X-position right (default).
Vertical alignment
Align Y-position with top of characters (default). Center Y-position. Align Y-position with bottom pixel line of font.
Return value
The selected text alignment mode.
Additional information
GUI_SetTextAllign() does not affect the character output routines beginning with GUI_DispChar().
Example
Displays the value 1234 with the center of the text at x=100, y=100:
GUI_SetTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER); GUI_DispDecAt(1234,100,100,4);
5.6
Prototypes
char GUI_GotoXY(int x, int y); char GUI_GotoX(int x); char GUI_GotoY(int y); Parameter x y Meaning
New X-position (in pixels, 0 is left border). New Y-position (in pixels, 0 is top border).
2002-2007 Micrium
88
CHAPTER 5
Displaying Text
Return value
Usually 0. If a value ! = 0 is returned, then the current text position is outside of the window (to the right or below), so a following write operation can be omitted.
Additional information
GUI_GotoXY() sets both the X- and Y-components of the current text position. GUI_GotoX() sets the X-component of the current text position; the Y-component remains unchanged. GUI_GotoY() sets the Y-component of the current text position; the X-component remains unchanged.
Example
Shows "(20,20)" at position 20,20 on the display:
GUI_GotoXY(20,20) GUI_DispString("The value is");
5.7
GUI_GetDispPosX()
Prototype
int GUI_GetDispPosX(void);
GUI_GetDispPosY()
Description
Returns the current Y-position.
Prototype
int GUI_GetDispPosY(void);
5.8
GUI_Clear()
Prototype
void GUI_Clear(void);
Additional information
If no window has been defined, the current window is the entire display. In this case, the entire display is cleared.
Example
Shows "Hello world" on the display, waits 1 second and then clears the display:
2002-2007 Micrium
89 GUI_DispStringAt("Hello world", 0, 0);// Disp text GUI_Delay(1000);// Wait 1 second (not part of C/GUI) GUI_Clear();// Clear screen
GUI_DispCEOL()
Description
Clears the current window (or the display) from the current text position to the end of the line using the height of the current font.
Prototype
void GUI_DispCEOL(void);
Example
Shows "Hello world" on the display, waits 1 second and then displays "Hi" in the same place, replacing the old string:
GUI_DispStringAt("Hello world", 0, 0);// Disp text Delay (1000); GUI_DispStringAt("Hi", 0, 0); GUI_DispCEOL();
2002-2007 Micrium
90
CHAPTER 5
Displaying Text
2002-2007 Micrium
91
The preceding chapter explained how to show strings on the display. Of course you may use strings and the functions of the standard "C" library to display values. However, this can sometimes be a difficult task. It is usually much easier (and much more efficient) to call a routine that displays the value in the form that you want. C/ GUI supports different decimal, hexadecimal and binary outputs. The individual routines are explained in this chapter. All functions work without the usage of a floating-point library and are optimized for both speed and size. Of course sprintf may also be used on any system. Using the routines in this chapter can sometimes simplify things and save both ROM space and execution time.
2002-2007 Micrium
92
CHAPTER 6
Displaying Values
2002-2007 Micrium
93
Prototype
void GUI_DispDec(I32 v, U8 Len); Parameter v Len
Value to display. Minimum -2147483648 (= -2^31). Maximum 2147483647 (= 2^31 -1). No. of digits to display (max. 10).
Meaning
Additional information
Leading zeros are not suppressed (are shown as 0). If the value is negative, a minus sign is shown.
Example
// Display time as minutes and seconds GUI_DispString("Min:"); GUI_DispDec(Min,2); GUI_DispString(" Sec:"); GUI_DispDec(Sec,2);
Related topics
GUI_DispSDec(), GUI_DispDecAt(), GUI_DispDecMin(), GUI_DispDecSpace()
GUI_DispDecAt()
Description
Displays a value in decimal form with a specified number of characters at a specified position, in the current window using the current font.
Prototype
void GUI_DispDecAt(I32 v, I16P x, I16P y, U8 Len); Parameter v x y Len
Value to display. Minimum -2147483648 (= -2^31). Maximum 2147483647 (= 2^31 -1). X-position to write to in pixels of the client window. Y-position to write to in pixels of the client window. No. of digits to display (max. 10).
Meaning
Additional information
Leading zeros are not suppressed. If the value is negative, a minus sign is shown.
Example
// Update seconds in upper right corner GUI_DispDecAT(Sec, 200, 0, 2);
Related topics
GUI_DispDec(), GUI_DispSDec(), GUI_DispDecMin(), GUI_DispDecSpace()
2002-2007 Micrium
94
CHAPTER 6
Displaying Values
GUI_DispDecMin()
Description
Displays a value in decimal form at the current text position in the current window using the current font. The length need not be specified; the minimum length will automatically be used.
Prototype
void GUI_DispDecMin(I32 v); Parameter v Meaning
Value to display. Minimum: -2147483648 (= -2^31); maximum 2147483647 (= 2^31 -1). Maximum no. of digits displayed is 10.
Additional information
If values have to be aligned but differ in the number of digits, this function is not a good choice. Try one of the functions that specify the number of digits.
Example
// Show result GUI_DispString("The result is :"); GUI_DispDecMin(Result);
Related topics
GUI_DispDec(), GUI_DispDecAt(), GUI_DispSDec(), GUI_DispDecSpace()
GUI_DispDecShift()
Description
Displays a long value in decimal form with a specified number of characters and with decimal point at the current text position, in the current window using the current font.
Prototype
void GUI_DispDecShift(I32 v, U8 Len, U8 Shift); Parameter v Len Shift Meaning
Value to display. Minimum: -2147483648 (= -2^31); maximum: 2147483647 (= 2^31 -1). No. of digits to display (max. 10). No. of digits to show to right of decimal point.
Additional information
Watch the maximum number of 9 characters (including sign and decimal point).
GUI_DispDecSpace()
Description
Displays a value in decimal form at the current text position in the current window using the current font. Leading zeros are suppressed (replaced by spaces).
2002-2007 Micrium
95
Prototype
void DispDecSpace(I32 v, U8 MaxDigits); Parameter v MaxDigits Meaning
Value to display. Minimum: -2147483648 (= -2^31); maximum: 2147483647 (= 2^31 -1). No. of digits to display, including leading spaces. Maximum no. of digits displayed is 10 (excluding leading spaces).
Additional information
If values have to be aligned but differ in the number of digits, this function is a good choice.
Example
// Show result GUI_DispString("The result is :"); GUI_DispDecSpace(Result, 200);
Related topics
GUI_DispDec(), GUI_DispDecAt(), GUI_DispSDec(), GUI_DispDecMin()
GUI_DispSDec()
Description
Displays a value in decimal form (with sign) with a specified number of characters at the current text position, in the current window using the current font.
Prototype
void GUI_DispSDec(I32 v, U8 Len); Parameter v Len Meaning
Value to display. Minimum: -2147483648 (= -2^31); maximum: 2147483647 (= 2^31 -1). No. of digits to display (max. 10).
Additional information
Leading zeros are not suppressed. This function is similar to GUI_DispDec, but a sign is always shown in front of the value, even if the value is positive.
Related topics
GUI_DispDec(), GUI_DispDecAt(), GUI_DispDecMin(), GUI_DispDecSpace()
GUI_DispSDecShift()
Description
Displays a long value in decimal form (with sign) with a specified number of characters and with decimal point at the current text position, in the current window using the current font.
2002-2007 Micrium
96
CHAPTER 6
Displaying Values
Prototype
void GUI_DispSDecShift(I32 v, U8 Len, U8 Shift); Parameter v Len Shift Meaning
Value to display. Minimum: -2147483648 (= -2^31); maximum: 2147483647 (= 2^31 -1). No. of digits to display (max. 10). No. of digits to show to right of decimal point.
Additional information
A sign is always shown in front of the value. Watch the maximum number of 9 characters (including sign and decimal point).
Example
void DemoDec(void) { long l = 12345; GUI_Clear(); GUI_SetFont(&GUI_Font8x8); GUI_DispStringAt("GUI_DispDecShift:\n",0,0); GUI_DispSDecShift(l, 7, 3); GUI_SetFont(&GUI_Font6x8); GUI_DispStringAt("Press any key",0,GUI_VYSIZE-8); WaitKey(); }
Prototype
void GUI_DispFloat(float v, char Len); Parameter v Len Meaning
Value to display. Minimum 1.2 E-38; maximum 3.4 E38. No. of digits to display (max. 9).
Additional information
Leading zeros are suppressed. The decimal point counts as one character.
User's & reference manual for C/GUI 2002-2007 Micrium
97
Example
/* Shows all features for displaying floating point values void DemoFloat(void) { float f = 123.45678; GUI_Clear() GUI_SetFont(&GUI_Font8x8); GUI_DispStringAt("GUI_DispFloat:\n",0,0); GUI_DispFloat (f,9); GUI_GotoX(100); GUI_DispFloat (-f,9); GUI_DispStringAt("GUI_DispFloatFix:\n",0,20); GUI_DispFloatFix (f,9,2); GUI_GotoX(100); GUI_DispFloatFix (-f,9,2); GUI_DispStringAt("GUI_DispSFloatFix:\n",0,40); GUI_DispSFloatFix (f,9,2); GUI_GotoX(100); GUI_DispSFloatFix (-f,9,2); GUI_DispStringAt("GUI_DispFloatMin:\n",0,60); GUI_DispFloatMin (f,3); GUI_GotoX(100); GUI_DispFloatMin (-f,3); GUI_DispStringAt("GUI_DispSFloatMin:\n",0,80); GUI_DispSFloatMin (f,3); GUI_GotoX(100); GUI_DispSFloatMin (-f,3); GUI_SetFont(&GUI_Font6x8); GUI_DispStringAt("Press any key",0,GUI_VYSIZE-8); WaitKey(); } */
GUI_DispFloatFix()
Description
Displays a floating-point value with specified number of total characters and a specified number of characters to the right of the decimal point, at the current text position in the current window using the current font.
2002-2007 Micrium
98
CHAPTER 6
Displaying Values
Prototype
void GUI_DispFloatFix (float v, char Len, char Decs); Parameter v Len Decs Meaning
Value to display. Minimum 1.2 E-38; maximum 3.4 E38. No. of digits to display (max. 9). No. of digits to show to right of decimal point.
Additional information
Leading zeros are not suppressed. If the value is negative, a minus sign is shown.
GUI_DispFloatMin()
Description
Displays a floating-point value with a minimum number of decimals to the right of the decimal point, at the current text position in the current window using the current font.
Prototype
void GUI_DispFloatMin(float f, char Fract); Parameter v Fract Meaning
Value to display. Minimum 1.2 E-38; maximum 3.4 E38. Minimum no. of characters to display.
Additional information
Leading zeros are suppressed. If the value is negative, a minus sign is shown. The length need not be specified; the minimum length will automatically be used. If values have to be aligned but differ in the number of digits, this function is not a good choice. Try one of the functions that specify the number of digits.
GUI_DispSFloatFix()
Description
Displays a floating-point value (with sign) with a specified number of total characters and a specified number of characters to the right of the decimal point, in the current window using the current font.
Prototype
void GUI_DispSFloatFix(float v, char Len, char Decs); Parameter v Len Decs Meaning
Value to display. Minimum 1.2 E-38; maximum 3.4 E38. No. of digits to display (max. 9). No. of digits to show to right of decimal point.
2002-2007 Micrium
99
Additional information
Leading zeros are not suppressed. A sign is always shown in front of the value.
GUI_DispSFloatMin()
Description
Displays a floating-point value (with sign) with a minimum number of decimals to the right of the decimal point, at the current text position in the current window using the current font.
Prototype
void GUI_DispSFloatMin(float f, char Fract); Parameter v Fract Meaning
Value to display. Minimum 1.2 E-38; maximum 3.4 E38. Minimum no. of digits to display.
Additional information
Leading zeros are suppressed. A sign is always shown in front of the value. The length need not be specified; the minimum length will automatically be used. If values have to be aligned but differ in the number of digits, this function is not a good choice. Try one of the functions that specify the number of digits.
Prototype
void GUI_DispBin(U32 v, U8 Len); Parameter v Len
Value to display, 32-bit. No. of digits to display (including leading zeros).
Meaning
Additional information
As with decimal and hexadecimal values, the least significant bit is rightmost.
Example
// // Show binary value 7, result: 000111 // U32 Input = 0x7; GUI_DispBin(Input, 6);
2002-2007 Micrium
100
CHAPTER 6
Displaying Values
Related topics
GUI_DispBinAt()
GUI_DispBinAt()
Description
Displays a value in binary form at a specified position in the current window using the current font.
Prototype
void DispBinAt(U32 Parameter v x y Len
Value to display, 16-bit. X-position to write to in pixels of the client window. Y-position to write to in pixels of the client window. No. of digits to display (including leading zeroes).
Additional information
As with decimal and hexadecimal values, the least significant bit is rightmost.
Example
// // Show binary input status // GUI_DispBinAt(Input, 0,0, 8);
Related topics
GUI_DispBin(), GUI_DispHex()
Prototype
void GUI_DispHex(U32 v, U8 Len); Parameter v Len
Value to display, 16-bit. No. of digits to display.
Meaning
Additional information
As with decimal and binary values, the least significant bit is rightmost.
2002-2007 Micrium
101
Example
/* Show value of AD-converter */ GUI_DispHex(Input, 4);
Related topics
GUI_DispDec(), GUI_DispBin(), GUI_DispHexAt()
GUI_DispHexAt()
Description
Displays a value in hexadecimal form at a specified position in the current window using the current font.
Prototype
void GUI_DispHexAt(U32 v, I16P x, I16P y, U8 Len); Parameter v x y Len
Value to display, 16-bit. X-position to write to in pixels of the client window. Y-position to write to in pixels of the client window. No. of digits to display.
Meaning
Additional information
As with decimal and binary values, the least significant bit is rightmost.
Example
// // Show value of AD-converter at specified position // GUI_DispHexAt(Input, 0, 0, 4);
Related topics
GUI_DispDec(), GUI_DispBin(), GUI_DispHex()
Prototype
const char * GUI_GetVersionString(void);
Example
// // Displays the current version at the current cursor position // GUI_DispString(GUI_GetVersionString());
2002-2007 Micrium
102
CHAPTER 6
Displaying Values
2002-2007 Micrium
103
C/GUI contains a complete 2-D graphic library which should be sufficient for most applications. The routines supplied with C/GUI can be used with or without clipping (please refer to Chapter 14: "The Window Manager") and are based on fast and efficient algorithms. Currently, only the DrawArc() function requires floating-point calculations.
2002-2007 Micrium
104
CHAPTER 7
7.1
Graphic API
The table below lists the available graphic-related routines in alphabetical order within their respective categories. Detailed descriptions can be found in the sections that follow. Routine Drawing modes GUI_GetDrawMode() GUI_SetDrawMode() GUI_GetPenSize() GUI_SetPenSize() GUI_GetClientRect() GUI_ClearRect() GUI_DrawGradientV() GUI_DrawGradientH() GUI_DrawPixel() GUI_DrawPoint() GUI_DrawRect() GUI_DrawRectEx() GUI_FillRect() GUI_FillRectEx() GUI_InvertRect() GUI_SetAlpha() GUI_DrawBitmap() GUI_DrawBitmapEx() GUI_DrawBitmapExp()
Returns the current drawing mode Sets the drawing mode.
Explanation
Pen size
Returns the current pen size in pixels. Sets the pen size in pixels.
Alpha blending
Sets the current alpha blending value.
Drawing bitmaps
Draws a bitmap. Draws a scaled bitmap. Draws a bitmap using additional parameters. Draws a bitmap with alpha blending information on a system with
GUI_DrawBitmapHWAlpha() hardware alpha blending support. Draws a magnified bitmap. GUI_DrawBitmapMag() Drawing lines Draws a horizontal line. GUI_DrawHLine() GUI_DrawLine() GUI_DrawLineRel() GUI_DrawLineTo() GUI_DrawPolyLine() GUI_DrawVLine() GUI_GetLineStyle() GUI_MoveRel() GUI_MoveTo() GUI_SetLineStyle()
Draws a line from a specified startpoint to a specified endpoint (absolute coordinates). Draws a line from the current position to an endpoint specified by Xand Y-distances (relative coordinates). Draws a line from the current position to a specified endpoint. Draws a polyline. Draws a vertical line. Returns the current line style. Moves the line pointer relative to its current position Moves the line pointer to the given position Sets the current line style.
Drawing polygons
User's & reference manual for C/GUI 2002-2007 Micrium
105
Routine GUI_DrawPolygon() GUI_EnlargePolygon() GUI_FillPolygon() GUI_MagnifyPolygon() GUI_RotatePolygon() GUI_DrawCircle() GUI_FillCircle() GUI_DrawEllipse() GUI_FillEllipse() GUI_DrawArc() GUI_DrawGraph() GUI_DrawPie() GUI_RestoreContext() GUI_SaveContext() GUI_SetClipRect()
Enlarges a polygon. Draws a filled polygon. Magnifys a polygon.
Explanation
Draws the outline of a polygon.
Drawing circles
Draws the outline of a a circle. Draws a filled circle.
Drawing ellipses
Draws the outline of an ellipse. Draws a filled ellipse.
Drawing arcs
Draws an arc.
Drawing a graph
Draws a graph.
Clipping
Sets the rectangle used for clipping
7.2
Drawing modes
C/GUI can draw in NORMAL mode or in XOR mode. The default is NORMAL mode, in which the content of the display is overdrawn by the graphic. In XOR mode, the content of the display is inverted when it is overdrawn.
GUI_GetDrawMode()
Description
Returns the current drawing mode.
2002-2007 Micrium
106
CHAPTER 7
Prototype
GUI_DRAWMODE GUI_GetDrawMode(void);
Return value
The currently selected drawing mode.
Additional information
For details about drawing modes please refer to the function GUI_SetDrawMode().
GUI_SetDrawMode()
Description
Selects the specified drawing mode.
Prototype
GUI_DRAWMODE GUI_SetDrawMode(GUI_DRAWMODE mode); Parameter mode Meaning
Drawing mode to set. May be a value returned by any routine which sets the drawing mode or one of the constants below.
Return value
The selected drawing mode.
Additional information
In addition to setting the drawing mode, this routine may also be used to restore a drawing mode that has previously been changed. If using colors, an inverted pixel is calculated as follows: New pixel color = number of colors - actual pixel color - 1.
Example
// // Showing two circles, the second one XOR-combined with the first: // GUI_Clear(); GUI_SetDrawMode(GUI_DRAWMODE_NORMAL); GUI_FillCircle(120, 64, 40); GUI_SetDrawMode(GUI_DRAWMODE_XOR); GUI_FillCircle(140, 84, 40);
2002-2007 Micrium
107
7.3
GUI_GetClientRect()
Prototype
void GUI_GetClientRect(GUI_RECT* pRect); Parameter pRect Meaning
Pointer to GUI_RECT-structure to store result.
7.4
Pen size
The pen size determines the thickness of vector drawing operations line GUI_DrawLine(), GUI_DrawCircle() and so on. Please note that the pen size takes not effect on all drawing functions.
GUI_GetPenSize()
Description
Returns the current pen size.
Prototype
U8 GUI_GetPenSize(void);
GUI_SetPenSize()
Description
Sets the pen size to be used for further drawing operations.
2002-2007 Micrium
108
CHAPTER 7
Prototype
U8 GUI_SetPenSize(U8 PenSize); Parameter PenSize
Pen size in pixels to be used.
Meaning
Return value
Previous pen size.
Add information
The pen size should be >= 1.
7.5
GUI_ClearRect()
Description
Clears a rectangular area at a specified position in the current window by filling it with the background color.
Prototype
void GUI_ClearRect(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
Upper left X-position. Upper left Y-position. Lower right X-position. Lower right Y-position.
Meaning
Related topics
GUI_InvertRect(), GUI_FillRect()
GUI_DrawGradientH()
Description
Draws a rectangle filled with a horizontal color gradient.
Prototype
void GUI_DrawGradientH(int x0, int y0, int x1, int y1,
2002-2007 Micrium
109
Meaning
Example
GUI_DrawGradientH(0, 0, 99, 99, 0x0000FF, 0x00FFFF);
GUI_DrawGradientV()
Description
Draws a rectangle filled with a vertical color gradient.
Prototype
void GUI_DrawGradientV(int x0, int y0, int x1, int y1, GUI_COLOR Color0, GUI_COLOR Color1); Parameter x0 y0 x1 y1 Color0 Color1
Upper left X-position. Upper left Y-position. Lower right X-position. Lower right Y-position. Color to be drawn on the leftmost side of the rectangle. Color to be drawn on the rightmost side of the rectangle.
Meaning
Example
GUI_DrawGradientV(0, 0, 99, 99, 0x0000FF, 0x00FFFF);
GUI_DrawPixel()
Description
Draws a pixel at a specified position in the current window.
2002-2007 Micrium
110
CHAPTER 7
Prototype
void GUI_DrawPixel(int x, int y); Parameter x y
X-position of pixel. Y-position of pixel.
Meaning
Related topics
GUI_DrawPoint()
GUI_DrawPoint()
Description
Draws a point with the current pen size at a specified position in the current window.
Prototype
void GUI_DrawPoint(int x, int y); Parameter x y
X-position of point. Y-position of point.
Meaning
Related topics
GUI_DrawPixel()
GUI_DrawRect()
Description
Draws a rectangle at a specified position in the current window.
Prototype
void GUI_DrawRect(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
Upper left X-position. Upper left Y-position. Lower right X-position. Lower right Y-position.
Meaning
GUI_DrawRectEx()
Description
Draws a rectangle at a specified position in the current window.
Prototype
void GUI_DrawRectEx(const GUI_RECT *pRect); Parameter pRect Meaning
Pointer to a GUI_RECT-structure containing the coordinates of the rectangle
2002-2007 Micrium
111
GUI_FillRect()
Description
Draws a filled rectangular area at a specified position in the current window.
Prototype
void GUI_FillRect(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
Upper left X-position. Upper left Y-position. Lower right X-position. Lower right Y-position.
Meaning
Additional information
Uses the current drawing mode, which normally means all pixels inside the rectangle are set.
Related topics
GUI_InvertRect(), GUI_ClearRect()
GUI_FillRectEx()
Description
Draws a filled rectangular area at a specified position in the current window.
Prototype
void GUI_FillRectEx Parameter pRect (const GUI_RECT* pRect); Meaning
Pointer to a GUI_RECT-structure containing the coordinates of the rectangle
GUI_InvertRect()
Description
Draws an inverted rectangular area at a specified position in the current window.
Prototype
void GUI_InvertRect(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
Upper left X-position. Upper left Y-position. Lower right X-position. Lower right Y-position.
Meaning
Related topics
GUI_FillRect(), GUI_ClearRect()
2002-2007 Micrium
112
CHAPTER 7
7.6
Alpha blending
Alpha blending is a method of combining a foreground image with the background to create the appearance of semi transparency. An alpha value determines how much of a pixel should be visible and how much of the background should show through.
GUI_SetAlpha()
Description
Enables software alpha blending for all subsequent drawing operations.
Prototype
unsigned GUI_SetAlpha(U8 Value); Parameter Alpha Meaning
Alpha value to be used for all subsequent drawing operations. Default is 0 which means no alpha blending.
Return value
Previous value used for alpha blending.
Additional information
The function sets the alpha value to be used for all subsequent drawing operations. A value of 0 for parameter Alpha means opaque (alpha blending disabled) and a value of 255 means completely transparent (invisible). Please note that software alpha blending increases the CPU load. Further it is strongly recommended to set the alpha value back to the default value after finishing the drawing operations.
Example
extern const GUI_BITMAP _LogoBitmap; GUI_SetColor(GUI_BLUE); GUI_FillCircle(100, 50, 49); GUI_SetColor(GUI_YELLOW); for (i = 0; i < 100; i++) { U8 Alpha; Alpha = (i * 255 / 100); GUI_SetAlpha(Alpha); GUI_DrawHLine(i, 100 - i, 100 + i); } GUI_SetAlpha(0x80); GUI_DrawBitmap(&_LogoBitmap, 30, 30); GUI_SetColor(GUI_MAGENTA); GUI_SetFont(&GUI_Font24B_ASCII); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringHCenterAt("Alphablending", 100, 3); GUI_SetAlpha(0); /* Set back to default (opaque) */
2002-2007 Micrium
113
7.7
Drawing bitmaps
Description
Draws a bitmap image at a specified position in the current window.
GUI_DrawBitmap()
Prototype
void GUI_DrawBitmap(const GUI_BITMAP* pBM, int x, int y); Parameter pBM x y
Pointer to the bitmap to display. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Meaning
Additional information
The bitmap data must be defined pixel by pixel. Every pixel is equivalent to one bit. The most significant bit (msb) defines the first pixel; the picture data is interpreted as bitstream starting with the msb of the first byte. A new line always starts at an even byte address, as the nth line of the bitmap starts at offset n*BytesPerLine. The bitmap can be shown at any point in the client area. Usually, the bitmap converter is used to generate bitmaps. For more information, please refer to Chapter 10: "Bitmap Converter".
Example
extern const GUI_BITMAP bmMicriumLogo; void main() { GUI_Init(); GUI_DrawBitmap(&bmMicriumLogo,45,20); } /* declare external Bitmap */
2002-2007 Micrium
114
CHAPTER 7
GUI_DrawBitmapExp()
Description
Same function as GUI_DrawBitmap(), but with additional parameters.
Prototype
void GUI_DrawBitmapExp(int x0, int y0, int XSize, int YSize, int XMul, int YMul, int BitsPerPixel, int BytesPerLine, const U8* pData, const GUI_LOGPALETTE* pPal); Parameter x0 y0 Xsize Ysize XMUL YMul BitsPerPixel BytesPerLine pData pPal Meaning
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Number of pixels in horizontal direction. Valid range: 1... 255. Number of pixels in vertical direction. Valid range: 1... 255. Scale factor of X-direction. Scale factor of Y-direction. Number of bits per pixel. Number of bytes per line of the image. Pointer to the actual image, the data that defines what the bitmap looks like. Pointer to a GUI_LOGPALETTE structure.
GUI_DrawBitmapEx()
Description
This routine makes it possible to scale and/or to mirror a bitmap on the display.
Prototype
void GUI_DrawBitmapEx(const GUI_BITMAP* pBitmap, int x0, int y0, int xCenter, int yCenter, int xMag, int yMag); Parameter pBM x0 y0 xCenter
Pointer to the bitmap to display. X-position of the anker point in the display. Y-position of the anker point in the display. X-positiom of the anker point in the bitmap.
Meaning
2002-2007 Micrium
115
Meaning
Y-positiom of the anker point in the bitmap.
Additional information
A negative value of the xMag-parameter would mirror the bitmap in the X-axis and a negative value of the yMag-parameter would mirror the bitmap in the Y-axis. The unit of xMag- and yMag are thousandth. The position given by the parameter xCenter and yCenter specifies the pixel of the bitmap which should be displayed at the display at position x0/y0 independent of scaling or mirroring. This function can not be used to draw RLE-compressed bitmaps.
GUI_DrawBitmapHWAlpha()
Description
Draws a bitmap with alpha information on a multi layer system with hardware alpha blending support.
Prototype
void GUI_DrawBitmapHWAlpha(const GUI_BITMAP GUI_UNI_PTR * pBM, int x0, int y0); Parameter pBM x0 y0
Pointer to the bitmap to display. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Meaning
Additional information
In C/GUI logical colors are handled as 32 bit values. The lower 24 bits are used for the color information and the upper 8 bits are used to manage the alpha value. An alpha value of 0 means the image is opaque and a value of 0xFF means completely transparent (invisible). On systems with hardware support for alpha blending the alpha values need to be written to the display controller which does the alpha blending. Normally the alpha format of the hardware is not the same as the alpha definition in C/GUI described above. Mostly a value of 0 means fully transparent and higher values means the pixel becomes more visible. Because of this in the most cases custom color conversion routines are required to translate a logical color to the required hardware format. The sample folder contains the sample ALPHA_DrawBitmapHWAlpha which shows how to consider the requirement of custom color conversion.
GUI_DrawBitmapMag()
Description
This routine makes it possible to magnify a bitmap on the display.
Prototype
void GUI_DrawBitmapMag(const GUI_BITMAP* pBM, int x0, int y0,
2002-2007 Micrium
116
CHAPTER 7
Meaning
GUI_DrawStreamedBitmap()
Description
Draws a bitmap from a data bitmap data stream.
Prototype
void GUI_DrawStreamedBitmap(const GUI_BITMAP_STREAM* pBMH, int x, int y); Parameter pBMH x y
Pointer to the data stream. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Meaning
Additional information
You can use the bitmap converter (Chapter 10) to create bitmap data streams. The format of these streams is not the same as the format of a .bmp file.
7.8
Drawing lines
The most frequently used drawing routines are those that draw a line from one point to another.
GUI_DrawHLine()
Description
Draws a horizontal line one pixel thick from a specified starting point to a specified endpoint in the current window.
Prototype
void GUI_DrawHLine(int y, int x0, int x1); Parameter y x0 x1
Y-position. X-starting position. X-end position.
Meaning
Additional information
If x1 < x0, nothing will be displayed.
2002-2007 Micrium
117
With most LCD controllers, this routine is executed very quickly because multiple pixels can be set at once and no calculations are needed. If it is clear that horizontal lines are to be drawn, this routine executes faster than the GUI_DrawLine() routine.
GUI_DrawLine()
Description
Draws a line from a specified starting point to a specified endpoint in the current window (absolute coordinates).
Prototype
void GUI_DrawLine(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
X-starting position. Y-starting position. X-end position. Y-end position.
Meaning
Additional information
If part of the line is not visible because it is not in the current window or because part of the current window is not visible, this is due to clipping.
GUI_DrawLineRel()
Description
Draws a line from the current (X,Y) position to an endpoint specified by X-distance and Y-distance in the current window (relative coordinates).
Prototype
void GUI_DrawLineRel(int dx, int dy); Parameter dx dy Meaning
Distance in X-direction to end of line to draw. Distance in Y-direction end of line to draw.
GUI_DrawLineTo()
Description
Draws a line from the current (X,Y) position to an endpoint specified by X- and Ycoordinates in the current window.
Prototype
void GUI_DrawLineTo(int x, int y); Parameter x y
X-end position. Y-end position.
Meaning
2002-2007 Micrium
118
CHAPTER 7
GUI_DrawPolyLine()
Description
Connects a predefined list of points with lines in the current window.
Prototype
void GUI_DrawPolyLine(const GUI_POINT* pPoint, int NumPoints, int x, int y); Parameter pPoint NumPoints x y
Pointer to the polyline to display. Number of points specified in the list of points. X-position of origin. Y-position of origin.
Meaning
Additional information
The starting point and endpoint of the polyline need not be identical.
GUI_DrawVLine()
Description
Draws a vertical line one pixel thick from a specified starting point to a specified endpoint in the current window.
Prototype
void GUI_DrawVLine(int x, int y0, int y1); Parameter x y0 y1
X-position. Y-starting position. Y-end position.
Meaning
Additional information
If y1 < y0, nothing will be displayed. With most LCD controllers, this routine is executed very quickly because multiple pixels can be set at once and no calculations are needed. If it is clear that vertical lines are to be drawn, this routine executes faster than the GUI_DrawLine() routine.
GUI_GetLineStyle()
Description
Returns the current line style used by the function GUI_DrawLine.
Prototype
U8 GUI_GetLineStyle (void);
Return value
Current line style used by the function GUI_DrawLine.
2002-2007 Micrium
119
GUI_MoveRel()
Description
Moves the current line pointer relative to its current position.
Prototype
void GUI_MoveRel(int dx, int dy); Parameter dx dy
Distance to move in X. Distance to move in Y.
Meaning
Related topics
GUI_DrawLineTo(), GUI_MoveTo()
GUI_MoveTo()
Description
Moves the current line pointer to the given position.
Prototype
void GUI_MoveTo(int x, int y); Parameter x y
New position in X. New position in Y.
Meaning
GUI_SetLineStyle()
Description
Sets the current line style used by the function GUI_DrawLine.
Prototype
U8 GUI_SetLineStyle(U8 LineStyle); Parameter LineStyle Meaning
New line style to be used (see table below).
Permitted values for parameter LineStyle GUI_LS_SOLID GUI_LS_DASH GUI_LS_DOT GUI_LS_DASHDOT GUI_LS_DASHDOTDOT
Lines would be drawn solid (default). Lines would be drawn dashed. Lines would be drawn dotted. Lines would be drawn alternating with dashes and dots. Lines would be drawn alternating with dashes and double dots.
Return value
Previous line style used by the function GUI_DrawLine.
2002-2007 Micrium
120
CHAPTER 7
Additional information
This function sets only the line style used by GUI_DrawLine. The style will be used only with a pen size of 1.
7.9
Drawing polygons
The polygon drawing routines can be helpful when drawing vectorized symbols.
GUI_DrawPolygon()
Description
Draws the outline of a polygon defined by a list of points in the current window.
Prototype
void GUI_DrawPolygon(const GUI_POINT* pPoint, int NumPoints, int x, int y); Parameter pPoint NumPoints x y
Pointer to the polygon to display. Number of points specified in the list of points. X-position of origin. Y-position of origin.
Meaning
Additional information
The polyline drawn is automatically closed by connecting the endpoint to the starting point.
GUI_EnlargePolygon()
Description
Enlarges a polygon on all sides by a specified length in pixels.
Prototype
void GUI_EnlargePolygon(GUI_POINT* pDest, const GUI_POINT* pSrc, int NumPoints, int Len); Parameter pDest pSrc NumPoints Len
Pointer to the destination polygon. Pointer to the source polygon. Number of points specified in the list of points. Length (in pixels) by which to enlarge the polygon.
Meaning
Additional information
Make sure the destination array of points is equal to or larger than the source array.
Example
#define countof(Array) (sizeof(Array) / sizeof(Array[0])) const GUI_POINT aPoints[] = { { 0, 20}, { 40, 20},
2002-2007 Micrium
121 { 20, }; GUI_POINT aEnlargedPoints[countof(aPoints)]; void Sample(void) { int i; GUI_Clear(); GUI_SetDrawMode(GUI_DM_XOR); GUI_FillPolygon(aPoints, countof(aPoints), 140, 110); for (i = 1; i < 10; i++) { GUI_EnlargePolygon(aEnlargedPoints, aPoints, countof(aPoints), i * 5); GUI_FillPolygon(aEnlargedPoints, countof(aPoints), 140, 110); } } 0}
GUI_FillPolygon()
Description
Draws a filled polygon defined by a list of points in the current window.
Prototype
void GUI_FillPolygon(const GUI_POINT* pPoint, int NumPoints, int x, int y); Parameter pPoint NumPoints x y Meaning
Pointer to the polygon to display and to fill. Number of points specified in the list of points. X-position of origin. Y-position of origin.
Additional information
The polyline drawn is automatically closed by connecting the endpoint to the starting point. It is not required that the endpoint touches the outline of the polygon. Rendering a polygon is done by drawing one or more horizontal lines for each y-position of the polygon. Per default the maximum number of points used to draw the horizontal lines for one y-position is 12 (which means 6 lines per y-position). If this value needs to be increased, the macro GUI_FP_MAXCOUNT can be used to set the maximum number of points.
Example
#define GUI_FP_MAXCOUNT 50
2002-2007 Micrium
122
CHAPTER 7
GUI_MagnifyPolygon()
Description
Magnifies a polygon by a specified factor.
Prototype
void GUI_MagnifyPolygon(GUI_POINT* pDest, const GUI_POINT* pSrc, int NumPoints, int Mag); Parameter pDest pSrc NumPoints Mag
Pointer to the destination polygon. Pointer to the source polygon. Number of points specified in the list of points. Factor used to magnify the polygon.
Meaning
Additional information
Make sure the destination array of points is equal to or larger than the source array. Note the difference between enlarging and magnifying a polygon. Whereas setting the parameter Len to 1 will enlarge the polygon by one pixel on all sides, setting the parameter Mag to 1 will have no effect.
Example
#define countof(Array) (sizeof(Array) / sizeof(Array[0])) const GUI_POINT aPoints[] = { { 0, 20}, { 40, 20}, { 20, 0} }; GUI_POINT aMagnifiedPoints[countof(aPoints)]; void Sample(void) { int Mag, y = 0, Count = 4; GUI_Clear(); GUI_SetColor(GUI_GREEN); for (Mag = 1; Mag <= 4; Mag *= 2, Count /= 2) { int i, x = 0; GUI_MagnifyPolygon(aMagnifiedPoints, aPoints, countof(aPoints), Mag); for (i = Count; i > 0; i--, x += 40 * Mag) { GUI_FillPolygon(aMagnifiedPoints, countof(aPoints), x, y); } y += 20 * Mag; } }
2002-2007 Micrium
123
GUI_RotatePolygon()
Description
Rotates a polygon by a specified angle.
Prototype
void GUI_RotatePolygon(GUI_POINT* pDest, const GUI_POINT* pSrc, int NumPoints, float Angle); Parameter pDest pSrc NumPoints Angle
Pointer to the destination polygon. Pointer to the source polygon. Number of points specified in the list of points. Angle in radian used to rotate the polygon.
Meaning
Additional information
Make sure the destination array of points is equal to or larger than the source array.
Example
The following example shows how to draw a polygon. 2DGL_DrawPolygon.c in the samples shipped with C/GUI. It is available as
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : 2DGL_DrawPolygon.c Purpose : Example for drawing a polygon ---------------------------------------------------------------------*/ #include "gui.h" /******************************************************************* *
2002-2007 Micrium
124
CHAPTER 7 * The points of the arrow * ******************************************************************** */ static const GUI_POINT aPointArrow[] = { { 0, -5}, {-40, -35}, {-10, -25}, {-10, -85}, { 10, -85}, { 10, -25}, { 40, -35}, }; /******************************************************************* * * Draws a polygon * ******************************************************************** */ static void DrawPolygon(void) { int Cnt =0; GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetFont(&GUI_Font8x16); GUI_SetColor(0x0); GUI_DispStringAt("Polygons of arbitrary shape ", 0, 0); GUI_DispStringAt("in any color", 120, 20); GUI_SetColor(GUI_BLUE); /* Draw filled polygon */ GUI_FillPolygon (&aPointArrow[0],7,100,100); } /******************************************************************* * * main * ******************************************************************** */ void main(void) { GUI_Init(); DrawPolygon(); while(1) GUI_Delay(100); }
2002-2007 Micrium
125
Prototype
void GUI_DrawCircle(int x0, int y0, int r); Parameter x0 y0 r Meaning
X-position of the center of the circle in pixels of the client window. Y-position of the center of the circle in pixels of the client window. Radius of the circle (half the diameter). Minimum: 0 (will result in a point); maximum: 180.
Additional information
This routine cannot handle a radius in excess of 180 because it uses integer calculations that would otherwise produce an overflow. However, for most embedded applications this is not a problem since a circle with diameter 360 is larger than the display anyhow.
Example
// Draw concentric circles void ShowCircles(void) { int i; for (i=10; i<50; i++) GUI_DrawCircle(120,60,i); }
GUI_FillCircle()
Description
Draws a filled circle of specified dimensions at a specified position in the current window.
Prototype
void GUI_FillCircle(int x0, int y0, int r); Parameter x0 y0 r Meaning
X-position of the center of the circle in pixels of the client window. Y-position of the center of the circle in pixels of the client window. Radius of the circle (half the diameter). Minimum: 0 (will result in a point); maximum: 180.
2002-2007 Micrium
126
CHAPTER 7
Additional information
This routine cannot handle a radius in excess of 180.
Example
GUI_FillCircle(120,60,50);
Prototype
void GUI_DrawEllipse Parameter x0 y0 rx ry (int x0, int y0, int rx, int ry); Meaning
X-position of the center of the circle in pixels of the client window. Y-position of the center of the circle in pixels of the client window. X-radius of the ellipse (half the diameter). Minimum: 0; maximum: 180. Y-radius of the ellipse (half the diameter). Minimum: 0; maximum: 180.
Additional information
This routine cannot handle rx/ry parameters in excess of 180 because it uses integer calculations that would otherwise produce an overflow.
Example
See the GUI_FillEllipse() example.
GUI_FillEllipse()
Description
Draws a filled ellipse of specified dimensions at a specified position in the current window.
2002-2007 Micrium
127
Prototype
void GUI_FillEllipse(int x0, int y0, int rx, int ry); Parameter x0 y0 rx ry Meaning
X-position of the center of the circle in pixels of the client window. Y-position of the center of the circle in pixels of the client window. X-radius of the ellipse (half the diameter). Minimum: 0; maximum: 180. Y-radius of the ellipse (half the diameter). Minimum: 0; maximum: 180.
Additional information
This routine cannot handle a rx/ry parameters in excess of 180.
Example
/* Demo ellipses */ GUI_SetColor(0xff); GUI_FillEllipse(100, 180, 50, 70); GUI_SetColor(0x0); GUI_DrawEllipse(100, 180, 50, 70); GUI_SetColor(0x000000); GUI_FillEllipse(100, 180, 10, 50);
2002-2007 Micrium
128
CHAPTER 7
Prototype
void GL_DrawArc (int xCenter, int yCenter, int rx, int ry, int a0, int a1); Parameter xCenter yCenter rx ry a0 a1 Meaning
Horizontal position of the center in pixels of the client window. Vertical position of the center in pixels of the client window. X-radius (pixels). Y-radius (pixels). Starting angle (degrees). Ending angle (degrees).
Limitations
Currently the ry parameter is not used. The rx parameter is used instead.
Additional information
GUI_DrawArc() uses the floating-point library. It cannot handle rx/ry parameters in excess of 180 because it uses integer calculations that would otherwise produce an overflow.
Example
void DrawArcScale(void) { int x0 = 160; int y0 = 180; int i; char ac[4]; GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetPenSize( 5 ); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontComic18B_ASCII); GUI_SetColor( GUI_BLACK ); GUI_DrawArc( x0,y0,150, 150,-30, 210 ); GUI_Delay(1000); for (i=0; i<= 23; i++) { float a = (-30+i*10)*3.1415926/180; int x = -141*cos(a)+x0; int y = -141*sin(a)+y0; if (i%2 == 0) GUI_SetPenSize( 5 ); else GUI_SetPenSize( 4 ); GUI_DrawPoint(x,y); if (i%2 == 0) { x = -123*cos(a)+x0; y = -130*sin(a)+y0; sprintf(ac, "%d", 10*i); GUI_SetTextAlign(GUI_TA_VCENTER); GUI_DispStringHCenterAt(ac,x,y); } } }
2002-2007 Micrium
129
Prototype
void GUI_DrawGraph(I16 *paY, int NumPoints, int x0, int y0); Parameter paY NumPoints x0 y0
Number of Y-values to be displayed. Starting point in x. Starting point in y.
Meaning
Pointer to an array containing the Y-values of the graph.
Additional information
The function first sets the line-cursor to the position specified with x0, y0 and the first Y-value of the given array. Then it starts drawing lines to x0 + 1, y0 + *(paY + 1), x0 + 2, y0 + *(paY + 2) and so on.
Example
#include "GUI.h" #include <stdlib.h> I16 aY[100]; void MainTask(void) { int i; GUI_Init(); for (i = 0; i < GUI_COUNTOF(aY); i++) { aY[i] = rand() % 50; } GUI_DrawGraph(aY, GUI_COUNTOF(aY), 0, 0);
2002-2007 Micrium
130 }
CHAPTER 7
Prototype
void GUI_DrawPie(int x0, int y0, int r, int a0, int a1, int Type); Parameter x0 y0 r a0 a1 Type Meaning
X-position of the center of the circle in pixels of the client window. Y-position of the center of the circle in pixels of the client window. Radius of the circle (half the diameter). Starting angle (degrees). End angle (degrees). (reserved for future use, should be 0)
Example
int i, a0, a1; const unsigned aValues[] = {100, 135, 190, 240, 340, 360}; const GUI_COLOR aColors[] = { GUI_BLUE, GUI_GREEN, GUI_RED, GUI_CYAN, GUI_MAGENTA, GUI_YELLOW }; for (i = 0; i < GUI_COUNTOF(aValues); i++) { a0 = (i == 0) ? 0 : aValues[i - 1]; a1 = aValues[i]; GUI_SetColor(aColors[i]); GUI_DrawPie(100, 100, 50, a0, a1, 0); }
2002-2007 Micrium
131
Prototype
void GUI_RestoreContext(const GUI_CONTEXT* pContext); Parameter pContext Meaning
Pointer to a GUI_CONTEXT structure containing the new context.
Additional information
The GUI-context contains the current state of the GUI like the text cursor position, a pointer to the current font and so on. Sometimes it could be usefull to save the current state ant to restore it later. For this you can use these functions.
GUI_SaveContext()
Description
The function saves the current GUI-context. (See also GUI_RestoreContext)
Prototype
void GUI_SaveContext(GUI_CONTEXT* pContext); Parameter pContext Meaning
Pointer to a GUI_CONTEXT structure for saving the current context.
7.16 Clipping
GUI_SetClipRect()
Description
Sets the clipping rectangle used for limiting the output.
Prototype
void GUI_SetClipRect(const GUI_RECT* pRect); Parameter pRect Meaning
Pointer to the rectangle which should be used for clipping. A NULL pointer should be used to restore the default value.
Additional information
The clipping area is per default limited to the configured (virtual) display size. Under some circumstances it can be usefull to use a smaller clipping rectangle, which can be set using this function. The rectangle referred to should remain unchanged until the function is called again with a NULL pointer.
Sample
The following sample shows how to use the function:
GUI_RECT Rect = {10, 10, 100, 100}; GUI_SetClipRect(&Rect); . User's & reference manual for C/GUI 2002-2007 Micrium
CHAPTER 7
2002-2007 Micrium
133
The recommended and most efficient way to display a bitmap known at compile time is to use the bitmap converter to convert it into a "C" file and add it to the project / makefile. For details about the bitmap converter please refer to chapter Chapter 10, "Bitmap converter". If the application needs to display images not known at compile needs to be available in a graphic file format support by C/GUI. image file can reside in memory or on an other storage device; it even if the amount of availalble memory is less than the size of the C/GUI currently supports BMP, JPEG and GIF file formats. time, the image In this case, the can be displayed image file.
2002-2007 Micrium
134
CHAPTER 8
8.1
8.1.1
Supported formats
The BMP file format has been defined by Microsoft. There are a number of different formats as shown in the table below: Bits per pixel 1 4 4 8 8 16 24 32 yes yes yes yes yes no no no Indexed no no yes no yes no no no Compression yes yes no yes no no yes yes Supported
8.1.2
The table below lists the available BMP file related routines in alphabetical order. Detailed descriptions follows: Routine GUI_BMP_Draw() GUI_BMP_DrawEx() GUI_BMP_DrawScaled() GUI_BMP_DrawScaledEx() GUI_BMP_GetXSize() GUI_BMP_GetXSizeEx() GUI_BMP_GetYSize() GUI_BMP_GetYSizeEx() GUI_BMP_Serialize() GUI_BMP_SerializeEx() Explanation
Draws a bitmap file which has been loaded into memory. Draws a BMP file which needs not to be loaded into memory. Draws a BMP file with scaling which has been loaded into memory. Draws a BMP file with scaling which needs not to be loaded into memory. Returns the X-size of a bitmap loaded into memory. Returns the X-size of a BMP file which needs not to be loaded into memory. Returns the Y-size of a bitmap loaded into memory. Returns the Y-size of a BMP file which needs not to be loaded into memory. Creates a BMP-file. Creates a BMP-file from the given rectangle.
GUI_BMP_Draw()
Description
Draws a Windows .bmp file, which has been loaded into memory, at a specified position in the current window.
2002-2007 Micrium
135
Prototype
int GUI_BMP_Draw(const void* pBMP, int x0, int y0); Parameter pBMP x0 y0 Meaning
Pointer to the start of the memory area in which the .bmp file resides. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Additional information
There are different types of .bmp files. Supported types are 1/4/8/24 bpp files. These are the most common file types; other types and compression are not supported. The samples shipped with C/GUI contain an example that uses this function to show all files in the Windows system directory.
GUI_BMP_DrawEx()
Description
Draws a .bmp file, which does not have to be loaded into memory, at a specified position in the current window.
Prototype
int GUI_BMP_DrawEx(GUI_BMP_GET_DATA_FUNC * fpGetData, void * p, int x0, int y0); Parameter fpGetData p x0 y0 Meaning
Pointer to a function which is called by the BMP routine for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Return value
Zero on success, nonzero if the function fails.
Additional information
This function is used for drawing .bmp files if not enough RAM is available to load the whole file into memory. The GUI library then calls the function pointed by the parameter fpGetData to read the data.
Example
The following code excerpt shows how to use the function:
2002-2007 Micrium
CHAPTER 8
int APP_GetData(void * p, int NumBytesReq, const U8 ** ppData, unsigned StartOfFile){ DWORD NumBytesRead; HANDLE * phFile; phFile = (HANDLE *)p; if (StartOfFile) { /* Reset file pointer to the beginning of the file */ .../* TBD */ } /* Read BMP file data into buffer */ .../* TBD */ return NumBytesRead; } void DrawBMP(HANDLE hFile, int x, int y) { GUI_BMP_DrawEx(APP_GetData, (void *)&hFile, x, y); }
GUI_BMP_DrawScaled()
Description
Draws a .bmp file, which has been loaded into memory, at a specified position in the current window using scaling.
Prototype
int GUI_BMP_DrawScaled(const void * pFileData, int x0, int y0, int Num, int Denom); Parameter pFileData x0 y0 Num Denom Meaning
Pointer to the start of the memory area in which the .bmp file resides. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Numerator to be used for scaling. Denominator used for scaling.
Return value
Zero on success, nonzero if the function fails.
Additional information
The function scales the image by building a fraction with the given numerator and denominator. If for example an image should be shrinked to 2/3 of size the parameter Num should be 2 and Denom should be 3.
GUI_BMP_DrawScaledEx()
Description
Draws a .bmp file, which does not have to be loaded into memory, at a specified position in the current window using scaling.
Prototype
int GUI_BMP_DrawScaledEx(GUI_BMP_GET_DATA_FUNC * fpGetData, void * p,
2002-2007 Micrium
137
int x0, int y0, int Num, int Denom); Parameter fpGetData p x0 y0 Num Denom Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Numerator to be used for scaling. Denominator used for scaling.
Return value
Zero on success, nonzero if the function fails.
Additional information
The function scales the image by building a fraction with the given numerator and denominator. If for example an image should be shrinked to 2/3 of size the parameter Num should be 2 and Denom should be 3. For more details please refer to the function GUI_BMP_DrawEx() explained earlier in this chapter.
GUI_BMP_GetXSize()
Description
Returns the X-size of a specified bitmap which has been loaded into memory.
Prototype
int GUI_BMP_GetXSize(const void* pBMP); Parameter pBMP Meaning
Pointer to the start of the memory area in which the .bmp file resides.
Return value
X-size of the bitmap.
GUI_BMP_GetXSizeEx()
Description
Returns the X-size of a specified .bmp file which does not have to be loaded into memory.
Prototype
int GUI_BMP_GetXSizeEx(GUI_BMP_GET_DATA_FUNC * fpGetData, void * p); Parameter fpGetData p Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
Return value
X-size of the bitmap.
2002-2007 Micrium
138
CHAPTER 8
GUI_BMP_GetYSize()
Description
Returns the Y-size of a specified bitmap which has been loaded into memory.
Prototype
int GUI_BMP_GetYSize(const void* pBMP);; Parameter pBMP Meaning
Pointer to the start of the memory area in which the .bmp file resides.
Return value
Y-size of the bitmap.
GUI_BMP_GetYSizeEx()
Description
Returns the Y-size of a specified .bmp file which does not have to be loaded into memory.
Prototype
int GUI_BMP_GetYSizeEx(GUI_BMP_GET_DATA_FUNC * fpGetData, void * p); Parameter fpGetData p Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
Return value
Y-size of the bitmap.
GUI_BMP_Serialize()
Description
The function creates a BMP-file containing the complete contents of the LCD.
Prototype
void GUI_BMP_Serialize(GUI_CALLBACK_VOID_U8_P * pfSerialize, void * p); Parameter pfSerialize p
Pointer to serialization function Pointer to user defined data passed to serialization function
Meaning
Additional information
The following sample will show how to create a BMP-file under windows.
static void _DrawSomething(void) { /* Draw something */ GUI_DrawLine(10, 10, 100, 100); } static void _WriteByte2File(U8 Data, void * p) { U32 nWritten; WriteFile(*((HANDLE *)p), &Data, 1, &nWritten, NULL); User's & reference manual for C/GUI 2002-2007 Micrium
139 } static void _ExportToFile(void) { HANDLE hFile = CreateFile("C:\\GUI_BMP_Serialize.bmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); GUI_BMP_Serialize(_WriteByte2File, &hFile); CloseHandle(hFile); } void MainTask(void) { GUI_Init(); _DrawSomething(); _ExportToFile(); }
GUI_BMP_SerializeEx()
Description
The function creates a BMP-file containing the given area.
Prototype
void GUI_BMP_SerializeEx(GUI_CALLBACK_VOID_U8_P * pfSerialize, int x0, int y0, int xSize, int ySize, void * p); Parameter pfSerialize x0 y0 xSize ySize p
Pointer to serialization function. Start position in X to create the BMP-file. Start position in Y to create the BMP-file. Size in X. Size in Y. Pointer to user defined data passed to serialization function.
Meaning
Additional information
(See GUI_BMP_Serialize)
2002-2007 Micrium
140
CHAPTER 8
8.2
8.2.1
This software implements JPEG baseline, extended-sequential, and progressive compression processes. Provision is made for supporting all variants of these processes, although some uncommon parameter settings aren't implemented yet. For legal reasons, code for the arithmetic-coding variants of JPEG is not distributed. It appears that the arithmetic coding option of the JPEG spec is covered by patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot legally be used without obtaining one or more licenses. For this reason, support for arithmetic coding has not been included to the free JPEG software. (Since arithmetic coding provides only a marginal gain over the unpatented Huffman mode, it is unlikely that very many implementations will support it.) So far as we are aware, there are no patent restrictions on the remaining code. The library does cot contain provision for supporting the hierarchical or lossless processes defined in the standard.
8.2.2
Under some circumstances it can be useful to add a JPEG file as C file to the project. In this case the JPEG file first needs to be converted to a C file. This can be done using the tool Bin2C.exe shipped with C/GUI. It can be found in the Tools subfolder. It converts the given binary file (in this case the JPEG file) to a C file. The filename of the C file is the same as the binary file name with the file extension .c. The following steps will show how to embed a JPEG file using Bin2C: Start Bin2C.exe and select the JPEG file to be converted to a C file, for example Image.jpeg and convert it to a C file. Add the C file to the project.
Sample
The following sample shows how to display the converted JPEG file:
#include "GUI.h" #include "Image.c" /* Include the converted C file */ void MainTask(void) { GUI_Init(); GUI_JPEG_Draw(acImage, sizeof(acImage), 0, 0); ... }
2002-2007 Micrium
141
8.2.3
The graphic library first decodes the graphic information. If the image has to be drawn the decoding process takes considerable time. If a JPEG file is used in a frequently called callback routine of the window manager, the decoding process can take a considerable amount of time. The calculation time can be reduced by the use of memory devices. The best way would be to draw the image first into a memory device. In this case the decompression would be executed only one time. For more information about memory devices please take a look to the memory device chapter.
8.2.4
Memory usage
The JPEG decompression uses 38Kb RAM for decompression independent of the image size and a size dependent amount of bytes. The RAM requirement can be calculated as follows: Approximate RAM requirement = X-Size of image * 60 + 38Kb
8.2.5
Contrary to baseline and extended-sequential JPEG files progressive JPEGs consist of multiple scans. Each of these scans is based on the previous scan(s) and refines the appearance of the JPEG image. This requires scanning the whole file even if only one line needs to be decompressed. If enough RAM is configured for the whole image data, the decompression needs only be done one time. If less RAM is configured, the JPEG decoder uses banding for drawing the image. The more bands required the more times the image needs to be decompressed and the slower the performance. With other words: The more RAM the better the performance.
8.2.6
The table below lists the available JPEG file related routines in alphabetical order. Detailed descriptions follows: Routine GUI_JPEG_Draw() GUI_JPEG_DrawEx() GUI_JPEG_DrawScaled() Explanation
Draws a JPEG file which has been loaded into memory. Draws a JPEG file which needs not to be loaded into memory. Draws a JPEG file with scaling which has been loaded into memory. Draws a JPEG file with scaling which needs not to be loaded into Fills a GUI_JPEG_INFO structure from a JPEG file which has been loaded into memory. Fills a GUI_JPEG_INFO structure from a JPEG file which needs not to be loaded into memory.
GUI_JPEG_Draw()
Description
Draws a .jpeg file, which has been loaded into memory, at a specified position in the current window.
2002-2007 Micrium
142
CHAPTER 8
Prototype
int GUI_JPEG_Draw(const void * pFileData, int DataSize, int x0, int y0); Parameter pFileData DataSize x0 y0
Number of bytes of the .jpeg file. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Meaning
Pointer to the start of the memory area in which the .jpeg file resides.
Return value
Zero if success, nonzero if the function fails. (The current implementation always returns 0)
Additional information
The sample folder contains the sample 2DGL_DrawJPG.c which shows how to use the function.
GUI_JPEG_DrawEx()
Description
Draws a .jpeg file, which does not have to be loaded into memory, at a specified position in the current window.
Prototype
int GUI_JPEG_DrawEx(GUI_JPEG_GET_DATA_FUNC * fpGetData, void * p, int x0, int y0); Parameter fpGetData p x0 y0 Meaning
Pointer to a function which is called by the JPEG routine for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Return value
Zero if success, nonzero if the function fails. (The current implementation always returns 0)
Additional information
This function is used for drawing .jpegs if not enough RAM is available for loading the whole file into memory. The JPEG library then calls the function pointed by the parameter fpGetData for getting data on demand.
Meaning
2002-2007 Micrium
143
Meaning
Pointer to data pointer. This pointer should be set to a valid location. If this flag is 1, the data pointer should be set to the beginning of the data stream.
Example
The following code excerpt will show how to use the function:
static char acBuffer[0x200]; int APP_GetData(void * p, int NumBytesReq, const U8 ** ppData, unsigned StartOfFile){ int NumBytes; HANDLE hFile; hFile = *(HANDLE *)p; if (StartOfFile) { /* Reset file pointer to the beginning of the file */ .../* TBD */ } /* Calculate number of bytes to read */ NumBytes = (sizeof(acBuffer) < NumBytesReq) ? sizeof(acBuffer) : NumBytesReq; /* Read JPEG file data into buffer */ .../* TBD */ return NumBytes; } void DrawJPEG(HANDLE hFile, int x, int y) { GUI_JPEG_DrawEx(APP_GetData, (void *)&hFile, x, y); }
The sample folder contains the sample 2DGL_DrawJPGScaled.c which shows how to use a GetData function.
GUI_JPEG_DrawScaled()
Description
Draws a .jpeg file, which has been loaded into memory, at a specified position in the current window using scaling.
Prototype
int GUI_JPEG_DrawScaled(const void * pFileData, int DataSize, int x0, int y0, int Num, int Denom); Meaning
Pointer to the start of the memory area in which the .jpeg file resides. Number of bytes of the .jpeg file. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Numerator to be used for scaling. Denominator used for scaling.
Return value
Zero if success, nonzero if the function fails. (The current implementation always returns 0)
2002-2007 Micrium
144
CHAPTER 8
Additional information
The function scales the image by building a fraction with the given numerator and denominator. If for example an image should be shrinked to 2/3 of size the parameter Num should be 2 and Denom should be 3. The sample folder contains the sample 2DGL_DrawJPGScaled.c which shows how to draw scaled JPEGs.
GUI_JPEG_DrawScaledEx()
Description
Draws a .jpeg file, which does not have to be loaded into memory, at a specified position in the current window using scaling.
Prototype
int GUI_JPEG_DrawScaledEx(GUI_JPEG_GET_DATA_FUNC * fpGetData, void * p, int x0, int y0, int Num, int Denom); Meaning
Pointer to a function which is called by the JPEG routine for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Numerator to be used for scaling. Denominator used for scaling.
Return value
Zero if success, nonzero if the function fails. (The current implementation always returns 0)
Additional information
The function scales the image by building a fraction with the given numerator and denominator. If for example an image should be shrinked to 2/3 of size the parameter Num should be 2 and Denom should be 3. For more details please refer to the function GUI_JPEG_DrawEx() explained earlier in this chapter. The sample folder contains the sample 2DGL_DrawJPGScaled.c which shows how to use the function.
GUI_JPEG_GetInfo()
Description
Fills a GUI_JPEG_INFO structure with information about the given image.
Prototype
int GUI_JPEG_GetInfo(const void * pFileData, int DataSize,
2002-2007 Micrium
145
Meaning
Pointer to the start of the memory area in which the .jpeg file resides.
Return value
Zero if success, nonzero if the function fails. (The current implementation always returns 0)
Elements of GUI_JPEG_INFO
Data type int int Element XSize YSize
Pixel size in X of the image. Pixel size in Y of the image.
Meaning
Additional information
The sample folder contains the sample 2DGL_DrawJPG.c which shows how to use the function.
GUI_JPEG_GetInfoEx()
Description
Fills a GUI_JPEG_INFO structure with information about a .jpeg file, which does not have to be loaded into memory.
Prototype
int GUI_JPEG_GetInfoEx(GUI_JPEG_GET_DATA_FUNC * fpGetData, void * p, GUI_JPEG_INFO * pInfo); Meaning
Pointer to a function which is called by the JPEG routine for getting data. Void pointer passed to the function pointed by
fpGetData .
Return value
Zero if success, nonzero if the function fails. (The current implementation always returns 0)
Additional information
For more details about the function and the parameters fpGetData and p please refer to the function GUI_JPEG_GetInfo() and GUI_JPEG_DrawEx() explained earlier in this chapter. The sample folder contains the sample 2DGL_DrawJPGScaled.c which shows how to use the function.
2002-2007 Micrium
146
CHAPTER 8
8.3
8.3.1
Under some circumstances it can be useful to add a GIF file as C file to the project. This can be done by exactly the same way as described before under JPEG file support.
8.3.2
The graphic library first decodes the graphic information. If the image has to be drawn the decoding process takes considerable time. If a GIF file is used in a frequently called callback routine of the window manager, the decoding process can take a considerable amount of time. The calculation time can be reduced by the use of memory devices. The best way would be to draw the image first into a memory device. In this case the decompression would be executed only one time. For more information about memory devices please take a look to the memory device chapter.
8.3.3
Memory usage
C/GUI needs about 16Kb static work area for
8.3.4
The table below lists the available GIF file related routines in alphabetical order. Detailed descriptions follows: Routine GUI_GIF_Draw() GUI_GIF_DrawEx() GUI_GIF_DrawSub() GUI_GIF_DrawSubEx() GUI_GIF_DrawSubScaled() Explanation
Draws a GIF file which has been loaded into memory. Draws the given sub image of a GIF file which has been loaded into memory. Draws the given sub image of a GIF file which has been loaded into memory. Draws the given sub image of a GIF file which needs not to be loaded into memory. Draws the given sub image of a GIF file with scaling which has been loaded into memory. Draws the given sub image of a GIF file with scaling which needs
GUI_GIF_DrawSubScaledEx() not to be loaded into memory. Returns the given comment of a GIF file. GUI_GIF_GetComment() GUI_GIF_GetCommentEx() GUI_GIF_GetImageInfo()
Returns the given comment of a GIF file which needs not to be loaded into memory. Returns information about the given sub image.
2002-2007 Micrium
147
Explanation
Returns information about the given sub image of a GIF file which needs not to be loaded into memory. Returns a GUI_GIF_IMAGE_INFO structure used for drawing animated GIFs. Returns information about a GIF file which needs not to be loaded into memory. Returns the X-size of a bitmap loaded into memory. Returns the X-size of a bitmap which needs not to be loaded into memory. Returns the Y-size of a bitmap loaded into memory. Returns the Y-size of a bitmap which needs not to be loaded into memory.
GUI_GIF_Draw()
Description
Draws the first image of a .gif file, which has been loaded into memory, at a specified position in the current window.
Prototype
int GUI_GIF_Draw(const void * pGIF, U32 NumBytes, int x0, int y0); Parameter pGIF NumBytes x0 y0
Number of bytes of the .gif file. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
Meaning
Pointer to the start of the memory area in which the .gif file resides.
Return value
0 on success, != 0 on error.
Additional information
If the file contains more than one image, the function shows only the first image of the file. Transparency and interlaced images are supported.
GUI_GIF_DrawEx()
Description
Draws a .gif file, which does not have to be loaded into memory, at a specified position in the current window.
Prototype
int GUI_GIF_DrawEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p, int x0, int y0); Parameter fpGetData p x0 y0 Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display.
2002-2007 Micrium
148
CHAPTER 8
Return value
0 on success, != 0 if the function fails.
Additional information
This function is used for drawing .jpegs if not enough RAM is available to load the whole file into memory. The JPEG library then calls the function pointed by the parameter fpGetData to read the data.
Meaning
Example
The following code excerpt shows how to use the function:
static char acBuffer[0x200]; int APP_GetData(void * p, int NumBytesReq, const U8 ** ppData, unsigned StartOfFile){ int NumBytes; HANDLE hFile; hFile = *(HANDLE *)p; if (StartOfFile) { /* Reset file pointer to the beginning of the file */ .../* TBD */ } /* Calculate number of bytes to read */ NumBytes = (sizeof(acBuffer) < NumBytesReq) ? sizeof(acBuffer) : NumBytesReq; /* Read JPEG file data into buffer */ .../* TBD */ return NumBytes; } void DrawJPEG(HANDLE hFile, int x, int y) { GUI_JPEG_DrawEx(APP_GetData, (void *)&hFile, x, y); }
GUI_GIF_DrawSub()
Description
Draws the given sub image of a .gif file, which has been loaded into memory, at a specified position in the current window.
Prototype
int GUI_GIF_DrawSub(const void * pGIF, U32 NumBytes,
2002-2007 Micrium
149
int x0, int y0, int Index); Parameter pGIF NumBytes x0 y0 Index
Number of bytes of the .gif file. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Zerobased index of sub image to be shown.
Meaning
Pointer to the start of the memory area in which the .gif file resides.
Return value
0 on success, != 0 on error.
Additional information
The function manages the background pixels between the current and the previous image. If for example sub image #3 should be drawn at offset x20/y20 with a size of w10/h10 and the previous sub image was shown at x15/y15 with a size of w20/h20 and the background needs to be redrawn, the function fills the pixels between the images with the background color. The file 2DGL_DrawGIF.c of the sample folder shows how to use the function.
GUI_GIF_DrawSubEx()
Description
Draws the given sub image of a .gif file, which does not have to be loaded into memory, at a specified position in the current window.
Prototype
int GUI_GIF_DrawSubEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p, int x0, int y0, int Index); Parameter fpGetData p x0 y0 Index Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Zerobased index of sub image to be shown.
Return value
Zero on success, nonzero if the function fails.
Additional information
This function is used for drawing .gif images if not enough RAM is available to load the whole file into memory. The GUI library then calls the function pointed by the parameter fpGetData to read the data. For more details please refer to the function GUI_GIF_DrawEx() explained earlier in this chapter.
2002-2007 Micrium
150
CHAPTER 8
GUI_GIF_DrawSubScaled()
Description
Draws the given sub image of a .gif file, which has been loaded into memory, at a specified position in the current window using scaling.
Prototype
int GUI_GIF_DrawSubScaled(const void * pFileData, int x0, int y0, int Index, int Num, int Denom); Parameter pFileData DataSize x0 y0 Index Num Denom
Number of bytes of the .jpeg file. X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Zerobased index of sub image to be shown. Numerator to be used for scaling. Denominator used for scaling.
Meaning
Pointer to the start of the memory area in which the .jpeg file resides.
Return value
Zero on success, nonzero if the function fails.
Additional information
The function scales the image by building a fraction with the given numerator and denominator. If for example an image should be shrinked to 2/3 of size the parameter Num should be 2 and Denom should be 3.
GUI_GIF_DrawSubScaledEx()
Description
Draws the given sub image of a .gif file, which does not have to be loaded into memory, at a specified position in the current window using scaling.
Prototype
int GUI_GIF_DrawSubScaledEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p, int x0, int y0, int Index, int Num, int Denom); Parameter fpGetData p x0 y0 Index Num Denom Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
X-position of the upper left corner of the bitmap in the display. Y-position of the upper left corner of the bitmap in the display. Zerobased index of sub image to be shown. Numerator to be used for scaling. Denominator used for scaling.
Return value
Zero on success, nonzero if the function fails.
2002-2007 Micrium
151
Additional information
The function scales the image by building a fraction with the given numerator and denominator. If for example an image should be shrinked to 2/3 of size the parameter Num should be 2 and Denom should be 3.
GUI_GIF_GetComment()
Description
Returns the given comment from the GIF image.
Prototype
int GUI_GIF_GetComment(const void * pGIF, U32 NumBytes, U8 * pBuffer, int MaxSize, int Index); Parameter pGIF NumBytes pBuffer MaxSize Index
Number of bytes of the .gif file. Pointer to a buffer to be filled with the comment. Size of the buffer. Zero based index of comment to be returned.
Meaning
Pointer to the start of the memory area in which the
Return value
0 on success, != 0 on error.
Additional information
A GIF file can contain 1 or more comments. The function copies the comment into the given buffer. If the comment is larger than the given buffer only the bytes which fit into the buffer will be copied. The file 2DGL_DrawGIF.c of the sample folder shows how to use the function.
GUI_GIF_GetCommentEx()
Description
Returns the given comment from a GIF image, which does not have to be loaded into memory.
Prototype
int GUI_GIF_GetCommentEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p, U8 * pBuffer, int MaxSize, int Index); Parameter fpGetData p pBuffer MaxSize Index Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by Size of the buffer. Zero based index of comment to be returned.
fpGetData .
Return value
0 on success, != 0 on error.
2002-2007 Micrium
152
CHAPTER 8
Additional information
For details please refer to the function GUI_GIF_GetComment().
GUI_GIF_GetImageInfo()
Description
Returns information about the given sub image.
Prototype
int GUI_GIF_GetImageInfo(const void * pGIF, U32 NumBytes, GUI_GIF_IMAGE_INFO * pInfo, int Index); Parameter pGIF NumBytes pInfo Index
Number of bytes of the .gif file. Pointer to a
Meaning
Pointer to the start of the memory area in which the
Return value
0 on success, != 0 on error.
Elements of GUI_GIF_IMAGE_INFO
Data type int int int int int Element xPos yPos xSize ySize Delay Meaning
X position of the last drawn image. Y position of the last drawn image. X size of the last drawn image. Y size of the last drawn image. Time in 1/100 seconds the image should be shown in a movie.
Additional information
If an image needs be shown as a movie this function should be used to get the time the sub image should be visible and the next sub image should be shown. If the delay member is 0 the image should be visible for 1/10 second.
GUI_GIF_GetImageInfoEx()
Description
Returns information about the given sub image of a GIF file, which needs not to be loaded into memory.
Prototype
int GUI_GIF_GetImageInfoEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p, GUI_GIF_IMAGE_INFO * pInfo, int Index); Parameter fpGetData p pInfo Index Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by Pointer to a Zero based index of sub image.
2002-2007 Micrium
153
Return value
0 on success, != 0 on error.
Additional information
For more details please refer to the function GUI_GIF_GetImageInfo().
GUI_GIF_GetInfo()
Description
Returns an information structure of the given GIF image with information about the size and the number of images within the given file.
Prototype
int GUI_GIF_GetInfo(const void * pGIF, U32 NumBytes, GUI_GIF_INFO * pInfo); Parameter pGIF NumBytes pInfo
Number of bytes of the .gif file. Pointer to a
Meaning
Pointer to the start of the memory area in which the
Return value
0 on success, != 0 on error.
Elements of GUI_GIF_INFO
Data type int int int Element XSize YSize NumImages
Pixel size in X of the image. Pixel size in Y of the image. Number of images in the file.
Meaning
GUI_GIF_GetInfoEx()
Description
Returns an information structure with information about the size and the number of sub images within the given GIF file, which needs not to be loaded into memory.
Prototype
int GUI_GIF_GetInfoEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p, GUI_GIF_INFO * pInfo);; Parameter fpGetData p pInfo Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by Pointer to a
fpGetData .
Return value
0 on success, != 0 on error.
2002-2007 Micrium
154
CHAPTER 8
Elements of GUI_GIF_INFO
Data type int int int Element XSize YSize NumImages
Pixel size in X of the image. Pixel size in Y of the image. Number of sub images in the file.
Meaning
GUI_GIF_GetXSize()
Description
Returns the X-size of a specified GIF image which has been loaded into memory.
Prototype
int GUI_GIF_GetXSize(const void * pGIF); Parameter pGIF Meaning
Pointer to the start of the memory area in which the
Return value
X-size of the GIF image.
GUI_GIF_GetXSizeEx()
Description
Returns the X-size of a specified GIF image, which needs not to be loaded into memory.
Prototype
int GUI_GIF_GetXSizeEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p); Parameter fpGetData p Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
Return value
X-size of the GIF image.
GUI_GIF_GetYSize()
Description
Returns the Y-size of a specified GIF image which has been loaded into memory.
Prototype
int GUI_GIF_GetYSize(const void * pGIF);; Parameter pGIF Meaning
Pointer to the start of the memory area in which the
Return value
Y-size of the GIF image.
User's & reference manual for C/GUI 2002-2007 Micrium
155
GUI_GIF_GetYSizeEx()
Description
Returns the Y-size of a specified GIF image, which needs not to be loaded into memory.
Prototype
int GUI_GIF_GetYSizeEx(GUI_GIF_GET_DATA_FUNC * fpGetData, void * p); Parameter fpGetData p Meaning
Pointer to a function which is called by the GUI for getting data. Void pointer passed to the function pointed by
fpGetData .
Return value
Y-size of the GIF image.
2002-2007 Micrium
156
CHAPTER 8
2002-2007 Micrium
157
Chapter 9 Fonts
This chapter describes the various methods of font support in C/GUI. The most common fonts are shipped with C/GUI as C font files. All of them contain the ASCII character set and most of them also the characters of ISO 8859-1. In fact, you will probably find that these fonts are fully sufficient for your application. For detailed information on the individual fonts, please refer to the subchapter "Standard Fonts", which describes all fonts included with C/GUI and shows all characters as they appear on the display. C/GUI is compiled for 8-bit characters, allowing for a maximum of 256 different character codes out of which the first 32 are reserved as control characters. The characters that are available depends on the selected font. For accessing the full Unicode area of 65536 possible characters C/GUI supports UTF8 decoding which is described in chapter 23 "Foreign Language Support".
2002-2007 Micrium
158
CHAPTER 9
Fonts
9.1
Introduction
The first way of font support was the possibility to use C files with font definitions containing bitmaps with 1bpp pixel information for each character. This kind of font support was limited to use only the fonts which are compiled with the application. Over time, the font support has been improved regarding font quality, ROM requirement, performance, scalability and the ability to add further fonts at run time. In the meantime C/GUI fonts cover antialiasing, drawing of compound characters like required in Thai language, fonts located on external non addressable media and TrueType support. Except the TrueType font format, which is a vector font, all other kinds of fonts are bitmap fonts.
9.2
Font types
C/GUI supports different internal types of fonts defined by C/GUI and the common used TrueType fonts.
2002-2007 Micrium
159
The following table shows the difference between the font types. The pictures only show the pixel information saved in the font file: Ext. prop. framed bitmap font *
9.3
Font formats
The following explains the differences between the supported font formats, when to use them and what is required to be able to use them.
9.3.1
C file format
This is the most common way of using fonts. When using fonts in form of C files, we recommend compiling all available fonts and linking them as library modules or putting all of the font object files in a library which you can link with your application. This way you can be sure that only the fonts which are needed by your application are actually linked. The font converter (described in a separate manual) may be used to create additional fonts.
When to use
This format should be used if the fonts are known at compile time and if there is enough addressable memory available for the font data.
Requirements
In order to be able to use a font C file in your application, the following requirements must be met:
2002-2007 Micrium
160
CHAPTER 9
Fonts
The font file is in a form compatible with C/GUI as "C" file, object file or library. The font file is linked with your application. The font declaration is contained in the application.
Format description
A font C file first contains the pixel information of all characters included by the font. It is followed by a character information table with size information about each character. This table is followed by range information structures for each contiguous area of characters contained in the font file, whereas each structure points to the next one. Please note that this method can enlarge a font file a lot if using many separate characters. After the range information structures a GUI_FONT structure follows with the main information like type, pixel size and so on of the font.
9.3.2
System independent fonts are binary data blocks containing the font information. The font converter can be used to create system independent fonts. This tool is not part of the basic package. A short description follows later in this chapter. For details about how to create system independent fonts please refer to the font converter documentation.
When to use
This format should be used if the fonts are not known at compile time and if there is enough addressable memory available for the font data.
Requirements
In order to be able to use a SIF font file in your application, it is required that the whole file reside in addressable memory (ROM or RAM).
Format description
The structure of a SIF file is nearly the same as of a C file. It contains the same information in binary format. The sequence of the file components is vice versa: General font information followed by range information structures, character information table and at least pixel information of all characters.
9.3.3
As well as SIF fonts XBF fonts are binary data blocks containing the font information and the font converter can be used to create XBF files. Contrary to other fonts, XBF fonts do not have to reside in memory when they are used, whereas all other kinds of C/GUI fonts need to reside completely in memory. The XBF font file can remain on any external media when it is used. Data access is done by a GetData callback function whereas all other fonts need to reside in addressable memory (RAM or ROM). The advantage of XBF fonts is that it is possible to use very large fonts on system with little memory.
When to use
This format should be used if there is not enough addressable memory available for the font data and if there is any kind of external media available for storing the fonts.
Requirements
In order to be able to use a XBF font in your application, a GetData callback function is required which is responsible for getting font data.
2002-2007 Micrium
161
Format description
This format differs in general from SIF and C file format. At first it contains a small block of general font information including the lowest character code and the highest character code. It is followed by an access table containing offset and data size information for each character between lowest and highest character code. If a character does not exist this information is zero for the according character. The access table is followed by the character information of all characters containing pixel data and character size information.
9.3.4
TrueType is an outline font standard developed by Apple Computer. It offers font developers a high degree of control over how their fonts are displayed at various font heights. Contrary to bitmap fonts which are based on bitmaps for each character, TrueType fonts are based on vector graphics. The advantage of the vector representation is the loss-free scalability. This implies that each character first needs to be rasterized into a bitmap before it is drawn. To avoid rasterization each time a character is drawn the bitmap data normally is cached by the font engine. This requires a fast CPU and enough RAM. The C/GUI TTF package is not part of the shipment. It is freely available under www.micrium.com/uc-gui_freetype.html.
Licensing
The C/GUI implementation of the TTF support is based on the FreeType font library from David Turner, Robert Wilhelm and Werner Lemberg which is freely available under www.freetype.org. It is used in C/GUI under the FreeType license which can be found under GUI\TrueType\FTL.txt. It has been slightly adapted and a glue layer with GUI-functions has been added.
When to use
This format should be used if fonts need to be scaleable at run-time.
Requirements
CPU: TTF support works only on 32 bit CPUs. Our definition of a 32bit CPU: sizeof(int) = 4. ROM: The ROM requirement of the TTF engine is app. 250K. The exact size depends on the CPU, the compiler and the optimization level of the compiler. RAM: The RAM requirement of the library depends a lot on the used fonts. The basic RAM requirement of the TTF engine is app. 50K. When creating a GUI font with GUI_TTF_CreateFont() the font engine loads all font tables defined in the TTF file required to generate the characters. The table sizes varies a lot between the fonts. The additional required amount of RAM for creating a font can be between a few KB up to more than 1MB. For typical fonts 80-300kB are required. It depends on the used font file how much RAM is required. At least the TTF engine requires a bitmap cache. Per default the engine uses 200K for the cache. This should be enough for most applications. The TTF engine allocates its memory via the non C/GUI functions malloc() and free(). It must be made sure that these functions work before using the TTF engine.
Format description
For details about the TTF format please refer to the information available under www.apple.com.
2002-2007 Micrium
162
CHAPTER 9
Fonts
9.4
9.5
Please note that this kind of declaring prototypes does not work if the fonts should be used with C/GUI configuration macros like BUTTON_FONT_DEFAULT or similar. In this case the fonts need to be declared in the configuration file GUIConf.h. The declaration in this case can look like the following sample:
typedef struct GUI_FONT GUI_FONT; extern const GUI_FONT GUI_FontApp1; #define BUTTON_FONT_DEFAULT &GUI_FontApp1 #define EDIT_FONT_DEFAULT &GUI_FontApp1
The typedef is required because the structure GUI_FONT has not been defined at the early point where GUIConf.h is included by C/GUI.
9.6
Selection of a font
C/GUI offers different fonts, one of which is always selected. This selection can be changed by calling the function GUI_SetFont() or one of the GUI_XXX_CreateFont() functions, which select the font to use for all text output to follow for the current task. If no font has been selected by your application, the default font is used. This default is configured in GUIConf.h and can be changed. You should make sure that the default font is one that you are actually using in your application because the default font will be linked with your application and will therefore use up ROM memory.
2002-2007 Micrium
163
9.7
Font API
The table below lists the available font-related routines in alphabetical order within their respective categories. Detailed descriptions can be found in the sections that follow. Routine GUI_SetFont() GUI_SIF_CreateFont() GUI_SIF_DeleteFont() GUI_TTF_CreateFont() GUI_TTF_DestroyCache() GUI_TTF_Done() GUI_TTF_GetFamilyName() GUI_TTF_GetStyleName() GUI_TTF_SetCacheSize()
Sets the current font.
Explanation C file related font functions SIF file related font functions
Creates and selects a font by passing a pointer to system independent font data. Deletes a font created by GUI_SIF_CreateFont() TTF file related font functions Creates a GUI font from a TTF font file. Destroys the cache of the TTF engine. Frees all dynamically allocated memory of the TTF engine. Returns the family name of the font. Returns the style name of the font. Can be used to set the default size of the TTF cache.
XBF file related font functions GUI_XBF_CreateFont() GUI_XBF_DeleteFont() GUI_GetCharDistX() GUI_GetFont() GUI_GetFontDistY() GUI_GetFontInfo() GUI_GetFontSizeY() GUI_GetLeadingBlankCols() GUI_GetStringDistX() GUI_GetTextExtend()
Creates and selects a font by passing a pointer to a callback function, which is responsible for getting data from the XBF font file.
GUI_GetTrailingBlankCols() character. Returns the Y-spacing of a particular font. GUI_GetYDistOfFont() Returns the Y-size of a particular font. GUI_GetYSizeOfFont() Evaluates whether a specified character is in a particular font. GUI_IsInFont()
9.8
GUI_SetFont()
2002-2007 Micrium
164
CHAPTER 9
Fonts
Prototype
const GUI_FONT * GUI_SetFont(const GUI_FONT * pNewFont); Parameter pFont Meaning
Pointer to the font to be selected and used.
Return value
Returns a pointer to the previously selected font so that it may be restored at a later point.
Examples
Displays sample text in 3 different sizes, restoring the former font afterwards:
void DispText(void) { const GUI_FONT GUI_FLASH* OldFont=GUI_SetFont(&GUI_Font8x16); GUI_DispStringAt("This text is 8 by 16 pixels",0,0); GUI_SetFont(&GUI_Font6x8); GUI_DispStringAt("This text is 6 by 8 pixels",0,20); GUI_SetFont(&GUI_Font8); GUI_DispStringAt("This text is proportional",0,40); GUI_SetFont(OldFont); // Restore font }
9.9
GUI_SIF_CreateFont()
Prototype
void GUI_SIF_CreateFont(void * pFontData, GUI_FONT * pFont,
2002-2007 Micrium
165
Meaning
Pointer to the system independent font data.
Additionnal Information
Contrary to the C/GUI standard fonts which must be compiled and linked with the application program, system independent fonts (SIF) are binary data blocks containing the font information. The font converter can be used to create system independent fonts. This tool is not part of the basic package. A short description follows later in this chapter. For details about how to create system independent fonts please refer to the font converter documentation. When using this function C/GUI needs to fill a GUI_FONT structure with the font information. The user needs to pass a pointer to this structure in the parameter pFont. The contents of this structure must remain valid during the use of the font. The function does not know what kind of font should be created. To tell the function the type of the font to be created it must be passed in the parameter pFontType. This has been done to avoid linkage of code which is not required.
Example
static GUI_FONT _Font; /* Font structure in RAM */ void MainTask(void) { GUI_Init(); GUI_SIF_CreateFont(_DownloadedFont, &_Font, GUI_SIF_TYPE_PROP); GUI_DispString("Hello World!"); while (1) { GUI_Exec(); } }
GUI_SIF_DeleteFont()
Description
Deletes a font pointed by the parameter pFont.
Prototype
void GUI_SIF_DeleteFont(GUI_FONT * pFont); Parameter pFont
Pointer to the font to be deleted.
Meaning
2002-2007 Micrium
166
CHAPTER 9
Fonts
Additionnal Information
After using a font created with GUI_SIF_CreateFont() the font should be deleted if not used anymore.
Example
GUI_FONT _Font; /* Font structure in RAM */ GUI_SIF_CreateFont(_DownloadedFont, &_Font, GUI_SIF_TYPE_PROP); /* Use the font */ GUI_SIF_DeleteFont(&_Font);
Prototype
int GUI_TTF_CreateFont(GUI_FONT * pFont, GUI_TTF_CS * pCS); Parameter pFont pCS
Pointer to a Pointer to a
Meaning GUI_FONT structure in RAM filled by the function. GUI_TTF_CS structure containing the creation parameters.
Return value
0 on success, 1 on error.
2002-2007 Micrium
167
Elements of GUI_TTF_CS
Data type GUI_TTF_DATA * Element pTTF Meaning
Pointer to GUI_TTF_DATA structure which contains location and size of the font file to be used. Pixel height of new font. It means the height of the surrounding rectangle between the glyphs 'g' anf 'f'. Please notice that it is not the distance between two lines of text. With other words the value returned by GUI_GetFontSizeY() is not identically with this value. Some font files can contain more than one font face. In case of more than one face this index specifies the zero based face index to be used to create the font. Usually 0.
PixelHeight
PixelHeight
FaceIndex
FaceIndex
Elements of GUI_TTF_DATA
Data type const void * NumBytes Element pData NumBytes
Size of file in bytes.
Meaning
Pointer to TTF font file in addressable memory area.
Additionnal Information
When using the function the first time it initializes the TTF engine and the internal cache system. If the cache should use other values as defined per default it needs to be configured before the first call of this function. For details how to configure the cache please refer to the function GUI_TTF_SetCacheSize(). The internal data cache manages the complete mechanism of creating fonts and caching bitmap data. Font faces are uniquely identified from the cache by the address given in parameter pTTF and the parameter FaceIndex, which normally is 0. If the same font file for example should be used for creating fonts of different sizes the parameter pTTF should point to the same location of a GUI_TTF_DATA structure. The parameter PixelHeight specifies the height of the surrounding rectangle between the glyphs g anf f. Please note that the value of PixelHeight this is not the same as the offset from one line of text to the next line.
Example
GUI_TTF_CS Cs0, Cs1; GUI_TTF_DATA Data; GUI_FONT Font0, Font1; /* Set parameters for accessing the font file */ Data.pData = aTTF; /* Address */ Data.NumBytes = sizeof(aTTF); /* Size */ /* Set creation parameters of first font */ Cs0.pTTF = &Data; /* Use address of GUI_TTF_DATA */ Cs0.PixelHeight = 24; /* Pixel height */ Cs0.FaceIndex = 0; /* Initialize to 0 */ /* Set creation parameters of second font */ Cs1.pTTF = &Data; /* Use address of GUI_TTF_DATA */ Cs1.PixelHeight = 48; /* Pixel height */ Cs1.FaceIndex = 0; /* Initialize to 0 */ /* Create 2 fonts */ GUI_TTF_CreateFont(&Font0, &Cs0); GUI_TTF_CreateFont(&Font1, &Cs1); /* Draw something using the fonts */ GUI_SetFont(&Font0); GUI_DispString("Hello world\n"); GUI_SetFont(&Font1); GUI_DispString("Hello world");
2002-2007 Micrium
168
CHAPTER 9
Fonts
GUI_TTF_DestroyCache()
Description
This function frees all memory allocated by the TTF cache system and destroys the cache.
Prototype
void GUI_TTF_DestroyCache(void);
Additionnal Information
The next time GUI_TTF_CreateFont() is used C/GUI automatically creates and initializes a new cache.
GUI_TTF_Done()
Description
This function frees all memory allocated by the TTF engine and its internal cache system.
Prototype
void GUI_TTF_Done(void);
Additionnal Information
The next time GUI_TTF_CreateFont() is used C/GUI automatically initializes the TTF engine and creates and initializes a new cache.
GUI_TTF_GetFamilyName()
Description
The function returns the font family name defined in the font file.
Prototype
int GUI_TTF_GetFamilyName(GUI_FONT * pFont, char * pBuffer, int NumBytes); Parameter pFont pBuffer NumBytes GUI_TTF_CreateFont().
Buffer to be filled with the family name. Size of buffer in bytes.
Meaning
Pointer to a GUI_FONT structure which has been created using
Return value
0 on success, 1 on error.
GUI_TTF_GetStyleName()
Description
The function returns the style name (bold, regular, ...) defined in the font file.
2002-2007 Micrium
169
Prototype
int GUI_TTF_GetStyleName(GUI_FONT * pFont, char * pBuffer, int NumBytes); Parameter pFont pBuffer NumBytes GUI_TTF_CreateFont().
Buffer to be filled with the style name. Size of buffer in bytes.
Meaning
Pointer to a GUI_FONT structure which has been created using
Return value
0 on success, 1 on error.
GUI_TTF_SetCacheSize()
Description
Sets the size parameters GUI_TTF_CreateFont(). used to create the cache on the first call of
Prototype
void GUI_TTF_SetCacheSize(unsigned MaxFaces, unsigned MaxSizes, U32 MaxBytes); Parameter MaxFaces MaxSizes MaxBytes Meaning
Maximum number of font faces the cache should be able to handle simultaneously. 0 selects default value. Maximum number of size objects the cache should be able to handle simultaneously. 0 selects default value. Maximum number of bytes used for the bitmap cache. 0 selects default value.
Additionnal Information
If for example 3 font faces should be used, each with 2 sizes, the cache should be able to manage 6 size objects. The default values used by the TTF engine are: 2 faces, 4 size objects and 200K of bitmap data cache.
Prototype
int GUI_XBF_CreateFont(GUI_FONT * pFont, GUI_XBF_DATA * pXBF_Data, const GUI_XBF_TYPE * pFontType, GUI_XBF_GET_DATA_FUNC * pfGetData,
2002-2007 Micrium
170
CHAPTER 9
Fonts
Meaning GUI_FONT structure in RAM filled by the function. GUI_XBF_DATA structure in RAM filled by the function.
See table below. Pointer to a callback function which is responsible for getting data from the font file. Application defined pointer passed to the GetData callback function.
Additionnal Information
Contrary to the C/GUI standard fonts, which must be compiled and linked with the application program, external binary fonts (XBF) are binary data blocks containing the font information. The font converter can be used to create XBF files. This tool is not part of the basic package. A short description of the font converter follows later in this chapter. For details about how to create external binary fonts please refer to the font converter documentation. Contrary to other fonts, XBF fonts do not have to reside in memory when they are used, whereas all other kinds of C/GUI fonts need to reside completely in memory. The XBF font file can remain on any external media during it is used. Data access is done by a GetData callback function whereas all other fonts need to reside in addressable memory (RAM or ROM). The advantage of XBF fonts is that it is possible to use very large fonts on system with little memory. The parameter pfGetData should point to an application defined callback routine, which is responsible for getting data from the font. Parameter pVoid is passed to the callback function when requesting font data. It can be used for example to pass a file handle to the callback function. The function requires pointers to a GUI_FONT structure and a GUI_XBF_DATA structure. These structures will be filled by the function with font information. It is required, that the contents of this structures remain valid during the use of the font. Because the function does not know what kind of XBF font should be created, the parameter pFontType is used to tell the function the type of the font to be created. This has been done to avoid linkage of code which is not required. The maximum number of data bytes per character is limited to 200 per default. This should cover the most requirements. If loading a character with more bytes a warning will be generated in the debug version. The default value can be increased by adding the following define to the file GUIConf.h:
#define GUI_MAX_XBF_BYTES 500 /* Sets the maximum number of bytes/character to 500*/
2002-2007 Micrium
171
Example
static GUI_FONT Font; /* GUI_FONT structure in RAM */ static GUI_XBF_DATA XBF_Data; /* GUI_XBF_DATA structure in RAM */ static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer) { /* May use the pVoid pointer to get a file handle */ .../* TBD */ /* Set file pointer to the given position */ .../* TBD */ /* Read the required number of bytes into the given buffer */ .../* TBD */ } void CreateXBF_Font(void * pVoid) { GUI_XBF_CreateFont(&Font, &XBF_Data, GUI_XBF_TYPE_PROP, _cbGetData, pVoid); } /* /* /* /* /* Pointer to GUI_FONT structure */ Pointer to GUI_XBF_DATA structure */ Font type to be created */ Pointer to callback function */ Pointer to be passed to callback */
GUI_XBF_DeleteFont()
Description
Deletes a XBF font pointed by the parameter pFont.
Prototype
void GUI_XBF_DeleteFont(GUI_FONT * pFont); Parameter pFont
Pointer to the font to be deleted.
Meaning
Additionnal Information
After using a font created with GUI_XBF_CreateFont() the font should be deleted if not used anymore.
Prototype
const GUI_FONT * GUI_GetFont(void)
GUI_GetCharDistX()
Description
Returns the width in pixels (X-size) used to display a specified character in the currently selected font.
2002-2007 Micrium
172
CHAPTER 9
Fonts
Prototype
int GUI_GetCharDistX(U16 c); Meaning
Character to calculate width from.
Parameter c
GUI_GetFontDistY()
Description
Returns the Y-spacing of the currently selected font.
Prototype
int GUI_GetFontDistY(void);
Additionnal information
The Y-spacing is the vertical distance in pixels between two adjacent lines of text. The returned value is the YDist value of the entry for the currently selected font. The returned value is valid for both proportional and monospaced fonts.
GUI_GetFontInfo()
Description
Calculates a pointer to a GUI_FONTINFO structure of a particular font.
Prototype
void GUI_GetFontInfo(const GUI_FONT*pFont, GUI_FONTINFO* pfi); Parameter pFont pfi
Pointer to the font. Pointer to a GUI_FONTINFO structure.
Meaning
Additionnal information
The definition of the GUI_FONTINFO structure is as follows:
typedef struct { U16 Flags; } GUI_FONTINFO;
Example
Gets the info of GUI_Font6x8. After the calculation, FontInfo.Flags contains the flag GUI_FONTINFO_FLAG_MONO.
GUI_FONTINFO FontInfo; GUI_GetFontInfo(&GUI_Font6x8, &FontInfo);
GUI_GetFontSizeY()
Description
Returns the height in pixels (Y-size) of the currently selected font.
2002-2007 Micrium
173
Prototype
int GUI_GetFontSizeY(void);
Additionnal information
The returned value is the YSize value of the entry for the currently selected font. This value is less than or equal to the Y-spacing returned by the function GUI_GetFontDistY(). The returned value is valid for both proportional and monospaced fonts.
GUI_GetLeadingBlankCols()
Description
Returns the number of leading blank pixel columns in the currently selected font for the given character.
Prototype
int GUI_GetLeadingBlankCols(U16 c); Parameter c
Character to be used.
Meaning
Sample
The result for the character B shown in the screenshot above should be 2.
GUI_GetStringDistX()
Description
Returns the X-size used to display a specified string in the currently selected font.
Prototype
int GUI_GetStringDistX(const char GUI_FAR *s); Meaning
Pointer to the string.
Parameter s
GUI_GetTextExtend()
Description
Calculates the size of a given string using the current font.
2002-2007 Micrium
174
CHAPTER 9
Fonts
Prototype
void GUI_GetTextExtend(GUI_RECT* pRect, const char* s, int Len); Parameter pRect s Len
Pointer to the string. Number of characters of the string.
Meaning
Pointer to GUI_RECT-structure to store result.
GUI_GetTrailingBlankCols()
Description
Returns the number of trailing blank pixel columns in the currently selected font for the given character.
Prototype
int GUI_GetTrailingBlankCols(U16 c); Parameter c
Character to be used.
Meaning
Sample
The result for the character B shown in the screenshot above should be 1.
GUI_GetYDistOfFont()
Description
Returns the Y-spacing of a particular font.
Prototype
int GUI_GetYDistOfFont(const GUI_FONT* pFont); Meaning
Pointer to the font.
Parameter pFont
Additionnal information
(see GUI_GetFontDistY())
GUI_GetYSizeOfFont()
Description
Returns the Y-size of a particular font.
2002-2007 Micrium
175
Prototype
int GUI_GetYSizeOfFont(const GUI_FONT* pFont); Meaning
Pointer to the font.
Parameter pFont
Additionnal information
(see GUI_GetFontSizeY())
GUI_IsInFont()
Description
Evaluates whether or not a particular font contains a specified character.
Prototype
char GUI_IsInFont(const GUI_FONT*pFont, U16 c); Parameter pFont c
Pointer to the font. Character to be searched for.
Meaning
Additionnal information
If the pointer pFont is set to 0, the currently selected font is used.
Example
Evaluates whether the font GUI_FontD32 contains an "X":
if (GUI_IsInFont(&GUI_FontD32, 'X') == 0) { GUI_DispString("GUI_FontD32 does not contains 'X'"); }
2002-2007 Micrium
176
CHAPTER 9
Fonts
Unfortunately, as ASCII stands for American Standard Code for Information Interchange, it is designed for American needs. It does not include any of the special characters used in European languages, such as , , , , , and others. There is no single standard for these "European extensions" of the ASCII set of characters; several different ones exist. The one used on the Internet and by most Windows programs is ISO 8859-1, a superset of the ASCII set of characters.
Description
non-breaking space inverted exclamation cent sign pound sterling general currency sign yen sign broken vertical bar section sign umlaut (dieresis) copyright feminine ordinal left angle quote, guillemotleft not sign soft hyphen registered trademark macron accent degree sign plus or minus superscript two superscript three acute accent micro sign paragraph sign middle dot
Char
2002-2007 Micrium
177
Code
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 cedilla
Description
superscript one masculine ordinal right angle quote, guillemot right fraction one-fourth fraction one-half fraction three-fourth inverted question mark capital A, grave accent capital A, acute accent capital A, circumflex accent capital A, tilde capital A, dieresis or umlaut mark capital A, ring capital A, diphthong (ligature) capital C, cedilla capital E, grave accent capital E, acute accent capital E, circumflex accent capital E, dieresis or umlaut mark capital I, grave accent capital I, acute accent capital I, circumflex accent capital I, dieresis or umlaut mark Eth, Icelandic N, tilde capital O, grave accent capital O, acute accent capital O, circumflex accent capital O, tilde capital O, dieresis or umlaut mark multiply sign capital O, slash capital U, grave accent capital U, acute accent capital U, circumflex accent capital U, dieresis or umlaut mark capital Y, acute accent THORN, Icelandic sharp s, German (s-z ligature) small a, grave accent small a, acute accent small a, circumflex accent small a, tilde small a, dieresis or umlaut mark small a, ring small ae diphthong (ligature) cedilla small e, grave accent small e, acute accent small e, circumflex accent small e, dieresis or umlaut mark small i, grave accent
Char
2002-2007 Micrium
178
CHAPTER 9
Fonts
Code
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
Description
small i, acute accent small i, circumflex accent small i, dieresis or umlaut mark small eth, Icelandic small n, tilde small o, grave accent small o, acute accent small o, circumflex accent small o, tilde small o, dieresis or umlaut mark division sign small o, slash small u, grave accent small u, acute accent small u, circumflex accent small u, dieresis or umlaut mark small y, acute accent small thorn, Icelandic small y, dieresis or umlaut mark
Char
9.13.3 Unicode
Unicode is the ultimate in character coding. It is an international standard based on ASCII and ISO 8859-1. Contrary to ASCII, UNICODE requires 16-bit characters because all characters have their own code. Currently, more than 30,000 different characters are defined. However, not all of the character images are defined in C/ GUI. It is the responsibility of the user to define these additional characters. Please contact Micrium or your distributor, as we may already have the character set that you need.
2002-2007 Micrium
179
The font converter is described in a separate documentation which can be obtained by request from Micrium ([email protected]).
Example
extern const GUI_FONT GUI_FontNew; int main(void) { GUI_Init(); GUI_Clear(); GUI_SetFont(&GUI_FontNew); GUI_DispString("Hello world\n"); return 0; }
2002-2007 Micrium
180
CHAPTER 9
Fonts
<characterset>
Example 1
GUI_Font16_ASCII Element GUI_Font 16 ASCII
Standard font prefix. Heigth in pixels. Font contains ASCII characters only.
Meaning
Example 2
GUI_Font8x15B_ASCII Element GUI_Font 8 x15 B ASCII
Standard font prefix. Width of characters. Heigth in pixels. Bold font. Font contains ASCII characters only.
Meaning
2002-2007 Micrium
181
Example 3
GUI_Font8x16x1x2 Element GUI_Font 8 x16 x1 x2
Standard font prefix. Width of characters. Heigth in pixels. Magnification factor in X. Magnification factor in Y.
Meaning
<characterset>
Meaning
2002-2007 Micrium
182
CHAPTER 9
Fonts
2002-2007 Micrium
183
2002-2007 Micrium
184
CHAPTER 9
Fonts
Font name
GUI_Font8_ASCII GUI_Font8_1 GUI_Font10S_ASCII GUI_Font10S_1 GUI_Font10_ASCII GUI_Font10_1 GUI_Font13_ASCII GUI_Font13_1 GUI_Font13B_ASCII GUI_Font13B_1 GUI_Font13H_ASCII GUI_Font13H_1 GUI_Font13HB_ASCII GUI_Font13HB_1 GUI_Font16_ASCII GUI_Font16_1 GUI_Font16_HK
Measurement
F: 8, B: 7, C: 7, L: 5, U: 1 F: 8, B: 7, C: 7, L: 5, U: 1 F: 10, B: 8, C: 6, L: 4, U: 2 F: 10, B: 8, C: 6, L: 4, U: 2 F: 10, B: 9, C: 8, L: 6, U: 1 F: 10, B: 9, C: 8, L: 6, U: 1 F: 13, B: 11, C: 8, L: 6, U: 2 F: 13, B: 11, C: 8, L: 6, U: 2 F: 13, B: 11, C: 8, L: 6, U: 2 F: 13, B: 11, C: 8, L: 6, U: 2 F: 13, B: 11, C: 9, L: 7, U: 2 F: 13, B: 11, C: 9, L: 7, U: 2 F: 13, B: 11, C: 9, L: 7, U: 2 F: 13, B: 11, C: 9, L: 7, U: 2 F: 16, B: 13, C: 10, L: 7, U: 3 F: 16, B: 13, C: 10, L: 7, U: 3 -
Used files
F08_ASCII.c F08_ASCII.c F08_1.c F10S_ASCII.c F10_ASCII.c F10_1.c F10_ASCII F10_ASCII.c F10_1.c F13_ASCII.c F13_ASCII.c F13_1.c F13B_ASCII.c F13B_ASCII.c F13B_1.c F13H_ASCII.c F13H_ASCII.c F13H_1.c F13HB_ASCII.c F13HB_ASCII.c F13HB_1.c F16_ASCII.c F16_ASCII.c F16_1.c F16_HK.c F16_1HK.c F16_HK.c F16_ASCII.c F16_1.c F16B_ASCII.c F16B_ASCII.c F16B_1.c FComic18B_ASCII.c FComic18B_ASCII.c FComic18B_1.c F20_ASCII.c F20_ASCII.c F20_1.c
GUI_Font16_1HK
F: 16, B: 13, C: 10, L: 7, U: 3 F: 16, B: 13, C: 10, L: 7, U: 3 F: 18, B: 15, C: 12, L: 9, U: 3 F: 18, B: 15, C: 12, L: 9, U: 3 F: 20, B: 16, C: 13, L: 10, U: 4 F: 20, B: 16, C: 13, L: 10, U: 4
2002-2007 Micrium
185
Font name
GUI_Font20B_ASCII GUI_Font20B_1 GUI_Font24_ASCII GUI_Font24_1 GUI_Font24B_ASCII GUI_Font24B_1 GUI_FontComic24B_ASCII GUI_FontComic24B_1 GUI_Font32_ASCII GUI_Font32_1 GUI_Font32B_ASCII GUI_Font32B_1
Measurement
F: 20, B: 16, C: 13, L: 10, U: 4 F: 20, B: 16, C: 13, L: 10, U: 4 F: 24, B: 19, C: 15, L: 11, U: 5 F: 24, B: 19, C: 15, L: 11, U: 5 F: 24, B: 19, C: 15, L: 11, U: 5 F: 24, B: 19, C: 15, L: 11, U: 5 F: 24, B: 20, C: 17, L: 13, U: 4 F: 24, B: 20, C: 17, L: 13, U: 4 F: 32, B: 26, C: 20, L: 15, U: 6 F: 32, B: 26, C: 20, L: 15, U: 6 F: 32, B: 25, C: 20, L: 15, U: 7 F: 32, B: 25, C: 20, L: 15, U: 7
Used files
F20B_ASCII.c F20B_ASCII.c F20B_1.c F24_ASCII.c F24_ASCII.c F24_1.c F24B_ASCII.c F24B_ASCII.c F24B_1.c FComic24B_ASCII FComic24B_ASCII FComic24B_1 F32_ASCII.c F32_ASCII.c F32_1.c F32B_ASCII.c F32B_ASCII.c F32B_1.c
9.15.4.3 Characters
The following shows all characters of all proportional standard fonts:
2002-2007 Micrium
186
CHAPTER 9
Fonts
GUI_Font8_ASCII
GUI_Font8_1
GUI_Font10S_ASCII
GUI_Font10S_1
GUI_Font10_ASCII
GUI_Font10_1
GUI_Font13_ASCII
2002-2007 Micrium
187
GUI_Font13_1
GUI_Font13B_ASCII
GUI_Font13B_1
GUI_Font13H_ASCII
GUI_Font13H_1
GUI_Font13HB_ASCII
GUI_Font13HB_1
2002-2007 Micrium
188
CHAPTER 9
Fonts
GUI_Font16_ASCII
GUI_Font16_1
GUI_Font16_HK
GUI_Font16_1HK
2002-2007 Micrium
189
GUI_Font16B_ASCII
GUI_Font16B_1
GUI_FontComic18B_ASCII
GUI_FontComic18B_1
GUI_Font20_ASCII
2002-2007 Micrium
190
CHAPTER 9
Fonts
GUI_Font20_1
GUI_Font20B_ASCII
GUI_Font20B_1
GUI_Font24_ASCII
2002-2007 Micrium
191
GUI_Font24_1
GUI_Font24B_ASCII
GUI_Font24B_1
2002-2007 Micrium
192
CHAPTER 9
Fonts
GUI_FontComic24B_ASCII
GUI_FontComic24B_1
GUI_Font32_ASCII
2002-2007 Micrium
193
GUI_Font32_1
GUI_Font32B_ASCII
2002-2007 Micrium
194
CHAPTER 9
Fonts
GUI_Font32B_1
2002-2007 Micrium
195
Font name
GUI_Font4x6 GUI_Font6x8 GUI_Font6x9 GUI_Font8x8 GUI_Font8x9 GUI_Font8x10_ASCII GUI_Font8x12_ASCII GUI_Font8x13_ASCII GUI_Font8x13_1
Measurement
F: 6, B: 5, C: 5, L: 4, U: 1 F: 8, B: 7, C: 7, L: 5, U: 1 F: 9, B: 7, C: 7, L: 5, U: 2 F: 8, B: 7, C: 7, L: 5, U: 1 F: 9, B: 7, C: 7, L: 5, U: 2 F: 10, B: 9, C: 9, L: 7, U: 1 F: 12, B: 10, C: 9, L: 6, U: 2 F: 13, B: 11, C: 9, L: 6, U: 2 F: 13, B: 11, C: 9, L: 6, U: 2
Used files
F4x6.c F6x8.c F6x8.c F8x8.c F8x8.c F8x10_ASCII.c F8x12_ASCII.c F8x13_ASCII.c F8x13_ASCII.c F8x13_1.c
2002-2007 Micrium
196
CHAPTER 9
Fonts
Font name
GUI_Font8x15B_ASCII GUI_Font8x15B_1 GUI_Font8x16 GUI_Font8x17
Measurement
F: 15, B: 12, C: 9, L: 7, U: 3 F: 15, B: 12, C: 9, L: 7, U: 3 F: 16, B: 12, C: 10, L: 7, U: 4 F: 17, B: 12, C: 10, L: 7, U: 5
Used files
F8x15_ASCII.c F8x15B_ASCII.c F8x15B_1.c F8x16.c F8x16.c
GUI_Font8x18
F8x16.c
GUI_Font8x16x1x2
F8x16.c
GUI_Font8x16x2x2
F8x16.c
GUI_Font8x16x3x3
F8x16.c
9.15.5.3 Characters
The following shows all characters of all monospaced standard fonts:
2002-2007 Micrium
197
GUI_Font4x6
GUI_Font6x8
GUI_Font6x9
GUI_Font8x8
GUI_Font8x9
GUI_Font8x10_ASCII
2002-2007 Micrium
198
CHAPTER 9
Fonts
GUI_Font8x12_ASCII
GUI_Font8x13_ASCII
GUI_Font8x13_1
GUI_Font8x15B_ASCII
GUI_Font8x15B_1
GUI_Font8x16
2002-2007 Micrium
199
GUI_Font8x17
GUI_Font8x18
GUI_Font8x16x1x2
2002-2007 Micrium
200
CHAPTER 9
Fonts
GUI_Font8x16x2x2
2002-2007 Micrium
201
GUI_Font8x16x3x3
2002-2007 Micrium
202
CHAPTER 9
Fonts
2002-2007 Micrium
203
2002-2007 Micrium
204
CHAPTER 9
Fonts
Font name
GUI_FontD32 GUI_FontD48 GUI_FontD64 GUI_FontD80
Measurement
F: 32, C: 31 F: 48, C: 47 F: 64, C: 63 F: 80, C: 79
Used files
FD32.c FD48.c FD64.c FD80.c
9.15.6.3 Characters
The following shows all characters of all proportional digit fonts:
GUI_FontD32
2002-2007 Micrium
205
GUI_FontD48
GUI_FontD64
GUI_FontD80
2002-2007 Micrium
206
CHAPTER 9
Fonts
Font name
GUI_FontD24x32 GUI_FontD36x48 GUI_FontD48x64 GUI_FontD60x80
Measurement
F: 32, C: 31 F: 48, C: 47 F: 64, C: 63 F: 80, C: 79
Used files
FD24x32.c FD36x48.c FD48x60.c FD60x80.c
9.15.7.3 Characters
The following shows all characters of all monospaced digit fonts:
GUI_FontD24x32
2002-2007 Micrium
207
GUI_FontD36x48
GUI_FontD48x64
GUI_FontD60x80
2002-2007 Micrium
208
CHAPTER 9
Fonts
2002-2007 Micrium
209
The bitmap converter is a Windows program which is easy to use. Simply load a bitmap (in the form of a .bmp or a .gif file) into the application. Convert the color format if you want or have to, and convert it into a "C" file by saving it in the appropriate format. The "C" file may then be compiled, allowing the image to be shown on your display with C/GUI.
2002-2007 Micrium
210
CHAPTER 10
Bitmap Converter
Trying to read bitmap files of other formats will cause an error message of the bitmap converter.
2002-2007 Micrium
211
Color depth
1bpp 2bpp 4bpp 8bpp 4bpp 8bpp 15bpp 15bpp 16bpp 16bpp 16bpp 16bpp 24bpp 24bpp
Compression
no no no no yes yes no no no no yes yes no no
Transparency
yes yes yes yes yes yes no no no no no no no no
Palette
yes yes yes yes yes yes no no no no no no no no
2002-2007 Micrium
212
CHAPTER 10
Bitmap Converter
10.3.3 Transparency
A palette based bitmap can be converted to a transparent bitmap. Transparency means each pixel with index 0 will not produce any output. The command Image/ Transparency can be used to select the color which should be used for transparency. After selecting the transparent color, the pixel indices of the image will be recalculated, so that the selected color is on position 0 of the bitmap palette. When saving the bitmap file as C file, it will be saved with the transparency attribute.
2002-2007 Micrium
213
The command File/Load Alpha Mask can be used for loading an alpha mask.
The command File/Create Alpha can be used tor creating the alpha values.
Color depth
In general the lower the color depth the smaller the ROM requirement of the bitmap. Each display driver has been optimized for drawing 1bpp bitmaps (text) and bitmaps with the same color depth as the display.
2002-2007 Micrium
214
CHAPTER 10
Bitmap Converter
Compression
The supported RLE compression method has the best effect on bitmaps with many horizontal sequences of equal-colored pixels. Details later in this chapter. The performance is typically slightly slower than drawing uncompressed bitmaps.
Palette
The ROM requirement of a palette is 4 bytes for each color. So a palette of 256 colors uses 1kB. Furthermore C/GUI needs to convert the colors of the palette before drawing the bitmap. Advantage: Bitmaps are device independent meaning they can be displayed on any display, independent of its color depth and format.
Transparency
The ROM requirement of transparent bitmaps is the same as without transparency. The performance is with transparency slightly slower than without.
2002-2007 Micrium
215
Step 1: Start the application. The bitmap converter is opened showing an empty window.
Step 2: Load a bitmap into the bitmap converter. Choose File/Open . Locate the document you want to open and click Open (must be a .bmp file). In this example, the file MicriumLogoBlue.bmp is chosen.
In this example, the loaded bitmap is in full-color mode. It must be converted to a palette format before a "C" file can be generated.
2002-2007 Micrium
216
CHAPTER 10
Bitmap Converter
Procedure
Step 3: Convert the image if necessary. Choose Image/Convert Select the desired palette. In this example, the option chosen.
Screen shot
The image is unchanged in terms of appearance, but uses less memory since a palette of only 15 colors is used instead of the full-color mode. These 15 colors are the only ones actually required to display this particular image.
Step 4: Save the bitmap as a "C" file. Choose File/Save As . Select a destination and a name for the "C" file. Select the file type. In this example, the file is saved as "C" bitmap file. Click Save .
Step 5: Specify bitmap format. If the bitmap should be saved as C file the format should now be specified. Use one of the available formats shown in the dialog. If the bitmap should be saved without palette, activate the check box "Without palette" The bitmap converter will create a separate file in the specified destination, containing the "C" source code for the bitmap.
2002-2007 Micrium
217
The bitmap converter is opened and the same file is loaded as in steps 1 and 2 of the previous example. The bitmap converter displays the loaded bitmap.
Choose
Image/Convert Into/Gray4.
2002-2007 Micrium
218
CHAPTER 10
Bitmap Converter
Procedure
The bitmap converter displays the converted bitmap. In this example, the image uses less memory since a palette of only 4 grayscales is used instead of the full-color mode. If the target display supports only 4 grayscales, there is no use in having a higher pixel depth as it would only waste memory.
Screen shot
Compression ratios
The ratio of compression achieved will vary depending on the bitmap used. The more horizontal uniformity in the image, the better the ratio will be. A higher number of bits per pixel will also result in a higher degree of compression. In the bitmap used in the previous examples, the total number of pixels in the image is (200*94) = 18,800. Since 2 pixels are stored in 1 byte, the total uncompressed size of the image is 18,800/2 = 9,400 bytes. The total compressed size for this particular bitmap is 3,803 bytes for 18,800 pixels (see the example at the end of the chapter). The ratio of compression can therefore be calculated as 9,400/3,803 = 2.47.
2002-2007 Micrium
219
Total file size is therefore: 16+(NumColors*4) bytes. A custom palette file with 8 colors would be 16+(8*4) = 48 bytes. At this point, a binary editor must be used in order to create such a file. The maximum number of colors supported is 256; the minimum is 2.
Sample
This sample file would define a palette containing 2 colors -- red and white:
0000: 65 6d 57 69 6e 50 61 6c 02 00 00 00 00 00 00 00 0010: ff 00 00 00 ff ff ff 00
The 8 headers make up the first eight bytes of the first line. The U32 is stored lsb first (big endian) and represents the next four bytes, followed by the four 0 bytes. Colors are stored 1 byte per color, where the 4th byte is 0 as follows: RRGGBB00. The second line of code defines the two colors used in this sample.
220
CHAPTER 10
Bitmap Converter
2002-2007 Micrium
221
2002-2007 Micrium
222
CHAPTER 10
Bitmap Converter
Explanation
Rotate image by 90 degrees counterclockwise. Rotate image by 180 degrees. Invert indices. Save file as
filename .
User-specified file name including the file Must be an integer from 1 to 3 as follows: 1 : "C" with palette (.c file)
Specifies the bitmap format (only if type == 1): 1: 1 bit per pixel 2: 2 bits per pixel 3: 4 bits per pixel 5: 8 bits per pixel 6: RLE4 compression 7: RLE8 compression 8: High color 565 9: High color 565, red and blue swapped 10: High color 555 11: High color 555, red and blue swapped 12: RLE16 compression <fmt> 13: RLE16 compression, red and blue swapped 17: True color 24bpp If this parameter is not given, the bitmap converter uses the following default formats in dependence of the number of colors of the bitmap: Number of colors <= 2: 1 bit per pixel Number of colors <= 4: 2 bits per pixel Number of colors <= 16: 4 bits per pixel Number of colors <= 256: 8 bits per pixel RGB: High color 565 Saves the bitmap with or without palette (only if type == 1) <noplt> 0: Save bitmap with palette (default) 1: Save bitmap without palette
-exit -help -?
2002-2007 Micrium
223
your company logo into a C bitmap. Take a look at the sample bitmap pictured:
The bitmap is loaded into the bitmap converter, converted to Best palette, and saved as "C with palette". The resulting C source code is displayed below (some data is not shown to conserve space).
2002-2007 Micrium
224
CHAPTER 10
Bitmap Converter
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x10, . . . 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x20, 0x01, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20 }; const GUI_BITMAP bmMicriumLogoBlue = { 269, /* XSize */ 76, /* YSize */ 135, /* BytesPerLine */ 4, /* BitsPerPixel */ acMicriumLogoBlue, /* Pointer to picture data (indices) */ &PalMicriumLogoBlue /* Pointer to palette */ }; /* *** End of file *** */
2002-2007 Micrium
225
2002-2007 Micrium
226
CHAPTER 10
Bitmap Converter
/* ABS: 002 Pixels @ 268,073*/ 0, 2, 0x20, /* RLE: 267 Pixels @ 001,074*/ 254, 0x01, 13, 0x01, /* ABS: 003 Pixels @ 268,074*/ 0, 3, 0x20, 0x10, /* RLE: 267 Pixels @ 002,075*/ 254, 0x02, 13, 0x02, 0}; /* 4702 for 20444 pixels */ const GUI_BITMAP bmLogoCompressed = { 269, /* XSize */ 76, /* YSize */ 135, /* BytesPerLine */ GUI_COMPRESS_RLE4, /* BitsPerPixel */ acLogoCompressed, /* Pointer to picture data (indices) */ &PalLogoCompressed /* Pointer to palette */ ,GUI_DRAW_RLE4 }; /* *** End of file *** */
2002-2007 Micrium
227
Chapter 11 Colors
C/GUI supports black/white, grayscale (monochrome with different intensities) and color displays. The same user program can be used with any display; only the LCDconfiguration needs to be changed. The color management tries to find the closest match for any color that should be displayed. Logical colors are the colors the application deals with. A logical colors is always defined as an RGB value. This is a 24-bit value containing 8 bits per color as follows: 0xBBGGRR. Therefore, white would be 0xFFFFFF, black would be 0x000000, bright red 0xFF. Physical colors are the colors which can actually be displayed by the display. They are specified in the same 24-bit RGB format as logical colors. At run-time, logical colors are mapped to physical colors. For displays with few colors (such as monochrome displays or 8/16-color LCDs), C/ GUI converts them by using an optimized version of the "least-square deviation search". It compares the color to display (the logical color) with all the available colors that the LCD can actually show (the physical colors) and uses the one that the LCD-metric considers closest.
2002-2007 Micrium
228
CHAPTER 11
Colors
Example:
/* Set background color to magenta */ GUI_SetBkColor(GUI_MAGENTA); GUI_Clear();
229
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : COLOR_ShowColorBar.c Purpose : Example draws a color bar ---------------------------------------------------------------------*/ #include "GUI.H" /******************************************************************* * * Draws 13 color bars * ******************************************************************** */ void ShowColorBar(void) { int x0 = 60, y0 = 40, yStep = 15, i; int NumColors = LCD_GetDevCap(LCD_DEVCAP_NUMCOLORS); int xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE) - x0; GUI_SetFont(&GUI_Font13HB_1); GUI_DispStringHCenterAt("C/GUI-sample: Show color bars", 160, 0); GUI_SetFont(&GUI_Font8x8); GUI_SetColor(GUI_WHITE); GUI_SetBkColor(GUI_BLACK); #if (LCD_FIXEDPALETTE) GUI_DispString("Fixed palette: "); GUI_DispDecMin(LCD_FIXEDPALETTE); #endif GUI_DispStringAt("Red", 0, y0 + yStep); GUI_DispStringAt("Green", 0, y0 + 3 * yStep); GUI_DispStringAt("Blue", 0, y0 + 5 * yStep); GUI_DispStringAt("Grey", 0, y0 + 6 * yStep); GUI_DispStringAt("Yellow", 0, y0 + 8 * yStep); GUI_DispStringAt("Cyan", 0, y0 + 10 * yStep); GUI_DispStringAt("Magenta", 0, y0 + 12 * yStep); for (i = 0; i < xsize; i++) { U16 cs = (255 * (U32)i) / xsize; U16 x = x0 + i;; /* Red */ GUI_SetColor(cs); GUI_DrawVLine(x, y0 , y0 + yStep - 1); GUI_SetColor(0xff + (255 - cs) * 0x10100L); GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1); /* Green */ GUI_SetColor(cs<<8); GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1); GUI_SetColor(0xff00 + (255 - cs) * 0x10001L); GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1); /* Blue */ GUI_SetColor(cs * 0x10000L); GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1); GUI_SetColor(0xff0000 + (255 - cs) * 0x101L); GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1); /* Gray */ GUI_SetColor((U32)cs * 0x10101L); GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1); /* Yellow */ GUI_SetColor(cs * 0x101); GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1); GUI_SetColor(0xffff + (255 - cs) * 0x10000L); GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1); /* Cyan */ GUI_SetColor(cs * 0x10100L); GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1); User's & reference manual for C/GUI 2002-2007 Micrium
230
CHAPTER 11 GUI_SetColor(0xffff00 + (255 - cs) * GUI_DrawVLine(x, y0 + 10 * yStep, y0 /* Magenta */ GUI_SetColor(cs * 0x10001); GUI_DrawVLine(x, y0 + 11 * yStep, y0 GUI_SetColor(0xff00ff + (255 - cs) * GUI_DrawVLine(x, y0 + 12 * yStep, y0 } } /******************************************************************* * * main * ******************************************************************** */ void main(void) { GUI_Init(); ShowColorBar(); while(1) GUI_Delay(100); } 0x1L); + 11 * yStep - 1); + 12 * yStep - 1); 0x100L); + 13 * yStep - 1);
Colors
LCD_SWAP_RB
Mask
x x x x 0 1 0 1 0 1 0 1
0x01 0x03 0x0F 0x1F BGR RGB BBGGRR RRGGBB BBGGGRRR RRGGGBBB BBBGGRRR RRRGGBBB
2002-2007 Micrium
231
LCD_SWAP_RB
Mask
256 256 4096 4096 4096 4096 4096 32768 32768 65536 65536 65536 65536 65536 65536 262144 256 240 232 233 (232 + transparency) 16777216 16777216 16777216 + 8 bit alpha blending 16777216 + 8 bit alpha blending
0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 x x x x 0 1 0 1 x
BBBGGGRR RRRGGGBB 0000BBBBGGGGRRRR 0000RRRRGGGGBBBB BBBBGGGGRRRR0000 0BBBB0GGGG0RRRR0 0RRRR0GGGG0BBBB0 0BBBBBGGGGGRRRRR 0RRRRRGGGGGBBBBB BBBBBGGGGGRRRRRR RRRRRGGGGGBBBBBB BBBBBGGGGGGRRRRR RRRRRGGGGGGBBBBB BBBBBBGGGGGRRRRR RRRRRRGGGGGBBBBB BBBBBBGGGGGGRRRRRR 0xFF 0xFF 0xFF 0xFF BBBBBBBBGGGGGGGGRRRRRRRR RRRRRRRRGGGGGGGGBBBBBBBB AAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB x
2002-2007 Micrium
232
CHAPTER 11
Colors
Available colors: 2:
Available colors: 2 x 2 = 4:
2002-2007 Micrium
233
Available colors: 2 x 2 x 2 = 8:
111 mode: 3 bpp (2 levels per color), red and blue swapped
Use this mode if the basic 8 colors are enough, if your hardware supports only one bit per pixel and color or if you do not have sufficient video memory for a higher color depth. The available colors are the same as those in 111 mode. Color mask: RGB Available colors: 2 x 2 x 2 = 8:
222 mode: 6 bpp (4 levels per color), red and blue swapped
This mode is a good choice if your hardware does not have a palette for every individual color. 2 bits per pixel and color are reserved; usually 1 byte is used to store one pixel. The available colors are the same as those in 222 mode. Color mask: RRGGBB
2002-2007 Micrium
234
CHAPTER 11
Colors
2002-2007 Micrium
235
2002-2007 Micrium
236
CHAPTER 11
Colors
2002-2007 Micrium
237
44412 mode:
The red, green and blue components are each 4 bits. Color mask: 0000BBBBGGGGRRRR Available colors: 16 x 16 x 16 = 4096.
44416 mode:
The red, green and blue components are each 4 bits. One bit between the color components is not used. The available colors are the same as those in 44412 mode. Color mask: 0BBBB0GGGG0RRRR0 Available colors: 16 x 16 x 16 = 4096.
444121 mode:
The red, green and blue components are each 4 bits. The lower 4 bits of the color mask are not used. The available colors are the same as those in 44412 mode. Color mask: BBBBGGGGRRRR0000 Available colors: 16 x 16 x 16 = 4096.
2002-2007 Micrium
238
CHAPTER 11
Colors
2002-2007 Micrium
239
22216 mode: 8 bpp, 2 levels per color + 8 grayscales + 16 levels of alpha blending
This mode can be used with a programmable color lookup table (LUT), supporting a total of 256 possible colors and alpha blending support. It supports the 8 basic colors, 8 grayscales and 16 levels of alpha blending for each color / grayscale. With other words it can be used if only a few colors are required but more levels of alpha blending. Available colors: (2 x 2 x 2 + 8) * 16 = 256
84444 mode: 8 bpp, 4 levels per color + 16 grayscales + 4(3) levels of alpha blending
This mode can be used with a programmable color lookup table (LUT), supporting a total of 256 possible colors and alpha blending support. 4 levels of intensity are available for each color, in addition to 16 grayscales and 4 levels of alpha blending for each color / grayscale. With other words it can be used if only a few levels of alpha blending are required and different shades of colors.
2002-2007 Micrium
240
CHAPTER 11
Colors
2002-2007 Micrium
241
2002-2007 Micrium
242
CHAPTER 11
Colors
The function LCD_Color2Index_User() is called by C/GUI if a RGB value should be converted into an index value for the display controller whereas the function LCD_Index2Color_User() is called if an index value should be converted into a RGB value. LCD_GetIndexMask_User() should return a bit mask value, which has each bit set to 1 which is used by the display controller and unused bits should be set to 0. For example the index mask of the 44416 mode is 0BBBB0GGGG0RRRR0, where 0 stands for unused bits. The bit mask for this mode is 0x7BDE.
2002-2007 Micrium
243
Example
The following example (part of LCDConf.h) would define a custom palette with 4 colors, all of which are shades of gray:
#define LCD_FIXEDPALETTE 0 #define LCD_PHYSCOLORS 0xffffff, 0xaaaaaa, 0x555555, 0x000000
If you are simply modifying the LUT at run time, the color conversion routines will not be aware of this and will therefore still assume that the LUT is initialized as it was originally.
2002-2007 Micrium
244
CHAPTER 11
Colors
Prototype
GUI_COLOR GUI_GetBkColor(void);
Return value
The current background color.
GUI_GetBkColorIndex()
Description
Returns the index of the current background color.
Prototype
int GUI_GetBkColorIndex(void);
Return value
The current background color index.
2002-2007 Micrium
245
GUI_GetColor()
Description
Returns the current foreground color.
Prototype
GUI_COLOR GUI_GetColor(void);
Return value
The current foreground color.
GUI_GetColorIndex()
Description
Returns the index of the current foreground color.
Prototype
int GUI_GetColorIndex(void);
Return value
The current foreground color index.
GUI_SetBkColor()
Description
Sets the current background color.
Prototype
GUI_COLOR GUI_SetBkColor(GUI_COLOR Color); Parameter Color Meaning
Color for background, 24-bit RGB value.
Return value
The selected background color.
GUI_SetBkColorIndex()
Description
Sets the index of the current background color.
Prototype
int GUI_SetBkColorIndex(int Index); Parameter Index
Index of the color to be used.
Meaning
Return value
The selected background color index.
2002-2007 Micrium
246
CHAPTER 11
Colors
GUI_SetColor()
Description
Sets the current foreground color.
Prototype
void GUI_SetColor(GUI_COLOR Color); Parameter Color Meaning
Color for foreground, 24-bit RGB value.
Return value
The selected foreground color.
GUI_SetColorIndex()
Description
Sets the index of the current foreground color.
Prototype
void GUI_SetColorIndex(int Index); Parameter Index
Index of the color to be used.
Meaning
Return value
The selected foreground color index.
Prototype
int GUI_Color2Index(GUI_COLOR Color) Parameter Color Meaning
RGB value of the color to be converted.
Return value
The color index.
GUI_Index2Color()
Returns the RGB color value of a specified index.
2002-2007 Micrium
247
Prototype
int GUI_Index2Color(int Index) Parameter Index Meaning
Index of the color. to be converted
Return value
The RGB color value.
GUI_InitLUT()
Description
Initializes the lookup table of the LCD controller(s).
Prototype
void LCD_InitLUT(void);
Additional information
The lookup table needs to be enabled (by the LCD_INITCONTROLLER macro) for this function to have any effect.
GUI_SetLUTColor()
Description
Modifies a single entry to the color table and the LUT of the LCD controller(s).
Prototype
void GUI_SetLUTColor(U8 Pos, GUI_COLOR Color); Parameter Pos Color Meaning
Position within the lookup table. Should be less than the number of colors (e.g. 0-3 for 2 bpp, 0-15 for 4 bpp, 0-255 for 8 bpp). 24-bit RGB value.
Additional information
The closest value possible will be used for the LUT. If a color LUT is to be initialized, all 3 components are used. In monochrome modes the green component is used, but it is still recommended (for better understanding of the program code) to set all 3 colors to the same value (such as 0x555555 or 0xa0a0a0). The lookup table needs to be enabled (by the LCD_INITCONTROLLER macro) for this function to have any effect. This function is always available, but has an effect only if: a) The LUT is used b) The color table is located in RAM (LCD_PHYSCOLORS_IN_RAM)
2002-2007 Micrium
248
CHAPTER 11
Colors
GUI_SetLUTEntry()
Description
Modifies a single entry to the LUT of the LCD controller(s).
Prototype
void GUI_SetLUTEntry(U8 Pos, GUI_COLOR Color); Parameter Pos Color Meaning
Position within the lookup table. Should be less than the number of colors (e.g. 0-3 for 2 bpp, 0-15 for 4 bpp, 0-255 for 8 bpp). 24-bit RGB value.
Additional information
The closest value possible will be used for the LUT. If a color LUT is to be initialized, all 3 components are used. In monochrome modes the green component is used, but it is still recommended (for better understanding of the program code) to set all 3 colors to the same value (such as 0x555555 or 0xa0a0a0). The lookup table needs to be enabled (by the LCD_INITCONTROLLER macro) for this function to have any effect. This function is often used to ensure that the colors actually displayed match the logical colors (linearization).
Example
// // Linearize the palette of a 4-grayscale LCD // GUI_SetLUTEntry(0, 0x000000); GUI_SetLUTEntry(1, 0x777777); // 555555 would be linear GUI_SetLUTEntry(2, 0xbbbbbb); // aaaaaa would be linear GUI_SetLUTEntry(3, 0xffffff);
2002-2007 Micrium
249
Memory devices can be used in a variety of situations, mainly to prevent the display from flickering when using drawing operations for overlapping items. The basic idea is quite simple. Without the use of a memory device, drawing operations write directly to the display. The screen is updated as drawing operations are executed, which gives it a flickering appearance as the various updates are made. For example, if you want to draw a bitmap in the background and some transparent text in the foreground, you would first have to draw the bitmap and then the text. The effect would be a flickering of the text. If a memory device is used for such a procedure, however, all drawing operations are executed in memory. The final result is displayed on the screen only when all operations have been carried out, with the advantage of no flickering. This difference can be seen in the example in the following section, which illustrates a sequence of drawing operations both with and without the use of a memory device. The distinction may be summarized as follows: If no memory device is used, the effects of drawing operations can be seen step by step, with the disadvantage of a flickering display. With a memory device, the effects of all routines are made visible as a single operation. No intermediate steps can actually be seen. The advantage, as explained above, is that display flickering is completely eliminated, and this is often desirable. Memory devices are an additional (optional) software item and are not shipped with the C/GUI basic package. The software for memory devices is located in the subdirectory GUI\Memdev.
2002-2007 Micrium
250
CHAPTER 12
Memory Devices
Step 1:
GUI_Clear
Step 2:
GUI_DrawPolygon
Step 3:
GUI_DispString
Step 4:
GUI_MEMDEV_CopyToLCD
(only when using memory device)
2002-2007 Micrium
251
Memory usage
1 byte / 8 pixels: (XSIZE + 7) / 8 * YSIZE XSIZE * YSIZE
2002-2007 Micrium
252
CHAPTER 12
Memory Devices
Memory usage
2 bytes / pixel: XSIZE * YSIZE * 2 4 bytes / pixel: XSIZE * YSIZE * 4
Example:
A memory device of 111 pixels in X and 33 pixels in Y should be created. It should be compatible to a display with a color depth of 12 bpp and should support transparency. The required number of bytes can be calculated as follows: Number of required bytes = (111 * 2 + (111 + 7) / 8) * 33 = 7788 bytes
Memory usage
2 byte / 8 pixels: (XSIZE + 7) / 8 * YSIZE * 2 1 bytes / pixel + 1 byte / 8 pixels: (XSIZE + (XSIZE + 7) / 8) * YSIZE 2 bytes / pixel + 1 byte / 8 pixels: (XSIZE * 2 + (XSIZE + 7) / 8) * YSIZE 4 bytes / pixel + 1 byte / 8 pixels: (XSIZE * 4 + (XSIZE + 7) / 8) * YSIZE
Example:
A memory device of 200 pixels in X and 50 pixels in Y should be created. It should be compatible to a display with a color depth of 4bpp and should support transparency. The required number of bytes can be calculated as follows: Number of required bytes = (200 + (200 + 7) / 8) * 50 = 11250 bytes
12.5 Performance
Using memory devices typically does no significantly affect performance. When memory devices are used, the work of the driver is easier: It simply transfers bitmaps to the display controller. On systems with slow drivers (for example displays connected via serial interface), the performance is better if memory devices are used; on systems with a fast driver (such as memory mapped display memory, LCDLin driver and others) the use of memory devices costs some performance. If 'banding' is needed, the used time to draw a window increases with the number of bands. The more memory available for memory devices, the better the performance.
2002-2007 Micrium
253
it
(using
Macro GUI_USE_MEMDEV_1BPP_FOR_SCREEN
0
Default
Explanation
Enables the use of 1bpp memory devices with displays of 1bpp color depth.
12.9.1 GUI_USE_MEMDEV_1BPP_FOR_SCREEN
On systems with a display color depth <= 8bpp the default color depth of memory devices compatible to the display is 8bpp. To enable the use of 1bpp memory devices with displays of 1bpp color depth the following line should be added to the configuration file GUIConf.h:
#define GUI_USE_MEMDEV_1BPP_FOR_SCREEN 1
2002-2007 Micrium
254
CHAPTER 12
Memory Devices
All functions are listed in alphabetical order within their respective categories. Detailed descriptions of the routines can be found in the sections that follow. Routine Basic functions GUI_MEMDEV_Clear() GUI_MEMDEV_CopyFromLCD() GUI_MEMDEV_CopyToLCD() GUI_MEMDEV_CopyToLCDAA() GUI_MEMDEV_CopyToLCDAt() GUI_MEMDEV_Create() GUI_MEMDEV_CreateEx() GUI_MEMDEV_CreateFixed() GUI_MEMDEV_Delete() GUI_MEMDEV_GetDataPtr() GUI_MEMDEV_GetXSize() GUI_MEMDEV_GetYSize() GUI_MEMDEV_MarkDirty() GUI_MEMDEV_ReduceYSize() GUI_MEMDEV_Select() GUI_MEMDEV_SetOrg() GUI_MEMDEV_Write() GUI_MEMDEV_WriteAlpha() GUI_MEMDEV_WriteAlphaAt() GUI_MEMDEV_WriteAt() GUI_MEMEDV_WriteEx() GUI_MEMDEV_WriteExAt() GUI_SelectLCD() GUI_MEMDEV_Draw()
Marks the memory device contents as unchanged. Copies contents of LCD to memory device. Copies contents of memory device to LCD. Copies the contents of memory device antialiased. Copies contents of memory device to LCD at the given position. Creates the memory device (first step). Creates the memory device with additional creation flags. Creates a memory device with a given color depth. Frees the memory used by the memory device. Returns a pointer to the data area for direct manipulation. Returns the X-size (width) of memory device. Returns the Y-size (height) of memory device. Marks the given area as containing pixels to be drawn. Reduces Y-size of memory device. Selects a memory device as target for drawing operations. Changes the origin of the memory device on the LCD. Writes the contents of a memory device into a memory device. Writes the contents of a memory device into a memory device using alpha blending. Writes the contents of a memory device into a memory device using the given position and alpha blending. Writes the contents of a memory device into a memory device to the given position. Writes the contents of a memory device into a memory device using alpha blending and scaling. Writes the contents of a memory device into a memory device to the given position using alpha blending and scaling. Selects the LCD as target for drawing operations.
Explanation
2002-2007 Micrium
255
Prototype
void GUI_MEMDEV_Clear(GUI_MEMDEV_Handle hMem); Parameter hMem
Handle to memory device.
Meaning
Add. information
The next drawing operation with GUI_MEMDEV_CopyToLCD() will then write only the bytes modified between GUI_MEMDEV_Clear() and GUI_MEMDEV_CopyToLCD().
GUI_MEMDEV_CopyFromLCD()
Description
Copies the contents of a memory device from LCD data (video memory) to the memory device. In other words: read back the contents of the LCD to the memory device.
Prototype
void GUI_MEMDEV_CopyFromLCD(GUI_MEMDEV_Handle hMem); Parameter hMem
Handle to memory device.
Meaning
GUI_MEMDEV_CopyToLCD()
Description
Copies the contents of a memory device from memory to the LCD.
Prototype
void GUI_MEMDEV_CopyToLCD(GUI_MEMDEV_Handle hMem) Parameter hMem
Handle to memory device.
Meaning
Add. information
Do not use this function within a paint callback function called by the window manager, because it deactivates the clipping area of the window manager. The function GUI_MEMDEV_WriteAt should be used instead.
GUI_MEMDEV_CopyToLCDAA()
Description
Copies the contents of a memory device (antialiased) from memory to the LCD.
2002-2007 Micrium
256
CHAPTER 12
Memory Devices
Prototype
void GUI_MEMDEV_CopyToLCDAA(GUI_MEMDEV_Handle MemDev); Parameter hMem
Handle to memory device.
Meaning
Add. information
The device data is handled as antialiased data. A matrix of 2x2 pixels is converted to 1 pixel. The intensity of the resulting pixel depends on how many pixels are set in the matrix.
Example
Creates a memory device and selects it for output. A large font is then set and a text is written to the memory device:
GUI_MEMDEV_Handle hMem = GUI_MEMDEV_Create(0,0,60,32); GUI_MEMDEV_Select(hMem); GUI_SetFont(&GUI_Font32B_ASCII); GUI_DispString("Text"); GUI_MEMDEV_CopyToLCDAA(hMem);
GUI_MEMDEV_CopyToLCDAt()
Description
Copies the contents of a memory device from memory to the LCD at the given position.
Prototype
void GUI_MEMDEV_CopyToLCDAt(GUI_MEMDEV_Handle hMem, int x, int y) Parameter hMem x y
Handle to memory device. Position in X Position in Y
Meaning
GUI_MEMDEV_Create()
Description
Creates a memory device.
Prototype
GUI_MEMDEV_Handle GUI_MEMDEV_Create(int x0, int y0, int XSize, int YSize) Parameter x0 y0 xsize ysize
X-position of memory device. Y-position of memory device. X-size of memory device. Y-size of memory device.
Meaning
2002-2007 Micrium
257
Return value
Handle for created memory device. If the routine fails the return value is 0.
GUI_MEMDEV_CreateEx()
Description
Creates a memory device.
Prototype
GUI_MEMDEV_Handle GUI_MEMDEV_CreateEx(int x0, int y0, int XSize, int YSize int Flags) Parameter x0 y0 xsize ysize Flags
X-position of memory device. Y-position of memory device. X-size of memory device. Y-size of memory device. (see table below).
Meaning
GUI_MEMDEV_NOTRANS
Return value
Handle for created memory device. If the routine fails the return value is 0.
GUI_MEMDEV_CreateFixed()
Description
Creates a memory device of fixed size, color depth (bpp) and specified color conversion.
Prototype
GUI_MEMDEV_Handle GUI_MEMDEV_CreateFixed( int x0, int y0, int xsize, int ysize, int Flags, const tLCDDEV_APIList * pMemDevAPI, const LCD_API_COLOR_CONV * pColorConvAPI) Parameter x0 y0 xsize
X-position of memory device. Y-position of memory device. X-size of memory device.
Meaning
2002-2007 Micrium
258
CHAPTER 12
Memory Devices
Meaning
GUI_MEMDEV_NOTRANS
Parameter pMemDevAPI
Defines the color depth of the memory device in bpp. The color depth of the memory device should be equal or greater than the required bits for the color conversion routines. A memory device with a 1bpp color conversion (GUI_COLOR_CONV_1 ) for example requires at least a memory device with 1bpp color depth. The available memory devices are 1bpp, 8bpp and 16bpp memory devices. So an 1bpp memory device should be used. If using a 4 bit per pixel color conversion (GUI_COLOR_CONV_4 ) at least 4bpp are needed for the memory device. In this case an 8bpp memory device should be used.
GUI_MEMDEV_APILIST_8
GUI_MEMDEV_APILIST_32
Create memory device with 32bpp color depth (1 U32 per pixel) Use if the specified color conversion requires more than 16 bpp. (True color modes)
2002-2007 Micrium
259
Parameter pColorConvAPI
This parameter defines the desired color conversion. For more details about the used bits per pixel and the color conversion please refer to the chapter "Colors".
Return value
Handle for created memory device. If the routine fails the return value is 0.
Add. information
This function can be used if a memory device with a specified color conversion should be created. This could make sense if for example some items should be printed on a printer device. The sample folder contains the code sample MEMDEV_Printing.c which shows, how to use the function to print something in 1bpp color conversion mode.
Sample
The following sample shows how to create a memory device with 1bpp color depth:
GUI_MEMDEV_Handle hMem; hMem = GUI_MEMDEV_CreateFixed(0, 0, 128, 128, 0, GUI_MEMDEV_APILIST_1, /* Used API list */ GUI_COLOR_CONV_1); /* Black/white color conversion */ GUI_MEMDEV_Select(hMem);
GUI_MEMDEV_Delete()
Description
Deletes a memory device.
Prototype
void GUI_MEMDEV_Delete(GUI_MEMDEV_Handle MemDev); Parameter hMem
Handle to memory device.
Meaning
Return value
Handle for deleted memory device.
2002-2007 Micrium
260
CHAPTER 12
Memory Devices
GUI_MEMDEV_GetDataPtr()
Description
Returns a pointer to the data area (image area) of a memory device. This data area can then be manipulated without the use of GUI functions; it can for example be used as output buffer for a JPEG or video decompression routine.
Prototype
void* GUI_MEMDEV_GetDataPtr(GUI_MEMDEV_Handle hMem); Parameter hMem
Handle to memory device.
Meaning
Add. information
The device data is stored from the returned addr. onwards. An application modifying this data has to take extreme caution that it does not overwrite memory outside of this data area. If this data area is used with C/GUIs default memory management, the memory area must remain locked as long as the pointer is in use.
GUI_MEMDEV_GetXSize()
Description
Returns the X-size (width) of a memory device.
Prototype
int GUI_MEMDEV_GetXSize(GUI_MEMDEV_Handle hMem); Meaning
Handle to memory device.
Parameter hMem
GUI_MEMDEV_GetYSize()
Description
Returns the Y-size (height) of a memory device in pixels.
2002-2007 Micrium
261
Prototype
int GUI_MEMDEV_GetYSize(GUI_MEMDEV_Handle hMem); Meaning
Handle to memory device.
Parameter hMem
GUI_MEMDEV_MarkDirty()
Description
Tells the memory device that the pixels in the given area have been changed.
Prototype
void GUI_MEMDEV_MarkDirty(GUI_MEMDEV_Handle hMem, int x0, int y0, int x1, int y1); Parameter hMem x0 y0 x1 y1
Handle to memory device. Leftmost pixel to be marked. Topmost pixel to be marked. Rightmost pixel to be marked. Bottommost pixel to be marked.
Meaning
Add. information
When drawing into a memory device with the C/GUI drawing API functions like GUI_DrawLine() a memory device with transparency support (default) marks each modified pixel. The drawing functions like GUI_MEMDEV_CopyToLCD() then draw only the modified pixels. If the contents of a memory device have been changed by the application program using the pointer returned by GUI_MEMDEV_GetDataPtr(), the memory device does not know which pixels are changed. In this case the function GUI_MEMDEV_MarkDirty() should be used to mark these pixels. Using this function with memory devices without transparency, created with the flag GUI_MEMDEV_NOTRANS, makes no sense.
GUI_MEMDEV_ReduceYSize()
Description
Reduces the Y-size of a memory device.
Prototype
void GUI_MEMDEV_ReduceYSize(GUI_MEMDEV_Handle hMem, int YSize); Parameter hMem YSize
Handle to memory device. New Y-size of the memory device.
Meaning
Add. information
Changing the size of the memory device is more efficient than deleting and then recreating it.
2002-2007 Micrium
262
CHAPTER 12
Memory Devices
GUI_MEMDEV_Select()
Description
Activates a memory device (or activates LCD if handle is 0)
Prototype
void GUI_MEMDEV_Select(GUI_MEMDEV_Handle hMem) Parameter hMem
Handle to memory device.
Meaning
GUI_MEMDEV_SetOrg()
Description
Changes the origin of the memory device on the LCD.
Prototype
void GUI_MEMDEV_SetOrg(GUI_MEMDEV_Handle hMem, int x0, int y0); Parameter hMem x0 y0
Handle to memory device. Horizontal position (of the upper left pixel). Vertical position (of the upper left pixel).
Meaning
Add. information
This routine can be helpful when the same device is used for different areas of the screen or when the contents of the memory device are to be copied into different areas. Changing the origin of the memory device is more efficient than deleting and then recreating it.
GUI_MEMDEV_Write()
Description
Writes the contents of the given memory device into the currently selected memory device.
Prototype
void GUI_MEMDEV_Write(GUI_MEMDEV_Handle hMem); Parameter hMem
Handle to memory device.
Meaning
GUI_MEMDEV_WriteAlpha()
Description
Writes the contents of the given memory device into the currently selected memory device using alpha blending.
2002-2007 Micrium
263
Prototype
void GUI_MEMDEV_WriteAlpha(GUI_MEMDEV_Handle hMem, int Alpha); Parameter hMem Alpha
Handle to memory device. Alpha blending factor, 0 - 255
Meaning
Add. information
Alpha blending means mixing 2 colors with a given intensity. This function makes it possible to write semi-transparent from one memory device into an other memory device. The Alpha-parameter specifies the intensity used when writing to the currently selected memory device.
GUI_MEMDEV_WriteAlphaAt()
Description
Writes the contents of the given memory device into the currently selected memory device at the specified position using alpha blending.
Prototype
void GUI_MEMDEV_WriteAlphaAt(GUI_MEMDEV_Handle hMem, int Alpha, int x, int y); Parameter hMem Alpha x y
Handle to memory device. Alpha blending factor, 0 - 255 Position in X Position in Y
Meaning
Add. information
(See GUI_MEMDEV_WriteAlpha)
GUI_MEMDEV_WriteAt()
Description
Writes the contents of the given memory device into the currently selected memory device at the specified position.
Prototype
void GUI_MEMDEV_WriteAt(GUI_MEMDEV_Handle hMem, int x, int y); Parameter hMem x y
Handle to memory device. Position in X Position in Y
Meaning
2002-2007 Micrium
264
CHAPTER 12
Memory Devices
GUI_MEMDEV_WriteEx()
Description
Writes the contents of the given memory device into the currently selected memory device at position (0, 0) using alpha blending and scaling.
Prototype
void GUI_MEMDEV_WriteEx(GUI_MEMDEV_Handle hMem, int xMag, int yMag, int Alpha); Parameter hMem xMag yMag Alpha
Handle to memory device. Scaling factor for X-axis * 1000. Scaling factor for Y-axis * 1000. Alpha blending factor, 0 - 255.
Meaning
Add. information
A negative scaling factor mirrors the output. Please also refer to function GUI_MEMDEV_WriteExAt().
GUI_MEMDEV_WriteExAt()
Description
Writes the contents of the given memory device into the currently selected memory device at the specified position using alpha blending and scaling.
Prototype
void GUI_MEMDEV_WriteEx(GUI_MEMDEV_Handle hMem, int xMag, int yMag, int Alpha); Parameter hMem x y xMag yMag Alpha
Handle to memory device. Position in X. Position in Y. Scaling factor for X-axis * 1000. Scaling factor for Y-axis * 1000. Alpha blending factor, 0 - 255.
Meaning
Add. information
A negative scaling factor mirrors the output.
Example
The following sample creates 2 memory devices: hMem0 (40x10) and hMem1 (80x20). A small white text is drawn at the upper left position of hMem0 and hMem1. Then the function GUI_MEMDEV_WriteEx() writes the contents of hMem0 to hMem1 using mirroring and magnifying:
2002-2007 Micrium
265 GUI_MEMDEV_Handle hMem0, hMem1; GUI_Init(); hMem0 = GUI_MEMDEV_Create(0, 0, 40, 10); hMem1 = GUI_MEMDEV_Create(0, 0, 80, 20); GUI_MEMDEV_Select(hMem0); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispString("Text"); GUI_MEMDEV_Select(hMem1); GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_DispStringAt("Text", 0, 0); GUI_MEMDEV_WriteExAt(hMem0, 0, 0, -2000, -2000, 160); GUI_MEMDEV_CopyToLCD(hMem1);
GUI_SelectLCD()
Description
Selects the LCD as target for drawing operations.
Prototype
void GUI_SelectLCD(void))
266 */
CHAPTER 12
Memory Devices
/******************************************************************* * * _Draw */ static void _Draw(int Delay) { GUI_SetPenSize(5); GUI_SetColor(GUI_RED); GUI_DrawLine(Rect.x0 + 3, Rect.y0 + 3, Rect.x1 - 3, Rect.y1 - 3); GUI_Delay(Delay); GUI_SetColor(GUI_GREEN); GUI_DrawLine(Rect.x0 + 3, Rect.y1 - 3, Rect.x1 - 3, Rect.y0 + 3); GUI_Delay(Delay); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontComic24B_ASCII); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringInRect("Closed", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER); GUI_Delay(Delay); } /******************************************************************* * * _DemoMemDev */ static void _DemoMemDev(void) { GUI_MEMDEV_Handle hMem; int i; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("MEMDEV_MemDev - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Shows the advantage of using a\nmemorydevice", 160,50); GUI_SetFont(&GUI_Font8_1); GUI_DispStringHCenterAt("Draws the picture\nwithout a\nmemory device", 50, 90); GUI_DispStringHCenterAt("Draws the picture\nusing a\nmemory device", 270, 90); /* Create the memory device */ hMem = GUI_MEMDEV_Create(Rect.x0, Rect.y0, Rect.x1 - Rect.x0, Rect.y1 - Rect.y0); /* Routes the drawing operations to the memory device */ GUI_MEMDEV_Select(hMem); _Draw(0); /* Routes the drawing operations to the LCD */ GUI_MEMDEV_Select(0); while (1) { for (i = 0; i < 3; i++) { GUI_Delay(250); GUI_ClearRect(LCD_GetXSize() - Rect.x1, Rect.y0, LCD_GetXSize(), Rect.y1); GUI_Delay(250); GUI_MEMDEV_CopyToLCDAt(hMem, LCD_GetXSize() - Rect.x1, Rect.y0); } GUI_Delay(500); /* Uses no memory device */ _Draw(400); GUI_Delay(400); GUI_ClearRect(0, 130, 319, 219); } GUI_MEMDEV_Delete(hMem); /* Destroy memory device */ } /******************************************************************* * * MainTask * * Demonstrates the use of memory devices * ******************************************************************** */ void MainTask(void) { GUI_Init(); _DemoMemDev();
2002-2007 Micrium
267 }
GUI_MEMDEV_Draw()
Description
Basic drawing function that prevents flickering of the display.
Prototype
int GUI_MEMDEV_Draw(GUI_RECT* pRect, GUI_CALLBACK_VOID_P* pfDraw, void* pData, int NumLines, int Flags) Parameter pRect pfDraw pData NumLines Flags Meaning
Pointer to a GUI_RECT structure for the used LCD area. Pointer to a callback function for executing the drawing. Pointer to a data structure used as parameter for the callback function. 0 (recommended) or number of lines for the memory device. (see table below).
2002-2007 Micrium
268
CHAPTER 12
Memory Devices
GUI_MEMDEV_NOTRANS
Return value
0 if successful, 1 if the routine fails.
Add. information
If the parameter NumLines is 0, the number of lines in each band is calculated automatically by the function. The function then iterates over the output area band by band by moving the origin of the memory device.
2002-2007 Micrium
269 GUI_Clear(); GUI_SetFont(&GUI_Font8x8); GUI_SetTextMode(GUI_TM_TRANS); /* draw background */ GUI_SetColor(GUI_GREEN); GUI_FillRect(pDrawItContext->XPos_Text, pDrawItContext->YPos_Text - 25, pDrawItContext->XPos_Text + 100, pDrawItContext->YPos_Text - 5); /* draw polygon */ GUI_SetColor(GUI_BLUE); GUI_FillPolygon(pDrawItContext->aPointsDest, SIZE_OF_ARRAY(aPoints), 160, 120); /* draw foreground */ GUI_SetColor(GUI_RED); GUI_FillRect(220 - pDrawItContext->XPos_Text, pDrawItContext->YPos_Text + 5, 220 - pDrawItContext->XPos_Text + 100, pDrawItContext->YPos_Text + 25); } /******************************************************************* * * Demonstrates the banding memory device * ******************************************************************** */ #define USE_BANDING_MEMDEV (1) /* Set to 0 for drawing without banding memory device */ void DemoBandingMemdev(void) { int i; int XSize = LCD_GET_XSIZE(); int YSize = LCD_GET_YSIZE(); tDrawItContext DrawItContext; GUI_SetFont(&GUI_Font8x9); GUI_SetColor(GUI_WHITE); GUI_DispStringHCenterAt("Banding memory device\nwithout flickering", XSize / 2, 40); DrawItContext.XPos_Poly = XSize / 2; DrawItContext.YPos_Poly = YSize / 2; DrawItContext.YPos_Text = YSize / 2 - 4; for (i = 0; i < (XSize - 100); i++) { float angle = i * 3.1415926 / 60; DrawItContext.XPos_Text = i; /* Rotate the polygon */ GUI_RotatePolygon(DrawItContext.aPointsDest, aPoints, SIZE_OF_ARRAY(aPoints), angle); #if USE_BANDING_MEMDEV { GUI_RECT Rect = {0, 70, 320,170}; /* Use banding memory device for drawing */ GUI_MEMDEV_Draw(&Rect, &DrawIt, &DrawItContext, 0, 0); } #else /* Simple drawing without using memory devices */ DrawIt((void *)&DrawItContext); #endif #ifdef WIN32 GUI_Delay(20); /* Use a short delay only in the simulation */ #endif } } /******************************************************************* * * main * ******************************************************************** */ void main(void) {
2002-2007 Micrium
CHAPTER 12
Memory Devices
GUI_MEMDEV_CreateAuto()
Description
Creates an auto device object.
Prototype
int GUI_MEMDEV_CreateAuto(GUI_AUTODEV * pAutoDev); Parameter pAutoDev
Pointer to a GUI_AUTODEV object.
Meaning
Return value
Currently 0, reserved for later use.
2002-2007 Micrium
271
GUI_MEMDEV_DeleteAuto()
Description
Deletes an auto device object.
Prototype
void GUI_MEMDEV_DeleteAuto(GUI_AUTODEV * pAutoDev); Parameter pAutoDev
Pointer to a GUI_AUTODEV object.
Meaning
GUI_MEMDEV_DrawAuto()
Description
Executes a specified drawing routine using a banding memory device.
Prototype
int GUI_MEMDEV_DrawAuto(GUI_AUTODEV * pAutoDev, GUI_AUTODEV_INFO * pAutoDevInfo, GUI_CALLBACK_VOID_P * pfDraw, void * pData); Parameter pAutoDev pAutoDevInfo pfDraw pData
Pointer to a GUI_AUTODEV object. Pointer to a GUI_AUTODEV_INFO object. Pointer to the user-defined drawing function which is to be executed. Pointer to a data structure passed to the drawing function.
Meaning
Return value
0 if successful, 1 if the routine fails.
Add. information
The GUI_AUTODEV_INFO structure contains the information about what items must be drawn by the user function:
typedef struct { char DrawFixed; } GUI_AUTODEV_INFO;
DrawFixed is set to 1 if all items have to be drawn. It is set to 0 when only the moving or changing objects have to be drawn. We recommend the following procedure when using this feature:
typedef struct { GUI_AUTODEV_INFO AutoDevInfo; /* Information about what has to be drawn */ /* Additional data used by the user function */ ... } PARAM; static void Draw(void * p) { PARAM * pParam = (PARAM *)p; if (pParam->AutoDevInfo.DrawFixed) { /* Draw fixed background */ ... } /* Draw moving objects */ ... User's & reference manual for C/GUI 2002-2007 Micrium
272
Memory Devices
void main(void) { PARAM Param; /* Parameters for drawing routine */ GUI_AUTODEV AutoDev; /* Object for banding memory device */ /* Set/modify informations for drawing routine */ ... GUI_MEMDEV_CreateAuto(&AutoDev); /* Create GUI_AUTODEV-object */ GUI_MEMDEV_DrawAuto(&AutoDev, /* Use GUI_AUTODEV-object for drawing */ &Param.AutoDevInfo, &Draw, &Param); GUI_MEMDEV_DeleteAuto(&AutoDev); /* Delete GUI_AUTODEV-object */ }
2002-2007 Micrium
273 0xBBBBDF,0xC7C7C7,0x616193 }; static const GUI_LOGPALETTE PalScaleR140 = { 15, /* number of entries */ 0, /* No transparency */ &ColorsScaleR140[0] }; static const unsigned char acScaleR140[] = { /* ... The pixel data is not shown in the manual. Please take a look at the sample source file ... */ }; static const GUI_BITMAP bmScaleR140 = { 200, /* XSize */ 73, /* YSize */ 100, /* BytesPerLine */ 4, /* BitsPerPixel */ acScaleR140, /* Pointer to picture data (indices) */ &PalScaleR140 /* Pointer to palette */ }; /******************************************************************* * * static data, shape of polygon * ******************************************************************** */ static const GUI_POINT _aNeedle[] = { { MAG * ( 0), MAG * ( 0 + 125)}, { MAG * (-3), MAG * (-15 + 125)}, { MAG * (-3), MAG * (-65 + 125)}, { MAG * ( 3), MAG * (-65 + 125)}, { MAG * ( 3), MAG * (-15 + 125)}, }; /******************************************************************* * * structure containing information for drawing routine */ typedef struct { /* Information about what has to be displayed */ GUI_AUTODEV_INFO AutoDevInfo; /* Polygon data */ GUI_POINT aPoints[7]; float Angle; } PARAM; /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _GetAngle This routine returns the value to indicate. In a real application, this value would somehow be measured. */ static float _GetAngle(int tDiff) { if (tDiff < 15000) { return 225 - 0.006 * tDiff ; } tDiff -= 15000; if (tDiff < 7500) { return 225 - 90 + 0.012 * tDiff ; } tDiff -= 7000;
2002-2007 Micrium
CHAPTER 12
Memory Devices
/******************************************************************* * * _Draw */ static void _Draw(void * p) { PARAM * pParam = (PARAM *)p; /* Fixed background */ if (pParam->AutoDevInfo.DrawFixed) { GUI_ClearRect (60, 80 + bmScaleR140.YSize, 60 + bmScaleR140.XSize - 1, 180); GUI_DrawBitmap(&bmScaleR140, 60, 80); } /* Moving needle */ GUI_SetColor(GUI_WHITE); GUI_AA_FillPolygon(pParam->aPoints, countof(_aNeedle), MAG * 160, MAG * 220); /* Fixed foreground */ if (pParam->AutoDevInfo.DrawFixed) { GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_RED); GUI_SetFont(&GUI_Font24B_ASCII); GUI_DispStringHCenterAt("RPM / 1000", 160, 140); } } /******************************************************************* * * _DemoScale */ static void _DemoScale(void) { int Cnt; int tDiff, t0; PARAM Param; /* Parameters for drawing routine */ GUI_AUTODEV AutoDev; /* Object for banding memory device */ /* Show message */ GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("MEMDEV_AutoDev - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Scale using GUI_AUTODEV-object", 160, 50); /* Enable high resolution for antialiasing */ GUI_AA_EnableHiRes(); GUI_AA_SetFactor(MAG); while (1) { t0 = GUI_GetTime(); /* Create GUI_AUTODEV-object */ GUI_MEMDEV_CreateAuto(&AutoDev); /* Show needle for a fixed time */ for (Cnt = 0; (tDiff = GUI_GetTime() - t0) < 24000; Cnt++) { /* Get value to display an calculate polygon for needle */ Param.Angle = _GetAngle(tDiff)* DEG2RAD; GUI_RotatePolygon(Param.aPoints, _aNeedle, countof(_aNeedle), Param.Angle); GUI_MEMDEV_DrawAuto(&AutoDev, &Param.AutoDevInfo, &_Draw, &Param); } /* Display milliseconds / picture */ GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Milliseconds / picture:", 160, 200); GUI_SetTextAlign(GUI_TA_CENTER); GUI_SetTextMode(GUI_TM_NORMAL); GUI_DispNextLine(); GUI_GotoX(160); GUI_DispFloatMin((float)tDiff / (float)Cnt, 2); /* Delete GUI_AUTODEV-object */ GUI_MEMDEV_DeleteAuto(&AutoDev); GUI_Delay(3000); GUI_ClearRect(0, 70, 319, 239); } }
2002-2007 Micrium
275 /******************************************************************* * * MainTask * * Demonstrates the use of an auto memory device * ******************************************************************** */ void MainTask(void) { GUI_Init(); while(1) { _DemoScale(); } }
GUI_MEASDEV_Create()
Description
Creates a measurement device.
Prototype
GUI_MEASDEV_Handle GUI_MEASDEV_Create(void);
Return value
The handle of the measurement device.
2002-2007 Micrium
276
CHAPTER 12
Memory Devices
GUI_MEASDEV_ClearRect()
Description
Call this function to clear the measurement rectangle of device. the given measurement
Prototype
void GUI_MEASDEV_ClearRect(GUI_MEASDEV_Handle hMem); Parameter hMem
Handle to measurement device.
Meaning
GUI_MEASDEV_Delete()
Description
Deletes a measurement device.
Prototype
void GUI_MEASDEV_Delete (GUI_MEASDEV_Handle hMem); Parameter hMem
Handle to measurement device.
Meaning
GUI_MEASDEV_GetRect()
Description
Retrieves the result of the drawing operations.
Prototype
void GUI_MEASDEV_GetRect(GUI_MEASDEV_Handle hMem, GUI_RECT *pRect); Parameter hMem pRect
Handle to measurement device. Pointer to GUI_RECT-structure to store result.
Meaning
GUI_MEASDEV_Select()
Description
Selects a measurement device as target for drawing operations.
Prototype
void GUI_MEASDEV_Select (GUI_MEASDEV_Handle hMem); Parameter hMem
Handle to measurement device.
Meaning
Example
The following sample shows the use of a measurement device. It creates a measurement device, draws a line and displays the result of the measurement device:
void MainTask(void) {
2002-2007 Micrium
277 GUI_MEASDEV_Handle hMeasdev; GUI_RECT Rect; GUI_Init(); hMeasdev = GUI_MEASDEV_Create(); GUI_MEASDEV_Select(hMeasdev); GUI_DrawLine(10, 20, 30, 40); GUI_SelectLCD(); GUI_MEASDEV_GetRect(hMeasdev, &Rect); GUI_MEASDEV_Delete(hMeasdev); GUI_DispString("X0:"); GUI_DispDec(Rect.x0, 3); GUI_DispString(" Y0:"); GUI_DispDec(Rect.y0, 3); GUI_DispString(" X1:"); GUI_DispDec(Rect.x1, 3); GUI_DispString(" Y1:"); GUI_DispDec(Rect.y1, 3); }
2002-2007 Micrium
278
CHAPTER 12
Memory Devices
2002-2007 Micrium
279
2002-2007 Micrium
280
CHAPTER 13
Advantages
No real time kernel is used (-> smaller ROM size, just one stack -> less RAM for stacks), no preemption/synchronization problems.
Disadvantages
The superloop type of program can become hard to maintain if it exceeds a certain program size. Real time behavior is poor, since one software component cannot be interrupted by any other component (only by interrupts). This means that the reaction time of one software component depends on the exectution time of all other components in the system.
2002-2007 Micrium
281
Using C/GUI
There are no real restrictions regarding the use of C/GUI. As always, GUI_Init() has to be called before you can use the software. From there on, any API function can be used. If the window managers callback mechanism is used, then a C/GUI update function has to be called regularly. This is typically done by calling the GUI_Exec() from within the superloop. Blocking functions such as GUI_Delay() and GUI_ExecDialog() should not be used in the loop since they would block the other software modules. The default configuration, which does not support multitasking (#define GUI_MT 0) can be used; kernel interface routines are not required.
Advantages
The real time behavior of the system is excellent. The real time behavior of a task is affected only by tasks running at higher priority. This means that changes to a program component running in a low priority task do not affect the real time behavior at all. If the user interface is executed from a low priority task, this means that changes to the user interface do not affect the real time behavior. This kind of system makes it easy to assign different components of the software to different members of the development team, which can work to a high degree independently from each other.
2002-2007 Micrium
282
CHAPTER 13
Disadvantages
You need to have a real time kernel (RTOS), which costs money and uses up ROM and RAM (for stacks). In addition, you will have to think about task synchronization and how to transfer information from one task to another.
Using C/GUI
If the window managers callback mechanism is used, then a C/GUI update function (typically GUI_Exec(), GUI_Delay()) has to be called regularly from the task calling C/GUI. Since C/GUI is only called by one task, to C/GUI it is the same as being used in a single task system. The default configuration, which does not support multitasking (#define GUI_MT 0) can be used; kernel interface routines are not required. You can use any real time kernel, commercial or proprietary.C/GUI
Advantages
The real time behavior of the system is excellent. The real time behavior of a task is affected only by tasks runnig at higher priority. This means that changes of a program component running in a low priority task do not affect the real time behavior at all. If the user interface is executed from a low priority task, this means that changes on the user interface do not affect the real time behavior. This kind of system makes it easy to assign different components of the software to different members of the development team, which can work to a high degree independently from each other.
Disadvantages
You have to have a real time kernel (RTOS), which costs money and uses up some ROM and RAM (for stacks). In addition, you will have to think about task synchronization and how to transfer information from one task to another.
Using C/GUI
If the window managers callback mechanism is used, then a C/GUI update function (typically GUI_Exec(), GUI_Delay()) has to be called regularly from one or more tasks calling C/GUI. The default configuration, which does not support multitasking (#define GUI_MT 0) can NOT be used. The configuration needs to enable multitasking support and define a maximum number of tasks from which C/GUI is called (excerpt from GUIConf.h):
2002-2007 Micrium
283
// Enable multitasking support // Max. number of tasks that may call C/GUI
Kernel interface routines are required, and need to match the kernel being used. You can use any real time kernel, commercial or proprietary. Both the macros and the routines are discussed in the following chapter sections.
Recommendations
Call the C/GUI update functions (i.e. GUI_Exec(), GUI_Delay()) from just one task. It will help to keep the program structure clear. If you have sufficient RAM in your system, dedicate one task (with the lowest priority) to updating C/GUI. This task will continuously call GUI_Exec() as shown in the example below and will do nothing else. Keep your real time tasks (which determine the behavior of your system with respect to I/O, interface, network, etc.) seperate from tasks that call C/GUI. This will help to assure best real time performance. If possible, use only one task for your user interface. This helps to keep the program structure simple and simplifies debugging. (However, this is not required and may not be suitable in some systems.)
Example
This excerpt shows the dedicated C/GUI update task. It is taken from the example MT_Multitasking, which is included in the samples shipped with C/GUI:
/******************************************************************* * * GUI background processing * * This task does the background processing. * The main job is to update invalid windows, but other things such as * evaluating mouse or touch input may also be done. */ void GUI_Task(void) { while(1) { GUI_Exec(); /* Do the background work ... Update windows etc.) */ GUI_X_ExecIdle(); /* Nothing left to do for the moment ... Idle processing */ } }C/GUI
Macro GUI_MAXTASK
4
Default
Explanation
Define the maximum number of tasks from which C/GUI is called when multitasking support is enabled (see below).
0 Activate to enable multitasking support. GUI_OS Defines a function that signals an event. GUI_X_SIGNAL_EVENT() GUI_X_ExecIdle() Defines a function that waits for an event. GUI_X_WAIT_EVENT()
2002-2007 Micrium
284
CHAPTER 13
GUI_MAXTASK
Description
Defines the maximum number of tasks from which C/GUI is called to access the display.
Type
Numerical value
Additional information
This function is only relevant when GUI_OS is activated.
GUI_OS
Description
Enables multitasking support by activating the module GUITask.
Type
Binary switch 0: inactive, multitask support disabled (default) 1: active, multitask support enabled
GUI_X_SIGNAL_EVENT
Description
Defines a function that signals an event.
Type
Function replacement
Additional information
Per default the GUI needs to periodically check for events unless a function is defined which waits and one that triggers an event. This macro defines the function which triggers an event. It makes only sense in combination with GUI_X_WAIT_EVENT. The advantage of using the macros GUI_X_SIGNAL_EVENT and GUI_X_WAIT_EVENT instead of polling is the reduction of CPU load of the waiting task to 0% while it waits for input. If the macro has been defined as recommended and the user gives the system any input (keyboard or pointer input device) the defined function should signal an event. It is recommended to specify the function GUI_X_SignalEvent() for the job.
Sample
#define GUI_X_SIGNAL_EVENT() GUI_X_SignalEvent()
GUI_X_WAIT_EVENT
Description
Defines a function which waits for an event.
2002-2007 Micrium
285
Type
Function replacement
Additional information
Per default the GUI needs to periodically check for events unless a function is defined which waits and one that triggers an event. This macro defines the function which waits for an event. Makes only sense in combination with GUI_X_SIGNAL_EVENT. The advantage of using the macros GUI_X_SIGNAL_EVENT and GUI_X_WAIT_EVENT instead of polling is the reduction of CPU load of the waiting task to 0% while it waits for input. If the macro has been defined as recommended and the system waits for user input the defined function should wait for an event signaled from the function defined by the macro GUI_X_SIGNAL_EVENT. It is recommended to specify the function GUI_X_WaitEvent() for the job.
Sample
#define GUI_X_WAIT_EVENT() GUI_X_WaitEvent()
GUI_X_InitOS()
Description
Creates the resource semaphore or mutex typically used by GUI_X_Lock() and GUI_X_Unlock().
Prototype
void GUI_X_InitOS(void)
GUI_X_GetTaskID()
Description
Returns a unique ID for the current task.
2002-2007 Micrium
286
CHAPTER 13
Prototype
U32 GUI_X_GetTaskID(void);
Return value
ID of the current task as a 32-bit integer.
Additional information
Used with a real-time operating system. It does not matter which value is returned, as long as it is unique for each task/ thread using the C/GUI API and as long as the value is always the same for each particular thread.
GUI_X_Lock()
Description
Locks the GUI.
Prototype
void GUI_X_Lock(void);
Additional information
This routine is called by the GUI before it accesses the display or before using a critical internal data structure. It blocks other threads from entering the same critical section using a resource semaphore/mutex until GUI_X_Unlock() has been called. When using a real time operating system, you normally have to increment a counting resource semaphore.
GUI_X_Unlock()
Description
Unlocks the GUI.
Prototype
void GUI_X_Unlock(void);
Additional information
This routine is called by the GUI after accessing the display or after using a critical internal data structure. When using a real time operating system, you normally have to decrement a counting resource semaphore.
Examples
Kernel interface routines for C/OS-II
The following example shows an adaption of the four routines for uC/OS-II (excerpt from file GUI_X_uCOS-II.c):
#include "INCLUDES.H" static OS_EVENT * DispSem; U32 void void void GUI_X_GetTaskId(void) GUI_X_InitOS(void) GUI_X_Unlock(void) GUI_X_Lock(void) { { { { return ((U32)(OSTCBCur->OSTCBPrio)); } DispSem = OSSemCreate(1); } OSSemPost(DispSem); }
2002-2007 Micrium
2002-2007 Micrium
288
CHAPTER 13
2002-2007 Micrium
289
When using the C/GUI window manager (WM), everything which appears on the display is contained in a window -- a rectangular area on the screen. A window can be any size, and you can display multiple windows on the screen at once, even partially or entirely in front of other windows. The window manager supplies a set of routines which allow you to easily create, move, resize, and otherwise manipulate any number of windows. It also provides lower-level support by managing the layering of windows on the display and by alerting your application to display changes that affect its windows. The C/GUI window manager is a separate (optional) software item and is not included in the C/GUI basic package. The software for the window manager is located in the subdirectory GUI\WM.
2002-2007 Micrium
290
CHAPTER 14
Active window
The window which is currently being used for drawing operations is referred to as the active window. It is not necessarily the same as the topmost window.
Callback routines
Callback routines are defined by the user program, instructing the graphic system to call a specific function when a specific event occurs. Normally they are used to automatically redraw a window when its content has changed.
Client area
The client area of a window is simply its usable area. If a window contains a frame or title bar, then the client area is the rectangular inner area. If there is no such frame, then the coordinates of the client area are identical to those of the window itself.
Coordinates
Coordinates are usually 2 dimensional coordinates, expressed in units of pixels. A coordinate consists of 2 values. The first value specifies the horizontal component (also called the x-coordinate), the second value specifies the vertical component (also called the y-coordinate).
Desktop coordinates
Desktop coordinates are coordinates of the desktop window. The upper left position (the origin) of the display is (0,0).
Desktop window
The desktop window is automatically created by the window manager, and always covers the entire display area. It is always the bottommost window, and when no other window has been defined, it is the default (active) window. All windows are descendants (children, grandchildren, etc.) of the desktop window.
2002-2007 Micrium
291
Handle
When a new window is created, the WM assigns it a unique identifier called a handle. The handle is used in any further operations performed on that particular window.
Hiding/showing windows
A hidden window is not visible, although it still exists (has a handle). When a window is created, it is hidden by default if no create flag is specified. Showing a window makes it visible; hiding it makes it invisible.
Parent coordinates
Parent coordinates are window coordinates relative to the parent window. The upper left position (the origin) of the window is (0,0).
Transparency
A window that has transparency contains areas that are not redrawn with the rest of the window. These areas operate as though the window behind "shows through" them. In this case, it is important that the window behind is redrawn before the window with transparency. The WM automatically handles redrawing in the correct order.
Validation/invalidation
A valid window is a fully updated window which does not need redrawing. An invalid window does not yet reflect all updates and therefore needs to be redrawn, either completely or partially. When changes are made that affect a particular window, the WM marks that window as invalid. The next time the window is redrawn (either manually or by a callback routine) it will be validated.
Window coordinates
Window coordinates are coordinates of a window. The upper left position (the origin) of the window is (0,0).
Z-position, bottom/top
Although a window is displayed on a two-dimensional screen in terms of X and Y, the WM also manages what is known as a Z-position, or depth coordinate -- a position in a virtual third dimension which determines its placement from background to foreground. Windows can therefore appear on top of or beneath one another. Setting a window to the bottom will place it "underneath" all of its sibling windows (if any); setting it to the top will place it "on top of" its siblings. When a window is created, it is set to the top by default if no create flag is specified.
2002-2007 Micrium
292
CHAPTER 14
Warning: When not using the callback mechanism, it is your responsibility to manage screen updates!
Prototype
void callback(WM_MESSAGE* pMsg); Parameter pMsg Meaning
Pointer to a data structure of type WM_MESSAGE.
The action performed by the callback routine depends on the type of message it receives. The prototype above is usually followed by a switch statement, which defines different behaviors for different messages using one or more case statements (typically at least WM_PAINT).
Example
Creates a callback routine to automatically redraw a window:
2002-2007 Micrium
293 void WinHandler(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(0xFF00); GUI_Clear(); GUI_DispStringAt("Hello world",0,0); break; } }
14.2.4 Invalidation
Invalidation of a window or a part of it tells the WM that the invalid area of the window should be redrawn the next time GUI_Exec() or GUI_Delay() is called. The invalidation routines of C/GUI do not redraw the invalid part of a window. They only manage the invalid areas of the windows.
2002-2007 Micrium
294
CHAPTER 14
To make sure the window manager can handle the redrawing of transparent windows it is necessary to redraw the window in reaction to the WM_PAINT message. Otherwise it can not be guaranteed that the appearance of a transparent window will be correctly. The use of transparent windows is more CPU-intensive than the use of non transparent windows. If performance is a problem, trying to avoid transparent windows may be an option
2002-2007 Micrium
295
14.3 Messages
The following section shows which system messages are used by C/GUI, how to use the message data and how to use application defined messages.
Elements of WM_MESSAGE
Data type Element int WM_HWIN WM_HWIN void* int MsgId hWin hWinSrc Data.p Data.v
Destination window. Source window. Data pointer. Data value.
Meaning
Type of message (see table below).
Explanation
2002-2007 Micrium
296
CHAPTER 14
Explanation
Sent to a window if a pointer input device touches the outline of a window in pressed state. Sent to a parent window if a child window has been touched by the pointer input device.
WM_CREATE
Description
This message is sent immediately after a window has been created, giving the window the chance to initialize and create any child windows.
Data
This message contains no data.
WM_DELETE
Description
This message is sent just before a window is deleted, telling the window to free its data structures (if any).
Data
This message contains no data.
WM_GET_ID
Description
This message is sent to a window to request its Id. All C/GUI widgets handle this message. Application defined windows should handle this message in their callback routine. Otherwise this message will be ignored.
Data
The callback routine of the window should store the Id in the Data.v value.
WM_INIT_DIALOG
Description
This message is sent to a window immediately after the creation of the dialog and before the dialog is displayed. Dialog procedures typically use this message to initialize widgets and carry out any other initialization tasks that affect the appearance of the dialog box.
2002-2007 Micrium
297
Data
This message contains no data.
WM_KEY
Description
Sent to the window currently containing the focus if a key has been pressed.
Data
The Data.p pointer of the message points to a WM_KEY_INFO structure.
Elements of WM_KEY_INFO
Data type int int Element Key PressedCount Meaning
The key which has been pressed. > 0 if the key has been pressed, 0 if the key has been released.
WM_MOVE
Description
This message is sent to a window immediately after it has been moved. If the window has any child windows, they will be moved first. Also each child window will receive this message after it has been moved. The message is sent regardless if the window is visible or not.
Data
This message contains no data.
WM_NOTIFY_PARENT
Description
Informs a parent window that something has occured in one of its child window. These messages are typically send by widgets to their parent windows to give them a chance to react on the event.
Data
The Data.v value of the message contains the notification code of the message. For more informations about the notification codes please refer to the according widget.
WM_NOTIFY_VIS_CHANGED
Description
This message is sent to a window if its visibility is changed and the configuration switch WM_SUPPORT_NOTIFY_VIS_CHANGED is set to 1. The visibility of a window changes if obstruction changes: The window is partially or totally covered or uncovered by a higher level window (a window which is displayed on top of the window), the window is deleted or the window changes from not hidden to hidden or reverse.
2002-2007 Micrium
298
CHAPTER 14
Typical application
Applications which show a video in a window using a hardware decoder. The hardware decoder can write directly into the display, bypassing C/GUI, if the window containing the video is completely visible. If the visibility changes, the hardware decoder needs to be reprogrammed.
Example
The following shows a typical reaction on this message:
case WM_NOTIFY_VIS_CHANGED: if (WM_IsCompletelyVisible(WM_GetClientWindow(pMsg->hWin))) { ... }
The sample folder of C/GUI contains the sample WM_Video.c which shows how to use the message.
Data
This message contains no data.
WM_PAINT
Description
The WM sends this message to a window if it has become invalid (partially or complete) and needs to be drawn. When a window receives a WM_PAINT message, it should repaint itself. Before sending this message to the window, the WM makes sure it is selected. More details about how to react on the WM_PAINT message is described earlier in this chapter under "Using callback routines".
Data
The Data.p pointer of the message points to a GUI_RECT structure containing the invalid rectangle of the window in screen coordinates. This information could be used to optimize the paint function.
WM_SET_FOCUS
Description
Send to a window if it gains or looses the input focus.
Data
If the window gains the input focus, the Data.v value is set to 1. If the window accepts the input focus, it should set the Data.v value to 0 in reaction on this message. If the window looses the input focus, the Data.v value is set to 0.
WM_SET_ID
Description
Send to a window to change the Id. All C/GUI widgets handle this message. Application defined windows should handle this message in their callback routine. Otherwise this message will be ignored.
Data
The Data.v value contains the new Id of the window.
2002-2007 Micrium
299
WM_SIZE
Description
Sent to a window after its size has changed. Gives the window the chance to reposition its child windows (if any).
Data
This message contains no data.
WM_TIMER
Description
This message will be send to a window when a timer created by WM_CreateTimer() has expired.
Data
The Data.v value contains the handle of the expired timer.
2002-2007 Micrium
300
CHAPTER 14
WM_MOUSEOVER
Description
A WM_MOUSEOVER message is send to a window if a pointer input device touches the outline of a window. It is send only if mouse support is enabled. This message is not sent to disabled windows. To enable mouse support please add the following line to the file GUIConf.h:
#define GUI_SUPPORT_MOUSE 1
Data
The Data.p pointer of the message points to a GUI_PID_STATE structure.
Elements of GUI_PID_STATE
Data type int int U8 Element x y Pressed Meaning
Horizontal position of the PID in window coordinates. Vertical position of the PID in window coordinates. Is always set to 0 when receiving a WM_MOUSEOVER message.
WM_MOUSEOVER_END
Description
A WM_MOUSEOVER_END message is sent to a window if the mouse pointer has been moved out of the window. It is send only if mouse support is enabled. This message is not sent to disabled windows.
Data
The Data.p pointer of the message points to a GUI_PID_STATE structure. For details about this structure please refer to the message WM_MOUSEOVER.
WM_PID_STATE_CHANGED
Description
Sent to the window affected by the pointer input device when the pressed state has changed. The affected window is the visible window at the input position. With other words: If the user releases for example the touch screen over a window, the pressed state changes from 1 (pressed) to 0 (unpressed). In this case a WM_PID_STATE_CHANGED message is send to the window. This message is send before the touch message is send. An invisible window does not receive this message. Transparent windows are handled the same way as visible windows. This message is not sent to disabled windows.
Data
The Data.p pointer of the message points to a WM_PID_STATE_CHANGED_INFO structure.
2002-2007 Micrium
301
Elements of WM_PID_STATE_CHANGED_INFO
Data type int int U8 U8 Element x y State StatePrev Meaning
Horizontal position of the PID in window coordinates. Vertical position of the PID in window coordinates. Pressed state (> 0 if PID is pressed). Previous pressed state
WM_TOUCH
Description
A WM_TOUCH message is send to a window if the PID is in pressed state and the pointer is over the visible part of the window or the PID just has been released. This message is not sent to disabled windows.
Data
The Data.p pointer of the message points to a GUI_PID_STATE structure. For details about the structure prease refer to the message WM_MOUSEOVER.
Elements of GUI_PID_STATE
Data type int int x y Element Meaning
Horizontal position of the PID in window coordinates. Vertical position of the PID in window coordinates. If the message is originated by a touch screen this value can be 0 (unpressed) or 1 (pressed). If the message is originated by a mouse each bit represents a mouse button (0 for unpressed and 1 for pressed state): - Bit 0 represents the first button (normally the left button) - Bit 1 represents the second button (normally the right button) - Bit 2 represents the third button (normally the middle button) The remaining bits can be used for further buttons.
U8
Pressed
WM_TOUCH_CHILD
Description
This message is send to the parent window if the outline of a child window has been touched with a pointer input device in pressed or unpressed state. This message is not sent to disabled windows.
Data
The Data.p pointer of the message points to the touch message send to the child window. For details about the message data please refer to the WM_TOUCH description.
2002-2007 Micrium
302
CHAPTER 14
Example
The following sample explains what happens if a pointer input device is dragged over a dialog with a button:
Position
Explanation
The pointer input device (PID) is pressed at this position. This causes the WM to send the following WM_PID_STATE_CHANGED message to the window at this position: x = Horizontal position in in desktop coordinates. y = Vertical position in in desktop coordinates. State = 1 StatePrev = 0 The WM also sends a WM_TOUCH message with the same x and y coordinates to the window: x = Horizontal position in in desktop coordinates. y = Vertical position in in desktop coordinates. Pressed = 1 The PID is dragged to this position. The window below (the button) will receive no WM_PID_STATE_CHANGED message, because the PID remains in pressed state. The WM only sends a WM_TOUCH message to the window: x = Horizontal position in in desktop coordinates. y = Vertical position in in desktop coordinates. Pressed = 1 The PID is released at this position. This causes the WM to send the following WM_PID_STATE_CHANGED message to the window at this position: x = Horizontal position in in desktop coordinates. y = Vertical position in in desktop coordinates. State = 0 StatePrev = 1 The WM also sends a WM_TOUCH message with the same x and y coordinates to the window: x = Horizontal position in in desktop coordinates. y = Vertical position in in desktop coordinates. Pressed = 0
2002-2007 Micrium
303
WM_NOTIFICATION_CHILD_DELETED
Description
This notification code is send to the parent window before a child window will be deleted.
Data
The hWinSrc element of the message contains the handle of the window to be deleted.
2002-2007 Micrium
304
CHAPTER 14
Macro WM_SUPPORT_NOTIFY_VIS_CHANGED 0
1
Default
Explanation
Enables the WM to send a
WM_NOTIFY_VIS_CHANGED message
to a window if its visibility is changed. Enable support for transparent windows. If set to 0 the additional code for transparency support is not included.
WM_SUPPORT_TRANSPARENCY
WM_SUPPORT_NOTIFY_VIS_CHANGED
Per default C/GUI does not inform windows if their visibility has changed. If enabled, the WM sends WM_NOTIFY_VIS_CHANGED messages.
WM_SUPPORT_TRANSPARENCY
Per default C/GUI supports transparent windows. This means per default the additional code used to handle transparent windows is linked if the WM is used. If the application does not use transparent windows the memory requirement of the application can be reduced if setting WM_SUPPORT_TRANSPARENCY to 0.
2002-2007 Micrium
305
14.5 WM API
The following table lists the available routines of the C/GUI window manager API. All functions are listed in alphabetical order within their respective categories. Detailed descriptions of the routines can be found later in the chapter. Routine Basic functions WM_Activate() WM_AttachWindow() WM_AttachWindowAt() WM_BroadcastMessage() WM_BringToBottom() WM_BringToTop() WM_ClrHasTrans() WM_CreateWindow() WM_CreateWindowAsChild() WM_Deactivate() WM_DefaultProc() WM_DeleteWindow() WM_DetachWindow() WM_DisableWindow() WM_EnableWindow() WM_Exec() WM_Exec1() WM_ForEachDesc() WM_GetActiveWindow() WM_GetCallback() WM_GetClientRect() WM_GetClientRectEx() WM_GetDesktopWindow() WM_GetDesktopWindowEx() WM_GetDialogItem() WM_GetFirstChild() WM_GetFocussedWindow() WM_GetHasTrans() WM_GetInvalidRect() WM_GetNextSibling() WM_GetOrgX() WM_GetOrgY() WM_GetParent() WM_GetPrevSibling() WM_GetStayOnTop() WM_GetUserData() WM_GetWindowOrgX() WM_GetWindowOrgY() WM_GetWindowRect()
Activates the window manager. Attaches a window to a new parent window. Attaches a window to a new parent window at the given position. Sends a message to all existing windows. Places a window behind its siblings. Places a window in front of its siblings. Clears the
Explanation
Creates a window. Creates a child window. Deactivates the window manager. Default routine to handle messages. Deletes a window. Detaches a window from its parent window. Sets the widget state to disabled. Sets the window state to enabled (default). Redraws invalid windows by executing callbacks (all jobs). Redraws one invalid window by executing one callback (one job only). Iterates over all descendants of a window. Returns handle of the active window. Returns a pointer to the callback function of a window. Returns the size of the active window. Returns the size of a window. Returns the window handle of the desktop window Returns the window handle of the specified desktop window Returns the window handle of a dialog box item (widget). Returns handle of a windows first child window. Returns the handle of the window with the input focus. Returns current value of the
Returns the invalid rectangle of the given window. Returns the handle of a windows next sibling. Returns the origin in X of the active window. Returns the origin in Y of the active window. Returns handle of a windows parent window. Returns the handle of a windows previous sibling. Returns current value of the
Retrieves the user data of a window Returns the origin in X of a window. Returns the origin in Y of a window. Returns the screen coordinates of the active window.
2002-2007 Micrium
306
CHAPTER 14
Routine WM_GetWindowRectEx() WM_GetWindowSizeX() WM_GetWindowSizeY() WM_HasCaptured() WM_HasFocus() WM_HideWindow() WM_InvalidateArea() WM_InvalidateRect() WM_InvalidateWindow() WM_IsCompletelyCovered() WM_IsCompletelyVisible() WM_IsEnabled() WM_IsVisible() WM_IsWindow() WM_MakeModal() WM_MoveChildTo() WM_MoveTo() WM_MoveWindow() WM_NotifyParent() WM_Paint() WM_PaintWindowAndDescs() WM_ReleaseCapture() WM_ResizeWindow() WM_SelectWindow() WM_SendMessage() WM_SendMessageNoPara() WM_SendToParent() WM_SetDesktopColor() WM_SetDesktopColorEx() WM_SetCallback() WM_SetCapture() WM_SetCreateFlags() WM_SetFocus() WM_SetHasTrans() WM_SetId() WM_SetpfPollPID() WM_SetSize() WM_SetWindowPos() WM_SetXSize() WM_SetYSize() WM_SetStayOnTop() WM_SetTransState() WM_SetUserClipRect()
Explanation
Returns the screen coordinates of a window. Returns the horizontal size (width) of a window. Returns the vertical size (height) of a window. Checks if the given window has captured mouse- and touchscreen-input. Checks if the given window has the input focus. Makes a window invisible. Invalidates a certain section of the display. Invalidates a part of a window. Invalidates a window. Checks if a window is completely covered or not. Checks if a window is completely visible or not. Returns if a window is enabled or not. Returns if a window is visible or not. Determine whether a specified handle is a valid window handle. Changes the window to a modal window. Sets the position of a window in window coordinates. Sets the position of a window in desktop coordinates. Moves a window to another position. Sends a WM_NOTIFY_PARENT message to the parent of the given window. Draws or redraws a window immediately. Draws a given window and all descendant windows immediately. Stops capturing mouse- and touch screen-input. Changes window size. Sets the active window to be used for drawing operations. Sends a message to a window. Sends a message without parameters to a window. Sends the given message to the parent window of the given window. Sets desktop window color. Sets desktop window color of the given desktop. Sets the callback routine for a window. Starts capturing mouse- and touch screen-input. Sets the flags to be used as default when creating new windows Sets input focus to a specified window. Sets the
2002-2007 Micrium
307
Routine WM_SetUserData() WM_ShowWindow() WM_Update() WM_UpdateWindowAndDescs() WM_ValidateRect() WM_ValidateWindow() WM_DisableMemdev() WM_EnableMemdev() WM_CreateTimer() WM_DeleteTimer() WM_RestartTimer() WM_GetClientWindow() WM_GetId() WM_GetInsideRect() WM_GetInsideRectEx() WM_GetScrollPosH() WM_GetScrollPosV() WM_GetScrollState() WM_SetScrollPosH() WM_SetScrollPosV() WM_SetScrollState()
Makes a window visible.
Explanation
Sets the user data of the given window. Draws the invalid part of the given window. Draws the invalid part of a given window and the invalid part of all descendant windows. Validates parts of a window. Validates a window.
Timer related
Creates a timer which sends a WM_TIMER message to a window. Deletes a timer. Restarts a timer.
Prototype
void WM_Activate(void);
2002-2007 Micrium
308
CHAPTER 14
Add. information
The WM is activated by default after initialization. This function only needs to be called if there has been a previous call of WM_Deactivate().
WM_AttachWindow()
Description
The given window will be detached from its parent window and attached to the new parent window. The new origin in window coordinates of the new parent window will be the same as the old origin in window coordinates of the old parent window.
Prototype
void WM_AttachWindow(WM_HWIN hWin, WM_HWIN hParent); Parameter hWin hWinParent
Window handle. Window handle of the new parent.
Meaning
Add. Information
If the given window handle is 0 or both handles are the same the function returns immediately. If only the given parent window handle is 0 the function detaches the given window and returns; the window remains unattached.
WM_AttachWindowAt()
Description
The given window will be detached from its parent window and attached to the new parent window. The given position will be used to set the origin of the window in window coordinates of the parent window.
Prototype
void WM_AttachWindowAt(WM_HWIN hWin, WM_HWIN hParent, int x, int y); Parameter hWin hWinParent x y
Window handle. Window handle of the new parent. X position of the window in window coordinates of the parent window. Y position of the window in window coordinates of the parent window.
Meaning
Add. Information
If the given window handle is 0 or both handles are the same the function returns immediately. If only the given parent window handle is 0 the function detaches the given window, moves it to the new position and returns; the window remains unattached.
WM_BringToBottom()
Description
Places a specified window underneath its siblings.
2002-2007 Micrium
309
Prototype
void WM_BringToBottom(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The window will be placed underneath all other sibling windows, but will remain in front of its parent.
WM_BringToTop()
Description
Places a specified window on top of its siblings.
Prototype
void WM_BringToTop(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The window will be placed on top of all other sibling windows and its parent.
WM_BroadcastMessage()
Description
Sends the given message to all existing windows.
Prototype
int WM_BroadcastMessage(WM_MESSAGE * pMsg); Parameter pMsg
Pointer to message to be send.
Meaning
Add. information
A window should not delete itself or a parent window in reaction of a broadcasted message.
WM_ClrHasTrans()
Description
Clears the has transparency flag (sets it to 0).
Prototype
void WM_ClrHasTrans(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
2002-2007 Micrium
310
CHAPTER 14
Add. information
When set, this flag tells the window manager that a window contains sections which are not redrawn and will therefore be transparent. The WM then knows that the background needs to be redrawn prior to redrawing the window in order to make sure the transparent sections are restored correctly. When the flag is cleared with WM_ClrHasTrans(), the WM will not automatically redraw the background before redrawing the window.
WM_CreateWindow()
Description
Creates a window of a specified size at a specified location.
Prototype
WM_HWIN WM_CreateWindow(int x0, int y0, int width, int height, U8 Style, WM_CALLBACK* cb int NumExtraBytes); Parameter x0 y0 width height Style cb NumExtraBytes Meaning
Upper left X-position in desktop coordinates. Upper left Y-position in desktop coordinates. X-size of window. Y-size of window. Window create flags, listed below. Pointer to callback routine, or NULL if no callback used. Number of extra bytes to be allocated, normally 0.
WM_CF_ANCHOR_BOTTOM
WM_CF_ANCHOR_LEFT
WM_CF_ANCHOR_RIGHT
WM_CF_ANCHOR_TOP
WM_CF_BGND
2002-2007 Micrium
311
WM_CF_CONST_OUTLINE
WM_CF_LATE_CLIP
WM_CF_MEMDEV
WM_CF_MEMDEV_ON_REDRAW
WM_CF_SHOW WM_CF_STAYONTOP
Return value
Handle for created window.
Add. information
Several create flags can be combined by using the (OR) operator. Negative-position coordinates may be used.
Examples
Creates a window with callback:
hWin2 = WM_CreateWindow(100, 10 ,180, 100, WM_CF_SHOW, &WinHandler, 0);
2002-2007 Micrium
312
CHAPTER 14
WM_CreateWindowAsChild()
Description
Creates a window as a child window.
Prototype
WM_HWIN WM_CreateWindowAsChild(int x0, int y0, int width, int height, WM_HWIN hWinParent, U8 Style, WM_CALLBACK* cb int NumExtraBytes); Parameter x0 y0 width height hWinParent Style cb NumExtraBytes Meaning
Upper left X-position in window coordinates of the parent window. Upper left Y-position in window coordinates of the parent window. X-size of window. If 0, X-size of client area of parent window. Y-size of window. If 0, Y-size of client area of parent window. Handle of parent window. Window create flags (see
WM_CreateWindow() ).
Pointer to callback routine, or NULL if no callback used. Number of extra bytes to be allocated, normally 0.
Return value
Handle for the child window.
Add. information
If the hWinParent parameter is set to 0, the background window is used as parent. A child window is placed on top of its parent and any previous siblings by default, so that if their Z-positions are not changed, the "youngest" window will always be topmost. The Z-positions of siblings may be changed, although they will always remain on top of their parent regardless of their order.
WM_Deactivate()
Description
Deactivates the window manager.
Prototype
void WM_Deactivate(void);
Add. information
After calling this function, the clip area is set to the complete LCD area and the WM will not execute window callback functions.
2002-2007 Micrium
313
WM_DefaultProc()
Description
Default message handler.
Prototype
void WM_DefaultProc(WM_MESSAGE* pMsg) Parameter pMsg
Pointer to message.
Meaning
Add. information
Use this function to handle unprocessed messages as in the following example:
static WM_RESULT cbBackgroundWin(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_Clear(); default: WM_DefaultProc(pMsg); } }
WM_DeleteWindow()
Description
Deletes a specified window.
Prototype
void WM_DeleteWindow(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
Before the window is deleted, it receives a WM_DELETE message. This message is typically used to delete any objects (widgets) it uses and to free memory dynamically allocated by the window. If the specified window has any existing child windows, these are automatically deleted before the window itself is deleted. Child windows therefore do not need to be separately deleted. Before the window will be deleted it sends a WM_NOTIFICATION_CHILD_DELETED message to its parent window.
WM_DetachWindow()
Description
Detaches a window from its parent window. Detached windows will not be redrawn by the window manager.
2002-2007 Micrium
314
CHAPTER 14
Prototype
void WM_DetachWindow(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
WM_DisableWindow()
Description
Set the specified window to a disabled state. The WM does not pass pointer input device (PID) messages (touch, mouse, joystick, ...) to a disabled window.
Prototype
void WM_DisableWindow(WM_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Add. information
A widget that is disabled will typically appear gray, and will not accept input from the user. However, the actual appearance may vary (depends on widget/configuration settings, etc.). A disabled window will not receive the following messages: WM_TOUCH, WM_TOUCH_CHILD, WM_PID_STATE_CHANGED and WM_MOUSEOVER.
WM_EnableWindow()
Description
Sets the specified window to enabled state. An enabled window receives pointer input device (PID) messages (touch, mouse, joystick, ...) from the WM.
Prototype
void WM_EnableWindow(WM_Handle hObj); Parameter hObj
Handle of window.
Meaning
Add. information
This is the default setting for any widget.
WM_Exec()
Description
Redraws invalid windows by executing callback functions (all jobs).
Prototype
int WM_Exec(void);
Return value
0 if there were no jobs performed.
2002-2007 Micrium
315
Add. information
This function will automatically call WM_Exec1() repeatedly until it has completed all jobs -- essentially until a 0 value is returned. It is recommended to call the function GUI_Exec() instead. Normally this function does not need to be called by the user application. It is called automatically by GUI_Delay(). If you are using a multitasking system, we recommend executing this function by a separate task as seen below:
void ExecIdleTask(void) { while(1) { WM_Exec(); } }
WM_Exec1()
Description
Redraws an invalid window by executing one callback function (one job only).
Prototype
int WM_Exec1(void);
Return value
0 if there were no jobs performed. 1 if a job was performed.
Add. information
This routine may be called repeatedly until 0 is returned, which means all jobs have been completed. It is recommended to call the function GUI_Exec1() instead. This function is called automatically by WM_Exec().
WM_ForEachDesc()
Description
Iterates over all descendants of the given window. A descendant of a window is a child window or a grand child window or a child of a grand child or ....
Prototype
void WM_ForEachDesc(WM_HWIN hWin, WM_tfForEach * pcb, void * pData); Parameter hWin pcb pData
Window handle. Pointer to callback function to be called by
Meaning WM_ForEachDesc .
Add. Information
This function calls the callback function given by the pointer pcb for each descendant of the given window. The parameter pData will be passed to the user function and can be used to point to user defined data.
316
CHAPTER 14
Sample
The following sample shows how the function can be used. It creates 3 windows, the first as a child window of the desktop, the second as a child window of the first window and the third as a child window of the second window. After creating the window it uses WM_ForEachDesc() to move each window within its parent window:
#include "GUI.h" #include "WM.h" /********************************************************************* * * _cbWin */ static void _cbWin(WM_MESSAGE * pMsg) { GUI_COLOR Color; switch (pMsg->MsgId) { case WM_PAINT: WM_GetUserData(pMsg->hWin, &Color, 4); GUI_SetBkColor(Color); GUI_Clear(); break; default: WM_DefaultProc(pMsg); } } /********************************************************************* * * _cbDoSomething */ static void _cbDoSomething(WM_HWIN hWin, void * p) { int Value = *(int *)p; WM_MoveWindow(hWin, Value, Value); } /********************************************************************* * * MainTask */ void MainTask(void) { WM_HWIN hWin_1, hWin_2, hWin_3; int Value = 10; GUI_COLOR aColor[] = {GUI_RED, GUI_GREEN, GUI_BLUE}; GUI_Init(); WM_SetDesktopColor(GUI_BLACK); hWin_1 = WM_CreateWindow( 10, 10, 100, 100, WM_CF_SHOW, _cbWin, 4); hWin_2 = WM_CreateWindowAsChild(10, 10, 80, 80, hWin_1, WM_CF_SHOW, _cbWin, 4); hWin_3 = WM_CreateWindowAsChild(10, 10, 60, 60, hWin_2, WM_CF_SHOW, _cbWin, 4); WM_SetUserData(hWin_1, &aColor[0], 4); WM_SetUserData(hWin_2, &aColor[1], 4); WM_SetUserData(hWin_3, &aColor[2], 4); while(1) { WM_ForEachDesc(WM_HBKWIN, _cbDoSomething, (void *)&Value); Value *= -1; GUI_Delay(500); } }
WM_GetCallback()
Description
Returns a pointer to the callback function of the given window
2002-2007 Micrium
317
Prototype
WM_CALLBACK * WM_GetCallback(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
Pointer of type WM_CALLBACK * which points to the callback function of the given window. If the window has no callback function, NULL is returned.
WM_GetActiveWindow()
Description
Returns the handle of the active window used for drawing operations.
Prototype
WM_HWIN WM_GetActiveWindow(void);
Return value
The handle of the active window.
WM_GetClientRect()
Description
Returns the coordinates of the client area in the active window in window coordinates. That means x0 and y0 of the GUI_RECT structure will be 0, x1 and y1 corresponds to the size - 1.
Prototype
void WM_GetClientRect(GUI_RECT* pRect); Parameter pRect
Pointer to a GUI_RECT structure.
Meaning
WM_GetClientRectEx()
Description
Returns the coordinates of the client area of a window in window coordinates. That means x0 and y0 of the GUI_RECT structure will be 0, x1 and y1 corresponds to the size - 1.
Prototype
void WM_GetClientRectEx(WM_HWIN hWin, GUI_RECT* pRect); Parameter hWin pRect
Window handle. Pointer to a GUI_RECT structure.
Meaning
2002-2007 Micrium
318
CHAPTER 14
WM_GetDesktopWindow()
Description
Returns the handle of the desktop window.
Prototype
WM_HWIN WM_GetDesktopWindow(void);
Return value
The handle of the desktop window.
Add. information
The desktop window is always the bottommost window and any further created windows are its descendants.
WM_GetDesktopWindowEx()
Description
Returns the handle of the specified desktop window when working in a multi layer environment.
Prototype
WM_HWIN WM_GetDesktopWindowEx(unsigned int LayerIndex); Parameter LayerIndex
Index of layer
Meaning
Return value
The handle of the specified desktop window.
WM_GetDialogItem()
Description
Returns the window handle of a dialog box item (widget).
Prototype
WM_HWIN WM_GetDialogItem(WM_HWIN hDialog, int Id); Parameter hDialog Id
Handle of dialog box. Window Id of the widget.
Meaning
Return value
The window handle of the widget.
Add. information
This function is always used when creating dialog boxes, since the window Id of a widget used in a dialog must be converted to its handle before it can be used.
2002-2007 Micrium
319
WM_GetFirstChild()
Description
Returns the handle of a specified windows first child window.
Prototype
void WM_GetFirstChild(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
Handle of the windows first child window; 0 if no child window exists.
Add. information
A windows first child window is the first child created to that particular parent. If the Z-positions of the windows have not been changed, it will be the window directly on top of the specified parent.
WM_GetFocussedWindow()
Description
Returns the handle of the window with the input focus.
Prototype
WM_HWIN WM_GetFocussedWindow(void);
Return value
Handle of the window with the input focus or 0 if no window has the input focus.
WM_GetHasTrans()
Description
Returns the current value of the has transparency flag.
Prototype
U8 WM_GetHasTrans(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
0: no transparency 1: window has transparency
Add. information
When set, this flag tells the window manager that a window contains sections which are not redrawn and will therefore be transparent. The WM then knows that the background needs to be redrawn prior to redrawing the window in order to make sure the transparent sections are restored correctly.
2002-2007 Micrium
320
CHAPTER 14
WM_GetInvalidRect()
Description
Returns the invalid rectangle of a window in desktop coordinates.
Prototype
int WM_GetInvalidRect(WM_HWIN hWin, GUI_RECT * pRect); Parameter hWin pRect
Window handle. Pointer to a GUI_RECT-structure for storing the invalid rectangle.
Meaning
Return value
0 if nothing is invalid, otherwise 1.
WM_GetNextSibling()
Description
Returns the handle of a specified windows next sibling.
Prototype
void WM_GetNextSibling(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
Handle of the windows next sibling; 0 if none exists.
Add. information
A windows next sibling is the next child window that was created relative to the same parent. If the Z-positions of the windows have not been changed, it will be the window directly on top of the one specified.
WM_GetOrgX(), WM_GetOrgY()
Description
Returns the X- or Y-position (respectively) of the origin of the active window in desktop coordinates.
Prototypes
int WM_GetOrgX(void); int WM_GetOrgY(void);
Return value
X- or Y-position of the origin of the active window in desktop coordinates.
WM_GetParent()
Description
Returns the handle of a specified windows parent window.
2002-2007 Micrium
321
Prototype
void WM_GetParent(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
Handle of the windows parent window; 0 if none exists.
Add. information
The only case in which no parent window exists is if the handle of the desktop window is used as parameter.
WM_GetPrevSibling()
Description
Returns the handle of a specified windows previous sibling.
Prototype
void WM_GetPrevSibling(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
Handle of the windows previous sibling; 0 if none exists.
Add. information
A windows previous sibling is the previous child window that was created relative to the same parent. If the Z-positions of the windows have not been changed, it will be the window directly below of the one specified.
WM_GetStayOnTop()
Description
Returns the current value of the stay on top flag.
Prototype
int WM_GetStayOnTop(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
0: stay on top flag not set 1: stay on top flag set
WM_GetUserData()
Description
Retrieves the data set with WM_SetUserData.
User's & reference manual for C/GUI 2002-2007 Micrium
322
CHAPTER 14
Prototype
int WM_GetUserData(WM_HWIN hWin, void* pDest, int SizeoOfBuffer); Parameter hWin pDest SizeOfBuffer
Window handle. Pointer to buffer. SIze of buffer.
Meaning
Return value
Number of bytes retrieved.
Add. information
The maximum number of bytes returned by this function is the number of ExtraBytes specified when creating the window.
WM_GetWindowOrgX(), WM_GetWindowOrgY()
Description
Returns the X- or Y-position (respectively) of the origin of the specified window in desktop coordinates.
Prototypes
int WM_GetWindowOrgX(WM_HWIN hWin); int WM_GetWindowOrgY(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
X- or Y-position of the client area in pixels.
WM_GetWindowRect()
Description
Returns the coordinates of the active window in desktop coordinates.
Prototype
void WM_GetWindowRect(GUI_RECT* pRect); Parameter pRect
Pointer to a GUI_RECT structure.
Meaning
WM_GetWindowRectEx()
Description
Returns the coordinates of a window in desktop coordinates.
2002-2007 Micrium
323
Prototype
void WM_GetWindowRectEx(WM_HWIN hWin, GUI_RECT* pRect); Parameter hWin pRect
Window handle. Pointer to a GUI_RECT structure.
Meaning
Add. Information
If the given window handle is 0 or the given pointer to the GUI_RECT structure is NULL the function returns immediately.
WM_GetWindowSizeX(), WM_GetWindowSizeY()
Description
Return the X- or Y-size (respectively) of a specified window.
Prototypes
int WM_GetWindowSizeX(WM_HWIN hWin); int WM_GetWindowSizeY(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
X- or Y-size of the window in pixels. Defined as x1-x0+1 in horizontal direction, y1-y0+1 in vertical direction, where x0, x1, y0, y1 are the leftmost/rightmost/topmost/bottommost positions of the window. If the given window handle is 0 the function returns the size of the desktop window.
WM_HasCaptured()
Description
Returns 1 if the given window has captured mouse- and touchscreen-input, 0 if not.
Prototype
int WM_HasCaptured(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
1 if the given window has captured mouse- and touchscreen-input, 0 if not.
Add. Information
If the given window handle is invalid or 0 the function returns a wrong result.
WM_HasFocus()
Description
Checks if the given window has the input focus.
2002-2007 Micrium
324
CHAPTER 14
Prototype
int WM_HasFocus(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
1 if the given window has the input focus, otherwise 0.
Add. Information
If the given window handle is invalid or 0 the function returns a wrong result.
WM_HideWindow()
Description
Makes a specified window invisible.
Prototype
void WM_HideWindow(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The window will not immediately appear "invisible" after calling this function. The invalid areas of other windows (areas which appear to lie "behind" the window which should be hidden) will be redrawn when executing WM_Exec(). If you need to hide (draw over) a window immediately, you should call WM_Paint() to redraw the other windows.
WM_InvalidateArea()
Description
Invalidates a specified, rectangular area of the display.
Prototype
void WM_InvalidateArea(GUI_RECT* pRect); Parameter pRect Meaning
Pointer to a GUI_RECT structure with desktop coordinates.
Add. information
Calling this function will tell the WM that the specified area is not updated. This function can be used to invalidate any windows or parts of windows that overlap or intersect the area. The coordinates of the GUI_RECT structure have to be in desktop coordinates.
2002-2007 Micrium
325
WM_InvalidateRect()
Description
Invalidates a specfied, rectangular area of a window.
Prototype
void WM_InvalidateRect(WM_HWIN hWin, GUI_RECT* pRect); Parameter hWin pRect
Window handle. Pointer to a GUI_RECT structure with window coordinates of the parent window.
Meaning
Add. information
Calling this function will tell the WM that the specified area is not updated. The next time WM_Paint() is called to redraw the window, the area will be redrawn as well. The coordinates of the GUI_RECT structure have to be in window coordinates.
WM_InvalidateWindow()
Description
Invalidates a specified window.
Prototype
void WM_InvalidateWindow(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
Calling this function tells the WM that the specified window is not updated.
WM_IsCompletelyCovered()
Description
Checks if the given window is completely covered or not.
Prototype
char WM_IsCompletelyCovered(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
1 if the given window is completely covered, otherwise 0.
Add. Information
If the given window handle is invalid or 0 the function returns a wrong result.
2002-2007 Micrium
326
CHAPTER 14
WM_IsCompletelyVisible()
Description
Checks if the given window is completely visible or not.
Prototype
char WM_IsCompletelyVisible(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
1 if the given window is completely visible, otherwise 0.
Add. Information
If the given window handle is invalid or 0 the function returns a wrong result.
WM_IsEnabled()
Description
This function returns if a window is enabled or not.
Prototype
int WM_IsEnabled(WM_HWIN hObj); Parameter hObj
Handle of window.
Meaning
Return value
1 if the window is enabled, 0 if not.
Add. information
A widget that is disabled will typically appear gray, and will not accept input from the user. However, the actual appearance may vary (depends on widget/configuration settings, etc.)
WM_IsVisible()
Description
Determines whether or not a specified window is visible.
Prototype
int WM_IsVisible(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
0: Window is not visible 1: Window is visible
2002-2007 Micrium
327
WM_IsWindow()
Description
Determines whether or not a specified handle is a valid window handle.
Prototype
void WM_IsWindow(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
0: handle is not a valid window handle 1: handle is a valid window handle
Add. Information
This function should be used only if absolutely necessary. The more windows exist the more time will be used to evaluate, if the given handle is a window.
WM_MakeModal()
Description
This function makes the window work in modal mode. This means pointer device input will only be send to the modal window or a child window of it if the input position is within the rectangle of the modal window.
Prototype
void WM_MakeModal(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
WM_MoveChildTo()
Description
Moves a specified window to a certain position.
Prototype
void WM_MoveChildTo(WM_HWIN hWin, int x, int y); Parameter hWin x y
Window handle. New X-position in window coordinates of the parent window. New Y-position in window coordinates of the parent window.
Meaning
WM_MoveTo()
Description
Moves a specified window to a certain position.
2002-2007 Micrium
328
CHAPTER 14
Prototype
void WM_MoveTo(WM_HWIN hWin, int x, int y); Parameter hWin x y
Window handle. New X-position in desktop coordinates. New Y-position in desktop coordinates.
Meaning
WM_MoveWindow()
Description
Moves a specified window by a certain distance.
Prototype
void WM_MoveWindow(WM_HWIN hWin, int dx, int dy); Parameter hWin dx dy
Window handle. Horizontal distance to move. Vertical distance to move.
Meaning
WM_NotifyParent()
Description
Sends a WM_NOTIFY_PARENT message to the given window.
Prototype
void WM_NotifyParent(WM_HWIN hWin, int Notification); Parameter hWin Notification
Window handle. Value to send to the parent window.
Meaning
Add. information
The Notification-parameter will be send in the Data.v element of the message.
WM_Paint()
Description
Draws or redraws a specified window immediately.
Prototype
void WM_Paint(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The window is redrawn reflecting all updates made since the last time it was drawn.
2002-2007 Micrium
329
WM_PaintWindowAndDescs()
Description
Paints the given window and all its descendants.
Prototype
void WM_PaintWindowAndDescs(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The function draws the complete window regions by invalidating them before drawing.
WM_ReleaseCapture()
Description
Releases capturing of mouse- and touchscreen-input.
Prototype
void WM_ReleaseCapture(void);
Add. information
Use WM_SetCapture() to send all mouse- and touchscreen-input to a specific window.
WM_ResizeWindow()
Description
Changes the size of a specified window by adding (or subtracting) the given differences.
Prototype
void WM_ResizeWindow(WM_HWIN hWin, int XSize, int YSize); Parameter hWin dx dy
Window handle. Difference in X. Difference in Y.
Meaning
WM_SelectWindow()
Description
Sets the active window to be used for drawing operations.
Prototype
WM_HWIN WM_SelectWindow(WM_HWIN Parameter hWin
Window handle.
hWin); Meaning
2002-2007 Micrium
330
CHAPTER 14
Return value
The selected window.
Add. Information
This function should not be called within a paint function called by the window manager. If the wnidow manager sends a WM_PAINT message the target window already has been selected. When working with a multi layer configuration the function switches also to the layer of the top level parent window of the given window. If the given window handle is 0 the function selects the first created window, normally the first desktop window.
Example
Sets a window with handle hWin2 to the active window, sets the background color, and then clears the window:
WM_SelectWindow(hWin2); GUI_SetBkColor(0xFF00); GUI_Clear();
WM_SendMessage()
Description
Sends a message to a specified window.
Prototype
void WM_SendMessage(WM_HWIN hWin, WM_MESSAGE* pMsg) Parameter hWin pMsg
Window handle. Pointer to message.
Meaning
WM_SendMessageNoPara()
Description
Sends a message without parameters to a specified window.
Prototype
void WM_SendMessageNoPara(WM_HWIN hWin, int MsgId) Parameter hWin MsgId
Window handle. Id of message to be send.
Meaning
Add. Information
If only a message Id should be send to a window this should be done with this function, because it does not need a pointer to a WM_MESSAGE structure. Please note that the receiving window gets no further information except the message Id.
WM_SendToParent()
Description
Sends the given message to the parent window of the given window.
2002-2007 Micrium
331
Prototype
void WM_SendToParent(WM_HWIN hWin, WM_MESSAGE* pMsg); Parameter hWin pMsg
Window handle. Pointer to WM_MESSAGE-structure.
Meaning
WM_SetDesktopColor()
Description
Sets the color for the desktop window.
Prototype
GUI_COLOR WM_SetDesktopColor(GUI_COLOR Color); Parameter Color Meaning
Color for desktop window, 24-bit RGB value.
Return value
The previously selected desktop window color.
Add. information
The default setting for the desktop window is not to repaint itself. If this function is not called, the desktop window will not be redrawn at all; therefore other windows will remain visible even after they are deleted. Once a color is specified with this function, the desktop window will repaint itself. In order to restore the default, call this function and specify GUI_INVALID_COLOR.
WM_SetDesktopColorEx()
Description
Sets the color for the desktop window in a multi layer environment.
Prototype
GUI_COLOR WM_SetDesktopColorEx(GUI_COLOR Color, unsigned int LayerIndex); Parameter Color LayerIndex
Index of the layer.
Meaning
Color for desktop window, 24-bit RGB value.
Return value
The previously selected desktop window color.
Add. information
(see WM_SetDesktopColor).
WM_SetCallback()
Description
Sets a callback routine to be executed by the window manager.
2002-2007 Micrium
332
CHAPTER 14
Prototype
WM_CALLBACK* WM_SetCallback (WM_HWIN hWin, WM_CALLBACK* cb) Parameter hWin cb
Window handle. Pointer to callback routine.
Meaning
Return value
Pointer to the previous callback routine.
Add. Information
The given window will be invalidated. This makes sure the window will be redrawn.
WM_SetCapture()
Description
Routes all mouse- and touchscreen-messages to the given window.
Prototype
void WM_SetCapture(WM_HWIN hObj, int AutoRelease); Parameter hWin AutoRelease
Window handle. 1 if capturing should end iwhen the user releases the touch.
Meaning
WM_SetCreateFlags()
Description
Sets the flags to be used as default when creating a new window.
Prototype
U8 WM_SetCreateFlags (U8 Flags) Parameter Flags
Window create flags (see
Meaning WM_CreateWindow() ).
Return value
Former value of this parameter.
Add. information
The flags specified here are binary ORed with the flags specified in the WM_CreateWindow() and WM_CreateWindowAsChild() routines. The flag WM_CF_MEMDEV is frequently used to enable memory devices on all windows.
Example
WM_SetCreateFlags(WM_CF_MEMDEV); /* Auto. use memory devices on all windows */
WM_SetFocus
Description
Sets the input focus to a specified window.
User's & reference manual for C/GUI 2002-2007 Micrium
333
Prototype
void WM_SetFocus(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
0 if window accepted focus; value other than 0 if it could not.
Add. information
The window receives a WM_SETFOCUS message which gives it the input focus. If for some reason the window could not accept the focus, nothing happens.
WM_SetHasTrans()
Description
Sets the has transparency flag (sets it to 1).
Prototype
void WM_SetHasTrans(WM_HWIN hWin); Parameter HWin
Window handle.
Meaning
Add. information
When set, this flag tells the window manager that a window contains sections which are not redrawn and will therefore be transparent. The WM then knows that the background needs to be redrawn prior to redrawing the window in order to make sure the transparent sections are restored correctly.
WM_SetId()
Description
This function sends a WM_SET_ID message to the given window.
Prototype
void WM_SetId(WM_HWIN hObj, int Id); Parameter hObj Id
Window handle. Id to be send to the window.
Meaning
Add. information
This function can be used to change the Id of a widget. It works with any wmWin widget. When using this function with a application defined window, the callback function of the window should handle the message. Otherwise it will be ignored.
2002-2007 Micrium
334
CHAPTER 14
WM_SetpfPollPID()
Description
Sets a function which will be called by the window manager in order to poll the pointer input device (touch-screen or mouse).
Prototype
WM_tfPollPID* WM_SetpfPollPID(WM_tfPollPID* pf); Parameter pf
Pointer to a function of type
Meaning WM_tfPollPID.
Add. information
The function type is defined as follows:
typedef void WM_tfPollPID(void);
Example
Example of a touch-screen handled as a device:
void ReadTouch(void) { // ...read touchscreen } WM_SetpfPollPID(ReadTouch);
WM_SetSize()
Description
Sets the new size of a window.
Prototype
void WM_SetSize(WM_HWIN hWin, int XSize, int YSize); Parameter hWin XSize YSize
Window handle. New size in X. New size in Y.
Meaning
WM_SetWindowPos()
Description
Sets the size and the position of a window.
Prototype
void WM_SetWindowPos(WM_HWIN hWin, int xPos, int yPos, int xSize, int ySize); Parameter hWin xPos yPos xSize ySize
Window handle. New position in X in desktop coordinates. New position in Y in desktop coordinates. New size in X. New size in Y.
Meaning
2002-2007 Micrium
335
WM_SetXSize()
Description
Sets the new X-size of a window.
Prototype
void WM_SetXSize(WM_HWIN hWin, int XSize); Parameter hWin XSize
Window handle. New size in X.
Meaning
WM_SetYSize()
Description
Sets the new Y-size of a window.
Prototype
void WM_SetYSize(WM_HWIN hWin, int YSize); Parameter hWin YSize
Window handle. New size in Y.
Meaning
WM_SetStayOnTop()
Description
Sets the stay on top flag.
Prototype
void WM_SetStayOnTop(WM_HWIN hWin, int OnOff); Parameter hWin OnOff
Window handle. (see table below)
Meaning
Permitted values for parameter OnOff 0 1 Stay on top flag would be cleared. Stay on top flag would be set.
WM_SetTransState()
Description
This function sets or clears the flags WM_CF_HASTRANS and WM_CF_CONST_OUTLINE of the given window.
2002-2007 Micrium
336
CHAPTER 14
Prototype
void WM_SetTransState(WM_HWIN hWin, unsigned State); Parameter hWin State
Window handle. Combination of the flags
Add. information
For details about the flag WM_CF_CONST_OUTLINE please refer to the function WM_CreateWindow().
WM_SetUserClipRect()
Description
Temporarily reduces the clip area of the current window to a specified rectangle.
Prototype
const GUI_RECT* WM_SetUserClipRect(const GUI_RECT* pRect); Parameter pRect Meaning
Pointer to a GUI_RECT structure defining the clipping region in desktop coordinates.
Return value
Pointer to the previous clip rectangle.
Add. information
A NULL pointer can be passed in order to restore the default settings. The clip rectangle will automatically be reset by the WM when callbacks are used. The specified rectangle must be relative to the current window. You cannot enlarge the clip rectangle beyond the current window rectangle. Your application must ensure that the specified rectangle retains its value until it is no longer needed; i.e. until a different clip rectangle is specified or until a NULL pointer is passed. This means that the rectangle structure passed as parameter should not be an auto variable (usually located on the stack) if the clip rectangle remains active until after the return. In this case, a static variable should be used.
Example
This example is taken from the drawing routine of a progress indicator. The progress indicator must write text on top of the progress bar, where the text color has to be different on the left and right parts of the bar. This means that half of a digit could be in one color, while the other half could be in a different color. The best way to do this is to temporarily reduce the clip area when drawing each part of the bar as shown below:
2002-2007 Micrium
337 /* Draw left part of the bar */ r.x0=0; r.x1=x1-1; r.y0=0; r.y1 = GUI_YMAX; WM_SetUserClipRect(&r); GUI_SetBkColor(pThis->ColorBar[0]); GUI_SetColor(pThis->ColorText[0]); GUI_Clear(); GUI_GotoXY(xText,yText); GUI_DispDecMin(pThis->v); GUI_DispChar('%'); /* Draw right part of the bar */ r.x0=r.x1; r.x1=GUI_XMAX; WM_SetUserClipRect(&r); GUI_SetBkColor(pThis->ColorBar[1]); GUI_SetColor(pThis->ColorText[1]); GUI_Clear(); GUI_GotoXY(xText,yText); GUI_DispDecMin(pThis->v); GUI_DispChar('%');
WM_SetUserData()
Description
Sets the extra data of a window. Memory for extra data is reserved with the parameter ExtraBytes when creating a window.
Prototype
int WM_SetUserData(WM_HWIN hWin, void* pDest, int SizeoOfBuffer); Parameter hWin pDest SizeOfBuffer
Window handle. Pointer to buffer. SIze of buffer.
Meaning
Return value
Number of bytes reserved when creating the window.
Add. information
The maximum number of bytes used to store user data is the number of ExtraBytes specified when creating a window.
WM_ShowWindow()
Description
Makes a specified window visible.
Prototype
void WM_ShowWindow(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The window will not immediately be visible after calling this function. It will be redrawn when executing WM_Exec(). If you need to show (draw) the window immediately, you should calll WM_Paint().
2002-2007 Micrium
338
CHAPTER 14
WM_Update()
Description
Draws the invalid part of the specified window immediately.
Prototype
void WM_Update(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
After updating a window its complete region is marked as valid.
WM_UpdateWindowAndDescs()
Description
Paints the invalid part of the given window and the invalid part of all its descendants.
Prototype
void WM_UpdateWindowAndDescs(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Add. information
The function only draws the invalid window regions.
WM_ValidateRect()
Description
Validates a specfied, rectangular area of a window.
Prototype
void WM_ValidateRect Parameter hWin pRect
Window handle. Pointer to a GUI_RECT structure with window coordinates of the parent window.
Add. information
Calling this function will tell the WM that the specified area is updated. Normally this function is called internally and does not need to be called by the user application. The coordinates of the GUI_RECT structure have to be in desktop coordinates.
WM_ValidateWindow()
Description
Validates a specified window.
2002-2007 Micrium
339
Prototype
void WM_ValidateWindow Parameter hWin
Window handle.
Add. information
Calling this function will tell the WM that the specified window is updated. Normally this function is called internally and does not need to be called by the user application.
WM_DisableMemdev()
Description
Disables the use of memory devices for redrawing a window.
Prototype
void WM_EnableMemdev (WM_HWIN hWin) Parameter hWin
Window handle.
Meaning
WM_EnableMemdev()
Description
Enables the use of memory devices for redrawing a window.
Prototype
void WM_EnableMemdev (WM_HWIN hWin) Parameter hWin
Window handle.
Meaning
2002-2007 Micrium
340
CHAPTER 14
Prototype
WM_HTIMER WM_CreateTimer(WM_HWIN hWin, int Id, int Period, int Mode); Parameter hWin Id Period Mode
Handle of window to be informed. (reserved for future use, should be 0) Time period after which the given window should receive a message. (reserved for future use, should be 0)
Meaning
Return value
Handle of the timer.
Add. information
The function creates a one shot timer which sends a WM_TIMER message to the given window. After the timer period has expired the timer object remains valid and can be restarted using the function WM_RestartTimer() or deleted with WM_DeleteTimer().
Example
static void _cbWin(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_TIMER: /* ... do something ... */ WM_RestartTimer(pMsg->Data.v, 1000); break; } } static void _DemoTimer(void) { WM_HWIN hWin; WM_HTIMER hTimer; hWin = WM_CreateWindow(10, 10, 100, 100, WM_CF_SHOW, _cbWin, 0); hTimer = WM_CreateTimer(hWin, 0, 1000, 0); while (1) { GUI_Exec(); } }
WM_DeleteTimer()
Description
Deletes the given timer.
Prototype
void WM_DeleteTimer(WM_HTIMER hTimer); Parameter hTimer
Handle of the timer to be deleted.
Meaning
2002-2007 Micrium
341
Add. information
After a timer has expired the timer object remains valid and will not be deleted automatically. If it is not used anymore it should be deleted using this function.
WM_RestartTimer()
Description
Restarts the given timer with the given period.
Prototype
void WM_RestartTimer(WM_HTIMER hTimer, int Period); Parameter hTimer Period
Handle of the timer to be restarted. New period to be used.
Meaning
Add. information
After the period has expired a WM_TIMER message will be send to the window assigned to the timer. For details please refer to the function WM_CreateTimer().
2002-2007 Micrium
342
CHAPTER 14
Prototype
WM_HWIN WM_GetClientWindow(WM_HWIN hObj); Parameter hWin
Handle of widget.
Meaning
Return value
Handle of the client window.
Add. information
Use this function to retrieve the client window handle of a FRAMEWIN widget.
WM_GetId()
Description
Returns the ID of a specified widget window.
Prototype
int WM_GetId(WM_HWIN hObj); Parameter hObj
Handle of widget.
Meaning
Return value
The ID of the widget specified at creation. 0 will be returned if the specified window is not a widget.
WM_GetInsideRect()
Description
Returns the coordinates of the client area of the active widget less the border size. The function sends a message to the active window to retrieve the inside rectangle. If the widget does not handle the message (that means the widget has no border) WM_GetClientRect will be used to calculate the rectangle. The result is given in window coordinates. That means x0 and y0 of the GUI_RECT structure corresponds to the border size in x and y, x1 and y1 corresponds to the size of the window less the border size - 1.
2002-2007 Micrium
343
Prototype
void WM_GetInsideRect(GUI_RECT* pRect); Parameter pRect
Pointer to a GUI_RECT structure.
Meaning
WM_GetInsideRectEx()
Description
Returns the coordinates of a window less the border size. For details please take a look at WM_GetInsideRect described above.
Prototype
void WM_GetInsideRectEx(WM_HWIN hObj, GUI_RECT* pRect); Parameter hObj pRect
Handle of widget. Pointer to a GUI_RECT structure.
Meaning
WM_GetScrollPosH()
Description
If a horizontal scroll bar is attached to the window, the function returns the scroll position of it.
Prototype
int WM_GetScrollPosH(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
Return value
Scroll position of the horizontal scroll bar attached to this window.
Add. information
If no horizontal scroll bar is attached to the window, the function returns 0. For more information, please refer to the scroll bar widget section.
WM_GetScrollPosV()
Description
If a vertical scroll bar is attached to the window, the function returns the scroll position of it.
Prototype
int WM_GetScrollPosV(WM_HWIN hWin); Parameter hWin
Window handle.
Meaning
2002-2007 Micrium
344
CHAPTER 14
Return value
Scroll position of the vertical scroll bar attached to this window.
Add. information
If no vertical scroll bar is attached to the window, the function returns 0. For more information, please refer to the scroll bar widget section.
WM_GetScrollState()
Description
Fills a data structure with information on the current state of a specified scroll bar widget window.
Prototype
void WM_GetScrollState(WM_HWIN hObj, WM_SCROLL_STATE* pScrollState); Parameter Meaning
Handle of scroll bar widget. hObj pScrollState Pointer to a data structure of type WM_SCROLL_STATE.
Add. information
This function does not return since the state of a scroll bar is defined by more than one value. It has no effect on other types of widgets or windows. For more information, please refer to the scroll bar widget section.
Elements of WM_SCROLL_STATE
Data type Element int int int Meaning
NumItems Number of items. Current value. v PageSize Number of items visible on one page.
WM_SetScrollPosH()
Description
If a horizontal scroll bar is attached to the window, the function sets the scroll position of it.
Prototype
void WM_SetScrollPosH(WM_HWIN hWin, unsigned ScrollPos); Parameter hWin ScrollPos
Window handle. New scroll position of the scroll bar.
Meaning
Add. information
If no horizontal scroll bar is attached to the window, the function returns. For more information, please refer to the scroll bar widget section.
2002-2007 Micrium
345
WM_SetScrollPosV()
Description
If a vertical scroll bar is attached to the window, the function sets the scroll position of it.
Prototype
void WM_SetScrollPosV(WM_HWIN hWin, unsigned ScrollPos); Parameter hWin ScrollPos
Window handle. New scroll position of the scroll bar.
Meaning
Add. information
If no vertical scroll bar is attached to the window, the function returns. For more information, please refer to the scroll bar widget section.
WM_SetScrollState()
Description
Sets the state of a specified scroll bar widget.
Prototype
void WM_SetScrollState(WM_HWIN hObj, const WM_SCROLL_STATE* pState); Parameter hObj
Handle of scroll bar widget.
Meaning
2002-2007 Micrium
346
CHAPTER 14
14.10 Example
The following example illustrates the difference between using a callback routine for redrawing the background and not having one. It also shows how to set your own callback function. The example is available as WM_Redraw.c in the samples shipped with C/GUI:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : WM_Redraw.c Purpose : Demonstrates the redrawing mechanism of the window manager ---------------------------------------------------------------------*/ #include "GUI.H" /******************************************************************* * * Callback routine for background window * ******************************************************************** */ static void cbBackgroundWin(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_Clear(); default: WM_DefaultProc(pMsg); } } /******************************************************************* * * Callback routine for foreground window * ******************************************************************** */ static void cbForegroundWin(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(GUI_GREEN); GUI_Clear(); GUI_DispString("Foreground window"); break; default: WM_DefaultProc(pMsg); } } /******************************************************************* * * Demonstrates the redraw mechanism of C/GUI * ******************************************************************** */ static void DemoRedraw(void) { GUI_HWIN hWnd; while(1) { /* Create foreground window */ hWnd = WM_CreateWindow(10, 10, 100, 100, WM_CF_SHOW, cbForegroundWin, 0); /* Show foreground window */ User's & reference manual for C/GUI 2002-2007 Micrium
347 GUI_Delay(1000); /* Delete foreground window */ WM_DeleteWindow(hWnd); GUI_DispStringAt("Background of window has not been redrawn", 10, 10); /* Wait a while, background will not be redrawn */ GUI_Delay(1000); GUI_Clear(); /* Set callback for Background window */ WM_SetCallback(WM_HBKWIN, cbBackgroundWin); /* Create foreground window */ hWnd = WM_CreateWindow(10, 10, 100, 100,WM_CF_SHOW, cbForegroundWin, 0); /* Show foreground window */ GUI_Delay(1000); /* Delete foreground window */ WM_DeleteWindow(hWnd); /* Wait a while, background will be redrawn */ GUI_Delay(1000); /* Delete callback for Background window */ WM_SetCallback(WM_HBKWIN, 0); }} /******************************************************************* * * main * ******************************************************************** */ void main(void) { GUI_Init(); DemoRedraw(); }
2002-2007 Micrium
348
CHAPTER 14
2002-2007 Micrium
349
Widgets are windows with object-typeproperties; they are called controls in the windows world and make up the elements of the user interface. They can react automatically to certain events; for example, a button can appear in a different state if it is pressed. Widgets need to be created, have properties which may be changed at any time during their existence and are then typically deleted when they are no longer needed. Just like a window, a widget is referenced by a handle which is returned by its create function. Widgets require the window manager. Once a widget is created, it is treated just like any other window; the WM ensures that it is properly displayed (and redrawn) whenever necessary. Widgets are not required when writing an application or a user interface, but they can make programming much easier.
2002-2007 Micrium
350
CHAPTER 15
Screenshot
Explanation
Button which can be pressed. Text or bitmaps may be displayed on a button. Check box which may be checked or unchecked.
CHECKBOX
DROPDOWN
EDIT
Single-line edit field which prompts the user to type a number or text.
FRAMEWIN
GRAPH
HEADER
LISTBOX
LISTVIEW
MENU
MULTIEDIT
2002-2007 Micrium
351
Name
Screenshot
Explanation
MULTIPAGE
PROGBAR
RADIOBUTTON
Radio button which may be selected. Only one button may be selected at a time.
SCROLLBAR
SLIDER
TEXT
The first line reserves memory for the handle of the widget. The last line actually creates the widget. The widget will then automatically be drawn by the window manager if WM_Exec() is called at a later point or in a separate task. Member functions are available for each type of widget which allow modifications to their appearance. Once the widget has been created, its properties can be changed by calling one of its member functions. These functions take the handle of the widget
2002-2007 Micrium
352
CHAPTER 15
as their first argument. In order to make the progress bar created above show 45% and to change the bar colors from their defaults (dark gray/light gray) to green/red, the following section of code may be used:
PROGBAR_SetBarColor(hProgBar, 0, GUI_GREEN); PROGBAR_SetBarColor(hProgBar, 1, GUI_RED); PROGBAR_SetValue(hProgBar, 45);
Default configuration
All widgets also have one or more configuration macros which define various default settings such as fonts and colors used. The available configuration options are listed for each widget in their respective sections later in the chapter.
2002-2007 Micrium
353
Macro
0
Default
Explanation
If set to 1, each child widget of a widget, has the same effect as the parent widget. If for example a listbox needs to create a scrollbar, the new scrollbar has the same effect as the listbox. If set to 1, the default appearance of the widgets is large sized. That means that all widgets which show text are configured to use large sized default fonts. If set to 1, the default appearance of the widgets is medium sized. That means that all widgets which show text are configured to use medium sized default fonts. If set to 1, the default appearance of the widgets is small sized. That means that all widgets which show text are configured to use small sized default fonts.
WIDGET_USE_PARENT_EFFECT
WIDGET_USE_SCHEME_LARGE
WIDGET_USE_SCHEME_MEDIUM
WIDGET_USE_SCHEME_SMALL
WIDGET_USE_SCHEME...
The table below shows the default appearance of the widget schemes: WIDGET_USE_SCHEME_LARGE WIDGET_USE_SCHEME_MEDIUM
2002-2007 Micrium
354
CHAPTER 15
WIDGET_USE_SCHEME_SMALL
Explanation
For a complete list of WM-related functions, please refer to Chapter 14: "The Window Manager".
Explanation
Default callback function. Used for automatic creation in dialog boxes. Returns the default effect used for new widgets. Sets the default effect used for new widgets. Sets the effect used for a given widget.
2002-2007 Micrium
355
<WIDGET>_Callback()
Description
Default callback function of the widgets to be used from within overwritten callback function.
Prototype
void <WIDGET>_Callback(WM_MESSAGE * pMsg); Parameter pMsg Meaning
Pointer to a data structure of type WM_MESSAGE.
Add. information
A default callback function of a widget should not be called directly. It is only to be used from within an overwritten callback function. For details about the WM_MESSAGE data structure please refer to the beginning of the chapter The Window Manager.
<WIDGET>_CreateIndirect()
Description
Creates a widget to be used in dialog boxes.
Prototype
<WIDGET>_Handle <WIDGET>_CreateIndirect(const GUI_WIDGET_CREATE_INFO* pCreateInfo, WM_HWIN hParent, int x0, int y0, WM_CALLBACK* cb); Parameter pCreateInfo hParent x0 y0 cb
Pointer to a Handle of parent window. Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Pointer to a callback function.
Add. information
Any widget may be created indirectly by using the appropriate prefix. For example: BUTTON_CreateIndirect() to indirectly create a button widget, CHECKBOX_CreateIndirect() to indirectly create a check box widget, and so on. A widget only needs to be created indirectly if it is to be included in a dialog box. Otherwise, it may be created directly by using the <WIDGET>_Create() functions. Please see Chapter 16: "Dialogs" for more information about dialog boxes.
Resource table
The GUI_WIDGET_CREATE_INFO data structure is defined in the dialog resource table as follows: typedef struct { GUI_WIDGET_CREATE_FUNC* pfCreateIndirect; // Create function const char* pName; // Text (not used for all widgets) I16 Id; // Window ID of the widget
User's & reference manual for C/GUI 2002-2007 Micrium
356
CHAPTER 15
I16 x0, y0, xSize, ySize; I16 Flags; I32 Para; } GUI_WIDGET_CREATE_INFO;
// Size and position of the widget // Widget-specific flags (or 0) // Widget-specific parameter (or 0)
Widget flags and parameters are optional, and vary depending on the type of widget. The available flags and parameters for each widget (if any) will be listed under the appropriate section later in the chapter.
WIDGET_GetDefaultEffect()
Description
Returns the default effect used for new widgets.
Prototype
const WIDGET_EFFECT * WIDGET_GetDefaultEffect(void);
Return value
The result of the function is a pointer to a WIDGET_EFFECT structure.
Add. information
For more information please refer to the function WIDGET_SetDefaultEffect().
WIDGET_SetDefaultEffect()
Description
Sets the default effect used for new widgets.
Prototype
const WIDGET_EFFECT * WIDGET_SetDefaultEffect(const WIDGET_EFFECT* pEffect); Parameter pEffect Meaning
Pointer to a WIDGET_EFFECT structure. See table below.
Return value
Previous used default effect.
Add. information
The following table shows the appearance of some widgets in dependence of the used effect: 3D None Simple
2002-2007 Micrium
357
3D
None
Simple
WIDGET_SetEffect()
Description
Sets the effect for the given widget.
Prototype
void WIDGET_SetEffect(WM_HWIN hObj, const WIDGET_EFFECT* pEffect); Parameter hObj pEffect
Handle of widget. Pointer to a WIDGET_EFFECT structure. For details please refer to the function
Meaning
WIDGET_SetDefaultEffect()
Prototype
int _OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) Parameter pDrawItemInfo Meaning
Pointer to a WIDGET_ITEM_DRAW_INFO structure.
2002-2007 Micrium
358
CHAPTER 15
Elements of WIDGET_ITEM_DRAW_INFO
Data type WM_HWIN int int int int Element hWin Cmd ItemIndex x0 y0
Handle to the widget. (see table below) Zero based index of item to be drawn. X position in window coordinates to be used to draw the item. Y position in window coordinates to be used to draw the item.
Meaning
Permitted values for element Cmd WIDGET_ITEM_GET_XSIZE the given item. WIDGET_ITEM_GET_YSIZE the given item. WIDGET_ITEM_DRAW
The function returns the x-size (widgth) in pixels of The function returns the y-size (height) in pixels of The function draws the given item at the given position.
Return value
Depends on the given command.
Reaction to commands
The function has to react to the command given in the WIDGET_ITEM_DRAW_INFO structure. This can be done in one of 2 ways: By calling the appropriate default function supplied by the particular widget (e.g. LISTBOX_OwnerDraw()) By supplying code that reacts accordingly.
Commands
The commands listed below are supported and should be reacted to by the function. As explained above, the default owner draw function should be called for all not handled functions. This is can save code size (for example if the height is the same as the default height) and makes sure that your code stays compatible if in a future version of the software and add. command is introduced.
WIDGET_ITEM_GET_XSIZE
The X-size in pixels of the given item has to be returned.
WIDGET_ITEM_GET_YSIZE
The Y-size (height) in pixels of the given item has to be returned.
WIDGET_ITEM_DRAW
The given item has to be drawn. x0 and y0 of the WIDGET_ITEM_DRAW_INFO structure specify the position of the item in window coordinates. The item has to fill its entire rectangle; the rectangle is defined by the starting position x0, y0 supplied to the function and the sizes returned by the function as reaction to the commands WIDGET_ITEM_GET_YSIZE, WIDGET_ITEM_GET_XSIZE. It may NOT leave a part of this rectangular area unpainted. It can not paint outside of this rectangular area because the clip rectangle has been set before the function call.
2002-2007 Micrium
359
All BUTTON-related routines are located in the file(s) BUTTON*.c, BUTTON.h. All identifiers are prefixed BUTTON.
Default
Explanation
Number of pixels that text/bitmap moves in horizontal direction in pressed state. Number of pixels that text/bitmap moves in vertical direction in pressed state.
GUI_TA_HCENTER | Alignment used to display the button text. GUI_TA_VCENTER 0xAAAAAA GUI_WHITE Background color, unpressed state. Background color, pressed state. Default color for rendering the focus rectangle. Font used for button text. See description below. Text color, unpressed state. Text color, pressed state.
BUTTON_REACT_ON_LEVEL
A button per default reacts on each touch message. For example if touching a dialog with a pointer input device (PID) not exactly on the button and then move the PID in pressed state over the button, the button changes from unpressed to pressed state. This behavior can be useful if using a touch panel. If a button should only react on level changes, BUTTON_REACT_ON_LEVEL should be set to 1. Then a button changes the state only if the PID is pressed and released on the button. If then moving a PID in pressed state over the button it does not react. This behavior can be useful if dialogs should react on WM_NOTIFICATION_CLICKED. Example (BUTTON_REACT_ON_LEVEL = 0): One dialog (dialog 2) is shown over an other dialog (dialog 1). The close button of dialog 2 is on the same position as a button of dialog 1. Now the close button of dialog 2 is pressed, which removes dialog 2. The PID now is in pressed state. If now moving the button before releasing it the button of dialog 1 would change from unpressed to pressed state. This unwanted behavior can be avoid by setting BUTTON_REACT_ON_LEVEL to 1.
BUTTON_BKCOLOR0_DEFAULT, BUTTON_BKCOLOR1_DEFAULT
The default for the button is to use a white background in the pressed state. This has been done purposely because it makes it very obvious that the button is pressed, on any kind of display. If you want the background color of the button to be the same in both its pressed and unpressed states, change BUTTON_BKCOLOR1_DEFAULT to BUTTON_BKCOLOR0_DEFAULT.
User's & reference manual for C/GUI 2002-2007 Micrium
360
CHAPTER 15
Sets the default font for new BUTTON widgets. BUTTON_SetDefaultFont() BUTTON_SetDefaultTextAlign() Sets the default text alignment for new BUTTON widgets.
2002-2007 Micrium
361
Routine
Explanation
BUTTON_SetDefaultTextColor() Sets the default text color for new BUTTON widgets. BUTTON_SetFocussable() BUTTON_SetFont() BUTTON_SetPressed() BUTTON_SetStreamedBitmap() BUTTON_SetStreamedBitmapEx() BUTTON_SetText() BUTTON_SetTextAlign() BUTTON_SetTextColor()
Sets the ability to receive the input focus. Select the font for the text. Sets the state of the button to pressed or unpressed. Set the bitmap used when displaying the BUTTON. Set the bitmap used when displaying the BUTTON. Set the text. Sets the alignment of the BUTTON text. Set the color(s) for the text.
BUTTON_Create()
(Obsolete, BUTTON_CreateEx should be used instead)
Description
Creates a BUTTON widget of a specified size at a specified location.
Prototype
BUTTON_Handle BUTTON_Create(int x0, int y0, int xsize, int ysize, int Id, int Flags); Parameter x0 y0 xsize ysize Id Flags Meaning
Leftmost pixel of the button (in parent coordinates). Topmost pixel of the button (in parent coordinates). Horizontal size of the button (in pixels). Vertical size of the button (in pixels). ID to be returned when button is pressed. Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
Return value
Handle for the created BUTTON widget; 0 if the routine fails.
BUTTON_CreateAsChild()
(Obsolete, BUTTON_CreateEx should be used instead)
Description
Creates a BUTTON widget as a child window.
Prototype
BUTTON_Handle BUTTON_CreateAsChild(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags); Parameter x0 y0 xsize Meaning
X-position of the button relative to the parent window. Y-position of the buton relative to the parent window. Horizontal size of the button (in pixels).
2002-2007 Micrium
362
CHAPTER 15
Meaning
Handle of parent window. If 0, the new button window will be a child of the desktop (top-level window). ID to be returned when button is pressed. Window create flags (see
BUTTON_Create() ).
Return value
Handle for the created BUTTON widget; 0 if the routine fails.
BUTTON_CreateEx()
Description
Creates a BUTTON widget of a specified size at a specified location.
Prototype
BUTTON_Handle BUTTON_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new button window will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Not used yet, reserved for future use. Window ID of the widget.
Return value
Handle for the created BUTTON widget; 0 if the routine fails.
BUTTON_CreateIndirect()
Prototype explained at the beginning of the chapter. The elements Flags and Para of the resource passed as parameter are not used.
BUTTON_GetBitmap()
Description
Returns a pointer to the optional button bitmap.
Prototype
const GUI_BITMAP * BUTTON_GetBitmap(BUTTON_Handle hObj,
2002-2007 Micrium
363
Meaning
Permitted values for parameter Index BUTTON_BI_DISABLED Bitmap for disabled state. Bitmap for pressed state. BUTTON_BI_PRESSED BUTTON_BI_UNPRESSED Bitmap for unpressed state.
Return value
Pointer to the bitmap, 0 if no bitmap exist.
Add. information
For details about how to set a button bitmap please refer to the functions BUTTON_SetBitmap() and BUTTON_SetBitmapEx().
BUTTON_GetBkColor()
Description
Returns the background color of the given BUTTON widget.
Prototype
GUI_COLOR BUTTON_GetBkColor(BUTTON_Handle hObj, unsigned int Index); Parameter hObj Index
Handle of widget. Index for color (see table below).
Meaning
Permitted values for parameter Index BUTTON_CI_DISABLED Color for disabled state. Color for pressed state. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Color for unpressed state.
Return value
Background color of the given BUTTON widget
BUTTON_GetDefaultBkColor()
Description
Returns the default background color used by new BUTTON widgets.
Prototype
GUI_COLOR BUTTON_GetDefaultBkColor(unsigned Index); Parameter Index
Index for color (see table below).
Meaning
2002-2007 Micrium
364
CHAPTER 15
Permitted values for parameter Index BUTTON_CI_DISABLED Color for disabled state. Color for pressed state. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Color for unpressed state.
Return value
Background color used by new BUTTON widgets.
BUTTON_GetDefaultFont()
Description
Returns a pointer to the GUI_FONT structure used used to display the BUTTON text of new BUTTON widgets.
Prototype
const GUI_FONT * BUTTON_GetDefaultFont(void);
Return value
Pointer to the GUI_FONT structure used used to display the text of new BUTTON widgets.
BUTTON_GetDefaultTextAlign()
Description
Returns the default text alignment used to display the text of new BUTTON widgets.
Prototype
int BUTTON_GetDefaultTextAlign(void);
Return value
Default text alignment used to display the text of new BUTTON widgets.
BUTTON_GetDefaultTextColor()
Description
Returns the default text color used to display the text of new BUTTON widgets.
Prototype
GUI_COLOR BUTTON_GetDefaultTextColor(unsigned Index); Parameter Index
Index for color (see table below).
Meaning
Permitted values for parameter Index BUTTON_CI_DISABLED Color for disabled state. Color for pressed state. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Color for unpressed state.
2002-2007 Micrium
365
Return value
Default text color used to display the text of new BUTTON widgets.
BUTTON_GetFont()
Description
Returns a pointer to the font used to display the text of the given BUTTON widget
Prototype
const GUI_FONT * BUTTON_GetFont(BUTTON_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
pointer to the font used to display the text of the given BUTTON widget.
BUTTON_GetText()
Description
Retrieves the text of the specified BUTTON widget.
Prototype
void BUTTON_GetText(BUTTON_Handle hObj, char * pBuffer, int MaxLen); Parameter hObj pBuffer MaxLen
Handle of widget. Pointer to buffer. Size of buffer.
Meaning
BUTTON_GetTextColor()
Description
Returns the text color of the given BUTTON widget.
Prototype
GUI_COLOR BUTTON_GetTextColor(BUTTON_Handle hObj, unsigned int Index); Parameter hObj Index
Handle of widget. Index for color (see table below).
Meaning
Permitted values for parameter Index BUTTON_CI_DISABLED Color for disabled state. Color for pressed state. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Color for unpressed state.
Return value
Text color of the given BUTTON widget.
2002-2007 Micrium
366
CHAPTER 15
BUTTON_IsPressed()
Description
Returns if the BUTTON is pressed or not.
Prototype
unsigned BUTTON_IsPressed(BUTTON_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
1 if the button is pressed, 0 if not.
BUTTON_SetBitmap()
Description
Sets the bitmap(s) to be used when displaying a specified button.
Prototype
void BUTTON_SetBitmap(BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP* pBitmap); Parameter hObj Index pBitmap
Handle of button. Index for bitmap (see table below). Pointer to the bitmap structure.
Meaning
Permitted values for parameter Index BUTTON_BI_DISABLED Bitmap for disabled state. Bitmap for pressed state. BUTTON_BI_PRESSED BUTTON_BI_UNPRESSED Bitmap for unpressed state.
Add. information
If only a bitmap for the unpressed state is set the button will show it also when it is pressed or disabled.
BUTTON_SetBitmapEx()
Description
Sets the bitmap(s) to be used when displaying a specified button.
Prototype
void BUTTON_SetBitmapEx(BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP* pBitmap, int x, int y); Parameter hObj Index
Handle of button. Index for bitmap (see
Meaning BUTTON_SetBitmap() ).
2002-2007 Micrium
367
Parameter pBitmap x y
Pointer to the bitmap structure.
Meaning
X-position for the bitmap relative to the button. Y-position for the bitmap relative to the button.
Add. information
If only a bitmap for the unpressed state is set the button will show it also when it is pressed or disabled.
BUTTON_SetBkColor()
Description
Sets the button background color.
Prototype
void BUTTON_SetBkColor(BUTTON_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of button. Index for color (see table below). Background color to be set.
Meaning
Permitted values for parameter Index BUTTON_CI_DISABLED Sets the color to be used when button is disabled. Sets the color to be used when button is pressed. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Sets the color to be used when button is unpressed.
BUTTON_SetBMP()
Description
Sets the bitmap(s) to be used when displaying a specified button.
Prototype
void BUTTON_SetBMP(BUTTON_Handle hObj, unsigned int Index, const void * pBitmap); Parameter hObj Index pBitmap
Handle of widget. Index for bitmap (see table below). Pointer to bitmap file data
Meaning
Permitted values for parameter Index BUTTON_BI_DISABLED Sets the bitmap to be used when button is disabled. Sets the bitmap to be used when button is pressed. BUTTON_BI_PRESSED BUTTON_BI_UNPRESSED Sets the bitmap to be used when button is unpressed.
2002-2007 Micrium
368
CHAPTER 15
Add. information
If only a bitmap for the unpressed state is set the button will show it also when it is pressed or disabled. For additional informations regarding bitmap files please take a look at chapter 6, "BMP File Support".
BUTTON_SetBMPEx()
Description
Sets the bitmap(s) to be used when displaying a specified button.
Prototype
void BUTTON_SetBMPEx(BUTTON_Handle hObj, unsigned int Index, const void * pBitmap, int x, int y); Parameter hObj Index pBitmap x y
Handle of widget. Index for bitmap (see
Meaning BUTTON_SetBitmap() ).
Pointer to bitmap file data X-position for the bitmap relative to the button. Y-position for the bitmap relative to the button.
Add. information
If only a bitmap for the unpressed state is set the button will show it also when it is pressed or disabled. For additional informations regarding bitmap files please take a look at chapter 6, "BMP File Support".
BUTTON_SetDefaultBkColor()
Description
Sets the default background color used by new BUTTON widgets.
Prototype
void BUTTON_SetDefaultBkColor(GUI_COLOR Color, unsigned Index); Parameter Color Index
Color to be used. Index for color (see table below).
Meaning
Permitted values for parameter Index BUTTON_CI_DISABLED Color for disabled state. Color for pressed state. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Color for unpressed state.
2002-2007 Micrium
369
BUTTON_SetDefaultFocusColor()
Description
Sets the default focus rectangle color for new BUTTON widgets.
Prototype
GUI_COLOR BUTTON_SetDefaultFocusColor(GUI_COLOR Color); Parameter Color Meaning
Default color to be used for new buttons.
Return value
Previous default focus rectangle color.
Add. information
For more information please refer to the function BUTTON_SetFocusColor().
BUTTON_SetDefaultFont()
Description
Sets a pointer to a GUI_FONT structure used to display the text of new BUTTON widgets.
Prototype
void BUTTON_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont Meaning
Pointer to GUI_FONT structure to be used.
BUTTON_SetDefaultTextAlign()
Description
Sets the default text alignment used to display the text of new BUTTON widgets.
Prototype
void BUTTON_SetDefaultTextAlign(int Align); Parameter Align Meaning
Text alignment to be used. For details refer to
GUI_SetTextAlign()
BUTTON_SetDefaultTextColor()
Description
Seturns the default text color used to display the text of new BUTTON widgets.
2002-2007 Micrium
370
CHAPTER 15
Prototype
void BUTTON_SetDefaultTextColor(GUI_COLOR Color, unsigned Index); Parameter Color Index
Default text color to be used. Index for color (see table below).
Meaning
Permitted values for parameter Index BUTTON_CI_DISABLED Color for disabled state. Color for pressed state. BUTTON_CI_PRESSED BUTTON_CI_UNPRESSED Color for unpressed state.
BUTTON_SetFocusColor()
Before After
Description
Sets the color used to render the focus rectangle of the BUTTON widget.
Prototype
GUI_COLOR BUTTON_SetFocusColor(BUTTON_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget. Color to be used for the focus rectangle.
Meaning
Return value
Previous color of the focus rectangle.
Add. information
The focus rectangle is only visible if the widget has the input focus.
BUTTON_SetFocussable()
Description
Sets the ability to receive the input focus.
Prototype
void BUTTON_SetFocussable(BUTTON_Handle hObj, int State); Parameter hWin State
Window handle. see table below
Meaning
2002-2007 Micrium
371
BUTTON_SetFont()
Description
Sets the button font.
Prototype
void BUTTON_SetFont(BUTTON_Handle hObj, const GUI_FONT* pFont); Parameter hObj pFont
Handle of button. Pointer to the font.
Meaning
Add. information
If no font is selected, BUTTON_FONT_DEF will be used.
BUTTON_SetPressed()
Description
Sets the state of the button to pressed or unpressed.
Prototype
void BUTTON_SetPressed(BUTTON_Handle hObj, int State); Parameter hObj State
Handle of button. State, 1 for pressed, 0 for unpressed
Meaning
BUTTON_SetStreamedBitmap()
Description
Sets the streamed bitmap(s) to be used when displaying a specified button object.
Prototype
void BUTTON_SetStreamedBitmap(BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP_STREAM* pBitmap); Parameter hObj Index pBitmap
Handle of button. Index for bitmap (see
Meaning BUTTON_SetBitmap() ).
Add. information
To be able to use this function you must include the following line in LCDConf.h:
#define BUTTON_SUPPORT_STREAMED_BITMAP 1
372
CHAPTER 15
BUTTON_SetStreamedBitmapEx()
Description
Sets the streamed bitmap(s) to be used when displaying a specified button object.
Prototype
void BUTTON_SetStreamedBitmapEx(BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP_STREAM * pBitmap, int x, int y); Parameter hObj Index pBitmap x y
Handle of button. Index for bitmap (see
Meaning BUTTON_SetBitmap() ).
Pointer to a bitmap stream. X-position for the bitmap relative to the button. Y-position for the bitmap relative to the button.
Add. information
To be able to use this function you must include the following line in LCDConf.h:
#define BUTTON_SUPPORT_STREAMED_BITMAP 1
BUTTON_SetText()
Description
Sets the text to be displayed on the button.
Prototype
void BUTTON_SetText(BUTTON_Handle hObj, const char* s); Parameter hObj s
Handle of button. Text to display.
Meaning
BUTTON_SetTextAlign()
Description
Sets the alignement of the button text.
Prototype
void BUTTON_SetTextAlign(BUTTON_Handle hObj, int Align); Parameter hObj Align
Handle of button. Text alignment to be set (see
Meaning GUI_SetTextAlign() )
Add. information
The default value of the text alignment is GUI_TA_HCENTER | GUI_TA_VCENTER.
2002-2007 Micrium
373
BUTTON_SetTextColor()
Description
Sets the button text color.
Prototype
void BUTTON_SetTextColor(BUTTON_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of button. Index for text color (see Text color to be set.
Meaning BUTTON_SetBkColor() ).
15.4.5 Examples
Using the BUTTON widget
The following example demonstrates how to use two bitmaps to create a simple button. It is available as WIDGET_SimpleButton.c in the samples shipped with C/GUI:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ***** C/GUI - Graphical user interface for embedded applications **** C/GUI is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with a license and should not be redistributed in any way. We appreciate your understanding and fairness. ---------------------------------------------------------------------File : WIDGET_SimpleButton.c Purpose : Example demonstrating the use of a BUTTON widget ---------------------------------------------------------------------*/ #include "GUI.h" #include "BUTTON.h" /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _DemoButton */ static void _DemoButton(void) { BUTTON_Handle hButton; GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Click on button...", 160, 90); /* Create the button*/ hButton = BUTTON_Create(110, 110, 100, 40, GUI_ID_OK, WM_CF_SHOW); /* Set the button text */ BUTTON_SetText(hButton, "Click me..."); /* Let window manager handle the button */ while (GUI_WaitKey() != GUI_ID_OK);
2002-2007 Micrium
374 /* Delete the button*/ BUTTON_Delete(hButton); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(1000); }
CHAPTER 15
/******************************************************************* * * MainTask * * Demonstrates the use of a simple button * ******************************************************************** */ void MainTask(void) { GUI_Init(); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_SimpleButton - Sample", 160, 5); while (1) { _DemoButton(); } }
2002-2007 Micrium
375 ******************************************************************** */ /******************************************************************* * * Bitmap data, 2 phone logos */ static const GUI_COLOR Colors[] = { 0x000000, 0xFFFFFF }; static const GUI_LOGPALETTE Palette = { 2, 1, Colors }; static const unsigned ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, _____XXX, XXXXXXXX, ___XXXXX, XXXXXXXX, __XXXXXX, XXXXXXXX, _XXXXXXX, X_______, _XXXXXXX, X__XX___, _XXXXXXX, X__XX___, _XXXXXXX, X__XX___, ________, ___XX___, _______X, XXXXXXXX, ______XX, XXXXXXXX, _____XXX, XXXX__X_, ____XXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXX__X_, ___XXXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXX__X_, ___XXXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXXXXXX, }; static const unsigned ________, ________, ______XX, X_______, ____XXXX, XXXXX___, ____XXXX, XXXXXXX_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXXXXXX, _____XXX, XXXX_XXX, _______X, XXXX___X, ________, _XX_____, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ___XX___, ________, ___XX___, ________, ___XX___, ________, ___XX___, _______X, XXXXXXXX, ______XX, XXXXXXXX, _____XXX, XXXX__X_, ____XXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXX__X_, ___XXXXX, XXXX__X_, ___XXXXX, XXXXXXXX, char acPhone0[] = { ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, XXXXXXXX, XXX_____, XXXXXXXX, XXXXX___, XXXXXXXX, XXXXXX__, _______X, XXXXXXX_, ___XX__X, XXXXXXX_, ___XX__X, XXXXXXX_, ___XX__X, XXXXXXX_, ___XX___, ________, XXXXXXXX, X_______, XXXXXXXX, XX______, _X__XXXX, XXX_____, _X__XXXX, XXXX____, XXXXXXXX, XXXXX___, _X__XXXX, XXXXX___, _X__XXXX, XXXXX___, XXXXXXXX, XXXXX___, _X__XXXX, XXXXX___, _X__XXXX, XXXXX___, XXXXXXXX, XXXXX___, XXXXXXXX, XXXXX___ char acPhone1[] = { ________, ________, ________, ________, ________, ________, ________, ________, X_______, ________, XXX_____, ________, XXXXX___, ________, XXXXXXX_, ________, _XXXXXXX, X_______, ___XXXXX, XXX_____, _____XXX, XXXXX___, _______X, XXXXXX__, ________, XXXXXXX_, ________, XXXXXXX_, _______X, XXXXXXXX, ___XX__X, XXXXXXXX, ___XX___, _XXXXXXX, ___XX___, ___XXXX_, ___XX___, _____XX_, XXXXXXXX, X_______, XXXXXXXX, XX______, _X__XXXX, XXX_____, _X__XXXX, XXXX____, XXXXXXXX, XXXXX___, _X__XXXX, XXXXX___, _X__XXXX, XXXXX___, XXXXXXXX, XXXXX___,
2002-2007 Micrium
376 ___XXXXX, ___XXXXX, ___XXXXX, ___XXXXX, }; XXXX__X_, XXXX__X_, XXXXXXXX, XXXXXXXX, _X__XXXX, _X__XXXX, XXXXXXXX, XXXXXXXX,
static const unsigned ________, ________, ________, ________, ________, ________, ________, ________, ________, _______X, ________, _____XXX, ________, ___XXXXX, ________, _XXXXXXX, _______X, XXXXXXX_, _____XXX, XXXXX___, ___XXXXX, XXX_____, __XXXXXX, X_______, _XXXXXXX, ________, _XXXXXXX, ________, XXXXXXXX, X_______, XXXXXXXX, X__XX___, XXXXXXX_, ___XX___, _XXXX___, ___XX___, _XX_____, ___XX___, _______X, XXXXXXXX, ______XX, XXXXXXXX, _____XXX, XXXX__X_, ____XXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXX__X_, ___XXXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXX__X_, ___XXXXX, XXXX__X_, ___XXXXX, XXXXXXXX, ___XXXXX, XXXXXXXX, };
char acPhone2[] = { ________, ________, _______X, XX______, ___XXXXX, XXXX____, _XXXXXXX, XXXX____, XXXXXXXX, XXXXX___, XXXXXXXX, XXXXX___, XXX_XXXX, XXX_____, X___XXXX, X_______, _____XX_, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ___XX___, ________, ___XX___, ________, ___XX___, ________, ___XX___, ________, XXXXXXXX, X_______, XXXXXXXX, XX______, _X__XXXX, XXX_____, _X__XXXX, XXXX____, XXXXXXXX, XXXXX___, _X__XXXX, XXXXX___, _X__XXXX, XXXXX___, XXXXXXXX, XXXXX___, _X__XXXX, XXXXX___, _X__XXXX, XXXXX___, XXXXXXXX, XXXXX___, XXXXXXXX, XXXXX___
static const GUI_BITMAP bm_1bpp_0 = { 32, 31, 4, 1, acPhone0, &Palette}; static const GUI_BITMAP bm_1bpp_1 = { 32, 31, 4, 1, acPhone1, &Palette}; static const GUI_BITMAP bm_1bpp_2 = { 32, 31, 4, 1, acPhone2, &Palette}; /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _Wait */ static int _Wait(int Delay) { int EndTime, r = 1; EndTime = GUI_GetTime() + Delay; while (GUI_GetTime() < EndTime) { GUI_Exec(); if (GUI_GetKey() == GUI_ID_OK) { r = 0; break; } } return r; } /******************************************************************* * * _DemoButton */ static void _DemoButton(void) { BUTTON_Handle hButton;
2002-2007 Micrium
377 int Stat = 0; GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Click on phone button...", 160,80); GUI_Delay(500); /* Create the button */ hButton = BUTTON_Create(142, 100, 36, 40, GUI_ID_OK, WM_CF_SHOW); /* Modify the button attributes */ BUTTON_SetBkColor (hButton, 1, GUI_RED); /* Loop until button is pressed */ while (1) { BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_1, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); if (!_Wait(50)) break; BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_0, 2, 4); if (!_Wait(45)) break; BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_2, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_2, 2, 4); if (!_Wait(50)) break; BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_0, 2, 4); if (!_Wait(45)) break; } BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_1, 2, 4); BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4); GUI_ClearRect(0, 80, 319, 120); GUI_DispStringHCenterAt("You have answered the telephone", 160, 145); GUI_Delay(2000); /* Delete button object */ BUTTON_Delete(hButton); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(400); } /******************************************************************* * * MainTask * * Demonstrates the use of a BUTTON widget * ******************************************************************** */ void MainTask(void) { GUI_Init(); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_PhoneButton - Sample", 160, 5); while (1) { _DemoButton(); } }
2002-2007 Micrium
378
CHAPTER 15
Enabled
Disabled
All CHECKBOX-related routines are located in the file(s) CHECKBOX*.c, CHECKBOX.h. All identifiers are prefixed CHECKBOX.
2002-2007 Micrium
379
Default
0xC0C0C0 0x808080 GUI_WHITE 0x101010 GUI_BLACK
Explanation
Default background color. Background color of the default image, disabled state. Background color of the default image, enabled state. Foreground color of the default image, disabled state. Foreground color of the default image, enabled state. Color used to render the focus rectangle. Default font used to display the optional checkbox text. Pointer to bitmap used to draw the widget if checked, disabled state. Pointer to bitmap used to draw the widget if checked, enabled state. Spacing used to display the optional checkbox text beside the box. Default alignment of the optional checkbox text. Default color used to display the optional checkbox text.
2002-2007 Micrium
380
CHAPTER 15
2002-2007 Micrium
381
CHECKBOX_Check()
Before After
Description
Sets a specified check box to a checked state.
Prototype
void CHECKBOX_Check(CHECKBOX_Handle hObj); Parameter hObj
Handle of check box.
Meaning
CHECKBOX_Create()
(Obsolete, CHECKBOX_CreateEx should be used instead)
Description
Creates a CHECKBOX widget of a specified size at a specified location.
Prototype
CHECKBOX_Handle CHECKBOX_Create(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags); Parameter x0 y0 xsize ysize hParent Id Flags Meaning
Leftmost pixel of the check box (in parent coordinates). Topmost pixel of the check box (in parent coordinates). Horizontal size of the check box (in pixels). Vertical size of the check box (in pixels). Handle of parent window. ID to be returned. Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
Return value
Handle for the created CHECKBOX widget; 0 if the routine fails.
Add. information
If the parameters xsize or ysize are 0 the size of the bitmap will be used as default size of the check box.
CHECKBOX_CreateIndirect()
Prototype explained at the beginning of the chapter. The elements Flags and Para of the resource passed as parameter are not used.
2002-2007 Micrium
382
CHAPTER 15
CHECKBOX_CreateEx()
Description
Creates a CHECKBOX widget of a specified size at a specified location.
Prototype
CHECKBOX_Handle CHECKBOX_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new CHECKBOX widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Not used yet, reserved for future use. Window ID of the widget.
Return value
Handle for the created widget; 0 if the routine fails.
Add. information
If the parameters xsize or ysize are 0 the size of the default check mark bitmap (11 x 11 pixels) plus the effect size will be used as default size of the check box. If the desired size of the check box is different to the default size it can be usefull to set a user defined check mark image using the function CHECKBOX_SetImage(). If check box text should be shown with the widget the size should be large enough to show the box + text + spacing between box and text.
CHECKBOX_GetDefaultBkColor()
Description
Returns the default background color of new check box widgets.
Prototype
GUI_COLOR CHECKBOX_GetDefaultBkColor (void);
Return value
Default background color of new check box widgets.
Add. information
The background color returned by this function is not the background color shown in the box, but the background color of the rest of the widget. For more information please refer to CHECKBOX_SetBkColor().
2002-2007 Micrium
383
CHECKBOX_GetDefaultFont()
Description
Returns a pointer to a GUI_FONT structure used to display the check box text of new check box widgets.
Prototype
const GUI_FONT * CHECKBOX_GetDefaultFont(void);
Return value
Pointer to a GUI_FONT structure used to display the check box text of new check box widgets.
Add. information
For more information please refer to CHECKBOX_SetFont().
CHECKBOX_GetDefaultSpacing()
Description
Returns the default spacing between box and text used to display the check box text of new check box widgets.
Prototype
int CHECKBOX_GetDefaultSpacing(void);
Return value
Default spacing between box and text used to display the check box text of new check box widgets.
Add. information
For more information please refer to CHECKBOX_SetSpacing().
CHECKBOX_GetDefaultTextAlign()
Description
Returns the default alignment used to display the check box text of new check box widgets.
Prototype
int CHECKBOX_GetDefaultAlign(void);
Return value
Default alignment used to display the check box text.
Add. information
For more information please refer to CHECKBOX_SetTextAlign().
CHECKBOX_GetDefaultTextColor()
Description
Returns the default text color used to display the check box text of new check box widgets.
2002-2007 Micrium
384
CHAPTER 15
Prototype
GUI_COLOR CHECKBOX_GetDefaultTextColor(void);
Return value
Default text color used to display the check box text of new check box widgets.
Add. information
For more information please refer to CHECKBOX_SetTextColor().
CHECKBOX_GetState()
Description
Returns the current state of the given check box.
Prototype
int CHECKBOX_GetState(CHECKBOX_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
Current state of the given check box.
Add. information
Per default a check box can have 2 states, checked (1) and unchecked (0). With the function CHECKBOX_SetNumStates() the number of possible states can be increased to 3. If the check box is in the third state the function returns 2. For more information please refer to CHECKBOX_SetNumStates().
CHECKBOX_GetText()
Description
Returns the optional text of the given check box.
Prototype
int CHECKBOX_GetText(CHECKBOX_Handle hObj, char * pBuffer, int MaxLen); Parameter hObj pBuffer MaxLen
Handle of widget. Pointer to buffer to which the text will be copied. Buffer size in bytes.
Meaning
Return value
Length of the text copied into the buffer.
Add. information
If the check box contains no text the function returns 0 and the buffer remains unchanged.
2002-2007 Micrium
385
CHECKBOX_IsChecked()
Description
Returns the current state (checked or not checked) of a specified CHECKBOX widget.
Prototype
int CHECKBOX_IsChecked(CHECKBOX_Handle hObj); Parameter hObj
Handle of check box.
Meaning
Return value
0: not checked 1: checked
CHECKBOX_SetBkColor()
Before After
Description
Sets the background color used to display the background of the check box.
Prototype
void CHECKBOX_SetBkColor(CHECKBOX_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget. Color to be used to draw the background or transparent mode.
Add. information
If the check box should work in transparent mode GUI_INVALID_COLOR should be used.
CHECKBOX_SetBoxBkColor()
Before After
Description
Sets the background color of the box area.
2002-2007 Micrium
386
CHAPTER 15
Prototype
GUI_COLOR CHECKBOX_SetBoxBkColor(CHECKBOX_Handle hObj, GUI_COLOR Color, int Index); Parameter hObj Color Index
Handle of widget. Color to be used. (see table below)
Meaning
Return value
Previous background color.
Add. information
The color set by this function will only be visible, if the images used by the widget are transparent or no image is used. The default images of this widget are transparent.
CHECKBOX_SetDefaultBkColor()
Description
Sets the default background color used for new check box widgets.
Prototype
void CHECKBOX_SetDefaultBkColor(GUI_COLOR Color); Parameter Color
Color to be used,
Add. information
For more information please refer to CHECKBOX_SetBkColor().
CHECKBOX_SetDefaultFocusColor()
Description
Sets the color used to render the focus rectangle of new check box widgets.
Prototype
GUI_COLOR CHECKBOX_SetDefaultFocusColor(GUI_COLOR Color); Parameter Color
Color to be used.
Meaning
Return value
Previous color used to render the focus rectangle.
2002-2007 Micrium
387
Add. information
For mode information please refer to CHECKBOX_SetFocusColor().
CHECKBOX_SetDefaultFont()
Description
Sets a pointer to a GUI_FONT structure used to display the check box text of new check box widgets.
Prototype
void CHECKBOX_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont Meaning
Pointer to GUI_FONT structure to be used.
Add. information
For more information please refer to CHECKBOX_SetFont().
CHECKBOX_SetDefaultImage()
Description
Sets the images used for new check boxes to be shown if they has been checked.
Prototype
void CHECKBOX_SetDefaultImage(const GUI_BITMAP * pBitmap, unsigned int Index); Parameter pBitmap Index
Pointer to bitmap. (see table below)
Meaning
Permitted values for parameter Index CHECKBOX_BI_INACTIV_UNCHECKED check box is unchecked and disabled. CHECKBOX_BI_ACTIV_UNCHECKED CHECKBOX_BI_INACTIV_CHECKED CHECKBOX_BI_ACTIV_CHECKED CHECKBOX_BI_INACTIV_3STATE CHECKBOX_BI_ACTIV_3STATE
Sets the bitmap displayed when the check box is unchecked and enabled. Sets the bitmap displayed when the check box is checked and disabled. Sets the bitmap displayed when the check box is checked and enabled. Sets the bitmap displayed when the check box is in the third state and disabled. Sets the bitmap displayed when the check box is in the third state and enabled. Sets the bitmap displayed when the
Add. information
The image has to fill the complete inner area of the check box.
2002-2007 Micrium
388
CHAPTER 15
CHECKBOX_SetDefaultSpacing()
Description
Sets the default spacing between box and text used to display the check box text of new check box widgets.
Prototype
void CHECKBOX_SetDefaultSpacing(int Spacing); Parameter Spacing Meaning
Number of pixels between box and text used for new check box widgets.
Add. information
For more information please refer to CHECKBOX_SetSpacing().
CHECKBOX_SetDefaultTextAlign()
Description
Sets the default alignment used to display the check box text of new check box widgets.
Prototype
void CHECKBOX_SetDefaultTextAlign(int Align); Parameter Align Meaning
Text alignment used to display the text of new check box widgets.
Add. information
For more information please refer to CHECKBOX_SetTextAlign().
CHECKBOX_SetDefaultTextColor()
Description
Sets the default text color used to display the check box text of new check box widgets.
Prototype
void CHECKBOX_SetDefaultTextColor(GUI_COLOR Color); Parameter Color
Color to be used.
Meaning
Add. information
For more information please refer to CHECKBOX_SetTextColor().
2002-2007 Micrium
389
CHECKBOX_SetFocusColor()
Before After
Description
Sets the color used to render the focus rectangle.
Prototype
GUI_COLOR CHECKBOX_SetFocusColor(CHECKBOX_Handle hObj, GUI_COLOR Color); Parameter hObj
Handle of widget.
Meaning
Return value
Previous color of the focus rectangle.
Add. information
The focus rectangle is only visible if the widget has the input focus.
CHECKBOX_SetImage()
Before After
Description
Sets the images to be shown if the check box has been checked.
Prototype
void CHECKBOX_SetImage(CHECKBOX_Handle hObj, const GUI_BITMAP * pBitmap, unsigned int Index); Parameter hObj pBitmap Index
Handle of check box. Pointer to bitmap. (see table shown under
Meaning
CHECKBOX_SetDefaultImage )
2002-2007 Micrium
390
CHAPTER 15
Add. information
The image has to fill the complete inner area of the check box. If using this function make sure, the size of the check box used to create the widget is large enough to show the bitmap and (optional) the text.
CHECKBOX_SetNumStates()
Description
This function sets the number of possible states of the given check box.
Prototype
void CHECKBOX_SetNumStates(CHECKBOX_Handle hObj, unsigned NumStates); Parameter hObj NumStates
Handle of widget. Number of possible states of the given check box. Currently supported are 2 or 3 states.
Meaning
Add. information
Per default a check box supports 2 states: checked (1) and unchecked (0). If the check box should support a third state the number of possible states can be increased to 3.
CHECKBOX_SetSpacing()
Before After
Description
Sets the number of pixels between box and text of a given check box widget.
Prototype
void CHECKBOX_SetSpacing(CHECKBOX_Handle hObj, unsigned Spacing); Parameter hObj Spacing
Handle of widget. Number of pixels between box and text to be used.
Meaning
Add. information
The default spacing is 4 pixels. The function CHECKBOX_SetDefaultSpacing() or the configuration macro CHECKBOX_SPACING_DEFAULT can be used to set the default value.
2002-2007 Micrium
391
CHECKBOX_SetState()
Before After
Description
Sets the new state of the given check box widget.
Prototype
void CHECKBOX_SetState(CHECKBOX_Handle hObj, unsigned State); Parameter hObj State
Handle of widget. Zero based number of new state.
Meaning
Add. information
The passed state should not be greater than the number of possible states set with CHECKBOX_SetNumStates() minus 1.
CHECKBOX_SetText()
Before After
Description
Sets the optional text shown beside the box.
Prototype
void CHECKBOX_SetText(CHECKBOX_Handle hObj, const char * pText); Parameter hObj pText
Handle of widget. Pointer to text to be shown beside the box.
Meaning
2002-2007 Micrium
392
CHAPTER 15
Add. information
Clicking on the text beside the box has the same effect as clicking into the box.
CHECKBOX_SetTextAlign()
Before After
Description
Sets the alignment used to display the check box text beside the box.
Prototype
void CHECKBOX_SetTextAlign(CHECKBOX_Handle hObj, int Align); Parameter hObj Align
Handle of widget. Desired text alignment.
Meaning
Add. information
Per default the text alignment is GUI_TA_LEFT | GUI_TA_VCENTER. The function CHECKBOX_SetDefaultTextAlign() and the configuraton macro CHECKBOX_TEXTALIGN_DEFAULT can be used to set a user defined default value.
CHECKBOX_SetTextColor()
Before After
Description
Sets the color used to display the check box text.
Prototype
void CHECKBOX_SetTextColor(CHECKBOX_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget. Desired color of check box text.
Meaning
Add. information
Per default the text color of a check box text is GUI_BLACK. The function CHECKBOX_SetDefaultTextColor() and the configuration macro CHECKBOX_TEXTCOLOR_DEFAULT can be used to set a user defined default color.
2002-2007 Micrium
393
CHECKBOX_Uncheck()
Before After
Description
Sets a specified check box to an unchecked state.
Prototype
void CHECKBOX_Uncheck(CHECKBOX_Handle hObj); Parameter hObj
Handle of check box.
Meaning
Add. information
This is the default setting for check boxes.
2002-2007 Micrium
394
CHAPTER 15
If mouse support is enabled, the open list reacts on moving the mouse over it.
Default
GUI_TA_LEFT &GUI_Font13_1 GUI_WHITE GUI_GRAY GUI_BLUE GUI_KEY_SPACE GUI_KEY_ENTER
Explanation
Text alignment used to display the dropdown text in closed state. Default font Background color, unselected state. Background color, selected state without focus. Background color, selected state with focus. Key which can be used to expand the dropdown list. Key which can be used to select an item from the open dropdown list. Text color, unselected state. Text color, selected state without focus. Enable 3D support.
Explanation
Widget has been clicked. Widget has been released. Widget has been clicked and pointer has been moved out off of the widget without releasing. The scroll position of the optional scrollbar of the opened dropdown widget has been changed. The selection of the dropdown list has been changes.
2002-2007 Micrium
395
Reaction
Selects an item from the open dropdown list and closes the list.
DROPDOWN_SetDefaultScrollbarColor() the dropdown list. Sets the font of the given DROPDOWN widget DROPDOWN_SetFont() Sets the state of the given item. DROPDOWN_SetItemDisabled() DROPDOWN_SetItemSpacing() DROPDOWN_SetScrollbarColor() DROPDOWN_SetSel() DROPDOWN_SetTextAlign() DROPDOWN_SetTextColor() DROPDOWN_SetTextHeight()
Sets an additional spacing between the items of the dropdown list. Sets the colors of the scrollbar in the dropdown list. Sets the current selection Sets the text alignment used to display the dropdown text in closed state. Sets the text color of the given DROPDOWN widget. Sets the height of the rectangle used to display the dropdown text in closed state.
2002-2007 Micrium
396
CHAPTER 15
DROPDOWN_AddString()
Description
Adds a new element to the dropdown list.
Prototype
void DROPDOWN_AddString(DROPDOWN_Handle hObj, const char* s); Parameter hObj s
Handle of widget Pointer to string to be added
Meaning
DROPDOWN_Collapse()
Description
Closes the dropdown list of the DROPDOWN widget.
Prototype
void DROPDOWN_Collapse(DROPDOWN_Handle hObj); Parameter hObj
Handle of widget
Meaning
DROPDOWN_Create()
(Obsolete, DROPDOWN_CreateEx() should be used instead)
Description
Creates a DROPDOWN widget of a specified size at a specified location.
Prototype
DROPDOWN_Handle DROPDOWN_Create(WM_HWIN hWinParent, int x0, int y0, int xsize, int ysize, int Flags); Parameter hWinParent x0 y0 xsize ysize Flags
Handle of parent window Leftmost pixel of the DROPDOWN widget (in parent coordinates). Topmost pixel of the DROPDOWN widget (in parent coordinates). Horizontal size of the DROPDOWN widget (in pixels). Vertical size of the DROPDOWN widget in open state (in pixels). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 12: "The Window Manager" for a list of available parameter values).
Meaning
Return value
Handle for the created DROPDOWN widget, 0 on failure.
2002-2007 Micrium
397
Add. information
The ysize of the widget in closed state depends on the font used to create the widget. You can not set the ysize of a closed DROPDOWN widget.
DROPDOWN_CreateEx()
Description
Creates a DROPDOWN widget of a specified size at a specified location.
Prototype
DROPDOWN_Handle DROPDOWN_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget in open state (in pixels). Handle of parent window. If 0, the new DROPDOWN widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Window ID of the widget.
DROPDOWN_SetAutoScroll DROPDOWN_CF_UP
Creates a DROPDOWN widget which opens the dropdown list above the widget. This flag is usefull if the space below the widget is not sufficient for the dropdown list.
Return value
Handle for the created widget; 0 if the routine fails.
DROPDOWN_CreateIndirect()
Prototype explained at the beginning of the chapter.
DROPDOWN_DecSel()
Description
Decrement the selection, moves the selection of a specified DROPDOWN widget up by one item.
2002-2007 Micrium
398
CHAPTER 15
Prototype
void DROPDOWN_DecSel(DROPDOWN_Handle hObj); Parameter hObj
Handle of widget
Meaning
DROPROWN_DeleteItem()
Description
Deletes the given item of the dropdown list.
Prototype
void DROPDOWN_DeleteItem(DROPDOWN_Handle hObj, unsigned int Index); Parameter hObj Index
Handle of widget. Zero based index of the item to be deleted.
Meaning
Add. information
If the index is greater than the number of items < 1 the function returns immediately.
DROPDOWN_Expand()
Description
Opens the dropdown list of the widget.
Prototype
void DROPDOWN_Expand(DROPDOWN_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Add. information
The dropdown list remains open until an element has been selected or the focus has been lost.
DROPDOWN_GetItemDisabled()
Description
Returns the state of the given item.
Prototype
unsigned DROPDOWN_GetItemDisabled(DROPDOWN_Handle hObj, unsigned Index); Parameter hObj Index
Handle of widget Zerobased index of the item.
Meaning
2002-2007 Micrium
399
Return value
1 if the given item is disabled, 0 if not.
DROPDOWN_GetNumItems()
Description
Returns the number of items in the given DROPDOWN widget.
Prototype
int DROPDOWN_GetNumItems(DROPDOWN_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Number of items in the given DROPDOWN widget.
DROPDOWN_GetSel()
Description
Returns the number of the currently selected item in a specified DROPDOWN widget.
Prototype
int DROPDOWN_GetSel(DROPDOWN_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Number of the currently selected item.
DROPDOWN_IncSel()
Description
Increment the selection, moves the selection of a specified DROPDOWN widget down by one item.
Prototype
void DROPDOWN_IncSel(DROPDOWN_Handle hObj); Parameter hObj
Handle of widget
Meaning
DROPDOWN_InsertString()
Description
Inserts a string to the dropdown list at the given position.
Prototype
void DROPDOWN_InsertString(DROPDOWN_Handle hObj, const char* s,
User's & reference manual for C/GUI 2002-2007 Micrium
400
CHAPTER 15
Meaning
Add. information
If the given index is greater than the number of items the string will be appended to the end of the dropdown list.
DROPDOWN_SetAutoScroll()
Description
Enables the automatic use of a vertical scrollbar in the dropdown list.
Prototype
void DROPDOWN_SetAutoScroll(DROPDOWN_Handle hObj, int OnOff); Parameter hObj OnOff
Handle of widget. (see table below)
Meaning
Add. information
If enabled the dropdown list checks if all elements fits into the listbox. If not a vertical scrollbar will be added.
DROPDOWN_SetBkColor()
Before After
Description
Sets the background color of the given DROPDOWN widget.
Prototype
void DROPDOWN_SetBkColor(DROPDOWN_Handle hObj, unsigned int Index,
2002-2007 Micrium
401
Meaning
DROPDOWN_SetColor()
Before After
Description
Sets the color of the button or the arrow of the given DROPDOWN widget.
Prototype
void DROPDOWN_SetColor(DROPDOWN_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of widget Index of desired item (see table below). Color to be used.
Meaning
DROPDOWN_SetDefaultColor()
Description
Sets the default colors for the arrow and the button of new DROPDOWN widgets.
Prototype
GUI_COLOR DROPDOWN_SetDefaultColor(int Index, GUI_COLOR Color); Parameter Index Color
Please refer to the function Color to be used.
Meaning DROPDOWN_SetColor() .
2002-2007 Micrium
402
CHAPTER 15
DROPDOWN_SetDefaultFont()
Description
Sets the default font used for new DROPDOWN widgets.
Prototype
void DROPDOWN_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont
Pointer to GUI_FONT structure.
Meaning
DROPDOWN_SetDefaultScrollbarColor()
Description
Sets the default colors used for the optional scrollbar in the dropdown list.
Prototype
GUI_COLOR DROPDOWN_SetDefaultScrollbarColor(int Index, GUI_COLOR Color); Parameter Index Color
Please refer to the function Color to be used.
Meaning DROPDOWN_SetScrollbarColor() .
DROPDOWN_SetFont()
Description
Sets the font used to display the given DROPDOWN widget.
Prototype
void DROPDOWN_SetFont(DROPDOWN_Handle hObj, const GUI_FONT* pfont); Parameter hObj pFont
Handle of widget Pointer to the font.
Meaning
2002-2007 Micrium
403
DROPDOWN_SetItemDisabled()
Before After
Description
Sets the enabled state of the given item.
Prototype
void DROPDOWN_SetItemDisabled(DROPDOWN_Handle hObj, unsigned Index, int OnOff); Parameter hObj Index OnOff
Handle of widget Zerobased index of the item. 1 for enabled, 0 for disabled.
Meaning
DROPDOWN_SetScrollbarColor()
Before After
Description
Sets the colors of the optional scrollbar in the dropdown list.
Prototype
void DROPDOWN_SetScrollbarColor(DROPDOWN_Handle hObj, unsigned int Index,
2002-2007 Micrium
404
CHAPTER 15
Meaning
Permitted values for parameter Index SCROLLBAR_CI_THUMB Color of thumb area. SCROLLBAR_CI_SHAFT Color of shaft. SCROLLBAR_CI_ARROW Color of arrows.
DROPDOWN_SetScrollbarWidth()
Description
Sets the width of the scrollbars used by the dropdown list of the given DROPDOWN widget.
Prototype
void DROPDOWN_SetScrollbarWidth(DROPDOWN_Handle hObj, unsigned Width); Parameter hObj Width
Handle of widget. Width of the scrollbar(s) used by the dropdown list of the given DROPDOWN widget.
Meaning
DROPDOWN_SetSel()
Description
Sets the selected item of a specified DROPDOWN widget.
Prototype
void DROPDOWN_SetSel(DROPDOWN_Handle hObj, int Sel); Parameter hObj Sel
Handle of widget Element to be selected.
Meaning
2002-2007 Micrium
405
DROPDOWN_SetItemSpacing()
Before After
Description
Sets an additional spacing below the items of the dropdown list.
Prototype
void DROPDOWN_SetItemSpacing(DROPDOWN_Handle hObj, unsigned Value); Parameter hObj Value
Handle of widget Number of pixels used as additional space between the items of the dropdown list.
Meaning
DROPDOWN_SetTextAlign()
Before After
Description
Sets the alignment used to display the dropdown text in closed state.
Prototype
void DROPDOWN_SetTextAlign(DROPDOWN_Handle hObj, int Align); Parameter hObj Align
Handle of widget Alignment used to display the dropdown text in closed state.
Meaning
DROPDOWN_SetTextColor()
Description
Sets the background color of the given DROPDOWN widget.
Prototype
void DROPDOWN_SetTextColor(DROPDOWN_Handle hObj,
User's & reference manual for C/GUI 2002-2007 Micrium
406
CHAPTER 15
Meaning
DROPDOWN_SetTextHeight()
Before After
Description
Sets the height of the rectangle used to display the DROPDOWN text in closed state.
Prototype
void DROPDOWN_SetTextHeight(DROPDOWN_Handle hObj, unsigned TextHeight); Parameter hObj TextHeight
Handle of widget Height of the rectangle used to display the text in closed state.
Meaning
Add. Information
Per default the height of the DROPDOWN widget depends on the used font. Using this function with TextHeight > 0 means the given value should be used. TextHeight = 0 means the default behavior should be used.
2002-2007 Micrium
407
You can also use edit fields for entering values in binary, decimal, or hexadecimal modes. A decimal-mode edit field might appear similar to those in the following table. Like a check box, an edit field will appear gray if disabled: Edit field with user input (decimal) Disabled edit field
All EDIT-related routines are located in the file(s) EDIT*.c, EDIT.h. All identifiers are prefixed EDIT.
Default
Explanation
GUI_TA_RIGHT | Alignment for edit field text. GUI_TA_VCENTER 0xc0c0c0 GUI_WHITE 1 &GUI_Font13_1 GUI_BLACK GUI_BLACK 2 Background color, disabled state. Background color, enabled state. Width of border, in pixels. Font used for edit field text. Text color, disabled state. Text color, enabled state. Distance in X to offset text from left border of edit field.
Available alignment flags are: GUI_TA_LEFT, GUI_TA_RIGHT, GUI_TA_HCENTER for horizontal alignment. GUI_TA_TOP, GUI_TA_BOTTOM, GUI_TA_VCENTER for vertical alignment.
2002-2007 Micrium
408
CHAPTER 15
Explanation
2002-2007 Micrium
409
Routine EDIT_GetText() EDIT_GetValue() EDIT_SetBinMode() EDIT_SetBkColor() EDIT_SetCursorAtChar() EDIT_SetCursorAtPixel() EDIT_SetDecMode() EDIT_SetDefaultBkColor() EDIT_SetDefaultFont() EDIT_SetDefaultTextAlign() EDIT_SetDefaultTextColor() EDIT_SetFloatMode() EDIT_SetFloatValue() EDIT_SetFont() EDIT_SetHexMode() EDIT_SetInsertMode() EDIT_SetMaxLen() EDIT_SetpfAddKeyEx() EDIT_SetSel() EDIT_SetText() EDIT_SetTextAlign() EDIT_SetTextColor() EDIT_SetTextMode() EDIT_SetValue() EDIT_SetUlongMode() GUI_EditBin() GUI_EditDec() GUI_EditHex() GUI_EditString()
Get user input.
Explanation
Returns the current value. Enables the binary edit mode. Sets the background color of the edit field. Sets the edit widget cursor to a specified character position. Sets the edit widget cursor to a specified pixel position. Enables the decimal edit mode. Sets the default background color. Sets the default font used for edit fields. Sets the default text alignment for edit fields. Sets the default text color. Enables the floating point edit mode. Sets the floating point value if using the floating point edit mode. Select the font for the text. Enables the hexadecimal edit mode. Enables or disables the insert mode. Sets the maximum number of characters of the edit field. Sets a function which is called to add a character. Sets the current selection. Sets the text. Sets the text alignment for the edit field. Sets the color(s) for the text. Sets the edit mode of the widget back to text mode. Sets the current value. Enables the unsigned long decimal edit mode. Edits a binary value at the current cursor position. Edits a decimal value at the current cursor position. Edits a hexadecimal value at the current cursor position. Edits a string at the current cursor position.
EDIT_AddKey()
Description
Adds user input to a specified edit field.
Prototype
void EDIT_AddKey(EDIT_Handle hObj, int Key); Parameter hObj Key
Handle of edit field. Character to be added.
Meaning
Add. information
The specified character is added to the user input of the EDIT widget. If the last character should be erased, the key GUI_KEY_BACKSPACE can be used. If the maximum count of characters has been reached, another character will not be added.
2002-2007 Micrium
410
CHAPTER 15
EDIT_Create()
(Obsolete, EDIT_CreateEx should be used instead)
Description
Creates an EDIT widget of a specified size at a specified location.
Prototype
EDIT_Handle EDIT_Create(int x0, int y0, int xsize, int ysize, int Id, int MaxLen, int Flags); Parameter x0 y0 xsize ysize Id MaxLen Flags Meaning
Leftmost pixel of the edit field (in parent coordinates). Topmost pixel of the edit field (in parent coordinates). Horizontal size of the edit field (in pixels). Vertical size of the edit field (in pixels. ID to be returned. Maximum count of characters. Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
Return value
Handle for the created EDIT widget; 0 if the routine fails.
EDIT_CreateAsChild()
(Obsolete, EDIT_CreateEx should be used instead)
Description
Creates an EDIT widget as a child window.
Prototype
EDIT_Handle EDIT_CreateAsChild(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, int MaxLen); Parameter x0 y0 xsize ysize hParent Id Flags MaxLen Meaning
X-position of the edit field relative to the parent window. Y-position of the edit field relative to the parent window. Horizontal size of the edit field (in pixels). Vertical size of the edit field (in pixels. Handle of parent window. ID to be returned. Window create flags (see
EDIT_Create() ).
Return value
Handle for the created EDIT widget; 0 if the routine fails.
2002-2007 Micrium
411
EDIT_CreateEx()
Description
Creates a EDIT widget of a specified size at a specified location.
Prototype
EDIT_Handle EDIT_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, int MaxLen); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id MaxLen Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new EDIT widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Not used, reserved for future use. Window ID of the widget. Maximum count of characters.
Return value
Handle for the created widget; 0 if the routine fails.
EDIT_CreateIndirect()
Prototype explained at the beginning of the chapter. The following flags may be used as the Flags element of the resource passed as parameter: Permitted indirect creation flags ("OR" combinable) EDIT_CF_LEFT EDIT_CF_RIGHT EDIT_CF_HCENTER EDIT_CF_TOP EDIT_CF_BOTTOM EDIT_CF_VCENTER
Horizontal alignment: left Horizontal alignment: right Horizontal alignment: center Vertical alignment: top Vertical alignment: bottom Vertical alignment: center
The Para element is used as maximum length of a string to display / max. no. of digits if used in decimal, bin or hex mode.
EDIT_EnableBlink()
Description
Enables/disables a blinking cursor.
2002-2007 Micrium
412
CHAPTER 15
Prototype
void EDIT_EnableBlink(EDIT_Handle hObj, int Period, int OnOff); Parameter hObj Period OnOff
Handle of edit field. Blinking period 1 enables blinking, 0 disables blinking
Meaning
Add. Information
This function calls GUI_X_GetTime().
EDIT_GetCursorCharPos()
Description
Returns the number of the character at the cursor position.
Prototype
int EDIT_GetCursorCharPos(EDIT_Handle hObj); Parameter hObj
Handle of edit field.
Meaning
Return value
Number of the character at the cursor position.
Add. Information
The widget returns the character position if it has the focus or not. This means the cursor position is also returned, if the cursor is currently not visible in the widget.
EDIT_GetCursorPixelPos()
Description
Returns the pixel position of the cursor in window coordinates.
Prototype
void EDIT_GetCursorPixelPos(EDIT_Handle hObj, int * pxPos, int * pyPos); Parameter hObj pxPos pyPos
Handle of edit field. Pointer to integer variable for the X-position in window coordinates. Pointer to integer variable for the Y-position in window coordinates.
Meaning
Add. Information
The widget returns the pixel position if it has the focus or not. This means the cursor position is also returned, if the cursor is currently not visible in the widget.
EDIT_GetDefaultBkColor()
Description
Returns the default background color used for EDIT widgets.
User's & reference manual for C/GUI 2002-2007 Micrium
413
Prototype
GUI_COLOR EDIT_GetDefaultBkColor(unsigned int Index); Parameter Index
(see table below)
Meaning
Return value
Default background color used for EDIT widgets.
EDIT_GetDefaultFont()
Description
Returns the default font used for EDIT widgets.
Prototype
const GUI_FONT* EDIT_GetDefaultFont(void);
Return value
Default font used for EDIT widgets.
EDIT_GetDefaultTextAlign()
Description
Returns the default text alignment used for EDIT widgets.
Prototype
int EDIT_GetDefaultTextAlign(void);
Return value
Default text alignment used for EDIT widgets.
EDIT_GetDefaultTextColor()
Description
Returns the default text color used for EDIT widgets.
Prototype
GUI_COLOR EDIT_GetDefaultTextColor(unsigned int Index); Parameter Index
Has to be 0, reserved for future use.
Meaning
Return value
Default text color used for EDIT widgets.
2002-2007 Micrium
414
CHAPTER 15
EDIT_GetFloatValue()
Description
Returns the current value of the edit field as floating point value.
Prototype
float EDIT_GetFloatValue(EDIT_Handle hObj); Parameter hObj
Handle of edit field.
Meaning
Return value
The current value.
Add. Information
The use of this function makes only sense if the edit field is in floating point edit mode.
EDIT_GetNumChars
Description
Returns the number of characters of the specified edit field.
Prototype
int EDIT_GetNumChars(EDIT_Handle hObj); Parameter hObj
Handle of edit field.
Meaning
Return value
Number of characters of the specified edit field.
EDIT_GetText()
Description
Retrieves the user input of a specified edit field.
Prototype
void EDIT_GetText(EDIT_Handle hObj, char* sDest, int MaxLen); Parameter hObj sDest MaxLen
Handle of edit field. Pointer to buffer. Size of buffer.
Meaning
EDIT_GetValue()
Description
Returns the current value of the edit field. The current value is only useful if the edit field is in binary, decimal or hexadecimal mode.
2002-2007 Micrium
415
Prototype
I32 EDIT_GetValue(EDIT_Handle hObj); Meaning
Handle of edit field.
Parameter hObj
Return value
The current value.
EDIT_SetBinMode()
Description
Enables the binary edit mode of the edit field. The given value can be modified in the given range.
Prototype
void EDIT_SetBinMode(EDIT_Handle hObj, U32 Value, U32 Min, U32 Max); Parameter hObj Value Min Max
Handle of edit field. Value to be modified. Minimum value. Maximum value.
Meaning
EDIT_SetBkColor()
Description
Sets the edit fields background color.
Prototype
void EDIT_SetBkColor(EDIT_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of edit field. Index for background color (see table below). Color to be set.
Meaning
EDIT_SetCursorAtChar()
Description
Sets the edit widget cursor to a specified character position.
2002-2007 Micrium
416
CHAPTER 15
Prototype
void EDIT_SetCursorAtChar(EDIT_Handle hObj, int xPos); Parameter hObj xPos
Handle of edit field. Character position to set cursor to.
Meaning
Add. information
The character position works as follows: 0: left of the first (leftmost) character, 1: between the first and second characters, 2: between the second and third characters, and so on.
EDIT_SetCursorAtPixel()
Description
Sets the edit widget cursor to a specified pixel position.
Prototype
void EDIT_SetCursorAtPixel(EDIT_Handle hObj, int Pos); Parameter hObj Pos
Handle of edit field. Pixel position to set cursor to.
Meaning
EDIT_SetDecMode()
Description
Enables the decimal edit mode of the edit field. The given value can be modified in the given range.
Prototype
void EDIT_SetDecMode(EDIT_Handle hEdit, I32 Value, I32 Min, I32 Max, int Shift, U8 Flags); Parameter hObj Value Min Max Shift Flags
Handle of edit field. Value to be modified. Minimum value. Maximum value. If > 0 it specifies the position of the decimal point. See table below.
Meaning
2002-2007 Micrium
417
EDIT_SetDefaultBkColor()
Description
Sets the default background color used for edit widgets.
Prototype
void EDIT_SetDefaultBkColor(unsigned int Index, GUI_COLOR Color); Parameter Index Color
(see table below) Color to be used.
Meaning
EDIT_SetDefaultFont()
Description
Sets the default font used for edit fields.
Prototype
void EDIT_SetDefaultFont(const GUI_FONT* pFont); Parameter pFont Meaning
Pointer to the font to be set as default.
EDIT_SetDefaultTextAlign()
Description
Sets the default text alignment for edit fields.
Prototype
void EDIT_SetDefaultTextAlign(int Align); Parameter Align Meaning
Default text alignment. For details please refer to
GUI_SetTextAlign() .
EDIT_SetDefaultTextColor()
Description
Sets the default text color used for edit widgets.
Prototype
void EDIT_SetDefaultTextColor(unsigned int Index, GUI_COLOR Color); Parameter Index Color
Has to be 0, reserved for future use. Color to be used.
Meaning
2002-2007 Micrium
418
CHAPTER 15
EDIT_SetFloatMode()
Description
Enables the floating point edit mode of the edit field. The given value can be modified in the given range.
Prototype
void EDIT_SetFloatMode(EDIT_Handle hObj, float Value, float Min, float Max, int Shift, U8 Flags); Meaning
Handle of edit field. Value to be modified. Minimum value. Maximum value. Number of post decimal positions. See table below.
Permitted values for parameter Flags ("OR" combinable) 0 (default) GUI_EDIT_SIGNED GUI_EDIT_SUPPRESS_LEADING_ZEROES
Edit in normal mode, sign is only displayed if the value is negative "+" and "-" sign is displayed. Does not show leading zeroes.
EDIT_SetFloatValue
Description
The function can be used to set the floating point value of the edit field if working in floating point mode.
Prototype
void EDIT_SetFloatValue(EDIT_Handle hObj, float Value); Parameter hObj Value
Handle of edit field. New floating point value of the edit field.
Meaning
Add. Information
The use of this function makes only sense if the edit field works in floating point mode. If working in text mode the function has no effect. If working in binary, decimal or hexadecimal mode the behavior of the edit field is undefined.
EDIT_SetFont()
Description
Sets the edit field font.
2002-2007 Micrium
419
Prototype
void EDIT_SetFont(EDIT_Handle hObj, const GUI_FONT* pfont); Parameter hObj pFont
Handle of edit field. Pointer to the font.
Meaning
EDIT_SetHexMode()
Description
Enables the hexadecimal edit mode of the edit field. The given value can be modified in the given range.
Prototype
void EDIT_SetHexMode(EDIT_Handle hObj, U32 Value, U32 Min, U32 Max); Parameter hObj Value Min Max
Handle of edit field. Value to be modified. Minimum value. Maximum value.
Meaning
EDIT_SetInsertMode
Description
Enables or disables the insert mode of the edit widget.
Prototype
int EDIT_SetInsertMode(EDIT_Handle hObj, int OnOff); Parameter hObj OnOff
Handle of edit field. See table below.
Meaning
Return value
Returns the previous insert mode state.
Add. Information
The use of this function makes only sense if the edit widget operates in text mode or in any user defined mode. If working in hexadecimal, binary, floating point or decimal mode the use of this function has no effect except that it changes the appearance of the cursor.
2002-2007 Micrium
420
CHAPTER 15
EDIT_SetMaxLen()
Description
Sets the maximum number of characters to be edited by the given edit field.
Prototype
void EDIT_SetMaxLen(EDIT_Handle hObj, int MaxLen); Parameter hObj MaxLen
Handle of edit field. Number of characters.
Meaning
EDIT_SetpfAddKeyEx
Description
Sets the function pointer which is used by the EDIT widget to call the function which is responsible for adding characters.
Prototype
void EDIT_SetpfAddKeyEx(EDIT_Handle hObj, tEDIT_AddKeyEx * pfAddKeyEx); Parameter hObj pfAddKeyEx
Handle of edit field. Function pointer to the function to be used to add a character.
Meaning
Add. Information
If working in text mode (default) or one of the modes for editing values, the edit widget uses its own routines to add a character. The use of this function only makes sense if the default behavior of the edit widget needs to be changed. If a function pointer has been set with this function the application program is responsible for the contents of the text buffer.
EDIT_SetSel
Before After
Description
Used to set the current selection of the edit field.
2002-2007 Micrium
421
Prototype
void EDIT_SetSel(EDIT_Handle hObj, int FirstChar, int LastChar); Parameter hObj FirstChar LastChar
Handle of edit field. Zero based index of the first character to be selected. -1 if no character should be selected. Zero based index of the last character to be selected. -1 if all characters from the first character until the last character should be selected.
Meaning
Add. Information
Selected characters are usually displayed in reverse. Setting the cursor position deselects all characters.
Sample
EDIT_SetSel(0, -1) /* Selects all characters of the widget */ EDIT_SetSel(-1, 0) /* Deselect all characters */ EDIT_SetSel(0, 2) /* Selects the first 3 characters */
EDIT_SetText()
Description
Sets the text to be displayed in the edit field.
Prototype
void EDIT_SetText(EDIT_Handle hObj, const char* s) Parameter hObj s
Handle of edit field. Text to display.
Meaning
EDIT_SetTextAlign()
Description
Sets the text alignment of the edit field.
Prototype
void EDIT_SetTextAlign(EDIT_Handle hObj, int Align); Parameter hObj Align
Handle of edit field. Text alignment to be set (see
Meaning GUI_SetTextAlign() )
EDIT_SetTextColor()
Description
Sets the edit fields text color.
Prototype
void EDIT_SetTextColor(EDIT_Handle hObj, unsigned int Index,
2002-2007 Micrium
422
CHAPTER 15
Meaning
EDIT_SetTextMode()
Description
Sets the edit mode of the widget back to text mode.
Prototype
void EDIT_SetTextMode(EDIT_Handle hEdit); Parameter hObj
Handle of widget.
Meaning
Add. information
If one of the functions EDIT_SetBinMode(), EDIT_SetDecMode(), EDIT_SetFloatMode() or EDIT_SetHexMode() has been used to set the edit field to one of the numeric edit modes, this function sets the edit mode back to text mode. It also clears the contents of the widget.
EDIT_SetUlongMode()
Description
Enables the unsigned long decimal edit mode of the edit field. The given value can be modified in the given range.
Prototype
void EDIT_SetUlongMode(EDIT_Handle hEdit, U32 Value, U32 Min, U32 Max); Parameter hObj Value Min Max
Handle of edit field. Value to be modified. Minimum value. Maximum value.
Meaning
EDIT_SetValue()
Description
Sets the current value of the edit field. Only useful if binary, decimal or hexadecimal edit mode is set.
2002-2007 Micrium
423
Prototype
void EDIT_SetValue(EDIT_Handle hObj, I32 Value); Parameter hObj Value
Handle of edit field. New value.
Meaning
GUI_EditBin()
Description
Edits a binary value at the current cursor position.
Prototype
U32 GUI_EditBin(U32 Value, U32 Min, U32 Max, int Len, int xsize); Parameter Value Min Max Len xsize
Value to be modified. Minimum value. Maximum value. Number of digits to edit. Pixel-size in X of the edit field.
Meaning
Return value
The new value will be returned if <ENTER> is pressed. If <ESC> is pressed, the old value is returned.
Add. Information
The routine returns after pressing <ENTER> or <ESC>. The contents of the given text will be modified only if <ENTER> is pressed.
GUI_EditDec()
Description
Edits a decimal value at the current cursor position.
Prototype
U32 GUI_EditDec(I32 Value, I32 Min, I32 Max, int Len, int xsize, int Shift, U8 Flags); Parameter Value Min Max Len xsize Shift Flags
Value to be modified. Minimum value. Maximum value. Number of digits to edit. Pixel-size in X of edit field. If > 0 it specifies the position of the decimal point. See
Meaning
EDIT_SetDecMode() .
2002-2007 Micrium
424
CHAPTER 15
Return value
The new value will be returned if <ENTER> is pressed. If <ESC> is pressed, the old value is returned.
Add. Information
The routine returns after pressing <ENTER> or <ESC>. The contents of the given text will be modified only if <ENTER> is pressed.
GUI_EditHex()
Description
Edits a hexadecimal value at the current cursor position.
Prototype
U32 GUI_EditHex(U32 Value, U32 Min, U32 Max, int Len, int xsize); Parameter Value Min Max Len xsize
Value to be modified. Minimum value. Maximum value. Number of digits to edit. Pixel-size in X of the edit field.
Meaning
Return value
The new value will be returned if <ENTER> is pressed. If <ESC> is pressed, the old value is returned.
Add. Information
The routine returns after pressing <ENTER> or <ESC>. The contents of the given text will be modified only if <ENTER> is pressed.
GUI_EditString()
Description
Edits a string at the current cursor position.
Prototype
void GUI_EditString(char * pString, int Len, int xsize); Parameter pString Len xsize
Pointer to the string to be edited. Maximum number of characters. Pixel-size in X of the edit field.
Meaning
Add. Information
The routine returns after pressing <ENTER> or <ESC>. The contents of the given text will be modified only if <ENTER> is pressed.
2002-2007 Micrium
425
15.7.5 Example
The following example demonstrates the use of the EDIT widget. It is available as WIDGET_Edit.c in the samples shipped with C/GUI:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ***** C/GUI - Graphical user interface for embedded applications **** C/GUI is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with a license and should not be redistributed in any way. We appreciate your understanding and fairness. ---------------------------------------------------------------------File : WIDGET_Edit.c Purpose : Example demonstrating the use of a EDIT widget ---------------------------------------------------------------------*/ #include "GUI.h" #include "EDIT.h" /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _DemoEdit * Edit a string until ESC or ENTER is pressed */ static void _DemoEdit(void) { EDIT_Handle hEdit; char aBuffer[28]; int Key; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_Edit - Sample", 160, 5); GUI_SetFont(&GUI_Font8x16); GUI_DispStringHCenterAt("Use keyboard to modify string...", 160, 90); /* Create edit widget */ hEdit = EDIT_Create( 50, 110, 220, 25, , sizeof(aBuffer), 0 ); /* Modify edit widget */ EDIT_SetText(hEdit, "Press <ENTER> when done..."); EDIT_SetFont(hEdit, &GUI_Font8x16); EDIT_SetTextColor(hEdit, 0, GUI_RED); /* Set keyboard focus to edit widget */ WM_SetFocus(hEdit); /* Handle keyboard until ESC or ENTER is pressed */ do { WM_Exec(); Key = GUI_GetKey(); } while ((Key != GUI_KEY_ENTER) && (Key != GUI_KEY_ESCAPE)); /* Fetch result from edit widget */ if (Key == GUI_KEY_ENTER) { EDIT_GetText(hEdit, aBuffer, sizeof(aBuffer)); } /* Delete the edit widget */ EDIT_Delete(hEdit); GUI_ClearRect(0, 50, 319, 239); /* Display the changed string */ User's & reference manual for C/GUI 2002-2007 Micrium
426
CHAPTER 15
if (Key == GUI_KEY_ENTER) { GUI_Delay(250); GUI_DispStringHCenterAt("The string you have modified is:", 160, 90); GUI_DispStringHCenterAt(aBuffer, 160, 110); GUI_Delay(3000); GUI_ClearRect(0, 50, 319, 239); } GUI_Delay(500); } /******************************************************************* * * MainTask * * Demonstrates the use of a EDIT widget * ******************************************************************** */ void MainTask(void) { GUI_Init(); while (1) { _DemoEdit(); } }
2002-2007 Micrium
427
You can attach predefined buttons to the title bar as seen below or you can attach your own buttons to a title bar: Explanation Frame window
Frame window with minimize-, maximize- and close button in maximized state.
Frame window with minimize-, maximize- and close button in minimized state
2002-2007 Micrium
428
CHAPTER 15
Title bar
Client window
The frame window actually consists of 2 windows; the main window and a child window. The child window is called Client window. It is important to be aware of this when dealing with callback functions: There are 2 windows with 2 different callback functions. When creating child windows, these child windows are typically created as children of the client window; their parent is therefor the client window. Detail B H D Title bar Client window Description
Border size of the frame window. The default size of the border is 3 pixels. Height of the title bar. Depends on the size of the used font for the title. Spacing between title bar and client window. (1 pixel) The title bar is part of the frame window and not a separate window. The client window is a separate window created as a child window of the frame window.
2002-2007 Micrium
429
Macro FRAMEWIN_ALLOW_DRAG_ON_FRAME FRAMEWIN_BARCOLOR_ACTIVE_DEFAULT FRAMEWIN_BARCOLOR_INACTIVE_DEFAULT FRAMEWIN_BORDER_DEFAULT FRAMEWIN_CLIENTCOLOR_DEFAULT FRAMEWIN_DEFAULT_FONT FRAMEWIN_FRAMECOLOR_DEFAULT FRAMEWIN_IBORDER_DEFAULT FRAMEWIN_TITLEHEIGHT_DEFAULT
1
Default
Explanation
Allows dragging the widget on the surrounding frame. Title bar color, active state. Title bar color, inactive state. Outer border width, in pixels. Color of client window area. Frame color. Inner border width, in pixels. Default height of title bar.
2002-2007 Micrium
430
CHAPTER 15
Routine FRAMEWIN_Minimize() FRAMEWIN_OwnerDraw() FRAMEWIN_Restore() FRAMEWIN_SetActive() FRAMEWIN_SetBarColor() FRAMEWIN_SetBorderSize() FRAMEWIN_SetClientColor() FRAMEWIN_SetDefaultBarColor() FRAMEWIN_SetDefaultBorderSize() FRAMEWIN_SetDefaultClientColor() FRAMEWIN_SetDefaultFont() FRAMEWIN_SetDefaultTextColor() FRAMEWIN_SetDefaultTitleHeight() FRAMEWIN_SetFont() FRAMEWIN_SetMoveable() FRAMEWIN_SetOwnerDraw() FRAMEWIN_SetResizeable() FRAMEWIN_SetText() FRAMEWIN_SetTextAlign() FRAMEWIN_SetTextColor() FRAMEWIN_SetTextColorEx() FRAMEWIN_SetTitleHeight() FRAMEWIN_SetTitleVis()
Explanation
Hides the client area of the frame window. Default function for drawing the title bar. Restores a minimized or maximized frame window. Sets the state of the frame window. (Obsolete) Sets the color of the title bar. Sets the border size of the frame window. Sets the color of the client area Sets the default color of the title bar Sets the default border size Sets the default color of the client area. Sets the default font used for the title bar. Sets the default text color of the title. Sets the default height of the title bar Selects the font used for the title text. Sets the frame window to a moveable/non-moveable state. Enables the frame window to be owner drawn. Sets the frame window to resizable state. Sets the title text. Sets the alignment of the title text. Sets the color(s) for the title text. Sets the color(s) for the title text. Sets the height of the title bar. Sets the visibility flag of the title bar
FRAMEWIN_AddButton()
Before After
Description
Adds a button to the title bar of the frame window.
Prototype
WM_HWIN FRAMEWIN_AddButton(FRAMEWIN_Handle hObj, int Flags, int Off, int Id); Parameter hObj
Handle of frame window.
Meaning
2002-2007 Micrium
431
Meaning
X-offset used to create the BUTTON widget ID of the BUTTON widget
Return value
Handle of the BUTTON widget.
Add. information
The button will be created as a child window from the frame window. So the window manager keeps sure it will be deleted when the frame window will be deleted. The button can be created at the left side or at the right side of the title bar depending on the parameter Flags. The parameter Offset specifies the space between the button and the border of the frame window or the space between the previous created button.
FRAMEWIN_AddCloseButton()
Before After
Description
Adds a close button to the title bar of the frame window.
Prototype
WM_HWIN FRAMEWIN_AddCloseButton(FRAMEWIN_Handle hObj, int Flags, int Off); Parameter hObj Flags Off
Handle of frame window. (see table below) X-offset used to create the BUTTON widget
Meaning
Return value
Handle of the close button.
2002-2007 Micrium
432
CHAPTER 15
Add. information
When the user presses the close button the frame window and all its children will be deleted.
FRAMEWIN_AddMaxButton()
Before After Maximized
Description
Adds a maximize button to the title bar of the frame window.
Prototype
WM_HWIN FRAMEWIN_AddMaxButton(FRAMEWIN_Handle hObj, int Flags, int Off); Parameter hObj Flags Off
Handle of frame window. (see table below) X-offset used to create the BUTTON widget
Meaning
Return value
Handle of the maximize button.
Add. information
When the user presses the maximize button the first time the frame window will be enlarged to the size of its parent window. The second use of the button will reduce the frame window to its old size and restores the old position.
2002-2007 Micrium
433
FRAMEWIN_AddMenu()
Before After
Description
Adds the given menu to a frame window. The menu is shown below the title bar.
Prototype
void FRAMEWIN_AddMenu(FRAMEWIN_Handle hObj, WM_HWIN hMenu); Parameter hObj hMenu
Handle of frame window. Handle of menu widget to be added.
Meaning
Add. information
The added menu is attached as a child of the frame window. If the frame window has been created with a callback routine, the function makes sure, that the WM_MENU messages are passed to the client window of the frame window.
2002-2007 Micrium
434
CHAPTER 15
FRAMEWIN_AddMinButton()
Before After Minimized window
Description
Adds a minimize button to the title bar of the frame window.
Prototype
WM_HWIN FRAMEWIN_AddMinButton(FRAMEWIN_Handle hObj, int Flags, int Off); Parameter hObj Flags Off
Handle of frame window. (see table below) X-offset used to create the BUTTON widget
Meaning
Return value
Handle of the minimize button.
Add. information
When the user presses the minimize button the first time the client area of the frame window will be hidden and only the title bar remains visible. The second use of the button will restore the frame window to its old size.
FRAMEWIN_Create()
(Obsolete, FRAMEWIN_CreateEx should be used instead)
Description
Creates a FRAMEWIN widget of a specified size at a specified location.
Prototype
FRAMEWIN_Handle FRAMEWIN_Create(const char* pTitle, WM_CALLBACK* cb, int Flags, int x0, int y0,
2002-2007 Micrium
435
Meaning
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Leftmost pixel of the frame window (in parent coordinates). Topmost pixel of the frame window (in parent coordinates). Horizontal size of the frame window (in pixels). Vertical size of the frame window (in pixels).
Return value
Handle for the created FRAMEWIN widget; 0 if the routine fails.
FRAMEWIN_CreateAsChild()
(Obsolete, FRAMEWIN_CreateEx should be used instead)
Description
Creates a FRAMEWIN widget as a child window.
Prototype
FRAMEWIN_Handle FRAMEWIN_CreateAsChild(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, const char* pText, WM_CALLBACK* cb, int Flags); Parameter x0 y0 xsize ysize hParent pText cb Flags Meaning
X-position of the frame window relative to the parent window. Y-position of the frame window relative to the parent window. Horizontal size of the frame window (in pixels). Vertical size of the frame window (in pixels). Handle of parent window. Text to be displayed in the title bar. Pointer to callback routine. Window create flags (see
FRAMEWIN_Create() ).
Return value
Handle for the created FRAMEWIN widget; 0 if the routine fails.
FRAMEWIN_CreateEx()
Description
Creates a FRAMEWIN widget of a specified size at a specified location.
Prototype
FRAMEWIN_Handle FRAMEWIN_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id,
2002-2007 Micrium
436
CHAPTER 15
const char* pTitle, WM_CALLBACK* cb); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id pTitle cb Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new FRAMEWIN widget will be a child of the desktop (top-level window). Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Window ID of the widget. Title displayed in the title bar. Pointer to user callback routine. This user callback routine is called by the window callback routine of the client window.
FRAMEWIN_SetMoveable
Return value
Handle for the created widget; 0 if the routine fails.
Add. information
The user callback routine is typically used for 2 purposes: to paint the client window (if filling with a color is not desired) to react to messages of child windows, typically dialog elements The normal behaviour of the client window is to paint itself, filling the entire window with the client color. If the user callback also fills the client window (or a part of it), it can be desireable to set the client color to GUI_INVALID_COLOR, causing the window callback to not fill the client window. The user callback of the client window does not receive all messages sent to the client window; some system messages are completely handled by the window callback routine and are not passed to the user callback. All notification messages as well as WM_PAINT and all user messages are sent to the user callback routine. The handle received by the user callback is the handle of the frame window (the parent window of the client window), except for the WM_PAINT message, which receives the handle of the client window.
FRAMEWIN_GetActive()
Description
Returns if the given frame window is in active state or not.
2002-2007 Micrium
437
Prototype
GUI_COLOR FRAMEWIN_GetBarColor(FRAMEWIN_Handle hObj, unsigned Index); Parameter hObj
Handle of frame window.
Meaning
Return value
1 if frame window is in active state, 0 if not.
FRAMEWIN_GetBarColor()
Description
Returns the color of the title bar of the given frame window.
Prototype
GUI_COLOR FRAMEWIN_GetBarColor(FRAMEWIN_Handle hObj, unsigned Index); Parameter hObj Index
Handle of frame window. (see table below)
Meaning
Return value
Color of the title bar as RGB value.
FRAMEWIN_GetBorderSize()
Description
Returns the border size of the given frame window.
Prototype
int FRAMEWIN_GetBorderSize(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Return value
The border size of the given frame window.
FRAMEWIN_GetDefaultBarColor()
Description
Returns the default color for title bars in frame windows.
2002-2007 Micrium
438
CHAPTER 15
Prototype
const GUI_COLOR* FRAMEWIN_GetDefaultBarColor(unsigned int Index); Parameter Index
(see table below)
Meaning
Return value
Pointer to the default title bar color used for frame windows in the specified state.
FRAMEWIN_GetDefaultBorderSize()
Description
Returns the default size of a frame window border.
Prototype
int FRAMEWIN_GetDefaultBorderSize(void);
Return value
Default size of a frame window border.
FRAMEWIN_GetDefaultClientColor()
Description
Returns the default color of client areas in frame windows.
Prototype
const GUI_COLOR* FRAMEWIN_GetDefaultClientColor(void);
Return value
Pointer to the default client area color.
FRAMEWIN_GetDefaultFont()
Description
Returns the default font used for frame window captions.
Prototype
const GUI_FONT* FRAMEWIN_GetDefaultFont(void);
Return value
Pointer to the default font used for frame window captions.
FRAMEWIN_GetDefaultTextColor()
Description
Returns the default text color of the title.
2002-2007 Micrium
439
Prototype
GUI_COLOR FRAMEWIN_GetDefaultTextColor(unsigned Index); Parameter Index
(see table below)
Meaning
Return value
Default text color of the title.
FRAMEWIN_GetFont()
Description
Returns a pointer to the font used to draw the title text.
Prototype
const GUI_FONT GUI_UNI_PTR * FRAMEWIN_GetFont(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Return value
Pointer to the font used to draw the title text.
FRAMEWIN_GetText()
Description
Returns the title text.
Prototype
void FRAMEWIN_GetText(FRAMEWIN_Handle hObj, char * pBuffer, int MaxLen); Parameter hObj pBuffer MaxLen
Handle of frame window. Pointer to buffer to be filled with the title text. Buffer size in bytes.
Meaning
Add. information
If the buffer size is smaller than the title text the function copies MaxNum bytes.
FRAMEWIN_GetTextAlign()
Description
Returns the text alignment of the title text.
2002-2007 Micrium
440
CHAPTER 15
Prototype
int FRAMEWIN_GetTextAlign(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Return value
The currently used text alignment. For details about text aligment please refer to the function GUI_SetTextAlign().
FRAMEWIN_GetDefaultTitleHeight()
Description
Returns the default height of title bars in frame windows.
Prototype
int FRAMEWIN_GetDefaultCaptionSize(void);
Return value
Default title bar height. For more informations about the title height please take a look to FRAMEWIN_SetDefaultTitleHeight.
FRAMEWIN_GetTitleHeight()
Description
Returns the height of title bar of the given frame window.
Prototype
int FRAMEWIN_GetTitleHeight(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Return value
The height of title bar of the given frame window. For more informations about the title height please take a look to FRAMEWIN_SetDefaultTitleHeight.
FRAMEWIN_IsMaximized()
Description
Returns if the frame window is maximized or not.
Prototype
int FRAMEWIN_IsMaximized(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Return value
1 if the frame window is maximized, 0 if not.
User's & reference manual for C/GUI 2002-2007 Micrium
441
FRAMEWIN_IsMinimized()
Description
Returns if the frame window is minimized or not.
Prototype
int FRAMEWIN_IsMinimized(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Return value
1 if the frame window is minimized, 0 if not.
FRAMEWIN_Maximize()
Before After
Description
Enlarges a frame window to the size of its parent window.
Prototype
void FRAMEWIN_Maximize(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Add. information
When calling this function the frame window will show the same behavior as when the user presses the maximize button. The frame window will be enlarged to the size of its parent window.
2002-2007 Micrium
442
CHAPTER 15
FRAMEWIN_Minimize()
Before After
Description
Hides the client area of the given frame window.
Prototype
void FRAMEWIN_Minimize(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Add. information
When calling this function the frame window will show the same behavior as when the user presses the minimize button. The client area of the frame window will be hidden and only the title bar remains visible.
FRAMEWIN_OwnerDraw()
Description
Default function for drawing the title bar of a frame window.
Prototypes
int FRAMEWIN_OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo); Parameter pDrawItemInfo
Pointer to a
Add. information
This function is usefull if FRAMEWIN_SetOwnerDrawn() is used. It should be called for all unhandled commands passed to the owner draw function. For more information, refer to the section explaining user drawn widgets and FRAMEWIN_SetOwnerDraw().
2002-2007 Micrium
443
FRAMEWIN_Restore()
Before After
Description
Restores a minimized or maximized frame window to its old size and position.
Prototype
void FRAMEWIN_Restore(FRAMEWIN_Handle hObj); Parameter hObj
Handle of frame window.
Meaning
Add. information
If the given frame window is neither maximized nor minimized the function takes no effect.
FRAMEWIN_SetActive()
Before After
Description
Sets the state of a specified frame window. Depending on the state, the color of the title bar will change.
Prototype
void FRAMEWIN_SetActive(FRAMEWIN_Handle hObj, int State); Parameter hObj State
Handle of frame window. State of frame window (see table below).
Meaning
2002-2007 Micrium
444
CHAPTER 15
Add. information
This function is obsolete. If pointing with a input device to a child of a frame window the frame window will become active automaticly. It is not recomended to use this function. If using this function to set a frame window to active state, it is not warranted that the state becomes inactive if an other frame window becomes active.
FRAMEWIN_SetBarColor()
Before After
Description
Sets the color of the title bar of a specified frame window.
Prototype
void FRAMEWIN_SetBarColor(FRAMEWIN_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of frame window. Index for state of frame window (see table below). Color to be set.
Meaning
FRAMEWIN_SetBorderSize()
Before After
Description
Sets the border size of a specified frame window.
2002-2007 Micrium
445
Prototype
void FRAMEWIN_SetBorderSize(FRAMEWIN_Handle hObj, unsigned Size); Parameter hObj Size
Handle of frame window. New border size of the frame window.
Meaning
FRAMEWIN_SetClientColor()
Before After
Description
Sets the color of the client window area of a specified frame window.
Prototype
void FRAMEWIN_SetClientColor(FRAMEWIN_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of frame window. Color to be set.
Meaning
FRAMEWIN_SetDefaultBarColor()
Description
Sets the default color for title bars in frame windows.
Prototype
void FRAMEWIN_SetDefaultBarColor(unsigned int Index, GUI_COLOR Color); Parameter Index Color
Color to be set.
Meaning
Index for state of frame window (see table below).
FRAMEWIN_SetDefaultBorderSize()
Description
Sets the default border size of frame windows.
2002-2007 Micrium
446
CHAPTER 15
Prototype
void FRAMEWIN_SetDefaultBorderSize(int BorderSize); Parameter BorderSize
Size to be set.
Meaning
FRAMEWIN_SetDefaultClientColor()
Description
Sets the default color for client areas in frame windows.
Prototype
void FRAMEWIN_SetDefaultClientColor(GUI_COLOR Color); Parameter Color
Color to be set.
Meaning
FRAMEWIN_SetDefaultFont()
Description
Sets the default font used to display the title in frame windows.
Prototype
void FRAMEWIN_SetDefaultFont(const GUI_FONT* pFont); Parameter pFont
Pointer to font to be used as default
Meaning
FRAMEWIN_SetDefaultTextColor()
Description
Sets the default text color of the title.
Prototype
void FRAMEWIN_SetDefaultTextColor(unsigned Index, GUI_COLOR Color); Parameter Index Color
(see table below) Color to be used.
Meaning
FRAMEWIN_SetDefaultTitleHeight()
Description
Sets the size in Y for the title bar.
2002-2007 Micrium
447
Prototype
void FRAMEWIN_SetDefaultTitleHeight(int Height); Parameter Height
Size to be set
Meaning
Add. information
The default value of the title height is 0. That means the height of the title depends on the font used to display the title text. If the default value is set to a value > 0 each new frame window will use this height for the title height and not the height of the font of the title.
FRAMEWIN_SetFont()
Before After
Description
Sets the title font.
Prototype
void FRAMEWIN_SetFont(FRAMEWIN_Handle hObj, const GUI_FONT* pfont); Parameter hObj pFont
Handle of frame window. Pointer to the font.
Meaning
FRAMEWIN_SetMoveable()
Description
Sets a frame window to a moveable or fixed state.
Prototype
void FRAMEWIN_SetMoveable(FRAMEWIN_Handle hObj, int State); Parameter hObj State
Handle of frame window. State of frame window (see table below).
Meaning
2002-2007 Micrium
448
CHAPTER 15
Add. information
The default state of a frame window after creation is fixed. Moveable state means, the frame window can be dragged with a pointer input device (PID). To move the frame window, it first needs to be touched with a PID in pressed state in the title area. Moving the pressed PID now moves also the widget. If the config macro FRAMEWIN_ALLOW_DRAG_ON_FRAME is 1 (default), the frame window can also be dragged on the surrounding frame. This works only if the frame window is not in resizable state.
FRAMEWIN_SetOwnerDraw()
Description
Enables the frame window to be owner drawn.
Prototype
void FRAMEWIN_SetOwnerDraw(FRAMEWIN_Handle hObj, WIDGET_DRAW_ITEM_FUNC * pfDrawItem); Parameter hObj pfDrawItem
Handle of frame window. Pointer to owner draw function.
Meaning
Add. information
This function sets a function pointer to a function which will be called by the widget if a frame window has to be drawn. It gives you the possibility to draw a complete customized title bar, not just plain text. pfDrawItem is a pointer to an applicationdefined function of type WIDGET_DRAW_ITEM_FUNC which is explained at the beginning of the chapter.
Example
The following shows a typical owner draw function:
int _OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) { GUI_RECT Rect; char acBuffer[20]; switch (pDrawItemInfo->Cmd) { case WIDGET_ITEM_DRAW: Rect.x0 = pDrawItemInfo->x0 + 1; Rect.x1 = pDrawItemInfo->x1 - 1; Rect.y0 = pDrawItemInfo->y0 + 1; Rect.y1 = pDrawItemInfo->y1; FRAMEWIN_GetText(pDrawItemInfo->hWin, acBuffer, sizeof(acBuffer)); GUI_DrawGradientH(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, GUI_RED, GUI_GREEN); GUI_SetFont(FRAMEWIN_GetFont(pDrawItemInfo->hWin)); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetColor(GUI_YELLOW); GUI_DispStringInRect(acBuffer, &Rect, FRAMEWIN_GetTextAlign(pDrawItemInfo->hWin)); return 0; } return FRAMEWIN_OwnerDraw(pDrawItemInfo); } void CreateFrameWindow(void) { ... FRAMEWIN_SetOwnerDraw(hWin, _OwnerDraw); ... }
2002-2007 Micrium
449
FRAMEWIN_SetResizeable()
Before After
Description
Sets the resizable state of the given frame window.
Prototype
void FRAMEWIN_SetResizeable(FRAMEWIN_Handle hObj, int State); Parameter hObj State
Handle of frame window. 1 if the frame window should be resizable, 0 if not.
Meaning
Add. information
If the frame window is in resizable state its size can be changed by dragging the borders. If a pointer input device points over the border, the cursor will change to a resize cursor (if cursor is on and if optional mouse support is enabled). If pointing to the edge of the border, the X and Y size of the window can be changed simultaneously.
FRAMEWIN_SetText()
Before After
Description
Sets the title text.
2002-2007 Micrium
450
CHAPTER 15
Prototype
void FRAMEWIN_SetText(FRAMEWIN_Handle hObj, const char* s); Parameter hObj s
Handle of frame window. Text to display as the title.
Meaning
FRAMEWIN_SetTextAlign()
Before After
Description
Sets the text alignment of the title bar.
Prototype
void FRAMEWIN_SetTextAlign(FRAMEWIN_Handle hObj, int Align); Parameter hObj Align
Handle of frame window. Alignment attribute for the title (see table below).
Meaning
Permitted values for parameter Align GUI_TA_HCENTER Centers the title (default). Displays the title to the left. GUI_TA_LEFT Displays the title to the right. GUI_TA_RIGHT
Add. information
If this function is not called, the default behavior is to display the text centered.
FRAMEWIN_SetTextColor()
Before After
Description
Sets the color of the title text for both states, active and inactive.
User's & reference manual for C/GUI 2002-2007 Micrium
451
Prototype
void FRAMEWIN_SetTextColor(FRAMEWIN_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of frame window. Color to be set.
Meaning
FRAMEWIN_SetTextColorEx()
Before After
Description
Sets the text color for the given state.
Prototype
void FRAMEWIN_SetTextColorEx(FRAMEWIN_Handle hObj, unsigned Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of frame window. (see table below) Color to be used.
Meaning
FRAMEWIN_SetTitleHeight()
Before After
Description
Sets the height of the title bar.
2002-2007 Micrium
452
CHAPTER 15
Prototype
int FRAMEWIN_SetTitleHeight(FRAMEWIN_Handle hObj, int Height); Parameter hObj Height
Handle of frame window. Height of the title bar.
Meaning
Add. information
Per default the height of the title bar depends on the size on the font used to display the title text. When using FRAMEWIN_SetTitleHeight the height will be fixed to the given value. Changes of the font takes no effect concerning the height of the title bar. A value of 0 will restore the default behavior.
FRAMEWIN_SetTitleVis()
Before After
Description
Sets the visibility flag of the title bar.
Prototype
void FRAMEWIN_SetTitleVis(FRAMEWIN_Handle hObj, int Show); Parameter hObj Show
Handle of frame window. 1 for visible (default), 0 for hidden
Meaning
2002-2007 Micrium
453
Border
Frame
Grid
Data objects
Data area
Scrollbar(s)
Scale objects
The following table explains the details of the diagram above: Detail Border Frame Grid Data area Data object(s) Application defined graphic Description
The optional border is part of the graph widget. A thin line around the data area, part of the graph widget. Shown in the background of the data area, part of the graph widget. Area, in which grid and data objects are shown. For each curve one data object should be added to the graph widget. An application defined callback function can be used to draw any application defined text and/or graphics.
2002-2007 Micrium
454
CHAPTER 15
Detail Scrollbar(s)
Description
If the range of the data object is bigger than the data area of the graph widget, the graph widget can automatically show a horizontal and/or a vertical scrollbar.
Scale object(s) Horizontal and vertical scales can be attached to the graph widget. X-Size of the data area. X-Size Y-Size of the data area. Y-Size
Once attached to the graph widget the data and scale objects need not to be deleted by the application. This is done by the graph widget.
Example
The following shows a small sample how to create and delete a graph widget:
GRAPH_DATA_Handle hData; GRAPH_SCALE_Handle hScale; WM_HWIN hGraph; hGraph = GRAPH_CreateEx(10, 10, 216, 106, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_GRAPH0); hData = GRAPH_DATA_YT_Create(GUI_DARKGREEN, NumDataItems, aData0, MaxNumDataItems); GRAPH_AttachData(hGraph, hData); hScale = GRAPH_SCALE_Create(28, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 20); GRAPH_AttachScale(hGraph, hScale); /* Do somting with the widget... */ WM_DeleteWindow(hGraph);
2002-2007 Micrium
455
15.9.4.1 GRAPH_DATA_XY
This data object is used to show curves which consist of an array of points. The object data is drawn as a polyline. A typical application for using this data object is drawing a function graph.
15.9.4.2 GRAPH_DATA_YT
This data object is used to show curves with one Y-value for each X-position on the graph. A typical application for using this data object is showing a curve with with continuously updated measurement values.
2002-2007 Micrium
456
CHAPTER 15
Macro GRAPH_BKCOLOR_DEFAULT GRAPH_BORDERCOLOR_DEFAULT GRAPH_FRAMECOLOR_DEFAULT GRAPH_GRIDCOLOR_DEFAULT GRAPH_GRIDSPACING_X_DEFAULT GRAPH_GRIDSPACING_Y_DEFAULT GRAPH_BORDER_L_DEFAULT GRAPH_BORDER_T_DEFAULT GRAPH_BORDER_R_DEFAULT GRAPH_BORDER_B_DEFAULT
Default
GUI_BLACK 0xC0C0C0 GUI_WHITE 50 50 0 0 0 0
Explanation
Default background color of the data area. Default background color of the border. Default color of the thin frame line. Default horizontal spacing of the grid. Default vertical spacing of the grid. Default size of the left border. Default size of the top border. Default size of the right border. Default size of the bottom border.
Macro
Default
Explanation
Default text color. Default font used to draw the values.
Explanation
2002-2007 Micrium
457
Explanation
Sets the vertical range of the graph widget. Sets the user callback function.
GRAPH_DATA_YT related routines Adds one data item to the data object. GRAPH_DATA_YT_AddValue() Creates a GRAPH_DATA_YT object. GRAPH_DATA_YT_Create() GRAPH_DATA_YT_SetOffY()
Sets a vertical offset for drawing the data.
GRAPH_DATA_XY related routines Adds one point to the data object. GRAPH_DATA_XY_AddPoint() Creates a GRAPH_DATA_YT object. GRAPH_DATA_XY_Create() GRAPH_DATA_XY_SetLineStyle() Sets the line style used to draw the data. Sets a horizontal offset for drawing the data. GRAPH_DATA_XY_SetOffX() Sets a vertical offset for drawing the data. GRAPH_DATA_XY_SetOffY() Sets the pen size used to draw the data. GRAPH_DATA_XY_SetPenSize() Scale related routines Creates a scale object. GRAPH_SCALE_Create() GRAPH_SCALE_SetFactor() GRAPH_SCALE_SetFixed() GRAPH_SCALE_SetFont() GRAPH_SCALE_SetNumDecs() GRAPH_SCALE_SetOff() GRAPH_SCALE_SetPos() GRAPH_SCALE_SetTextColor() GRAPH_SCALE_SetTickDist()
Sets a calculation factor used to calculate from pixels to the desired unit. Avoids scrolling of the scale. Sets the font used to draw the numbers. Sets the number of digits of the fractional portion. Sets an optional offset which is added to the numbers. Sets the horizontal or vertical position of the scale. Sets the text color of the scale. Sets the distance in pixels between the tick marks.
Description
Attaches a data object to an existing graph widget.
2002-2007 Micrium
458
CHAPTER 15
Prototype
void GRAPH_AddGraph(GRAPH_Handle hObj, GRAPH_DATA_Handle hData); Parameter hObj hData
Handle of widget Handle of the data object to be added to the widget. The data object should be created with GRAPH_DATA_YT_Create() or GRAPH_DATA_XY_Create()
Meaning
Add. Information
Once attached to a graph widget the application needs not to destroy the data object. The graph widget deletes all attached data objects when it is deleted. For details about how to create data objects please refer to the functions GRAPH_DATA_YT_Create() and GRAPH_DATA_XY_Create().
GRAPH_AttachScale()
Before After
Description
Attaches a scale object to an existing graph widget.
Prototype
void GRAPH_AttachScale(GRAPH_Handle hObj, GRAPH_SCALE_Handle hScale); Parameter hObj hScale
Handle of widget Handle of the scale to be added.
Meaning
Add. Information
Once attached to a graph widget the application needs not to destroy the scale object. The graph widget deletes all attached scale objects when it is deleted. For details about how to create scale objects please refer to the function GRAPH_SCALE_Create().
GRAPH_CreateEx()
Description
Creates a new graph widget.
Prototype
GRAPH_Handle GRAPH_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
2002-2007 Micrium
459
int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new button window will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Window Id of the widget.
Return value
Handle for the created graph widget; 0 if the routine fails.
GRAPH_DetachData()
Description
Detaches a data object from a graph widget.
Prototype
void GRAPH_DetachData(GRAPH_Handle hObj, GRAPH_DATA_Handle hData); Parameter hObj hData
Handle of widget Handle of the data object to be detached from the widget.
Meaning
Add. Information
Once detached from a graph widget the application needs to destroy the data object. Detaching a data object does not delete it. For more details about deleting data objects please refer to GRAPH_DATA_YT_Delete() and GRAPH_DATA_XY_Delete().
GRAPH_DetachScale()
Description
Detaches a scale object from a graph widget.
2002-2007 Micrium
460
CHAPTER 15
Prototype
void GRAPH_DetachScale(GRAPH_Handle hObj, GRAPH_SCALE_Handle hScale); Parameter hObj hScale
Handle of widget Handle of the scale object to be detached from the widget.
Meaning
Add. Information
Once detached from a graph widget the application needs to destroy the scale object. Detaching a scale object does not delete it. For more details about deleting scale objects please refer to GRAPH_SCALE_Delete().
GRAPH_SetBorder()
Before After
Description
Sets the left, top, right and bottom border of the given graph widget.
Prototype
void GRAPH_SetBorder(GRAPH_Handle hObj, unsigned BorderL, unsigned BorderT, unsigned BorderR, unsigned BorderB); Parameter hObj BorderL BorderT BorderR BorderB
Handle of widget. Size in pixels from the left border. Size in pixels from the top border. Size in pixels from the right border. Size in pixels from the bottom border.
Meaning
Add. Information
The border size is the number of pixels between the widget effect frame and the data area of the graph widget. The frame, the thin line around the data area, is only visible if the border size is at least one pixel. For details about how to set the color of the border and the thin frame please refer to GRAPH_SetColor().
2002-2007 Micrium
461
GRAPH_SetColor()
Before After
Description
Sets the desired color of the given graph widget.
Prototype
GUI_COLOR GRAPH_SetColor(GRAPH_Handle hObj, GUI_COLOR Color, unsigned Index); Parameter hObj Color Index
Handle of widget. Color to be used for the desired item. (see table below)
Meaning
Return value
Previous color used for the desired item.
GRAPH_SetGridDistX(), GRAPH_SetGridDistY()
Before After
Description
These functions set the distance from one grid line to the next.
Prototypes
unsigned GRAPH_SetGridDistX(GRAPH_Handle hObj, unsigned Value);
2002-2007 Micrium
462
CHAPTER 15
Meaning
Return value
Previous grid line distance.
Add. Information
The first vertical grid line is drawn at the leftmost position of the data area and the first horizontal grid line is drawn at the bottom position of the data area, except an offset is used.
GRAPH_SetGridFixedX()
Description
Fixes the grid in X-axis.
Prototype
unsigned GRAPH_SetGridFixedX(GRAPH_Handle hObj, unsigned OnOff); Parameter hObj OnOff
Handle of widget. 1 if grid should be fixed in X-axis, 0 if not (default).
Meaning
Return value
Previous value used
Add. Information
In some situations it can be useful to fix the grid in X-axis. A typical application would be a YT-graph, to which continuously new values are added and horizontal scrolling is possible. In this case it could be desirable to fix the grid in the background. For details about how to activate scrolling for a graph widget please refer to the functions GRAPH_SetVSizeX() and GRAPH_SetVSizeY().
GRAPH_SetGridOffY()
Before After
Description
Adds an offset used to show the horizontal grid lines.
2002-2007 Micrium
463
Prototype
unsigned GRAPH_SetGridOffY(GRAPH_Handle hObj, unsigned Value); Parameter hObj Value
Handle of widget. Offset to be used.
Meaning
Return value
Previous offset used to draw the horizontal grid lines.
Add. Information
When rendering the grid the widget starts drawing the horizontal grid lines from the bottom of the data area and uses the current spacing. In case of a zero point in the middle of the Y-axis it could happen, that there is no grid line in the middle. In this case the grid can be shifted in Y-axis by adding an offset with this function. A positive value shifts the grid down and negative values shifts it up. For details about how to set the grid spacing please refer to the functions GRAPH_SetGridSpacingX() and GRAPH_SetGridSpacingY().
GRAPH_SetGridVis()
Before After
Description
Sets the visibility of the grid lines.
Prototype
unsigned GRAPH_SetGridVis(GRAPH_Handle hObj, unsigned OnOff); Parameter hObj OnOff
Handle of widget. 1 if the grid should be visible, 0 if not (default).
Meaning
Return value
Previous value of the grid visibility.
2002-2007 Micrium
464
CHAPTER 15
GRAPH_SetLineStyleH(), GRAPH_SetLineStyleV
Before After
Description
These functions are used to set the line style used to draw the horizontal and vertical grid lines.
Prototypes
U8 GRAPH_SetLineStyleH(GRAPH_Handle hObj, U8 LineStyle); U8 GRAPH_SetLineStyleV(GRAPH_Handle hObj, U8 LineStyle); Parameter hObj LineStyle
Handle of widget. Line style to be used. For details about the supported line styles please refer to the function GUI_SetLineStyle() . Default is GUI_LS_SOLID.
Meaning
Return value
Previous line style used to draw the horizontal/vertical grid lines.
Add. Information
Please note that using other styles than GUI_LS_SOLID will need more time to show the grid.
2002-2007 Micrium
465
GRAPH_SetVSizeX(), GRAPH_SetVSizeY()
Before After
Description
The functions set the virtual size in X and Y-axis.
Prototypes
unsigned GRAPH_SetVSizeX(GRAPH_Handle hObj, unsigned Value); unsigned GRAPH_SetVSizeY(GRAPH_Handle hObj, unsigned Value); Parameter hObj Value
Handle of widget. Virtual size in pixels in X or Y axis.
Meaning
Return value
Previous virtual size of the widgets data area in X or Y-axis.
Add. Information
If the widgets virtual size is bigger than the visible size of the data area, the widget automatically shows a scrollbar. If for example a data object, created by the function GRAPH_DATA_YT_Create(), contains more data than can be shown in the data area, the function GRAPH_SetVSizeX() can be used to enable scrolling. A function call like GRAPH_SetVSizeX(NumDataItems) enables the horizontal scrollbar, provided that the number of data items is bigger than the X-size of the visible data area.
2002-2007 Micrium
466
CHAPTER 15
GRAPH_SetUserDraw()
Before After
Description
Sets the user draw function. This function is called by the widget during the drawing process to give the application the possibility to draw user defined data.
Prototype
void GRAPH_SetUserDraw(GRAPH_Handle hObj, void (* pUserDraw)(WM_HWIN hObj, int Stage)); Parameter hObj pUserDraw
Handle of widget Pointer to application function to be called by the widget during the drawing process.
Meaning
Add. Information
The user draw function is called at the beginning after filling the background of the data area and after drawing all graph items like described at the beginning of the chapter. On the first call the clipping region is limited to the data area. On the last call it is limited to the complete graph widget area except the effect frame.
Example
The following small sample shows the use of a user draw function:
static void _UserDraw(WM_HWIN hWin, int Stage) { switch (Stage) { case GRAPH_DRAW_FIRST: /* Draw for example a user defined grid... */ break; case GRAPH_DRAW_LAST: /* Draw for example a user defined scale or additional text... */ break; } } static void _CreateGraph(void) { WM_HWIN hGraph; hGraph = GRAPH_CreateEx(10, 10, 216, 106, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_GRAPH0); GRAPH_SetUserDraw(hGraph, _UserDraw); /* Enable user draw */ ... } User's & reference manual for C/GUI 2002-2007 Micrium
467
GRAPH_DATA_YT_AddValue()
Before After
Description
Adds a new data item to a GRAPH_DATA_YT object.
Prototype
void GRAPH_DATA_YT_AddValue(GRAPH_DATA_Handle hDataObj, I16 Value); Parameter hDataObj Value
Handle of data object. Value to be added to the data object.
Meaning
Add. Information
The given data value is added to the data object. If the data object is full, that means it contains as many data items as specified in parameter MaxNumItems during the creation, it first shifts the data items by one before adding the new value. So the first data item is shifted out when adding a data item to a full object. The value 0x7FFF can be used to handle invalid data values. These values are excluded when drawing the graph. The following screenshot shows a graph with 2 gaps of invalid data:
GRAPH_DATA_YT_Create()
Description
Creates a data object of type GRAPH_DATA_YT.
2002-2007 Micrium
468
CHAPTER 15
Prototype
GRAPH_DATA_Handle GRAPH_DATA_YT_Create(GUI_COLOR Color, unsigned MaxNumItems, I16 * pData, unsigned NumItems); Parameter Color MaxNumItems pData NumItems
Color to be used to draw the data. Maximum number of data items. Pointer to data to be added to the object. The pointer should point to an array of values. Number of data items to be added.
Meaning
I16
Return value
Handle of data object if creation was successful, otherwise 0.
Add. Information
The last data item is shown at the rightmost column of the data area. If a data object contains more data as can be shown in the data area of the graph widget, the function GRAPH_SetVSizeX() can be used to show a scrollbar which makes it possible to scroll through large data objects. Once attached to a graph widget a data object needs not to be deleted by the application. This is automatically done during the deletion of the graph widget.
GRAPH_DATA_YT_Delete()
Description
Deletes the given data object.
Prototype
void GRAPH_DATA_YT_Delete(GRAPH_DATA_Handle hDataObj); Parameter hDataObj
Data object to be deleted.
Meaning
Add. Information
When a graph widget is deleted it deletes all currently attached data objects. So the application needs only to delete unattached data objects.
2002-2007 Micrium
469
GRAPH_DATA_YT_SetOffY()
Before After
Description
Sets a vertical offset used to draw the object data.
Prototype
void GRAPH_DATA_YT_SetOffY(GRAPH_DATA_Handle hDataObj, int Off); Parameter hDataObj Off
Handle of data object. Vertical offset which should be used to draw the data.
Meaning
Add. Information
The vertical range of data, which is shown by the data object, is the range (0) - (Ysize of data area - 1). In case of using a scroll bar the current scroll position is added to the range.
Example
If for example the visible data range should be -200 to -100 the data needs to be shiftet in positive direction by 200 pixels:
GRAPH_DATA_YT_SetOffY(hDataObj, 200);
2002-2007 Micrium
470
CHAPTER 15
GRAPH_DATA_XY_AddPoint()
Before After
Description
Adds a new data item to a GRAPH_DATA_XY object.
Prototype
void GRAPH_DATA_XY_AddPoint(GRAPH_DATA_Handle hDataObj, GUI_POINT * pPoint); Parameter hDataObj pPoint
Handle of data object. Pointer to a GUI_POINT structure to be added to the data object.
Meaning
Add. Information
The given point is added to the data object. If the data object is full, that means it contains as many points as specified in parameter MaxNumItems during the creation, it first shifts the data items by one before adding the new point. So the first point is shifted out when adding a new point to a full object.
GRAPH_DATA_XY_Create()
Description
Creates a data object of type GRAPH_DATA_XY.
Prototype
GRAPH_DATA_Handle GRAPH_DATA_XY_Create(GUI_COLOR Color, unsigned MaxNumItems, GUI_POINT * pData,
2002-2007 Micrium
471
Meaning
Return value
Handle of data object if creation was successful, otherwise 0.
Add. Information
Once attached to a graph widget a data object needs not to be deleted by the application. This is automatically done during the deletion of the graph widget.
GRAPH_DATA_XY_Delete()
Description
Deletes the given data object.
Prototype
void GRAPH_DATA_XY_Delete(GRAPH_DATA_Handle hDataObj); Parameter hDataObj
Data object to be deleted.
Meaning
Add. Information
When a graph widget is deleted it deletes all currently attached data objects. So the application needs only to delete unattached data objects.
GRAPH_DATA_XY_SetOffX(), GRAPH_DATA_XY_SetOffY()
Before After
Description
Sets a vertical or horizontal offset used to draw the polyline.
Prototype
void GRAPH_DATA_XY_SetOffX(GRAPH_DATA_Handle hDataObj, int Off);
2002-2007 Micrium
472
CHAPTER 15
Meaning
Add. Information
The range of data shown by the data object is (0, 0) - (X-size of data area - 1, Y-size of data area - 1). In case of using scroll bars the current scroll position is added to the respective range. To make other ranges of data visible this functions should be used to set an offset, so that the data is in the visible area.
Example
If for example the visible data range should be (100, -1200) - (200, -1100) the the following offsets need to be used:
GRAPH_DATA_XY_SetOffX(hDataObj, -100); GRAPH_DATA_XY_SetOffY(hDataObj, 1200);
GRAPH_DATA_XY_SetLineStyle()
Before After
Description
Sets the line style used to draw the polyline.
Prototype
void GRAPH_DATA_XY_SetLineStyle(GRAPH_DATA_Handle hDataObj, U8 LineStyle); Parameter hDataObj LineStyle
Handle of data object. New line style to be used. For details about the supported line styles please refer to the function GUI_SetLineStyle() .
Meaning
Limitations
Please note, that only curves with line style GUI_LS_SOLID (default) can be drawn with a pen size >1.
2002-2007 Micrium
473
GRAPH_DATA_XY_SetPenSize()
Before After
Description
Sets the pen size used to draw the polyline.
Prototype
void GRAPH_DATA_XY_SetPenSize(GRAPH_DATA_Handle hDataObj, U8 PenSize); Parameter hDataObj PenSize
Handle of data object. Pen size which should be used to draw the polyline.
Meaning
Limitations
Please note, that only curves with line style GUI_LS_SOLID (default) can be drawn with a pen size >1.
GRAPH_SCALE_Create()
Description
Creates a scale object.
Prototype
GRAPH_SCALE_Handle GRAPH_SCALE_Create(int Pos, int Align, unsigned Flags, unsigned TickDist); Parameter Pos TextAlign Flags TickDist Meaning
Position relative to the left/top edge of the graph widget. Text alignment used to draw the numbers. For details please refer to the function GUI_SetTextAlign() . (see table below) Distance from one tick mark to the next.
2002-2007 Micrium
474
CHAPTER 15
Return value
Handle of the scale object if creation was successful, otherwise 0.
Add. Information
A horizontal scale object starts labeling from the bottom edge of the data area to the top and a vertical scale object from the left edge (horizontal scale) to the right, where the first position is the zero point. The parameter TickDist specifies the distance between the numbers. The parameter Pos specifies in case of a horizontal scale the vertical distance in pixels from the top edge of the graph widget to the scale text. In case of a vertical scale the parameter specifies the horizontal distance from the left edge of the graph widget to the horizontal text position. Please note, that the actual text position also depends on the text alignment specified with parameter TextAlign. The scale object draws a number for each position which is within the data area. In case of a horizontal scale there is one exception: If the first position is 0 no number is drawn at this position. Once attached to a graph widget a scale object needs not to be deleted by the application. This is automatically done during the deletion of the graph widget.
GRAPH_SCALE_Delete()
Description
Deletes the given scale object.
Prototype
void GRAPH_SCALE_Delete(GRAPH_SCALE_Handle hScaleObj); Parameter hScaleObj
Scale object to be deleted.
Meaning
Add. Information
When a graph widget is deleted it deletes all currently attached scale objects. So the application needs only to delete unattached scale objects.
GRAPH_SCALE_SetFactor()
Before After
Description
Sets a factor used to calculate the numbers to be drawn.
2002-2007 Micrium
475
Prototype
float GRAPH_SCALE_SetFactor(GRAPH_SCALE_Handle hScaleObj, float Factor); Parameter hScaleObj Factor
Handle of scale object. Factor to be used to calculate the number.
Meaning
Return value
Old factor used to calculate the numbers.
Add. Information
Without using a factor the unit of the scale object is pixel. So the given factor should convert the pixel value to the desired unit.
GRAPH_SCALE_SetFont()
Before After
Description
Sets the font used to draw the scale numbers.
Prototype
const GUI_FONT * GRAPH_SCALE_SetFont(GRAPH_SCALE_Handle hScaleObj, const GUI_FONT * pFont); Parameter hScaleObj pFont
Handle of scale object. Font to be used.
Meaning
Return value
Previous used font used to draw the numbers.
2002-2007 Micrium
476
CHAPTER 15
GRAPH_SCALE_SetNumDecs()
Before After
Description
Sets the number of post decimal positions to be shown.
Prototype
int GRAPH_SCALE_SetNumDecs(GRAPH_SCALE_Handle hScaleObj, int NumDecs); Parameter hScaleObj NumDecs
Handle of scale object. Number of post decimal positions.
Meaning
Return value
Previous number of post decimal positions.
GRAPH_SCALE_SetOff()
Before After
Description
Sets an offset used to shift the scale object in positive or negative direction.
Prototype
int GRAPH_SCALE_SetOff(GRAPH_SCALE_Handle hScaleObj, int Off); Parameter hScaleObj Off
Handle of scale object. Offset used for drawing the scale.
Meaning
Return value
Previous used offset.
2002-2007 Micrium
477
Add. Information
As described under the function GRAPH_SCALE_Create() a horizontal scale object starts labeling from the bottom edge of the data area to the top and a vertical scale object from the left edge (horizontal scale) to the right, where the first position is the zero point. In many situations it is not desirable, that the first position is the zero point. If the scale should be shifted in positive direction, a positive offset should be added, for negative direction a negative value.
GRAPH_SCALE_SetPos()
Before After
Description
Sets the position for showing the scale object within the graph widget.
Prototype
int GRAPH_SCALE_SetPos(GRAPH_SCALE_Handle hScaleObj, int Pos); Parameter hScaleObj Pos
Handle of scale object. Position, at which the scale should be shown.
Meaning
Return value
Previous position of the scale object.
Add. Information
The parameter Pos specifies in case of a horizontal scale the vertical distance in pixels from the top edge of the graph widget to the scale text. In case of a vertical scale the parameter specifies the horizontal distance from the left edge of the graph widget to the horizontal text position. Please note, that the actual text position also depends on the text alignment of the scale object.
2002-2007 Micrium
478
CHAPTER 15
GRAPH_SCALE_SetTextColor()
Before After
Description
Sets the text color used to draw the numbers.
Prototype
GUI_COLOR GRAPH_SCALE_SetTextColor(GRAPH_SCALE_Handle hScaleObj, GUI_COLOR Color); Parameter hScaleObj Color
Handle of scale object. Color to be used to show the numbers.
Meaning
Return value
Previous color used to show the numbers.
GRAPH_SCALE_SetTickDist()
Before After
Description
Sets the distance from one number to the next.
Prototype
unsigned GRAPH_SCALE_SetTickDist(GRAPH_SCALE_Handle hScaleObj, unsigned Dist); Parameter hScaleObj Dist
Handle of scale object. Distance in pixels between the numbers.
Meaning
Return value
Previous distance between the numbers.
2002-2007 Micrium
479
2002-2007 Micrium
480
CHAPTER 15
If a pointer input device (PID) is used, the width of the header items can be managed by dragging the dividers by the PID.
Predefined cursors
There are 2 predefined cursors as shown below: GUI_CursorHeaderM (default) GUI_CursorHeaderMI
You can also create and use your own cursors when using a HEADER widget as described later in this chapter.
2002-2007 Micrium
481
Default
0xAAAAAA &GUI_Font13_1 2
Explanation
Default value of background color Default font Horizontal space between text and border Vertical space between text and border Enable/disable dragging support Default value of text color
2002-2007 Micrium
482
CHAPTER 15
Routine HEADER_SetBkColor() HEADER_SetBMP() HEADER_SetBMPEx() HEADER_SetDefaultBkColor() HEADER_SetDefaultBorderH() HEADER_SetDefaultBorderV() HEADER_SetDefaultCursor() HEADER_SetDefaultFont() HEADER_SetDefaultTextColor() HEADER_SetDragLimit() HEADER_SetFont() HEADER_SetHeight() HEADER_SetTextAlign() HEADER_SetItemText() HEADER_SetItemWidth() HEADER_SetStreamedBitmap() HEADER_SetStreamedBitmapEx() HEADER_SetTextColor()
Explanation
Sets the background color of the widget. Sets the bitmap used when displaying the given item. Sets the bitmap used when displaying the given item. Sets the default background color. Sets the default value for the horizontal spacing. Sets the default value for the vertical spacing. Sets the default cursor. Sets the default font. Sets the default text color. Sets the limit for dragging the items on or off. Sets the font of the widget. Sets the height of the widget. Sets the alignment of the given item. Sets the text of a given item. Sets the width of a given item. Sets the bitmap used when displaying the given item. Sets the bitmap used when displaying the given item. Sets the Text color of the widget.
HEADER_AddItem()
Description
Adds an item to an already existing HEADER widget.
Prototype
void HEADER_AddItem(HEADER_Handle hObj, int Width, const char * s, int Align); Parameter hObj Width s Align
Handle of widget Width of the new item Text to be displayed Text alignment mode to set. May be a combination of a horizontal and a vertical alignment flag.
Meaning
Permitted values for parameter Align (horizontal and vertical flags are OR-combinable) Horizontal alignment GUI_TA_LEFT GUI_TA_HCENTER GUI_TA_RIGHT GUI_TA_TOP GUI_TA_VCENTER GUI_TA_BOTTOM
Align X-position left (default). Center X-position. Align X-position right (default).
Vertical alignment
Align Y-position with top of characters (default). Center Y-position. Align Y-position with bottom pixel line of font.
2002-2007 Micrium
483
Add. information
The Width-parameter can be 0. If Width = 0 the width of the new item will be calculated by the given text and by the default value of the horizontal spacing.
HEADER_Create()
(Obsolete, HEADER_CreateEx should be used instead)
Description
Creates a HEADER widget of a specified size at a specified location.
Prototype
HEADER_Handle HEADER_Create(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, int SpecialFlags); Parameter x0 y0 xsize ysize hParent Id Flags Meaning
Leftmost pixel of the HEADER widget (in parent coordinates). Topmost pixel of the HEADER widget (in parent coordinates). Horizontal size of the HEADER widget (in pixels). Vertical size of the HEADER widget (in pixels). Handle of the parent window Id of the new HEADER widget Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
Return value
Handle for the created HEADER widget; 0 if the routine fails.
HEADER_CreateAttached()
Description
Creates a HEADER widget which is attached to an existing window.
Prototype
HEADER_Handle HEADER_CreateAttached(WM_HWIN hParent, int Id, int SpecialFlags); Parameter
Handle of widget hObj Id of the HEADER widget Id SpecialFlags (Not used, reserved for later use)
Meaning
Return value
Handle for the created HEADER widget; 0 if the routine fails.
2002-2007 Micrium
484
CHAPTER 15
Add. information
An attached HEADER widget is essentially a child window which will position itself on the parent window and operate accordingly.
HEADER_CreateEx()
Description
Creates a HEADER widget of a specified size at a specified location.
Prototype
HEADER_Handle HEADER_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new HEADER widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Not used, reserved for future use. Window ID of the widget.
Return value
Handle for the created widget; 0 if the routine fails.
HEADER_CreateIndirect()
Description
Prototype explained at the beginning of the chapter.
HEADER_GetDefaultBkColor()
Description
Returns the default background color used when creating a HEADER widget.
Prototype
GUI_COLOR HEADER_GetDefaultBkColor(void);
Return value
Default background color used when creating a HEADER widget.
2002-2007 Micrium
485
HEADER_GetDefaultBorderH()
Description
Returns the value used for the horizontal spacing when creating a HEADER widget. Horizontal spacing means the horizontal distance in pixel between text and the horizontal border of the item.
Prototype
int HEADER_GetDefaultBorderH(void);
Return value
Value used for the horizontal spacing when creating a HEADER widget.
Add. information
Horizontal spacing takes effect only if the given width of a new item is 0.
HEADER_GetDefaultBorderV()
Description
Returns the value used for the vertical spacing when creating a HEADER widget. Vertical spacing means the vertical distance in pixel between text and the vertical border of the HEADER widget.
Prototype
int HEADER_GetDefaultBorderV(void);
Return value
Value used for the vertical spacing when creating a HEADER widget.
HEADER_GetDefaultCursor()
Description
Returns a pointer to the cursor diplayed when dragging the width of an item.
Prototype
const GUI_CURSOR * HEADER_GetDefaultCursor(void);
Return value
pointer to the cursor diplayed when dragging the width of an item.
HEADER_GetDefaultFont()
Description
Returns a pointer to the default font used when creating a HEADER widget.
Prototype
const GUI_FONT * HEADER_GetDefaultFont(void);
Return value
Pointer to the default font used when creating a HEADER widget.
2002-2007 Micrium
486
CHAPTER 15
HEADER_GetDefaultTextColor()
Description
Returns the default text color used when creating a HEADER widget.
Prototype
GUI_COLOR HEADER_GetDefaultTextColor(void);
Return value
Default text color used when creating a HEADER widget.
HEADER_GetHeight()
Description
Returns the height of the given HEADER widget.
Prototype
int HEADER_GetHeight(HEADER_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Height of the given HEADER widget.
HEADER_GetItemWidth()
Description
Returns the item width of the given HEADER widget.
Prototype
int HEADER_GetItemWidth(HEADER_Handle hObj, unsigned int Index); Parameter hObj Index
Handle of widget Index of the item
Meaning
Return value
Width of the item.
HEADER_GetNumItems()
Description
Returns the number of items of the given HEADER widget.
Prototype
int HEADER_GetNumItems(HEADER_Handle hObj); Parameter hObj
Handle of widget
Meaning
2002-2007 Micrium
487
Return value
Number of items of the given HEADER widget.
HEADER_SetBitmap()
Description
Sets the bitmap used when displaying the specified item.
Prototype
void HEADER_SetBitmap(HEADER_Handle hObj, unsigned int Index, const GUI_BITMAP * pBitmap); Parameter hObj Index pBitmap
Handle of widget Index of the item Pointer to a bitmap structure to be displayed
Meaning
Add. information
One item of a HEADER widget can contain text and a bitmap. (look at sample under HEADER_SetBitmapEx)
HEADER_SetBitmapEx()
Description
Sets the bitmap used when displaying the specified item.
Prototype
void HEADER_SetBitmapEx(HEADER_Handle hObj, unsigned int Index, const GUI_BITMAP * pBitmap, int x, int y); Parameter hObj Index pBitmap x y
Handle of widget Index of the item Pointer to a bitmap structure to be displayed Additional offset in x Additional offset in y
Meaning
Add. information
One item of a HEADER widget can contain text and a bitmap. Example:
... HEADER_Handle hHeader; GUI_Init(); HEADER_SetDefaultTextColor(GUI_YELLOW); HEADER_SetDefaultFont(&GUI_Font8x8); hHeader = HEADER_Create(10, 10, 100, 40, WM_HBKWIN, 1234, WM_CF_SHOW, 0); HEADER_AddItem(hHeader, 50, "Phone", GUI_TA_BOTTOM | GUI_TA_HCENTER); HEADER_AddItem(hHeader, 50, "Code" , GUI_TA_BOTTOM | GUI_TA_HCENTER); HEADER_SetBitmapEx(hHeader, 0, &bmPhone, 0, -15); User's & reference manual for C/GUI 2002-2007 Micrium
488
HEADER_SetBkColor()
Description
Sets the background color of the given HEADER widget.
Prototype
void HEADER_SetBkColor(HEADER_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget Background color to be set
Meaning
HEADER_SetBMP()
Description
Sets the bitmap used when displaying the specified item.
Prototype
void HEADER_SetBMP(HEADER_Handle hObj, unsigned int Index, const void * pBitmap); Parameter hObj Index pBitmap
Handle of widget Index of HEADER item Pointer to bitmap file data
Meaning
Add. information
For additional informations regarding bitmap files please take a look at chapter 6.
HEADER_SetBMPEx()
Description
Sets the bitmap used when displaying the specified item.
Prototype
void HEADER_SetBMPEx(HEADER_Handle hObj, unsigned int Index, const void * pBitmap,
2002-2007 Micrium
489
Meaning
Add. information
For additional informations regarding bitmap files please take a look at chapter 6.
HEADER_SetDefaultBkColor()
Description
Sets the default background color used when creating a HEADER widget.
Prototype
GUI_COLOR HEADER_SetDefaultBkColor(GUI_COLOR Color); Parameter Color
Background color to be used
Meaning
Return value
Previous default background color.
HEADER_SetDefaultBorderH()
Description
Sets the value used for the horizontal spacing when creating a HEADER widget. Horizontal spacing means the horizontal distance in pixel between text and the horizontal border of the item.
Prototype
int HEADER_SetDefaultBorderH(int Spacing); Parameter Spacing
Value to be used
Meaning
Return value
Previous default value.
Add. information
Horizontal spacing takes effect only if the given width of a new item is 0.
2002-2007 Micrium
490
CHAPTER 15
HEADER_SetDefaultBorderV()
Description
Sets the value used for the vertical spacing when creating a HEADER widget. Vertical spacing means the vertical distance in pixel between text and the vertical border of the HEADER widget.
Prototype
int HEADER_SetDefaultBorderV(int Spacing); Parameter Spacing
Value to be used
Meaning
Return value
Previous default value.
HEADER_SetDefaultCursor()
Description
Sets the cursor which will be displayed when dragging the width of an HEADER item.
Prototype
const GUI_CURSOR * HEADER_SetDefaultCursor(const GUI_CURSOR * pCursor); Parameter pCursor Meaning
Pointer to the cursor to be shown when dragging the width of an HEADER item
Return value
Pointer to the previous default cursor.
Add. information
There are 2 predefined cursors shown at the beginning of this chapter.
HEADER_SetDefaultFont()
Description
Sets the default font used when creating a HEADER widget.
Prototype
const GUI_FONT * HEADER_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont
Pointer to font to be used
Meaning
Return value
Pointer to previous default font.
HEADER_SetDefaultTextColor()
Description
Returns the default text color used when creating a HEADER widget.
User's & reference manual for C/GUI 2002-2007 Micrium
491
Prototype
GUI_COLOR HEADER_SetDefaultTextColor(GUI_COLOR Color); Parameter Color
Color to be used
Meaning
Return value
Previous default value.
HEADER_SetDragLimit()
Description
Sets the limit for dragging the dividers on or off. If the limit is on, a divider can only be dragged within the widget area. If the limit is off, it can be dragged outside the widget.
Prototype
void HEADER_SetDragLimit(HEADER_Handle hObj, unsigned OnOff); Parameter hObj OnOff
Handle of widget 1 for setting the drag limit on, 0 for off.
Meaning
HEADER_SetFont()
Description
Sets the font used when displaying the given HEADER widget
Prototype
void HEADER_SetFont(HEADER_Handle hObj, const GUI_FONT * pFont); Parameter hObj pFont
Handle of widget Pointer to font to be used
Meaning
HEADER_SetHeight()
Description
Sets the height of the given HEADER widget.
Prototype
void HEADER_SetHeight(HEADER_Handle hObj, int Height); Parameter hObj Height
Handle of widget New height
Meaning
HEADER_SetTextAlign()
Description
Sets the text alignment of the specified HEADER item.
User's & reference manual for C/GUI 2002-2007 Micrium
492
CHAPTER 15
Prototype
void HEADER_SetTextAlign(HEADER_Handle hObj, unsigned int Index, int Align); Parameter hObj Index Align
Handle of widget Index of header item Text alignment mode to set. May be a combination of a horizontal and a vertical alignment flag.
Meaning
Permitted values for parameter Align (horizontal and vertical flags are OR-combinable) Horizontal alignment GUI_TA_LEFT GUI_TA_HCENTER GUI_TA_RIGHT GUI_TA_TOP GUI_TA_VCENTER GUI_TA_BOTTOM
Align X-position left (default). Center X-position. Align X-position right (default).
Vertical alignment
Align Y-position with top of characters (default). Center Y-position. Align Y-position with bottom pixel line of font.
HEADER_SetItemText()
Description
Sets the text used when displaying the specified item.
Prototype
void HEADER_SetItemText(HEADER_Handle hObj, unsigned int Index, const char * s); Parameter hObj Index s
Handle of widget Index of HEADER item Pointer to string to be displayed
Meaning
Add. information
One HEADER item can contain a string and a bitmap.
HEADER_SetItemWidth()
Description
Sets the width of the specified HEADER item.
Prototype
void HEADER_SetItemWidth(HEADER_Handle hObj, unsigned int Index, int Width); Parameter hObj Index Width
Handle of widget Index of HEADER item New width
Meaning
2002-2007 Micrium
493
HEADER_SetStreamedBitmap()
Description
Sets the bitmap used when displaying the specified item.
Prototype
void HEADER_SetStreamedBitmap(HEADER_Handle hObj, unsigned int Index, const GUI_BITMAP_STREAM * pBitmap); Parameter hObj Index pBitmap
Handle of widget Index of the item Pointer to streamed bitmap data to be displayed
Meaning
Add. information
For additional informations regarding streamed bitmap files please take a look at chapter 6, "2-D Graphic Library".
HEADER_SetStreamedBitmapEx()
Description
Sets the bitmap used when displaying the specified item.
Prototype
void HEADER_SetStreamedBitmapEx(HEADER_Handle hObj, unsigned int Index, const GUI_BITMAP_STREAM * pBitmap, int x, int y); Parameter hObj Index pBitmap x y
Handle of widget Index of the item Pointer to streamed bitmap data to be displayed Additional offset in x Additional offset in y
Meaning
Add. information
For additional informations regarding streamed bitmap files please take a look at chapter 6, "2-D Graphic Library".
HEADER_SetTextColor()
Description
Sets the text color used when displaying the widget.
2002-2007 Micrium
494
CHAPTER 15
Prototype
void HEADER_SetTextColor(HEADER_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget Color to be used
Meaning
15.10.5 Example
The source of the following sample is available as WIDGET_Header.c in the samples shipped with C/GUI:
2002-2007 Micrium
495
All LISTBOX-related routines are in the file(s) LISTBOX*.c, LISTBOX.h. All identifiers are prefixed LISTBOX.
Default
GUI_WHITE GUI_GRAY GUI_BLUE &GUI_Font13_1 GUI_BLACK GUI_WHITE GUI_WHITE
Explanation
Background color, unselected state. Background color, selected state without focus. Background color, selected state with focus. Font used. Text color, unselected state. Text color, selected state without focus. Text color, selected state with focus.
2002-2007 Micrium
496
CHAPTER 15
LISTBOX_GetDefaultScrollStepH() tal. Returns the default text alignment for new list boxes. LISTBOX_GetDefaultTextAlign() Returns the default text color for new list boxes. LISTBOX_GetDefaultTextColor() Returns the font of the list box. LISTBOX_GetFont() Returns the disabled state of the given item. LISTBOX_GetItemDisabled() Returns the selection state of a LISTBOX entry. LISTBOX_GetItemSel() Returns the text of a list box entry. LISTBOX_GetItemText() Returns if the multi select mode is active. LISTBOX_GetMulti() Returns the number of items in a list box. LISTBOX_GetNumItems() Returns the number of pixels to be scrolled horizontal. LISTBOX_GetScrollStepH() Returns the number of the selected item. LISTBOX_GetSel() Returns the text alignment of the LISTBOX. LISTBOX_GetTextAlign() Increments selection. LISTBOX_IncSel() Inserts an element. LISTBOX_InsertString() Invalidates an item of an owner drawn LISTBOX. LISTBOX_InvalidateItem() Default function for drawing a LISTBOX entry. LISTBOX_OwnerDraw() Activates automatic use of a horizontal scrollbar. LISTBOX_SetAutoScrollH() Activates automatic use of a vertical scrollbar. LISTBOX_SetAutoScrollV() Sets the background color. LISTBOX_SetBkColor() Sets the default background color for LISTBOX widgets. LISTBOX_SetDefaultBkColor()
2002-2007 Micrium
497
Routine LISTBOX_SetDefaultFont() LISTBOX_SetDefaultScrollStepH() LISTBOX_SetDefaultTextAlign() LISTBOX_SetDefaultTextColor() LISTBOX_SetFont() LISTBOX_SetItemDisabled() LISTBOX_SetItemSel() LISTBOX_SetItemSpacing() LISTBOX_SetMulti() LISTBOX_SetOwnerDraw() LISTBOX_SetScrollbarColor() LISTBOX_SetScrollbarWidth() LISTBOX_SetScrollStepH() LISTBOX_SetSel() LISTBOX_SetString() LISTBOX_SetTextAlign() LISTBOX_SetTextColor()
Explanation
Changes the default font for LISTBOX widgets. Sets the default number of pixels to be scrolled horizontal. Sets the default text alignment for new LISTBOX widgets. Sets the default text color for LISTBOX widgets. Selects the font. Sets the disabled state of the given item. Sets the selection state of the given item. Sets a spacing between the items. Sets the multi selection mode on or off. Enables the list box to be owner drawn. Sets the colors of the optional scrollbar. Sets the width of the scrollbars used by the LISTBOX. Sets the number of pixels to be scrolled horizontal. Sets the selected item. Sets the text of an element. Sets the text alignment of the LISTBOX. Sets the foreground color.
LISTBOX_AddString()
Description
Adds an item to an already existing list box.
Prototype
void LISTBOX_AddString(LISTBOX_Handle hObj, const char* s); Parameter hObj s
Handle of list box. Text to display.
Meaning
LISTBOX_Create()
Description
Creates a LISTBOX widget of a specified size at a specified location.
Prototype
LISTBOX_Handle LISTBOX_Create(const GUI_ConstString* ppText, int x0, int y0, int xSize, int ySize, int Flags); Parameter ppText x0 y0 xSize ySize Flags Meaning
Pointer to an array of string pointers containing the elements to be displayed. Leftmost pixel of the list box (in parent coordinates). Topmost pixel of the list box (in parent coordinates). Horizontal size of the list box (in pixels). Vertical size of the list box (in pixels). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
2002-2007 Micrium
498
CHAPTER 15
Return value
Handle for the created FRAMEWIN widget, 0 on failure.
Add. information
If the parameter ySize is greater than the required space for drawing the contents of the widget, the Y-size will be reduced to the required value. The same applies for the Xsize parameter.
LISTBOX_CreateAsChild()
Description
Creates a LISTBOX widget as a child window.
Prototype
LISTBOX_Handle LISTBOX_CreateAsChild(const GUI_ConstString* ppText, WM_HWIN hParent, int x0, int y0, int xSize, int ySize, int Flags); Parameter ppText hParent x0 y0 xSize ySize Flags
Handle of parent window. X-position of the list box relative to the parent window. Y-position of the list box relative to the parent window. Horizontal size of the list box (in pixels). Vertical size of the list box (in pixels). Window create flags (see
Meaning
Pointer to an array of string pointers containing the elements to be displayed.
LISTBOX_Create() ).
Return value
Handle for the created LISTBOX widget; 0 if the routine fails.
Add. information
If the parameter ySize is greater than the space required for drawing the contents of the widget, the Y-size will be reduced to the required value. If ySize = 0 the Y-size of the widget will be set to the Y-size of the client area from the parent window. The same applies for the Xsize parameter.
LISTBOX_CreateEx()
Description
Creates a LISTBOX widget of a specified size at a specified location.
Prototype
LISTBOX_Handle LISTBOX_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, const GUI_ConstString* ppText); Parameter x0 y0 xsize Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels).
2002-2007 Micrium
499
Meaning
Vertical size of the widget (in pixels). Handle of parent window. If 0, the new HEADER widget will be a child of the desktop (top-level window). Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Not used, reserved for future use. Window ID of the widget. Pointer to an array of string pointers containing the elements to be displayed.
Return value
Handle for the created widget; 0 if the routine fails.
LISTBOX_CreateIndirect()
Prototype explained at the beginning of the chapter. The elements Flags and Para of the resource passed as parameter are not used.
LISTBOX_DecSel()
Description
Decrement the list box selection (moves the selection bar of a specified list box up by one item).
Prototypes
void LISTBOX_DecSel(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Add. information
Please note that the numbering of items always starts from the top with a value of 0; therefore decrementing the selection will actually move the selection one row up.
LISTBOX_DeleteItem()
Description
Deletes an element from a listbox.
Prototypes
void LISTBOX_DeleteItem(LISTBOX_Handle hObj, unsigned int Index); Parameter hObj Index
Handle of list box. Zero based index of element to be deleted.
Meaning
LISTBOX_GetDefaultBkColor()
Description
Returns the default background color for new LISTBOX widgets.
2002-2007 Micrium
500
CHAPTER 15
Prototype
GUI_COLOR LISTBOX_GetDefaultBkColor(unsigned Index); Parameter Index Meaning
Zero based index for background color (see table below)
Return value
Default background color for new LISTBOX widgets.
LISTBOX_GetDefaultFont()
Description
Returns the default font used for creating LISTBOX widgets.
Prototype
const GUI_FONT* LISTBOX_GetDefaultFont(void);
Return value
Pointer to the default font.
LISTBOX_GetDefaultScrollStepH()
Description
Returns the default horizontal scroll step used for creating LISTBOX widgets. The horizontal scroll step defines the number of pixels to be scrolled if needed.
Prototype
int LISTBOX_GetDefaultScrollStepH(void);
Return value
Default horizontal scroll step.
LISTBOX_GetDefaultTextAlign()
Description
Returns the default text alignment for new LISTBOX widgets.
Prototype
int LISTBOX_GetDefaultTextAlign(void);
Return value
Default text alignment for new LISTBOX widgets.
Add. information
For more information please refer to LISTBOX_SetTextAlign().
2002-2007 Micrium
501
LISTBOX_GetDefaultTextColor()
Description
Returns the default text color for new LISTBOX widgets.
Prototype
GUI_COLOR LISTBOX_GetDefaultTextColor(unsigned Index); Parameter Index Meaning
Zero based index for text color (see table below)
Return value
Default text color for new LISTBOX widgets.
LISTBOX_GetFont()
Description
Returns a pointer to the font used to display the text of the list box.
Prototype
const GUI_FONT * LISTBOX_GetFont(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Return value
Pointer to the font used to display the text of the list box.
LISTBOX_GetItemDisabled()
Description
Returns if the given list box item has been disabled.
Prototype
int LISTBOX_GetItemDisabled(LISTBOX_Handle hObj, unsigned Index); Parameter hObj Index
Handle of list box. Zero based index of item.
Meaning
Return value
1 if item has been disabled, 0 if not.
2002-2007 Micrium
502
CHAPTER 15
LISTBOX_GetItemSel()
Description
Returns the selection state of the given listbox item. The selection state of a LISTBOX item can be modified in multi selection mode only.
Prototype
int LISTBOX_GetItemSel(LISTBOX_Handle hObj, unsigned int Index); Parameter hObj Index
Handle of list box. Zero based index of item.
Meaning
Return value
1 if item has been selected, 0 if not.
LISTBOX_GetItemText()
Description
Returns the text of the given list box item.
Prototype
void LISTBOX_GetItemText(LISTBOX_Handle hObj, unsigned Index, char * pBuffer, int MaxSize); Parameter hObj Index pBuffer MaxSize
Handle of list box. Zero based index of item. Pointer to buffer to store the item text. Size of the buffer.
Meaning
Add. information
The function copies the text of the given list box item into the given buffer.
LISTBOX_GetMulti()
Description
Returns if the multi selection mode of the given list box is active.
Prototype
int LISTBOX_GetMulti(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Return value
1 if active, 0 if not.
2002-2007 Micrium
503
LISTBOX_GetNumItems()
Description
Returns the number of items in a specified list box.
Prototypes
unsigned LISTBOX_GetNumItems(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Return value
Number of items in the list box.
LISTBOX_GetScrollStepH()
Description
Returns the horizontal scroll step of the given list box.
Prototype
int LISTBOX_GetScrollStepH(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Return value
Horizontal scroll step of the given list box.
LISTBOX_GetSel()
Description
Returns the zero based index of the currently selected item in a specified list box. In multi selection mode the function returns the index of the focused element.
Prototype
int LISTBOX_GetSel(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Return value
Zero based index of the currently selected item.
Add. information
If no element has been selected the function returns -1.
LISTBOX_GetTextAlign()
Description
Returns the text alignment of the given LISTBOX widget.
2002-2007 Micrium
504
CHAPTER 15
Prototype
int LISTBOX_GetTextAlign(LISTBOX_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
Text alignment of the given LISTBOX widget.
Add. information
For more information please refer to LISTBOX_SetTextAlign().
LISTBOX_IncSel()
Description
Increment the list box selection (moves the selection bar of a specified list box down by one item).
Prototypes
void LISTBOX_IncSel(LISTBOX_Handle hObj); Parameter hObj
Handle of list box.
Meaning
Add. information
Please note that the numbering of items always starts from the top with a value of 0; therefore incrementing the selection will actually move the selection one row down.
LISTBOX_InsertString()
Description
Inserts an element into a listbox.
Prototypes
void LISTBOX_InsertString(LISTBOX_Handle hObj, const char* s, unsigned int Index); Parameter hObj s Index
Handle of list box. Pointer to string to be inserted. Zero based index of element to be inserted.
Meaning
LISTBOX_InvalidateItem()
Description
Invalidates an item of a owner drawn listbox.
2002-2007 Micrium
505
Prototypes
void LISTBOX_InvalidateItem(LISTBOX_Handle hObj, int Index); Parameter hObj Index
Handle of list box. Zero based index of element to be invalidated or LISTBOX_ALL_ITEMS if all items should be invalidated.
Meaning
Add. information
This function only needs to be called if an item of an owner drawn listbox has been changed. If a listbox API function (like LISTBOX_SetString()) has been used to modify a listbox item LISTBOX_InvalidateItem() needs not to be called. It needs to be called if the user decides, that for example the vertical size of an item has been changed. With other words if no listbox API function has been used to modify the item this function needs to be called.
LISTBOX_ALL_ITEMS
If all items of a listbox should be invalidated use this define as Index parameter.
LISTBOX_OwnerDraw()
Description
Default function to handle a LISTBOX entry.
Prototypes
int LISTBOX_OwnerDraw(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo); Parameter pDrawItemInfo
Pointer to a
Add. information
This function is usefull if LISTBOX_SetOwnerDrawn() has been used. It can be used from your drawing function to retrieve the original x size of a LISTBOX entry and/or to display the text of a LISTBOX entry and should be called for all unhandled commands. For more information, refer to the section explaining user drawn widgets, LISTBOX_SetOwnerDraw() and to the provided sample.
LISTBOX_SetAutoScrollH()
Description
Enables/disables the automatic use of a horizontal scrollbar.
Prototypes
void LISTBOX_SetAutoScrollH(LISTBOX_Handle hObj, int OnOff); Parameter hObj OnOff
Handle of list box. (See table below)
Meaning
2002-2007 Micrium
506
CHAPTER 15
Add. information
If enabled the listbox checks if all elements fits into the listbox. If not a horizontal scrollbar will be attached to the window.
LISTBOX_SetAutoScrollV()
Description
Enables/disables the automatic use of a vertical scrollbar.
Prototypes
void LISTBOX_SetAutoScrollV(LISTBOX_Handle hObj, int OnOff); Parameter hObj OnOff
Handle of list box. (See table below)
Meaning
Add. information
If enabled the listbox checks if all elements fits into the listbox. If not a vertical scrollbar will be added.
LISTBOX_SetBkColor()
Description
Sets the list box background color.
Prototype
void LISTBOX_SetBkColor(LISTBOX_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of list box. Index for background color (see table below). Color to be set.
Meaning
2002-2007 Micrium
507
LISTBOX_SetDefaultBkColor()
Description
Sets the default background color for new LISTBOX widgets.
Prototype
void LISTBOX_SetDefaultBkColor(unsigned Index, GUI_COLOR Color); Parameter Index Color
Desired background color.
Meaning
Zero based index for background color (see table below)
LISTBOX_SetDefaultFont()
Description
Sets the default font used for creating LISTBOX widgets.
Prototype
void LISTBOX_SetDefaultFont(const GUI_FONT* pFont) Parameter pFont
Pointer to the font.
Meaning
LISTBOX_SetDefaultScrollStepH()
Description
Sets the default horizontal scroll step used when creating a LISTBOX widget.
Prototype
void LISTBOX_SetDefaultScrollStepH(int Value); Parameter Value
Number of pixels to be scrolled.
Meaning
LISTBOX_SetDefaultTextAlign()
Description
Sets the default text alignment for new LISTBOX widgets.
Prototype
void LISTBOX_SetDefaultTextAlign(int Align); Parameter Align Meaning
Default text alignment for new LISTBOX widgets.
2002-2007 Micrium
508
CHAPTER 15
Add. information
For more information please refer to LISTBOX_SetTextAlign().
LISTBOX_SetDefaultTextColor()
Description
Sets the default text color for new LISTBOX widgets.
Prototype
void LISTBOX_SetDefaultTextColor(unsigned Index, GUI_COLOR Color); Parameter Index Color
Desired text color.
Meaning
Zero based index for text color (see table below)
LISTBOX_SetFont()
Description
Sets the list box font.
Prototype
void LISTBOX_SetFont(LISTBOX_Handle hObj, const GUI_FONT* pfont); Parameter hObj pFont
Handle of list box. Pointer to the font.
Meaning
LISTBOX_SetItemDisabled()
Description
Modifies the disable state of the given list box item.
Prototype
void LISTBOX_SetItemDisabled(LISTBOX_Handle hObj, unsigned Index, int OnOff); Parameter hObj Index OnOff
Handle of list box. Zero based index of the listbox item. 1 for disabled, 0 for not disabled.
Meaning
Add. information
When scrolling through a list box disabled items will be skipped. You can not scroll to a disabled list box item.
User's & reference manual for C/GUI 2002-2007 Micrium
509
LISTBOX_SetItemSel()
Description
Modifies the selection state of the given list box item.
Prototype
void LISTBOX_SetItemSel(LISTBOX_Handle hObj, unsigned Index, int OnOff); Parameter hObj Index OnOff
Handle of list box. Zero based index of the listbox item. 1 for selected, 0 for not selected.
Meaning
Add. information
Setting the selection state of a list box item makes only sense when using the multi selection mode. See also LISTBOX_SetMulti().
LISTBOX_SetItemSpacing()
Before After
Description
Sets an additional spacing below the items of a list box.
Prototype
void LISTBOX_SetItemSpacing(LISTBOX_Handle hObj, unsigned Value); Parameter hObj Value
Handle of list box. Number of pixels used as additional spacing between the items.
Meaning
LISTBOX_SetMulti()
Description
Switches the multi selection mode of a LISTBOX on or off.
2002-2007 Micrium
510
CHAPTER 15
Prototype
void LISTBOX_SetMulti(LISTBOX_Handle hObj, int Mode); Parameter hObj Mode
Handle of list box. 0 for off, 1 for on.
Meaning
Add. information
The multi selection mode enables the list box to have more than one selected element. Using the space key would toggle the selection state of a list box item.
LISTBOX_SetOwnerDraw()
Description
Sets the list box to be owner drawn.
Prototype
void LISTBOX_SetOwnerDraw(LISTBOX_Handle hObj, WIDGET_DRAW_ITEM_FUNC * pfDrawItem); Parameter hObj pfDrawItem
Handle of list box. Pointer to owner draw function.
Meaning
Add. information
This function sets a function pointer to a function which will be called by the widget if a list box item has to be drawn and when the x or y size of a item is needed. It gives you the possibility to draw anything as list box item, not just plain text. pfDrawItem is a pointer to a application-defined function of type WIDGET_DRAW_ITEM_FUNC which is explained at the beginning of the chapter.
2002-2007 Micrium
511
Example
example
is
available
in
the
samples
as
LISTBOX_SetScrollbarColor()
Before After
Description
Sets the colors of the optional scrollbar.
Prototype
void LISTBOX_SetScrollbarColor(LISTBOX_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of widget Index of desired item (see table below). Color to be used.
Meaning
Permitted values for parameter Index SCROLLBAR_CI_THUMB Color of thumb area. SCROLLBAR_CI_SHAFT Color of shaft. SCROLLBAR_CI_ARROW Color of arrows.
2002-2007 Micrium
512
CHAPTER 15
LISTBOX_SetScrollbarWidth()
Description
Sets the width of the scrollbars used by the given list box.
Prototype
void LISTBOX_SetScrollbarWidth(LISTBOX_Handle hObj, unsigned Width); Parameter hObj Width
Handle of list box. Width of the scrollbar(s) used by the given listbox.
Meaning
LISTBOX_SetScrollStepH()
Description
Sets the horizontal scroll step of the given list box. The horizontal scroll step defines the number of pixels to be scrolled if needed.
Prototype
void LISTBOX_SetScrollStepH(LISTBOX_Handle hObj, int Value); Parameter hObj Value
Handle of list box. Number of pixels to be scrolled.
Meaning
LISTBOX_SetSel()
Description
Sets the selected item of a specified list box.
Prototype
void LISTBOX_SetSel(LISTBOX_Handle hObj, int Sel); Parameter hObj Sel
Handle of list box. Element to be selected.
Meaning
LISTBOX_SetString()
Description
Sets the contents of the given item.
Prototypes
void LISTBOX_SetString(LISTBOX_Handle hObj, const char* s, unsigned int Index); Parameter hObj s Index
Handle of list box. Pointer to string containing the new contents. Zero based index of element to be changed.
Meaning
2002-2007 Micrium
513
LISTBOX_SetTextAlign()
Before After
Description
The function sets the text alignment used to display each item of the list box.
Prototype
void LISTBOX_SetTextAlign(LISTBOX_Handle hObj, int Align); Parameter hObj Align
Handle of widget. Text alignment to be used.
Meaning
Permitted values for parameter Align (horizontal and vertical flags are OR-combinable) Horizontal alignment GUI_TA_LEFT GUI_TA_HCENTER GUI_TA_RIGHT GUI_TA_TOP GUI_TA_VCENTER GUI_TA_BOTTOM
Align X-position left (default). Center X-position. Align X-position right (default).
Vertical alignment
Align Y-position with top of characters (default). Center Y-position. Align Y-position with bottom pixel line of font.
Add. information
The default alignment of list boxes is GUI_TA_LEFT. Per default the height of each item depends on the height of the font used to render the list box items. So vertical text alignment makes only sense if the function LISTBOX_SetItemSpacing() is used to set an additional spacing below the items.
LISTBOX_SetTextColor()
Description
Sets the list box text color.
Prototype
void LISTBOX_SetTextColor(LISTBOX_Handle hObj, unsigned int Index,
2002-2007 Micrium
514
CHAPTER 15
Meaning LISTBOX_SetBackColor() ).
15.11.5 Examples
Using the LISTBOX widget
The following example demonstrates the simple use of the LISTBOX widget. It is available in the samples as WIDGET_SimpleListBox.c:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ***** C/GUI - Graphical user interface for embedded applications **** C/GUI is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with a license and should not be redistributed in any way. We appreciate your understanding and fairness. ---------------------------------------------------------------------File : WIDGET_SimpleListBox.c Purpose : Example demonstrating the LISTBOX widget ---------------------------------------------------------------------*/ #include "GUI.h" #include "LISTBOX.h" #include <stddef.h> /******************************************************************* * * defines * ******************************************************************** */ #define countof(Array) (sizeof(Array) / sizeof(Array[0])) /******************************************************************* * * static variables * ******************************************************************** */ static const GUI_ConstString _ListBox[] = { "English", "Deutsch", "Franais", "Japanese", "Italiano", NULL }; /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _DemoListBox User's & reference manual for C/GUI 2002-2007 Micrium
515 */ void _DemoListBox(void) { int i; int Entries = countof(_ListBox) - 1; LISTBOX_Handle hListBox; int ySize = GUI_GetYDistOfFont(&GUI_Font13B_1) * Entries; /* Create the listbox */ hListBox = LISTBOX_Create(_ListBox, 130, 80, 60, ySize, WM_CF_SHOW); /* Change current selection of the listbox */ for (i = 0; i < Entries-1; i++) { GUI_Delay(500); LISTBOX_IncSel(hListBox); WM_ExecIdle(); } for (i = 0; i < Entries-1; i++) { GUI_Delay(500); LISTBOX_DecSel(hListBox); WM_ExecIdle(); } GUI_Delay(750); /* Delete listbox widget */ LISTBOX_Delete(hListBox); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(750); } /******************************************************************* * * MainTask * * Demonstrates LISTBOX widget * ******************************************************************** */ void MainTask(void) { GUI_Init(); GUI_SetBkColor(GUI_BLUE); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_SimpleListBox - Sample", 160, 5); while(1) { _DemoListBox(); } }
2002-2007 Micrium
516
CHAPTER 15
C/GUI is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with a license and should not be redistributed in any way. We appreciate your understanding and fairness. ---------------------------------------------------------------------File : WIDGET_ListBox.c Purpose : Example demonstrating the LISTBOX widget ---------------------------------------------------------------------*/ #include #include #include #include "GUI.h" "FRAMEWIN.h" "LISTBOX.h" <stddef.h>
#define SPEED 1000 /******************************************************************* * * static variables * ******************************************************************** */ static const GUI_ConstString _ListBox[] = { "English", "Deutsch", NULL }; /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _ShowSeveralFunctions */ static void _ShowSeveralFunctions(LISTBOX_Handle hListBox) { int NumEntries, i; /* Add scrollbar */ GUI_DispStringAtCEOL("SCROLLBAR_CreateAttached", 5, 55); GUI_Delay(SPEED); SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL); GUI_Delay(SPEED * 0.75); /* Add strings */ GUI_DispStringAtCEOL("LISTBOX_AddString", 5, 55); GUI_Delay(SPEED); LISTBOX_AddString(hListBox, "Franais"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Japanese"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Italiano"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Espaol"); GUI_Delay(SPEED / 6); LISTBOX_AddString(hListBox, "Other language ..."); GUI_Delay(SPEED * 0.6); /* Set focus */ GUI_DispStringAtCEOL("WM_SetFocus", 5, 55); GUI_Delay(SPEED * 0.9); WM_SetFocus(hListBox); GUI_Delay(SPEED * 0.7); /* Set font */ GUI_DispStringAtCEOL("LISTBOX_SetFont", 5, 55); GUI_Delay(SPEED * 0.9); LISTBOX_SetFont(hListBox, &GUI_Font13B_1); GUI_Delay(SPEED * 0.7); /* Increment selection */ GUI_DispStringAtCEOL("LISTBOX_IncSel", 5, 55); GUI_Delay(SPEED); NumEntries = LISTBOX_GetNumItems(hListBox); for (i = 0; i < NumEntries - 1; i++) {
2002-2007 Micrium
517 LISTBOX_IncSel(hListBox); GUI_Delay(SPEED / 6); } GUI_Delay(SPEED / 4); /* Show automatic scrollbar */ GUI_DispStringAtCEOL("Optional automatic scrollbar", 5, 55); GUI_Delay(SPEED); LISTBOX_SetAutoScrollH(hListBox, 1); LISTBOX_SetAutoScrollV(hListBox, 1); GUI_Delay(SPEED * 0.75); /* Set font */ GUI_DispStringAtCEOL("LISTBOX_SetFont", 5, 55); GUI_Delay(SPEED); LISTBOX_SetFont(hListBox, &GUI_Font16B_1); GUI_Delay(SPEED * 0.75); /* Decrement selection */ GUI_DispStringAtCEOL("LISTBOX_DecSel", 5, 55); GUI_Delay(SPEED); for (i = 0; i < NumEntries - 1; i++) { LISTBOX_DecSel(hListBox); GUI_Delay(SPEED / 6); } GUI_Delay(SPEED / 4); /* Change width of scrollbar */ GUI_DispStringAtCEOL("Change scrollbar width", 5, 55); GUI_Delay(SPEED * 0.7); { SCROLLBAR_Handle hScrollH = WM_GetDialogItem(hListBox, GUI_ID_HSCROLL); SCROLLBAR_Handle hScrollV = WM_GetDialogItem(hListBox, GUI_ID_VSCROLL); SCROLLBAR_SetWidth(hScrollV, 14); GUI_Delay(SPEED / 4); SCROLLBAR_SetWidth(hScrollH, 14); GUI_Delay(SPEED * 0.6); } /* Change size of listbox */ GUI_DispStringAtCEOL("Change size of listbox", 5, 55); GUI_Delay(SPEED * 0.75); WM_ResizeWindow(hListBox, -15, 0); GUI_Delay(SPEED / 4); WM_ResizeWindow(hListBox, 0, -15); GUI_Delay(SPEED / 4); WM_ResizeWindow(hListBox, 15, 0); GUI_Delay(SPEED / 4); WM_ResizeWindow(hListBox, 0, 15); GUI_Delay(SPEED / 2); /* Disable item */ GUI_DispStringAtCEOL("LISTBOX_SetItemDisabled", 5, 55); GUI_Delay(SPEED); LISTBOX_SetItemDisabled(hListBox, 4, 1); GUI_Delay(SPEED * 0.75); /* Set multi selection mode */ GUI_DispStringAtCEOL("LISTBOX_SetMulti", 5, 55); GUI_Delay(SPEED); LISTBOX_SetMulti(hListBox, 1); GUI_Delay(SPEED * 0.75); /* Select item */ GUI_DispStringAtCEOL("LISTBOX_SetItemSel", 5, 55); GUI_Delay(SPEED); LISTBOX_SetItemSel(hListBox, 0, 1); GUI_Delay(SPEED / 4); LISTBOX_SetItemSel(hListBox, 1, 1); GUI_Delay(SPEED / 4); LISTBOX_SetItemSel(hListBox, 2, 1); GUI_Delay(SPEED * 0.8); /* Delete listbox widget */ GUI_DispStringAtCEOL("LISTBOX_Delete", 5, 55); GUI_Delay(SPEED * 1.1); LISTBOX_Delete(hListBox); GUI_Delay(SPEED * 0.75); } /******************************************************************* *
2002-2007 Micrium
518
CHAPTER 15
* _DemoListBox */ static void _DemoListBox(void) { LISTBOX_Handle hListBox; /* Display titel */ GUI_SetBkColor(0xB00000); GUI_SetColor(0xFFFFFF); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Listbox - Sample", 160, 5); GUI_Delay(SPEED / 2); /* Create listbox */ GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("LISTBOX_Create", 5, 55); GUI_Delay(SPEED * 0.9); hListBox = LISTBOX_Create(_ListBox, 100, 80, 120, 115, WM_CF_SHOW); GUI_Delay(SPEED * 0.75); /* Show serveral functions of listbox */ _ShowSeveralFunctions(hListBox); /* Clear display */ GUI_Clear(); GUI_Delay(SPEED * 1.5); } /******************************************************************* * * _DemoListBoxAsChild */ static void _DemoListBoxAsChild(void) { FRAMEWIN_Handle hFrame; LISTBOX_Handle hListBox; /* Display titel */ GUI_SetBkColor(0xB00000); GUI_SetColor(0xFFFFFF); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Listbox as child - Sample", 160, 5); GUI_Delay(SPEED / 2); /* Create framewin */ GUI_SetFont(&GUI_Font8x16); GUI_SetTextAlign(GUI_TA_LEFT); GUI_DispStringAtCEOL("using", 5, 40); GUI_DispStringAtCEOL("FRAMEWIN_Create", 5, 55); GUI_Delay(SPEED); hFrame = FRAMEWIN_Create("List box", NULL, WM_CF_SHOW, 100, 80, 120, 140); FRAMEWIN_SetFont(hFrame, &GUI_Font16B_ASCII); FRAMEWIN_SetActive(hFrame, 1); GUI_Delay(SPEED * 0.75); /* Create listbox */ GUI_DispStringAtCEOL("LISTBOX_CreateAsChild", 5, 55); GUI_Delay(SPEED); hListBox = LISTBOX_CreateAsChild(_ListBox, WM_GetClientWindow(hFrame), 0, 0, 0, 0, WM_CF_SHOW); GUI_Delay(SPEED * 0.75); /* Show serveral functions of listbox */ _ShowSeveralFunctions(hListBox); /* Delete framewin widget */ GUI_DispStringAtCEOL("FRAMEWIN_Delete", 5, 55); GUI_Delay(SPEED); FRAMEWIN_Delete(hFrame); GUI_Delay(SPEED * 0.75); /* Clear display */ GUI_Clear(); GUI_Delay(SPEED * 1.5); } /******************************************************************* * * MainTask * * Demonstrates LISTBOX widget * ********************************************************************
2002-2007 Micrium
2002-2007 Micrium
520
CHAPTER 15
Has input focus No surrounding FRAMEWIN No SCROLLBAR attached Grid lines not visible
Has input focus With surrounding FRAMEWIN No SCROLLBAR attached Grid lines not visible
Has input focus With surrounding FRAMEWIN SCROLLBAR attached Grid lines not visible
2002-2007 Micrium
521
Explanation
LISTVIEW widget
Has input focus With surrounding FRAMEWIN SCROLLBAR attached Grid lines visible
Default
&GUI_Font13_1 GUI_WHITE GUI_GRAY GUI_BLUE
Explanation
Default font Background color, unselected state. Background color, selected state without focus. Background color, selected state with focus. Defines the number of pixels to be scrolled if needed. Text color, unselected state. Text color, selected state without focus. Text color, selected state with focus. Color of grid lines (if shown) Default text alignment
2002-2007 Micrium
522
CHAPTER 15
Reaction
2002-2007 Micrium
523
Explanation
Sets the compare function for the given column. Sets the default background color for HEADER widgets. Sets the default font for HEADER widgets. Sets the default text color for HEADER widgets. Sets the default color of the grid lines for HEADER wid-
LISTVIEW_SetDefaultTextColor() gets. Fixes the given number of columns. LISTVIEW_SetFixed() Sets the font of the LISTVIEW. LISTVIEW_SetFont() Sets the visibility flag of the grid lines. LISTVIEW_SetGridVis() Sets the background color of a LISTVIEW cell LISTVIEW_SetItemBkColor() Sets the text of a LISTVIEW cell. LISTVIEW_SetItemText() Sets the text color of a LISTVIEW cell LISTVIEW_SetItemTextColor() Sets the number of pixels used for the left border. LISTVIEW_SetLBorder() Sets the number of pixels used for the right border. LISTVIEW_SetRBorder() Sets the row height of the LISTVIEW LISTVIEW_SetRowHeight() Sets the current selection. LISTVIEW_SetSel() Sets the current selection in unsorted state. LISTVIEW_SetSelUnsorted() Sets the column and sorting order to be sorted by. LISTVIEW_SetSort() Sets the text alignment of a column. LISTVIEW_SetTextAlign() Sets the text color. LISTVIEW_SetTextColor() Sets the user data of the given row. LISTVIEW_SetUserData()
LISTVIEW_AddColumn()
Description
Adds a new column to a LISTVIEW widget.
Prototype
void LISTVIEW_AddColumn(LISTVIEW_Handle hObj, int Width, const char * s, int Align); Parameter hObj Width s Align
Handle of widget Width of the new column Text to be displayed in the HEADER widget Text alignment mode to set. May be a combination of a horizontal and a vertical alignment flag.
Meaning
Permitted values for parameter Align (horizontal and vertical flags are OR-combinable) Horizontal alignment GUI_TA_LEFT GUI_TA_HCENTER GUI_TA_RIGHT
Align X-position left (default). Center X-position. Align X-position right (default).
Vertical alignment
2002-2007 Micrium
524
CHAPTER 15
Permitted values for parameter Align (horizontal and vertical flags are OR-combinable) GUI_TA_TOP GUI_TA_VCENTER GUI_TA_BOTTOM
Align Y-position with top of characters (default). Center Y-position. Align Y-position with bottom pixel line of font.
Add. information
The Width-parameter can be 0. If Width = 0 the width of the new column will be calculated by the given text and by the default value of the horizontal spacing. You can only add columns to an empty LISTVIEW widget. If it contains 1 or more rows you can not add a new column.
LISTVIEW_AddRow()
Description
Adds a new row to a LISTVIEW widget.
Prototype
void LISTVIEW_AddRow(LISTVIEW_Handle hObj, const GUI_ConstString * ppText); Parameter hObj ppText
Handle of widget Pointer to array containing the text of the LISTVIEW cells
Meaning
Add. information
The ppText-array should contain one item for each column. If it contains less items the remaining cells left blank.
LISTVIEW_CompareDec()
Description
Compare function for comparing 2 integer values.
Prototype
int LISTVIEW_CompareDec(const void * p0, const void * p1); Parameter p0 p1
Void pointer to first value: Void pointer to second value.
Meaning
Return value
< 0 if value of cell 0 greater than value of cell 1. 0 if value of cell 0 identical to value of cell 1. > 0 if value of cell 0 less than value of cell 1.
Add. information
The purpose of this function is to be used by the listviews sorting algorithm if the cell text represens integer values.
2002-2007 Micrium
525
For details about how to use this function for sorting please also refer to LISTVIEW_SetCompareFunc(). The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_CompareText()
Description
Compare function for comparing 2 integer values.
Prototype
int LISTVIEW_CompareText(const void * p0, const void * p1); Parameter p0 p1
Void pointer to first text: Void pointer to second text.
Meaning
Return value
> 0 if text of cell 0 greater than text of cell 1. 0 if text of cell 0 identical to text of cell 1. < 0 if text of cell 0 less than text of cell 1.
Add. information
The purpose of this function is to be used by the listviews sorting algorithm. For details about how to use this function for sorting please also refer to LISTVIEW_SetCompareFunc(). The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_Create()
(Obsolete, LISTVIEW_CreateEx should be used instead)
Description
Creates a LISTVIEW widget of a specified size at a specified location.
Prototype
LISTVIEW_Handle LISTVIEW_Create(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, int SpecialFlags); Parameter x0 y0 xsize ysize hParent Meaning
Leftmost pixel of the HEADER widget (in parent coordinates). Topmost pixel of the HEADER widget (in parent coordinates). Horizontal size of the HEADER widget (in pixels). Vertical size of the HEADER widget (in pixels). Handle of the parent window
2002-2007 Micrium
526
CHAPTER 15
Parameter Id Flags
Id of the new HEADER widget Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
Return value
Handle for the created LISTVIEW widget; 0 if the routine fails.
LISTVIEW_CreateAttached()
Description
Creates a LISTVIEW widget which is attached to an existing window.
Prototype
LISTVIEW_Handle LISTVIEW_CreateAttached(WM_HWIN hParent, int Id, int SpecialFlags); Parameter
Handle of widget hObj Id of the new LISTVIEW widget Id SpecialFlags (Not used, reserved for later use)
Meaning
Return value
Handle for the created LISTVIEW widget; 0 if the routine fails.
Add. information
An attached LISTVIEW widget is essentially a child window which will position itself on the parent window and operate accordingly.
LISTVIEW_CreateEx()
Description
Creates a LISTVIEW widget of a specified size at a specified location.
Prototype
LISTVIEW_Handle LISTVIEW_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new LISTVIEW widget will be a child of the desktop (top-level window).
2002-2007 Micrium
527
Parameter
Window create flags. Typically
WinFlags ExFlags Id
Return value
Handle for the created widget; 0 if the routine fails.
LISTVIEW_CreateIndirect()
Description
Prototype explained at the beginning of the chapter.
LISTVIEW_DecSel()
Description
Decrement the listview selection (moves the selection bar of a specified listview up by one item, if possible).
Prototype
void LISTVIEW_DecSel(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Add. information
Please note that the numbering of items always starts from the top with a value of 0; therefore decrementing the selection will actually move the selection one row up.
LISTVIEW_DeleteColumn()
Description
Deletes the specified column of the listview.
Prototype
void LISTVIEW_DeleteColumn(LISTVIEW_Handle hObj, unsigned Index); Parameter hObj Index
Handle of widget Zero based index of column to be deleted.
Meaning
Add. information
Please note that the numbering of items always starts from the left with a value of 0.
LISTVIEW_DeleteRow()
Description
Deletes the specified row of the listview.
2002-2007 Micrium
528
CHAPTER 15
Prototype
void LISTVIEW_DeleteRow(LISTVIEW_Handle hObj, unsigned Index); Parameter hObj Index
Handle of widget Zero based index of row to be deleted.
Meaning
Add. information
Please note that the numbering of items always starts from the top with a value of 0.
LISTVIEW_DisableRow()
Before After
Description
The function sets the state of the given row to disabled.
Prototype
void LISTVIEW_DisableRow(LISTVIEW_Handle hObj, unsigned Row); Parameter hObj Row
Handle of widget Zero based index of the row to be disabled.
Meaning
Add. information
When scrolling through a listview disabled items will be skipped. You can not scroll to a disabled listview item.
LISTVIEW_DisableSort()
Description
Disables sorting of the given listview. After calling this function the contents of the listview will be shown unsorted.
Prototype
void LISTVIEW_DisableSort(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Add. information
For details about how to use sorting in listview widgets please also refer to the functions LISTVIEW_SetCompareFunc() and
User's & reference manual for C/GUI 2002-2007 Micrium
529
LISTVIEW_SetSort(). The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_EnableRow()
Before After
Description
The function sets the state of the given row to enabled.
Prototype
void LISTVIEW_EnableRow(LISTVIEW_Handle hObj, unsigned Row); Parameter hObj Row
Handle of widget Zero based index of the row to be disabled.
Meaning
Add. information
Please refer to LISTVIEW_DisableRow().
LISTVIEW_EnableSort()
Description
Enables sorting for the given listview. After calling this function the contents of the listview can be rendered sorted after clicking on the header item of the desired column, by which the listview should sort its data. Please note, that this works only after a compare function for the desired column has been set.
Prototype
void LISTVIEW_EnableSort(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Add. information
For details about how to set a compare function please refer to LISTVIEW_SetCompareFunc(). The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
2002-2007 Micrium
530
CHAPTER 15
LISTVIEW_GetBkColor()
Description
Returns the background color of the given listview.
Prototype
GUI_COLOR LISTVIEW_GetBkColor(LISTVIEW_Handle hObj, unsigned Index); Parameter hObj Index
Handle of widget Index of color (see table below)
Meaning
Return value
Background color of the given listview.
LISTVIEW_GetFont()
Description
Returns a pointer to the font used to display the text of the listview.
Prototype
const GUI_FONT * LISTVIEW_GetFont(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
Pointer to the font used to display the text of the listview.
LISTVIEW_GetHeader()
Description
Returns the handle of the HEADER widget.
Prototype
HEADER_Handle LISTVIEW_GetHeader(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Handle of the HEADER widget.
2002-2007 Micrium
531
Add. information
Each LISTVIEW widget contains a HEADER widget to manage the columns. You can use this handle to change the properties of the LISTVIEW-HEADER, for example to change the text color of the HEADER widget. Example:
LISTVIEW_Handle hListView = LISTVIEW_Create(10, 80, 270, 89, 0, 1234, WM_CF_SHOW, 0); HEADER_Handle hHeader = LISTVIEW_GetHeader(hListView); HEADER_SetTextColor(hHeader, GUI_GREEN);
LISTVIEW_GetItemText()
Description
Returns the text of the given listview cell by copying it to the given buffer.
Prototype
void LISTVIEW_GetItemText(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, char* pBuffer, unsigned MaxSize); Parameter hObj Column Row pBuffer MaxSize
Handle of widget Zero based index of the cells column. Zero based index of the cells row Pointer to a buffer to be filled by the routine. Size in bytes of the buffer.
Meaning
Add. information
If the text of the cell does not fit into the buffer, the number of bytes specified by the parameter MaxSize will be copied to the buffer.
LISTVIEW_GetNumColumns()
Description
Returns the number of columns of the given LISTVIEW widget.
Prototype
unsigned LISTVIEW_GetNumColumns(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Number of columns of the given LISTVIEW widget.
LISTVIEW_GetNumRows()
Description
Returns the number of rows of the given LISTVIEW widget.
2002-2007 Micrium
532
CHAPTER 15
Prototype
unsigned LISTVIEW_GetNumRows(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Number of rows of the given LISTVIEW widget.
LISTVIEW_GetSel()
Description
Returns the number of the currently selected row in a specified LISTVIEW widget.
Prototype
int LISTVIEW_GetSel(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Number of the currently selected row.
LISTVIEW_GetSelUnsorted()
Description
Returns the index of the currently selected row in unsorted state.
Prototype
int LISTVIEW_GetSelUnsorted(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
Return value
Index of the currently selected row in unsorted state.
Add. information
This function returns the actually index of the selected row, whereas the function LISTVIEW_GetSel() only returns the index of the sorted row. The actuall (unsorted) row index should be used in function calls as row index. The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_GetTextColor()
Description
Returns the text color of the given listview.
2002-2007 Micrium
533
Prototype
GUI_COLOR LISTVIEW_GetTextColor(LISTVIEW_Handle hObj, unsigned Index); Parameter hObj Index
Handle of widget Index of color (see table below)
Meaning
Return value
Text color of the given listview.
LISTVIEW_GetUserData()
Description
Returns the user data of the given row.
Prototype
U32 LISTVIEW_GetUserData(LISTVIEW_Handle hObj, unsigned Row); Parameter hObj Row
Handle of widget Zero based index of row.
Meaning
Return value
User data of the given row.
Add. information
For details about how to set user data of a row please refer to the function LISTVIEW_SetUserData().
LISTVIEW_IncSel()
Description
Increment the list box selection (moves the selection bar of a specified LISTVIEW down by one item).
Prototype
void LISTVIEW_IncSel(LISTVIEW_Handle hObj); Parameter hObj
Handle of widget
Meaning
2002-2007 Micrium
534
CHAPTER 15
LISTVIEW_InsertRow()
Description
Inserts a new row into the listview at the given position.
Prototype
int LISTVIEW_InsertRow(LISTVIEW_Handle hObj, unsigned Index, const GUI_ConstString * ppText); Parameter hObj Index ppText
Handle of widget Index of the new row. Pointer to a string array containing the cell data of the new row.
Meaning
Return value
0 if function succeed, 1 if an error occures.
Add. information
The ppText-array should contain one item for each column. If it contains less items the remaining cells left blank. If the given index is >= the current number of rows, the function LISTVIEW_AddRow() will be used to add the new row. The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_SetAutoScrollH()
Description
Enables/disables the automatic use of a horizontal scrollbar.
Prototype
void LISTVIEW_SetAutoScrollH(LISTVIEW_Handle hObj, int OnOff); Parameter hObj OnOff
Handle of widget (see table below)
Meaning
Add. information
If enabled the listview checks if all columns fit into the widgets area. If not a horizontal scrollbar will be added.
LISTVIEW_SetAutoScrollV()
Description
Enables/disables the automatic use of a vertical scrollbar.
2002-2007 Micrium
535
Prototype
void LISTVIEW_SetAutoScrollV(LISTVIEW_Handle hObj, int OnOff); Parameter hObj OnOff
Handle of widget (see table below)
Meaning
Add. information
If enabled the listview checks if all rows fit into the widgets area. If not a vertical scrollbar will be added.
LISTVIEW_SetBkColor()
Description
Sets the background color of the given LISTVIEW widget.
Prototype
void LISTVIEW_SetBkColor(LISTVIEW_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of widget Index for background color (see table below). Color to be set.
Meaning
Add. Information
To set the background color for a single cell the function LISTVIEW_SetItemBkColor() should be used. The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_SetColumnWidth()
Description
Sets the width of the given column.
Prototype
void LISTVIEW_SetColumnWidth(LISTVIEW_Handle hObj,
2002-2007 Micrium
536
CHAPTER 15
Meaning
LISTVIEW_SetCompareFunc()
Description
Sets the compare function for the given column. A compare function needs to be set if the listview widget should be sorted by the given column.
Prototype
void LISTVIEW_SetCompareFunc(LISTVIEW_Handle hObj, unsigned Column, int (* fpCompare)(const void * p0, const void * p1)); Parameter hObj Column fpCompare
Handle of widget Index of the desired column for which the compare function should be set. Function pointer to compare function.
Meaning
Add. information
If the sorting feature of the listview widget is used, the widget uses a compare function to decide if the contents of one cell is greater, equal or less than the contents of the other cell. Per default no compare function is set for the listview columns. For each column which should be used for sorting, a compare function needs to be set. The cells of the listview widget contain text. But sometimes the text represents data of other types like dates, integers or others. So different compare functions are required for sorting. C/GUI provides 2 compare functions: LISTVIEW_CompareText(): text. Function can be used for comparing cells containing
LISTVIEW_CompareDec(): Function can be used for comparing cells which text, where the contents represents integer values. The compare function should return a value >0, if the contents of the second cell is greater than the contents of the first cell and <0, if the contents of the second cell is less than the contents of the first cell or 0 if equal. Also user defined compare functions can be used. The prototype of a applicationdefined function should be defined as follows:
2002-2007 Micrium
537
Prototype
int APPLICATION_Compare(const void * p0, const void * p1); Parameter p0 p1 Meaning
Pointer to NULL terminated string data of the first cell. Pointer to NULL terminated string data of the second cell.
Example
int APPLICATION_Compare(const void * p0, const void * p1) { return strcmp((const char *)p1, (const char *)p0); } void SetAppCompareFunc(WM_HWIN hListView, int Column) { LISTVIEW_SetCompareFunc(hListView, Column, APPLICATION_Compare); }
The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_SetDefaultBkColor()
Description
Sets the default background color for new LISTVIEW widgets.
Prototype
GUI_COLOR LISTVIEW_SetDefaultBkColor(unsigned int Index, GUI_COLOR Color); Parameter Index Color
Color to be set as default
Meaning
Index of default background color (see table below)
Return value
Previous default value.
LISTVIEW_SetDefaultFont()
Description
Sets the default font for new LISTVIEW widgets.
Prototype
const GUI_FONT * LISTVIEW_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont Meaning
Pointer to font used for new LISTVIEW widgets
2002-2007 Micrium
538
CHAPTER 15
Return value
Previous default value.
LISTVIEW_SetDefaultGridColor()
Description
Sets the default color of the grid lines for new LISTVIEW widgets.
Prototype
GUI_COLOR LISTVIEW_SetDefaultGridColor(GUI_COLOR Color); Parameter Color
New default value
Meaning
Return value
Previous default value
LISTVIEW_SetDefaultTextColor()
Description
Sets the default text color for new LISTVIEW widgets.
Prototype
GUI_COLOR LISTVIEW_SetDefaultTextColor(unsigned int Index, GUI_COLOR Color); Parameter Index Color
Color to be set as default
Meaning
Index of default text color (see table below)
Return value
Previous default value.
LISTVIEW_SetFixed()
Description
Fixes the given number of columns at their horizontal positions.
Prototype
unsigned LISTVIEW_SetFixed(LISTVIEW_Handle hObj, unsigned Fixed); Parameter hObj Fixed
Handle of listview. Number of columns to be fixed at their horizontal positions.
Meaning
2002-2007 Micrium
539
Add. Information
Using this function makes sense if one or more columns should remain at their horizontal positions during scrolling operations.
LISTVIEW_SetFont()
Description
Sets the listview font.
Prototype
void LISTVIEW_SetFont(LISTVIEW_Handle hObj, const GUI_FONT * pfont); Parameter hObj pFont
Handle of listview. Pointer to the font.
Meaning
LISTVIEW_SetGridVis()
Description
Sets the visibility flag of the grid lines. When creating a LISTVIEW the grid lines are disabled per default.
Prototype
int LISTVIEW_SetGridVis(LISTVIEW_Handle hObj, int Show); Parameter hObj Show
Handle of widget Sets the visibility of the grid lines
Meaning
Return value
Previous value of the visibility flag.
LISTVIEW_SetItemBkColor()
Before After
Description
Sets the background color of the given cell.
2002-2007 Micrium
540
CHAPTER 15
Prototype
void LISTVIEW_SetItemBkColor(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, unsigned int Index, GUI_COLOR Color); Parameter hObj Column Row Index Color
Handle of widget Number of column. Number of row. Index of background color (see table below). Color to be used.
Meaning
Add. Information
This function overwrites the default background color for the given cell set by LISTVIEW_SetBkColor().
LISTVIEW_SetItemText()
Description
Sets the text of one cell of the LISTVIEW widget specified by row and column.
Prototype
void LISTVIEW_SetItemText(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, const char * s); Parameter hObj Column Row s
Handle of widget. Number of column. Number of row. Text to be displayed in the table cell.
Meaning
2002-2007 Micrium
541
LISTVIEW_SetItemTextColor()
Before After
Description
Sets the text color of the given cell.
Prototype
void LISTVIEW_SetItemTextColor(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, unsigned int Index, GUI_COLOR Color); Parameter hObj Column Row Index Color
Handle of widget Number of column. Number of row. Index of text color (see table below). Color to be used.
Meaning
Add. Information
This function overwrites the LISTVIEW_SetTextColor(). default text color for the given cell set by
LISTVIEW_SetLBorder()
Before After
Description
Sets the number of pixels used for the left border within each cell of the listview.
2002-2007 Micrium
542
CHAPTER 15
Prototype
void LISTVIEW_SetLBorder(LISTVIEW_Handle hObj, unsigned BorderSize); Parameter hObj BorderSize
Handle of widget. Number of pixels to be used.
Meaning
Add. Information
Using this function has no effect to the header widget used by the listview.
LISTVIEW_SetRBorder()
Before After
Description
Sets the number of pixels used for the right border within each cell of the listview.
Prototype
void LISTVIEW_SetRBorder(LISTVIEW_Handle hObj, unsigned BorderSize); Parameter hObj BorderSize
Handle of widget. Number of pixels to be used.
Meaning
Add. Information
Using this function has no effect to the header widget used by the listview.
LISTVIEW_SetRowHeight()
Description
Sets the number of pixels used for the height of each row of the listview.
Prototype
unsigned LISTVIEW_SetRowHeight(LISTVIEW_Handle hObj, unsigned RowHeight); Parameter hObj
Handle of widget.
Meaning
Return value
Previous value of the row height set by this function. If the return value is 0, the height of the rows depends on the height of the font used by the widget.
2002-2007 Micrium
543
Add. Information
Per default the height of the rows depends on the height of the used font.
LISTVIEW_SetSel()
Description
Sets the selected row of a specified LISTVIEW widget.
Prototype
void LISTVIEW_SetSel(LISTVIEW_Handle hObj, int Sel); Parameter hObj Sel
Handle of widget Element to be selected.
Meaning
LISTVIEW_SetSelUnsorted()
Description
Sets the index of the currently selected row in unsorted state.
Prototype
void LISTVIEW_SetSelUnsorted(LISTVIEW_Handle hObj, int Sel); Parameter hObj Sel
Handle of widget. Zero based selection index in unsorted state.
Meaning
Add. information
This function sets the actually index of the selected row, whereas the function LISTVIEW_SetSel() sets the index of the sorted row. The actuall (unsorted) row index should be used in function calls as row index. The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_SetSort()
Before After
Description
This function sets the column to be sorted by and the sorting order.
User's & reference manual for C/GUI 2002-2007 Micrium
544
CHAPTER 15
Prototype
unsigned LISTVIEW_SetSort(LISTVIEW_Handle hObj, unsigned Column, unsigned Reverse); Parameter hObj Column Reverse
Handle of widget. Column to be sorted by. 0 for normal sorting order (greatest element at the top), 1 for reverse order.
Meaning
Return value
0 if function was successfully, 1 if not.
Add. information
Before calling this function a compare function needs to be set for the desired column. For details about how to set a compare function please refer to the function LISTVIEW_SetCompareFunc(). The sample folder contains the sample WIDGET_SortedListview.c which shows how to use the function.
LISTVIEW_SetTextAlign()
Description
Sets the alignment for the given column.
Prototype
void LISTVIEW_SetTextAlign(LISTVIEW_Handle hObj, unsigned int Index, int Align); Parameter hObj Index Align
Handle of widget Number of column Text alignment mode to set. May be a combination of a horizontal and a vertical alignment flag.
Meaning
Permitted values for parameter Align (horizontal and vertical flags are OR-combinable) Horizontal alignment GUI_TA_LEFT GUI_TA_HCENTER GUI_TA_RIGHT GUI_TA_TOP GUI_TA_VCENTER GUI_TA_BOTTOM
Align X-position left (default). Center X-position. Align X-position right (default).
Vertical alignment
Align Y-position with top of characters (default). Center Y-position. Align Y-position with bottom pixel line of font.
LISTVIEW_SetTextColor()
Description
Sets the text color of the given LISTVIEW widget.
User's & reference manual for C/GUI 2002-2007 Micrium
545
Prototype
void LISTVIEW_SetTextColor(LISTVIEW_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of widget Index for text color (see table below). Color to be set.
Meaning
LISTVIEW_SetUserData()
Description
Sets the user data of the given row.
Prototype
void LISTVIEW_SetUserData(LISTVIEW_Handle hObj, unsigned Row, U32 UserData); Parameter hObj Row UserData
Handle of widget. Row for which the user data should be set. Value to be associated with the row.
Meaning
Add. information
Sets the 32-bit value associated with the row. Each row has a corresponding 32-bit value intended for use by the application.
15.12.5 Example
The source of the following sample is available as WIDGET_ListView.c in the samples shipped with C/GUI:
2002-2007 Micrium
546
CHAPTER 15
Explanation
Black/white display
The table above shows the appearance of the menu widget using its default effect WIDGET_Effect_3D1L and using WIDGET_Effect_Simple. It also works with all other effects.
2002-2007 Micrium
547
WM_MENU
Description
This message is sent to inform the owner of a menu about selecting an item or opening a submenu. Disabled menu items will not send this message.
Data
The Data.p pointer of the message points to a MENU_MSG_DATA structure.
Elements of MENU_MSG_DATA
Data type U16 U16 Element MsgType ItemId
(see table below) Id of menu item.
Meaning
MENU_ON_ITEMACTIVATE MENU_ON_ITEMPRESSED
MENU_ON_ITEMSELECT
Sample
The following sample shows how to react on a WM_MENU message:
void Callback(WM_MESSAGE* pMsg) { MENU_MSG_DATA * pData; WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_MENU: pData = (MENU_MSG_DATA*)pMsg->Data.p; switch (pData->MsgType) { case MENU_ON_ITEMACTIVATE: _UpdateStatusbar(pData->ItemId); break; case MENU_ON_INITMENU: _OnInitMenu(); break; case MENU_ON_ITEMSELECT: switch (pData->ItemId) { case ID_MENU_ITEM0: ... /* React on selection of menu item 0 */ break; case ID_MENU_ITEM1: ... /* React on selection of menu item 1 */ break;
2002-2007 Micrium
CHAPTER 15
MENU_ITEM_DATA
This structure serves as a container to set or retrieve information about menu items.
Elements of MENU_ITEM_DATA
Data type const char * U16 U16 MENU_Handle Element pText Id Flags hSubmenu
Menu item text. Id of the menu item. (see table below) If the item represents a submenu this element contains the handle of the submenu.
Meaning
2002-2007 Micrium
549
Default
GUI_LIGHTGRAY 0x980000 GUI_LIGHTGRAY 0x980000 0x7C7C7C
Explanation
Background color for enabled and unselected items. Background color for enabled and selected items. Background color for disabled items. Background color for disabled and selected items. Background color for active submenu items. Border between item text and item bottom. Border between item text and left edge of item. Border between item text and right edge of item. Border between item text and item top. Font used. Text color for enabled and unselected items. Text color for enabled and selected items. Text color for disabled items. Text color for disabled and selected items. Text color for active submenu items.
MENU_BORDER_BOTTOM_DEFAULT 2 MENU_BORDER_LEFT_DEFAULT MENU_BORDER_RIGHT_DEFAULT MENU_BORDER_TOP_DEFAULT MENU_EFFECT_DEFAULT MENU_FONT_DEFAULT MENU_TEXTCOLOR0_DEFAULT MENU_TEXTCOLOR1_DEFAULT MENU_TEXTCOLOR2_DEFAULT MENU_TEXTCOLOR3_DEFAULT MENU_TEXTCOLOR4_DEFAULT
4 4 2
GUI_KEY_RIGHT
GUI_KEY_LEFT
GUI_KEY_DOWN
2002-2007 Micrium
550
CHAPTER 15
Reaction
- If the menu is vertical, the selection moves to the previous item. - If the menu is not the top level menu the current menu will be closed and the focus moves to the previous menu. - If the menu is the top level menu, the current menu item becomes unselected. - If the current menu item is a submenu, the submenu opens and the focus moves to the submenu. - If the current menu item is not a submenu, all submenus of the top level menu closes and a MENU_ON_ITEMSELECT message will be send to the owner of the menu.
GUI_KEY_ENTER
2002-2007 Micrium
551
2002-2007 Micrium
552
CHAPTER 15
MENU_AddItem()
Before After
Description
This function adds a new item to the end of the given menu.
Prototype
void MENU_AddItem(MENU_Handle hObj, const MENU_ITEM_DATA * pItemData); Parameter hObj pItemData
Handle of widget. Poiner to a MENU_ITEM_DATA structure containing the information of the new item.
Meaning
Add. Information
If using a menu with several submenus the Id of the menu items should be unique. Different submenus should not contain menu items with the same Ids. When adding items to a menu and no fixed sizes are used the size of the menu will be adapted. Please refer to the beginning of the menu chapter for details about the MENU_ITEM_INFO data structure.
MENU_Attach()
Description
Attaches the given menu at the given position with the given size to a specified window.
Prototype
void MENU_Attach(MENU_Handle hObj, WM_HWIN hDestWin, int x, int y, int xSize, int ySize, int Flags); Parameter hObj hDestWin x y xSize ySize Flags
Handle of widget. Handle to the window to which the menu should be attached. X position in window coordinates of the menu. Y position in window coordinates of the menu. Fixed X size of the menu. For details please refer to Reserved for future use
Meaning
MENU_CreateEx() . Fixed Y size of the menu. For details please refer to MENU_CreateEx() .
2002-2007 Micrium
553
Add. Information
After creating a menu widget this function can be used to attach the menu to an existing window.
MENU_CreateEx()
Description
Creates a menu of a specified size at a specified location.
Prototype
MENU_Handle MENU_CreateEx(int x0, int y0, int xSize, int ySize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xSize ySize Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Fixed horizontal size of the widget (in pixels). 0 if menu should handle the xSize. Fixed vertical size of the widget (in pixels). 0 if menu should handle the ySize. Handle of parent window. If 0, the new widget will be a child of the desktop (toplevel window). In some cases it can be useful to create the menu widget in unattached state and attach it later to an existing window. For this case WM_UNATTACHED can be used as parameter. Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Window ID of the widget.
hParent
WinFlags ExFlags Id
MENU_CF_OPEN_ON_POINTEROVER
Return value
Handle for the created widget; 0 if the routine fails.
Add. Information
The parameters xSize and/or ySize specifies if a fixed width and/or height should be used for the menu. If these parameters are > 0, fixed sizes should be used. If for example the menu should be attached as a horizontal menu to the top of a window it can be necessary to use a fixed X size which covers the whole top of the window. In this case the parameter xSize can be used to set a fixed X size of the menu. When attaching or deleting items of a menu with a fixed size the size of the widget does not change.
2002-2007 Micrium
554
CHAPTER 15
If the values are 0, the menu handles its size itself. That means the size of the menu depends on the size of the current menu items of a menu. If items are added or removed the size of the widget will be adapted.
MENU_DeleteItem()
Before After
Description
Deletes a given menu entry from a menu.
Prototype
void MENU_DeleteItem(MENU_Handle hObj, U16 ItemId); Parameter hObj ItemId
Handle of widget. Id of the menu item to be deleted.
Meaning
Add. Information
If the item does not exist the function returns immediately. When deleting items from a menu and no fixed sizes are used the window size will be adapted.
MENU_DisableItem()
Before After
Description
Disables the given menu item.
2002-2007 Micrium
555
Prototype
void MENU_DisableItem(MENU_Handle hObj, U16 ItemId); Parameter hObj ItemId
Handle of widget. Id of the menu item to be disabled.
Meaning
Add. Information
If a disabled menu item is selected, the menu widget sends no WM_MENU message to the owner. A disabled submenu item can not be opened.
MENU_EnableItem()
Before After
Description
Enables the given menu item.
Prototype
void MENU_EnableItem(MENU_Handle hObj, U16 ItemId); Parameter hObj ItemId
Handle of widget. Id of the menu item to be enabled.
Meaning
Add. Information
For details please refer to function MENU_DisableItem().
MENU_GetDefaultBkColor()
Description
Returns the default background color used to draw new menu items.
Prototype
GUI_COLOR MENU_GetDefaultBkColor(unsigned ColorIndex); Parameter ColorIndex Meaning
Index of color to be returned (see table below).
2002-2007 Micrium
556
CHAPTER 15
Permitted values for parameter ColorIndex MENU_CI_ACTIVE_SUBMENU MENU_CI_DISABLED MENU_CI_DISABLED_SEL MENU_CI_ENABLED MENU_CI_SELECTED
Background color of active submenu items. Background color of disabled menu items. Background color of disabled and selected menu items. Background color of enabled and not selected menu items. Background color of enabled and selected menu items.
Return value
Default background color used to draw new menu items.
Add. Information
For details please refer to function MENU_SetBkColor().
MENU_GetDefaultBorderSize()
Description
Returns the default border size used for new menu widgets.
Prototype
U8 MENU_GetDefaultBorderSize(unsigned BorderIndex); Parameter BorderIndex
(see table below)
Meaning
Return value
Default border size used for new menu widgets.
Add. Information
For details please refer to function MENU_SetBorderSize().
MENU_GetDefaultEffect()
Description
Returns the default effect for new menus.
Prototype
const WIDGET_EFFECT * MENU_GetDefaultEffect(void);
Return value
The result of the function is a pointer to a WIDGET_EFFECT structure.
2002-2007 Micrium
557
Add. Information
For more information please refer to the function WIDGET_SetDefaultEffect().
MENU_GetDefaultFont()
Description
Returns a pointer to the default font used to display the menu item text of new menus.
Prototype
const GUI_FONT * MENU_GetDefaultFont(void);
Return value
Pointer to the default font used to display the menu item text of new menus.
MENU_GetDefaultTextColor()
Description
Returns the default text color for new menus.
Prototype
GUI_COLOR MENU_GetDefaultTextColor(unsigned ColorIndex); Parameter ColorIndex Meaning
Index of color to be returned (see table below)
Permitted values for parameter ColorIndex MENU_CI_ACTIVE_SUBMENU MENU_CI_DISABLED MENU_CI_DISABLED_SEL MENU_CI_ENABLED MENU_CI_SELECTED
Text color of active submenu items. Text color of disabled menu items. Text color of disabled and selected menu items. Text color of enabled and not selected menu items. Text color of enabled and selected menu items.
Return value
Default text color for new menus.
Add. Information
For details please refer to function MENU_SetTextColor().
MENU_GetItem()
Description
Retrieves information about the given menu item.
2002-2007 Micrium
558
CHAPTER 15
Prototype
void MENU_GetItem(MENU_Handle hObj, U16 ItemId, MENU_ITEM_DATA * pItemData); Parameter hObj ItemId pItemData
Handle of widget. Id of the requested menu item. Poiner to a MENU_ITEM_DATA structure to be filled by the function.
Meaning
Add. Information
If using a menu with several submenus the handle of the widget needs to be the handle of the menu/submenu containing the requested item or the handle of a higher menu/submenu. The function sets the element pText of the MENU_ITEM_INFO data structure to 0. To retrieve the menu item text the function MENU_GetItemText() should be used. Please refer to the beginning of the menu chapter for details about the MENU_ITEM_INFO data structure.
MENU_GetItemText()
Description
Returns the text of the given menu item.
Prototype
void MENU_GetItemText(MENU_Handle hObj, U16 ItemId, char * pBuffer, unsigned BufferSize); Parameter hObj ItemId pBuffer BufferSize
Handle of widget. Id of the requested menu item. Buffer to be filled by the function. Maximum number of bytes to be retrieved.
Meaning
MENU_GetNumItems()
Description
Returns the number of items of the given menu.
Prototype
unsigned MENU_GetNumItems(MENU_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
Number of items of the given menu.
2002-2007 Micrium
559
MENU_GetOwner()
Description
Returns the owner window of the given menu.
Prototype
WM_HWIN MENU_GetOwner(MENU_Handle hObj); Parameter hObj
Handle of widget.
Meaning
Return value
Owner window of the given menu.
MENU_InsertItem()
Before After
Description
Inserts a menu item at the given position.
Prototype
void MENU_InsertItem(MENU_Handle hObj, U16 ItemId, const MENU_ITEM_DATA * pItemData); Parameter hObj ItemId pItemData
Handle of widget. Id of the menu item the new item should be inserted before. Poiner to a MENU_ITEM_DATA structure containing the information of the new item.
Meaning
Add. Information
Please refer to the beginning MENU_ITEM_INFO data structure. of the menu chapter for details about the
MENU_Popup()
Description
Opens the given menu at the given position. After selecting a menu item or after touching the display outside the menu the popup menu will be closed.
Prototype
void MENU_Popup(MENU_Handle hObj, WM_HWIN hDestWin, int x, int y,
User's & reference manual for C/GUI 2002-2007 Micrium
560
CHAPTER 15
int xSize, int ySize, int Flags); Parameter hObj hDestWin x y xSize ySize Flags
Handle of widget. Handle to the window to which the menu should be attached. X position in window coordinates of the menu. Y position in window coordinates of the menu. Fixed X size of the menu. For details please refer to Reserved for future use
Meaning
MENU_CreateEx() . Fixed Y size of the menu. For details please refer to MENU_CreateEx() .
Add. Information
After selecting a menu item or after touching the display outside the popup menu the menu will be closed. Please note that the menu will not be deleted automatically. The sample folder contains the sample WIDGET_PopupMenu.c which shows how to use the function.
MENU_SetBkColor()
Before After
Description
Sets the background color of the given menu.
Prototype
void MENU_SetBkColor(MENU_Handle hObj, unsigned ColorIndex, GUI_COLOR Color); Parameter hObj ColorIndex Color
Handle of widget. Index of color (see table below) Color to be used.
Meaning
Permitted values for parameter ColorIndex MENU_CI_ACTIVE_SUBMENU MENU_CI_DISABLED MENU_CI_DISABLED_SEL MENU_CI_ENABLED MENU_CI_SELECTED
Background color of active submenu items. Background color of disabled menu items. Background color of disabled and selected menu items. Background color of enabled and not selected menu items. Background color of enabled and selected menu items.
2002-2007 Micrium
561
MENU_SetBorderSize()
Before After
Before
After
Description
Sets the border size of the given menu.
Prototype
void MENU_SetBorderSize(MENU_Handle hObj, unsigned BorderIndex, U8 BorderSize); Parameter hObj BorderIndex BorderSize
Handle of widget. (see table below) Size to be used.
Meaning
MENU_SetDefaultBkColor()
Description
Sets the default background color used to draw new menu items.
2002-2007 Micrium
562
CHAPTER 15
Prototype
void MENU_SetDefaultBkColor(unsigned ColorIndex, GUI_COLOR Color); Parameter ColorIndex Color
Color to be used.
Meaning
Index of color to be returned (see table below).
Permitted values for parameter ColorIndex MENU_CI_ACTIVE_SUBMENU MENU_CI_DISABLED MENU_CI_DISABLED_SEL MENU_CI_ENABLED MENU_CI_SELECTED
Background color of active submenu items. Background color of disabled menu items. Background color of disabled and selected menu items. Background color of enabled and not selected menu items. Background color of enabled and selected menu items.
Add. Information
For details please refer to function MENU_SetBkColor().
MENU_SetDefaultBorderSize()
Description
Sets the default border size used for new menu widgets.
Prototype
void MENU_SetDefaultBorderSize(unsigned BorderIndex, U8 BorderSize); Parameter BorderIndex BorderSize
(see table below) Border size to be used.
Meaning
Add. Information
For details please refer to function MENU_SetBorderSize().
MENU_SetDefaultEffect()
Description
Sets the default effect for new menus.
2002-2007 Micrium
563
Prototype
void MENU_SetDefaultEffect(const WIDGET_EFFECT* pEffect); Parameter pEffect Meaning
Pointer to a WIDGET_EFFECT structure.
Add. Information
For more information please refer to the function WIDGET_SetDefaultEffect().
MENU_SetDefaultFont()
Description
Sets the pointer to the default font used to display the menu item text of new menus.
Prototype
void MENU_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont
Pointer to the
Add. Information
For details please refer to function MENU_SetFont().
MENU_SetDefaultTextColor()
Description
Sets the default text color for new menus.
Prototype
void MENU_SetDefaultTextColor(unsigned ColorIndex, GUI_COLOR Color); Parameter ColorIndex Color
Color to be used
Meaning
Index of color to be used (see table below)
Permitted values for parameter ColorIndex MENU_CI_ACTIVE_SUBMENU MENU_CI_DISABLED MENU_CI_DISABLED_SEL MENU_CI_ENABLED MENU_CI_SELECTED
Text color of active submenu items. Text color of disabled menu items. Text color of disabled and selected menu items. Text color of enabled and not selected menu items. Text color of enabled and selected menu items.
Add. Information
For details please refer to function MENU_SetTextColor().
2002-2007 Micrium
564
CHAPTER 15
MENU_SetFont()
Before After
Description
Sets the pointer to the default font used to display the menu item text of new menus.
Prototype
void MENU_SetFont(MENU_Handle hObj, const GUI_FONT * pFont); Parameter hObj pFont
Handle of widget. Pointer to the
MENU_SetItem()
Before After
Description
Sets the item information for the given menu item.
Prototype
void MENU_SetItem(MENU_Handle hObj, U16 ItemId, const MENU_ITEM_DATA * pItemData); Parameter hObj ItemId pItemData
Handle of widget. Id of the menu item to be changed. Poiner to a MENU_ITEM_DATA structure containing the new information.
Meaning
2002-2007 Micrium
565
MENU_SetOwner()
Description
Sets the owner of the menu to be informed by the widget.
Prototype
void MENU_SetOwner(MENU_Handle hObj, WM_HWIN hOwner); Parameter hObj hOwner
Handle of widget. Handle of the owner window which should receive the WM_MENU messages of the menu.
Meaning
Add. Information
If no owner is set the parent window of the menu will receive WM_MENU messages. In some cases it makes sense to send the messages not to the parent window of the menu. In this case this function can be used to set the recipient for the WM_MENU messages.
MENU_SetSel()
Before After
Description
Sets the selected item of the given menu.
Prototype
void MENU_SetSel(MENU_Handle hObj, int Sel); Parameter hObj Sel
Handle of widget. Zero based index of menu item to be selected.
Meaning
Return value
The function returns the zero based index of the previous selected menu item.
Add. Information
A value <0 for parameter Sel deselects the menu items.
2002-2007 Micrium
566
CHAPTER 15
MENU_SetTextColor()
Before After
Description
Sets the text color of the given menu.
Prototype
void MENU_SetTextColor(MENU_Handle hObj, unsigned ColorIndex, GUI_COLOR Color); Parameter hObj ColorIndex Color
Handle of widget. Index of color to be used (see table below) Color to be used.
Meaning
Permitted values for parameter ColorIndex MENU_CI_ACTIVE_SUBMENU MENU_CI_DISABLED MENU_CI_DISABLED_SEL MENU_CI_ENABLED MENU_CI_SELECTED
Text color of active submenu items. Text color of disabled menu items. Text color of disabled and selected menu items. Text color of enabled and not selected menu items. Text color of enabled and selected menu items.
2002-2007 Micrium
567
Default
Explanation
Distance between the elements of a message box and the elements of the client window frame. X-size of the "OK" button. Y-size of the "OK" button. Color of the client window background.
GUI_WHITE
GUI_MessageBox()
Description
Creates and displays a message box.
2002-2007 Micrium
568
CHAPTER 15
Prototype
int GUI_MessageBox(const char* sMessage, const char* sCaption, int Flags); Parameter sMessage sCaption Flags
Message to display. Caption for the title bar of the frame window. (see table below)
Meaning
Permitted values for parameter Flags GUI_MESSAGEBOX_CF_MOVEABLE the title bar or the frame. No function. 0
The message box can be moved by dragging
Add. Information
This function gives you the possibility to create and execute a message box with one line of code. The sample folder contains the sample DIALOG_MessageBox.c which shows how to use this function. For details about dragging please refer to the function FRAMEWIN_SetMoveable().
MESSAGEBOX_Create()
Description
Creates a message box.
Prototype
WM_HWIN GUI_MessageBox(const char* sMessage, const char* sCaption, int Flags); Parameter sMessage sCaption Flags
Message to display. Caption for the title bar of the frame window. (see table below)
Meaning
Return value
Handle of the message box window.
Add. information
This function gives you the possibility to create a messagebox before it is executed. The advantage of using this function is the possibility of changing the dialog properties or the dialog behaviour by using a user defined callback function. The function GUI_ExecCreatedDialog() should be used to execute the message box.
2002-2007 Micrium
569
edit mode, automatic horizontal scrollbar, non wrapping mode, insert mode,
edit mode, automatic vertical scrollbar, word wrapping mode, overwrite mode,
2002-2007 Micrium
570
CHAPTER 15
Default
GUI_Font13_1 GUI_WHITE 0xC0C0C0 GUI_BLACK GUI_BLACK Font used.
Explanation
Background color. Background color read only mode. Text color. Text color read only mode.
Reaction
2002-2007 Micrium
571
Explanation
MULTIEDIT_AddKey()
Description
Adds user input to a specified multiedit widget.
Prototype
void MULTIEDIT_AddKey(MULTIEDIT_HANDLE hObj, int Key); Parameter hObj Key
Handle of multiedit widget. Character to be added.
Meaning
2002-2007 Micrium
572
CHAPTER 15
Add. information
The specified character is added to the user input of the multiedit widget. If the maximum count of characters has been reached, another character will not be added.
MULTIEDIT_AddText()
Description
Adds the given text at the current cursor position.
Prototype
int MULTIEDIT_AddText(MULTIEDIT_HANDLE hObj, const char * s); Parameter hObj s
Handle of multiedit widget. Pointer to a NULL terminated text to be added.
Meaning
Add. information
If the number of characters exceeds the limit set with the function MULTIEDIT_SetMaxNumChars() the function will add only the characters of the text which fit into the widget respecting the limit.
MULTIEDIT_Create()
(Obsolete, MULTIEDIT_CreateEx should be used instead)
Description
Creates a MULTIEDIT widget of a specified size at a specified location.
Prototype
MULTIEDIT_HANDLE MULTIEDIT_Create(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, int ExFlags, const char * pText, int MaxLen); Parameter x0 y0 xsize ysize hParent Id Flags ExFlags pText MaxLen Meaning
Leftmost pixel of the multiedit widget (in parent coordinates). Topmost pixel of the multiedit widget (in parent coordinates). Horizontal size of the multiedit widget (in pixels). Vertical size of the multiedit widget (in pixels). Parent window of the multiedit widget. ID of the multiedit widget. Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Text to be used. Maximum number of bytes for text and prompt.
2002-2007 Micrium
573
Return value
Handle for the created MULTIEDIT widget; 0 if the routine fails.
MULTIEDIT_CreateEx()
Description
Creates a MULTIEDIT widget of a specified size at a specified location.
Prototype
MULTIEDIT_HANDLE MULTIEDIT_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, int BufferSize, const char* pText); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id BufferSize pText Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new MULTIEDIT widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Window ID of the widget. Initial text buffer size of the widget. Use the maximum number of characters. Text to be used.
MULTIEDIT_SetMaxNumChars to set
Return value
Handle for the created widget; 0 if the routine fails.
MULTIEDIT_CreateIndirect()
Prototype explained at the beginning of the chapter.
2002-2007 Micrium
574
CHAPTER 15
MULTIEDIT_EnableBlink()
Description
Enables/disables a blinking cursor.
Prototype
void MULTIEDIT_EnableBlink(EDIT_Handle hObj, int Period, int OnOff); Parameter hObj Period OnOff
Handle of edit field. Blinking period 1 enables blinking, 0 disables blinking
Meaning
Add. Information
This function calls GUI_X_GetTime().
MULTIEDIT_GetCursorCharPos()
Description
Returns the number of the character at the cursor position.
Prototype
int MULTIEDIT_GetCursorCharPos(MULTIEDIT_Handle hObj); Parameter hObj
Handle of multiedit widget.
Meaning
Return value
Number of the character at the cursor position.
Add. Information
The widget returns the character position if it has the focus or not. This means the cursor position is also returned, if the cursor is currently not visible in the widget.
MULTIEDIT_GetCursorPixelPos()
Description
Returns the pixel position of the cursor in window coordinates.
Prototype
void MULTIEDIT_GetCursorPixelPos(MULTIEDIT_Handle hObj, int * pxPos, int * pyPos); Parameter hObj pxPos pyPos
Handle of multiedit widget. Pointer to integer variable for the X-position in window coordinates. Pointer to integer variable for the Y-position in window coordinates.
Meaning
2002-2007 Micrium
575
Add. Information
The widget returns the pixel position if it has the focus or not. This means the cursor position is also returned, if the cursor is currently not visible in the widget.
MULTIEDIT_GetPrompt()
Description
Returns the current prompt text.
Prototype
void MULTIEDIT_GetPrompt(MULTIEDIT_HANDLE hObj, char * sDest, int MaxLen); Parameter hObj sDest MaxLen
Handle of multiedit widget. Buffer for the prompt text to be returned. Maximum number of bytes to be copied to sDest.
Meaning
Add. information
The function copies the current prompt text to the buffer given by sDest. The maximum number of bytes copied to the buffer is given by MaxLen.
MULTIEDIT_GetText()
Description
Returns the current text.
Prototype
void MULTIEDIT_GetText(MULTIEDIT_HANDLE hObj, char * sDest, int MaxLen); Parameter hObj sDest MaxLen
Handle of multiedit widget. Buffer for the text to be returned. Maximum number of bytes to be copied to sDest.
Meaning
Add. information
The function copies the current text to the buffer given by sDest. The maximum number of bytes copied to the buffer is given by MaxLen.
MULTIEDIT_GetTextSize()
Description
Returns the buffer size used to store the current text (and prompt).
Prototype
int MULTIEDIT_GetTextSize(MULTIEDIT_HANDLE hObj); Parameter hObj
Handle of multiedit widget.
Meaning
2002-2007 Micrium
576
CHAPTER 15
Return value
Buffer size used to store the current text (and prompt).
MULTIEDIT_SetAutoScrollH()
Description
Enables/disables the automatic use of a horizontal scrollbar.
Prototype
void MULTIEDIT_SetAutoScrollH(MULTIEDIT_HANDLE hObj, int OnOff); Parameter hObj OnOff
Handle of multiedit widget. (See table below)
Meaning
Add. information
Enabling the use of a automatic horizontal scrollbar makes only sense with the non wrapping mode explained later in this chapter. If enabled the multiedit widget checks if the width of the non wrapped text fits into the client area. If not a horizontal scrollbar will be attached to the window.
MULTIEDIT_SetAutoScrollV()
Description
Enables/disables the automatic use of a vertical scrollbar.
Prototype
void MULTIEDIT_SetAutoScrollV(MULTIEDIT_HANDLE hObj, int OnOff); Parameter hObj OnOff
Handle of multiedit widget. (See table below)
Meaning
Add. information
If enabled the multiedit widget checks if the height of the text fits into the client area. If not a vertical scrollbar will be attached to the window.
MULTIEDIT_SetBkColor()
Description
Sets the background color of the given multiedit widget.
2002-2007 Micrium
577
Prototype
void MULTIEDIT_SetBkColor(MULTIEDIT_HANDLE hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of multiedit widget. (See table below) Background color to be used.
Meaning
MULTIEDIT_SetBufferSize()
Description
Sets the maximum number of bytes used by text and prompt.
Prototype
void MULTIEDIT_SetBufferSize(MULTIEDIT_HANDLE hObj, int BufferSize); Parameter hObj BufferSize
Handle of multiedit widget. Maximum number of bytes.
Meaning
Add. information
The function clears the current contents of the multiedit widget and allocates the given number of bytes for the text and for the prompt.
MULTIEDIT_SetCursorOffset()
Description
Sets the cursor position to the given character.
Prototype
void MULTIEDIT_SetCursorOffset(MULTIEDIT_HANDLE hObj, int Offset); Parameter hObj Offset
Handle of multiedit widget. New cursor position.
Meaning
Add. information
The number of characters used for the prompt has to be added to the parameter Offset. If a prompt is used the value for parameter Offset should not be smaller than the number of characters used for the prompt.
2002-2007 Micrium
578
CHAPTER 15
MULTIEDIT_SetFont()
Description
Sets the font used to display the text and the prompt.
Prototype
void MULTIEDIT_SetFont(MULTIEDIT_HANDLE hObj, const GUI_FONT * pFont); Parameter hObj pFont
Handle of multiedit widget. Pointer to font to be used.
Meaning
MULTIEDIT_SetInsertMode()
Description
Enables/disables the insert mode. The default behaviour is overwrite mode.
Prototype
void MULTIEDIT_SetInsertMode(MULTIEDIT_HANDLE hObj, int OnOff); Parameter hObj OnOff
Handle of multiedit widget. (See table below)
Meaning
MULTIEDIT_SetMaxNumChars()
Description
Sets the maximum number of characters used by text and prompt.
Prototype
void MULTIEDIT_SetMaxNumChars(MULTIEDIT_HANDLE hObj, unsigned MaxNumChars); Parameter hObj MaxNumChars
Handle of multiedit widget. Maximum number of characters.
Meaning
MULTIEDIT_SetPasswordMode()
Description
Enables/disables the password mode.
2002-2007 Micrium
579
Prototype
void MULTIEDIT_SetPasswordMode(MULTIEDIT_HANDLE hObj, int OnOff); Parameter hObj OnOff
Handle of multiedit widget. (See table below)
Meaning
Add. information
The password mode enables you to conceal the user input.
MULTIEDIT_SetPrompt()
Description
Sets the prompt text.
Prototype
void MULTIEDIT_SetPrompt(MULTIEDIT_HANDLE hObj, const char * sPrompt); Parameter hObj sPrompt
Handle of multiedit widget. Pointer to the new prompt text.
Meaning
Add. information
The prompt text is displayed first. The cursor can not be moved into the prompt.
MULTIEDIT_SetReadOnly()
Description
Enables/disables the read only mode.
Prototype
void MULTIEDIT_SetReadOnly(MULTIEDIT_HANDLE hObj, int OnOff); Parameter hObj OnOff
Handle of multiedit widget. (see table below)
Meaning
Add. information
If the read only mode has been set the widget does not change the text. Only the cursor will be moved.
2002-2007 Micrium
580
CHAPTER 15
MULTIEDIT_SetText()
Description
Sets the text to be handled by the widget.
Prototype
void MULTIEDIT_SetText(MULTIEDIT_HANDLE hObj, const char * s); Parameter hObj s
Handle of multiedit widget. Pointer to the text to be handled by the multiedit widget.
Meaning
Add. information
The function copies the given text to the buffer allocated when creating the widget or by MULTIEDIT_SetMaxSize(). The current text can be retrieved by MULTIEDIT_GetText().
MULTIEDIT_SetTextAlign()
Description
Sets the text alignment for the given MULTIEDIT widget.
Prototype
void MULTIEDIT_SetTextAlign(MULTIEDIT_HANDLE hObj, int Align); Parameter hObj Align
Handle of multiedit widget. (see table below)
Meaning
MULTIEDIT_SetTextColor()
Description
Sets the text color.
Prototype
void MULTIEDIT_SetTextColor(MULTIEDIT_HANDLE hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of multiedit widget. (See table below) Text color to be used.
Meaning
2002-2007 Micrium
581
MULTIEDIT_SetWrapWord()
Description
Enables the word wrapping mode.
Prototype
void MULTIEDIT_SetWrapWord(MULTIEDIT_HANDLE hObj); Parameter hObj
Handle of multiedit widget.
Meaning
Add. information
If the word wrapping mode has been set the text at the end of a line will be wrapped at the beginning of the last word (if possible).
MULTIEDIT_SetWrapNone()
Description
Enables the non wrapping mode.
Prototype
void MULTIEDIT_SetWrapNone(MULTIEDIT_HANDLE hObj); Parameter hObj
Handle of multiedit widget.
Meaning
Add. information
Non wrapping means line wrapping would be done only at new lines. If the horizontal size of the text exceeds the size of the client area the text will be scrolled.
2002-2007 Micrium
582
CHAPTER 15
2002-2007 Micrium
583
A MULTIPAGE widget with n pages consists of n+2 windows: 1 MULTIPAGE window 1 Client window n Page windows The page windows will be added to the client window of the widget. The diagram at the right side shows the structure of the widget.
15.16.1Configuration options
Type
N N N S N N
MULTI | MULTI
0xD0D
0xC0C
&GUI_
0x808
0x000
Reaction
2002-2007 Micrium
584
CHAPTER 15
2002-2007 Micrium
585
MULTIPAGE_AddPage()
Before After
Description
Adds a new page to a given MULTIPAGE widget.
Prototype
void MULTIPAGE_AddPage(MULTIPAGE_Handle hObj, WM_HWIN hWin ,const char* pText); Parameter hObj hWin pText
Handle of MULTIPAGE widget. Handle of window to be shown in the given page. Pointer to text to be displayed in the tab of the page.
Meaning
Add. information
It is recomended, that all windows added to a MULTIPAGE widget handle the complete client area of the MULTIPAGE widget when processing the WM_PAINT message.
MULTIPAGE_CreateEx()
Description
Creates a new MULTIPAGE widget of a specified size at a specified position.
Prototype
MULTIPAGE_Handle MULTIPAGE_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
X-position of the widget (in parent coordinates). Y-position of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 13: "The Window Manager" for a list of available parameter values). Not used yet, reserved for future use. Window ID of the widget.
2002-2007 Micrium
586
CHAPTER 15
Return value
Handle of the new widget.
Add. information
The size of the tabs depends on the size of the font used for the MULTIPAGE widget.
MULTIPAGE_CreateIndirect()
Prototype explained at the beginning of the chapter.
MULTIPAGE_DeletePage()
Before After
Description
Removes a page from a MULTIPAGE widget and optional deletes the window.
Prototype
void MULTIPAGE_DeletePage(MULTIPAGE_Handle hObj, unsigned Index, int Delete); Parameter hObj Index Delete
Handle of MULTIPAGE widget. Zero based index of the page to be removed from the MULTIPAGE widget. If >0 the window attached to the page will be deleted.
Meaning
MULTIPAGE_DisablePage()
Before After
Description
Disables a page from a MULTIPAGE widget.
2002-2007 Micrium
587
Prototype
void MULTIPAGE_DisablePage(MULTIPAGE_Handle hObj, unsigned Index); Parameter hObj Index
Handle of MULTIPAGE widget. Zero based index of the page to be disabled.
Meaning
Add. information
A disabled page of a window can not be selected by clicking the tab of the page. The default state of MULTIEDIT pages is enabled.
MULTIPAGE_EnablePage()
Before After
Description
Enables a page of a MULTIPAGE widget.
Prototype
void MULTIPAGE_EnablePage(MULTIPAGE_Handle hObj, unsigned Index); Parameter hObj
Handle of MULTIPAGE widget.
Meaning
Add. information
The default state of MULTIEDIT pages is enabled.
MULTIPAGE_GetDefaultAlign()
Description
Returns the default tab alignment for new MULTIPAGE widgets.
Prototype
unsigned MULTIPAGE_GetDefaultAlign(void);
Return value
Default tab alignment for new MULTIPAGE widgets.
2002-2007 Micrium
588
CHAPTER 15
Add. information
The following table shows the alignment values returned by this function: Appearance of MULTIPAGE widget
Alignment
MULTIPAGE_ALIGN_LEFT | MULTIPAGE_ALIGN_TOP
MULTIPAGE_ALIGN_RIGHT | MULTIPAGE_ALIGN_TOP
MULTIPAGE_ALIGN_LEFT | MULTIPAGE_ALIGN_BOTTOM
MULTIPAGE_ALIGN_RIGHT | MULTIPAGE_ALIGN_BOTTOM
MULTIPAGE_GetDefaultBkColor()
Description
Returns the default background color for new MULTIPAGE widgets.
Prototype
GUI_COLOR MULTIPAGE_GetDefaultBkColor(unsigned Index); Parameter Index
See table below.
Meaning
2002-2007 Micrium
589
Return value
Default background color for new MULTIPAGE widgets.
MULTIPAGE_GetDefaultFont()
Description
Returns a pointer to the font used to display the text in the tabs of new MULTIPAGE widgets.
Prototype
const GUI_FONT * MULTIPAGE_GetDefaultFont(void);
Return value
Pointer to the font used to display the text in the tabs of new MULTIPAGE widgets.
MULTIPAGE_GetDefaultTextColor()
Description
Returns the default text color used to display the text in the tabs of new MULTIPAGE widgets.
Prototype
GUI_COLOR MULTIPAGE_GetDefaultTextColor(unsigned Index); Parameter Index
See table below.
Meaning
Return value
Default text color used to display the text in the tabs of new MULTIPAGE widgets.
MULTIPAGE_GetSelection()
Description
Retruns the zero based index of the currently selected page of a MULTIPAGE widget.
Prototype
int MULTIPAGE_GetSelection(MULTIPAGE_Handle hObj); Parameter hObj
Handle of MULTIPAGE widget.
Meaning
Return value
Zero based index of the currently selected page of a MULTIPAGE widget.
2002-2007 Micrium
590
CHAPTER 15
MULTIPAGE_GetWindow()
Description
Returns the handle of the window displayed in the given page.
Prototype
WM_HWIN MULTIPAGE_GetWindow(MULTIPAGE_Handle hObj, unsigned Index); Parameter hObj Index
Handle of MULTIPAGE widget. Zero based index of page.
Meaning
Return value
Handle of the window displayed in the given page..
MULTIPAGE_IsPageEnabled()
Description
Returns if the given page of a MULTIEDIT widget is enabled or not.
Prototype
int MULTIPAGE_IsPageEnabled (MULTIPAGE_Handle hObj, unsigned Index); Parameter hObj Index
Handle of MULTIPAGE widget. Zero based index of requested page.
Meaning
Return value
1 if the given page is enabled, otherwise 0.
MULTIPAGE_SelectPage()
Before After
Description
Sets the currently selected page of a MULTIPAGE widget.
2002-2007 Micrium
591
Prototype
void MULTIPAGE_SelectPage(MULTIPAGE_Handle hObj, unsigned Index); Parameter hObj Index
Handle of MULTIPAGE widget. Zero based index of page to be selected.
Meaning
MULTIPAGE_SetAlign()
Before After
Description
Sets the tab alignment for the given MULTIPAGE widget.
Prototype
void MULTIPAGE_SetAlign(MULTIPAGE_Handle hObj, unsigned Align); Parameter hObj Align
Handle of MULTIPAGE widget. See table below.
Meaning
Permitted values for parameter Index (horizontal and vertical flags are OR-combinable) MULTIPAGE_ALIGN_BOTTOM MULTIPAGE_ALIGN_LEFT MULTIPAGE_ALIGN_RIGHT MULTIPAGE_ALIGN_TOP
Aligns the tabs at the right side. Aligns the tabs at the left side. Aligns the tabs at the top of the widget. Aligns the tabs at the bottom of the widget..
Add. information
For more information please refer to the function MULTIPAGE_GetDefaultAlign().
2002-2007 Micrium
592
CHAPTER 15
MULTIPAGE_SetBkColor()
Before After
Description
Sets the background color of the given MULTIPAGE widget.
Prototype
void MULTIPAGE_SetBkColor(MULTIPAGE_Handle hObj, GUI_COLOR Color, unsigned Index); Parameter hObj Color Index
Handle of MULTIPAGE widget. Color to be used. See table below.
Meaning
Permitted values for parameter Index MULTIPAGE_CI_DISABLED Sets the default text color for disabled pages. Sets the default text color for enabled pages. MULTIPAGE_CI_ENABLED
Add. information
The function only sets the background color for the MULTIPAGE widget. The child windows added to the widget are not affected. That means if the complete client area is drawn by windows added to the widget, only the background color of the tabs changes.
MULTIPAGE_SetDefaultAlign()
Description
Sets the default tab alignment for new MULTIPAGE widgets.
Prototype
void MULTIPAGE_SetDefaultAlign(unsigned Align); Parameter Align Meaning
Tab alignment used for new MULTIPAGE widgets.
Add. information
For more informations about the tab alignment please refer to the functions MULTIPAGE_GetDefaultAlign() and MULTIPAGE_SetAlign().
2002-2007 Micrium
593
MULTIPAGE_SetDefaultBkColor()
Description
Sets the default background color used for new MULTIPAGE widgets.
Prototype
void MULTIPAGE_SetDefaultBkColor(GUI_COLOR Color, unsigned Index); Parameter Color Index
Color to be used. See table below.
Meaning
MULTIPAGE_SetDefaultFont()
Description
Sets the default font used to display the text in the tabs of new MULTIPAGE widgets.
Prototype
void MULTIPAGE_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont Meaning
Pointer to GUI_FONT structure to be used.
Add. information
The horizontal and vertical size of the tabs depends on the size of the used font.
MULTIPAGE_SetDefaultTextColor()
Description
Sets the default text color used to display the text in the tabs of new MULTIPAGE widgets.
Prototype
void MULTIPAGE_SetDefaultTextColor(GUI_COLOR Color, unsigned Index); Parameter Color Index
Color to be used. See table below.
Meaning
2002-2007 Micrium
594
CHAPTER 15
MULTIPAGE_SetFont()
Before After
Description
Sets the font used to display the text in the tabs of a given MULTIPAGE widget.
Prototype
void MULTIPAGE_SetFont(MULTIPAGE_Handle hObj, const GUI_FONT * pFont); Parameter hObj pFont
Handle of MULTIPAGE widget. Pointer to GUI_FONT structure used to display the text in the tabs.
Meaning
Add. information
The vertical and horizontal size of the tabs depend on the size of the used font and the text shown in the tabs.
MULTIPAGE_SetRotation()
Before After
Description
Sets the rotation mode of the given widget.
Prototype
void MULTIPAGE_SetRotation(MULTIPAGE_Handle hObj, unsigned Rotation); Parameter hObj Rotation
Handle of MULTIPAGE widget. Rotation mode (see table below)
Meaning
2002-2007 Micrium
595
MULTIPAGE_SetText()
Before After
Description
Sets the text displayed in the tab of a given page.
Prototype
void MULTIPAGE_SetText(MULTIPAGE_Handle hObj, const char* pText, unsigned Index); Parameter hObj pText Index
Handle of MULTIPAGE widget. Pointer to the text to be displayed. Zero based index of the page.
Meaning
MULTIPAGE_SetTextColor()
Before After
Description
Sets the color used to display the text in the tabs of a MULTIPAGE widget.
Prototype
void MULTIPAGE_SetTextColor(MULTIPAGE_Handle hObj,
2002-2007 Micrium
596
CHAPTER 15
Meaning
2002-2007 Micrium
597
Default
GUI_DEFAULT_FONT Font used.
Explanation
0x555555 (dark gray) Left bar color. 0xAAAAAA (light gray) Right bar color. 0xFFFFFF 0x000000 Text color, left bar. Text color, right bar.
PROGBAR_Create()
(Obsolete, PROGBAR_CreateEx should be used instead)
Description
Creates a PROGBAR widget of a specified size at a specified location.
Prototype
PROGBAR_Handle PROGBAR_Create(int x0, int y0, int xsize, int ysize, int
2002-2007 Micrium
598
CHAPTER 15
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values).
Return value
Handle for the created PROGBAR widget; 0 if the routine fails.
PROGBAR_CreateAsChild()
(Obsolete, PROGBAR_CreateEx should be used instead)
Description
Creates a PROGBAR widget as a child window.
Prototype
PROGBAR_Handle PROGBAR_CreateAsChild(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags); Parameter x0 y0 xsize ysize hParent Id Flags Meaning
X-position of the progress bar relative to the parent window. Y-position of the progress bar relative to the parent window. Horizontal size of the progress bar (in pixels). Vertical size of the progress bar (in pixels). Handle of parent window. ID to be returned. Window create flags (see
PROGBAR_Create() ).
Return value
Handle for the created PROGBAR widget; 0 if the routine fails.
PROGBAR_CreateEx()
Description
Creates a PROGBAR widget of a specified size at a specified location.
Prototype
PROGBAR_Handle PROGBAR_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags,
2002-2007 Micrium
599
int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new PROGBAR widget will be a child of the desktop (top-level window). Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). (see table below) Window ID of the widget.
Return value
Handle for the created widget; 0 if the routine fails.
PROGBAR_CreateIndirect()
Prototype explained at the beginning of the chapter. The elements Flags and Para of the resource passed as parameter are not used.
PROGBAR_SetBarColor()
Description
Sets the color(s) of the progress bar.
Prototype
void PROGBAR_SetBarColor(PROGBAR_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of progress bar. See table below. Other values are not permitted. Color to set (24-bit RGB value).
Meaning
PROGBAR_SetFont()
Description
Selects the font for the text display inside the progress bar.
2002-2007 Micrium
600
CHAPTER 15
Prototype
void PROGBAR_SetFont(PROGBAR_Handle hObj, const GUI_FONT* pFont); Parameter hObj pFont
Handle of progress bar. Pointer to the font.
Meaning
Add. information
If this function is not called, the default font for progress bars (the GUI default font) will be used. However, the progress bar default font may be changed in the GUIConf.h file. Simply #define the default font as follows (example):
#define PROGBAR_DEFAULT_FONT &GUI_Font13_ASCII
PROGBAR_SetMinMax()
Description
Sets the minimum and maximum values used for the progress bar.
Prototype
void PROGBAR_SetMinMax(PROGBAR_Handle hObj, int Min, int Max); Parameter hObj Min Max
Handle of progress bar. Minimum value Range: -16383 < Min <= 16383. Maximum value Range: -16383 < Max <= 16383.
Meaning
Add. information
If this function is not called, the default values of Min = 0, Max = 100 will be used.
PROGBAR_SetText()
Description
Sets the text displayed inside the progress bar.
Prototype
void PROGBAR_SetText(PROGBAR_Handle hObj, const char* s); Parameter hObj s
Handle of progress bar. Text to display. A NULL pointer is permitted; in this case a percentage value will be displayed.
Meaning
Add. information
If this function is not called, a percentage value will be displayed as the default. If you do not want to display any text at all, you should set an empty string.
2002-2007 Micrium
601
PROGBAR_SetTextAlign()
Description
Sets the text alignment.
Prototype
void PROGBAR_SetTextAlign(PROGBAR_Handle hObj, int Align); Parameter hObj Align
Handle of progress bar. Horizontal alignment attribute for the text (see table below).
Meaning
Permitted values for parameter Align GUI_TA_HCENTER Centers the title (default). Displays the title to the left. GUI_TA_LEFT Displays the title to the right. GUI_TA_RIGHT
Add. information
If this function is not called, the default behavior is to display the text centered.
PROGBAR_SetTextColor()
Description
Sets the text color of the progress bar.
Prototype
void PROGBAR_SetTextColor(PROGBAR_Handle hObj, unsigned int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of progress bar. See table below. Other values are not permitted. Color to set (24-bit RGB value).
Meaning
PROGBAR_SetTextPos()
Description
Sets the text position in pixels.
2002-2007 Micrium
602
CHAPTER 15
Prototype
void PROGBAR_SetTextPos(PROGBAR_Handle hObj, int XOff, int YOff); Parameter hObj XOff YOff
Handle of progress bar. Number of pixels to move text in horizontal direction. Positive number will move text to the right. Number of pixels to move text in vertical direction. Positive number will move text down.
Meaning
Add. information
The values move the text the specified number of pixels within the widget. Normally, the default of (0,0) should be sufficient.
PROGBAR_SetValue()
Description
Sets the value of the progress bar.
Prototype
void PROGBAR_SetValue(PROGBAR_Handle hObj, int v); Parameter hObj v
Handle of progress bar. Value to set.
Meaning
Add. information
The bar indicator will be calculated with regard to the max/min values. If a percentage is automatically displayed, the percentage will also be calculated using the given min/max values as follows: p = 100% * (v-Min)/(Max-Min) The default value after creation of the widget is 0.
15.17.4 Examples
Using the PROGBAR widget
The following simple example demonstrates the use of the PROGBAR widget. It is available in the samples as WIDGET_SimpleProgbar.c:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ***** C/GUI - Graphical user interface for embedded applications **** C/GUI is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with a license and should not be redistributed in any way. We appreciate your understanding and fairness. ---------------------------------------------------------------------File : WIDGET_SimpleProgbar.c Purpose : Demonstrates the use of the PROGBAR widget User's & reference manual for C/GUI 2002-2007 Micrium
603 ---------------------------------------------------------------------*/ #include "GUI.h" #include "PROGBAR.h" /******************************************************************* * * static code * ******************************************************************** */ /******************************************************************* * * _DemoProgBar */ static void _DemoProgBar(void) { PROGBAR_Handle ahProgBar; int i; GUI_SetFont(&GUI_Font8x16); GUI_DispStringAt("Progress bar", 100,80); /* Create progress bar */ ahProgBar = PROGBAR_Create(100, 100, 100, 20, WM_CF_SHOW); GUI_Delay (500); /* Modify progress bar */ for (i = 0; i <= 100; i++) { PROGBAR_SetValue(ahProgBar, i); GUI_Delay(10); } GUI_Delay (400); /* Delete progress bar */ PROGBAR_Delete(ahProgBar); GUI_ClearRect(0, 50, 319, 239); GUI_Delay(750); } /******************************************************************* * * MainTask * * Shows the use of progress bars * ******************************************************************** */ void MainTask(void) { GUI_Init(); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("WIDGET_SimpleProgbar - Sample", 160, 5); while(1) { _DemoProgBar(); } }
2002-2007 Micrium
604
CHAPTER 15
2002-2007 Micrium
605 PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_DARKGRAY); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_LIGHTGRAY); } else { PROGBAR_SetBarColor(ahProgBar[0], 0, GUI_GREEN); PROGBAR_SetBarColor(ahProgBar[0], 1, GUI_RED); } PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_HCENTER); PROGBAR_SetText(ahProgBar[0], NULL); for (i=0; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Tank empty"); for (; i>=0; i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200-i); GUI_Delay(5); } PROGBAR_SetText(ahProgBar[0], "Any text..."); PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_LEFT); for (; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 200+i); GUI_Delay(5); } PROGBAR_SetTextAlign(ahProgBar[0], GUI_TA_RIGHT); for (; i>=0; i--) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400-i); GUI_Delay(5); } PROGBAR_SetFont(ahProgBar[0], &GUI_FontComic18B_1); PROGBAR_SetText(ahProgBar[0], "Any font..."); for (; i<=100; i++) { PROGBAR_SetValue(ahProgBar[0], i); PROGBAR_SetValue(ahProgBar[1], 400+i); GUI_Delay(5); } GUI_Delay(500); } } /******************************************************************* * * MainTask * * Demonstrates the use of the PROGBAR widget * ******************************************************************** */ void MainTask(void) { GUI_Init(); while (1) { _DemoProgBar(); } }
2002-2007 Micrium
606
CHAPTER 15
Enabled
Disabled
Default
(see table above) (see table above)
Explanation
Default outer image used to show a disabled radio button. Default outer image used to show a enabled radio button.
Default inner image used to mark the RADIO_IMAGE_CHECK_DEFAULT (see table above) selected item.
Default font used to render the radio button text. Default text color of radio button text. Default background color of radio buttons if no transparency is used. Default color for rendering the focus rectangle.
2002-2007 Micrium
607
RADIO_Create()
(Obsolete, RADIO_CreateEx should be used instead)
Description
Creates a RADIO widget of a specified size at a specified location.
Prototype
RADIO_Handle RADIO_Create(int x0, int y0, int xsize, int ysize, WM_HWIN
2002-2007 Micrium
608
CHAPTER 15
hParent, int Id, int Flags, unsigned Para); Parameter x0 y0 xsize ysize hParent Id Flags Para Meaning
Leftmost pixel of the radio button widget (in parent coordinates). Topmost pixel of the radio button widget (in parent coordinates). Horizontal size of the radio button widget (in pixels). Vertical size of the radio button widget (in pixels). Handle of parent window. ID to be returned. Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Number of buttons in the group.
Return value
Handle for the created RADIO widget; 0 if the routine fails.
RADIO_CreateEx()
Description
Creates a RADIO widget of a specified size at a specified location.
Prototype
RADIO_Handle RADIO_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, int NumItems, int Spacing); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id NumItems Spacing Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new RADIO widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Not used, reserved for future use. Window ID of the widget. Number of items of the radio widget. (default is 2) Number of vertical pixels used for each item of the radio widget.
Return value
Handle for the created widget; 0 if the routine fails.
Add. information
If creating a radio widget make sure, that the given ysize is enough to show all items. The value should be at least NumItems * Spacing. If the given value of NumItems is <= 0 a default value of 2 is used.
2002-2007 Micrium
609
RADIO_CreateIndirect()
Prototype explained at the beginning of the chapter. The element Flags of the resource passed as parameter is not used. The following table shows the use of the resource element Para: Bits 0 8 16 24 - 7 - 15 - 23 - 31 Meaning
Number of items of the radio widget. If 0, a default value of 2 items is used. Number of vertical pixels used for each item. If 0 the height of the default image is used. Not used, reserved for future use. Not used, reserved for future use.
RADIO_Dec()
Before After
Description
Decrements the selection by a value of 1.
Prototype
void RADIO_Dec(RADIO_Handle hObj); Parameter hObj
Handle of radio button widget.
Meaning
Add. information
Please note that the numbering of the buttons always starts from the top with a value of 0; therefore decrementing the selection will actually move the selection one button up.
RADIO_GetDefaultFont()
Description
Returns the default font used to display the optional text next to new radio buttons.
Prototype
const GUI_FONT * RADIO_GetDefaultFont(void);
Return value
Default font used to display the optional text next to the radio buttons.
Add. information
For information about how to add text to a radio widget please refer to the function RADIO_SetText().
2002-2007 Micrium
610
CHAPTER 15
RADIO_GetDefaultTextColor()
Description
Returns the default text color used to display the optional text next to new radio buttons.
Prototype
GUI_COLOR RADIO_GetDefaultTextColor (void);
Return value
Default text color used to display the optional text next to new radio buttons.
Add. information
For information about how to add text to a radio widget please refer to the function RADIO_SetText().
RADIO_GetText()
Description
Returns the optional text of the given radio button.
Prototype
int RADIO_GetText(RADIO_Handle hObj, unsigned Index, char * pBuffer, int MaxLen); Parameter hObj Index pBuffer MaxLen
Handle of widget. Index of the desired item. Pointer to buffer to which the text will be copied. Buffer size in bytes.
Meaning
Return value
Length of the text copied into the buffer.
Add. information
If the desired item of the radio button contains no text the function returns 0 and the buffer remains unchanged.
RADIO_GetValue()
Description
Returns the current button selection.
Prototype
void RADIO_GetValue(RADIO_Handle hObj); Parameter hObj
Handle of radio button widget.
Meaning
2002-2007 Micrium
611
Return value
The value of the currently selected button. If no button is selected (in case of using a radio button group) the return value is -1.
Add. information
For information about how to use groups of radio buttons please refer to the function RADIO_SetGroupID().
RADIO_Inc()
Before After
Description
Increments the selection by a value of 1.
Prototype
void RADIO_Inc(RADIO_Handle hObj); Parameter hObj
Handle of radio button widget.
Meaning
Add. information
Please note that the numbering of the buttons always starts from the top with a value of 0; therefore incrementing the selection will actually move the selection one button down.
RADIO_SetBkColor()
Before After
Description
Sets the background color of the radio widget.
2002-2007 Micrium
612
CHAPTER 15
Prototype
void RADIO_SetBkColor(RADIO_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of radio button widget. Color to be used for the background. (range 0x000000 and 0xFFFFFF or a valid color define) GUI_INVALID_COLOR to make background transparent
Meaning
Add. information
The background of this widget can either be filled with any available color or transparent. If a valid RGB color is specified, the background is filled with the color, otherwise the background (typically the contents of the parent window) is visible. If the background is transparent, the widget is treated as transparent window, otherwise as non-transparent window. Note that using a background color allows more efficient (faster) rendering.
RADIO_SetDefaultFocusColor()
Description
Sets the default focus rectangle color for new radio buttons.
Prototype
GUI_COLOR RADIO_SetDefaultFocusColor(GUI_COLOR Color); Parameter Color Meaning
Default color to be used for new radio buttons.
Return value
Previous default focus rectangle color.
Add. information
For more information please refer to the function RADIO_SetFocusColor().
RADIO_SetDefaultFont()
Description
Sets the default font used to display the optional text next to new radio buttons.
Prototype
void RADIO_SetDefaultFont(const GUI_FONT * pFont); Parameter pFont Meaning
Pointer to GUI_FONT structure used to show the text of new radio widgets.
Add. information
For information about how to add text to a radio widget please refer to the function RADIO_SetText().
2002-2007 Micrium
613
RADIO_SetDefaultImage()
Description
Sets the images used to draw new radio buttons.
Prototype
void RADIO_SetDefaultImage(const GUI_BITMAP * pBitmap, unsigned int Index); Parameter pBitmap Index
Pointer to the bitmap. (see table below)
Meaning
Add. information
Two images are used to display a radio button. One image is used to draw the outer frame used to display a unselected radio button. In dependence of the current state it will be the bitmap referenced by RADIO_BI_ACTIV (default) or by RADIO_BI_ACTIV. The second image (referenced by RADIO_BI_CHECK) is used to mark the currently selected button.
RADIO_SetDefaultTextColor()
Description
Sets the default text color used to display the optional text next to new radio buttons.
Prototype
void RADIO_SetDefaultTextColor (GUI_COLOR TextColor); Parameter TextColor
New color to be used.
Meaning
Add. information
For information about how to add text to a radio widget please refer to the function RADIO_SetText().
2002-2007 Micrium
614
CHAPTER 15
RADIO_SetFocusColor()
Before After
Description
Sets the color used to render the focus rectangle of the radio button.
Prototype
GUI_COLOR RADIO_SetFocusColor(RADIO_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget. Color to be used for the focus rectangle.
Meaning
Return value
Previous color of the focus rectangle.
Add. information
The focus rectangle is only visible if the widget has the input focus.
RADIO_SetFont()
Before After
Description
Sets the font used to display the optional text next to the radio button.
Prototype
void RADIO_SetFont(RADIO_Handle hObj, const GUI_FONT * pFont); Parameter hObj pFont
Handle of radio button widget. Pointer to GUI_FONT structure to be used to display the text.
Meaning
2002-2007 Micrium
615
Add. information
For information about how to add text to a radio widget please refer to the function RADIO_SetText().
RADIO_SetGroupID()
Before After
Description
Sets the group ID of the radio widget.
Prototype
void RADIO_SetGroupID(RADIO_Handle hObj, U8 GroupID); Parameter hObj GroupID
Handle of radio button widget. ID of the radio button group. Must be between 1 and 255. If the value is 0 the radio widget is not assigned to a radio button group.
Meaning
Add. information
This command can be used to create groups of radio buttons. The behavior of one group is the same as the behavior of one radio button. This makes it possible to create for example 2 RADIO widgets side by side with 3 buttons each and build one group of them.
Example
The following sample shows how to create a group of 2 RADIO widgets as shown in the screenshot at the beginning of the function description:
hRadio_0 = RADIO_CreateEx(10, 10, 60, 0, WM_HBKWIN, WM_CF_SHOW, 0, 1234, 3, 20); RADIO_SetText(hRadio_0, "Red", 0); RADIO_SetText(hRadio_0, "Green", 1); RADIO_SetText(hRadio_0, "Blue", 2); hRadio_1 = RADIO_CreateEx(65, 10, 60, 0, WM_HBKWIN, WM_CF_SHOW, 0, 1234, 3, 20); RADIO_SetText(hRadio_1, "Magenta", 0); RADIO_SetText(hRadio_1, "Cyan", 1); RADIO_SetText(hRadio_1, "Yellow", 2); RADIO_SetGroupID(hRadio_0, 1); RADIO_SetGroupID(hRadio_1, 1);
RADIO_SetImage()
Description
Sets the images used to draw the radio button.
Prototype
void RADIO_SetImage(RADIO_Handle hObj,
2002-2007 Micrium
616
CHAPTER 15
const GUI_BITMAP * pBitmap, unsigned int Index); Parameter hObj pBitmap Index
Handle of radio button widget. Pointer to the bitmap. (see table shown under
Meaning
RADIO_SetDefaultImage )
Add. information
(see RADIO_SetDefaultImage).
RADIO_SetText()
Before After
Description
Sets the optional text shown next to the radio buttons.
Prototype
void RADIO_SetText(RADIO_Handle hObj, const char * pText, unsigned Index); Parameter hObj pText Index
Handle of radio button widget. Pointer to the text to be shown next to the specified radio button. Zero based index of the radio button.
Meaning
Add. information
If using a RADIO widget without text (old style) the focus rectangle is drawn arround the buttons of the widget. If using radio button text the focus rectangle is shown arround the text of the currently selected radio button of the widget.
Example
The following sample shows how to add the text shown in the screenshot above:
RADIO_SetText(hRadio_0, "Red", 0); RADIO_SetText(hRadio_0, "Green", 1); RADIO_SetText(hRadio_0, "Blue", 2);
2002-2007 Micrium
617
RADIO_SetTextColor()
Before After
Description
Sets the text color used to show the optional text besite the radio buttons.
Prototype
void RADIO_SetTextColor(RADIO_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of radio button widget. Color used to show the text.
Meaning
Add. information
For information about how to add text to a radio widget please refer to the function RADIO_SetText().
RADIO_SetValue()
Description
Sets the current button selection.
Prototype
void RADIO_SetValue(RADIO_Handle hObj, int v); Parameter hObj v
Handle of radio button widget. Value to be set.
Meaning
Add. information
The topmost radio button in a RADIO widget always has the 0 value, the next button down is always 1, the next is 2, etc.
2002-2007 Micrium
618
CHAPTER 15
All SCROLLBAR-related routines are located in the file(s) SCROLLBAR*.c, SCROLLBAR.h. All identifiers are prefixed SCROLLBAR.
Default
0x808080 0xc0c0c0 4
Explanation
Color of the shaft. Color of the thumb area. Minimum thumb size.
2002-2007 Micrium
619
SCROLLBAR_AddValue()
Definition
Increments or decrements the value of the scroll bar by a specified value.
Prototype
void SCROLLBAR_AddValue(SCROLLBAR_Handle hObj, int Add); Parameter hObj Add
Handle of scroll bar. Number of items to increment or decrement at one time.
Meaning
Add. information
The scroll bar cannot exceed the value set in SCROLLBAR_SetNumItems(). For example, if a window contains 200 items and the scroll bar is currently at value 195, incrementing the bar by 3 items will move it to value 198. However, incrementing by 10 items will only move the bar as far as value 200, which is the maximum value for this particular window.
SCROLLBAR_Create()
(Obsolete, SCROLLBAR_CreateEx should be used instead)
Description
Creates a SCROLLBAR widget of a specified size at a specified location.
2002-2007 Micrium
620
CHAPTER 15
Prototype
SCROLLBAR_Handle SCROLLBAR_Create(int x0, int y0, int xsize, int ysize WM_HWIN hParent, int Id, int WinFlags, int SpecialFlags); Parameter x0 y0 xsize ysize hParent Id WinFlags SpecialFlags Meaning
Leftmost pixel of the scroll bar (in parent coordinates). Topmost pixel of the scroll bar (in parent coordinates). Horizontal size of the scroll bar (in pixels). Vertical size of the scroll bar (in pixels). Handle of parent window. ID to be returned. Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Special creation flags (see indirect creation flags under SCROLLBAR_CreateIndirect() ).
Return value
Handle for the created SCROLLBAR widget; 0 if the routine fails.
SCROLLBAR_CreateAttached()
Description
Creates a scroll bar which is attached to an existing window.
Prototype
SCROLLBAR_Handle SCROLLBAR_CreateAttached(WM_HWIN hParent, int SpecialFlags); Parameter hParent SpecialFlags
Handle of parent window. Special creation flags (see indirect creation flags under SCROLLBAR_CreateIndirect() ).
Meaning
Return value
Handle for the created scrollbar; 0 if the routine fails.
Add. information
An attached scroll bar is essentially a child window which will position itself on the parent window and operate accordingly. Vertical attached scrollbars will be automatically placed on the right side of the parent window; horizontal scrollbars on the bottom. Since no more than one horizontal and one vertical scroll bar can be attached to a parent window, no ID needs to be passed as parameter. The following fixed IDs will automatically be assigned when an attached scroll bar is created: GUI_ID_HSCROLL for a horizontal scroll bar, and GUI_ID_VSCROLL for a vertical scroll bar.
Example
Creates a list box with an attached scrollbar:
2002-2007 Micrium
621 LISTBOX_Handle hListBox; hListBox = LISTBOX_Create(ListBox, 50, 50, 100, 100, WM_CF_SHOW); SCROLLBAR_CreateAttached(hListBox, SCROLLBAR_CF_VERTICAL);
SCROLLBAR_CreateEx()
Description
Creates a SCROLLBAR widget of a specified size at a specified location.
Prototype
SCROLLBAR_Handle SCROLLBAR_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new SCROLLBAR widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Special creation flags (see indirect creation flags under SCROLLBAR_CreateIndirect() ). Window ID of the widget.
Return value
Handle for the created widget; 0 if the routine fails.
SCROLLBAR_CreateIndirect()
Prototype explained at the beginning of the chapter. The following flags may be used as the Flags element of the resource passed as parameter: Permitted indirect creation flags ("OR" combinable) SCROLLBAR_CF_VERTICAL
Creates a vertical scroll bar (default is horizontal).
SCROLLBAR_CF_FOCUSSABLE Gives scroll bar the input focus. The Para element is not used in the resource table.
2002-2007 Micrium
622
CHAPTER 15
SCROLLBAR_Dec()
Description
Decrements the current value of the scroll bar by a value of 1.
Prototype
void SCROLLBAR_Dec(SCROLLBAR_Handle hObj); Parameter hObj
Handle of scroll bar.
Meaning
Add. information
The definition of an "item" is application-specific, although in most cases it is equal to one line. Items are numbered top to bottom or left to right, beginning with a value of 0.
SCROLLBAR_GetDefaultWidth()
Description
Returns the default width used to create a scrollbar.
Prototype
int SCROLLBAR_GetDefaultWidth(void);
Return value
Default width used to create a scrollbar.
SCROLLBAR_GetValue()
Description
Return the value of the current item.
Prototype
int SCROLLBAR_GetValue(SCROLLBAR_Handle hObj); Parameter hObj
Handle of scroll bar.
Meaning
Return value
The value of the current item.
SCROLLBAR_Inc()
Description
Increments the current value of the scroll bar by a value of 1.
Prototype
void SCROLLBAR_Inc(SCROLLBAR_Handle hObj); Parameter hObj
Handle of scroll bar.
Meaning
2002-2007 Micrium
623
Add. information
The definition of an "item" is application-specific, although in most cases it is equal to one line. Items are numbered top to bottom or left to right, beginning with a value of 0.
SCROLLBAR_SetColor()
Before After
Description
Sets the given color attribute of the scroll bar.
Prototype
GUI_COLOR SCROLLBAR_SetColor(SCROLLBAR_Handle hObj, int Index, GUI_COLOR Color); Parameter hObj Index Color
Handle of scroll bar. (see table below) Color to be used.
Meaning
Permitted values for parameter Index SCROLLBAR_CI_THUMB Color of thumb area. SCROLLBAR_CI_SHAFT Color of shaft. SCROLLBAR_CI_ARROW Color of arrows.
Return value
Previous color used for the given index.
SCROLLBAR_SetDefaultColor()
Description
Sets the default color attributes for new scroll bars.
Prototype
GUI_COLOR SCROLLBAR_SetDefaultColor(GUI_COLOR Color, unsigned int Index); Parameter Color Index
(see table under
Meaning
Color used as default for new scroll bars.
SCROLLBAR_SetColor())
Return value
Previous default color.
2002-2007 Micrium
624
CHAPTER 15
SCROLLBAR_SetDefaultWidth()
Description
Sets the default width used to create a scrollbar.
Prototype
int SCROLLBAR_SetDefaultWidth(int DefaultWidth); Parameter Meaning
Return value
Previous default width.
SCROLLBAR_SetNumItems()
Description
Sets the number of items for scrolling.
Prototype
void SCROLLBAR_SetNumItems(SCROLLBAR_Handle hObj, int NumItems); Parameter hObj NumItems
Handle of scroll bar. Number of items to be set.
Meaning
Add. information
The definition of an "item" is application-specific, although in most cases it is equal to one line. The number of items specified is the maximum value; the scroll bar cannot go beyond this value.
SCROLLBAR_SetPageSize()
Description
Sets the page size.
Prototype
void SCROLLBAR_SetPageSize(SCROLLBAR_Handle hObj, int PageSize); Parameter hObj PageSize
Handle of scroll bar. Page size (in number of items).
Meaning
Add. information
Page size is specified as the number of items to one page. If the user pages up or down, either with the keyboard or by mouse-clicking in the scroll bar area, the window will be scrolled up or down by the number of items specified to be one page.
2002-2007 Micrium
625
SCROLLBAR_SetState()
Description
Sets the state of a scroll bar.
Prototype
void SCROLLBAR_SetState(SCROLLBAR_Handle hObj, const WM_SCROLL_STATE* pState); Parameter hObj pState
Handle of scroll bar. Pointer to a data structure of type WM_SCROLL_STATE.
Meaning
Add. information
The data structure is defined as follows:
typedef struct { int NumItems; int v; int PageSize; } WM_SCROLL_STATE;
SCROLLBAR_SetValue()
Description
Sets the current value of a scroll bar.
Prototype
void SCROLLBAR_SetValue(SCROLLBAR_Handle hObj, int v); Parameter hObj v
Handle of scroll bar. Value to be set.
Meaning
SCROLLBAR_SetWidth()
Description
Sets the width of the scroll bar.
Prototype
void SCROLLBAR_SetWidth(SCROLLBAR_Handle hObj, int Width); Parameter hObj Width
Handle of scroll bar. Width to be set.
Meaning
2002-2007 Micrium
626
CHAPTER 15
All SLIDER-related routines are located in the file(s) SLIDER*.c, SLIDER.h. All identifiers are prefixed SLIDER.
Macro
Default
Explanation
Background color. Slider (thumb) color. Default color for rendering the focus rectangle.
Explanation
Create the slider. (Obsolete)
2002-2007 Micrium
627
Routine SLIDER_GetValue() SLIDER_Inc() SLIDER_SetBkColor() SLIDER_SetDefaultFocusColor() SLIDER_SetFocusColor() SLIDER_SetNumTicks() SLIDER_SetRange() SLIDER_SetValue() SLIDER_SetWidth()
Explanation
Return the current value of the slider bar. Increment the value of the slider bar. Sets the background color of the slider bar. Sets the default focus rectangle color for new slider bars. Sets the color of the focus rectangle. Sets the number of tick marks of the slider bar. Set the range of the slider value. Set the current value of the slider bar. Set the width of the slider bar.
SLIDER_Create()
(Obsolete, SLIDER_CreateEx should be used instead)
Description
Creates a SLIDER widget of a specified size at a specified location.
Prototype
SLIDER_Handle SLIDER_Create(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int WinFlags, int SpecialFlags); Parameter x0 y0 xsize ysize hParent Id WinFlags SpecialFlags Meaning
Leftmost pixel of the slider (in parent coordinates). Topmost pixel of the slider (in parent coordinates). Horizontal size of the slider (in pixels). Vertical size of the slider (in pixels). Handle of the parent window. Id to be returned Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Special creation flag (see indirect creation flag under SLIDER_CreateIndirect() ).
Return value
Handle for the created SLIDER widget; 0 if the routine fails.
SLIDER_CreateEx()
Description
Creates a SLIDER widget of a specified size at a specified location.
Prototype
SLIDER_Handle SLIDER_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags,
2002-2007 Micrium
628
CHAPTER 15
int ExFlags, int Id); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new SLIDER widget will be a child of the desktop (top-level window). Window create flags. Typically
immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Special creation flags (see indirect creation flags under SLIDER_CreateIndirect() ). Window ID of the widget.
Return value
Handle for the created widget; 0 if the routine fails.
SLIDER_CreateIndirect()
Prototype explained at the beginning of the chapter. The following flag may be used as the Flags element of the resource passed as parameter: Permitted indirect creation flag SLIDER_CF_VERTICAL Create a vertical slider (default is horizontal). The Para element is not used in the resource table.
SLIDER_Dec()
Description
Decrements the current value of the slider bar by one item.
Prototype
void SLIDER_Dec(SLIDER_Handle hObj); Parameter hObj
Handle of slider widget.
Meaning
SLIDER_GetValue()
Description
Returns the current value of the slider bar.
Prototype
int SLIDER_GetValue(SLIDER_Handle hObj); Parameter hObj
Handle of slider widget.
Meaning
2002-2007 Micrium
629
Return value
The current value of the slider.
SLIDER_Inc()
Description
Increments the current value of the slider bar by one item.
Prototype
void SLIDER_Inc(SLIDER_Handle hObj); Parameter hObj
Handle of slider widget.
Meaning
SLIDER_SetBkColor()
Description
Sets the background color of the slider.
Prototype
void SLIDER_SetBkColor(SLIDER_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of slider widget. Color to be used for the background. (range 0x000000 and 0xFFFFFF or a valid color define) GUI_INVALID_COLOR to make background transparent
Meaning
Add. information
The background of this widget can either be filled with any available color or transparent. If a valid RGB color is specified, the background is filled with the color, otherwise the background (typically the contents of the parent window) is visible. If the background is transparent, the widget is treated as transparent window, otherwise as non-transparent window. Note that using a background color allows more efficient (faster) rendering. This widget is per default a transparent window. The appearance of a transparent windows background depends on the appearance of the parent window. When a transparent window needs to be redrawn first the background will be drawn by sending a WM_PAINT message to the parent window. If using this function with a valid color the status of the window will be changed from transparent to non transparent and if the window needs to be redrawn the background will be filled with the given color. If GUI_INVALID_COLOR is passed to the function the status will be changed from non transparent to transparent.
SLIDER_SetDefaultFocusColor()
Description
Sets the default focus rectangle color for new slider bars.
2002-2007 Micrium
630
CHAPTER 15
Prototype
GUI_COLOR SLIDER_SetDefaultFocusColor(GUI_COLOR Color); Parameter Color Meaning
Default color to be used for new slider bars.
Return value
Previous default focus rectangle color.
Add. information
For more information please refer to the function SLIDER_SetFocusColor().
SLIDER_SetFocusColor()
Before After
Description
Sets the color used to render the focus rectangle of the slider bar.
Prototype
GUI_COLOR SLIDER_SetFocusColor(SLIDER_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of widget. Color to be used for the focus rectangle.
Meaning
Return value
Previous color of the focus rectangle.
Add. information
The focus rectangle is only visible if the widget has the input focus.
SLIDER_SetNumTicks()
Before After
Description
Sets the number of tick marks of the slider bar.
2002-2007 Micrium
631
Prototype
void SLIDER_SetNumTicks(SLIDER_Handle hObj, int NumTicks); Parameter hObj NumTicks
Handle of slider widget. Number of tick marks drawn.
Meaning
Add. information
After creating a slider widget the default number of tick marks is 10. The tick marks have no effect to snap the slider bar while dragging it.
SLIDER_SetRange()
Description
Sets the range of the slider.
Prototype
void SLIDER_SetRange(SLIDER_Handle hObj, int Min, int Max); Parameter hObj Min Max
Handle of slider widget. Minimum value. Maximum value.
Meaning
Add. information
After creating a slider widget the default range is set to 0 - 100.
Examples
If a value should be modified in the range of 0 - 2499 set the range as follows:
SLIDER_SetRange(hSlider, 0, 2499);
If a value should be modified in the range of 100 - 499 set the range as follows:
SLIDER_SetRange(hSlider, 100, 499);
If a value should be modified in the range of 0 to 5000 and the slider bar should change the value in steps of 250 set the range and the tick marks as follows. The result returned by SLIDER_GetValue() should be multiplied with 250:
SLIDER_SetRange(hSlider, 0, 20); SLIDER_SetNumTicks(hSlider, 21);
SLIDER_SetValue()
Description
Sets the current value of the slider bar.
Prototype
void SLIDER_SetValue(SLIDER_Handle hObj, int v); Parameter hObj v
Handle of slider widget. Value to be set.
Meaning
2002-2007 Micrium
632
CHAPTER 15
SLIDER_SetWidth()
Before After
Description
Sets the width of the slider bar.
Prototype
void SLIDER_SetWidth(SLIDER_Handle hObj, int Width); Parameter hObj Width
Handle of slider widget. Width to be set.
Meaning
15.20.5 Example
The source of the following sample is available as DIALOG_SliderColor.c in the samples shipped with C/GUI:
2002-2007 Micrium
633
Of course, text fields may also be used for labeling other widgets, as follows:
All TEXT-related routines are located in the file(s) TEXT*.c, TEXT.h. All identifiers are prefixed TEXT.
Default
GUI_INVALID_COLOR GUI_BLACK GUI_WRAPMODE_NONE &GUI_Font13_1
Explanation
Transparent background per default Default text color. Default wrapping mode. Font used.
Explanation
Creates the text widget. (Obsolete) Creates the text widget as a child window. (Obsolete) Creates the text widget. Creates the text widget from resource table entry. Returns the default font used for text. Sets the background color for the text. Sets the default font used for text. Sets the default text color used for text. Sets the default wrap mode for new text widgets. Sets the font used for a specified text widget. Sets the text for a specified text widget.
2002-2007 Micrium
634
CHAPTER 15
Explanation
Sets the text alignment of a specified text widget. Sets the text color of the given widget. Sets the wrap mode of a specified text widget.
TEXT_Create()
(Obsolete, TEXT_CreateEx should be used instead)
Description
Creates a TEXT widget of a specified size at a specified location.
Prototype
TEXT_Handle TEXT_Create(int x0, int y0, int xsize, int ysize, int Id, int Flags, const char* s, int Align); Parameter x0 y0 xsize ysize Id Flags s Align Meaning
Leftmost pixel of the text widget (in parent coordinates). Topmost pixel of the text widget (in parent coordinates). Horizontal size of the text widget (in pixels). Vertical size of the text widget (in pixels). ID to be returned. Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Pointer to the text to be displayed. Alignment attribute for the text (see indirect creation flags under TEXT_CreateIndirect() ).
Return value
Handle for the created TEXT widget; 0 if the routine fails.
TEXT_CreateAsChild()
(Obsolete, TEXT_CreateEx should be used instead)
Description
Creates a TEXT widget as a child window.
Prototype
TEXT_Handle TEXT_CreateAsChild(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, const char* s, int Align); Parameter x0 y0 xsize ysize hParent Meaning
X-position of the progress bar relative to the parent window. Y-position of the progress bar relative to the parent window. Horizontal size of the text widget (in pixels). Vertical size of the text widget (in pixels). Handle of parent window.
2002-2007 Micrium
635
Meaning TEXT_Create() ).
Pointer to the text to be displayed. Alignment attribute for the text (see indirect creation flags under TEXT_CreateIndirect() ).
Return value
Handle for the created TEXT widget; 0 if the routine fails.
TEXT_CreateEx()
Description
Creates a TEXT widget of a specified size at a specified location.
Prototype
TEXT_Handle TEXT_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, const char* pText); Parameter x0 y0 xsize ysize hParent WinFlags ExFlags Id pText Meaning
Leftmost pixel of the widget (in parent coordinates). Topmost pixel of the widget (in parent coordinates). Horizontal size of the widget (in pixels). Vertical size of the widget (in pixels). Handle of parent window. If 0, the new TEXT widget will be a child of the desktop (top-level window). Window create flags. Typically WM_CF_SHOW in order to make the widget visible immediately (please refer to WM_CreateWindow() in Chapter 14: "The Window Manager" for a list of available parameter values). Alignment attribute for the text (see indirect creation flags under TEXT_CreateIndirect() ). Window ID of the widget. Pointer to the text to be displayed.
Return value
Handle for the created widget; 0 if the routine fails.
TEXT_CreateIndirect()
Prototype explained at the beginning of the chapter. The following flags may be used as the Flags element of the resource passed as parameter: Permitted indirect creation flags ("OR" combinable) TEXT_CF_LEFT TEXT_CF_RIGHT TEXT_CF_HCENTER TEXT_CF_TOP TEXT_CF_BOTTOM TEXT_CF_VCENTER
User's & reference manual for C/GUI
Horizontal alignment: left Horizontal alignment: right Horizontal alignment: center Vertical alignment: top Vertical alignment: bottom Vertical alignment: center
2002-2007 Micrium
636
CHAPTER 15
TEXT_GetDefaultFont()
Description
Returns the default font used for text widgets.
Prototype
const GUI_FONT* TEXT_GetDefaultFont(void);
Return value
Pointer to the default font used for text widgets.
TEXT_SetBkColor()
Description
Sets the background color of the text widget.
Prototype
void TEXT_SetBkColor(TEXT_Handle hObj, GUI_COLOR Color); Parameter hObj Color
Handle of text widget. Color to be used for the background. (range 0x000000 and 0xFFFFFF or a valid color define) GUI_INVALID_COLOR to make background transparent
Meaning
Add. information
The background of this widget can either be filled with any available color or transparent. If a valid RGB color is specified, the background is filled with the color, otherwise the background (typically the contents of the parent window) is visible. If the background is transparent, the widget is treated as transparent window, otherwise as non-transparent window. Note that using a background color allows more efficient (faster) rendering.
TEXT_SetDefaultFont()
Description
Sets the default font used for text widgets.
Prototype
void TEXT_SetDefaultFont(const GUI_FONT* pFont); Parameter pFont Meaning
Pointer to the font to be set as default.
TEXT_SetDefaultTextColor()
Description
Sets the default text color used for text widgets.
2002-2007 Micrium
637
Prototype
void TEXT_SetDefaultTextColor(GUI_COLOR Color); Parameter Color
Color to be used.
Meaning
TEXT_SetDefaultWrapMode()
Description
Sets the default text wrapping mode used for new text widgets.
Prototype
GUI_WRAPMODE TEXT_SetDefaultWrapMode(GUI_WRAPMODE WrapMode); Parameter WrapMode Meaning
Default text wrapping mode used for new text widgets.
Return value
Previous default text wrapping mode.
Add. information
For details about text wrapping within the text widget please refer to the function TEXT_SetWrapMode().
TEXT_SetFont()
Description
Sets the font to be used for a specified text widget.
Prototype
void TEXT_SetFont(TEXT_Handle hObj, const GUI_FONT* pFont); Parameter hObj pFont
Handle of text widget. Pointer to the font to be used.
Meaning
TEXT_SetText()
Description
Sets the text to be used for a specified text widget.
Prototype
void TEXT_SetText(TEXT_Handle hObj, const char* s); Parameter hObj s
Handle of text widget. Text to be displayed.
Meaning
2002-2007 Micrium
638
CHAPTER 15
TEXT_SetTextAlign()
Description
Sets the text alignment of a specified text widget.
Prototype
void TEXT_SetTextAlign(TEXT_Handle hObj, int Align); Parameter hObj Align
Handle of text widget. Text alignment (see
Meaning TEXT_Create() ).
TEXT_SetTextColor()
Description
Sets the text color of a specified text widget.
Prototype
void TEXT_SetTextColor(TEXT_Handle pObj, GUI_COLOR Color); Parameter hObj Color
Handle of text widget. New text color.
Meaning
TEXT_SetWrapMode()
Description
Sets the wrapping mode of a specified text widget.
Prototype
void TEXT_SetWrapMode(TEXT_Handle hObj, GUI_WRAPMODE WrapMode); Parameter hObj WrapMode
Handle of text widget. (see table below)
Meaning
Add. information
For more details about text GUI_DispStringInRectWrap(). wrapping please refer to the function
2002-2007 Micrium
639
Macro
Default
Explanation
Default background color for new WINDOW widgets
WINDOW_BKCOLOR_DEFAULT 0xC0C0C0
WINDOW_CreateIndirect()
Prototype explained at the beginning of the chapter. The sample folder contains the file WIDGET_Window.c which shows how to use the WINDOW widget in a dialog resource.
WINDOW_SetDefaultBkColor()
Description
Sets the default background color used for WINDOW widgets.
Prototype
void WINDOW_SetDefaultBkColor(GUI_COLOR Color); Parameter Color
Color to be used.
Meaning
2002-2007 Micrium
640
CHAPTER 15
2002-2007 Micrium
641
Chapter 16 Dialogs
Widgets may be created and used on their own, as they are by nature windows themselves. However, it is often desirable to use dialog boxes, which are windows that contain one or more widgets. A dialog box (or dialog) is normally a window that appears in order to request input from the user. It may contain multiple widgets, requesting information from the user through various selections, or it may take the form of a message box which simply provides information (such as a note or warning to the user) and an "OK" button.
2002-2007 Micrium
642
CHAPTER 16
Dialogs
Dialog messages
A dialog box is a window, and it receives messages just like all other windows in the system do. Most messages are handled by the dialog box automatically; the others are passed to the callback routine specified upon creation of the dialog box (also known as the dialog procedure). There are two types of additional messages which are sent to the dialog window procedure: WM_INIT_DIALOG and WM_NOTIFY_PARENT. The WM_INIT_DIALOG message is sent to the dialog box procedure immediately before a dialog box is displayed. Dialog procedures typically use this message to initialize widgets and carry out any other initialization tasks that affect the appearance of the dialog box. The WM_NOTIFY_PARENT message is sent to the dialog box by its child windows in order to notify the parent of any events in order to ensure sychronization. The events sent by a child depend on its type and are documented seperately for every type of widget.
2002-2007 Micrium
643
Resource table
Dialog boxes may be created in a blocking manner (using GUI_ExecDialogBox()) or as non-blocking (using GUI_CreateDialogBox()). A resource table must first be defined which specifies all widgets to be included in the dialog. The example shown below creates a resource table. This particular sample was created manually, although it could also be done by a GUI-builder:
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = { { FRAMEWIN_CreateIndirect, "Dialog", 0, 10, 10, { BUTTON_CreateIndirect, "OK", GUI_ID_OK, 100, 5, { BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 100, 30, { TEXT_CreateIndirect, "LText", 0, 10, 55, { TEXT_CreateIndirect, "RText", 0, 10, 80, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT0, 60, 55, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT1, 60, 80, { TEXT_CreateIndirect, "Hex", 0, 10, 100, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT2, 60, 100, { TEXT_CreateIndirect, "Bin", 0, 10, 120, { EDIT_CreateIndirect, NULL, GUI_ID_EDIT3, 60, 120, { LISTBOX_CreateIndirect, NULL, GUI_ID_LISTBOX0, 10, 20, { CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK0, 10, 5, { CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK1, 30, 5, { SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER0, 60, 140, { SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER1, 10, 170, }; 180, 230, 0, 0 }, 60, 20, 0, 0 }, 60, 20, 0, 0 }, 48, 15, 0, GUI_TA_LEFT }, 48, 15, 0, GUI_TA_RIGHT }, 100, 15, 0, 50 }, 100, 15, 0, 50 }, 48, 15, 0, GUI_TA_RIGHT }, 100, 15, 0, 6 }, 48, 15, 0, GUI_TA_RIGHT }, 100, 15, 0, 0 }, 48, 40, 0, 0 }, 0, 0, 0, 0 }, 0, 0, 0, 0 }, 100, 20, 0, 0 }, 150, 30, 0, 0 }
Dialog procedure
The sample above has been created using the blank dialog procedure shown below. This is the basic template which should be used as a starting point when creating any dialog procedure:
/********************************************************************* * * Dialog procedure */ static void _cbCallback(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { default: WM_DefaultProc(pMsg); } }
For this sample, the dialog box is displayed with the following line of code:
GUI_ExecDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbCallback, 0, 0, 0);
2002-2007 Micrium
644
CHAPTER 16
Dialogs
The resulting dialog box looks as follows, or similar (the actual appearance will depend on your configuration and default settings):
After creation of the dialog box, all widgets included in the resource table will be visible, although as can be seen in the previous screen shot, they will appear "empty". This is because the dialog procedure does not yet contain code that initializes the individual elements. The initial values of the widgets, the actions caused by them, and the interactions between them need to be defined in the dialog procedure.
2002-2007 Micrium
The initialized dialog box now appears as follows, with all widgets containing their initial values:
646
CHAPTER 16 case GUI_ID_ESCAPE: GUI_EndDialog(hWin, 1); break; case GUI_ID_ENTER: GUI_EndDialog(hWin, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ if (Id == GUI_ID_OK) { /* OK Button */ GUI_EndDialog(hWin, 0); } if (Id == GUI_ID_CANCEL) { /* Cancel Button */ GUI_EndDialog(hWin, 1); } break; case WM_NOTIFICATION_SEL_CHANGED: /* Selection changed */ FRAMEWIN_SetText(hWin, "Dialog - sel changed"); break; default: FRAMEWIN_SetText(hWin, "Dialog - notification received"); } break; default: WM_DefaultProc(pMsg);
Dialogs
For further details, this entire example is available as Dialog.c in the samples shipped with C/GUI.
Explanation
Message boxes
Create a message box.
647
Prototype
WM_HWIN GUI_CreateDialogBox(const GUI_WIDGET_CREATE_INFO* paWidget, int NumWidgets, WM_CALLBACK* cb, WM_HWIN hParent,int x0, int y0); Parameter paWidget NumWidgets cb hParent x0 y0 Meaning
Pointer to resource table defining the widgets to be included in the dialog. Total number of widgets included in the dialog. Pointer to an application-specific callback function (dialog procedure). Handle of parent window (0 = no parent window). X-position of the dialog relative to parent window. Y-position of the dialog relative to parent window.
GUI_ExecDialogBox
Description
Creates a blocking dialog box.
Prototype
int GUI_ExecDialogBox(const GUI_WIDGET_CREATE_INFO* paWidget, int NumWidgets, WM_CALLBACK* cb, WM_HWIN hParent, int x0, int y0); Parameter paWidget NumWidgets cb hParent x0 y0 Meaning
Pointer to a resource table defining the widgets to be included in the dialog. Total number of widgets included in the dialog. Pointer to an application-specific callback function (dialog procedure). Handle of parent window (0 = no parent window). X-position of the dialog relative to parent window. Y-position of the dialog relative to parent window.
GUI_EndDialog
Description
Ends (closes) a dialog box.
Prototype
void GUI_EndDialog(WM_HWIN hDialog, int r); Parameter hDialog r
Handle to dialog box. Value to be returned by GUI_ExecDialogBox.
Meaning
Return value
Specifies the value to be returned to the calling thread from the function that created the dialog box (typically only relevant with GUI_ExecDialogBox). With non-blocking dialogs, there is no application thread waiting and the return value is ignored.
2002-2007 Micrium
648
CHAPTER 16
Dialogs
GUI_MessageBox
Description
Creates and displays a message box.
Prototype
void GUI_MessageBox(const char* sMessage, const char* sCaption, int Flags); Parameter sMessage sCaption Flags
Message to display. Caption for the title bar of the frame window. Reserved for future extensions, value does not matter.
Meaning
Additional information
The default properties of a message box can be changed by modifying them in the GUIConf.h file. The following table lists all available configuration macros: Type N N N S Macro MESSAGEBOX_BORDER MESSAGEBOX_XSIZEOK MESSAGEBOX_YSIZEOK MESSAGEBOX_BKCOLOR
4
Default
Explanation
Distance between the elements of a message box and the elements of the client window frame. X-size of the "OK" button. Y-size of the "OK" button. Color of the client window background.
50 20 GUI_WHITE
It is possible to display messages with more than one row. The example below shows how to do this.
Example
The following example demonstrates the use of a simple message box:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : DIALOG_MessageBox.c Purpose : Example demonstrating GUI_MessageBox ---------------------------------------------------------------------*/ #include "GUI.h" /******************************************************************* * User's & reference manual for C/GUI 2002-2007 Micrium
649 * main * ******************************************************************** */ void main(void) { GUI_Init(); WM_SetBkWindowColor(GUI_RED); /* Create message box and wait until it is closed */ GUI_MessageBox("This text is shown\nin a message box", "Caption/Title", GUI_MESSAGEBOX_CF_MOVEABLE); GUI_Delay(500); /* Wait for a short moment ... */ GUI_MessageBox("New message !", "Caption/Title", GUI_MESSAGEBOX_CF_MOVEABLE); }
2002-2007 Micrium
650
CHAPTER 16
Dialogs
2002-2007 Micrium
651
A virtual screen means a display area greater than the physical size of the display. It requires additional video memory and allows instantaneous switching between different screens even on slow CPUs. The following chapter shows the requirements for using virtual screens, how to configure C/GUI and how to take advantage of virtual screens. If a virtual display area is configured, the visible part of the display can be changed by setting the origin.
2002-2007 Micrium
652
CHAPTER 17
17.1 Introduction
Virtual pages Panning LCD_VXSIZE LCD_XSIZE LCD_XSIZE
LCD_YSIZE
LCD_VYSIZE
LCD_VYSIZE
LCD_YSIZE
Visible area
Virtual page 1
Virtual area
Virtual page 2
The virtual screen support of C/GUI can be used for panning or for switching between different video pages.
Panning
If the application uses one screen which is larger than the display, the virtual screen API functions can be used to make the desired area visible.
Virtual pages
Virtual pages are a way to use the display RAM as multiple pages. If an application for example needs 3 different screens, each screen can use its own page in the display RAM. In this case, the application can draw the second and the third page before they are used. After that the application can switch very fast between the different pages using the virtual screen API functions of C/GUI. The only thing the functions have to do is setting the right display start address for showing the desired screen. In this case the virtual Y-size typically is a multiple of the display size in Y.
17.2 Requirements
The virtual screen feature requires hardware with more display RAM than required for a single screen and the ability of the hardware to change the start position of the display output.
Video RAM
The used display controller should support video RAM for the virtual area. For example if the display has a resolution of 320x240 and a color depth of 16 bits per pixel and 2 screens should be supported, the required size of the video RAM can be calculated as follows: Size = LCD_XSIZE * LCD_YSIZE * LCD_BITSPERPIXEL / 8 * NUM_SCREENS
2002-2007 Micrium
653
17.3 Configuration
The virtual screen support configuration should be done in the file LCDConf.h. The table below shows all available configuration macros: Type
F N N
Default
---
Explanation
Macro used to set the display start position of the upper left corner. Vertical resolution of virtual display.
LCD_SET_ORG
Description
This macro is used by the display driver to set the display start position of the upper left corner of the display.
Type
Function replacement.
Prototype
#define LCD_SET_ORG(x, y) Parameter x y
X position of the visible area. Y position of the visible area.
Meaning
Example
#define LCD_SET_ORG(x, y) SetDisplayOrigin(x, y) /* Function call for setting the display start position */
LCD_VXSIZE, LCD_VYSIZE
Description
The virtual screen size is configured by the macros LCD_VXSIZE and LCD_VYSIZE. LCD_VXSIZE always should be > LCD_XSIZE and LCD_VYSIZE should be > LCD_YSIZE. If a virtual area is configured the clipping area of C/GUI depends on the virtual screen and not on the display size. Drawing operations outside of LCD_XSIZE and LCD_YSIZE but inside the virtual screen are performed.
Type
Numerical values.
2002-2007 Micrium
654
CHAPTER 17
17.4 Samples
In the following a few samples are shown to make clear how to use virtual screens with C/GUI.
Configuration
#define LCD_XSIZE 128 #define LCD_YSIZE 64 #define LCD_VYSIZE 192
Application
GUI_SetColor(GUI_RED); GUI_FillRect(0, 0, 127, 63); GUI_SetColor(GUI_GREEN); GUI_FillRect(0, 64, 127, 127); GUI_SetColor(GUI_BLUE); GUI_FillRect(0, 127, 127, 191); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringAt("Screen 0", 0, 0); GUI_DispStringAt("Screen 1", 0, 64); GUI_DispStringAt("Screen 2", 0, 128); GUI_SetOrg(0, 64); /* Set origin to screen 1 */ GUI_SetOrg(0, 128); /* Set origin to screen 2 */
2002-2007 Micrium
655
Output
The table below shows the output of the display: Explanation Display output Contents of virtual area
Before executing
GUI_SetOrg(0, 240)
After executing
GUI_SetOrg(0, 240)
After executing
GUI_SetOrg(0, 480)
2002-2007 Micrium
656
CHAPTER 17
After showing a short introduction the sample creates 2 screens on 2 separate pages as shown above. The first screen shows a dialog which includes a graphical representation of 2 temperature curves. When pressing the Set color button, the application switches instantaneously to the second screen, even on slow CPUs. After pressing the OK button of the Adjust color dialog, the application switches back to the first screen. For more details, please take a look at the source code of the sample.
2002-2007 Micrium
657
Make sure to modify LCDConf.h to include #define LCD_VYSIZE 480. When using the viewer both screens can be shown at the same time. The screenshot above shows the visible display at the left side and the contents of the whole configured virtual display RAM at the right side.
2002-2007 Micrium
658
CHAPTER 17
After a short intro screen the Main Screen is shown on the display using page 0. After the Setup button is pressed, the Setup screen is created on page 1. After the screen has been created, the application makes the screen visible by switching to page 1. The Calibration and the About screen both use page 2. If the user presses one of the buttons Calibration or About the application switches to page 2 and shows the dialog.
2002-2007 Micrium
659
The viewer can show all pages at the same time. The screenshot above shows the visible display at the left side and the contents of the whole layer (virtual display RAM) with the pages 0 - 2 at the right side.
2002-2007 Micrium
660
CHAPTER 17
GUI_GetOrg()
Description
Returns the display start position.
Prototype
void GUI_GetOrg(int * px, int * py); Parameter px py Meaning
Pointer to variable of type int to store the X position of the display start position. Pointer to variable of type int to store the Y position of the display start position.
Additional information
The function stores the current display start position into the variables pointed by the given pointers.
GUI_SetOrg()
Description
Sets the display start position.
Prototype
void GUI_SetOrg(int x, int y); Parameter x y Meaning
New X position of the display start position. New Y position of the display start position.
2002-2007 Micrium
661
If more than 1 display should be accessed or the LCD-controller supports more than 1 layer (and more than one layer should be used) multi layer support of C/GUI is required. This feature is a separate (optional) software item and is not included in the C/GUI basic package. The software for the multi layer support is located in the subdirectory GUI\MultiLayer. Multi layer support and multi display support work the same way. The configuration file can contain multiple configurations for up to 6 displays/layers with their own settings. That means each display can be accessed with its own color settings, its own size and its own LCD-driver. In order to activate this feature, you simply need to use an appropriate LCD-configuration file LCDConf.h and you have to define the number of layers in GUIConf.h.
2002-2007 Micrium
662
CHAPTER 18
18.1 Introduction
Windows can be placed in any layer or display, drawing operations can be used on any layer or display. Since there are really only smaller differences from this point of view, multiple layers and multiple displays are handled the same way (Using the same API routines) and are simply referred to as multiple layers, even if the particular embedded system uses multiple displays. The C/GUI viewer allows you to look at every individual layer (display), but in the case of multiple layer systems also to look at the actual output (the composite view). Currently systems with multiple displays and multiple layers can be used, but not simulated.
18.1.1 Limitations
Currently systems with a total of max 6 displays / layers are supported.
Sample
The following sample shows how to select a layer for drawing operations:
void MainTask(void) { GUI_Init(); /* Draw something on default layer 0 */ GUI_SetBkColor(GUI_GREEN); GUI_Clear(); GUI_DispStringHCenterAt("Layer 0", 100, 46); /* Draw something on layer 1 */ GUI_SelectLayer(1); /* Select layer 1 */ GUI_SetBkColor(GUI_RED); GUI_Clear(); GUI_SetColor(GUI_BLUE); GUI_FillRect(20, 20, 179, 79); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_DispStringHCenterAt("Layer 1", 100, 46); while(1) { GUI_Delay(100); } }
2002-2007 Micrium
663
Sample
The following sample shows how to create 3 windows on 2 different desktop windows:
/* Create 1 child window on destop 0 */ hWin0 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(0), WM_CF_SHOW, _cbWin0, 0); /* Create 2 child windows on destop 1 */ hWin1 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin1, 0); hWin2 = WM_CreateWindowAsChild(110, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin2, 0);
2002-2007 Micrium
664
CHAPTER 18
The following table shows the screenshot and the window hierarchy of the above sample: Screenshot Window hierarchy
Layer 0
Layer 1
Desktop 0
Desktop 1
Window 0
Window 1
Window 2
Sample
The following sample shows how to attach a window to a new parent window:
/* Create 1 child window on destop 0 */ hWin0 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(0), WM_CF_SHOW, _cbWin0, 0); /* Create 2 child windows on destop 1 */ hWin1 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin1, 0); hWin2 = WM_CreateWindowAsChild(110, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin2, 0); GUI_Delay(1000); /* Detach window 2 from desktop 1 and attach it to desktop 0 */ WM_AttachWindow(hWin2, WM_GetDesktopWindowEx(0));
2002-2007 Micrium
665
The following table shows the screenshot and the window hierarchy of the above sample before attaching the window to the new parent: Screenshot Window hierarchy
Layer 0
Layer 1
Desktop 0
Desktop 1
Window 0
Window 1
Window 2
The next table shows the screenshot and the window hierarchy of the above sample after attaching the window to the new parent: Screenshot Window hierarchy
Layer 0
Layer 1
Desktop 0
Desktop 1
Window 0
Window 1
Window 2
2002-2007 Micrium
666
CHAPTER 18
18.2.1 Transparency
Transparency means that at the position of pixels with color index 0 in a layer > 0, the color of the background layer is visible. Since for all but layer 0 Index 0 means transparency, Index 0 can not be used to display colors. This also means that the color conversion should never yield 0 as best match for a color, since this would result in a transparent pixel. This means that only some fixed palette modes or a custom palette mode should be used and that you need to be careful when defining you own palette. You need to make sure that the color conversion (24 bit RGB -> Index) never yields 0 as result.
Sample
The following sample shows how to use transparency. It draws 3 color bars in layer 0. Layer 1 is filled with white and 3 transparent items are drawn.
2002-2007 Micrium
667 GUI_SelectLayer(0); GUI_SetColor(GUI_RED); GUI_FillRect(0, 0, 199, 33); GUI_SetColor(GUI_GREEN); GUI_FillRect(0, 34, 199, 66); GUI_SetColor(GUI_BLUE); GUI_FillRect(0, 67, 199, 99); GUI_SelectLayer(1); GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK); GUI_DispStringHCenterAt("Layer 1", 100, 4); GUI_SetColor(GUI_TRANSPARENT); GUI_FillCircle(100, 50, 35); GUI_FillRect(10, 10, 40, 90); GUI_FillRect(160, 10, 190, 90);
Different methods
There are 3 different methods of managing the alpha information: Layer alpha blending: On systems with layer alpha blending the alpha value is fixed to the layer and can be set with the function LCD_SetAlphaEx(). Lookup table (LUT) alpha blending: This kind of alpha blending uses the LUT for managing the alpha information. Pixel alpha blending: Each pixel of the layer to be combined with the background consists of alpha blending information.
2002-2007 Micrium
668
CHAPTER 18
Sample
The following sample shows how to use pixel alpha blending. It draws a circle in layer 0 and a yellow triangle build of horizontal lines with a vertical gradient of alpha values:
GUI_SetColor(GUI_BLUE); GUI_FillCircle(100, 50, 49); GUI_SelectLayer(1); GUI_SetBkColor(GUI_TRANSPARENT); GUI_Clear(); for (i = 0; i < 100; i++) { U32 Alpha; Alpha = (i * 255 / 100) << 24; GUI_SetColor(GUI_YELLOW | Alpha); GUI_DrawHLine(i, 100 - i, 100 + i); }
669
Further you have to modify your LCDConf.h as described later in this chapter.
C/GUI comes with 2 samples including the configuration files. They can be found under Sample\Tutorial\MULTILAYER_ScreenRotation...
2002-2007 Micrium
670
CHAPTER 18
/********************************************************************* * * Configuration of Layer 1 * ********************************************************************** */ #define LCD_CONTROLLER_1 #define LCD_XSIZE_1 #define LCD_YSIZE_1 User's & reference manual for C/GUI 3916 400 234 /* X-resolution of LCD, Logical coor. */ /* Y-resolution of LCD, Logical coor. */ 2002-2007 Micrium
671 #define #define #define #define #define #define #define LCD_BITSPERPIXEL_1 8 LCD_FIXEDPALETTE_1 86661 LCD_SWAP_BYTE_ORDER_1 1 LCD_SWAP_RB_1 1 LCD_INIT_CONTROLLER_1() LCD_READ_MEM_1(Off) *((U16 *) (0xd00000 + (((U32)(Off)) << 1))) LCD_WRITE_MEM_1(Off,data) *((U16 *) (0xd00000 + (((U32)(Off)) << 1))) = data
#endif /* LCDCONF_H */
/********************************************************************* * * Full bus configuration */ #define LCD_READ_MEM_0(Off) *((U16 *) (0xc00000 + (((U32)(Off)) << 1))) #define LCD_WRITE_MEM_0(Off,data) *((U16 *) (0xc00000 + (((U32)(Off)) << 1))) = data #define LCD_READ_REG_0(Off) *((volatile U16 *)(0xc1ffe0 + (((U16)(Off)) << 1))) #define LCD_WRITE_REG_0(Off,data) *((volatile U16 *)(0xc1ffe0 + (((U16)(Off)) << 1))) = data /********************************************************************* * * Define contents of registers */ #define LCD_REG0_0 (0) #define LCD_REG1_0 (0x23) \ |(1<<2) #define LCD_REG2_0 ((3<<6) \ |(1<<5) \ |(1<<4) \ |(0<<3) \ |(0<<2) \ |(0<<1) \ |(0<<0)) #define LCD_REG3_0 \ ((0<<7) \ |(0<<3) \ |(0<<2) \ |(3<<0)) #define LCD_REG4_0 (LCD_XSIZE_0 / 8 - 1) #define LCD_REG5_0 ((LCD_YSIZE_0 - 1) & 255) #define LCD_REG6_0 ((LCD_YSIZE_0 - 1) >> 8) #define LCD_REG7_0 (0) #define LCD_REG8_0 (31) #define LCD_REG9_0 (0) #define LCD_REGA_0 (0) #define LCD_REGB_0 (0) #define LCD_REGC_0 (0) User's & reference manual for C/GUI 2002-2007 Micrium
672 #define #define #define #define #define #define LCD_REGD_0 LCD_REG12_0 LCD_REG13_0 LCD_REG14_0 LCD_REG1B_0 LCD_REG1C_0
CHAPTER 18
/********************************************************************* * * Init sequence for 16 bit access */ #if !LCD_SWAP_BYTE_ORDER_0 #define LCD_WRITE_REGLH_0(Adr, d0, d1) LCD_WRITE_REG(Adr, ((d0)<<8) | (d1)) #else #define LCD_WRITE_REGLH_0(Adr, d0, d1) LCD_WRITE_REG(Adr, ((d1)<<8) | (d0)) #endif #define LCD_INIT_CONTROLLER_0() LCD_WRITE_REGLH_0(0x00 >> LCD_WRITE_REGLH_0(0x02 >> LCD_WRITE_REGLH_0(0x04 >> LCD_WRITE_REGLH_0(0x06 >> LCD_WRITE_REGLH_0(0x08 >> LCD_WRITE_REGLH_0(0x0a >> LCD_WRITE_REGLH_0(0x0c >> LCD_WRITE_REG (0x0e >> LCD_WRITE_REG (0x10 >> LCD_WRITE_REGLH_0(0x12 >> LCD_WRITE_REGLH_0(0x14 >> LCD_WRITE_REGLH_0(0x1a >> LCD_WRITE_REGLH_0(0x1c >> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LCD_REG0_0, LCD_REG1_0); LCD_REG2_0, LCD_REG3_0); LCD_REG4_0, LCD_REG5_0); LCD_REG6_0, LCD_REG7_0); LCD_REG8_0, LCD_REG9_0); LCD_REGA_0, LCD_REGB_0); LCD_REGC_0, LCD_REGD_0); 0x00); 0x00); LCD_REG12_0, LCD_REG13_0); LCD_REG14_0, 0); 0, LCD_REG1B_0); LCD_REG1C_0, 0) \ \ \ \ \ \ \ \ \ \ \ \ \
/********************************************************************* * * Configuration of Display 1 * ********************************************************************** */ #define #define #define #define LCD_CONTROLLER_1 LCD_XSIZE_1 LCD_YSIZE_1 LCD_BITSPERPIXEL_1 6963 240 128 1 /* X-resolution of LCD, Logical coor. */ /* Y-resolution of LCD, Logical coor. */
/********************************************************************* * * Simple bus configuration */ void LCD_X_Write00(char c); void LCD_X_Write01(char c); char LCD_X_Read00(void); char LCD_X_Read01(void); #define LCD_WRITE_A1_1(Byte) LCD_X_Write01(Byte) #define LCD_WRITE_A0_1(Byte) LCD_X_Write00(Byte) #define LCD_READ_A1_1() LCD_X_Read01() #define LCD_READ_A0_1() LCD_X_Read00() #define LCD_INIT_CONTROLLER_1() #endif /* LCDCONF_H */ LCD_X_Init()
2002-2007 Micrium
673
GUI_AssignCursorLayer()
Description
The function assigns a layer to be used as cursor layer.
Prototype
void GUI_AssignCursorLayer(unsigned Index, unsigned CursorLayer); Parameter Index CursorLayer
Layer index. Layer to be used to manage the cursor.
Meaning
Additionnal Information
Using a hardware cursor means a layer is used as cursor layer. Contrary to the default cursor handling, where the cursor is drawn in the same video memory area as all other items, a hardware cursor is drawn in a separate layer. In this case C/GUI makes sure the background color of the hardware cursor layer is set to transparency and the selected cursor will be drawn into the layer. Whereas the default cursor management requires more or less calculation time to draw the cursor and to manage the background, moving a hardware cursor requires only the modification of a few registers. Please note that using this function requires that the display driver supports layer positioning.
GUI_SelectLayer()
Description
Selects a layer for drawing operations.
Prototype
unsigned int GUI_SelectLayer(unsigned int Index); Parameter Index
Layer index.
Meaning
2002-2007 Micrium
674
CHAPTER 18
Return value
Index of previous selected layer.
GUI_SetLayerAlphaEx()
Description
Sets the alpha blending of the given layer.
Prototype
int GUI_SetLayerAlphaEx(unsigned Index, int Alpha); Parameter Index Alpha
Layer index. Alpha blending value of the given layer.
Meaning
Additionnal Information
To be able to use this function the hardware and the used display driver need to support layer alpha blending. If the driver does not support this feature the function returns immediately. The usable range of alpha values depends on the hardware. In many cases the range of alpha values is limited, for example 0 - 0x3f. C/GUI does not know something about limitations and passes the given value to the driver. It is the responsibility of the application to make sure that the given value is in a legal range.
GUI_GetLayerPosEx()
Description
Sets the X- and Y-position of the given layer.
Prototype
void GUI_GetLayerPosEx(unsigned Index, GUI_POINT * pPos); Parameter Index pPos
Layer index. Pointer to a GUI_POINT structure containing the position to be set.
Meaning
Additionnal Information
To be able to use this function the hardware and the used display driver need to support layer positioning. If the driver does not support this feature the function returns immediately.
GUI_SetLayerSizeEx()
Description
Sets the X- and Y-size of the given layer.
2002-2007 Micrium
675
Prototype
int GUI_SetLayerSizeEx(unsigned Index, int xSize, int ySize); Parameter Index xSize ySize
Layer index. New horizontal size in pixels of the given layer. New vertical size in pixels of the given layer.
Meaning
Additionnal Information
To be able to use this function the hardware and the used display driver need to support layer sizing. If the driver does not support this feature the function returns immediately.
GUI_SetLayerVisEx()
Description
Sets the visibility of the given layer.
Prototype
int GUI_SetLayerVisEx(unsigned Index, int OnOff); Parameter Index OnOff
Layer index. 1 if layer should be visible, 0 for invisible.
Meaning
Additionnal Information
To be able to use this function the hardware and the used display driver need to support this feature. If the driver does not support this feature the function returns immediately.
GUI_SetLUTColorEx()
Description
Modifies a single entry in the color table and the LUT of the given layer.
Prototype
void GUI_SetLUTColorEx(U8 Pos, LCD_COLOR Color, unsigned int LayerIndex); Parameter Pos Color Index Meaning
Position within the lookup table. Should be less than the number of colors (e.g. 0-3 for 2 bpp, 0-15 for 4 bpp, 0-255 for 8 bpp). 24-bit RGB value. Layer index.
Additionnal Information
(see GUI_SetLUTColor)
2002-2007 Micrium
676
CHAPTER 18
LCD_GetNumLayers()
Description
Returns the number of layers configured in your configuration.
Prototype
int LCD_GetNumLayers(void);
Return value
Number of layers configured in your configuration.
2002-2007 Micrium
677
C/GUI provides touch-screen, mouse, and keyboard support. The basic C/GUI package includes a driver for analog touch-screens and a PS2 mouse driver, although other types of touch-panel and mouse devices can also be used with the appropriate drivers. Any type of keyboard driver is compatible with C/GUI. The software for input devices is located in the subdirectory GUI\Core.
2002-2007 Micrium
678
CHAPTER 19
19.1 Description
Pointer input devices are devices such as mouse, touch-screen, joystick. Multiple pointer input devices can be used in a single application to enable simultaneous mouse/touch-screen/joystick use. Basically all a PID driver does is call the routine GUI_PID_StoreState() whenever an event (such as mouse move, or press on the touch screen) has been detected. The window manager takes care of the appropriate reaction to PID events; If the window manager is not used, your application is responsible for reacting to PID events.
2002-2007 Micrium
679
Data structure
The structure of type GUI_PID_STATE referenced by the parameter pState is filled by the routine with the current values. The structure is defined as follows:
typedef struct { int x, y; unsigned char Pressed; } GUI_PID_STATE;
Elements of GUI_PID_STATE
Data type int int Element x y Meaning
X position of pointer input device. Y position of pointer input device. If using a touch screen this value can be 0 (unpressed) or 1 (pressed). If using a mouse bit 0 is used for the pressed state of the left button and bit 1 for the right button. The bits are 1 if the button is pressed and 0 if not.
unsigned char
Pressed
GUI_PID_GetState()
Description
Returns if the input device is currently pressed or not and fills the given GUI_PID_STATE structure with the current state information.
Prototype
void GUI_PID_GetState(const GUI_PID_STATE *pState); Parameter pState
Pointer to a structure of type
Meaning GUI_PID_STATE .
Return value
1 if input device is currently pressed; 0 if not pressed.
GUI_PID_StoreState()
Description
Stores the current state of the pointer input device.
2002-2007 Micrium
680
CHAPTER 19
Prototype
int GUI_PID_StoreState(GUI_PID_STATE *pState); Parameter pState
Pointer to a structure of type
Meaning GUI_PID_STATE .
Additional information
This function can be used from an interrupt service routine.
2002-2007 Micrium
681
GUI_MOUSE_GetState()
Description
Returns the current state of the mouse.
Prototype
int GUI_MOUSE_GetState(GUI_PID_STATE *pState); Parameter pState
Pointer to a structure of type
Meaning GUI_PID_STATE .
Return value
1 if mouse is currently pressed; 0 if not pressed.
Additional information
This function will call GUI_PID_GetState().
GUI_MOUSE_StoreState()
Description
Stores the current state of the mouse.
Prototype
void GUI_MOUSE_StoreState(const GUI_PID_STATE *pState); Parameter pState
Pointer to a structure of type
Meaning GUI_PID_STATE .
Additional information
This function will call GUI_PID_StoreState().
2002-2007 Micrium
682
CHAPTER 19
GUI_MOUSE_DRIVER_PS2_Init()
Description
Initializes the mouse driver.
Prototype
void GUI_MOUSE_DRIVER_PS2_Init(void);
GUI_MOUSE_DRIVER_PS2_OnRx()
Description
Must be called from receive interrupt routines.
Prototype
void GUI_MOUSE_DRIVER_PS2_OnRx(unsigned char Data); Parameter Data
Byte of data received by ISR.
Meaning
Additional Information
The PS2 mouse driver is a serial driver, meaning it receives 1 byte at a time. You need to ensure that this function is called from your receive interrupt routine every time a byte (1 character) is received.
User's & reference manual for C/GUI 2002-2007 Micrium
683
GUI_TOUCH_GetState()
Description
Returns the current state of the touch-screen.
Prototype
int GUI_TOUCH_GetState(GUI_PID_STATE *pState); Parameter pState
Pointer to a structure of type
Meaning GUI_PID_STATE .
Return value
1 if touch-screen is currently pressed; 0 if not pressed.
GUI_TOUCH_StoreState()
Description
Stores the current state of the touch-screen using X- and Y-coordinates as parameters.
Prototype
void GUI_TOUCH_StoreState(int x int y); Parameter x y
X-position. Y-position.
Meaning
2002-2007 Micrium
684
CHAPTER 19
Additional Information
If one of the given values is negative, the GUI assumes that the touch panel is not pressed.
GUI_TOUCH_StoreStateEx()
Description
Stores the current state of the touch-screen.
Prototype
void GUI_TOUCH_StoreStateEx(const GUI_PID_STATE *pState); Parameter pState
Pointer to a structure of type
Meaning GUI_PID_STATE .
Additional information
This function will call GUI_PID_StoreState().
Y+
X+
X-
Y-
2002-2007 Micrium
685
2002-2007 Micrium
686
CHAPTER 19
The C/GUI sample folder contains a small program which can be used to get these values from your touch panel. It is located in the folder Sample\GUI and its name is TOUCH_Sample.c. Run this sample on your hardware. The output should be similar to the screenshot at the right side. The following table shows how to get the values: Value GUI_TOUCH_AD_TOP GUI_TOUCH_AD_BOTTOM GUI_TOUCH_AD_LEFT GUI_TOUCH_AD_RIGHT How to get
Press the touch at the top and write down the analog input value in Y. Press the touch at the bottom and write down the analog input value in Y. Press the touch at the left and write down the analog input value in X. Press the touch at the right and write down the analog input value in X.
Modifying GUITouchConf.h
The last step is to modify the touch configuration file GUITouchConf.h. Insert the values into the file like the following sample:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * ********************************************************************** --------------------------------------------------------------------File : GUITouch.Conf.h Purpose : Configures C/GUI touch screen module ---------------------------------------------------------------------*/ #ifndef GUITOUCH_CONF_H #define GUITOUCH_CONF_H #define #define #define #define GUI_TOUCH_AD_TOP GUI_TOUCH_AD_BOTTOM GUI_TOUCH_AD_LEFT GUI_TOUCH_AD_RIGHT 877 273 232 918
#endif /* GUITOUCH_CONF_H */
2002-2007 Micrium
687
GUI_TOUCH_X_ActivateX(), GUI_TOUCH_X_ActivateY()
Description
These routines are called from GUI_TOUCH_Exec() to activate the measurement of the X- and the Y-axes. GUI_TOUCH_X_ActivateX() switches on the measurement voltage to the X-axis; GUI_TOUCH_X_ActivateY() switches on the voltage to the Yaxis. Switching on the voltage in X means the value for the Y-axis can be measured and vice versa.
Prototypes
void GUI_TOUCH_X_ActivateX(void); void GUI_TOUCH_X_ActivateY(void);
GUI_TOUCH_X_MeasureX(), GUI_TOUCH_X_MeasureY()
Description
These routines are called from GUI_TOUCH_Exec() to return the measurement values from the A/D converter for the X- and the Y-axes.
2002-2007 Micrium
688
CHAPTER 19
Prototypes
int GUI_TOUCH_X_MeasureX(void); int GUI_TOUCH_X_MeasureY(void);
Sample implementation
The following shows a sample implementation of the touch hardware routines for a Mitsubishi M16C/80 controller:
void GUI_TOUCH_X_ActivateX(void) { U8 Data; asm("fclr i"); /* Disable interrupts Data = P10; /* Read port data Data |= (1 << 2) | (1 << 3); /* Switch on power in X and enable measurement in Y Data &= ~((1 << 4) | (1 << 5)); /* Switch off power in Y and disable measurement in X P10 = Data; /* Write port data asm("fset i"); /* Enable interrupts } void GUI_TOUCH_X_ActivateY(void) { U8 Data; asm("fclr i"); /* Disable interrupts Data = P10; /* Read port data Data |= (1 << 5) | (1 << 4); /* Switch on power in Y and enable measurement in X Data &= ~((1 << 3) | (1 << 2)); /* Switch off power in X and disable measurement in Y P10 = Data; /* Write port data asm("fset i"); /* Enable interrupts } static void ReadADCx(int channel) ADCON0 = channel | (0 << 3) | (0 << 6) | (0 << 7); ADCON1 = (0 << 0) | (0 << 2) | (0 << 3) | (0 << 4) | (1 << 5) | (0 << 6); ADCON2 = (1 << 0); ADIC = 0; ADCON0 |= (1 << 6); while ((ADIC & (1 << 3)) == 0); ADCON0 &= ~(6 << 0); } int GUI_TOUCH_X_MeasureX(void) { ReadADCx(0); return AD0; } int GUI_TOUCH_X_MeasureY(void) { ReadADCx(1); return AD1; } { /* /* /* /* /* /* /* /* /* /* /* /* /* /* /* Select channel 0-7 One shot mode A-D conversion start (0=stop) FAD/4 select A-D sweep select (XX) No sweep mode 8 bit mode FAD4 select VRef connected Anex0/1 not used Use sample and hold Reset IR flag Start conversion Wait for end of conversion Start conversion = 0
*/ */ */ */ */ */
*/ */ */ */ */ */
*/ */ */ */ */ */ */ */ */ */ */ */ */ */ */
2002-2007 Micrium
689
GUI_TOUCH_Calibrate()
Description
Changes the calibration at run-time.
Prototype
int GUI_TOUCH_Calibrate(int Coord, int Log0, int Log1, int Phys0, int Phys1); Parameter Coord Log0 Log1 Phys0 Phys1
0 for X-axis, 1 for Y-axis. Logical value 0 in pixels. Logical value 1 in pixels. A/D converter value for Log0. A/D converter value for Log1.
Meaning
Additional information
The function takes as parameters the axis to be calibrated, two logical values in pixels for this axis and two corresponding physical values of the A/D converter.
GUI_TOUCH_Exec()
Description
Polls the touch-screen by calling the TOUCH_X routines to activate the measurement of the X- and Y-axes. You must ensure that this function is called for about 100 times per second.
Prototype
void GUI_TOUCH_Exec(void);
Additional information
If you are using a real-time operating system, the easiest way to make sure this function is called is to create a separate task. When not using a multitask system, you can use an interrupt service routine to do the job.
GUI_TOUCH_SetDefaultCalibration()
Description
Resets the calibration to the values set as default in the configuration file.
2002-2007 Micrium
690
CHAPTER 19
Prototype
void GUI_TOUCH_SetDefaultCalibration(void);
Additional information
If no values are set in the configuration file, the calibration will be restored to the original default values.
Macro GUI_TOUCH_SWAP_XY GUI_TOUCH_MIRROR_X GUI_TOUCH_MIRROR_Y GUI_TOUCH_AD_LEFT GUI_TOUCH_AD_RIGHT GUI_TOUCH_AD_TOP GUI_TOUCH_AD_BOTTOM GUI_TOUCH_XSIZE GUI_TOUCH_YSIZE
0 0 0
Default
Mirrors the X-axis. Mirrors the Y-axis.
Explanation
Set to 1 to swap the X- and the Y-axes.
Minimum value returned by the A/D converter. Maximum value returned by the A/D converter. Minimum value returned by the A/D converter. Maximum value returned by the A/D converter. Horizontal area covered by touch-screen. Vertical area covered by touch-screen.
2002-2007 Micrium
691
CHAPTER 19
2002-2007 Micrium
693
C/GUI provides support for any kind of keyboards. Any type of keyboard driver is compatible with C/GUI. The software for keyboard input is located in the subdirectory GUI\Core and part of the basic package.
2002-2007 Micrium
694
CHAPTER 20
Keyboard Input
20.1 Description
A keyboard input device uses ASCII character coding in order to be able to distinguish between characters. For example, there is only one "A" key on the keyboard, but an uppercase "A" and a lowercase "a" have different ASCII codes (0x41 and 0x61, respectively).
Description
2002-2007 Micrium
695
GUI_StoreKeyMsg()
Description
Stores a status message in a specified key.
Prototype
void GUI_StoreKeyMsg(int Key, int Pressed); Parameter Key Pressed Meaning
May be any extended ASCII character (between 0x20 and 0xFF) or any predefined C/GUI character code. Key state (see table below).
GUI_SendKeyMsg()
Description
Sends the keyboard data to the window with the input focus. If no window has the input focus, the function GUI_StoreKeyMsg() is called to store the data to the input buffer.
Prototype
void GUI_SendKeyMsg(int Key, int Pressed); Parameter Key Pressed Meaning
May be any extended ASCII character (between 0x20 and 0xFF) or any predefined C/GUI character code. Key state (see
GUI_StoreKeyMsg() ).
Additional infoemation
This function should not be called from an interrupt service routine.
GUI_ClearKeyBuffer()
Description
Clears the key buffer.
2002-2007 Micrium
696
CHAPTER 20
Keyboard Input
Prototype
void GUI_ClearKeyBuffer(void);
GUI_GetKey()
Description
Returns the current contents of the key buffer.
Prototype
int GUI_GetKey(void);
Return value
Codes of characters in key buffer; 0 if no keys in buffer.
GUI_StoreKey()
Description
Stores a key in the buffer.
Prototype
void GUI_StoreKey(int Key); Parameter Key Meaning
May be any extended ASCII character (between 0x20 and 0xFF) or any predefined C/GUI character code.
Additional Information
This function is typically called by the driver and not by the application itself.
GUI_WaitKey()
Description
Waits for a key to be pressed.
Prototype
int GUI_WaitKey(void);
Additional Information
The application is "blocked", meaning it will not return until a key is pressed.
2002-2007 Micrium
697
Chapter 21 Sprites
A sprite is an image which can be shown above all other graphics on the screen. A sprite preserves the screen area it covers. It can be moved or removed at any time, fully restoring the screen content. Animation by use of multiple images is possible. Sprites are completely independent from all other drawing operations as well as window operations: Sprites do not affect drawing or window operations; drawing or window operations do not affect sprites. Sprites can be seen as objects which are sitting "on top" of the screen, similar to cursors.
2002-2007 Micrium
698
CHAPTER 21
Sprites
21.1 Introducton
C/GUI sprites are implemented as a pure software solution. No additional hardware is required to use C/GUI sprites. They can be shown, moved and deleted without effect on the currently visible graphic items.
Memory requirements
Each sprite needs a memory area for saving the display data behind the sprite to be able to restore the background on moving operations or on removing the sprite. Further a memory area for a color cache is required. The size of the color cache depends on the number of colors used in the sprite image. So the complete number of bytes required for a sprite can be calculated as follows: SizeOfSpriteObject (~30 bytes) + (XSize * YSize + NumberOfBitmapColors) * REQUIRED_BYTES_PER_PIXEL
Performance
Please note that drawing a sprite is more computer-bound than drawing a simple bitmap, because it has to manage the background data and intersections with other sprites.
Z-order
Z-order is an ordering of overlapping two-dimensional objects, in this case the sprites. When two sprites overlap, their Z-order determines which one appears on top of the other. The sprite created at last is the topmost sprite.
Explanation
GUI_SPRITE_Create()
Description
Creates a sprite at the given position in the current layer.
2002-2007 Micrium
699
Prototype
GUI_HSPRITE GUI_SPRITE_Create(const GUI_BITMAP GUI_UNI_PTR * pBM, int x, int y); Parameter pBM x y Meaning
Pointer to a bitmap structure to be used for drawing the sprite. X-position of the sprite in screen coordinates. Y-position of the sprite in screen coordinates.
Return value
Handle of the new sprite, 0 on failure.
Add. information
The bitmap addressed by the parameter pBM needs to agree with the following requirements: It should not be compressed. It needs to be transparent. It needs to be a palette based bitmap with 1, 2, 4 or 8bpp. Other bitmaps or insufficient memory cause the function to fail.
GUI_SPRITE_CreateEx()
Description
Creates a sprite at the given position in the desired layer.
Prototype
GUI_HSPRITE GUI_SPRITE_CreateEx(const GUI_BITMAP GUI_UNI_PTR * pBM, int x, int y, int Layer);; Parameter pBM x y Layer Meaning
Pointer to a bitmap structure to be used for drawing the sprite. X-position of the sprite in screen coordinates. Y-position of the sprite in screen coordinates. Layer of sprite.
Return value
Handle of the new sprite, 0 on failure.
GUI_SPRITE_Delete()
Description
Deletes the given sprite.
Prototype
void GUI_SPRITE_Delete(GUI_HSPRITE hSprite); Parameter hSprite
Handle of sprite to be deleted.
Meaning
2002-2007 Micrium
700
CHAPTER 21
Sprites
Add. information
The function deletes the sprite from the memory and restores its background automatically.
GUI_SPRITE_GetState()
Description
Returns if the given Sprite is visible or not.
Prototype
int GUI_SPRITE_GetState(GUI_HSPRITE hSprite); Parameter hSprite
Handle of sprite.
Meaning
Return value
1 if it is visible, 0 if not.
GUI_SPRITE_Hide()
Description
Hides the given sprite.
Prototype
void GUI_SPRITE_Hide(GUI_HSPRITE hSprite); Parameter hSprite
Handle of sprite to hide.
Meaning
Add. information
The function removes the given sprite from the list of visible sprites.
GUI_SPRITE_SetBitmap()
Description
Sets a new image for drawing the sprite.
Prototype
int GUI_SPRITE_SetBitmap(GUI_HSPRITE hSprite, const GUI_BITMAP GUI_UNI_PTR * pBM); Parameter hSprite pBM
Handle of sprite. Pointer to a bitmap structure to be used for drawing the sprite.
Meaning
Return value
0 on success, 1 if the routine fails.
Add. information
The new bitmap must have exact the same size as the previous one. Passing a pointer to a bitmap of a different size causes the function to fail.
User's & reference manual for C/GUI 2002-2007 Micrium
701
The function immediately replaces the visible sprite image on the screen. No further operation is required for showing the new image.
GUI_SPRITE_SetBitmapAndPosition()
Description
Sets the position and the image at once.
Prototype
int GUI_SPRITE_SetBitmapAndPosition(GUI_HSPRITE hSprite, const GUI_BITMAP GUI_UNI_PTR * pBM, int x, int y); Parameter hSprite pBM x y
Handle of sprite. Pointer to the new bitmap structure to be used to draw the sprite. New X-position in screen coordinates. New Y-position in screen coordinates.
Meaning
Add. information
It makes a difference on using the functions GUI_SPRITE_SetBitmap() and GUI_SPRITE_SetPosition() one after another or using this function. Whereas the image on the screen will be rendered twice on calling GUI_SPRITE_SetBitmap() and GUI_SPRITE_SetPosition() it is rendered only once on using this function, which can be used very well in animations.
GUI_SPRITE_SetPosition()
Description
Moves the sprite to the new position.
Prototype
void GUI_SPRITE_SetPosition(GUI_HSPRITE hSprite, int x, int y); Parameter hSprite x y
Handle of sprite. New X-position in screen coordinates. New Y-position in screen coordinates.
Meaning
Add. information
The function moves the given sprite to the new position.
GUI_SPRITE_Show()
Description
Shows the given sprite.
2002-2007 Micrium
702
CHAPTER 21
Sprites
Prototype
void GUI_SPRITE_Show(GUI_HSPRITE hSprite); Parameter hSprite
Handle of sprite.
Meaning
Add. information
The function adds the given sprite to the list of visible sprites.
2002-2007 Micrium
703
Chapter 22 Cursors
Window manager support includes a system-wide cursor which may be changed to other, predefined styles. Although the cursor always exists, it is hidden by default like a window. It will not be visible until a call is made to show it, and may be hidden again at any point.
2002-2007 Micrium
704
CHAPTER 22
Cursors
Cross cursors
GUI_CursorCrossS Small cross
Explanation
Returns if the cursor is visible or not.
2002-2007 Micrium
705
GUI_CURSOR_GetState()
Description
Returns if the cursor is currently visible or not.
Prototype
int GUI_CURSOR_GetState(void);
Return value
1 if the cursor is visible and 0 if not.
GUI_CURSOR_Hide()
Description
Hides the cursor.
Prototype
void GUI_CURSOR_Hide(void);
Additional information
This is the default cursor setting. If you want the cursor to be visible, you must call GUI_CURSOR_Show().
GUI_CURSOR_Select()
Description
Sets a specified cursor style.
Prototype
void GUI_CURSOR_Select(const GUI_CURSOR *pCursor); Parameter pCursor
Pointer to the cursor to be selected.
Meaning
Permitted values for parameter pCursor GUI_CursorArrowS GUI_CursorArrowM GUI_CursorArrowL GUI_CursorArrowSI GUI_CursorArrowMI GUI_CursorArrowLI GUI_CursorCrossS GUI_CursorCrossM GUI_CursorCrossL GUI_CursorCrossSI GUI_CursorCrossMI GUI_CursorCrossLI
Small arrow. Medium arrow. Large arrow. Small inverted arrow. Medium inverted arrow. Large inverted arrow. Small cross. Medium cross. Large cross. Small inverted cross. Medium inverted cross. Large inverted cross.
Additional information
If this function is not called, the default cursor is a medium arrow.
User's & reference manual for C/GUI 2002-2007 Micrium
706
CHAPTER 22
Cursors
GUI_CURSOR_SetPosition()
Description
Sets the cursor position.
Prototype
void GUI_CURSOR_SetPosition(int x, int y); Parameter x y
X-position of the cursor. Y-position of the cursor.
Meaning
Additional information
Normally this function is called internally by the window manager and does not need to be called from the application.
GUI_CURSOR_Show()
Description
Shows the cursor.
Prototype
void GUI_CURSOR_Show(void);
Additional information
The default setting for the cursor is hidden; therefore this function must be called if you want the cursor to be visible.
2002-2007 Micrium
707
Chapter 23 Antialiasing
Lines are approximated by a series of pixels that must lie at display coordinates. They can therefore appear jagged, particularly lines which are nearly horizontal or nearly vertical. This jaggedness is called aliasing. Antialiasing is the smoothing of lines and curves. It reduces the jagged, stair-step appearance of any line that is not exactly horizontal or vertical. C/GUI supports different antialiasing qualities, antialiased fonts and high-resolution coordinates. Support for antialiasing is a seperate software item and is not included in the C/GUI basic package. The software for antialiasing is located in the subdirectory GUI\AntiAlias.
2002-2007 Micrium
708
CHAPTER 23
Antialiasing
23.1 Introduction
Antialiasing smoothes curves and diagonal lines by "blending" the background color with that of the foreground. The higher the number of shades used between background and foreground colors, the better the antialiasing result (and the longer the computation time).
Quality of antialiasing
The quality of antialiasing is set by the routine GUI_AA_SetFactor, explained later in the chapter. For an idea of the relationship between the antialiasing factor and the corresponding result, take a look at the image pictured. The first line is drawn without antialiasing (factor 1). The second line is drawn antialiased using factor 2. This means that the number of shades from foreground to background is 2 x 2 = 4. The next line is drawn with an antialiasing factor of 3, so there are 3 x 3 = 9 shades, and so on. Factor 4 should be sufficient for most applications. Increasing the antialiasing factor further does not improve the result dramatically, but increases the calculation time.
2002-2007 Micrium
709
Antialiased Fonts
Two types of antialiased fonts, low-quality (2bpp) and high-quality (4bpp), are supported. The routines needed to display these fonts are automatically linked when using them. The following table shows the effect on drawing the character "C" without antialiasing and with both types of antialiased fonts: Font type Black on white White on black
Antialiased fonts can be created with the C/GUI font converter. The general purpose of using antialiased fonts is to improve the appearance of text. While the effect of using high-quality antialiasing will be more visually pleasing than low-quality, computation time and memory consumption will increase proportionally. Low-quality (2bpp) fonts require twice the memory of non-antialiased (1bpp) fonts; high-quality (4bpp) fonts require four times the memory.
High-resolution coordinates
When drawing items using antialiasing, the same coordinates are used as for regular (non-antialiasing) drawing routines. This is the default mode. You do not need to consider the antialiasing factor in the function arguments. For example, to draw an antialiased line from (50, 100) to (100, 50) you would write:
GUI_AA_DrawLine(50, 100, 100, 50);
The high-resolution feature of C/GUI lets you use the virtual space determined by the antialiasing factor and your display size. High-resolution coordinates must be enabled with the routine GUI_AA_EnableHiRes, and may be disabled with GUI_AA_DisableHiRes. Both functions are explained later in the chapter. The advanUser's & reference manual for C/GUI 2002-2007 Micrium
710
CHAPTER 23
Antialiasing
tage of using high-resolution coordinates is that items can be placed not only at physical positions of your display but also "between" them. The virtual space of a high-resolution pixel is illustrated below based on an antialiasing factor of 3:
High resolution pixel
Physical pixel
To draw a line from pixel (50, 100) to (100, 50) in high-resolution mode with antialiasing factor 3, you would write:
GUI_AA_DrawLine(150, 300, 300, 150);
For sample programs using the high-resolution feature, see the examples at the end of this chapter.
2002-2007 Micrium
711
Explanation
Drawing functions
Draw an antialiased arc. Draw an antialiased line. Draw the outline of an antialiased polygon. Draw the outline of an antialiased polygon. Draw an antialiased circle. Draw a filled and antialiased polygon.
Prototype
void GUI_AA_DisableHiRes(void);
Additional Information
High-resolution coordinates are disabled by default.
GUI_AA_EnableHiRes()
Description
Enables high-resolution coordinates.
Prototype
void GUI_AA_EnableHiRes(void);
GUI_AA_GetFactor()
Description
Returns the current antialiasing quality factor.
Prototype
int GUI_AA_GetFactor(void);
2002-2007 Micrium
712
CHAPTER 23
Antialiasing
Return value
The current antialiasing factor.
GUI_AA_SetFactor()
Description
Sets the antialiasing quality factor.
Prototype
void GUI_AA_SetFactor(int Factor); Parameter Factor Meaning
The new antialiasing factor. Minimum: 1 (will result in no antialiasing) Maximum: 6
Additional Information
Setting the parameter Factor to 1, though permitted, will effectively disable antialiasing and result in a standard font. We recommend an antialiasing quality factor of 2-4. The default factor is 3.
Prototype
void GUI_AA_DrawArc(int x0, int y0, int rx, int ry, int a0, int a1); Parameter x0 y0 rx ry a0 a1
Horizontal position of the center. Vertical position of the center. Horizontal radius. Vertical radius. Starting angle (degrees). Ending angle (degrees).
Meaning
Limitations
Currently the ry parameter is not available. The rx parameter is used instead.
Additional Information
If working in high-resolution mode, position and radius must be in high-resolution coordinates. Otherwise they must be specified in pixels.
2002-2007 Micrium
713
GUI_AA_DrawLine()
Description
Displays an antialiased line at a specified position in the current window, using the current pen size and the current pen shape.
Prototype
void GUI_AA_DrawLine(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
X-starting position. Y-starting position. X-end position. Y-end position.
Meaning
Additional Information
If working in high-resolution mode, the coordinates must be in high-resolution coordinates. Otherwise they must be specified in pixels.
GUI_AA_DrawPolyOutline()
Description
Displays the outline of an antialiased polygon defined by a list of points, at a specified position in the current window and with a specified thickness.
Prototype
void GUI_AA_DrawPolyOutline(const GUI_POINT* pPoint, int NumPoints, int Thickness, int x, int y) Parameter pPoint NumPoints Thickness x y
Pointer to the polygon to display. Number of points specified in the list of points. Thickness of the outline. X-position of origin. Y-position of origin .
Meaning
Additional Information
The polyline drawn is automatically closed by connecting the endpoint to the starting point. The starting point must not be specified a second time as an endpoint. If working in high-resolution mode, the coordinates must be in high-resolution coordinates. Otherwise they must be specified in pixels. Per default the number of points processed by this function is limited to 10. If the polygon consists of more than 10 points the function GUI_AA_DrawPolyOutlineEx() should be used.
2002-2007 Micrium
714
CHAPTER 23
Antialiasing
Example
#define countof(Array) (sizeof(Array) / sizeof(Array[0])) static GUI_POINT aPoints[] = { { 0, 0 }, { 15, 30 }, { 0, 20 }, {-15, 30 } }; void Sample(void) { GUI_AA_DrawPolyOutline(aPoints, countof(aPoints), 3, 150, 40); }
GUI_AA_DrawPolyOutlineEx()
Description
Displays the outline of an antialiased polygon defined by a list of points, at a specified position in the current window and with a specified thickness.
Prototype
void GUI_AA_DrawPolyOutlineEx(const GUI_POINT* pPoint, int NumPoints, int Thickness, int x, int y, GUI_POINT * pBuffer); Parameter pPoint NumPoints Thickness x y pBuffer
Pointer to the polygon to display. Number of points specified in the list of points. Thickness of the outline. X-position of origin. Y-position of origin. Pointer to a buffer of GUI_POINT elements.
Meaning
Additional information
The number of polygon points is not limited by this function. Internally the function needs a buffer of GUI_POINT elements for calculation purpose. The number of points of the buffer needs to be >= the number of points of the polygon. For more details please refer to GUI_AA_DrawPolyOutline().
2002-2007 Micrium
715
GUI_AA_FillCircle()
Description
Displays a filled, antialiased circle at a specified position in the current window.
Prototype
void GUI_AA_FillCircle(int x0, int y0, int r); Parameter x0 y0 r Meaning
X-position of the center of the circle in pixels of the client window. Y-position of the center of the circle in pixels of the client window. Radius of the circle (half of the diameter). Minimum: 0 (will result in a point). Maximum: 180.
Additional Information
If working in high-resolution mode, the coordinates must be in high-resolution coordinates. Otherwise they must be specified in pixels.
GUI_AA_FillPolygon()
Description
Fills an antialiased polygon defined by a list of points, at a specified position in the current window.
Prototype
void GUI_AA_FillPolygon(const GUI_POINT* pPoint, int NumPoints, int x, int y) Parameter pPoint NumPoints x y
Pointer to the polygon to display. Number of points specified in the list of points. X-position of origin. Y-position of origin.
Meaning
Additional Information
The polyline drawn is automatically closed by connecting the endpoint to the starting point. The starting point must not be specified a second time as an endpoint. If working in high-resolution mode, the coordinates must be in high-resolution coordinates. Otherwise they must be specified in pixels.
2002-2007 Micrium
716
CHAPTER 23
Antialiasing
23.5 Examples
Different antialiasing factors
The following example creates diagonal lines with and without antialiasing. The source code can be found under Sample\Misc\AntialiasedLines.c.
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : AntialiasedLines.c Purpose : Shows lines with different antialiasing qualities ---------------------------------------------------------------------*/ #include "GUI.H" /******************************************************************* * * Show lines with different antialiasing qualities * ******************************************************************** */ static void DemoAntialiasing(void) { int i, x1, x2; int y = 2; /* Set drawing attributes */ GUI_SetColor(GUI_BLACK); GUI_SetBkColor(GUI_WHITE); GUI_SetPenShape(GUI_PS_FLAT); GUI_Clear(); x1 = 10; x2 = 90; /* Draw lines without antialiasing */ GUI_DispStringHCenterAt("\nNormal", (x1 + x2) / 2, 10); for (i = 1; i < 12; i++) { GUI_SetPenSize(i); GUI_DrawLine(x1, 40 + i * 15, x2, 40 + i * 15 + y); } x1 = 110; x2 = 190; /* Draw lines with antialiasing quality faktor 2 */ GUI_AA_SetFactor(2); GUI_DispStringHCenterAt("Antialiased\n\nusing factor 2", (x1 + x2) / 2, 10); for (i = 1; i < 12; i++) { GUI_SetPenSize(i); GUI_AA_DrawLine(x1, 40 + i * 15, x2, 40 + i * 15 + y); } x1 = 210; x2 = 290; /* Draw lines with antialiasing quality faktor 6 */ GUI_AA_SetFactor(6); GUI_DispStringHCenterAt("Antialiased\n\nusing factor 6", (x1 + x2) / 2, 10); for (i = 1; i < 12; i++) { GUI_SetPenSize(i); GUI_AA_DrawLine(x1, 40 + i * 15, x2, 40 + i * 15 + y); } } /******************************************************************* * * main * ******************************************************************** */
2002-2007 Micrium
2002-2007 Micrium
718
CHAPTER 23 GUI_AA_SetFactor(Factor); /* Set quality factor */ /* Drawing lines using the virtual resolution */ for (i = 0; i < Factor; i++) { int x = (i + 1) * 5 * Factor + i - 1; GUI_AA_DrawLine(x, 50, x, 199); }
Antialiasing
719 * ******************************************************************** */ #define countof(Obj) (sizeof(Obj)/sizeof(Obj[0])) static const GUI_POINT aPointer[] = { { 0, 3}, { 85, 1}, { 90, 0}, { 85, -1}, { 0, -3} }; static GUI_POINT aPointerHiRes[countof(aPointer)]; typedef struct { GUI_AUTODEV_INFO AutoInfo; GUI_POINT aPoints[countof(aPointer)]; int Factor; } PARAM; /******************************************************************* * * Drawing routines * ******************************************************************** */ static void DrawHiRes(void * p) { PARAM * pParam = (PARAM *)p; if (pParam->AutoInfo.DrawFixed) { GUI_ClearRect(0, 0, 99, 99); } GUI_AA_FillPolygon(pParam->aPoints, countof(aPointer), 5 * pParam->Factor, 95 * pParam->Factor); } static void Draw(void * p) { PARAM * pParam = (PARAM *)p; if (pParam->AutoInfo.DrawFixed) { GUI_ClearRect(100, 0, 199, 99); } GUI_AA_FillPolygon(pParam->aPoints, countof(aPointer), 105, 95); } /******************************************************************* * * Demonstrate high resolution by drawing rotating pointers * ******************************************************************** */ static void ShowHiresAntialiasing(void) { int i; GUI_AUTODEV aAuto[2]; PARAM Param; Param.Factor = 3; GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 50, 120); GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 150, 120); /* Create GUI_AUTODEV objects */ for (i = 0; i < countof(aAuto); i++) { GUI_MEMDEV_CreateAuto(&aAuto[i]); } /* Calculate pointer for high resolution */ for (i = 0; i < countof(aPointer); i++) { aPointerHiRes[i].x = aPointer[i].x * Param.Factor; aPointerHiRes[i].y = aPointer[i].y * Param.Factor; } GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */ while(1) {
2002-2007 Micrium
720
CHAPTER 23
Antialiasing
for (i = 0; i < 1800; i++) { float Angle = (i >= 900) ? 1800 - i : i; Angle *= 3.1415926f / 1800; /* Draw pointer with high resolution */ GUI_AA_EnableHiRes(); GUI_RotatePolygon(Param.aPoints, aPointerHiRes, countof(aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, DrawHiRes, &Param); /* Draw pointer without high resolution */ GUI_AA_DisableHiRes(); GUI_RotatePolygon(Param.aPoints, aPointer, countof(aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, Draw, &Param); #ifdef WIN32 GUI_Delay(2); #endif }
2002-2007 Micrium
721
Text written in a foreign language like Arabic or Chinese contains characters, which are normally not part of the fonts shipped with C/GUI. This chapter explains the basics like the Unicode standard, which defines all available characters worldwide and the UTF-8 encoding scheme, which is used by C/GUI to decode text with Unicode characters. It also explains how to enable Arabic language support and how to render text with Shift-JIS (Japanese Industry Standard) encoding.
2002-2007 Micrium
722
CHAPTER 24
24.1 Unicode
The Unicode standard is a 16-bit character encoding scheme. All of the characters available worldwide are in a single 16-bit character set (which works globally). The Unicode standard is defined by the Unicode consortium. C/GUI can display individual characters or strings in Unicode, although it is most common to simply use mixed strings, which can have any number of Unicode sequences within one ASCII string.
Encoding example
The text "Halle" contains ASCII characters and European extensions. The following hexdump shows this text as UTF-8 encoded text:
48 61 6C C3 B6 6C 65
Programming examples
If we want to display a text containing non-ASCII characters, we can do this by manually computing the UTF-8 codes for the non-ASCII characters in the string. However, if your compiler supports UTF-8 encoding (Sometimes called multi-byte encoding), even non-ASCII characters can be used directly in strings.
// // Example using ASCII encoding: // GUI_UC_SetEncodeUTF8(); /* required only once to activate UTF-8*/ GUI_DispString("Hal\xc3\xb6le"); // // Example using UTF-8 encoding: // GUI_UC_SetEncodeUTF8(); /* required only once to activate UTF-8*/ GUI_DispString("Halle");
2002-2007 Micrium
723
Choose "File/Save As...". The file dialog should contain a combo box to set the encoding format. Choose "UTF-8" and save the text file.
2002-2007 Micrium
CHAPTER 24
void MainTask(void) { int i; GUI_Init(); GUI_SetFont(&GUI_Font16_1HK); GUI_UC_SetEncodeUTF8(); for (i = 0; i < GUI_COUNTOF(_apStrings); i++) { GUI_DispString(_apStrings[i]); GUI_DispNextLine(); } while(1) { GUI_Delay(500); } }
Explanation
Prototype
int GUI_UC_ConvertUC2UTF8(const U16 GUI_UNI_PTR * s, int Len, char * pBuffer, int BufferSize); Parameter s Len pBuffer BufferSize Meaning
Pointer to Unicode string to be converted. Number of Unicode characters to be converted. Pointer to a buffer to write in the result. Buffer size in bytes.
Return value
The function returns the number of bytes written to the buffer.
2002-2007 Micrium
725
Additional Information
UTF-8 encoded characters can use up to 3 bytes. To be on the save side the reccomended buffer size is: Number of Unicode characters * 3. If the buffer is not big enough for the whole result, the function returns when the buffer is full.
GUI_UC_ConvertUTF82UC()
Description
Converts the given UTF-8 string into Unicode format.
Prototype
int GUI_UC_ConvertUTF82UC(const char GUI_UNI_PTR * s, int Len, U16 * pBuffer, int BufferSize); Parameter s Len pBuffer BufferSize Meaning
Pointer to UFT-8 string to be converted. Number of UTF-8 characters to be converted. Pointer to a buffer to write in the result. Buffer size in words.
Return value
The function returns the number of Unicode characters written to the buffer.
Additional Information
If the buffer is not big enough for the whole result, the function returns when the buffer is full.
GUI_UC_Encode()
Description
This function encodes a given character with the current encoding settings.
Prototype
int GUI_UC_Encode(char* s, U16 Char); Parameter s Char
Character to be encoded.
Meaning
Pointer to a buffer to store the encoded character.
Return value
The number of bytes stored to the buffer.
Additional Information
The function assumes that the buffer has at least 3 bytes for the result.
GUI_UC_GetCharCode()
Description
This function decodes a character from a given text.
2002-2007 Micrium
726
CHAPTER 24
Prototype
U16 GUI_UC_GetCharCode(const char* s); Parameter s
Pointer to the text to be encoded.
Meaning
Return value
The encoded character.
Related topics
GUI_UC_GetCharSize()
GUI_UC_GetCharSize()
Description
This function returns the number of bytes used to encode the given character.
Prototype
int GUI_UC_GetCharSize(const char* s); Parameter s
Pointer to the text to be encoded.
Meaning
Return value
Number of bytes used to encode the given character
Additional information
This function is used to determine how much bytes a pointer has to be incremented to point to the next character. The following example shows how to use the function:
static void _Display2Characters(const char * pText) { int Size; U16 Character; Size = GUI_UC_GetCharSize(pText); /* Size to increment pointer */ Character = GUI_UC_GetCharCode(pText); /* Get first character code */ GUI_DispChar(Character); /* Display first character */ pText += Size; /* Increment pointer */ Character = GUI_UC_GetCharCode(pText); /* Get next character code */ GUI_DispChar(Character); /* Display second character */ }
GUI_UC_SetEncodeNone()
Description
Disables character encoding.
Prototype
void GUI_UC_SetEncodeNone(void);
Additional information
After calling this function each byte of a text will be handled as one character. This is the default behviour of C/GUI.
2002-2007 Micrium
727
GUI_UC_SetEncodeUTF8()
Description
Enables UTF-8 encoding.
Prototype
void GUI_UC_SetEncodeUTF8(void);
Additional information
After calling GUI_UC_SetEncodeUTF8 each string related routine of C/GUI encodes a given sting in accordance to the UTF-8 transformation.
Prototype
void GUI_UC_DispString(const U16 GUI_FAR *s); Parameter s
Pointer to double byte string.
Meaning
Additional Information
If you need to display double byte strings you should use this function. Each character has to be defined by a 16 bit value.
2002-2007 Micrium
728
CHAPTER 24
The basic difference between western languages and Arabic is, that Arabic is written from the right to the left and that it does not know uppercase and lowercase characters. Further the character codes of the text are not identical with the character index in the font file used to render the character, because the notation forms of the characters depend on the positions in the text.
But not each character is allowed to be joined to the left and to the right (doublejoined). The character Hamza for example always needs to be separated and Alef is only allowed at the end or separated. Character combinations of the letters Lam and Alef should be transformed to a Ligature. This means one character substitionally for the combination of Lam and Alef. The above explanation shows, that the notation form is normally not identically with the character code of the text. The following table shows how C/GUI transforms the characters to the notation form in dependence of the text position: Base 0x0621 0x0622 0x0623 0x0624 0x0625 0x0626 0x0627 0x0628 0x0629 0x062A 0x062B Isolated 0xFE80 0xFE81 0xFE83 0xFE85 0xFE87 0xFE89 0xFE8D 0xFE8F 0xFE93 0xFE95 0xFE99 Final 0xFE82 0xFE84 0xFE86 0xFE88 0xFE8A 0xFE8E 0xFE90 0xFE94 0xFE96 0xFE9A Initial 0xFE8B 0xFE91 0xFE97 0xFE9B Medial 0xFE8C 0xFE92 0xFE98 0xFE9C Character Hamza Alef with Madda above Alef with Hamza above Waw with Hamza above Alef with Hamza below Yeh with Hamza above Alef Beh Teh Marbuta Teh Theh
2002-2007 Micrium
729
Base 0x062C 0x062D 0x062E 0x062F 0x0630 0x0631 0x0632 0x0633 0x0634 0x0635 0x0636 0x0637 0x0638 0x0639 0x063A 0x0641 0x0642 0x0643 0x0644 0x0645 0x0646 0x0647 0x0648 0x0649 0x064A 0x067E 0x0686 0x0698 0x06A9 0x06AF 0x06CC
Isolated 0xFE9D 0xFEA1 0xFEA5 0xFEA9 0xFEAB 0xFEAD 0xFEAF 0xFEB1 0xFEB5 0xFEB9 0xFEBD 0xFEC1 0xFEC5 0xFEC9 0xFECD 0xFED1 0xFED5 0xFED9 0xFEDD 0xFEE1 0xFEE5 0xFEE9 0xFEED 0xFEEF 0xFEF1 0xFB56 0xFB7A 0xFB8A 0xFB8E 0xFB92 0xFBFC
Final 0xFE9E 0xFEA2 0xFEA6 0xFEAA 0xFEAC 0xFEAE 0xFEB0 0xFEB2 0xFEB6 0xFEBA 0xFEBE 0xFEC2 0xFEC6 0xFECA 0xFECE 0xFED2 0xFED6 0xFEDA 0xFEDE 0xFEE2 0xFEE6 0xFEEA 0xFEEE 0xFEF0 0xFEF2 0xFB57 0xFB7B 0xFB8B 0xFB8F 0xFB93 0xFBFD
Initial 0xFE9F 0xFEA3 0xFEA7 0xFEB3 0xFEB7 0xFEBB 0xFEBF 0xFEC3 0xFEC7 0xFECB 0xFECF 0xFED3 0xFED7 0xFEDB 0xFEDF 0xFEE3 0xFEE7 0xFEEB 0xFEF3 0xFB58 0xFB7C 0xFB90 0xFB94 -
Medial 0xFEA0 0xFEA4 0xFEA8 0xFEB4 0xFEB8 0xFEBC 0xFEC0 0xFEC4 0xFEC8 0xFECC 0xFED0 0xFED4 0xFED8 0xFEDC 0xFEE0 0xFEE4 0xFEE8 0xFEEC 0xFEF4 0xFB59 0xFB7D 0xFB91 0xFB95 -
Character Jeem Hah Khah Dal Thal Reh Zain Seen Sheen Sad Dad Tah Zah Ain Ghain Feh Qaf Kaf Lam Meem Noon Heh Waw Alef Maksura Yeh Peh Tcheh Jeh Keheh Gaf Farsi Yeh
24.2.2 Ligatures
Character combinations of Lam and Alef needs to be transformed to ligatures. The following table shows how C/GUI transforms these combinations into ligatures, if the first letter is a Lam (code 0x0644):
Second letter 0x622, 0x623, 0x625, 0x627, Alef with Madda above Alef with Hamza above Alef with Hamza below Alef
2002-2007 Micrium
730
CHAPTER 24
24.2.4 Requirements
Arabic language support is part of the basic package. Please note, that the standard fonts of C/GUI does not contain font files with Arabic characters. To create a Arabic font file the font converter is required
Memory
The bidirectional text alignment and Arabic character transformation uses app. 60 KB of ROM and app. 800 bytes of additional stack.
If enabled, C/GUI automatically writes Arabic text from the right to the left and transforms the characters as described above and carrys on writing non Arabic text from the left to the right.
24.2.6 Sample
The sample folder contains the sample FONT_Arabic, which shows how to draw Arabic text. It contains a C/GUI font with Arabic characters and some small Arabic text samples.
2002-2007 Micrium
731
2002-2007 Micrium
732
CHAPTER 24
The Thai alphabet uses 44 consonants and 15 basic vowel characters. These are horizontally placed, left to right, with no intervening space, to form syllables, words, and sentences. Vowels are written above, below, before, or after the consonant they modify, although the consonant always sounds first when the syllable is spoken. The vowel characters (and a few consonants) can be combined in various ways to produce numerous compound vowels (dipthongs and tripthongs).
24.3.1 Requirements
As explained above the Thai language makes an extensive usage of compound characters. To be able to draw compound characters in C/GUI, a new font type is needed, which contains all reqiured character information like the image size, image position and cursor incrementation value. From version 4.00, C/GUI supports a new font type with this information. This also means that older font types can not be used to draw Thai text. Please note, that the standard fonts of C/GUI does not contain font files with Thai characters. To create a Thai font file the font converter of version 3.04 or newer is required.
Memory
The Thai language support needs no additional ROM or RAM.
24.3.3 Sample
The sample folder contains the sample FONT_ThaiText.c, which shows how to draw Thai text. It contains a C/GUI font with Thai characters and some small Thai text samples.
2002-2007 Micrium
733
24.4.2 Example
The following example defines a small font containing 6 characters: "A", "B", "C" and the Shift JIS characters 0x8350 (KATAKANA LETTER KE), 0x8351 (KATAKANA LETTER GE) and 0x8352 (KATAKANA LETTER KO). A mixed string is then drawn onto the display. The example is available as FONT_ShiftJIS.c.
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * C/GUI sample code * * * ********************************************************************** ---------------------------------------------------------------------File : ShiftJIS.c Purpose : Example demonstrating ShiftJIS capabilities of C/GUI ---------------------------------------------------------------------*/ #include "gui.h" /******************************************************************* * * Definition of ShiftJIS font * ******************************************************************** */ /* LATIN CAPITAL LETTER A */ static const unsigned char acFontSJIS13_0041[ 13] = { /* code 0041 */ ________, ________, ___X____, ___X____, __X_X___, __X_X___, __X_X___, _XXXXX__, _X___X__, _X___X__, XXX_XXX_, ________, ________}; User's & reference manual for C/GUI 2002-2007 Micrium
734
CHAPTER 24
/* LATIN CAPITAL LETTER B */ static const unsigned char acFontSJIS13_0042[ 13] = { /* code 0042 */ ________, ________, XXXXX___, _X___X__, _X___X__, _X___X__, _XXXX___, _X___X__, _X___X__, _X___X__, XXXXX___, ________, ________}; /* LATIN CAPITAL LETTER C */ static const unsigned char acFontSJIS13_0043[ 13] = { /* code 0043 */ ________, ________, __XX_X__, _X__XX__, X____X__, X_______, X_______, X_______, X_______, _X___X__, __XXX___, ________, ________}; /* KATAKANA LETTER KE */ static const unsigned char acFontSJIS13_8350[ 26] = { /* code 8350 */ __XX____,________, ___X____,________, ___X____,________, ___XXXXX,XXXX____, __X____X,________, _X_____X,________, X______X,________, ______X_,________, ______X_,________, _____X__,________, ____X___,________, __XX____,________, ________,________}; /* KATAKANA LETTER GE */ static const unsigned char acFontSJIS13_8351[ 26] = { /* code 8351 */ __XX____,X_X_____, ___X____,_X_X____, ___X____,________, __XXXXXX,XXX_____, __X____X,________, _X_____X,________, X______X,________, ______X_,________, ______X_,________, _____X__,________, ____X___,________, __XX____,________, ________,________}; /* KATAKANA LETTER KO */ static const unsigned char acFontSJIS13_8352[ 26] = { /* code 8352 */ ________,________, ________,________, __XXXXXX,XX______, ________,_X______, ________,_X______, ________,_X______,
2002-2007 Micrium
735 ________,_X______, ________,_X______, ________,_X______, _XXXXXXX,XXXX____, ________,________, ________,________, ________,________}; static const GUI_CHARINFO GUI_FontSJIS13_CharInfo[6] = { { 7, 7, 1, (void *)&acFontSJIS13_0041 } /* code 0041 ,{ 7, 7, 1, (void *)&acFontSJIS13_0042 } /* code 0042 ,{ 7, 7, 1, (void *)&acFontSJIS13_0043 } /* code 0043 ,{ 14, 14, 2, (void *)&acFontSJIS13_8350 } /* code 8350 ,{ 14, 14, 2, (void *)&acFontSJIS13_8351 } /* code 8351 ,{ 14, 14, 2, (void *)&acFontSJIS13_8352 } /* code 8352 }; */ */ */ */ */ */
static const GUI_FONT_PROP GUI_FontSJIS13_Prop2 = { 0x8350 /* first character */ ,0x8352 /* last character */ ,&GUI_FontSJIS13_CharInfo[ 3] /* address of first character */ ,(void*)0 /* pointer to next GUI_FONT_PROP */ }; static const GUI_FONT_PROP GUI_FontSJIS13_Prop1 = { 0x0041 /* first character */ ,0x0043 /* last character */ ,&GUI_FontSJIS13_CharInfo[ 0] /* address of first character */ ,(void *)&GUI_FontSJIS13_Prop2 /* pointer to next GUI_FONT_PROP */ }; static const GUI_FONT GUI_FontSJIS13 = { GUI_FONTTYPE_PROP_SJIS /* type of font ,13 /* height of font */ ,13 /* space of font y */ ,1 /* magnification x */ ,1 /* magnification y */ ,(void *)&GUI_FontSJIS13_Prop1 }; */
/******************************************************************* * * Definition of string containing ASCII and ShiftJIS characters * ******************************************************************** */ static const char aSJIS[] = { "ABC\x83\x50\x83\x51\x83\x52\x0" }; /******************************************************************* * * Demonstrates output of ShiftJIS characters * ******************************************************************** */ void DemoShiftJIS(void) { GUI_SetFont(&GUI_Font13HB_1); GUI_DispStringHCenterAt("C/GUI-sample: ShiftJIS characters", 160, 0); /* Set ShiftJIS font */ GUI_SetFont(&GUI_FontSJIS13); /* Display string */ GUI_DispStringHCenterAt(aSJIS, 160, 40); } /******************************************************************* * * main * ******************************************************************** */
2002-2007 Micrium
736
CHAPTER 24
2002-2007 Micrium
737
A display driver supports a particular family of display controllers (typically LCD controllers) and all displays which are connected to one or more of these controllers. The driver is essentially generic, meaning it can be configured by modifying the configuration file LCDConf.h. The driver itself does not need to be modified. This file contains all configurable options for the driver including how the hardware is accessed and how the controller(s) are connected to the display. This chapter provides an overview of the display drivers available for C/GUI. It explains the following in terms of each driver: Which LCD controllers can be accessed, as well as supported color depths and types of interfaces. Additional RAM requirements. Additional functions. How to access the hardware. Special configuration switches. Special requirements for particular LCD controllers.
2002-2007 Micrium
738
CHAPTER 25
Display drivers
Display Controller
Passive color display connected to an display controller with linear memory operating in monochrome mode. Example: Cirrus Logic EP7312 Fujitsu MB87J2020 (Jasmine) Fujitsu MB87J2120 (Lavender)
Supported bits/pixel
12
LCDColorOnMono
LCDFujitsu
1, 2, 4, 8, 16
LCDLin
1301 1304 1352 1353 1354 1356 1374 1375 1376 1386 3200
32168
LCDMem
Any display controller with linear video memory in 1, 2, 4, 8 and 16 bits/pixel mode, built- in LCD controllers such as Sharp 79531. Epson S1D13700 (direct interface) Solomon SSD1905 Fujitsu MB86276 (Lime) Fujitsu MB86290A (Cremson) Fujitsu MB86291 (Scarlet) Fujitsu MB86292 (Orchid) Fujitsu MB86293 (Coral Q) Fujitsu MB86294 (Coral B) Fujitsu MB86295 (Coral P) Toshiba Capricorn 2 Epson S1D13A03, S1D13A04, S1D13A05 1, 2, 4, 8, 16, Epson SED1352, S1D13502 24, 32 Epson SED1353, S1D13503 Epson SED1354, S1D13504 Epson SED1356, S1D13506 Epson SED1374, S1D13704 Epson SED1375, S1D13705 Epson SED1376, S1D13706 Epson SED1386, S1D13806 Any display controller with linear video memory (ARM or MIPS CPUs such as Sharp LH754xx, LH79520, Motorola Dragonball or NEC VR4181A) which should be accessed only in 32 bit mode. Any display controller with linear video memory which should be accessed in 8, 16 or 32 bit mode in dependence of the required operation. No controller, writes into main memory Requires ISR or special hardware to refresh 1, 2 LCD (monochrome displays) No controller, writes into main memory Requires ISR or special hardware to refresh LCD (color displays) Noritake display GU256X128C-3900 3, 6 1
LCDMemC LCDNoritake
0 9000
2002-2007 Micrium
739
Driver
Display Controller
Samsung KS0713, Samsung S6B0713 Samsung KS0724, Samsung S6B0724 UltraChip UC1601, UC1606 Samsung KS0108B, Samsung S6B0108B Hitachi HD61202 Philips PCF8810, PCF8811 Philips PCF8535 New Japan Radio Company NJU6679 Philips PCD8544 Epson S1D15710 Solomon SSD1303 OLED controller Samsung S6B0719 Sitronix ST7522 Solomon SSD1805 UltraChip UC1608 Epson S1D15721 Epson S1D15E05, S1D15E06 Epson SED1520 Epson SED1560 Epson SED1565, S1D10605 Novatek NT7502 Samsung S6B1713 Solomon SSD1815 Sitronix ST7565 Sunplus SPLC501C Epson SED1566 Epson SED1567 Epson SED1568 Epson SED1569 Epson SED1575, S1D15705 Sitronix ST7528 Epson SED1330 Epson SED1335 Epson S1D13700 (indirect interface) RAIO 8835 RAIO 8822/8803 Toshiba T6963 Any VESA compatible hardware FPGA based display controller from Xylon Solomon SSD0323 OLED controller Solomon SSD1854 STMicroelectronics STE2010 Samsung KS0711, Samsung S6B0711 Samsung KS0741, Samsung S6B0741 Sitronix ST7541 Toppoly C0C0 Toppoly C0E0 Epson S1D13700 Ultrachip UC1617 Solomon SSD1848 Epson S1D13701 OLED controller Epson SED159A Sitronix ST7632 Epson S1D15E05, S1D15E06 Epson S1D15719 UltraChip UC1611 UltraChip UC1610 NEC PD161620 Solomon SSD1781 Solomon SSD1783
Supported bits/pixel
LCDPage1bpp
LCDPage4bpp
LCDSLin
8, 16 8, 16, 32 4
LCD07X1
16 2 9, 12 8 2 2 4 2 12 16
2002-2007 Micrium
740
CHAPTER 25
Display drivers
Driver
LCD501 LCD6331 LCD6642X
Display Controller
Leadis LDS501 Samsung S6B33B0X, Samsung S6B33B1X, Samsung S6B33B2X Hitachi HD66420 Hitachi HD66421 Sharp LR38825 Renesas R63401 Renesas R61509 Solomon SSD1289 Toshiba JBT6K71 Sharp LCY-A06003 Samsung S6D0129 MagnaChip D54E4PA7551 Himax HX8312 Hitachi HD66766 Samsung S6D0110A Ilitec ILI9161 Hitachi HD66772 Samsung S6D0117 Sitronix ST7712 Himax HX8301 Ilitec ILI9220 Hitachi HD66789 Hitachi HD66750 Hitachi HD66753 Sitronix ST7529 Sitronix ST7920 Raio RA8822
Supported bits/pixel
8 16 2
LCD667XX
16
2 1, 4, 5 1 2
The basic package contains 2 drivers which dont support a specific LCD controller. They can be used as template for a new driver or for measurement purpose: Driver Value for macro LCD_CONTROLLER
-1
LCD Controller
Driver template. Can be used as a starting point for writing a new driver. Part of the basic package Empty driver. (Performs no output) Can be used for measurement purpose. Part of the basic package.
Supported bits/pixel
-
LCDTemplate
LCDNull
-2
Selecting a driver
As described in Chapter 28: "Low-Level Configuration", the macro LCD_CONTROLLER defines the LCD controller used. A controller is specified by its appropriate value, listed in the table above. The following sections discuss each of the available drivers individually.
2002-2007 Micrium
741
Typical block diagram for LCD controllers with full bus interface
Explanation
Reads the video memory of the LCD controller. Writes data to the video memory of the LCD controller. Reads the register of the LCD controller. Writes data to a specified register of the LCD controller.
2002-2007 Micrium
742
CHAPTER 25
Display drivers
Typical block diagram for LCD controllers with simple bus interface
8 (16) data bits, one address bit and 2 or 3 control lines are used to connect the CPU and one LCD controller. Four macros inform the LCD driver how to access each controller used. If the LCD controller(s) is connected directly to the address bus of the CPU, configuration is simple and usually consists of no more than one line per macro. If the LCD controller(s) is connected to I/O pins, the bus interface must be simulated, which takes about 5-10 lines of program per macro (or a function call to a routine which simulates the bus interface). The signal A0 is also called C/D (Command/ Data), D/I (Data/Instruction) or RS (Register select), depending on the display controller.
Explanation
Reads a byte from LCD controller with A0 - line low. Reads a byte from LCD controller with A0 - line high. Writes a byte to LCD controller with A0 - line low. Writes a byte to LCD controller with A0 - line high. Writes several bytes to the LCD controller with A0 - line high.
2002-2007 Micrium
743
Typical block diagram for LCD controllers with 4 pin SPI interface
Explanation
Writes a byte to LCD controller with A0 (C/D) - line low. Writes a byte to LCD controller with A0 (C/D) - line high. Writes several bytes to the LCD controller with A0 (C/D) - line high.
Explanation
Writes a byte to LCD controller. Writes several bytes to the LCD controller.
2002-2007 Micrium
744
CHAPTER 25
Display drivers
Explanation
Reads a status byte from LCD controller. Reads a data byte from LCD controller. Writes a instruction byte to LCD controller. Writes a data byte to LCD controller. Writes several data bytes to the LCD controller.
2002-2007 Micrium
745
Supported hardware
Controllers
#
444
LCD controller
Any Passive color display connected to an LCD controller with linear memory operating in monochrome mode. -
Add. info
Interfaces
The driver supports a 16 bit full bus interface from the CPU to the LCD controller.
G G G G
This driver supports a 12 bpp memory area for color displays. The pictures above show the dependence between the memory area handled by the driver and the SEG and COM lines of the LCD.
User's & reference manual for C/GUI 2002-2007 Micrium
746
CHAPTER 25
Display drivers
Hardware configuration
This driver requires a full bus interface for hardware access as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_MEM LCD_WRITE_MEM Explanation
Initialization sequence for the LCD controller. Read the contents of video memory of controller. Write to video memory (display data RAM) of controller.
Example:
A QVGA color display needs the following defines in LCDConf.h:
#define LCD_XSIZE 320 #define LCD_YSIZE 240
The LCD controller needs to be initialized to control a monochrome display of 960x240 resolution.
Special requirements
The driver needs to work in one of the following fixed palette modes: 44412 (default if working in 12bpp mode) 444121 44416 The driver does not work with other palettes.
2002-2007 Micrium
747
Supported hardware
Controllers
#
8720 8721 Jasmin Lavender
LCD controller
Add. info
Fully optimized, LUT is initialized Fully optimized, LUT is initialized
Interfaces
The driver has been tested with a 32 bit interface to the CPU. If a 16 bit interface is used, the 32-bit accesses can be replaced by 2 16-bit accesses.
Hardware configuration
This driver requires a full bus interface for hardware access as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_REG LCD_WRITE_REG Explanation
Initialization sequence for the LCD controller. Read a register of the display controller. (as 32 bit value) (optional) Write a register of the display controller. (as 32 bit value) (optional)
The driver contains a default for hardware access macros, which configures 32 bit access on the Fujistu demonstration platform (Using an MB91361 or MB91362 and a Jasmine chip at address 0x30000000); if the target hardware is compatible with these settings, then LCD_READ_REG(), LCD_WRITE_REG() do not need to be defined.
748
CHAPTER 25
Display drivers
Hardware initialization
The display controller requires a complicated initialization. Example code is available from Fujistu in the GDC module. This code is not part of the driver, since it depends on the actual chip used, on the clock settings, the display and a lot of other things. We recommend using the original Fujitsu code, since the documentation of the chips is not sufficient to write this code. Before calling GUI_Init(), the GDC should be initialized using this code (typically called as GDC_Init(0xff)).
Example:
LCDConf.h for VGA display, 8bpp, Jasmin
#define #define #define #define LCD_XSIZE 640 LCD_YSIZE 480 LCD_BITSPERPIXEL 8 LCD_CONTROLLER 8720 /* X-resolution of LCD, Logical coor. */ /* Y-resolution of LCD, Logical coor. */ /* Jasmine */
Special requirements
None
2002-2007 Micrium
749
Supported hardware
Controllers
The following table list the supported controllers and their assigned numbers for LCD_CONTROLLER, as well as the level of support: # LCD controller
Any LCD controller wirth linear memory and full bus interface, such as: Epson SED1352, S1D13502 Epson SED1353, S1D13503 Epson S1D13700 (direct interface) Solomon SSD1905 Fujitsu MB86290A (Cremson) Fujitsu MB86291 (Scarlet) Fujitsu MB86292 (Orchid) Fujitsu MB86293 (Coral Q) Fujitsu MB86294 (Coral B) Fujitsu MB86295 (Coral P) Microcontrollers with built-in LCD controllers such as Sharp LH79531 1301 1304 1354 1356 1374 1375 1376 1386 Toshiba Capricorn 2 Epson S1D13A03, S1D13A04, S1D13A05 Epson SED1354, S1D13504 Epson SED1356, S1D13506 Epson SED1374, S1D13704 Epson SED1375, S1D13705 Epson SED1376, S1D13706 Epson SED1386, S1D13806 LUT is handled by driver if required All layers can be supported LUT is handled by driver if required 2 D Engine supported (BitBLT) LUT is handled by driver if required LUT is handled by driver if required. 2 D Engine supported (BitBLT) LUT is handled by driver if required LUT is handled by driver if required LUT is handled by driver if required LUT is handled by driver if required 2 D Engine supported (BitBLT)
Add. info
1300
The LUT (color look up table) is not handled by the driver. If a LUT mode is used (typically 16 or 256 colors), the application program is responsible for initialization of the LUT.
Interfaces
The chips supported by this driver can be interfaced in 8/16-bit parallel (full bus) modes. The driver supports both interfaces. Please refer to the respective LCD controller manual in order to determine if your chip can be interfaced in 8-bit mode.
User's & reference manual for C/GUI 2002-2007 Micrium
750
CHAPTER 25
Display drivers
Byte order
8 bit databus 16 bit databus not swapped 16 bit databus swapped . . . Byte H-Byte L-Byte L-Byte H-Byte
Display mode
COM n
1 bit / pixel
S E G 0
S E G 1
S E G 2
. . .
2 bit / pixel
SEG 0
SEG 1
...
SEG 0 SEG 0
SEG 1
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD in terms of the color depth.
751
Hardware configuration
This driver requires a full bus interface for hardware access as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_MEM LCD_READ_REG LCD_WRITE_MEM LCD_WRITE_REG Explanation
Initialization sequence for the LCD controller. Read the contents of video memory of controller. Read the contents of a configuration register of controller. Write to video memory (display data RAM) of controller. Write to a configuration register of controller.
LCD_ENABLE_MEM_ACCESS S1D13806 LCD controllers. LCD_ENABLE_REG_ACCESS S1D13806 LCD controllers. LCD_FILL_RECT LCD_ON LCD_OFF LCD_SET_LUT_ENTRY LCD_SWAP_BYTE_ORDER LCD_USE_BITBLT
Function replacement macro which defines a function to be called by the driver for filling rectangles. For details please refer to LCDLin-driver (32 bit access). Function replacement macro which switches the LCD on Function replacement macro which switches the LCD off Function replacement macro used to set a single lookup table or palette RAM entry. Inverts the endian mode (swaps the high and low bytes) between CPU and LCD controller when using a 16-bit bus interface. If set to 0, it disables the BitBLT engine. If set to 1 (the default value), the driver will use all available hardware acceleration.
LCD_INIT_CONTROLLER
When writing or modifying the initialization macro, consider the following: To initialize the embedded SDRAM, bit 7 of register 20 (SDRAM initialization bit)
User's & reference manual for C/GUI 2002-2007 Micrium
752
CHAPTER 25
Display drivers
must be set to 1 (a minimum of 200 s after reset). When the SDRAM initialization bit is set, the actual initialization sequence occurs at the first SDRAM refresh cycle. The initialization sequence requires approximately 16 MCLKs to complete, and memory accesses cannot be made while the initialization is in progress. For more information, please see the LCD controller documentation.
LCD_READ_REG, LCD_WRITE_REG
In order for the BitBLT engine to work, the data type of the offset must be unsigned long. This is set with the configuration macros LCD_READ_REG and LCD_WRITE_REG as follows:
#define LCD_READ_REG(Off) *((volatile U16*)(0x800000+(((U32)(Off))<<1))) #define LCD_WRITE_REG(Off,Data) *((volatile U16*)(0x800000+(((U32)(Off))<<1)))=Data
2002-2007 Micrium
753
Supported hardware
Controllers
The following table list the supported controllers and their assigned numbers for LCD_CONTROLLER, as well as the level of support: #
3200
LCD controller
Any display controller with linear video memory in 4, 8 or 16 bits/pixel mode such as the build in display controller of Sharp LH754XX, ARM or MIPS CPUs.
Add. info
The LUT (color look up table or palette RAM) is not handled by the driver. If a LUT mode is used, the application program is responsible for initialization of the LUT. LUT support can be added by using the macro LCD_SET_LUT_ENTRY.
Interfaces
The driver supports any 32 bit full bus interface.
2002-2007 Micrium
754
CHAPTER 25
Display drivers
Big endian
P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 P30 P31 P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15
1 bit / pixel 2 bit / pixel 4 bit / pixel 8 bit / pixel 16 bit / pixel 24 bit / pixel 32 bit / pixel
P0
P1
P2
P3
P4
P5
P6
P7
Pixel 0 Pixel 0
Pixel 1
Pixel 2 Pixel 1
Pixel 3
Pixel 0 Pixel 0
Pixel 1
B I T 3 1
B I T 3 0
B I T 2 9
B I T 2 8
B I T 2 7
B I T 2 6
B I T 2 5
B I T 2 4
B I T 2 3
B I T 2 2
B I T 2 1
B I T 2 0
B I T 1 9
B I T 1 8
B I T 1 7
B I T 1 6
B I T 1 5
B I T 1 4
B I T 1 3
B I T 1 2
B I T 1 1
B I T 1 0
B I T 0 9
B I T 0 8
B I T 0 7
B I T 0 6
B I T 0 5
B I T 0 4
B I T 0 3
B I T 0 2
B I T 0 1
B I T 0 0
Little endian
1 bit / pixel 2 bit / pixel 4 bit / pixel 8 bit / pixel 16 bit / pixel 24 bit / pixel 32 bit / pixel Pixel 1 Pixel 0
P0 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29 P30 P31 P15 P14 P13 P12 P11 P10 P9 P8 P7 P6 P5 P4 P3 P2 P1 P0
P7
P6
P5
P4
P3
P2
P1
P0
Pixel 3 Pixel 1
Pixel 2
Pixel 0
The picture above shows the relation between the display memory and the pixels of the LCD in terms of the color depth and the endian mode.
2002-2007 Micrium
755
Hardware configuration
This driver requires a full bus interface for hardware access as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_ENDIAN_BIG LCD_INIT_CONTROLLER LCD_VRAM_ADR Explanation
Should be set to 1 for big endian mode, 0 for little endian mode. Initialization sequence for the LCD controller. Defines the start address of the video memory.
LCD_FILL_RECT()
Description
This macro can be used for defining a function which should be called by the display driver for filling rectangles.
Type
Function replacement.
Prototype
#define LCD_FILL_RECT(x0, y0, x1, y1, Index) Parameter x0 y0 Meaning
Leftmost X-position of the rectangle to be filled. Topmost Y-position of the rectangle to be filled.
2002-2007 Micrium
756
CHAPTER 25
Display drivers
Parameter x1 y1 Index
Meaning
Rightmost X-position of the rectangle to be filled. Bottommost Y-position of the rectangle to be filled. Color index to be used for filling.
Add. information
If this macro is defined, the driver calls the function defined by this macro instead of using its own filling routine. Using this macro can make sense if for example a BitBLT engine should be used for filling instead of the driver internal filling function. Index values are in the range of 0 - ((1 << LCD_BITS_PER_PIXEL) - 1).
Example
void CustomFillRect(int x0, int y0, int x1, int y1, int Index); #define LCD_FILL_RECT(x0, y0, x1, y1, Index) CustomFillRect(x0, y0, x1, y1, Index)
LCD_LIN_SWAP()
Description
This macro enables swapping of pixels within one byte.
Type
Numeric.
Prototype
#define LCD_LIN_SWAP
Add. information
Sometimes a display driver like the embedded display driver of the Motorola MX1 has a different pixel assignment as the default assignment shown under Display data RAM organization. In this case the macro LCD_LIN_SWAP can be used to swap the pixels within one byte after reading from and before writing to the video RAM. If the value of the macro is > 0, pixel swapping is activated. The value of LCD_LIN_SWAP defines the swapping mode. The following table shows the supported swapping modes in dependence of the defined value: Value
1
Default
P7 P6 P5 P4 P3 P2 P1 P0 P0 P1
After swapping
P2 P3 P4 P5 P6 P7
P3
P2
P1
P0
P0
P1
P2
P3
P1
P0
P0
P1
Example
#define LCD_LIN_SWAP 1
LCD_READ_MEM(), LCD_WRITE_MEM()
The default definitions of these macros are:
User's & reference manual for C/GUI 2002-2007 Micrium
757 #define LCD_READ_MEM(Off) (*((U32 *)LCD_VRAM_ADR + (U32)Off)) #define LCD_WRITE_MEM(Off, Data) *((U32 *)LCD_VRAM_ADR + (U32)Off) = Data
These macros normally need not to be defined in the configuration file. It makes only sense to define them, if the memory access should not work as defined like shown above. In this case these macros can be defined in the configuration file LCDConf.h instead of the video memory start address.
Example
Configuration for 16 bit access:
#define LCD_CONTROLLER 1300 #define LCD_READ_MEM(Off) *((U16*)(0xc00000 +(((U32)(Off)) << 1))) #define LCD_WRITE_MEM(Off,Data) *((U16*)(0xc00000 +(((U32)(Off)) << 1))) = Data
2002-2007 Micrium
758
CHAPTER 25
Display drivers
Supported hardware
Controllers
The following table list the supported controllers and their assigned numbers for LCD_CONTROLLER, as well as the level of support: #
32168
LCD controller
Any display controller with linear video memory which should be accessed in 8, 16 or 32 bit mode in dependence of the required operation.
Add. info
The LUT (color look up table or palette RAM) is not handled by the driver. If a LUT mode is used, the application program is responsible for initialization of the LUT. LUT support can be added by using the macro LCD_SET_LUT_ENTRY.
Interfaces
The driver supports any 32 bit full bus interface.
Hardware configuration
This driver requires a full bus interface for hardware access as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_ENDIAN_BIG LCD_INIT_CONTROLLER LCD_VRAM_ADR Explanation
Should be set to 1 for big endian mode, 0 for little endian mode. Initialization sequence for the LCD controller. Defines the start address of the video memory.
2002-2007 Micrium
759
LCD_FILL_RECT()
Description
This macro can be used for defining a function which should be called by the display driver for filling rectangles.
Type
Function replacement.
Prototype
#define LCD_FILL_RECT(x0, y0, x1, y1, Index) Parameter x0 y0 x1 y1 Index Meaning
Leftmost X-position of the rectangle to be filled. Topmost Y-position of the rectangle to be filled. Rightmost X-position of the rectangle to be filled. Bottommost Y-position of the rectangle to be filled. Color index to be used for filling.
Add. information
If this macro is defined, the driver calls the function defined by this macro instead of using its own filling routine. Using this macro can make sense if for example a BitBLT engine should be used for filling instead of the driver internal filling function. Index values are in the range of 0 - ((1 << LCD_BITS_PER_PIXEL) - 1).
Example
void CustomFillRect(int x0, int y0, int x1, int y1, int Index); #define LCD_FILL_RECT(x0, y0, x1, y1, Index) CustomFillRect(x0, y0, x1, y1, Index)
2002-2007 Micrium
760
CHAPTER 25
Display drivers
2002-2007 Micrium
761
CPU load
The CPU load depends on the hardware and controller used, as well as on the size of the display. For example: Mitsubishi M16C62 Controller, 16MHz, 160*100 display, 8-bit interface, 80 Hz update = app. 12% CPU load. Mitsubishi M16C62 Controller, 16MHz, 240*128 display, 8-bit interface, 80 Hz update = app. 22% CPU load.
Supported hardware
Controllers
None.
Interfaces
The driver supports 1/4/8-bit interfaces from the CPU to the LCD.
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD. The display memory is divided into two panes for each pixel. The lower bit of one pixel is stored in pane 0 and the higher bit is stored in pane 1. The advantage of this method is that the output of the display data can be executed very quickly. If working in 1 bpp mode only one pane will be used.
762
CHAPTER 25
Display drivers
Hardware configuration
Normally, the hardware interface is an interrupt service routine (ISR) which updates the LCD. An output routine written in "C" code is shipped with C/GUI. This routine should serve only as an example. To optimize the execution speed, it must be adapted in assembler code. For detailed information on how to write the output routine, please take a look at the sample supplied with the driver or contact us.
2002-2007 Micrium
763
Supported hardware
Controllers
None.
Interfaces
The driver supports 1/4/8-bit interfaces from the CPU to the LCD.
2002-2007 Micrium
764
CHAPTER 25
Display drivers
B B G
G R
R B
B G
G R
R B
B G
G R
R B
B G
G R
R B
B G
G R
R B
This driver supports a 3 or 6 bpp memory area for color displays. The pictures above show the dependence between the memory area handled by the driver and the SEG and COM lines of the LCD.
2002-2007 Micrium
765
Hardware configuration
Normally, the hardware interface is an interrupt service routine (ISR) which updates the LCD. An output routine written in "C" code is shipped with C/GUI. This routine should serve only as an example. To optimize the execution speed, it must be adapted in assembler code. For detailed information on how to write the output routine, please take a look at the sample supplied with the driver or contact us.
2002-2007 Micrium
766
CHAPTER 25
Display drivers
Interfaces
The driver supports the 8-bit parallel (simple bus) interface.
y S E G n
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
Additional RAM-requirement
This driver requires a display data cache, containing a complete copy of the contents of the display data RAM. The amount of memory used by the cache may be calculated as follows: Size of RAM (in bytes) = (LCD_XSIZE + 7) / 8 * LCD_YSIZE
2002-2007 Micrium
767
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which should be defined for hardware access: Macro LCD_DAD LCD_INIT_CONTROLLER LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Display address used for the communication protocoll. Default value is display address 0. Initialization sequence for the display. Write a byte to the display. Write multiple bytes to the display.
2002-2007 Micrium
768
CHAPTER 25
Display drivers
Interfaces
8-bit parallel (simple bus), serial (SPI4) and I2C bus interfaces are supported.
2002-2007 Micrium
769
COM 0 COM 1 COM 2 Page 0 COM 3 COM 4 COM 5 COM 6 COM 7 ...
DB0 DB1 DB2 Page n DB3 DB4 DB5 DB6 COM n DB7
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
770
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to LCD controller with A-line high.
Display orientation
Some of the supported display controllers supports hardware mirroring of x/y axis. It is reccomended to use these functions instead of the display orientation macros of C/GUI. If mirroring of the X axis is needed, the command 0xA1 (ADC select reverse) should be used in the initialization macro. This causes the display controller to reverse the assignment of column address to segment output. If the display size in X is smaller than the number of segment outputs of the display controller, the macro LCD_FIRSTSEG0 can be used to add an offset to the column address to make sure, the right RAM address of the LCD controller is accessed. If mirroring of the Y axis is needed the command 0xC8 (SHL select revers) should be used in the initialization macro and the macro LCD_FIRSTCOM0 should be used to define the offset needed to access the right RAM address of the display controller.
LCD_FIRSTSEG0
LCD_SUPPORT_CACHECONTROL
2002-2007 Micrium
771
Interfaces
The driver supports 8-bit parallel (simple bus) and 4 pin SPI interface.
...
DB0 DB1 DB2 Page n DB3 DB4 DB5 DB6 COM n DB7
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD. The display memory is divided into four panes for each pixel. The least significant bit (LSB) of each pixel is stored in pane 0 and the MSB is stored in pane 3.
2002-2007 Micrium
772
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface, a 4 pin SPI interface or a I2C bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line high. (Used only if working without cache) Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to LCD controller with A-line high.
Display orientation
A Sitronix ST7528 display controller supports hardware mirroring of x/y axis. It is reccomended to use these functions instead of the display orientation macros of C/ GUI. If mirroring of the X axis is needed, the command 0xA1 (ADC select reverse) should be used in the initialization macro. This causes the display controller to reverse the assignment of column address to segment output. If the display size in X is smaller than the number of segment outputs of the display controller, the macro LCD_FIRSTSEG0 can be used to add an offset to the column address to make sure, the right RAM address of the LCD controller is accessed. If mirroring of the Y axis is needed the command 0xC8 (SHL select revers) should be used in the initialization macro and the macro LCD_FIRSTCOM0 should be used to define the offset needed to access the right RAM address of the display controller.
2002-2007 Micrium
773
LCD_NUM_COM0
LCD_NUM_SEG0
2002-2007 Micrium
774
CHAPTER 25
Display drivers
LCD controller
Toshiba T6963
Add. info
1 BPP LCD controller with external memory. Graphic mode, fully supported 1 BPP LCD controller with external memory. Graphic mode, fully supported Access to the controller is slow, please refer to section "Add info about certain display controllers" for details. LCD controller with external memory. Graphic mode, fully supported
6901
6902
Interfaces
The driver supports the 8-bit parallel (simple bus) interface.
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
Additional RAM-requirement
This LCD driver may be used with or without a display data cache, containing a complete copy of the contents of the LCD data RAM. If a cache is not used, there are no additional RAM requirements.
2002-2007 Micrium
775
It is recommended to use this driver with a data cache for faster LCD-access. The amount of memory used by the cache may be calculated as follows: Size of RAM (in bytes) = (LCD_XSIZE + 7) / 8 * LCD_YSIZE
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high.
LCD_EXTENDED_WAIT
There is only a short time window to write to the LCD controller if you want to make sure, no distortion is visible on the LCD display when the driver writes to the LCD controller. If the configuration macro is set to 1 (default value) it makes sure that no distortion will be visible. If you disable this behavior the driver performance will be accelerated. But when writing to the display small distortions will be visible. To disable the LCD_EXTENDED_WAIT macro add the following line to your LCDConf.h:
#define LCD_EXTENDED_WAIT 0
2002-2007 Micrium
776
CHAPTER 25
Display drivers
2002-2007 Micrium
777
Supported hardware
Any PC-compatible hardware as described above.
Supported resolutions
The following resolutions are supported by the driver: 320 x 200 640 x 480 800 x 600
Hardware configuration
This driver uses the INT 10h ROM BIOS functions to provide the VBE services. Therefore this driver does not need any additional hardware configuration.
Example:
LCDConf.h for a VGA display 640x480, 16bpp:
#define #define #define #define #define LCD_XSIZE LCD_YSIZE LCD_BITSPERPIXEL LCD_CONTROLLER LCD_SWAP_RB 640 480 16 8600 1 /* X-resolution of LCD, Logical coor. */ /* Y-resolution of LCD, Logical coor. */
Special requirements
None
2002-2007 Micrium
778
CHAPTER 25
Display drivers
Interfaces
16-bit parallel (full bus) mode.
16 bit databus
. . .
L-Byte
H-Byte
Display mode
COM n
SEG 0 SEG 0
. . .
SEG n . . .
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD in terms of the color depth.
2002-2007 Micrium
779
Hardware configuration
This driver requires a full bus interface for hardware access as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_MEM LCD_READ_REG LCD_WRITE_MEM LCD_WRITE_REG Explanation
Initialization sequence for the LCD controller. Read the contents of video memory of controller. Read the contents of a configuration register of controller. Write to video memory (display data RAM) of controller. Write to a configuration register of controller.
2002-2007 Micrium
780
CHAPTER 25
Display drivers
Interfaces
8-bit parallel (simple bus) and serial (SPI4) bus interfaces are supported.
D B 3
D B 2
D B 1
D B 0
D B 7
D B 6
D B 5
D B 4
The picture above shows the relation between the display memory and the SEG and COM lines of the display.
2002-2007 Micrium
781
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to LCD controller with A-line high.
2002-2007 Micrium
782
CHAPTER 25
Display drivers
Interfaces
The chip supports three types of interfaces: 8-bit parallel (simple bus) interface 4-pin serial peripheral interface, or SPI. 3-pin SPI. The current version of the driver supports the 8-bit parallel (simple bus) or 4-pin SPI interface.
2002-2007 Micrium
783
DB0 DB1 DB2 Page n DB3 DB4 DB5 DB6 COM n DB7
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD. The display memory is divided into two panes for each pixel. The lower bit of each pixel is stored in pane 0 and the higher bit is stored in pane 1.
2002-2007 Micrium
784
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. (Used only if working without cache) Read a byte from LCD controller with A-line high. (Used only if working without cache) Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to LCD controller with A-line high.
Display orientation
The supported display controllers supports hardware mirroring of x/y axis. It is reccomended to use these functions instead of the display orientation macros of C/ GUI. If mirroring of the X axis is needed, the command 0xA1 (ADC select reverse) should be used in the initialization macro. This causes the display controller to reverse the assignment of column address to segment output. If the display size in X is smaller than the number of segment outputs of the display controller, the macro LCD_FIRSTSEG0 can be used to add an offset to the column address to make sure, the right RAM address of the LCD controller is accessed. If mirroring of the Y axis is needed the command 0xC8 (SHL select revers) should be used in the initialization macro and the macro LCD_FIRSTCOM0 should be used to define the offset needed to access the right RAM address of the display controller.
2002-2007 Micrium
785
Interfaces
The driver supports 16-bit parallel (simple bus) interface.
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
786
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface or with a 3 pin SPI interface. The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER Explanation
Initialization sequence for the display controller. Using a write buffer increases the performance of the driver. If multiple pixels should be written with the same color the driver first fills the buffer and then writes the contents of the buffer with one execution of the macro LCD_WRITEM_A1 instead of multiple executions. The default buffer size is 500 words. Reads a word from display controller with RS-line high. Writes multiple words to display controller with RS-line high. Writes multiple words to display controller with RS-line low. Writes multiple words to display controller with RS-line high.
LCD_WRITE_BUFFER_SIZE
Special requirements
The driver needs to work in the fixed palette mode 565, which is the default value for 16 bit per pixel configurations. The driver does not work with other palettes. Further the driver needs to swap the red and the blue part of the color index. You should use the following macro definitions in the file LCDConf.h:
#define LCD_SWAP_RB 1
2002-2007 Micrium
787
Interface
For the Epson controller the 8-bit parallel (simple bus) bus interface is supported, which is labeled Generic Bus Indirect in the Epson documentation. For the other controllers the 8-bit parallel (simple bus), I2C, 4 pin SPI and 3 pin SPI interfaces are supported.
2002-2007 Micrium
788
CHAPTER 25
Display drivers
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
Ultrachip UC1617 Byte 0 SEG 0 SEG 1 SEG 2 SEG 3 Byte 1 ... Byte n SEG n
D B 0
D B 1
D B 2
D B 3
D B 4
D B 5
D B 6
D B 7
The picture above shows the relation between the display memory and the SEG and COM lines of the display.
2002-2007 Micrium
789
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the display controller. Read a word from display controller with A-line high. Write a word to display controller with A-line low. Write a word to display controller with A-line high. Write multiple words to display controller with A-line high.
2002-2007 Micrium
790
CHAPTER 25
Display drivers
Interfaces
16-bit parallel (simple bus) bus interfaces is supported.
2002-2007 Micrium
791
R R R R G G G G B B B B R R R R G G G G B B B B COM 0 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 DB8 DB9 DB10 DB11 DB12 DB13 DB14 DB15 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 DB8 DB9 DB10 DB11 DB12 DB13 DB14 DB15
COM n
COM 1
. . .
R R R G G G B B B R R R G G G B B B R R R G G G B B B COM 0 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 DB8 DB9 DB10 DB11 DB12 DB13 DB14 DB15 DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 DB8 DB9 DB10 DB11 DB12 DB13 DB14 DB15
COM n
COM 1
. . .
The picture above shows the relation between the display memory and the SEG and COM lines of the display.
2002-2007 Micrium
792
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the display controller. Read a word from display controller with A-line high. Write a word to display controller with A-line low. Write a word to display controller with A-line high. Write multiple words to display controller with A-line high.
2002-2007 Micrium
793
Interfaces
The driver supports 8-bit parallel (simple bus) interface.
Byte 0
Byte 1
Byte 2
Byte n
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high.
2002-2007 Micrium
794
CHAPTER 25
Display drivers
2002-2007 Micrium
795
Interfaces
8-bit parallel (simple bus), serial (SPI4) and I2C bus interfaces are supported.
...
DB0 DB1 DB2 Page n DB3 DB4 COM n COM n DB5 DB6 DB7
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
796
CHAPTER 25
Display drivers
It is highly recommended to use this driver with a data cache for faster LCD-access. Not using a cache degrades the performance of this driver seriously. The amount of memory used by the cache may be calculated as follows: Size of RAM (in bytes) = (LCD_YSIZE + (8 / LCD_BITSPERPIXEL - 1)) / 8 * LCD_BITSPERPIXEL * LCD_XSIZE
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to LCD controller with A-line high.
2002-2007 Micrium
797
Interfaces
The chip supports 8-bit parallel (simple bus) interface.
R
COM 0 COM 1 . . . COM n D B 7 D B 6
R
D B 5
R
D B 4
R
D B 3
G G G G D D D B B B 2 1 0
G G G G
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD. The driver works in 1-pixel/2-byte-mode.
2002-2007 Micrium
798
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following tables lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 Explanation
Initialization sequence for the display controller. Read a byte from display controller with A-line low. Read a byte from display controller with A-line high. Write a byte to display controller with A-line low. Write a byte to display controller with A-line high.
Special requirements
The driver needs to work in the fixed palette mode 444121. The driver does not work with other palettes. You should use the following macro definition in the file LCDConf.h:
#define LCD_FIXEDPALETTE 444121
2002-2007 Micrium
799
Interfaces
The driver supports 8-bit parallel (simple bus) or 4 pin SPI interface.
R
COM 0 COM 1 . . . COM n D B 7 D B 6
R
D B 5
R
D B 4
R
D B 3
R
D B 2
G G G G G G B B B B B D D D D D D D D D D B B B B B B B B B B 1 0 7 6 5 4 3 2 1 0
G G G G G G
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
800
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface or a 4 pin SPI interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the display controller. Read a byte from display controller with A-line high. (Used only if working without cache) Write a byte to display controller with A-line low. Write a byte to display controller with A-line high. Write multiple bytes to display controller with A-line high.
Display orientation
The controller SSD1781 supports rotating and mirroring. So it is recommended to use the hardware functions of the controller if rotating and/or mirroring is needed instead of the display orientation macros LCD_MIRROR_... and LCD_SWAP_XY of C/ GUI. The configuration sample folder contains a sample which uses the hardware to rotate the output 180 degrees. The command 0xBC of the controller can be used to mirror and/or rotate the display output. For more details about how to change the display orientation via the hardware functions please refer to the manual of the SSD1781.
LCD_GET_BUSY
LCD_WAIT
Special requirements
The driver needs to work in the fixed palette mode 565, which is the default value for 16 bit per pixel configurations. The driver does not work with other palettes. Further the driver needs to swap the red and the blue part of the color index. You should use the following macro definitions in the file LCDConf.h:
#define LCD_SWAP_RB 1
2002-2007 Micrium
801
2002-2007 Micrium
802
CHAPTER 25
Display drivers
Interfaces
The driver supports 8-bit parallel (simple bus) interfaces.
Byte 0
Byte 1
Byte 2
Byte n
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_WRITE_A0 LCD_WRITE_A1 Explanation
Initialization sequence for the display controller. Write a byte to display controller with A-line low. Write a byte to display controller with A-line high.
2002-2007 Micrium
803
Special requirements
The driver needs to work in the fixed palette mode 233. The driver does not work with other palettes. Further the driver needs to swap the the red and the blue part of the color index. You should use the following macro definitions in the file LCDConf.h:
#define LCD_FIXEDPALETTE 233 #define LCD_SWAP_RB 1
2002-2007 Micrium
804
CHAPTER 25
Display drivers
Interfaces
The driver supports 8-bit parallel (simple bus) and 4 pin SPI interface.
R
COM 0 COM 1 . . . COM n D B 7 D B 6
R
D B 5
R
D B 4
R
D B 3
R
D B 2
G G G G G G B B B B B D D D D D D D D D D B B B B B B B B B B 1 0 7 6 5 4 3 2 1 0
G G G G G G
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
805
Hardware configuration
This driver accesses the hardware with a simple bus interface or with a 4 pin SPI interface. The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the display controller. Write a byte to display controller with A-line low. Write a byte to display controller with A-line high. Write multiple bytes to display controller with A-line high. Display Line Number (DLN) selection bits of the Driver Output
LCD_DRIVER_OUTPUT_MODE_DLN Mode Set instruction. For details please refer to the display controller documentation.
LCD_DRIVER_ENTRY_MODE_16B
Data bus width selection bit of the Entry Mode Set instruction. For details please refer to the display controller documentation.
The driver initializes the Driver Output Mode and Entry Mode itself. The user does not need to initialize this registers in the LCD_INIT_CONTROLLER macro.
Special requirements
The driver needs to work in the fixed palette mode 565. The driver does not work with other palettes. Further the driver needs to swap the red and the blue part of the color index. You should use the following macro definitions in the file LCDConf.h:
#define LCD_FIXEDPALETTE 565 #define LCD_SWAP_RB 1
2002-2007 Micrium
806
CHAPTER 25
Display drivers
Interfaces
The driver supports 8-bit parallel (simple bus) interfaces.
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
807
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 Explanation
Initialization sequence for the display controller. Read a byte from display controller with A-line low. Read a byte from display controller with A-line high. Write a byte to display controller with A-line low. Write a byte to display controller with A-line high.
Special requirements
None.
2002-2007 Micrium
808
CHAPTER 25
Display drivers
Interfaces
The driver supports 8-bit parallel, 16 bit parallel and 3 pin SPI interface. Default mode is 8-bit parallel.
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
809
Hardware configuration
This driver accesses the hardware with a simple bus interface or with a 3 pin SPI interface. The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_NUM_DUMMY_READS LCD_SERIAL_ID LCD_USE_SERIAL_3PIN LCD_USE_PARALLEL_16 Explanation
Initialization sequence for the display controller. Number of required dummy reads if a read operation should be executed. The default value is 2. If using a serial interface the display controllers HD66766 and HD66772 need 5 dummy reads. Sharp LR38825 needs 3 dummy reads with a 8-bit bus. With a serial interface this macro defines the ID signal of the device ID code. It should be 0 (default) or 1. Should be set to 1 if the serial interface is used. Default is 0. Should be set to 1 if the 16 bit parallel interface is used. Default is 0. Defines the size of the write buffer. Using a write buffer increases the performance of the driver. If multiple pixels should be written with the same color, the driver first fills the buffer and then writes the contents of the buffer with one execution of the macro LCD_WRITEM_A1, instead of multiple macro executions. The default buffer size is 500 bytes. Write a byte to display controller with RS-line low. Write a byte to display controller with RS-line high. Read multiple bytes (8 bit parallel interface) or multiple words (16 bit parallel interface) from display controller with RS-line high. Write multiple bytes (8 bit parallel interface) or multiple words (16 bit parallel interface) to display controller with RS-line high. Write multiple bytes (8 bit parallel interface) or multiple words (16 bit parallel interface) to display controller with RS-line low.
LCD_WRITE_BUFFER_SIZE
The driver initializes the Driver Output Mode and Entry Mode register itself. The user does not need to initialize this registers in the LCD_INIT_CONTROLLER macro.
Special requirements
None.
2002-2007 Micrium
810
CHAPTER 25
Display drivers
Interfaces
The driver supports 8-bit parallel (simple bus) interfaces.
D B 0
D B 1
D B 2
D B 3
D B 4
D B 5
D B 6
D B 7
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
811
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high.
2002-2007 Micrium
812
CHAPTER 25
Display drivers
Interfaces
The driver supports 8 and 16-bit parallel (simple bus) interface, 3 and 4 line SPI.
2002-2007 Micrium
813
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
814
CHAPTER 25
Display drivers
5bpp mode: Size of RAM (in bytes) = (LCD_XSIZE + 2) / 3 * 3 * LCD_YSIZE 4bpp mode: Size of RAM (in bytes) = ((LCD_XSIZE + 2) / 3 * 3 + 1) / 2 * LCD_YSIZE 1bpp mode: Size of RAM (in bytes) =((LCD_XSIZE + 2) / 3 * 3 + 7) / 8 * LCD_YSIZE
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 LCD_READM_A1 LCD_FIRSTPIXEL0 Explanation
Initialization sequence for the LCD controller. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to display controller with A-line high. Read multiple bytes from display controller with A-line high. Required only if no display data cache is configured. If the display size in X is smaller than the number of segment outputs of the display controller, this macro can be used for defining the first visible pixel of the display. It should be used if the first segment lines of the display controller are not connected to the display.
2002-2007 Micrium
815
Interfaces
The driver supports 8-bit parallel (simple bus) interface, or 3 line SPI.
D B 7
D B 6
D B 5
D B 4
D B 3
D B 2
D B 1
D B 0
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
816
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A0 LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to display controller with A-line high.
2002-2007 Micrium
817
Interfaces
The driver supports 8-bit parallel (simple bus) interface.
The picture above shows the relation between the display memory and the SEG and COM lines of the LCD.
2002-2007 Micrium
818
CHAPTER 25
Display drivers
Hardware configuration
This driver accesses the hardware with a simple bus interface as described in Chapter 28: "Low-Level Configuration". The following table lists the macros which must be defined for hardware access: Macro LCD_INIT_CONTROLLER LCD_READ_A1 LCD_WRITE_A0 LCD_WRITE_A1 LCD_WRITEM_A1 Explanation
Initialization sequence for the LCD controller. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to display controller with A-line high.
2002-2007 Micrium
819
2002-2007 Micrium
820
CHAPTER 25
Display drivers
2002-2007 Micrium
821
2002-2007 Micrium
822
CHAPTER 25
Display drivers
Drawing group
Universal draw bitmap routine. Draw a horizontal line. Draw a pixel in the current foreground color. Draw a vertical line. Fill a rectangular area. Draw a pixel in a specified color. Invert a pixel.
"Get" group
Returs the index of the color of a specific pixel.
"Set" group
Not yet used, reserved for future use (must exist in driver).
2002-2007 Micrium
823
Prototype
void LCD_L0_Init (void);
LCD_L0_ReInit()
Description
Reinitializes the LCD using the configuration settings, without erasing the display contents.
Prototype
void LCD_L0_ReInit (LCD_INITINFO* pInitInfo);
LCD_L0_Off(), LCD_L0_On()
Description
Switch the display off or on, respectively.
Prototypes
void LCD_L0_Off(void); void LCD_L0_On(void);
Add. information
Use of these routines does not affect the contents of the video memory or other settings. You may therefore safely switch off the display and switch it back on without having to refresh the contents.
Prototype
LCD_L0_DrawBitMap(int x0, int y0, int Xsize, int Ysize, int BitsPerPixel, int BytesPerLine, const U8* pData, int Diff,
2002-2007 Micrium
824
CHAPTER 25
Display drivers
const LCD_PIXELINDEX* pTrans); Parameter x0 y0 Xsize Ysize BitsPerPixel BytesPerLine pData Diff Meaning
Upper left X-position of bitmap to draw. Upper left Y-position of bitmap to draw. Number of pixels in horizontal direction. Number of pixels in vertical direction. Number of bits per pixel. Number of bytes per line of the image. Pointer to the actual image, the data that defines what the bitmap looks like. Number of pixels to skip from the left side.
LCD_L0_DrawHLine()
Description
Draws a horizontal line one pixel thick, at a specified position using the current foreground color.
Prototype
void LCD_L0_DrawHLine(int x0, int y, int x1); Parameter x0 y x1
Start position of line. Y-position of line to draw. End position of line.
Meaning
Add. information
With most LCD controllers, this routine executes very quickly because multiple pixels can be set at once and no calculations are needed. If it is clear that horizontal lines are to be drawn, this routine executes faster than the DrawLine routine.
LCD_L0_DrawPixel()
Description
Draws one pixel at a specified position using the current foreground color.
Prototype
void LCD_L0_DrawPixel(int x, int y); Parameter x y
X-position of pixel to draw. Y-position of pixel to draw.
Meaning
LCD_L0_DrawVLine()
Description
Draws a vertical line one pixel thick, at a specified position using the current foreground color.
2002-2007 Micrium
825
Prototype
void LCD_L0_DrawVLine(int x , int y0, int y1); Parameter x y0 y1
X-position of line to draw. Start position of line. End position of line.
Meaning
Add. information
With most LCD-controllers, this routine executes very quickly because multiple pixels can be set at once and no calculations are needed. If it is clear that horizontal lines are to be drawn, this routine executes faster than the DrawLine routine.
LCD_L0_FillRect()
Description
Draws a filled rectangle at a specified position using the current foreground color.
Prototype
void LCD_L0_FillRect(int x0, int y0, int x1, int y1); Parameter x0 y0 x1 y1
Upper left X-position. Upper left Y-position. Lower right X-position. Lower right Y-position.
Meaning
LCD_L0_SetPixelIndex()
Description
Draws one pixel using a specified color
Prototype
void LCD_L0_SetPixelIndex(int x, int y, int ColorIndex); Parameter x y ColorIndex
X-position of pixel to draw. Y-position of pixel to draw. Color to be used.
Meaning
LCD_L0_XorPixel()
Description
Inverts one pixel.
2002-2007 Micrium
826
CHAPTER 25
Display drivers
Prototype
void LCD_L0_XorPixel(int x, int y); Parameter x y
X-position of pixel to invert. Y-position of pixel to invert.
Meaning
Prototype
int LCD_L0_GetPixelIndex(int x, int y); Parameter x y
X-position of pixel. Y-position of pixel.
Meaning
Return value
The index of the pixel.
Add. information
For further information see Chapter 11: "Colors".
Prototype
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color; Parameter Pos Color Meaning
Position within the lookup table. Should be less than the number of colors, e.g. 0-3 for 2bpp, 0-15 for 4bpp, 0-255 for 8bpp. 24-bit RGB value. The closest value possible will be used for the LUT. If a color LUT is to be initialized, all 3 components are used. In monochrome modes the green component is used, but it is still recommended (for better understanding of the program code) to set all 3 colors to the same value (such as 0x555555 or 0xa0a0a0).
2002-2007 Micrium
827
Prototype
U8 LCD_ControlCache(U8 command); Parameter command Meaning
Specify the command to be given to the cache. Use the symbolic values in the table below.
Permitted values for parameter command LCD_CC_UNLOCK Set the default mode: cache is transparent. LCD_CC_LOCK LCD_CC_FLUSH
Lock the cache, no write operations will be performed until cache is unlocked or flushed. Flush the cache, writing all modified data to the video RAM.
Return value
Information on the state of the cache. Ignore.
Add. information
When the cache is locked, the driver maintains a "hitlist" -- a list of bytes which have been modified and need to be written to the display. This hitlist uses 1 bit per byte of video memory. This is an optional feature which is not supported by all LCD drivers
Example
The code in the following example performs drawing operations on the display which overlap. In order to accelerate the update of the display and to avoid flickering, the cache is locked before and unlocked after these operations.
LCD_ControlCache(LCD_CC_LOCK); GUI_FillCircle(30,30,20); GUI_SetDrawMode(GUI_DRAWMODE_XOR); GUI_FillCircle(50,30,10); GUI_SetTextMode(GUI_TEXTMODE_XOR); GUI_DispStringAt("Hello world\n",0,0); GUI_DrawHLine(16, 5,25); GUI_DrawHLine(18, 5,25); GUI_DispStringAt("XOR Text",0,20); GUI_DispStringAt("XOR Text",0,60); LCD_ControlCache(LCD_CC_UNLOCK);
2002-2007 Micrium
828
CHAPTER 25
Display drivers
LCD_GetBitsPerPixel()
Description
Returns the number of bits per pixel.
Prototype
int LCD_GetBitsPerPixel(void);
Return value
Number of bits per pixel.
LCD_GetBitsPerPixelEx()
Description
Returns the number of bits per pixel.
Prototype
int LCD_GetBitsPerPixelEx(int Index); Parameter Index
Layer index.
Meaning
Return value
Number of bits per pixel.
LCD_GetFixedPalette()
Description
Returns the fixed palette mode.
Prototype
int LCD_GetFixedPalette(void);
Return value
The fixed palette mode. See Chapter 11: "Colors" for more information on fixed palette modes.
LCD_GetFixedPaletteEx()
Description
Returns the fixed palette mode.
Prototype
int LCD_GetFixedPaletteEx(int Index); Parameter Index
Layer index.
Meaning
Return value
The fixed palette mode. See Chapter 9: "Colors" for more information on fixed palette modes.
User's & reference manual for C/GUI 2002-2007 Micrium
829
LCD_GetNumColors()
Description
Returns the number of currently available colors on the LCD.
Prototype
int LCD_GetNumColors(void);
Return value
Number of available colors
LCD_GetNumColorsEx()
Description
Returns the number of currently available colors on the LCD.
Prototype
U32 LCD_GetNumColorsEx(int Index); Parameter Index
Layer index.
Meaning
Return value
Number of available colors.
LCD_GetVXSize(), LCD_GetVYSize()
Description
Returns the virtual X- or Y-size, respectively, of the LCD in pixesl. In most cases, the virtual size is equal to the physical size.
Prototype
int LCD_GetVXSize(void) int LCD_GetVYSize(void)
Return value
Virtual X/Y-size of the display.
LCD_GetVXSizeEx(), LCD_GetVYSizeEx()
Description
Returns the virtual X- or Y-size, respectively, of the LCD in pixesl. In most cases, the virtual size is equal to the physical size.
Prototype
int LCD_GetVXSizeEx(int Index); int LCD_GetVYSizeEx(int Index); Parameter Index
Layer index.
Meaning
2002-2007 Micrium
830
CHAPTER 25
Display drivers
Return value
Virtual X/Y-size of the display.
LCD_GetXMag(), LCD_GetYMag()
Description
Returns the magnification factor in X- or Y-axis, respectively.
Prototype
int LCD_GetXMag(int Index); int LCD_GetYMag(int Index);
Return value
Magnification factor in X- or Y-axis.
LCD_GetXMagEx(), LCD_GetYMagEx()
Description
Returns the magnification factor in X- or Y-axis, respectively.
Prototype
int LCD_GetXMagEx(int Index); Parameter Index
Layer index.
Meaning
Return value
Magnification factor in X- or Y-axis.
LCD_GetXSize(), LCD_GetYSize()
Description
Returns the physical X- or Y-size, respectively, of the LCD in pixels.
Prototypes
int LCD_GetXSize(void) int LCD_GetYSize(void)
Return value
Physical X/Y-size of the display.
LCD_GetXSizeEx(), LCD_GetYSizeEx()
Description
Returns the physical X- or Y-size, respectively, of the LCD in pixels.
Prototype
int LCD_GetXSizeEx(int Index);
2002-2007 Micrium
831
Meaning
Return value
Physical X/Y-size of the display.
2002-2007 Micrium
832
CHAPTER 25
Display drivers
2002-2007 Micrium
833
VNC stands for Virtual Network Computing. It is, in essence, a client server system based on a simple display protocol which allows the user to view a computing 'desktop' environment not only on the machine where it is running, but from anywhere on the Internet and from a wide variety of machine architectures. Client and server communicate via TCP/IP. C/GUI VNC support is available as a separate package. It is not included in the basic package.
2002-2007 Micrium
834
CHAPTER 26
VNC support
26.1 Introduction
VNC consists of two types of components. A server, which generates a display, and a viewer, which actually draws the display on your screen. The remote machine (target or simulation) can not only be viewed, but also controlled via mouse or keyboard. The server and the viewer may be on different machines and on different architectures. The protocol which connects the server and viewer is simple, open, and platform independent. No state is stored at the viewer. Breaking the viewer's connection to the server and then reconnecting will not result in any loss of data. Because the connection can be remade from somewhere else, you have easy mobility. Using the VNC server, you may control your target from anywhere and you can make screenshots (e.g. for a manual) from a "live" system.
26.1.1 Requirements
TCP/IP stack
Since the communication between the server and the viewer is based on a TCP/IP connection, VNC requires a TCP/IP stack. In the Win32 simulation environment, TCP/ IP (Winsock) is normally present. In the target, a TCP/IP stack needs to be present. The TCP/IP stack is NOT part of C/GUI. The flexible interface ensures that any TCP/ IP stack can be used.
Multi tasking
The VNC server needs to run as a separate thread. Therefore a multi tasking system is required to use the C/GUI VNC server.
Encoding
The server supports raw encoding and hextile encoding.
Authentication
The Server currently does not require authentication. However, this feature can be added to the server easily at request.
Performance
Most viewers support hextile encoding, which supports descent compression. A typical quarter VGA screen requires typically 20 - 50 kb of data. An implementation running on an ARM7 platform (50 MHZ, with Cache) requires app. 200 - 300 ms for an update of the entire screen. The server handles incremental updates; in most cases the updated display area is a lot smaller than the entire display and less data needs to be transmitted. A typical ARM7 system therefore allows real time updates.
Multiple servers
The implementation is fully thread safe and reentrant; multiple VNC-servers can be started on the same CPU for different layers or displays. If your target (of course the same holds true for the simulation) has multiple displays or multiple layers, this can be a useful option. Only one VNC server may be started per layer at any given time; once the connection to a Viewer ends, an other one can connect.
2002-2007 Micrium
835
Version
The VNC implementation of C/GUI has been tested with version 3.3.3R2 and should work with this version or later versions.
Platforms
The viewer is available for different platforms. Please take a look to the website of AT&T Laboratories Cambridge for detailed information about the availability.
2002-2007 Micrium
836
CHAPTER 26
VNC support
Screenshot
The following screenshots shows the viewer: Connected to the simulation Connected to the target
start
the
VNC
server
is
to
call
the
function
The above function call creates a thread which listens on port 5900 for an incoming connection. After a connection has been detected GUI_VNC_Process() will be called.
Ports
The VNC server listens on port 590x, where x is the server index. So for most PC servers, the port will be 5900, because they use display 0 by default.
Sample
A ready to use sample (in executable form) is available on our website. The trial version also contains the VNC server; it takes no more than one line of code (using GUI_VNC_X_StartServer()) to activate it.
2002-2007 Micrium
837
RAM
The VNC support does not use static data. For each instance one GUI_VNC_CONTEXT structure (app. 60 bytes) is used.
Others
Each instance needs one TCP/IP socket and one thread.
Macro GUI_VNC_BUFFER_SIZE
Default
1000
Explanation
Frame buffer size. The buffer is located on the stack. Typically bigger sizes resut in only minor accellerations. A reasonable buffer size is app. 200 bytes. If set to 1 the GUI will be locked during a frame is send to the viewer. This option could make sense if screenshots for a documentation should be made. This macro defines the name of the target shown in the title bar of the viewer. If using the viewer in the simulation the default is: "Embedded GUI on WIN32" On the target the default is: "Embedded GUI" Enables or disables hextile encoding. Hextile encoding is a faster but needs bigger code (app. 1.4 k more).
GUI_VNC_LOCK_FRAME
GUI_VNC_PROGNAME
(see explanation)
GUI_VNC_SUPPORT_HEXTILE
Explanation
Attaches a VNC server to a layer. Without a multi display configuration the given index must be 0. The actual VNC server; initialises the communication with the viewer. Routine to be called to start a VNC viewer.
2002-2007 Micrium
838
CHAPTER 26
VNC support
GUI_VNC_AttachToLayer()
Description
This function attaches the given layer to the VNC server. Normally, with single layer configurations, this parameter should be 0.
Prototype
void GUI_VNC_AttachToLayer(GUI_VNC_CONTEXT * pContext, int LayerIndex); Parameter pContext LayerIndex Meaning
Pointer to a GUI_VNC_CONTEXT structure. Zero based index of layer to be handled by the server.
Return value
0 if the function succeed, != 0 if the function fails.
GUI_VNC_Process()
Description
The function sets the send and receive function used to send and receive data and starts the communication with the viewer.
Prototype
void GUI_VNC_Process(GUI_VNC_CONTEXT * pContext, GUI_tSend pfSend, GUI_tReceive pfReceive, void * pConnectInfo); Parameter pContext pfSend pfReceive pConnectInfo Meaning
Pointer to a GUI_VNC_CONTEXT structure. Pointer to the function to be used by the server to send data to the viewer. Pointer to the function to be used by the server to read from the viewer. Pointer to be passed to the send and receive function.
Additional information
The GUI_VNC_CONTEXT structure is used by the server to store connection state informations. The send and receive functions should return the number of bytes successfully send/ received to/from the viewer. The pointer pConnectInfo is passed to the send and receive routines. It can be used to pass a pointer to a structure containing connection information or to pass a socket number. The following types are used as function pointers to the routines used to send and receive bytes from/to the viewer: typedef int (*GUI_tSend) (const U8 * pData, int len, void* pConnectInfo); typedef int (*GUI_tReceive)( U8 * pData, int len, void* pConnectInfo);
Example:
static GUI_VNC_CONTEXT _Context; /* Data area for server */ static int _Send(const U8* buf, int len, void * pConnectionInfo) { User's & reference manual for C/GUI 2002-2007 Micrium
839 SOCKET Socket = (SOCKET)pConnectionInfo; ... } static int _Recv(U8* buf, int len, void * pConnectionInfo) { SOCKET Socket = (SOCKET)pConnectionInfo; ... } static void _ServerTask(void) { int Socket; ... GUI_VNC_Process(&_Context, _Send, _Recv, (void*)Socket); ... }
GUI_VNC_X_StartServer()
Description
Starts a VNC viewer with the given server index to display the given layer in the viewer. The function has to be written by the customer because the implementation depends on the used TCP/IP stack and on the used operating system. The C/GUI shipment contains a sample implementation under Sample\GUI_X\GUI_VNC_X_StartServer.c. It could be used as a starting point for adapting it to other systems.
Prototype
int GUI_VNC_X_StartServer(int LayerIndex, int ServerIndex); Parameter LayerIndex ServerIndex
Layer to be shown by the viewer. Server index.
Meaning
Additional information
There is no difference to start a VNC server in the simulation or on the target. In both cases you should call this function. The simulation contains an implementation of this function, the hardware implementation has to be done by the customer.
2002-2007 Micrium
840
CHAPTER 26
VNC support
2002-2007 Micrium
841
Some widgets, as well as our demonstration code, require time-related functions. The other parts of the C/GUI graphic library do not require a time base. The demonstration code makes heavy use of the routine GUI_Delay(), which delays for a given period of time. A unit of time is referred to as a tick.
2002-2007 Micrium
842
CHAPTER 27
Time-Related Functions
GUI_Delay()
Description
Delays for a specified period of time.
Prototype
void GUI_Delay(int Period); Parameter Period Explanation
Period in ticks until function should return.
Additional information
The time unit (tick) is usually milliseconds (depending on GUI_X_ functions). GUI_Delay() only executes idle functions for the given period. If the window manager is used, the delay time is used for the updating of invalid windows (through execution of WM_Exec()). This function will call GUI_X_Delay().
GUI_Exec()
Description
Executes callback functions (typically redrawing of windows).
Prototype
int GUI_Exec(void);
Return value
0 if there were no jobs performed. 1 if a job was performed.
Additional information
This function will automatically call GUI_Exec1() repeatedly until it has completed all jobs -- essentially until a 0 value is returned. Normally this function does not need to be called by the user application. It is called automatically by GUI_Delay().
GUI_Exec1()
Description
Executes a callback function (one job only -- typically redrawing a window).
2002-2007 Micrium
843
Prototype
int GUI_Exec1(void);
Return value
0 if there were no jobs performed. 1 if a job was performed.
Additional information
This routine may be called repeatedly until 0 is returned, which means all jobs have been completed. This function is called automatically by GUI_Exec().
GUI_GetTime()
Description
Returns the current system time.
Prototype
int GUI_GetTime(void);
Return value
The current system time in ticks.
Additional information
This function will call GUI_X_GetTime().
2002-2007 Micrium
844
CHAPTER 27
Time-Related Functions
2002-2007 Micrium
845
2002-2007 Micrium
846
CHAPTER 28
Macro LCD_CONTROLLER LCD_BITSPERPIXEL LCD_FIXEDPALETTE LCD_XSIZE LCD_YSIZE LCD_INIT_CONTROLLER() LCD_MIRROR_X LCD_MIRROR_Y LCD_SWAP_XY
Explanation
Select LCD controller. Specify bits per pixel. Specify fixed palette mode. Set to 0 for a user-defined color lookup table (then LCD_PHYSCOLORS must be defined). Define horizontal resolution of LCD. Define vertical resolution of LCD. Initialization sequence for the LCD controller(s). Not applicable with all controllers. Activate to mirror X-axis. Activate to mirror Y-axis. Activate to swap X- and Y-axes. If set to 0, SEG lines refer to columns and COM lines refer to rows. Maximum number of logical colors that the driver can support in a bitmap. Defines the contents of the color lookup table. Only required if LCD_FIXEDPALETTE is set to 0. Only relevant if physical colors are defined. Puts physical colors in RAM, making them modifiable at run time Activate to invert the display at compile time. Activate to initialize the lookup table with inverted colors at run time. Used to set a single lookup table or palette RAM entry. Activate to swap the red and blue components. Horizontal magnification factor of LCD. Vertical magnification factor of LCD. Read a byte from LCD controller with A-line low. Read a byte from LCD controller with A-line high. Write a byte to LCD controller with A-line low. Write a byte to LCD controller with A-line high. Write multiple bytes to LCD controller with A-line high.
Display orientation
B B B 0 0 0
Color configuration
N A
LCD_MAX_LOG_COLORS LCD_PHYSCOLORS
256 ---
B B B F B
LCD_PHYSCOLORS_IN_RAM LCD_REVERSE LCD_REVERS_LUT LCD_SET_LUT_ENTRY LCD_SWAP_RB LCD_XMAG<n> LCD_YMAG<n> LCD_READ_A0(Result) LCD_READ_A1(Result) LCD_WRITE_A0(Byte) LCD_WRITE_A1(Byte) LCD_WRITEM_A1
0 0 0 --0
2002-2007 Micrium
847
Type
F F F F S F F
Default
--------16 -----
Explanation
Read the contents of video memory of controller. Read the contents of a configuration register of controller. Write to video memory (display data RAM) of controller. Write to a configuration register of controller. Select bus-width (8/16) of LCD controller/ CPU interface. Switch the M/R signal to register access. Not applicable with all controllers. Switch the M/R signal to memory access. Not applicable with all controllers. Activate to invert the endian mode (swap the high and low bytes) between CPU and LCD controller when using a 16-bit bus interface. Horizontal resolution of virtual display. Not applicable with all drivers. Vertical resolution of virtual display. Not applicable with all drivers.
Virtual display
N N
LCD_VXSIZE LCD_VYSIZE
LCD_XSIZE LCD_YSIZE
N N A A N B
LCD controller configuration: common/segment lines 0 LCD controller <n>: first segment line used. LCD_FIRSTSEG<n> 0 LCD controller <n>: first common line used. LCD_FIRSTCOM<n> COM/SEG lookup tables --COM lookup table for controller. LCD_LUT_COM --SEG lookup table for controller. LCD_LUT_SEG Miscellaneous 1 Number of LCD controllers used. LCD_DIST_NUM_CONTROLLERS LCD_CACHE LCD_USE_BITBLT
1 Deactivate to disable use of display data cache, which slows down the speed of the driver. Not applicable with all drivers. Deactivate to disable BitBLT engine. If set to 1, the driver will use all available hardware acceleration. Activate to enable cache control functions of LCD_L0_ControlCache() driver API. Not applicable with all controllers. Timing value used by ISR for displaying pane 0 when using CPU as controller. Timing value used by ISR for displaying pane 1 when using CPU as controller. Function replacement macro which switches the LCD on. Function replacement macro which switches the LCD off.
B N N F F
0 ---------
848
CHAPTER 28
Configure the bus interface by defining the appropriate simple bus or full bus macros. 3. Define the size of your LCD (LCD_XSIZE, LCD_YSIZE). 4. Select the controller used in your system, as well as the appropriate bpp and the palette mode (LCD_CONTROLLER, LCD_BITSPERPIXEL, LCD_FIXEDPALETTE). 5. Configure which common/segment lines are used, if necessary. 6. Test the system. 7. Reverse X/Y if necessary (LCD_REVERSE); go back to step 6 in this case. 8. Mirror X/Y if necessary (LCD_MIRROR_X, LCD_MIRROR_Y); go back to step 6 in this case. 9. Check all the other configuration switches. 10. Erase unused sections of the configuration.
2.
Type
Selection switch
Additional information
The LCD controller used is designated by the appropriate number. Please refer to Chapter 24: "LCD Drivers" for more information about available options.
Example
Specifies an Epson SED1565 controller:
#define LCD_CONTROLLER 1565 /* Selects SED 1565 LCD-controller */
LCD_BITSPERPIXEL
Description
Specifies the number of bits per pixel.
Type
Numerical value
LCD_FIXEDPALETTE
Description
Specifies the fixed palette mode.
Type
Selection switch
Additional information
Set the value to 0 to use a color lookup table instead of a fixed palette mode. The macro LCD_PHYSCOLORS must then be defined.
2002-2007 Micrium
849
LCD_XSIZE, LCD_YSIZE
Description
Define the horizontal and vertical resolution (respectively) of the display used.
Type
Numerical values
Additional information
The values are logical sizes; X-direction specifies the direction which is used as the X-direction by all routines of the LCD driver. Usually the X-size equals the number of segments.
2002-2007 Micrium
850
CHAPTER 28
Type
Function replacement
Additional information
This macro must be user-defined to initialize some controllers. It is executed during the LCD_L0_Init() and LCD_L0_Reinit() routines of the driver. Please consult the data sheet of your controller for information on how to initialize your hardware.
Example
The sample below has been written for and tested with an Epson SED1565 controller using an internal power regulator.
#define LCD_INIT_CONTROLLER() \ LCD_WRITE_A0(0xe2); /* Internal reset */ \ LCD_WRITE_A0(0xae); /* Display on/off: off */ \ LCD_WRITE_A0(0xac); /* Power save start: static indicator off */ \ LCD_WRITE_A0(0xa2); /* LCD bias select: 1/9 */ \ LCD_WRITE_A0(0xa0); /* ADC select: normal */ \ LCD_WRITE_A0(0xc0); /* Common output mode: normal */ \ LCD_WRITE_A0(0x27); /* V5 voltage regulator: medium */ \ LCD_WRITE_A0(0x81); /* Enter electronic volume mode */ \ LCD_WRITE_A0(0x13); /* Electronic volume: medium */ \ LCD_WRITE_A0(0xad); /* Power save end: static indicator on */ \ LCD_WRITE_A0(0x03); /* static indicator register set: on (constantly on) */ \ LCD_WRITE_A0(0x2F); /* Power control set: booster, regulator and follower off */ \ LCD_WRITE_A0(0x40); /* Display Start Line */ \ LCD_WRITE_A0(0xB0); /* Display Page Address 0 */ \ LCD_WRITE_A0(0x10); /* Display Column Address MSB */ \ LCD_WRITE_A0(0x00); /* Display Column Address LSB */ \ LCD_WRITE_A0(0xaf); /* Display on/off: on */ \ LCD_WRITE_A0(0xe3); /* NOP */
2002-2007 Micrium
851
Display
2002-2007 Micrium
852
CHAPTER 28
Display
Driver optimizations
We can not optimize all drivers for all possible combinations of orientations and other config switches. In general, the default orientation is optimized. If you need to use a driver in an orientation which has not been optimized, please contat us.
LCD_MIRROR_X
Description
Inverts the X-direction (horizontal) of the display.
Type
Binary switch 0: inactive, X not mirrored (default) 1: active, X mirrored
Additional information
If activated: X -> LCD_XSIZE-1-X. This macro, in combination with LCD_MIRROR_Y and LCD_SWAP_XY, can be used to support any orientation of the display. Before changing this configuration switch, make sure that LCD_SWAP_XY is set as required by your application.
2002-2007 Micrium
853
LCD_MIRROR_Y
Description
Inverts the Y-direction (vertical) of the display.
Type
Binary switch 0: inactive, Y not mirrored (default) 1: active, Y mirrored
Additional information
If activated: Y -> LCD_YSIZE-1-Y. This macro, in combination with LCD_MIRROR_X and LCD_SWAP_XY, can be used to support any orientation of the display. Before changing this configuration switch, make sure that LCD_SWAP_XY is set as required by your application.
LCD_SWAP_XY
Description
Swaps the horizontal and vertical directions (orientation) of the display.
Type
Binary switch 0: inactive, X-Y not swapped (default) 1: active, X-Y swapped
Additional information
If set to 0 (not swapped), SEG lines refer to columns and COM lines refer to rows. If activated: X -> Y. When changing this switch, you will also have to swap the X-Y settings for the resolution of the display (using LCD_XSIZE and LCD_YSIZE).
2002-2007 Micrium
854
CHAPTER 28
Type
Numerical value (default is 256)
Additional information
If you are using a 4-grayscale LCD, it is usually sufficient to set this value to 4. However, in this case remember not to try to display bitmaps with more than 4 colors.
LCD_PHYSCOLORS
Description
Defines the contents of the color lookup table, if one is used.
Type
Alias
Additional information
This macro is only required if LCD_FIXEDPALETTE is set to 0. Refer to the color section for more information.
LCD_PHYSCOLORS_IN_RAM
Description
Puts the contents of the physical color table in RAM if enabled.
Type
Binary switch 0: inactive (default) 1: active
LCD_REVERSE
Description
Inverts the display at compile time.
Type
Binary switch 0: inactive, not reversed (default) 1: active, reversed
LCD_SET_LUT_ENTRY
Description
This macro can be used to set a single LUT entry. If defined the macro will be executed each time the GUI needs to set a LUT entry (typically during the initialisation).
Type
Function replacement
User's & reference manual for C/GUI 2002-2007 Micrium
855
Prototype
#define LCD_SET_LUT_ENTRY(Pos, Color) Parameter Pos Color
RGB value of color to be set.
Meaning
Zero based index of LUT entry to be set.
LCD_SWAP_RB
Description
Swaps the red and blue color components.
Type
Binary switch 0: inactive, not swapped (default) 1: active, swapped
LCD_XMAG
Description
Specifies the horizontal magnification factor of the LCD.
Type
Numerical value (default is 1)
Additional information
A factor of 1 results in no magnification.
LCD_YMAG
Description
Specifies the vertical magnification factor of the LCD.
Type
Numerical value (default is 1)
Additional information
A factor of 1 results in no magnification.
2002-2007 Micrium
856
CHAPTER 28
LCD_READ_A0
Description
Reads a byte from LCD controller with A0 (C/D) - line low.
Type
Function replacement
Prototype
#define LCD_READ_A0(Result) Parameter Result Meaning
Result read. This is not a pointer, but a placeholder for the variable in which the value will be stored.
LCD_READ_A1
Description
Reads a byte from LCD controller with A0 (C/D) - line high.
Type
Function replacement
Prototype
#define LCD_READ_A1(Result) Parameter Result Meaning
Result read. This is not a pointer, but a placeholder for the variable in which the value will be stored.
LCD_WRITE_A0
Description
Writes a byte to LCD controller with A0 (C/D) - line low.
Type
Function replacement
Prototype
#define LCD_WRITE_A0(Byte) Parameter Byte
Byte to write.
Meaning
2002-2007 Micrium
857
LCD_WRITE_A1
Description
Writes a byte to LCD controller with A0 (C/D) - line high.
Type
Function replacement
Prototype
#define LCD_WRITE_A1(Byte) Parameter Byte
Byte to write.
Meaning
LCD_WRITEM_A1
Description
Writes several bytes to the LCD controller with A0 (C/D) - line high.
Type
Function replacement
Prototype
#define LCD_WRITEM_A1(paBytes, NumberOfBytes) Parameter Meaning
Placeholder for the pointer to the first data byte. paBytes NumberOfBytes Number of data bytes to be written.
2002-2007 Micrium
858
CHAPTER 28
These samples can be used directly. All you need to do is to define the port access macros listed at the top of each example and to map them in your LCDConf.h in a similar manner to that shown below:
void LCD_X_Write00(char c); void LCD_X_Write01(char c); char LCD_X_Read00(void); char LCD_X_Read01(void); #define LCD_WRITE_A1(Byte) LCD_X_Write01(Byte) #define LCD_WRITE_A0(Byte) LCD_X_Write00(Byte) #define LCD_READ_A1(Result) Result = LCD_X_Read01() #define LCD_READ_A0(Result) Result = LCD_X_Read00()
Note that not all LCD controllers handle the A0 or C/D bit in the same way. For example, a Toshiba controller requires that this bit be low when accessing data and an Epson SED1565 requires it to be high.
2002-2007 Micrium
859
LCD_WRITE
Description
Writes a byte to the LCD controller.
Type
Function replacement
Prototype
#define LCD_WRITE(Byte) Parameter Byte
Byte to write.
Meaning
LCD_WRITEM
Description
Writes several bytes to the LCD controller.
Type
Function replacement
Prototype
#define LCD_WRITEM(paBytes, NumberOfBytes) Parameter Meaning
Placeholder for the pointer to the first data byte. paBytes NumberOfBytes Number of data bytes to be written.
This sample can be used directly. All you need to do is to define the port access macros listed at the top of the example and to map them in your LCDConf.h in a similar manner to that shown below:
void LCD_X_Write(char c); void LCD_X_WriteM(char * pData, int NumBytes); #define LCD_WRITE(Byte) LCD_X_Write(Byte) #define LCD_WRITEM(data, NumBytes) LCD_X_WriteM(data, NumBytes)
2002-2007 Micrium
860
CHAPTER 28
LCD_WRITE_A0
Description
Writes a byte to LCD controller with A0 - line low.
Type
Function replacement
Prototype
#define LCD_WRITE_A0(Byte) Parameter Byte
Byte to write.
Meaning
LCD_WRITE_A1
Description
Writes a byte to LCD controller with A0 - line high.
Type
Function replacement
Prototype
#define LCD_WRITE_A1(Byte) Parameter Byte
Byte to write.
Meaning
LCD_WRITEM_A1
Description
Writes several bytes to the LCD controller with A0 - line high.
Type
Function replacement
Prototype
#define LCD_WRITEM_A1(paBytes, NumberOfBytes) Parameter Meaning
Placeholder for the pointer to the first data byte. paBytes NumberOfBytes Number of data bytes to be written.
2002-2007 Micrium
861
This sample can be used directly. All you need to do is to define the port access macros listed at the top of the example and to map them in your LCDConf.h in a similar manner to that shown below:
void LCD_X_Write00(char c); void LCD_X_Write01(char c); void LCD_X_WriteM01(char * pData, int NumBytes); #define LCD_WRITE_A0(Byte) LCD_X_Write00(Byte) #define LCD_WRITE_A1(Byte) LCD_X_Write01(Byte) #define LCD_WRITEM_A1(data, NumBytes) LCD_X_WriteM01(data, NumBytes)
2002-2007 Micrium
862
CHAPTER 28
LCD_READ_A0
Description
Reads a status byte from LCD controller.
Type
Function replacement
Prototype
#define LCD_READ_A0(Result) Parameter Result Meaning
Result read. This is not a pointer, but a placeholder for the variable in which the value will be stored.
LCD_READ_A1
Description
Reads a data byte from LCD controller.
Type
Function replacement
Prototype
#define LCD_READ_A1(Result) Parameter Result Meaning
Result read. This is not a pointer, but a placeholder for the variable in which the value will be stored.
LCD_WRITE_A0
Description
Writes a instruction byte to LCD controller.
Type
Function replacement
Prototype
#define LCD_WRITE_A0(Byte) Parameter Byte
Byte to write.
Meaning
2002-2007 Micrium
863
LCD_WRITE_A1
Description
Writes a data byte to LCD controller.
Type
Function replacement
Prototype
#define LCD_WRITE_A1(Byte) Parameter Byte
Byte to write.
Meaning
LCD_WRITEM_A1
Description
Writes several data bytes to the LCD controller.
Type
Function replacement
Prototype
#define LCD_WRITEM_A1(paBytes, NumberOfBytes) Parameter Meaning
Placeholder for the pointer to the first data byte. paBytes NumberOfBytes Number of data bytes to be written.
This sample can be used directly. All you need to do is to define the port access macros listed at the top of the example and to map them in your LCDConf.h in a similar manner to that shown below:
void LCD_X_Write00(char c); void LCD_X_Write01(char c); char LCD_X_Read00(void); char LCD_X_Read01(void); #define LCD_WRITE_A1(Byte) LCD_X_Write01(Byte) #define LCD_WRITE_A0(Byte) LCD_X_Write00(Byte) #define LCD_READ_A1(Result) Result = LCD_X_Read01() #define LCD_READ_A0(Result) Result = LCD_X_Read00()
2002-2007 Micrium
864
CHAPTER 28
LCD_READ_MEM
Description
Reads the video memory of the LCD controller.
Type
Function replacement
Prototype
#define LCD_READ_MEM(Index) Parameter Index
Index of video memory of controller.
Meaning
Additional information
This macro defines how to read the video memory of the LCD controller. In order to configure this switch correctly, you need to know the base address of the video memory, the spacing and if 8/16- or 32-bit accesses are permitted. You should also know the correct syntax for your compiler because this kind of hardware access is not defined in ANSI "C" and is therefore different for different compilers.
LCD_READ_REG
Description
Reads the register of the LCD controller.
Type
Function replacement
Prototype
#define LCD_READ_REG(Index) Parameter Index
Index of the register to read.
Meaning
Additional information
This macro defines how to read the registers of the LCD controller. Usually, the registers are memory-mapped. In this case, the macro can normally be written as a single line. In order to configure this switch correctly, you need to know the address the registers are mapped to, the spacing and if 8/16- or 32-bit accesses are permitted. You should also know the correct syntax for your compiler because this kind of hardware access is not defined in ANSI "C" and is therefore different for different compilers. However, the syntax shown below works with the majority of them.
2002-2007 Micrium
865
Example
If the registers are mapped to a memory area starting at 0xc0000, the spacing is 2 and 16-bit accesses should be used; with most compilers the define should look as follows:
#define LCD_READ_REG(Index) *((U16*)(0xc0000+(Off<<1)))
LCD_WRITE_MEM
Description
Writes data to the video memory of the LCD controller.
Type
Function replacement
Prototype
LCD_WRITE_MEM(Index, Data) Parameter Index Data
Index of video memory of controller. Data to write to the register
Meaning
Additional information
This macro defines how to write to the video memory of the LCD controller. In order to configure this switch correctly, you need to know the base address of the rvideo memory, the spacing and if 8/16- or 32-bit accesses are permitted, as well as the correct syntax for your compiler. With 8-bit accesses, a value of 1 indicates byte 1. With 16-bit accesses, a value of 1 indicates word 1.
LCD_WRITE_REG
Description
Writes data to a specified register of the LCD controller
Type
Function replacement
Prototype
LCD_WRITE_REG(Index, Data) Parameter Index Data
Index of the register to write to Data to write to the register
Meaning
Additional information
This macro defines how to write to the registers of the LCD controller. If the registers are memory-mapped, the macro can normally be written as a single line. In order to configure this switch correctly, you need to know the address the registers are mapped to, the spacing and if 8/16- or 32-bit accesses are permitted, as well as the correct syntax for your compiler. With 8-bit accesses, a value of 1 indicates byte 1. With 16-bit accesses, a value of 1 indicates word 1.
2002-2007 Micrium
866
CHAPTER 28
Example
If the registers are mapped to a memory area starting at 0xc0000, the spacing is 4 and 8-bit access should be used; with most compilers the define should look as follows:
#define LCD_WRITE_REG(Index,Data) *((U8volatile *)(0xc0000+(Off<<2)))=data
LCD_BUSWIDTH
Description
Defines bus-width of LCD controller/CPU interface (external display access).
Type
Selection switch 8: 8-bit wide VRAM 16: 16-bit wide VRAM (default)
Additional information
Since this completely depends on your hardware, you will have to substitute these macros. The Epson SED1352 distinguishes between memory and register access; memory is the video memory of the LCD controller and registers are the 15 configuration registers. The macros define how to access (read/write) VRAM and registers.
LCD_ENABLE_REG_ACCESS
Description
Enables register access and sets the M/R signal to high.
Type
Function replacement
Prototype
#define LCD_ENABLE_REG_ACCESS() MR = 1
Additional Information
Only used for Epson SED1356 and SED1386 controllers. After using this macro, LCD_ENABLE_MEM_ACCESS must also to be defined in order to switch back to memory access after accessing the registers.
LCD_ENABLE_MEM_ACCESS
Description
Switches the M/R signal to memory access. It is executed after register access functions and sets the M/R signal to low.
Type
Function replacement
Prototype
#define LCD_ENABLE_MEM_ACCESS() MR = 0
Additional information
Only used for Epson SED1356 and SED1386 controllers.
2002-2007 Micrium
867
LCD_SWAP_BYTE_ORDER
Description
Inverts the endian mode (swaps the high and low bytes) between CPU and LCD controller when using a 16-bit bus interface.
Type
Binary switch 0: inactive, endian modes not swapped (default) 1: active, endian modes swapped
2002-2007 Micrium
868
CHAPTER 28
Type
Numerical values
Additional information
The values are logical sizes; X-direction specifies the direction which is used as Xdirection by all routines of the LCD driver. If a virtual display is not used, these values should be the same as the values for LCD_XSIZE, LCD_YSIZE (these are the default settings). The virtual display feature requires hardware support and is not available with all drivers.
2002-2007 Micrium
869
Explanation
First segment line used. First common line used.
Example
The following block diagram shows a single display, controlled by a single display controller, using external COM and SEG drivers. All outputs of the common driver (COM0-COM63) are being used, but only some outputs of the segment driver (SEG4SEG91). Note that for simplicity the video RAM is not shown in the diagram.
...
...
64 Pixels vertical
Common Driver
88 Pixels horizontal
LCD
2002-2007 Micrium
SEG 121
LCD Controller
Segment Driver SEG 0 SEG 1 SEG 2 SEG 3 SEG 4 SEG 5 SEG 6 SEG 7 SEG 8
870
CHAPTER 28
Please also note that the above configuration is identical if the COM or SEG lines are mirrored and even if the LCD is built-in sideways (90 turned, X-Y swapped). The same applies if the COM/SEG drivers are integrated into the LCD controller, as is the case for some controllers designed for small LCDs. A typical example for this type of controller would be the Epson SED15XX series.
2002-2007 Micrium
871
Explanation
Number of available display controllers Name of the display driver to be used LCD controller 1: leftmost (lowest) X-position. LCD controller 1: topmost (lowest) Y-position. LCD controller 1: rightmost (lowest) X-position. LCD controller 1: bottommost (lowest) Y-position.
Example
LCD_WRITE_A1(Byte) LCD_WRITE_A0(Byte) LCD_WRITE_A1C1(Byte) LCD_WRITE_A0C1(Byte) ... /* /* /* /* Write Write Write Write byte byte byte byte to to to to controller controller controller controller 0 0 1 1 with with with with RS RS RS RS line line line line high */ low */ high */ low */
2002-2007 Micrium
872
CHAPTER 28
...
...
Common Driver 1
64 Pixels vertical
...
LCD 1
64 Pixels vertical
88 Pixels horizontal
88 Pixels horizontal
LCD 2
segment line used */ com line used */ segment line used */ com line used */
LCD Controller 1
LCD Controller 2
2002-2007 Micrium
873
LCD_LUT_COM
Description
Defines a COM lookup table for the controller.
Type
Alias
Example
Let us assume your display contains only 10 COM lines and their connecting order is 0, 1, 2, 6, 5, 4, 3, 7, 8, 9. To configure the LCD driver so that the COM lines are accessed in the correct order, the following macro should be added to your LCDConf.h:
#define LCD_LUT_COM 0, 1, 2, 6, 5, 4, 3, 7, 8, 9
If you need to modify the segment order, you should use the macro LCD_LUT_SEG in the same manner.
LCD_LUT_SEG
Description
Defines a SEG lookup table for the controller.
Type
Alias
2002-2007 Micrium
874
CHAPTER 28
28.16 Miscellaneous
LCD_DIST_NUM_CONTROLLERS
Description
Defines the number of LCD controllers used.
Type
Numerical value (default is 1)
LCD_CACHE
Description
Controls caching of video memory in CPU memory.
Type
Binary switch 0: disabled, no display data cache used 1: enabled, display data cache used (default)
Additional information
This switch is not supported by all LCD drivers. Using a display data cache (which speeds up access) is recommended if access to the video memory is slow, which is usually the case with larger displays and simple bus interfaces (particularly if port-access or serial interfaces are used). Disabling the cache will slow down the speed of the driver.
LCD_USE_BITBLT
Description
Controls usage of hardware acceleration.
Type
Binary swith 0: disabled, BitBLT engine is not used 1: enabled, BitBLT engine is used (default)
Additional information
Disabling the BitBLT engine will instruct the driver not to use the available hardware acceleration.
LCD_SUPPORT_CACHECONTROL
Description
Switch support for the LCD_L0_ControlCache() function of the driver.
Type
Binary switch 0: disabled, LCD_L0_ControlCache() may not be used (default) 1: enabled, LCD_L0_ControlCache() may be used
Additional information
The API function LCD_L0_ControlCache() permits locking, unlocking, or flushing of the cache. For more information, refer to Chapter 28: "LCD Driver API".
User's & reference manual for C/GUI 2002-2007 Micrium
875
Please note that this feature is intended only for some LCD controllers with simple bus interface, for which it is important to access the controller as little as possible in order to maximize speed. For other controllers, this switch has no effect.
LCD_TIMERINIT0
Description
Timing value used by an interrupt service routine for displaying pane 0 of a pixel.
Type
Numerical value
Additional information
This macro is only relevant when no LCD controller is used, since it is then the job of the CPU to update the display in an interrupt service routine.
LCD_TIMERINIT1
Description
Timing value used by an interrupt service routine for displaying pane 1 of a pixel.
Type
Numerical value
Additional information
This macro is only relevant when no LCD controller is used, since it is then the job of the CPU to update the display in an interrupt service routine.
LCD_ON
Description
Switches the LCD on.
Type
Function replacement
LCD_OFF
Description
Switches the LCD off.
Type
Function replacement
2002-2007 Micrium
876
CHAPTER 28
2002-2007 Micrium
877
2002-2007 Micrium
878
CHAPTER 29
GUI_ALLOC_SIZE
---
GUI_DEBUG_LEVEL
Defines the debug level, which determines how many checks (assertions) are per1 (target) formed by C/GUI and if debug errors, 4 (simulation) warnings and messages are output. Higher debug levels generate bigger code. GUI_BLACK GUI_WHITE Define the default background color. Define the default foreground color.
N N
GUI_DEFAULT_BKCOLOR GUI_DEFAULT_COLOR
GUI_DEFAULT_FONT
Define which font is used as default after GUI_Init() . If you do not use the default font, it makes sense to change to a &GUI_Font6x8 different default, as the default font is referenced by the code and will therefore always be linked. Defines the number of available memory blocks for the memory management of C/ GUI. The maximum number of blocks depends per default on GUI_ALLOC_SIZE .
GUI_MAXBLOCKS
---
2002-2007 Micrium
879
Type
N
Macro
4
Default
Explanation
Define the maximum number of tasks from which C/GUI is called to access the display when multitasking support is enabled (see Chapter 13: "Execution Model: Single Task/Multitask"). This macro allows replacement of the memcpy function. Replacement of the memset function of the GUI. Activate to enable multitasking support with multiple tasks calling C/GUI (see Chapter 13: "Execution Model: Single Task/ Multitask"). Activates the Arabic language support (refer to Chapter 23.2: "Arabic language support"). Per default cursers are enabled if either GUI_SUPPORT_TOUCH or
GUI_MAXTASK
F F
-----
GUI_SUPPORT_ARABIC
GUI_SUPPORT_CURSOR
(see expl.)
GUI_SUPPORT_LARGE_BITMAPS
B B B B
1 0
Enables optional touch-screen support. Enables support for Unicode characters embedded in 8-bit strings. Please note: Unicode characters may always be displayed, as character codes are always treated as 16-bit. Marks the compiler output as evaluation version. Enables optional window manager support.
GUI_SUPPORT_UNICODE
B B
GUI_TRIAL_VERSION GUI_WINSUPPORT
0 0
29.3.1 GUI_ALLOC_SIZE
The dynamic memory is used by the window manager/widget library (optional) and the memory devices (optional). The following gives you an overview of the memory requirements of these modules.
880
CHAPTER 29
<=16bpp uses 2 bytes of RAM. If using the memory device module to prevent the display from flickering when using drawing operations for overlapping items a minimum of 4000 bytes is recommended. If enough RAM is available the allocated size should be sufficient to store the pixels of the largest window plus the memory requirement of the window manager.
Examples
If the 320 x If the 320 x current configuration is 16bpp and the largest window is 320x240 pixels 240 x 2 = 153600 bytes are useful for the memory device module. current configuration is 16bpp and the largest window is 320x240 pixels 240 = 76800 bytes are useful for the memory device module.
29.3.2 GUI_MAXBLOCKS
Defines the maximum number of available memory blocks for the memory management system. Per default it depends on GUI_ALLOC_SIZE and is calculated as follows:
GUI_MAXBLOCKS = (2 + GUI_ALLOC_SIZE / 32)
For the most applications the default is a good value. If an application requires more or less memory blocks it can be configured using the following define (where xxx is the maximum number of blocks):
#define GUI_MAXBLOCKS xxx
29.3.3 GUI_MEMCPY
This macro allows replacement of the memcpy function of the GUI. On a lot of systems, memcpy takes up a considerable amount of time because it is not optimized by the compiler manufacturer. C/GUI contains an alternative memcpy routine, which has been optimized for 32 bit CPUs. On a lot of systems this routine should generate faster code than the default memcpy routine. However, this is still a generic "C"-routine, which in a lot of systems can be replaced by faster code, typically using either a different "C" routine, which is better optimized for the particular CPU or by writing a routine in Assembly language. To use the optimized C/GUI routine add the following define to the file GUIConf.h:
#define GUI_MEMCPY(pSrc, pDest, NumBytes) GUI__memcpy(pSrc, pDest, NumBytes)
29.3.4 GUI_MEMSET
This macro allows replacement of the memset function of the GUI. On a lot of systems, memset takes up a considerable amount of time because it is not optimized by the compiler manufacturer. We have tried to address this by using our own memset() Routine GUI__memset. However, this is still a generic "C"-routine, which in a lot of systems can be replaced by faster code, typically using either a different "C" routine, which is better optimized for the particular CPU, by writing a routine in Assembly language or using the DMA. If you want to use your own memset replacement routine, add the define to the GUIConf.h file.
29.3.5 GUI_TRIAL_VERSION
This macro can be used to mark the compiler output as an evaluation build. It should be defined if the software is given to a third party for evaluation purpose (typically with evaluation boards).
2002-2007 Micrium
881
Note that a special license is required to do this; the most common licenses do not permit redistribution of C/GUI in source or object code (relinkable) form. Please contact [email protected] if you would like to do this. If GUI_TRIAL_VERSION is defined, the following message is shown when calling GUI_Init():
This message is always shown in the upper left corner of the display and is normally visible for 1 second. The timing is implemented by a call GUI_X_Delay(1000). The functionality of C/GUI is in no way limited if this switch is active.
Sample
#define GUI_TRIAL_VERSION 1
Explanation Init routine GUI_Init() ; can be used to initialize hardware. Timing routines
Return after a given period. Called only from non-blocking functions of window manager. Return the system time in milliseconds.
Debugging
Return debug information; required if logging is enabled.
882
CHAPTER 29
Prototype
void GUI_X_Init(void);
Prototype
void GUI_X_Delay(int Period) Parameter Period
Period in milliseconds.
Meaning
GUI_X_ExecIdle()
Description
Called only from non-blocking functions of the window manager.
Prototype
void GUI_X_ExecIdle(void);
Additional information
Called when there are no longer any messages which require processing. In this case the GUI is up to date.
GUI_X_GetTime()
Description
Used by GUI_GetTime to return the current system time in milliseconds.
Prototype
int GUI_X_GetTime(void)
Return value
The current system time in milliseconds, of type integer.
2002-2007 Micrium
883
29.8 Debugging
GUI_X_ErrorOut(), GUI_X_Warn(), GUI_X_Log()
Description
These routines are called by C/GUI with debug information in higher debug levels in case a problem (Error) or potential problem is discovered. The routines can be blank; they are not required for the functionality of C/GUI. In a target system, they are typically not required in a release (production) build, since a production build typically uses a lower debug level. Fatal errors are output using GUI_X_ErrorOut() if (GUI_DEBUG_LEVEL >= 3) Warnings are output using GUI_X_Warn() if (GUI_DEBUG_LEVEL >= 4) Messages are output using GUI_X_Log() if (GUI_DEBUG_LEVEL >= 5)
Prototypes
void GUI_X_ErrorOut(const char * s); void GUI_X_Warn(const char * s); void GUI_X_Log(const char * s); Parameter s
Pointer to the string to be sent.
Meaning
Additional information
This routine is called by C/GUI to tramsmit error messages or warnings, and is required if logging is enabled. The GUI calls this function depending on the configuration macro GUI_DEBUG_LEVEL. The following table lists the permitted values for GUI_DEBUG_LEVEL: Value 0 1 2 3 4 5 Symbolic name GUI_DEBUG_LEVEL_NOCHECK GUI_DEBUG_LEVEL_CHECK_PARA GUI_DEBUG_LEVEL_CHECK_ALL GUI_DEBUG_LEVEL_LOG_ERRORS GUI_DEBUG_LEVEL_LOG_WARNINGS GUI_DEBUG_LEVEL_LOG_ALL Explanation
No run-time checks are performed. Parameter checks are performed to avoid crashes. (Default for target system) Parameter checks and consistency checks are performed. Errors are recorded. Errors and warnings are recorded. (Default for PC-simulation) Errors, warnings and messages are recorded.
Explanation
Used to allocate a memory block, returns a memor handle. Used to release a memory block.
2002-2007 Micrium
884
CHAPTER 29
Type
F F A
Macro
Explanation
GUI_ALLOC_GETMAXSIZE() Returns the maximum number of bytes of available memory. Converts a memory handle to a memory pointer. GUI_ALLOC_H2P(hMem) Type of a memory handle. GUI_HMEM
GUI_ALLOC_ALLOC
Description
Allocates a memory block and returns a handle to it.
Type
Function replacement.
Prototype
#define GUI_ALLOC_ALLOC(Size) Parameter Size
Size of required memory block
Meaning
Example
#define GUI_ALLOC_ALLOC(Size) malloc(Size)
GUI_ALLOC_FREE
Description
Releases a memory block.
Type
Function replacement.
Prototype
#define GUI_ALLOC_FREE(pMem) Parameter pMem Meaning
Pointer to memory block to be released.
Example
#define GUI_ALLOC_FREE(pMem) free(pMem)
GUI_ALLOC_GETMAXSIZE
Description
Returns the maximum number of bytes of available memory.
Type
Function replacement.
Prototype
#define GUI_ALLOC_GETMAXSIZE()
Example
#define GUI_ALLOC_GETMAXSIZE() 10000 User's & reference manual for C/GUI 2002-2007 Micrium
885
GUI_ALLOC_H2P
Description
Converts a memory handle to a memory pointer.
Type
Function replacement.
Prototype
#define GUI_ALLOC_H2P(hMem) Parameter hMem Meaning
Memory handle to be converted to a memory pointer.
Example
#define GUI_ALLOC_H2P(hMem) hMem
GUI_HMEM
Description
Defines the type of a memory handle.
Type
Text replacement.
Example
#define GUI_HMEM void *
Example
The following sample is an excerpt from the GUIConf.h which uses the standard dynamic memory system:
#include <malloc.h> #include <memory.h> #define #define #define #define #define GUI_HMEM GUI_ALLOC_ALLOC(Size) GUI_ALLOC_FREE(pMem) GUI_ALLOC_H2P(hMem) GUI_ALLOC_GETMAXSIZE() void * malloc(Size) free(pMem) hMem 10000
Default
const
Explanation
Define "universal pointer". Define const storage.
2002-2007 Micrium
886
CHAPTER 29
GUI_UNI_PTR
Description
Defines a "universal pointer" which can point to RAM and flash ROM. On some systems it can be necessary since a default pointer can access RAM only, not the built-in Flash.
Type
Alias.
Example
#define GUI_UNI_PTR __generic
GUI_CONST_STORAGE
Description
Defines the const storage. On some systems it can be necessary since otherwise constants are copied into RAM.
Type
Alias.
Example
#define GUI_CONST_STORAGE __flash const
Macro GUI_COMPILER_SUPPORTS_FP 1
Default
Explanation
Set to 0 if the compiler does not support complex function calls via function pointers.
GUI_COMPILER_SUPPORTS_FP
Description
Used to enable/disable the use of complex function pointers.
Type
Alias.
Example
#define GUI_COMPILER_SUPPORTS_FP 0 /* Disable the use of complex function pointers */
2002-2007 Micrium
887
Additional information
Disabling this config switch will make it possible to use the software even with very limited "C"-compilers for small chips. Howver, this comes at a price: The available functionality is limited as well. The following limitations apply in this case: - Text rotation can not be used - Compressed bitmaps can not be used - Higher level software, such as memory devices, window manager & VNC server can not be used - Antialiasing can not be used - Some other (smaller) restrictions may apply.
2002-2007 Micrium
888
CHAPTER 29
2002-2007 Micrium
889
2002-2007 Micrium
890
CHAPTER 30
30.1 Performance
The following chapter shows driver benchmarks on different targets and performance values of image drawing operations.
CPU
M16C/60 (16 bit), 16MHz M16C/60 (16 bit), 16MHz M16C/80 (16 bit), 20MHz M16C/80 (16 bit), 20MHz M16C/80 (16 bit), 20MHz V850SB1 (32 bit), 20MHz V850SB1 (32 bit), 20MHz ARM720T (32 bit), 50MHz
SED1560 (1560) T6963 (6963) S1D13705 (1375) S1D13705 (1375) S1D13705 (1375) S1D13806 (1375) S1D13806 (1375) internal LCDController (3200)
1 1 1 4 8 8 16 16
Bench1: Filling
Bench the speed of filling. An area of 64*64 pixels is filled with different colors.
2002-2007 Micrium
Bench1 Filling
bpp
891
Megapixels / second
17.186 3.897 4.017 4.478 13.363 1.336 1.671 6.144 6.806 3.740 4.115 1.134 1.544 1.525 6.998 6.345 1.285 0.516 0.438 0.402 0.280 0.602 0.431
2002-2007 Micrium
892
CHAPTER 30
ROM
+ 6.2 kB
RAM
+ 2.5 kB
Explanation
Additional memory requirements of a Hello world application when using the window manager. The configured GUI_ALLOC_SIZE for the measurement was 2000. Additional memory requirements of a Hello world application when using memory devices. The configured GUI_ALLOC_SIZE for the measurement was 8000. Additional memory requirements for the antialiasing software item. The memory requirements of the driver depend on the configured driver and if a data cache is used or not. With a data cache the driver requires more RAM. For details please refer to the driver documentation. If working with a multi layer or a multi display configuration additional memory for each additional layer is required, because each layer requires its own driver. Memory requirements of a typicall Hello world application without using additional software items. Basic routines for drawing JPEG files. Basic routines for drawing GIF files. Routines for drawing sprites and cursors. Please refer to the font subchapter for details about the ROM requirements of the standard fonts shipped with C/GUI. This is the approximately basic ROM requirement for the widgets depending on the individual core functions used by the widgets. *1 *1 *1 *1 *1 *1 *1
Memory devices
+ 4.7 kB
+ 7 kB + 2 * LCD_XSIZE
Antialiasing
+ 4.5 kB
Driver
+ 2 - 8 kB
20
Multilayer
+ 2 - 8 kB
5.2 kB 12 kB 3.3 kB 4.7 kB (see explanation) 4.5 kB BUTTON CHECKBOX DROPDOWN EDIT 1 kB 1 kB 1.8 kB 2.2 kB 2.2 kB 2.9 kB 0.7 kB
80 Byte 38 kB 17 kB 16 Byte -
12 Bytes 48 Bytes -
2002-2007 Micrium
893
Component
Widget / GRAPH_DATA_YT Widget / HEADER Widget / LISTBOX Widget / LISTVIEW Widget / MENU Widget / MULTIEDIT Widget / MULTIPAGE Widget / PROGBAR Widget / RADIOBUTTON Widget / SCROLLBAR Widget / SLIDER Widget / TEXT
ROM
0.6 kB 2.8 kB 3.7 kB 3.6 kB 5.7 kB 7.1 kB 3.9 kB 1.3 kB 1.4 kB 2 kB 1.3 kB 0.4 kB -
RAM
*1 *1 *1 *1 *1 *1 *1 *1 *1 *1 *1 *1
Explanation
32 Bytes 56 Bytes 44 Bytes 52 Bytes 16 Bytes 32 Bytes 20 Bytes 32 Bytes 14 Bytes 16 Bytes 16 Bytes
*1. The listed memory requirements of the widgets contain the basic routines required for creating and drawing the widget. Depending of the specific widget there are several additional functions available which are not listed in the table.
Application
Application
Sample
GUI core
GUI core
Library
Fonts
Stack
Total
ROM
Window Hello world application
RAM
5.9 kB
1.8 kB
38
0.3 kB
0.1 kB
8.1 kB
62
272
334
43 kB
12.5 kB
2.7 kB
0.3 kB
1.5 kB
60 kB
5.2 kB
40
1.4 kB
6.6 kB
For details about the samples please refer to the following sections.
2002-2007 Micrium
Total
894
CHAPTER 30
30.3.1.1 Configuration
The following excerpts of the files GUIConf.h and LCDConf.h shows the used configuration options.
GUIConf.h:
#define #define #define #define #define #define GUI_WINSUPPORT GUI_SUPPORT_TOUCH GUI_SUPPORT_MOUSE GUI_SUPPORT_MEMDEV GUI_SUPPORT_AA GUI_DEFAULT_FONT 0 0 0 0 0 &GUI_Font6x8
LCDConf.h:
#define #define #define #define LCD_CONTROLLER LCD_BITSPERPIXEL LCD_MAX_LOG_COLORS LCD_CACHE 6963 1 2 0
30.3.1.2 System
The following table shows the hardware and the toolchain details of the project: Detail
CPU Toolchain Memory model Compile options
Description
M16C IAR embedded workbench version 1.36A near Size optimisation (-z9)
ROM
5.9 kB 1.8 kB 38 Bytes -0.3 kB 71 Bytes
RAM
62 Bytes --272 Bytes ---
2002-2007 Micrium
895
30.3.2.1 Configuration
The following excerpts of the files GUIConf.h and LCDConf.h shows the used configuration options.
GUIConf.h:
#define #define #define #define #define #define #define #define #define #define #define #define #define #define #define GUI_WINSUPPORT 1 GUI_SUPPORT_TOUCH 0 GUI_SUPPORT_MOUSE 1 GUI_SUPPORT_MEMDEV 0 GUI_SUPPORT_AA 0 GUI_MAXBLOCKS 160 GUI_ALLOC_SIZE 3500 BUTTON_FONT_DEFAULT &GUI_Font13_ASCII DROPDOWN_FONT_DEFAULT &GUI_Font13_ASCII EDIT_FONT_DEFAULT &GUI_Font13_ASCII HEADER_FONT_DEFAULT &GUI_Font13_ASCII LISTBOX_FONT_DEFAULT &GUI_Font13_ASCII LISTVIEW_FONT_DEFAULT &GUI_Font13_ASCII TEXT_FONT_DEFAULT &GUI_Font13_ASCII GUI_DEFAULT_FONT &GUI_Font6x8
LCDConf.h:
#define LCD_CONTROLLER #define LCD_BITSPERPIXEL 1375 8
30.3.2.2 System
The following table shows the hardware and the toolchain details of the project: Detail
CPU Toolchain Code model Compile options
Description
ARM AT91 IAR embedded workbench version 3.40A small Size optimization high
ROM
43 kB 12.5 kB 2.7 kB --
RAM
5.2 kB -40 1.4 kB
2002-2007 Micrium
896
CHAPTER 30
Description
Startup code Library
ROM
0.3 kB 1.5 kB ---
RAM
Total 60 kB 6.6 kB
2002-2007 Micrium
897
Chapter 31 Support
This chapter should help if any problem occurs. This could be a problem with the tool chain, with the hardware, the use of the GUI functions or with the performance and it describes how to contact the C/GUI support.
2002-2007 Micrium
898
CHAPTER 31
Support
899 } static void _Test(void) { int Result; tFunc * pFunc; pFunc = _Func; Result = pFunc(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); }
If the sample above can not be compiled, only the core C/GUI version can be used. The additional C/GUI packages like the window manager or the memory device module sometimes need to pass up to 10 parameters with a function pointer call. The core C/GUI package needs only up to 2 parameters in a function pointer call. But you can also use C/GUI if your compiler only supports one argument in a function pointer call. If so some functions are not available, for example rotating text or UTF8 encoding. For details about how to configure C/GUI in this case take a look at the chapter High-Level Configuration.
Contacting support
If this manual does not contain all help you need to configure C/GUI to work with your compiler, please contact the C/GUI support. Please send the following: A detailed description of the problem The configuration file GUIConf.h The configuration file LCDConf.h The error messages of the compiler
Executable to large
Some linkers are not able to link only the modules/functions referenced by the project. This results is an executable with a lot of unused code. In this case the use of a library would be very helpful. For detailes about how to build a C/GUI library please take a look at the chapter Getting started.
2002-2007 Micrium
900
CHAPTER 31
Support
Contacting support
If you need to contact the C/GUI support, please send the following information: A detailed description of the problem The configuration file GUIConf.h The configuration file LCDConf.h If using a simple bus interface please send the hardware routines including the configuration.
2002-2007 Micrium
901
The difference between the used time by the real driver and the LCDNull driver shows the execution time spent in the real hardware driver.
Contacting support
If you need to contact the C/GUI support in case of performance problems, please send the following informations to the support: A detailed description of the problem may as comment in the sample code. The configuration file GUIConf.h. The configuration file LCDConf.h. A sample source file which can be compiled in the simulation without any additional files.
2002-2007 Micrium
902
CHAPTER 31
Support
Problem report
The following file can be used as a starting point when creating a problem report. Please also fill in the CPU, the used tool chain and the problem description. It can be found under Sample\GUI\ProblemReport.c:
/********************************************************************* * Micrium Inc. * * Empowering embedded systems * * * * uC/GUI problem report * * * ********************************************************************** ---------------------------------------------------------------------File : ProblemReport.c CPU : Compiler/Tool chain : Problem description : ---------------------------------------------------------------------*/ #include "GUI.h" /* Add further GUI header files here as required. */ /******************************************************************* * * Static code * ******************************************************************** * * Please insert helper functions here if required. */ /******************************************************************* * * MainTask */ void MainTask(void) { GUI_Init(); /* To do: Insert the code here which demonstrates the problem. */ while (1); /* Make sure program does not terminate */ }
31.6 FAQs
Q: A: I use a different LCD controller. Can I still use C/GUI? Yes. The hardware access is done in the driver module and is completely independent of the rest of the GUI. The appropriate driver can be easily written for any controller (memory-mapped or bus-driven). Please get in touch with us. Which CPUs can I use C/GUI with? C/GUI can be used with any CPU (or MPU) for which a "C" compiler exists. Of course, it will work faster on 16/32-bit CPUs than on 8-bit CPUs. Is C/GUI flexible enough to do what I want to do in my application? C/GUI should be flexible enough for any application. If for some reason you do not think it is in your case, please contact us. Believe it or not, the source code is available. Does C/GUI work in a multitask environment? Yes, it has been designed with multitask kernels in mind.
Q: A: Q: A:
Q: A:
2002-2007 Micrium
903
2002-2007 Micrium
904
CHAPTER 31
Support
2002-2007 Micrium
905
Index
Symbols "C" compiler 32, 49, 211 "C" files converting bitmaps into 209, converting fonts into 179 inclusion of in uC/GUI 43 "C" programming language 31 MESSAGEBOX widget 567 Multi layer 673 MULTIEDIT widget 571 MULTIPAGE widget 584 pointer input devices (PID) 679 PROGBAR widget 597 PS2 mouse driver 682 RADIO widget 607 routines common to all widgets 354 SCROLLBAR widget 619 SLIDER widget 626 Sprites 698 text 76 TEXT widget 633 values 92 VNC 837 window manager 305 WINDOW widget 639 WM routines used for widgets 354 Application program interface (API) 34, 821 Arcs, drawing 127129 ASCII 76, 157, 176, 178 Auto device object 270275
210
Numerics 3 pin SPI, configuration 859 4 pin SPI, configuration 860861 A Access addresses, defining 45 Access routines, defining 45 Active window 290 Additional software 43 Alias macro 44 Aliasing 707 ANSI 31, 32, 864 Antialiasing 707720 of fonts 707, 709 qualities 707, 708 software for 707 with high-resolution coordinates 707, API reference antialising 711 BMP file support 134 BUTTON widget 360 CHECKBOX widget 380 colors 244 cursors 704 device simulator 54 EDIT widget 395, 408, 481, 522 fonts 163 FRAMEWIN widget 429 generic touch-screen 683 GIF file support 146 GRAPH widget 456 graphics 104 hardkey simulator 58 JPEG file API 141 kernel interface routines 285287 LCD driver 822 LCD layer 822 LISTBOX widget 496 memory devices 253 MENU widget 551
User's & reference manual for C/GUI
709710
B Background window 293 Banding memory device 267270 Best palette option 217, 221, 223 Binary switch macro 44 Binary values, displaying 99100 Bitmap converter 33, 209226 supported input formats 210 using for color conversion 217218 Bitmap file support 134 Bitmaps 209226 color conversion of 217218 device-dependent (DDB) 211 device-independent (DIB) 211 drawing 113116 full-color mode 211, 217 generating "C" files from 209, 210 generating C files from 211217 manipulating 210 RLE compressed 211, 218, 224 Blocking dialog 642 BmpCvt.exe 221 Bottom window 291 Button widget 350, 359377
2002-2007 Micrium
906
Index
BUTTON_3D_MOVE_X 359 BUTTON_3D_MOVE_Y 359 BUTTON_ALIGN_DEFAULT 359 BUTTON_BI_DISABLED 363, 366 BUTTON_BI_PRESSED 363, 366 BUTTON_BI_UNPRESSED 363, 366 BUTTON_BKCOLOR0_DEFAULT 359 BUTTON_BKCOLOR1_DEFAULT 359 BUTTON_CI_DISABLED 363, 364, 365,
367, 368,
370
BUTTON_CI_PRESSED
370
BUTTON_CI_UNPRESSED
368, 370
BUTTON_Create 361 BUTTON_CreateEx 362 BUTTON_CreateIndirect 362 BUTTON_FOCUSCOLOR_DEFAULT 359 BUTTON_FONT_DEFAULT 359 BUTTON_GetBitmap 362 BUTTON_GetBkColor 363 BUTTON_GetDefaultBkColor 363 BUTTON_GetDefaultFont 364 BUTTON_GetDefaultTextAlign 364 BUTTON_GetDefaultTextColor 364 BUTTON_GetFont 365 BUTTON_GetText 365 BUTTON_GetTextColor 365 BUTTON_IsPressed 366 BUTTON_REACT_ON_LEVEL 359 BUTTON_SetBitmap 366 BUTTON_SetBitmapEx 366 BUTTON_SetBkColor 367 BUTTON_SetBMP 367 BUTTON_SetBMPEx 368 BUTTON_SetDefaultBkColor 368 BUTTON_SetDefaultFocusColor 369 BUTTON_SetDefaultFont 369 BUTTON_SetDefaultTextAlign 369 BUTTON_SetDefaultTextColor 369 BUTTON_SetFocusColor 370 BUTTON_SetFocussable 370 BUTTON_SetFont 371 BUTTON_SetPressed 371 BUTTON_SetStreamedBitmap 371 BUTTON_SetStreamedBitmapEx 372 BUTTON_SetText 372 BUTTON_SetTextAlign 372 BUTTON_SetTextColor 373 BUTTON_TEXTCOLOR0_DEFAULT 359 BUTTON_TEXTCOLOR1_DEFAULT 359 C C files converting bitmaps into
211217
Callback mechanism 33, 291303 Callback routines 58, 290 using 292303 Character sets 176178 Check box widget 350, 378393 CHECKBOX_ALIGN_DEFAULT 379 CHECKBOX_BKCOLOR_DEFAULT 379 CHECKBOX_BKCOLOR0_DEFAULT 379 CHECKBOX_BKCOLOR1_DEFAULT 379 CHECKBOX_Check 381 CHECKBOX_Create 381 CHECKBOX_CreateEx 382 CHECKBOX_CreateIndirect 381 CHECKBOX_FGCOLOR0_DEFAULT 379 CHECKBOX_FGCOLOR1_DEFAULT 379 CHECKBOX_FOCUSCOLOR_DEFAULT 379 CHECKBOX_FONT_DEFAULT 379 CHECKBOX_GetDefaultBkColor 382 CHECKBOX_GetDefaultFont 383 CHECKBOX_GetDefaultSpacing 383 CHECKBOX_GetDefaultTextAlign 383 CHECKBOX_GetDefaultTextColor 383 CHECKBOX_GetState 384 CHECKBOX_GetText 384 CHECKBOX_IMAGE0_DEFAULT 379 CHECKBOX_IMAGE1_DEFAULT 379 CHECKBOX_IsChecked 385 CHECKBOX_SetBkColor 385 CHECKBOX_SetBoxBkColor 385 CHECKBOX_SetDefaultBkColor 386 CHECKBOX_SetDefaultFocusColor 386 CHECKBOX_SetDefaultFont 387 CHECKBOX_SetDefaultImage 387 CHECKBOX_SetDefaultSpacing 388 CHECKBOX_SetDefaultTextAlign 388 CHECKBOX_SetDefaultTextColor 388 CHECKBOX_SetFocusColor 389 CHECKBOX_SetImage 389 CHECKBOX_SetNumStates 390 CHECKBOX_SetSpacing 390 CHECKBOX_SetState 391 CHECKBOX_SetText 391 CHECKBOX_SetTextAlign 392 CHECKBOX_SetTextColor 392 CHECKBOX_SPACING_DEFAULT 379 CHECKBOX_TEXTCOLOR_DEFAULT 379 CHECKBOX_Uncheck 393 Child window 290, 312 Circles, drawing 125126 Client area, of windows 290 Clip area, of windows 290 Clipping 103, 290 Color bar test routine 228230 Color conversion, of bitmaps 210, 217218 Color lookup table (LUT) 243
2002-2007 Micrium
907
Color palettes best palette option 217, 221, 223 custom 218219, 243 fixed 217, 230241 Colors 227248 converting 227 logical 227 physical 227 predefined 228 COM/SEG lines configuration 869873 lookup tables for 873 Command line usage of bitmap converter 221222 Compile time switches 33 Compiling, with simulator demo program 51, 53 for your application 53 samples 51 Config folder 44, 53, 690, 845 Configuration, of uC/GUI high-level 877887 low-level 845875 Control characters 76, 157 Controls (see Widgets) Coordinates 35, 290, 709710 high-resolution 707, 709710 CPU load, when used as LCD controller 761 Cursors 703706 available styles 704 Custom palettes defining for hardware 243 file formats, for color conversion 219 for color conversion 218219 D Data types 37 Decimal values, displaying 9296 Demos 34 Depth coordinate 291 Desktop coordinates 290 Desktop window 290 Device simulation 5457 Device.bmp 54, 58 Device1.bmp 54, 57, 58 Device-dependent bitmap (DDB) 211 Device-independent bitmap (DIB) 211 Dialogs 641649 blocking 642 non-blocking 642 Directories, inclusion of 40 Directory structure for simulator 52 for uC/GUI 40 for Visual C++ workspace 53
User's & reference manual for C/GUI
Display driver 737831 Displaying bitmap files 133155 Drawing modes 105106 Dropdown widget 350, 394406 DROPDOWN_AddString 396 DROPDOWN_ALIGN_DEFAULT 394 DROPDOWN_BKCOLOR0_DEFAULT 394 DROPDOWN_BKCOLOR1_DEFAULT 394 DROPDOWN_BKCOLOR2_DEFAULT 394 DROPDOWN_CF_AUTOSCROLLBAR 397 DROPDOWN_CF_UP 397 DROPDOWN_Collapse 396 DROPDOWN_Create 396 DROPDOWN_CreateEx 397 DROPDOWN_DecSel 397 DROPDOWN_Expand 398 DROPDOWN_FONT_DEFAULT 394 DROPDOWN_GetItemDisabled 398 DROPDOWN_GetNumItems 399 DROPDOWN_GetSel 399 DROPDOWN_IncSel 399 DROPDOWN_InsertString 399 DROPDOWN_KEY_EXPAND 394 DROPDOWN_KEY_SELECT 394 DROPDOWN_SetAutoScroll 400 DROPDOWN_SetBkColor 400, 403, 511 DROPDOWN_SetColor 401 DROPDOWN_SetDefaultColor 401 DROPDOWN_SetDefaultFont 402 DROPDOWN_SetDefaultScrollbarColor 402 DROPDOWN_SetFont 402 DROPDOWN_SetItemDisabled 403 DROPDOWN_SetItemSpacing 405 DROPDOWN_SetScrollbarWidth 404 DROPDOWN_SetSel 404 DROPDOWN_SetTextAlign 405 DROPDOWN_SetTextColor 405 DROPDOWN_SetTextHeight 406 DROPDOWN_TEXTCOLOR0_DEFAULT 394 DROPDOWN_TEXTCOLOR1_DEFAULT 394 DROPDOWN_TEXTCOLOR2_DEFAULT 394 DROPROWN_DeleteItem 398 E Edit widget 350, 407426 EDIT_AddKey 409, 575, 576,
581
EDIT_ALIGN_DEFAULT 407 EDIT_BKCOLOR0_DEFAULT 407 EDIT_BKCOLOR1_DEFAULT 407 EDIT_BORDER_DEFAULT 407 EDIT_Create 410 EDIT_CreateAsChild 410 EDIT_CreateEx 411 EDIT_CreateIndirect 411
2002-2007 Micrium
908
Index
EDIT_EnableBlink 411 EDIT_FONT_DEFAULT 407 EDIT_GetCursorCharPos 412 EDIT_GetCursorPixelPos 412 EDIT_GetDefaultBkColor 412 EDIT_GetDefaultFont 413 EDIT_GetDefaultTextAlign 413 EDIT_GetDefaultTextColor 413 EDIT_GetFloatValue 414 EDIT_GetNumChars 414 EDIT_GetText 414 EDIT_GetValue 414 EDIT_SetBinMode 415 EDIT_SetBkColor 415 EDIT_SetCursorAtChar 415 EDIT_SetCursorAtPixel 416 EDIT_SetDecMode 416 EDIT_SetDefaultBkColor 417 EDIT_SetDefaultFont 417 EDIT_SetDefaultTextAlign 417 EDIT_SetDefaultTextColor 417 EDIT_SetFloatMode 418 EDIT_SetFloatValue 418 EDIT_SetFont 418 EDIT_SetHexMode 419 EDIT_SetInsertMode 419 EDIT_SetMaxLen 420 EDIT_SetpfAddKeyEx 420 EDIT_SetSel 420 EDIT_SetText 421 EDIT_SetTextAlign 421 EDIT_SetTextColor 421 EDIT_SetTextMode 422 EDIT_SetUlongMode 422 EDIT_SetValue 422 EDIT_TEXTCOLOR0_DEFAULT 407 EDIT_TEXTCOLOR1_DEFAULT 407 EDIT_XOFF 407 Ellipses, drawing 126127 Execution model 279287 supported types 280 F Fixed color palettes 217 Fixed palette modes 230241 Flickering of display 249, 339 Floating-point calculations 103 Floating-point values, displaying 9699 Font converter 33, 159, 179, 709, 733 Font editor 179 Font files linking 159, 179 naming convention 181 Fonts 33, 157207 adding 179
User's & reference manual for C/GUI
antialiased 158, 707, 709 converting (see Font converter) creating additional 159 declaring 159, 179 default 162 defining 33 Digit fonts (monospaced) 206207 Digit fonts (proportional) 204205 editing 179 External Bitmap Fonts (XBF) 160 file naming convention 181 generating "C" files from 179 included with uC/GUI 157 monospaced 158, 180, 195203 naming convention 180181 proportional 158, 180, 182194 scaling 33 selecting 162164 System Independent Fonts (SIF) 160 usage of 159 Foreign Language Support 721736 Frame window widget 350, 427452 FRAMEWIN_AddButton 430 FRAMEWIN_AddCloseButton 431 FRAMEWIN_AddMaxButton 432 FRAMEWIN_AddMenu 433, 449 FRAMEWIN_AddMinButton 434 FRAMEWIN_ALLOW_DRAG_ON_FRAME 429 FRAMEWIN_BARCOLOR_ACTIVE_DEFAULT 429 FRAMEWIN_BARCOLOR_INACTIVE_DEFAULT
429
FRAMEWIN_BORDER_DEFAULT 429 FRAMEWIN_CLIENTCOLOR_DEFAULT 429 FRAMEWIN_Create 434 FRAMEWIN_CreateAsChild 435 FRAMEWIN_CreateEx 435 FRAMEWIN_DEFAULT_FONT 429 FRAMEWIN_FRAMECOLOR_DEFAULT 429 FRAMEWIN_GetActive 436 FRAMEWIN_GetBarColor 437 FRAMEWIN_GetBorderSize 437 FRAMEWIN_GetDefaultBarColor 437 FRAMEWIN_GetDefaultBorderSize 438 FRAMEWIN_GetDefaultClientColor 438 FRAMEWIN_GetDefaultFont 438 FRAMEWIN_GetDefaultTextColor 438, 446 FRAMEWIN_GetDefaultTitleSize 440 FRAMEWIN_GetFont 439 FRAMEWIN_GetText 439 FRAMEWIN_GetTextAlign 439 FRAMEWIN_GetTitleHeight 440 FRAMEWIN_IBORDER_DEFAULT 429 FRAMEWIN_IsMaximized 440 FRAMEWIN_IsMinimized 441 FRAMEWIN_Maximize 441
2002-2007 Micrium
909
FRAMEWIN_Minimize 442 FRAMEWIN_OwnerDraw 442 FRAMEWIN_Restore 443 FRAMEWIN_SetActive 443 FRAMEWIN_SetBarColor 444 FRAMEWIN_SetBorderSize 444 FRAMEWIN_SetClientColor 445 FRAMEWIN_SetDefaultBarColor 445 FRAMEWIN_SetDefaultBorderSize 445 FRAMEWIN_SetDefaultClient Color 446 FRAMEWIN_SetDefaultFont 446 FRAMEWIN_SetDefaultTitleHeight 446 FRAMEWIN_SetFont 447 FRAMEWIN_SetMoveable 447 FRAMEWIN_SetOwnerDraw 448 FRAMEWIN_SetText 449 FRAMEWIN_SetTextAlign 450 FRAMEWIN_SetTextColor 450 FRAMEWIN_SetTextColorEx 451 FRAMEWIN_SetTitleHeight 451 FRAMEWIN_SetTitleVis 452 FRAMEWIN_TITLEHEIGHT_DEFAULT 429 Full bus interface, configuration 864867 Full-color mode, of bitmaps 211, 217 Function replacement macro 44 Function-level linking 41 G Getting Started 3947 GIF file support 146 Graph widget 350, 453479 GRAPH_AttachData 457 GRAPH_AttachScale 458 GRAPH_CreateEx 458 GRAPH_DATA_XY_AddPoint 470 GRAPH_DATA_XY_Create 470 GRAPH_DATA_XY_Delete 471 GRAPH_DATA_XY_SetLineStyle 472 GRAPH_DATA_XY_SetOffX 471 GRAPH_DATA_XY_SetPenSize 473 GRAPH_DATA_YT_AddValue 467 GRAPH_DATA_YT_Create 467 GRAPH_DATA_YT_Delete 468 GRAPH_DATA_YT_SetOffY 469 GRAPH_DetachData 459 GRAPH_SCALE_Create 473 GRAPH_SCALE_Delete 474 GRAPH_SCALE_SetFactor 474 GRAPH_SCALE_SetFont 475 GRAPH_SCALE_SetNumDecs 476 GRAPH_SCALE_SetOff 476 GRAPH_SCALE_SetPos 477 GRAPH_SCALE_SetTextColor 478 GRAPH_SCALE_SetTickDist 478 GRAPH_SetBorder 460
User's & reference manual for C/GUI
GRAPH_SetColor 461 GRAPH_SetGridFixedX 462 GRAPH_SetGridOffY 462 GRAPH_SetGridSpacingX 461 GRAPH_SetGridSpacingY 461 GRAPH_SetGridVis 463 GRAPH_SetLineStyleH 464 GRAPH_SetLineStyleV 464 GRAPH_SetUserDraw 466 GRAPH_SetVSizeX 465 GRAPH_SetVSizeY 465 Graphic library 33, 103132, 841 Grayscales 217, 227 GUI configuration 878880 GUI subdirectories 40, 53 GUI_AA_DisableHiRes 711 GUI_AA_DrawArc 712 GUI_AA_DrawLine 713 GUI_AA_DrawPolyOutline 713 GUI_AA_DrawPolyOutlineEx 714 GUI_AA_EnableHiRes 711 GUI_AA_FillCircle 715 GUI_AA_FillPolygon 715 GUI_AA_GetFactor 711 GUI_AA_SetFactor 712 GUI_ALLOC_ALLOC 884 GUI_ALLOC_FREE 884 GUI_ALLOC_GETMAXSIZE 884 GUI_ALLOC_H2P 885 GUI_ALLOC_SIZE 878 GUI_AssignCursorLayer 673 GUI_AUTODEV 270 GUI_AUTODEV_INFO 271 GUI_BITMAP structures 210 GUI_BMP_Draw 134 GUI_BMP_DrawEx 135 GUI_BMP_DrawScaled 136 GUI_BMP_DrawScaledEx 136 GUI_BMP_GetXSize 137 GUI_BMP_GetXSizeEx 137 GUI_BMP_GetYSize 138 GUI_BMP_GetYSizeEx 138 GUI_BMP_Serialize 138 GUI_BMP_SerializeEx 139 GUI_Clear 88 GUI_ClearKeyBuffer 695 GUI_ClearRect 108 GUI_Color2Index 246 GUI_COMPILER_SUPPORTS_FP 886 GUI_CONST_STORAGE 885, 886 GUI_CURSOR_GetState 705 GUI_CURSOR_Hide 705 GUI_CURSOR_Select 705 GUI_CURSOR_SetPosition 706 GUI_CURSOR_Show 706
2002-2007 Micrium
910
Index
GUI_DEBUG_LEVEL 878 GUI_DEFAULT_BKCOLOR 878 GUI_DEFAULT_COLOR 878 GUI_DEFAULT_FONT 878 GUI_Delay 841, 842 GUI_DispBin 99 GUI_DispBinAt 100 GUI_DispCEOL 89 GUI_DispChar 77 GUI_DispCharAt 78 GUI_DispChars 78 GUI_DispDec 92 GUI_DispDecAt 93 GUI_DispDecMin 94 GUI_DispDecShift 94 GUI_DispDecSpace 94 GUI_DispFloat 96 GUI_DispFloatFix 97 GUI_DispFloatMin 98 GUI_DispHex 100 GUI_DispHexAt 101 GUI_DispNextLine 79 GUI_DispSDec 95 GUI_DispSDecShift 95 GUI_DispSFloatFix 98 GUI_DispSFloatMin 99 GUI_DispString 79 GUI_DispStringAt 79 GUI_DispStringAtCEOL 80 GUI_DispStringHCenterAt 80 GUI_DispStringInRect 80 GUI_DispStringInRectWrap 82 GUI_DispStringLen 83 GUI_DrawArc 127 GUI_DrawBitmap 113 GUI_DrawBitmapEx 114 GUI_DrawBitmapExp 114 GUI_DrawBitmapHWAlpha 115 GUI_DrawBitmapMag 115 GUI_DrawCircle 125 GUI_DrawEllipse 126 GUI_DrawGradientH 108, 109 GUI_DrawGraph 129 GUI_DrawHLine 116 GUI_DrawLine 117 GUI_DrawLineRel 117 GUI_DrawLineTo 117 GUI_DRAWMODE_XOR 105 GUI_DrawPie 130 GUI_DrawPixel 109 GUI_DrawPoint 110 GUI_DrawPolygon 120 GUI_DrawPolyLine 118 GUI_DrawRect 110 GUI_DrawStreamedBitmap 116
User's & reference manual for C/GUI
GUI_DrawVLine 118, 119 GUI_EditBin 423 GUI_EditDec 423 GUI_EditHex 424 GUI_EditString 424 GUI_EnlargePolygon 120 GUI_Exec 842 GUI_Exec1 842 GUI_FillCircle 125 GUI_FillEllipse 126 GUI_FillPolygon 121 GUI_FillRect 111 GUI_FillRectEx 111 GUI_FONT structures 179 GUI_GetBkColor 244 GUI_GetBkColorIndex 244 GUI_GetCharDistX 171 GUI_GetClientRect 107 GUI_GetColor 245 GUI_GetColorIndex 245 GUI_GetDispPosX 88 GUI_GetDispPosY 88 GUI_GetDrawMode 105 GUI_GetFont 171 GUI_GetFontDistY 172 GUI_GetFontInfo 172 GUI_GetFontSizeY 172 GUI_GetKey 696 GUI_GetLayerPosEx 674 GUI_GetLeadingBlankCols 173 GUI_GetLineStyle 118 GUI_GetOrg 660 GUI_GetPenSize 107 GUI_GetStringDistX 173 GUI_GetTextAlign 86 GUI_GetTextExtend 173 GUI_GetTime 843 GUI_GetTrailingBlankCols 174 GUI_GetVersionString 101 GUI_GetYDistOfFont 174 GUI_GetYSizeOfFont 174 GUI_GIF_Draw 147 GUI_GIF_DrawEx 147 GUI_GIF_DrawSub 148 GUI_GIF_DrawSubEx 149 GUI_GIF_DrawSubScaled 150 GUI_GIF_DrawSubScaledEx 150 GUI_GIF_GetComment 151 GUI_GIF_GetCommentEx 151 GUI_GIF_GetImageInfo 152 GUI_GIF_GetImageInfoEx 152 GUI_GIF_GetInfo 153 GUI_GIF_GetInfoEx 153 GUI_GIF_GetXSize 154 GUI_GIF_GetXSizeEx 154
2002-2007 Micrium
911
GUI_GIF_GetYSize 154 GUI_GIF_GetYSizeEx 155 GUI_GotoX 87 GUI_GotoXY 87 GUI_GotoY 87 GUI_HMEM 885 GUI_Index2Color 246 GUI_Init 45 GUI_InitLUT 247 GUI_InvertRect 111 GUI_IsInFont 175 GUI_JPEG_Draw 141 GUI_JPEG_DrawEx 142 GUI_JPEG_DrawScaled 143 GUI_JPEG_DrawScaledEx 144 GUI_JPEG_GetInfo 144 GUI_JPEG_GetInfoEx 145 GUI_MagnifyPolygon 122 GUI_MAXBLOCKS 878 GUI_MAXTASK 284, 879 GUI_MEASDEV_ClearRect 276 GUI_MEASDEV_Create 275 GUI_MEASDEV_Delete 276 GUI_MEASDEV_GetRect 276 GUI_MEASDEV_Select 276 GUI_MEMDEV_Clear 255 GUI_MEMDEV_CopyFromLCD 255 GUI_MEMDEV_CopyToLCD 255 GUI_MEMDEV_CopyToLCDAA 255 GUI_MEMDEV_CopyToLCDAt 256 GUI_MEMDEV_Create 256, 257 GUI_MEMDEV_CreateAuto 270 GUI_MEMDEV_CreateFixed 257 GUI_MEMDEV_Delete 259 GUI_MEMDEV_DeleteAuto 271 GUI_MEMDEV_Draw 267 GUI_MEMDEV_DrawAuto 271 GUI_MEMDEV_GetDataPtr 260 GUI_MEMDEV_GetYSize 260 GUI_MEMDEV_MarkDirty 261 GUI_MEMDEV_ReduceYSize 261 GUI_MEMDEV_Select 262 GUI_MEMDEV_SetOrg 262 GUI_MEMDEV_Write 262 GUI_MEMDEV_WriteAlpha 262 GUI_MEMDEV_WriteAlphaAt 263 GUI_MEMDEV_WriteAt 263 GUI_MEMDEV_WriteEx 264 GUI_MEMSET 879 GUI_MessageBox 567, 648 GUI_MOUSE_DRIVER_PS2_Init 682 GUI_MOUSE_DRIVER_PS2_OnRx 682 GUI_MOUSE_GetState 681 GUI_MoveRel 119 GUI_OS 284, 879
User's & reference manual for C/GUI
GUI_PID_GetState 679 GUI_PID_STATE 679 GUI_PID_StoreState 679 GUI_RestoreContext 130 GUI_RotatePolygon 123 GUI_SaveContext 131 GUI_SelectLCD 265 GUI_SelLayer 673 GUI_SendKeyMsg 695 GUI_SetAlpha 112 GUI_SetBkColor 245 GUI_SetBkColorIndex 245 GUI_SetClipRect 131 GUI_SetColor 246 GUI_SetColorIndex 246 GUI_SetDrawMode 106 GUI_SetFont 163 GUI_SetLayerAlphaEx 674 GUI_SetLayerSizeEx 674 GUI_SetLayerVisEx 675 GUI_SetLBorder 86 GUI_SetLineStyle 119 GUI_SetLUTColor 247 GUI_SetLUTColorEx 675 GUI_SetLUTEntry 248 GUI_SetOrg 660 GUI_SetPenSize 107 GUI_SetTextAlign 86 GUI_SetTextMode 85 GUI_SetTextStyle 86 GUI_SIF_CreateFont 164 GUI_SIF_DeleteFont 165 GUI_SPRITE_Create 698 GUI_SPRITE_CreateEx 699 GUI_SPRITE_Delete 699 GUI_SPRITE_GetState 700 GUI_SPRITE_Hide 700 GUI_SPRITE_SetBitmap 700 GUI_SPRITE_SetBitmapAndPosition 701 GUI_SPRITE_SetPosition 701 GUI_StoreKey 696 GUI_StoreKeyMsg 695 GUI_SUPPORT_ARABIC 879 GUI_SUPPORT_CURSOR 879 GUI_SUPPORT_LARGE_BITMAPS 879 GUI_SUPPORT_MEMDEV 879 GUI_SUPPORT_MOUSE 879 GUI_SUPPORT_ROTATION 879 GUI_SUPPORT_TOUCH 879 GUI_SUPPORT_UNICODE 879 GUI_TEXTMODE_NORMAL 85, 87 GUI_TEXTMODE_REVERSE 85, 87 GUI_TEXTMODE_TRANSPARENT 85, 87 GUI_TEXTMODE_XOR 85, 87 GUI_TOUCH_AD_BOTTOM 690
2002-2007 Micrium
912
Index
GUI_TOUCH_AD_LEFT 690 GUI_TOUCH_AD_RIGHT 690 GUI_TOUCH_AD_TOP 690 GUI_TOUCH_Calibrate 689 GUI_TOUCH_Exec 689 GUI_TOUCH_GetState 683 GUI_TOUCH_MIRROR_X 690 GUI_TOUCH_MIRROR_Y 690 GUI_TOUCH_SetDefaultCalibration 689 GUI_TOUCH_StoreState 681, 683 GUI_TOUCH_StoreStateEx 684 GUI_TOUCH_SWAP_XY 690 GUI_TOUCH_X_ActivateX 687 GUI_TOUCH_X_ActivateY 687 GUI_TOUCH_X_MeasureX 687 GUI_TOUCH_X_MeasureY 687 GUI_TOUCH_XSIZE 690 GUI_TOUCH_YSIZE 690 GUI_TRIAL_VERSION 879 GUI_TTF_CreateFont 166 GUI_TTF_DestroyCache 168 GUI_TTF_Done 168 GUI_TTF_GetFamilyName 168 GUI_TTF_GetStyleName 168 GUI_TTF_SetCacheSize 169 GUI_UC_ConvertUC2UTF8 724 GUI_UC_ConvertUTF82UC 725 GUI_UC_DispString 727 GUI_UC_Encode 725 GUI_UC_GetCharCode 725 GUI_UC_GetCharSize 726 GUI_UC_SetEncodeNone 726 GUI_UC_SetEncodeUTF8 727 GUI_UNI_PTR 885, 886 GUI_VNC_AttachToLayer 838 GUI_VNC_Process 838 GUI_VNC_X_StartServer 839 GUI_WaitKey 696 GUI_WINSUPPORT 879 GUI_X_Delay 842, 882 GUI_X_ExecIdle 882 GUI_X_GetTaskID 285 GUI_X_GetTime 843, 882 GUI_X_Init 881 GUI_X_InitOS 285 GUI_X_Lock 286 GUI_X_Log 883 GUI_X_Unlock 286 GUI_X_WAIT_EVENT 284 GUI_XBF_CreateFont 169 GUI_XBF_DeleteFont 171 GUIConf.h 162, 253, 877 H Handle, of a window
Hardkey simulation 5761 Header widget 350, 480494 HEADER_AddItem 482 HEADER_Create 483 HEADER_CreateAttached 483 HEADER_CreateEx 484, 526 HEADER_CreateIndirect 484 HEADER_GetDefaultBkColor 484 HEADER_GetDefaultBorderH 485 HEADER_GetDefaultBorderV 485 HEADER_GetDefaultCursor 485 HEADER_GetDefaultFont 485 HEADER_GetDefaultTextColor 486 HEADER_GetHeight 486 HEADER_GetItemWidth 486 HEADER_GetNumColumns 486 HEADER_SetBitmap 487 HEADER_SetBitmapEx 487 HEADER_SetBkColor 488 HEADER_SetBMP 488 HEADER_SetBMPEx 488 HEADER_SetDefaultBkColor 489 HEADER_SetDefaultBorderH 489 HEADER_SetDefaultBorderV 490 HEADER_SetDefaultCursor 490 HEADER_SetDefaultFont 490 HEADER_SetDefaultTextColor 490 HEADER_SetDragLimit 491 HEADER_SetFont 491 HEADER_SetHeight 491 HEADER_SetItemText 492 HEADER_SetItemWidth 492 HEADER_SetStreamedBitmap 493 HEADER_SetStreamedBitmapEx 493 HEADER_SetTextAlign 491 HEADER_SetTextColor 493 Hello world program 4547 Hexadecimal values, displaying 100101 Hiding windows 291 High-resolution coordinates 707, 709710 I I/O pins, connection to 857, 859, 860, 863 I2C bus interface, configuration 862863 Initializing uC/GUI 45 Input devices 677692 joystick 691692 keyboard 693696 mouse 681682 touch screen 683690 Interrupt service routines 280, 281, 282, 689 Invalidation, of windows 291 ISO 8859-1 157, 176, 178
291
2002-2007 Micrium
913
287
Keyboard input support
693696
LCD_GetVYSizeEx 829 LCD_GetXMagEx 830 LCD_GetXSize 830 LCD_GetXSizeEx 830 LCD_GetYMagEx 830 LCD_GetYSize 830 LCD_GetYSizeEx 830 LCD_INIT_CONTROLLER
L LCD 751 caching in memory 33 configuration of 227 connecting to microcontroller 3536 initialization of 45 magnifying 855 simulated 54 without LCD controller 36, 760761 LCD controller configuration of 845875 connected to port/buffer 35 initialization of 850 memory-mapped 35 support for 35, 738 using CPU as 760761 with LUT hardware 247, 873 LCD driver 50 availability/selection 738 customization of 35 LCD_BITSPERPIXEL 848 LCD_BUSWIDTH 751, 866 LCD_CACHE 770, 775, 781, 789, 792,
796, 807,
746, 747, 751, 755, 758, 767, 770, 772, 775, 779, 781, 784, 786, 789, 792, 793, 796, 798, 800, 802, 805, 807, 809, 811, 814, 816, 818, 850 LCD_L0_ControlCache 769, 783, 827 LCD_L0_DrawBitMap 823 LCD_L0_DrawHLine 824 LCD_L0_DrawPixel 824 LCD_L0_DrawVLine 824 LCD_L0_FillRect 825 LCD_L0_GetPixelIndex 826 LCD_L0_Init 823 LCD_L0_Off 823 LCD_L0_On 823 LCD_L0_ReInit 823 LCD_L0_SetLUTEntry 826 LCD_L0_SetPixelIndex 825 LCD_L0_XorPixel 825 LCD_LIN_SWAP 755, 756 LCD_LUT_COM 873 LCD_LUT_SEG 873 LCD_MAX_LOG_COLORS 854 LCD_MIRROR_X 852 LCD_MIRROR_Y 853 LCD_NUM_COM0 773 LCD_NUM_CONTROLLERS 874 LCD_NUM_DUMMY_READS 809 LCD_NUM_SEG0 773 LCD_OFF 746, 748, 751, 755, 759, 762, 765, 875 LCD_ON 746, 748, 751, 755, 759, 762, 765, 875 LCD_PHYSCOLORS 854 LCD_PHYSCOLORS_IN_RAM 247 LCD_READ_A0 770, 775, 784, 793, 796, 798, 807, 811, 816, 856, 862 LCD_READ_A1 770, 772, 775, 781, 784, 789, 792, 793, 796, 798, 800, 807, 811, 816, 818, 856, 862 LCD_READ_MEM 746, 751, 755, 779, 864 LCD_READ_REG 747, 751, 752, 779, 864 LCD_READM_A1 786, 809, 814 LCD_REVERSE 854 LCD_SERIAL_ID 809 LCD_SET_LUT_ENTRY 751, 755, 759, 854 LCD_SUPPORT_CACHECONTROL 770, 775, 874 LCD_SWAP_BYTE_ORDER 751, 867 LCD_SWAP_RB 751, 855 LCD_SWAP_XY 853 LCD_TIMERINIT0 762, 765, 875
2002-2007 Micrium
914
Index
LCD_TIMERINIT1 762, 765, 875 LCD_USE_BITBLT 751, 779, 874 LCD_USE_BITBLT_1BPP 779 LCD_USE_BITBLT_FILL 779 LCD_USE_PARALLEL_16 809 LCD_USE_SERIAL_3PIN 809 LCD_VRAM_ADR 755, 758 LCD_VXSIZE 868 LCD_VYSIZE 868 LCD_WAIT 800 LCD_WRITE 859 LCD_WRITE_A0 770, 772, 775,
781, 784, 789, 792, 793, 796, 798, 800, 802, 805, 807, 809, 811, 814, 816, 818, 856, 860, 862 LCD_WRITE_A1 767, 770, 772, 775, 781, 784, 786, 789, 792, 793, 796, 798, 800, 802, 805, 807, 809, 811, 814, 816, 818, 857, 860, 863 LCD_WRITE_BUFFER_SIZE 786, 809 LCD_WRITE_MEM 746, 751, 755, 779, 865 LCD_WRITE_REG 747, 751, 752, 779, 865 LCD_WRITEM 859 LCD_WRITEM_A0 786, 809 LCD_WRITEM_A1 767, 770, 772, 781, 784, 786, 789, 792, 796, 800, 805, 809, 814, 816, 818, 857, 860, 863 LCD_XMAG 855 LCD_XSIZE 849 LCD_YMAG 855 LCD_YSIZE 849 LCD0323 driver 780781 LCD07X1 driver 782784 LCD1200 driver 785786 LCD13700 driver 787789 LCD13701 driver 790792 LCD159A driver 793794 LCD1611 driver 795796 LCD161620 driver 797798 LCD1781 driver 799801 LCD501 driver 802803 LCD6331 driver 804805 LCD6642X driver 806807 LCD66750 driver 810811 LCD667XX driver 808809 LCD7529 driver 812814 LCD7920 driver 815816 LCD8822 driver 817818 LCDColorOnMono driver 745746 LCDConf.h 35, 37, 44, 243, 737, 845 LCDFujitsu driver 747748 LCDLin driver 749752 LCDLin32 driver 753757 LCDLin32168 driver 758759 LCDMem driver 760762 LCDMemC driver 763765 LCDNoritake driver 766767
User's & reference manual for C/GUI
LCDNull driver 820 LCDPage1bpp driver 768770 LCDPage4bpp driver 771773 LCDSLin driver 774776 LCDTemplate driver 819 LCDVesa driver 777 LCDXylon driver 778779 Library, creating 41 Linearization 248 Lines, drawing 116118 Linking source files 41 List box widget 350, 495519 LISTBOX_ 506 LISTBOX_AddString 497 LISTBOX_BKCOLOR0_DEFAULT 495 LISTBOX_BKCOLOR1_DEFAULT 495 LISTBOX_BKCOLOR2_DEFAULT 495 LISTBOX_Create 497 LISTBOX_CreateAsChild 498 LISTBOX_CreateEx 498 LISTBOX_CreateIndirect 499 LISTBOX_DecSel 499 LISTBOX_DeleteItem 499 LISTBOX_FONT_DEFAULT 495 LISTBOX_GetDefaultBkColor 499 LISTBOX_GetDefaultFont 500 LISTBOX_GetDefaultScrollStepH 500 LISTBOX_GetDefaultTextAlign 500 LISTBOX_GetDefaultTextColor 501 LISTBOX_GetFont 501 LISTBOX_GetItemDisabled 501 LISTBOX_GetItemSel 502 LISTBOX_GetItemText 502 LISTBOX_GetMulti 502 LISTBOX_GetNumItems 503 LISTBOX_GetScrollStepH 503 LISTBOX_GetSel 503 LISTBOX_GetTextAlign 503 LISTBOX_IncSel 504 LISTBOX_InsertString 504 LISTBOX_InvalidateItem 504 LISTBOX_OwnerDraw 505 LISTBOX_SetAutoScrollH 505 LISTBOX_SetBkColor 506 LISTBOX_SetDefaultBkColor 507 LISTBOX_SetDefaultFont 507 LISTBOX_SetDefaultScrollStepH 507 LISTBOX_SetDefaultTextColor 508 LISTBOX_SetFont 508 LISTBOX_SetItemDisabled 508 LISTBOX_SetItemSel 509 LISTBOX_SetItemSpacing 509 LISTBOX_SetMulti 509 LISTBOX_SetOwnerDraw 510 LISTBOX_SetScrollbarWidth 512
2002-2007 Micrium
915
LISTBOX_SetScrollStepH 512 LISTBOX_SetSel 512 LISTBOX_SetString 512 LISTBOX_SetTextAlign 513 LISTBOX_SetTextColor 513 LISTBOX_TEXTCOLOR0_DEFAULT LISTBOX_TEXTCOLOR1_DEFAULT LISTBOX_TEXTCOLOR2_DEFAULT Listview widget 350, 520545 LISTVIEW_ 528, 529, 531 LISTVIEW_AddColumn 523 LISTVIEW_AddRow 524 LISTVIEW_CompareDec 524 LISTVIEW_CompareText 525 LISTVIEW_Create 525 LISTVIEW_CreateAttached 526 LISTVIEW_CreateIndirect 527 LISTVIEW_DecSel 527 LISTVIEW_DeleteColumn 527 LISTVIEW_DeleteRow 527 LISTVIEW_DisableSort 528 LISTVIEW_EnableSort 529 LISTVIEW_GetBkColor 530 LISTVIEW_GetFont 530 LISTVIEW_GetHeader 530 LISTVIEW_GetNumColumns 531 LISTVIEW_GetNumRows 531 LISTVIEW_GetSel 532 LISTVIEW_GetSelUnsorted 532 LISTVIEW_GetTextColor 532 LISTVIEW_GetUserData 533 LISTVIEW_IncSel 533 LISTVIEW_InsertRow 534 LISTVIEW_SetAutoScrollH 534 LISTVIEW_SetAutoScrollV 534 LISTVIEW_SetBkColor 535 LISTVIEW_SetColumnWidth 535 LISTVIEW_SetCompareFunc 536 LISTVIEW_SetDefaultBkColor 537 LISTVIEW_SetDefaultFont 537 LISTVIEW_SetDefaultGridColor 538 LISTVIEW_SetDefaultTextColor 538 LISTVIEW_SetFixed 538 LISTVIEW_SetFont 539 LISTVIEW_SetGridVis 539 LISTVIEW_SetItemBkColor 539 LISTVIEW_SetItemText 540 LISTVIEW_SetItemTextColor 541 LISTVIEW_SetLBorder 541 LISTVIEW_SetRBorder 542 LISTVIEW_SetRowHeight 542 LISTVIEW_SetSel 543 LISTVIEW_SetSelUnsorted 543 LISTVIEW_SetSort 543 LISTVIEW_SetTextAlign 544
User's & reference manual for C/GUI
M Measurement device object 275277 Memory devices 249277 auto 270275 banding 267270 basic usage of 253 disabling of 253, 339 software for 249 with window manager 339 Memory, reducing consumption of 210, 217 MENU 350 MENU_AddItem 552 MENU_Attach 552 MENU_CreateEx 553 MENU_DeleteItem 554 MENU_DisableItem 554 MENU_EnableItem 555 MENU_GetDefaultBkColor 555 MENU_GetDefaultBorderSize 556 MENU_GetDefaultEffect 556 MENU_GetDefaultFont 557 MENU_GetDefaultTextColor 557 MENU_GetItem 557 MENU_GetItemText 558 MENU_GetNumItems 558 MENU_GetOwner 559 MENU_IF_DISABLED 548 MENU_IF_SEPARATOR 548 MENU_InsertItem 559 MENU_MSG_DATA 547 MENU_ON_INITMENU 547 MENU_ON_ITEMACTIVATE 547 MENU_ON_ITEMPRESSED 547 MENU_ON_ITEMSELECT 547 MENU_Popup 559 MENU_SetBkColor 560 MENU_SetBorderSize 561 MENU_SetDefaultBkColor 561 MENU_SetDefaultBorderSize 562 MENU_SetDefaultEffect 562 MENU_SetDefaultFont 563 MENU_SetDefaultTextColor 563 MENU_SetFont 564 MENU_SetItem 564 MENU_SetOwner 565 MENU_SetSel 565 MENU_SetTextColor 566 Message box widget 567568 MESSAGEBOX_Create 568 Messages, sent by callback routines 295 Monospaced fonts (see Fonts)
2002-2007 Micrium
916
Index
MULTIEDIT 350 Multiedit widget 569581 MULTIEDIT_AddKey 571 MULTIEDIT_AddText 572 MULTIEDIT_Create 572 MULTIEDIT_CreateEx 573 MULTIEDIT_CreateIndirect 573 MULTIEDIT_EnableBlink 574 MULTIEDIT_GetCursorCharPos 574 MULTIEDIT_GetCursorPixelPos 574 MULTIEDIT_GetPrompt 575 MULTIEDIT_GetText 575 MULTIEDIT_GetTextSize 575 MULTIEDIT_SetAutoScrollH 576 MULTIEDIT_SetAutoScrollV 576 MULTIEDIT_SetBkColor 576 MULTIEDIT_SetBufferSize 577 MULTIEDIT_SetCursorOffset 577 MULTIEDIT_SetFont 578 MULTIEDIT_SetInsertMode 578 MULTIEDIT_SetMaxNumChars 578 MULTIEDIT_SetPasswordMode 578 MULTIEDIT_SetPrompt 579 MULTIEDIT_SetReadOnly 579 MULTIEDIT_SetText 580 MULTIEDIT_SetTextAlign 580 MULTIEDIT_SetTextColor 580 MULTIEDIT_SetWrapNone 581 MULTIEDIT_SetWrapWord 581 MULTIPAGE 351 Multipage widget 582596 MULTIPAGE_AddPage 585 MULTIPAGE_CreateIndirect 586 MULTIPAGE_DeletePage 586 MULTIPAGE_DisablePage 586 MULTIPAGE_EnablePage 587 MULTIPAGE_GetDefaultAlign 587 MULTIPAGE_GetDefaultBkColor 588 MULTIPAGE_GetDefaultFont 589 MULTIPAGE_GetDefaultTextColor 589 MULTIPAGE_GetSelection 589 MULTIPAGE_GetWindow 590 MULTIPAGE_IsPageEnabled 590 MULTIPAGE_SelectPage 590 MULTIPAGE_SetAlign 591 MULTIPAGE_SetBkColor 592 MULTIPAGE_SetDefaultAlign 592 MULTIPAGE_SetDefaultBkColor 593 MULTIPAGE_SetDefaultFont 593 MULTIPAGE_SetDefaultTextColor 593 MULTIPAGE_SetFont 594 MULTIPAGE_SetRotation 594 MULTIPAGE_SetText 595 MULTIPAGE_SetTextColor 595 Multiple layer support 661676
User's & reference manual for C/GUI
Multitask environments
351
N Non-blocking dialog 642 NORMAL drawing mode 105 Normal text 84 Numerical value macro 44 O Optional software
43
P Palettes (see Color palettes) Parent window 290 Performance 889895 Pixels 35 Pointer input device support data structure for 679 Polygons, drawing 120124 PROGBAR_Create 597 PROGBAR_CreateAsChild 598 PROGBAR_CreateEx 598 PROGBAR_CreateIndirect 599 PROGBAR_DEFAULT_BARCOLOR0 597 PROGBAR_DEFAULT_BARCOLOR1 597 PROGBAR_DEFAULT_FONT 597 PROGBAR_DEFAULT_TEXTCOLOR0 597 PROGBAR_DEFAULT_TEXTCOLOR1 597 PROGBAR_SetBarColor 599 PROGBAR_SetFont 599 PROGBAR_SetMinMax 600 PROGBAR_SetText 600 PROGBAR_SetTextAlign 601 PROGBAR_SetTextColor 601 PROGBAR_SetTextPos 601 PROGBAR_SetValue 602 Progress bar widget 351, 597605 Proportional fonts (see Fonts) R Radio button widget 351, 606617 RADIO_Create 607 RADIO_CreateEx 608 RADIO_CreateIndirect 609 RADIO_Dec 609 RADIO_GetDefaultFont 609 RADIO_GetDefaultTextColor 610 RADIO_GetText 610 RADIO_GetValue 610 RADIO_Inc 611 RADIO_SetBkColor 611 RADIO_SetDefaultFocusColor 612 RADIO_SetDefaultFont 612 RADIO_SetDefaultImage 613 RADIO_SetDefaultTextColor 613
2002-2007 Micrium
917
RADIO_SetFocusColor 614 RADIO_SetFont 614 RADIO_SetGroupID 615 RADIO_SetImage 615 RADIO_SetText 616 RADIO_SetTextColor 617 RADIO_SetValue 617 Real bus-interface 857 Redrawing mechanism 351 resource 54 Resource file 54, 57 Resource semaphore 285 Resource usage 889895 Reverse text 84 RLE compression, of bitmaps
S S1D13806 controller 751 Sample programs 34, 45 Scroll bar widget 351, 618625 SCROLLBAR_AddValue 619 SCROLLBAR_COLOR_ARROW_DEFAULT 618 SCROLLBAR_COLOR_SHAFT_DEFAULT 618 SCROLLBAR_COLOR_THUMB_DEFAULT 618 SCROLLBAR_Create 619 SCROLLBAR_CreateAttached 620 SCROLLBAR_CreateEx 621 SCROLLBAR_CreateIndirect 621 SCROLLBAR_Dec 622 SCROLLBAR_GetDefaultWidth 622 SCROLLBAR_GetValue 622 SCROLLBAR_Inc 622 SCROLLBAR_SetColor 623 SCROLLBAR_SetDefaultColor 623 SCROLLBAR_SetDefaultWidth 624 SCROLLBAR_SetNumItems 624 SCROLLBAR_SetPageSize 624 SCROLLBAR_SetState 625 SCROLLBAR_SetValue 625 SCROLLBAR_SetWidth 625 SCROLLBAR_THUMB_SIZE_MIN_DEFAULT 618 SED1386 controller 751 Selection switch macro 44 Shift JIS creating fonts 733736 Showing windows 291 Sibling window 290 SIM_GUI_CreateLCDInfoWindow() 65 SIM_GUI_CreateLCDWindow 66 SIM_GUI_Exit 66 SIM_GUI_Init 66 SIM_GUI_SetLCDColorBlack 55 SIM_GUI_SetLCDColorWhite 55 SIM_GUI_SetLCDPos 56 SIM_GUI_SetLCDWindowHook 67
User's & reference manual for C/GUI
SIM_GUI_SetMag 56 SIM_GUI_SetTransColor 57 SIM_HARDKEY_GetNum 59 SIM_HARDKEY_GetState 59 SIM_HARDKEY_SetCallback 59 SIM_HARDKEY_SetMode 57, 60 SIM_HARDKEY_SetState 61 SIM_SetTransColor 54 Simple bus interface, configuration 856858 Simulator 33, 4967 directory structure for 52 usage of with uC/GUI source 5253 usage of with uC/GUI trial version 5051 Single task system 280, 280281 Slider widget 351, 626632 SLIDER_BKCOLOR0_DEFAULT 626 SLIDER_COLOR0_DEFAULT 626 SLIDER_Create 627 SLIDER_CreateEx 627 SLIDER_CreateIndirect 628 SLIDER_Dec 628 SLIDER_FOCUSCOLOR_DEFAULT 626 SLIDER_GetValue 628 SLIDER_Inc 629 SLIDER_SetBkColor 629 SLIDER_SetDefaultFocusColor 629 SLIDER_SetFocusColor 630 SLIDER_SetNumTicks 630 SLIDER_SetRange 631 SLIDER_SetValue 631 SLIDER_SetWidth 632 Source files, linking 41 Sprintf 91 Sprites 697702 Standard fonts 157 Subdirectories, of GUI 40 Superloop 280, 280281 Support 897903 Syntax, conventions used 34 T Text alignment 8687 displaying 7583 modes 8485 positioning 76, 8788 Text widget 351, 633638 TEXT_Create 634 TEXT_CreateAsChild 634 TEXT_CreateEx 635 TEXT_CreateIndirect 635 TEXT_DEFAULT_BK_COLOR 633 TEXT_DEFAULT_TEXT_COLOR 633 TEXT_DEFAULT_WRAPMODE 633 TEXT_FONT_DEFAULT 633
2002-2007 Micrium
918
Index
TEXT_GetDefaultFont 636 TEXT_SetBkColor 636 TEXT_SetDefaultFont 636 TEXT_SetDefaultTextColor 636 TEXT_SetDefaultWrapMode 637 TEXT_SetFont 637 TEXT_SetText 637 TEXT_SetTextAlign 638 TEXT_SetTextColor 638 TEXT_SetWrapMode 638 Tick 841, 842 Time-related functions 841843 Toggle behavior, of hardkeys 57, 60 Top window 291 TOUCH_X_ActivateY 687 TOUCH_X_MeasureY 687 Touch-screens 33 Transparency 291 in device simulation 54 Transparent reversed text 84 Transparent text 84 Trial version, of uC/GUI 5051 Tutorial 45 U uC/GUI as trial version 5051 configuration of 44 directory structure for 40 Driver benchmark 890, 891 in multitask environments 45, 351 initialization of 45 memory requirements 892 updating to newer versions 40 uC/OS 279 kernel interface routines for 286 Unicode 157, 178 API reference 724 displaying characters in 723 User drawn widgets 357 UTF-8 strings 723 V Validation, of windows 291 Values, displaying 91101 Vectorized symbols 120 Viewer 33, 6974 Virtual display 33 Virtual screen support 651660 Visual C++ 50, 53 directory structure for 53 VNC support 833839 W Western Latin character set (see ISO 8859-1)
User's & reference manual for C/GUI
WIDGET_DRAW_ITEM_FUNC 357 WIDGET_GetDefaultEffect 356 WIDGET_ITEM_DRAW 358 WIDGET_ITEM_DRAW_INFO 145 WIDGET_ITEM_GET_XSIZE 358 WIDGET_ITEM_GET_YSIZE 358 WIDGET_SetDefaultEffect 356 WIDGET_SetEffect 357 WIDGET_USE_PARENT_EFFECT 353 Widgets 33, 349639, 841 currently available 350 dynamic memory usage 352 handles of 349, 352 member functions of 351 using 351 Win32, kernel interface routines for 287 Window coordinates 291 Window manager 33, 289347, 349, 842 Window objects (see Widgets) Window widget 639 WINDOW_BKCOLOR_DEFAULT 639 WINDOW_SetDefaultBkColor 639 Windows 289347 clearing 8889 properties of 290 terms associated with 290291 WM_Activate 307 WM_AttachWindow 308 WM_AttachWindowAt 308 WM_BringToBottom 308 WM_BringToTop 309 WM_BroadcastMessage 309 WM_CF_ANCHOR_BOTTOM 310 WM_CF_ANCHOR_LEFT 310 WM_CF_ANCHOR_RIGHT 310 WM_CF_ANCHOR_TOP 310 WM_CF_BGND 310 WM_CF_CONST_OUTLINE 311 WM_CF_FGND 311 WM_CF_HASTRANS 311 WM_CF_HIDE 311 WM_CF_LATE_CLIP 311 WM_CF_MEMDEV 311 WM_CF_MEMDEV_ON_REDRAW 311 WM_CF_SHOW 311 WM_CF_STAYONTOP 311 WM_ClrHasTrans 309 WM_CREATE 295, 296 WM_CreateTimer 340 WM_CreateWindow 310 WM_CreateWindowAsChild 312 WM_Deactivate 312 WM_DefaultProc 313 WM_DELETE 295, 296 WM_DeleteTimer 340
2002-2007 Micrium
919
WM_DeleteWindow 313 WM_DetachWindow 313 WM_DisableMemdev 339 WM_DisableWindow 314 WM_EnableMemdev 339 WM_EnableWindow 314 WM_Exec 314, 351, 842 WM_Exec1 315 WM_ForEachDesc 315 WM_GET_ID 295, 296 WM_GetActiveWindow 317 WM_GetBackgroundWindow 318 WM_GetCallback 316 WM_GetClientRect 317 WM_GetClientRectEx 317 WM_GetClientWindow 342 WM_GetDesktopWindowEx 318, 319 WM_GetDialogItem 318 WM_GetFirstChild 319 WM_GetFocussedWindow 319 WM_GetHasTrans 319 WM_GetId 342 WM_GetInsideRect 342 WM_GetInsideRectEx 343 WM_GetInvalidRect 320 WM_GetNextSibling 320 WM_GetOrgX 320 WM_GetOrgY 320 WM_GetParent 320 WM_GetPrevSibling 321 WM_GetScrollPosH 343 WM_GetScrollPosV 343 WM_GetScrollState 344 WM_GetStayOnTop 321 WM_GetUserData 321 WM_GetWindowOrgX 322 WM_GetWindowOrgY 322 WM_GetWindowRect 322 WM_GetWindowRectEx 322 WM_GetWindowSizeX 323 WM_GetWindowSizeY 323 WM_HasCaptured 323 WM_HasFocus 323 WM_HideWindow 324 WM_INIT_DIALOG 295, 296 WM_InvalidateArea 324 WM_InvalidateRect 325 WM_InvalidateWindow 325 WM_IsCompletelyCovered 325 WM_IsCompletelyVisible 326 WM_IsEnabled 326 WM_IsVisible 326 WM_IsWindow 327 WM_KEY 295, 297 WM_MakeModal 327
User's & reference manual for C/GUI
394, 408, 481, 495, 521, 570, 583, 606, 618, 626 WM_NOTIFICATION_MOVED_OUT 360, 379, 394, 408, 481, 495, 521, 570, 583, 606 WM_NOTIFICATION_RELEASED 360, 379, 394, 408, 481, 495, 521, 570, 583, 606, 618, 626 WM_NOTIFICATION_SCROLL_CHANGED 394, 495, 521, 570 WM_NOTIFICATION_SCROLLBAR_ADDED 618 WM_NOTIFICATION_SEL_CHANGED 394, 495, 521 WM_NOTIFICATION_VALUE_CHANGED 379, 408, 570, 583, 606, 618, 626 WM_NOTIFY_PARENT 295, 297, 352 WM_NOTIFY_VIS_CHANGED 295, 297 WM_NotifyParent 328 WM_PAINT 295, 298 WM_Paint 328, 351 WM_PaintWindowAndDescs 329 WM_PID_STATE_CHANGED 295, 300 WM_ReleaseCapture 329 WM_ResizeWindow 329 WM_RestartTimer 341 WM_SelectWindow 329 WM_SendMessage 330 WM_SendMessageNoPara 330 WM_SendToParent 330 WM_SET_FOCUS 295, 298 WM_SET_ID 295, 298 WM_SetCallback 331, 332 WM_SetCapture 332 WM_SetDesktopColor 331 WM_SetDesktopColorEx 331 WM_SetFocus 332 WM_SetHasTrans 333 WM_SetpfPollPID 334 WM_SetScrollPosH 344 WM_SetScrollPosV 345 WM_SetScrollState 345 WM_SetSize 334 WM_SetStayOnTop 335 WM_SetTransState 335 WM_SetUserClipRect 336 WM_SetUserData 337 WM_SetWindowPos 334 WM_SetXSize 335
2002-2007 Micrium
WM_MENU 547 WM_MESSAGE 295 WM_MOUSEOVER 295, 300 WM_MOUSEOVER_END 295, 300 WM_MOVE 295, 297 WM_MoveChildTo 327 WM_MoveTo 327 WM_MoveWindow 328 WM_NOTIFICATION_CHILD_DELETED 296 WM_NOTIFICATION_CLICKED 360, 379,
920
Index
WM_SetYSize 335 WM_ShowWindow 337 WM_SIZE 295, 299 WM_SUPPORT_NOTIFY_VIS_CHANGED WM_SUPPORT_TRANSPARENCY 304 WM_TIMER 295, 299 WM_TOUCH 296, 301 WM_TOUCH_CHILD 296, 301 WM_Update 338 WM_UpdateWindowAndDescs 338 WM_USER 296, 303 WM_ValidateRect 338 WM_ValidateWindow 338 X X-axis 35 XOR drawing mode XOR text 84 Y Y-axis
304
105
35
Z Z-position 291
2002-2007 Micrium