MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_textfield.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
24 /*******************************************************************************
25  Module for Microchip Graphics Library - Legato User Interface Library
26 
27  Company:
28  Microchip Technology Inc.
29 
30  File Name:
31  legato_widget_textfield.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements text field widget functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_TEXTFIELD_H
47 #define LEGATO_TEXTFIELD_H
48 
50 
51 #if LE_TEXTFIELD_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
59 
60 typedef struct leTextFieldWidget leTextFieldWidget;
61 
62 // *****************************************************************************
63 /* Function Pointer:
64  leTextFieldWidget_TextChangedCallback
65 
66  Summary:
67  Text changed event function callback type
68 */
73 typedef void (* leTextFieldWidget_TextChangedCallback)(leTextFieldWidget*);
74 
75 // *****************************************************************************
76 /* Function Pointer:
77  leTextFieldWidget_FocusChangedCallback
78 
79  Summary:
80  Focus changed event function callback type
81 */
86 typedef void (* leTextFieldWidget_FocusChangedCallback)(leTextFieldWidget*, leBool);
87 
88 /* internal use only */typedef struct leTextFieldWidget leTextFieldWidget;
93 
94 #define LE_TEXTFIELDWIDGET_VTABLE(THIS_TYPE) \
95  LE_EDITWIDGET_VTABLE(THIS_TYPE) \
96  \
97  uint32_t (*getCursorDelay)(const THIS_TYPE* _this); \
98  leResult (*setCursorDelay)(THIS_TYPE* _this, uint32_t dt); \
99  leBool (*getCursorEnabled)(const THIS_TYPE* _this); \
100  leResult (*setCursorEnabled)(THIS_TYPE* _this, leBool en); \
101  uint32_t (*getCursorPosition)(const THIS_TYPE* _this); \
102  leResult (*setCursorPosition)(THIS_TYPE* _this, uint32_t pos); \
103  const leString* (*getString)(const THIS_TYPE* txt); \
104  leResult (*setString)(THIS_TYPE* _this, const leString* str); \
105  leFont* (*getFont)(const THIS_TYPE* _this); \
106  leResult (*setFont)(THIS_TYPE* _this, const leFont* fnt); \
107  leString* (*getHintString)(const THIS_TYPE* txt); \
108  leResult (*setHintString)(THIS_TYPE* _this, const leString* str); \
109  leResult (*setClearValueOnFirstEdit)(THIS_TYPE* _this, leBool clr); \
110  leTextFieldWidget_TextChangedCallback (*getTextChangedEventCallback)(const THIS_TYPE* _this); \
111  leResult (*setTextChangedEventCallback)(THIS_TYPE* _this, leTextFieldWidget_TextChangedCallback cb); \
112  leTextFieldWidget_FocusChangedCallback (*getFocusChangedEventCallback)(const THIS_TYPE* _this); \
113  leResult (*setFocusChangedEventCallback)(THIS_TYPE* _this, leTextFieldWidget_FocusChangedCallback cb); \
114 
115 typedef struct leTextFieldWidgetVTable
116 {
117  LE_TEXTFIELDWIDGET_VTABLE(leTextFieldWidget)
118 } leTextFieldWidgetVTable;
119 
120 // DOM-IGNORE-END
121 
122 // *****************************************************************************
123 // *****************************************************************************
124 // Section: Data Types and Constants
125 // *****************************************************************************
126 // *****************************************************************************
127 
128 // *****************************************************************************
136 typedef struct leTextFieldWidget
137 {
138  leEditWidget editWidget; // edit widget base class
139 
140  const leTextFieldWidgetVTable* fn;
141 
142  const leString* hintText;
143  leDynamicString text; // the text to edit
144 
145  uint32_t cursorPos; // current cursor position
146  uint32_t cursorDelay; // cursor blink delay
147  uint32_t cursorTime; // current cursor tick counter
148  leBool cursorEnable; // cursor enabled flag
149  leBool cursorVisible; // cursor visbility flag
150  leBool clearOnFirstEdit; // needs clear on first edit
151 
152  leTextFieldWidget_TextChangedCallback textChangedEvent; // text changed event
153  leTextFieldWidget_FocusChangedCallback focusChangedEvent; // focus changed event
154 } leTextFieldWidget;
155 
156 // *****************************************************************************
157 // *****************************************************************************
158 // Section: Routines
159 // *****************************************************************************
160 // *****************************************************************************
161 
173 leTextFieldWidget* leTextFieldWidget_New(void);
174 
185 void leTextFieldWidget_Constructor(leTextFieldWidget* wgt);
186 
187 #ifdef _DOXYGEN_
188 #define THIS_TYPE struct leWidget
189 
190 
191 // *****************************************************************************
202 virtual uint32_t getCursorDelay(const leTextFieldWidget* _this);
203 
204 
205 // *****************************************************************************
218 virtual leResult setCursorDelay(leTextFieldWidget* _this,
219  uint32_t dt);
220 
221 // *****************************************************************************
232 virtual leBool getCursorEnabled(const leTextFieldWidget* _this);
233 
234 // *****************************************************************************
247 virtual leResult setCursorEnabled(leTextFieldWidget* _this,
248  leBool en);
249 
250 
251 // *****************************************************************************
262 virtual uint32_t getCursorPosition(const leTextFieldWidget* _this);
263 
264 
265 // *****************************************************************************
278 virtual leResult setCursorPosition(leTextFieldWidget* _this,
279  uint32_t pos);
280 
281 
282 // *****************************************************************************
294 virtual const leString* getString(const leTextFieldWidget* txt);
295 
296 
297 // *****************************************************************************
310 virtual leResult setString(leTextFieldWidget* _this,
311  const leString* str);
312 
313 // *****************************************************************************
324 virtual leFont* getFont(const leTextFieldWidget* _this);
325 
326 
327 // *****************************************************************************
340 virtual leResult setFont(leTextFieldWidget* _this,
341  const leFont* fnt);
342 
343 
344 // *****************************************************************************
355 virtual leString* getHintString(const leTextFieldWidget* _this);
356 
357 
358 // *****************************************************************************
371 virtual leResult setHintString(leTextFieldWidget* _this,
372  const leString* str);
373 
374 // *****************************************************************************
388 virtual leResult setClearValueOnFirstEdit(leTextFieldWidget* _this,
389  leBool clr);
390 
391 
402 virtual leTextFieldWidget_TextChangedCallback getTextChangedEventCallback
403  (const leTextFieldWidget* _this);
404 
418 virtual leResult setTextChangedEventCallback(leTextFieldWidget* _this,
419  leTextFieldWidget_TextChangedCallback cb);
420 
431 virtual leTextFieldWidget_FocusChangedCallback getFocusChangedEventCallback
432  (const leTextFieldWidget* _this);
433 
447 virtual leResult setFocusChangedEventCallback(leTextFieldWidget* _this,
448  leTextFieldWidget_FocusChangedCallback cb);
449 
450 #undef THIS_TYPE
451 #endif
452 
453 #ifdef __cplusplus
454 }
455 #endif
456 
457 #endif // LE_TEXTFIELD_WIDGET_ENABLED
458 #endif /* LEGATO_TEXTFIELD_H */
Common macros and definitions used by Legato.
This struct represents a string.
Definition: legato_string.h:107
This struct represents a dynamic string.
Definition: legato_dynamicstring.h:59
virtual leResult setFont(leString *_this, const leFont *font)
Set font.
This struct represents a font object.
Definition: legato_font.h:156
leResult
This enum represents function call results.
Definition: legato_common.h:123
Dynamic string functions and definitions.
Edit widget functions and definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
virtual leFont * getFont(const leString *_this)
Get font.
Definition: legato_editwidget.h:90