GUIslice  0.16.0
Embedded GUI in C
XSelNum.h
Go to the documentation of this file.
1 #ifndef _GUISLICE_EX_XSELNUM_H_
2 #define _GUISLICE_EX_XSELNUM_H_
3 
4 #include "GUIslice.h"
5 
6 
7 // =======================================================================
8 // GUIslice library extension: Select Number (SelNum) control
9 // - Calvin Hass
10 // - https://www.impulseadventure.com/elec/guislice-gui.html
11 // - https://github.com/ImpulseAdventure/GUIslice
12 // =======================================================================
13 //
14 // The MIT License
15 //
16 // Copyright 2016-2020 Calvin Hass
17 //
18 // Permission is hereby granted, free of charge, to any person obtaining a copy
19 // of this software and associated documentation files (the "Software"), to deal
20 // in the Software without restriction, including without limitation the rights
21 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 // copies of the Software, and to permit persons to whom the Software is
23 // furnished to do so, subject to the following conditions:
24 //
25 // The above copyright notice and this permission notice shall be included in
26 // all copies or substantial portions of the Software.
27 //
28 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 // THE SOFTWARE.
35 //
36 // =======================================================================
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif // __cplusplus
42 
43 
44 
45 #if (GSLC_FEATURE_COMPOUND)
46 // ============================================================================
47 // Extended Element: SelNum (Number Selector)
48 // - Demonstration of a compound element consisting of
49 // a counter text field along with an increment and
50 // decrement button.
51 // ============================================================================
52 
53 // Define unique identifier for extended element type
54 // - Select any number above GSLC_TYPE_BASE_EXTEND
55 #define GSLC_TYPEX_SELNUM GSLC_TYPE_BASE_EXTEND + 3
56 
57 #define SELNUM_STR_LEN 6
58 
59 // Extended element data structures
60 // - These data structures are maintained in the gslc_tsElem
61 // structure via the pXData pointer
63 typedef struct {
64 
65  // Core functionality for SelNum
66  int16_t nCounter;
67 
68  // Internal sub-element members
70  gslc_tsElemRef asElemRef[4];
71  gslc_tsElem asElem[4];
72 
73  #if (GSLC_LOCAL_STR == 0)
74  // If elements don't provide their own internal string buffer, then
75  // we need to provide storage here in the extended data of the compound
76  // element. For now, simply provide a fixed-length memory buffer.
77  char acElemTxt[4][SELNUM_STR_LEN];
78  #endif
80 
81 
82 
83 
96 gslc_tsElemRef* gslc_ElemXSelNumCreate(gslc_tsGui* pGui,int16_t nElemId,int16_t nPage,
97  gslc_tsXSelNum* pXData,gslc_tsRect rElem,int8_t nFontId);
98 
99 
110 bool gslc_ElemXSelNumDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw);
111 
112 
122 
123 
133 void gslc_ElemXSelNumSetCounter(gslc_tsGui* pGui,gslc_tsXSelNum* pSelNum,int16_t nCount);
134 
135 
148 bool gslc_ElemXSelNumClick(void* pvGui,void *pvElemRef,gslc_teTouch eTouch,int16_t nX,int16_t nY);
149 
162 bool gslc_ElemXSelNumTouch(void* pvGui,void* pvElemRef,gslc_teTouch eTouch,int16_t nRelX,int16_t nRelY);
163 #endif // GLSC_COMPOUND
164 
165 // ============================================================================
166 
167 // ------------------------------------------------------------------------
168 // Read-only element macros
169 // ------------------------------------------------------------------------
170 
171 // Macro initializers for Read-Only Elements in Flash/PROGMEM
172 //
173 #ifdef __cplusplus
174 }
175 #endif // __cplusplus
176 #endif // _GUISLICE_EX_XSELNUM_H_
177 
gslc_tsCollect sCollect
Collection management for sub-elements.
Definition: XSelNum.h:69
int16_t nCounter
Counter for demo purposes.
Definition: XSelNum.h:66
bool gslc_ElemXSelNumDraw(void *pvGui, void *pvElemRef, gslc_teRedrawType eRedraw)
Draw a SelNum element on the screen.
Definition: XSelNum.c:226
Extended data for SelNum element.
Definition: XSelNum.h:63
bool gslc_ElemXSelNumTouch(void *pvGui, void *pvElemRef, gslc_teTouch eTouch, int16_t nRelX, int16_t nRelY)
Handle touch (up,down,move) events to SelNum element.
Definition: XSelNum.c:368
gslc_teRedrawType
Redraw types.
Definition: GUIslice.h:370
bool gslc_ElemXSelNumClick(void *pvGui, void *pvElemRef, gslc_teTouch eTouch, int16_t nX, int16_t nY)
Handle a click event within the SelNum.
Definition: XSelNum.c:310
Rectangular region. Defines X,Y corner coordinates plus dimensions.
Definition: GUIslice.h:519
Element collection struct.
Definition: GUIslice.h:656
Element reference structure.
Definition: GUIslice.h:578
int gslc_ElemXSelNumGetCounter(gslc_tsGui *pGui, gslc_tsXSelNum *pSelNum)
Get the current counter associated with SelNum.
Definition: XSelNum.c:268
gslc_teTouch
Processed event from input raw events and actions.
Definition: GUIslice.h:305
void gslc_ElemXSelNumSetCounter(gslc_tsGui *pGui, gslc_tsXSelNum *pSelNum, int16_t nCount)
Set the current counter associated with SelNum.
Definition: XSelNum.c:279
GUI structure.
Definition: GUIslice.h:716
gslc_tsElemRef * gslc_ElemXSelNumCreate(gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXSelNum *pXData, gslc_tsRect rElem, int8_t nFontId)
Create a SelNum Element.
Definition: XSelNum.c:84
Element Struct.
Definition: GUIslice.h:593
#define SELNUM_STR_LEN
Definition: XSelNum.h:57