GUIslice  0.16.0
Embedded GUI in C
XKeyPad_Num.h
Go to the documentation of this file.
1 #ifndef _GUISLICE_EX_XKEYPAD_NUM_H_
2 #define _GUISLICE_EX_XKEYPAD_NUM_H_
3 
4 #include "GUIslice.h"
5 
6 #include "elem/XKeyPad.h"
7 
8 // =======================================================================
9 // GUIslice library extension: XKeyPad control (numeric entry)
10 // - Paul Conti, Calvin Hass
11 // - https://www.impulseadventure.com/elec/guislice-gui.html
12 // - https://github.com/ImpulseAdventure/GUIslice
13 // =======================================================================
14 //
15 // The MIT License
16 //
17 // Copyright 2016-2020 Calvin Hass
18 //
19 // Permission is hereby granted, free of charge, to any person obtaining a copy
20 // of this software and associated documentation files (the "Software"), to deal
21 // in the Software without restriction, including without limitation the rights
22 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 // copies of the Software, and to permit persons to whom the Software is
24 // furnished to do so, subject to the following conditions:
25 //
26 // The above copyright notice and this permission notice shall be included in
27 // all copies or substantial portions of the Software.
28 //
29 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 // THE SOFTWARE.
36 //
37 // =======================================================================
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif // __cplusplus
43 
44 
45 // ============================================================================
46 // Extended Element: KeyPad Character entry
47 // - NOTE: The XKeyPad_Num extends the XKeyPad base element
48 // ============================================================================
49 
50 
51 // Variant XKeyPad config structure
52 typedef struct {
53  // Common configuration
55 
56  // Variant-specific configuration
57  bool bFloatEn;
58  bool bSignEn;
59  // Variant-specific state
60  bool bValPositive;
63 
78  gslc_tsElemRef* gslc_ElemXKeyPadCreate_Num(gslc_tsGui* pGui, int16_t nElemId, int16_t nPage,
79  gslc_tsXKeyPad* pXData, int16_t nX0, int16_t nY0, int8_t nFontId, gslc_tsXKeyPadCfg_Num* pConfig);
80 
81 
90 
98  void gslc_ElemXKeyPadReset_Num(void* pvConfig);
99 
100 
114  void gslc_ElemXKeyPadTxtInit_Num(void* pvKeyPad);
115 
116 
129  void gslc_ElemXKeyPadLabelGet_Num(void* pvKeyPad,uint8_t nId,uint8_t nStrMax,char* pStr);
130 
131 
151  void gslc_ElemXKeyPadStyleGet_Num(void* pvKeyPad,uint8_t nId, bool* pbVisible, gslc_tsColor* pcolTxt, gslc_tsColor* pcolFrame, gslc_tsColor* pcolFill, gslc_tsColor* pcolGlow);
152 
153 
168  void gslc_ElemXKeyPadBtnEvt_Num(void* pvKeyPad,uint8_t nId,gslc_tsXKeyPadResult* psResult);
169 
180 
191 
192 // ============================================================================
193 
194 #ifdef __cplusplus
195 }
196 #endif // __cplusplus
197 #endif // _GUISLICE_EX_XKEYPAD_NUM_H_
198 
gslc_tsXKeyPadCfg_Num gslc_ElemXKeyPadCfgInit_Num()
Initialize the KeyPad config structure.
Definition: XKeyPad_Num.c:376
bool bValPositive
Is the current value positive? (1=positive, 0=negative)
Definition: XKeyPad_Num.h:60
void gslc_ElemXKeyPadTxtInit_Num(void *pvKeyPad)
Callback function to update internal state whenever the text field is manually set via gslc_ElemXKeyP...
Definition: XKeyPad_Num.c:129
bool bSignEn
Enable negative numbers.
Definition: XKeyPad_Num.h:58
gslc_tsXKeyPadCfg sBaseCfg
KeyPad base config struct.
Definition: XKeyPad_Num.h:54
Configuration for the KeyPad.
Definition: XKeyPad.h:155
void gslc_ElemXKeyPadBtnEvt_Num(void *pvKeyPad, uint8_t nId, gslc_tsXKeyPadResult *psResult)
Callback function activated when a key has been pressed.
Definition: XKeyPad_Num.c:255
bool bFloatEn
Enable floating point (ie. decimal point)
Definition: XKeyPad_Num.h:57
Extended data for KeyPad element.
Definition: XKeyPad.h:195
void gslc_ElemXKeyPadStyleGet_Num(void *pvKeyPad, uint8_t nId, bool *pbVisible, gslc_tsColor *pcolTxt, gslc_tsColor *pcolFrame, gslc_tsColor *pcolFill, gslc_tsColor *pcolGlow)
Callback function to retrieve the style associated with a KeyPad button.
Definition: XKeyPad_Num.c:194
void gslc_ElemXKeyPadCfgSetSignEn_Num(gslc_tsXKeyPadCfg_Num *pConfig, bool bEn)
Update the KeyPad configuration to enable negative numbers.
Definition: XKeyPad_Num.c:443
bool bValDecimalPt
Does the current value include a decimal point?
Definition: XKeyPad_Num.h:61
void gslc_ElemXKeyPadLabelGet_Num(void *pvKeyPad, uint8_t nId, uint8_t nStrMax, char *pStr)
Callback function to retrieve the label associated with a KeyPad button.
Definition: XKeyPad_Num.c:151
Element reference structure.
Definition: GUIslice.h:578
void gslc_ElemXKeyPadCfgSetFloatEn_Num(gslc_tsXKeyPadCfg_Num *pConfig, bool bEn)
Update the KeyPad configuration to enable floating point numbers.
Definition: XKeyPad_Num.c:438
Return status for XKeyPad.
Definition: XKeyPad.h:94
void gslc_ElemXKeyPadReset_Num(void *pvConfig)
Callback function to reset internal state.
Definition: XKeyPad_Num.c:117
gslc_tsElemRef * gslc_ElemXKeyPadCreate_Num(gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXKeyPad *pXData, int16_t nX0, int16_t nY0, int8_t nFontId, gslc_tsXKeyPadCfg_Num *pConfig)
Create a KeyPad Element.
Definition: XKeyPad_Num.c:416
GUI structure.
Definition: GUIslice.h:716
Definition: XKeyPad_Num.h:52
Color structure. Defines RGB triplet.
Definition: GUIslice.h:534