| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- /*********************************************************************
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- **********************************************************************
- * *
- * (c) 1996 - 2015 SEGGER Microcontroller GmbH & Co. KG *
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- ** emWin V5.32 - Graphical user interface for embedded applications **
- All Intellectual Property rights in the Software belongs to SEGGER.
- emWin 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 the following terms:
- The software has been licensed to STMicroelectronics International
- N.V. a Dutch company with a Swiss branch and its headquarters in Plan-
- les-Ouates, Geneva, 39 Chemin du Champ des Filles, Switzerland for the
- purposes of creating libraries for ARM Cortex-M-based 32-bit microcon_
- troller products commercialized by Licensee only, sublicensed and dis_
- tributed under the terms and conditions of the End User License Agree_
- ment supplied by STMicroelectronics International N.V.
- Full source code is available at: www.segger.com
- We appreciate your understanding and fairness.
- ----------------------------------------------------------------------
- Licensing information
- Licensor: SEGGER Software GmbH
- Licensed to: STMicroelectronics International NV
- Licensed SEGGER software: emWin
- License number: GUI-00429
- License model: Buyout SRC [Buyout Source Code License, signed November 29th 2012]
- Licensed product: -
- Licensed platform: STMs ARM Cortex-M based 32 BIT CPUs
- Licensed number of seats: -
- ----------------------------------------------------------------------
- File : GUIDEMO_Cursor.c
- Purpose : shows Cursor-API
- ----------------------------------------------------------------------
- */
- #include "GUIDEMO.h"
- #if (SHOW_GUIDEMO_CURSOR && GUI_SUPPORT_CURSOR)
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define NUM_CURSORS 3
- #define XMAX 28
- /*********************************************************************
- *
- * Types
- *
- **********************************************************************
- */
- typedef struct {
- const GUI_CURSOR * pCursor;
- char Size;
- } CURSOR_INFO;
- typedef struct {
- CURSOR_INFO aCursor[NUM_CURSORS];
- const char * pType;
- } CURSORTYPE_INFO;
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- static const CURSORTYPE_INFO _CursorArrow = {
- {
- {&GUI_CursorArrowS, 'S'},
- {&GUI_CursorArrowM, 'M'},
- #if (NUM_CURSORS == 3)
- {&GUI_CursorArrowL, 'L'},
- },
- "arrow cursors"
- #else
- },
- "arrow\ncursors"
- #endif
- };
- static const CURSORTYPE_INFO _CursorArrowI = {
- {
- {&GUI_CursorArrowSI, 'S'},
- {&GUI_CursorArrowMI, 'M'},
- #if (NUM_CURSORS == 3)
- {&GUI_CursorArrowLI, 'L'},
- },
- "inverted arrow cursors"
- #else
- },
- "inverted\narrow cursors"
- #endif
- };
- static const CURSORTYPE_INFO _CursorCross = {
- {
- {&GUI_CursorCrossS, 'S'},
- {&GUI_CursorCrossM, 'M'},
- #if (NUM_CURSORS == 3)
- {&GUI_CursorCrossL, 'L'},
- },
- "cross cursors"
- #else
- },
- "cross\ncursors"
- #endif
- };
- static const CURSORTYPE_INFO _CursorCrossI = {
- {
- {&GUI_CursorCrossSI, 'S'},
- {&GUI_CursorCrossMI, 'M'},
- #if (NUM_CURSORS == 3)
- {&GUI_CursorCrossLI, 'L'},
- },
- "inverted cross cursors"
- #else
- },
- "inverted\ncross cursors"
- #endif
- };
- static int _ScreenX0;
- static int _ScreenY0;
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _ShowCursorType
- */
- static void _ShowCursorType(const CURSORTYPE_INFO* pCursorType, int x0, int y0) {
- const GUI_CURSOR * pCursor;
- char Char;
- int yMax;
- int yHot;
- int i;
- int x;
- int y;
- yMax = 0;
- yHot = 0;
- //
- // Calculate height and width of biggest cursor
- //
- for (i = 0; i < NUM_CURSORS; i++) {
- pCursor = pCursorType->aCursor[i].pCursor;
- if (pCursor->pBitmap->YSize > yMax) {
- yMax = pCursor->pBitmap->YSize;
- yHot = pCursor->yHot;
- }
- }
- GUI_SetFont(&GUI_FontRounded16);
- #if (NUM_CURSORS != 3)
- GUI_SetLBorder(x0);
- #endif
- GUI_DispStringAt(pCursorType->pType, x0, y0);
- y0 += GUI_GetFontDistY() + 1;
- GUI_SetFont(&GUI_Font13B_ASCII);
- for (i = 0; i < NUM_CURSORS; i++) {
- pCursor = pCursorType->aCursor[i].pCursor;
- Char = pCursorType->aCursor[i].Size;
- y = y0 + yHot - pCursor->yHot;
- x = ((pCursor->pBitmap->XSize - GUI_GetCharDistX(Char)) / 2);
- GUI_DrawBitmap(pCursor->pBitmap, x0 + XMAX * i + 5, y);
- GUI_DispCharAt(Char, x0 + XMAX * i + 5 + x, y0 + yMax + 2);
- }
- }
- /*********************************************************************
- *
- * _DispCursor
- */
- static void _DispCursor(void) {
- int xSize;
- int ySize;
- xSize = LCD_GetXSize();
- ySize = LCD_GetYSize();
- _ScreenX0 = (xSize - XSIZE_MIN) / 2;
- _ScreenY0 = (ySize - YSIZE_MIN) / 2;
- GUIDEMO_DrawBk();
- GUI_SetTextMode(GUI_TM_TRANS);
- GUI_SetFont(&GUI_FontRounded22);
- GUI_DispStringHCenterAt("Available cursors", xSize / 2, 12);
- //
- // Display the cursors
- //
- _ShowCursorType(&_CursorArrow, _ScreenX0 + 20, _ScreenY0 + 50);
- _ShowCursorType(&_CursorCross, _ScreenX0 + 20, _ScreenY0 + 120);
- _ShowCursorType(&_CursorArrowI, _ScreenX0 + 140, _ScreenY0 + 50);
- _ShowCursorType(&_CursorCrossI, _ScreenX0 + 140, _ScreenY0 + 120);
- GUIDEMO_Wait(4000);
- GUI_CURSOR_Select(&GUI_CursorArrowM);
- GUI_CURSOR_Hide();
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * GUIDEMO_Cursor
- */
- void GUIDEMO_Cursor(void) {
- GUIDEMO_ConfigureDemo("Cursor", "STemWin supports\nsoftware cursors", GUIDEMO_SHOW_CURSOR | GUIDEMO_SHOW_CONTROL);
- _DispCursor();
- }
- #else
- void GUIDEMO_Cursor_C(void);
- void GUIDEMO_Cursor_C(void) {}
- #endif // SHOW_GUIDEMO_CURSOR && GUI_SUPPORT_CURSOR
- /*************************** End of file ****************************/
|