MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_scrollbar.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_scrollbar.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements scroll bar widget functions.
38 *******************************************************************************/
39 
46 #ifndef LEGATO_SCROLLBAR_H
47 #define LEGATO_SCROLLBAR_H
48 
50 
51 #if LE_SCROLLBAR_WIDGET_ENABLED == 1
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
59 
60 // *****************************************************************************
61 // *****************************************************************************
62 // Section: Data Types and Constants
63 // *****************************************************************************
64 // *****************************************************************************
65 
66 // *****************************************************************************
67 /* Enumeration:
68  leScrollBarState
69 
70  Summary:
71  Defines the various scroll bar state values
72 
73  Description:
74 
75 
76  Remarks:
77  None.
78 */
83 typedef enum leScrollBarState
84 {
85  LE_SCROLLBAR_STATE_NONE,
86  LE_SCROLLBAR_STATE_TOP_PRESSED,
87  LE_SCROLLBAR_STATE_TOP_INSIDE,
88  LE_SCROLLBAR_STATE_BOTTOM_PRESSED,
89  LE_SCROLLBAR_STATE_BOTTOM_INSIDE,
90  LE_SCROLLBAR_STATE_HANDLE_DOWN
91 } leScrollBarState;
92 
93 typedef struct leScrollBarWidget leScrollBarWidget;
94 
95 // *****************************************************************************
96 /* Function Pointer:
97  leScrollBarWidget_ValueChangedEvent
98 
99  Summary:
100  Value changed event function callback type
101 */
102 typedef void (* leScrollBarWidget_ValueChangedEvent)(leScrollBarWidget*);
103 
104 /* internal use only */typedef struct leScrollBarWidget leScrollBarWidget;
109 
110 #define LE_SCROLLBARWIDGET_VTABLE(THIS_TYPE) \
111  LE_WIDGET_VTABLE(THIS_TYPE) \
112  \
113  leOrientation (*getOrientation)(const THIS_TYPE* _this); \
114  leResult (*setOrientation)(THIS_TYPE* _this, leOrientation align, leBool swapDimensions); \
115  uint32_t (*getMaximumValue)(const THIS_TYPE* _this); \
116  leResult (*setMaximumValue)(THIS_TYPE* _this, uint32_t val); \
117  uint32_t (*getExtentValue)(const THIS_TYPE* _this); \
118  leResult (*setExtentValue)(THIS_TYPE* _this, uint32_t val); \
119  uint32_t (*getScrollPercentage)(const THIS_TYPE* _this); \
120  leResult (*setScrollPercentage)(THIS_TYPE* _this, uint32_t val); \
121  uint32_t (*getScrollValue)(const THIS_TYPE* _this); \
122  leResult (*setScrollValue)(THIS_TYPE* _this, uint32_t val); \
123  uint32_t (*getStepSize)(const THIS_TYPE* _this); \
124  leResult (*setStepSize)(THIS_TYPE* _this, uint32_t val); \
125  leResult (*stepBackward)(THIS_TYPE* _this); \
126  leResult (*stepForward)(THIS_TYPE* _this); \
127  leScrollBarWidget_ValueChangedEvent (*getValueChangedEventCallback)(const THIS_TYPE* _this); \
128  leResult (*setValueChangedEventCallback)(THIS_TYPE* _this, leScrollBarWidget_ValueChangedEvent cb); \
129 
130 typedef struct leScrollBarWidgetVTable
131 {
132  LE_SCROLLBARWIDGET_VTABLE(leScrollBarWidget)
133 } leScrollBarWidgetVTable;
134 
140 // *****************************************************************************
148 typedef struct leScrollBarWidget
149 {
150  leWidget widget; // widget base class
151 
152  const leScrollBarWidgetVTable* fn;
153 
154  leScrollBarState state; // scrollbar input state
155  leOrientation alignment; // scroll bar direction
156 
157  uint32_t max; // maximum scroll value
158  uint32_t extent; // visible space/handle size
159  uint32_t value; // current scroll value
160  uint32_t step; // discreet scroll stepping value
161 
162  leScrollBarWidget_ValueChangedEvent valueChangedEvent; // value changed callback
163 
164  lePoint handleDownOffset;
165 } leScrollBarWidget;
166 
167 // *****************************************************************************
168 // *****************************************************************************
169 // Section: Routines
170 // *****************************************************************************
171 // *****************************************************************************
172 
173 // *****************************************************************************
174 /* Function:
175  leScrollBarWidget* leScrollBarWidget_New()
176 
177  Summary:
178  Allocates memory for a new widget of this type. The application is
179  responsible for the managment of this memory until the widget is added to
180  a widget tree.
181 
182  Description:
183 
184 
185  Parameters:
186 
187  Returns:
188  leScrollBarWidget*
189 
190  Remarks:
191  Use leWidget_Delete() to free this pointer.
192 */
204 leScrollBarWidget* leScrollBarWidget_New(void);
205 
216 void leScrollBarWidget_Constructor(leScrollBarWidget* wgt);
217 
218 #ifdef _DOXYGEN_
219 #define THIS_TYPE struct leWidget
220 
221 // *****************************************************************************
222 /* Virtual Member Function:
223  leOrientation getOrientation(const leScrollBarWidget* _this)
224 
225  Summary:
226  Gets the scroll bar orientation
227 
228  Description:
229  Gets the scroll bar orientation
230 
231  Parameters:
232  const leScrollBarWidget* _this - The scroll bar widget to operate on
233 
234  Remarks:
235  Usage - _this->fn->getOrientation(_this);
236 
237  Returns:
238  leOrientation - the orientation value
239 */
251 leOrientation getOrientation(const leScrollBarWidget* _this);
252 
253 // *****************************************************************************
254 /* Virtual Member Function:
255  leResult setOrientation(leScrollBarWidget* _this,
256  leOrientation align,
257  leBool swapDimensions)
258 
259  Summary:
260  Sets the scroll bar orientation
261 
262  Description:
263  Sets the scroll bar orientation
264 
265  Parameters:
266  leScrollBarWidget* _this - The scroll bar widget to operate on
267  leOrientation align - the orientation value
268  leBool swapDimensions - swap the width and height values when changing this
269 
270  Remarks:
271  Usage - _this->fn->setOrientation(_this, align, swapDimensions);
272 
273  Returns:
274  leResult - the result of the operation
275 */
292 virtual leResult setOrientation(leScrollBarWidget* _this,
293  leOrientation align,
294  leBool swapDimensions);
295 
296 // *****************************************************************************
297 /* Virtual Member Function:
298  uint32_t getMaximumValue(const leScrollBarWidget* _this)
299 
300  Summary:
301  Gets the maximum scroll value
302 
303  Description:
304  Gets the maximum scroll value
305 
306  Parameters:
307  const leScrollBarWidget* _this - The scroll bar widget to operate on
308 
309  Remarks:
310  Usage - _this->fn->getMaximumValue(_this);
311 
312  Returns:
313  uint32_t - the value
314 */
325 virtual uint32_t getMaximumValue(const leScrollBarWidget* _this);
326 
327 // *****************************************************************************
328 /* Virtual Member Function:
329  leResult setMaximumValue(leScrollBarWidget* _this,
330  uint32_t val)
331 
332  Summary:
333  Sets the maximum scroll value
334 
335  Description:
336  Sets the maximum scroll value
337 
338  Parameters:
339  leScrollBarWidget* _this - The scroll bar widget to operate on
340  uint32_t val - the value
341 
342  Remarks:
343  Usage - _this->fn->setMaximumValue(_this, val);
344 
345  Returns:
346  leResult - the result of the operation
347 */
361 virtual leResult setMaximumValue(leScrollBarWidget* _this,
362  uint32_t val);
363 
364 // *****************************************************************************
365 /* Virtual Member Function:
366  uint32_t getExtentValue(const leScrollBarWidget* _this)
367 
368  Summary:
369  Gets the extent value
370 
371  Description:
372  Gets the extent value
373 
374  Parameters:
375  const leScrollBarWidget* _this - The scroll bar widget to operate on
376 
377  Remarks:
378  Usage - _this->fn->getExtentValue(_this);
379 
380  Returns:
381  uint32_t - the value
382 */
393 virtual uint32_t getExtentValue(const leScrollBarWidget* _this);
394 
395 // *****************************************************************************
396 /* Virtual Member Function:
397  leResult setExtentValue(leScrollBarWidget* _this,
398  uint32_t val)
399 
400  Summary:
401  Sets the extent value
402 
403  Description:
404  Sets the extent value
405 
406  Parameters:
407  leScrollBarWidget* _this - The scroll bar widget to operate on
408  uint32_t val - the value
409 
410  Remarks:
411  Usage - _this->fn->setExtentValue(_this, val);
412 
413  Returns:
414  leResult - the result of the operation
415 */
429 virtual leResult setExtentValue(leScrollBarWidget* _this,
430  uint32_t val);
431 
432 
433 // *****************************************************************************
434 /* Virtual Member Function:
435  uint32_t getScrollPercentage(const leScrollBarWidget* _this)
436 
437  Summary:
438  Gets the scroll value as a percentage
439 
440  Description:
441  Gets the scroll value as a percentage
442 
443  Parameters:
444  const leScrollBarWidget* _this - The scroll bar widget to operate on
445 
446  Remarks:
447  Usage - _this->fn->getScrollPercentage(_this);
448 
449  Returns:
450  uint32_t - the scroll value percentage
451 */
462 virtual uint32_t getScrollPercentage(const leScrollBarWidget* _this);
463 
464 
465 // *****************************************************************************
466 /* Virtual Member Function:
467  leResult setScrollPercentage(leScrollBarWidget* _this,
468  uint32_t val)
469 
470  Summary:
471  Sets the scroll value using a percentage
472 
473  Description:
474  Sets the scroll value using a percentage
475 
476  Parameters:
477  leScrollBarWidget* _this - The scroll bar widget to operate on
478  uint32_t val - the percentage value
479 
480  Remarks:
481  Usage - _this->fn->setScrollPercentage(_this, val);
482 
483  Returns:
484  leResult - the result of the operation
485 */
499 virtual leResult setScrollPercentage(leScrollBarWidget* _this,
500  uint32_t val);
501 
502 // *****************************************************************************
503 /* Virtual Member Function:
504  uint32_t getScrollValue(const leScrollBarWidget* _this)
505 
506  Summary:
507  Gets the scroll value
508 
509  Description:
510  Gets the scroll value
511 
512  Parameters:
513  const leScrollBarWidget* _this - The scroll bar widget to operate on
514 
515  Remarks:
516  Usage - _this->fn->getScrollValue(_this);
517 
518  Returns:
519  uint32_t - the value
520 */
531 virtual uint32_t getScrollValue(const leScrollBarWidget* _this);
532 
533 // *****************************************************************************
534 /* Virtual Member Function:
535  leResult setScrollValue(leScrollBarWidget* _this,
536  uint32_t val)
537 
538  Summary:
539  Sets the scroll value
540 
541  Description:
542  Sets the scroll value
543 
544  Parameters:
545  leScrollBarWidget* _this - The scroll bar widget to operate on
546  uint32_t val - the value
547 
548  Remarks:
549  Usage - _this->fn->setScrollValue(_this, val);
550 
551  Returns:
552  leResult - the result of the operation
553 */
567 virtual leResult setScrollValue(leScrollBarWidget* _this,
568  uint32_t val);
569 
570 // *****************************************************************************
571 /* Virtual Member Function:
572  uint32_t getStepSize(const leScrollBarWidget* _this)
573 
574  Summary:
575  Gets the step size
576 
577  Description:
578  Gets the step size
579 
580  Parameters:
581  const leScrollBarWidget* _this - The scroll bar widget to operate on
582 
583  Remarks:
584  Usage - _this->fn->getStepSize(_this);
585 
586  Returns:
587  uint32_t - the step size
588 */
599 virtual uint32_t getStepSize(const leScrollBarWidget* _this);
600 
601 
602 // *****************************************************************************
603 /* Virtual Member Function:
604  leResult setStepSize(leScrollBarWidget* _this,
605  uint32_t val)
606 
607  Summary:
608  Sets the step size
609 
610  Description:
611  Sets the step size
612 
613  Parameters:
614  leScrollBarWidget* _this - The scroll bar widget to operate on
615  uint32_t val - the step size
616 
617  Remarks:
618  Usage - _this->fn->setStepSize(_this, val);
619 
620  Returns:
621  leResult - the result of the operation
622 */
636 virtual leResult setStepSize(leScrollBarWidget* _this,
637  uint32_t val);
638 
639 // *****************************************************************************
640 /* Virtual Member Function:
641  leResult stepBackward(leScrollBarWidget* _this)
642 
643  Summary:
644  Steps the value backwards
645 
646  Description:
647  Steps the value backwards
648 
649  Parameters:
650  leScrollBarWidget* _this - The scroll bar widget to operate on
651 
652  Remarks:
653  Usage - _this->fn->stepBackward(_this);
654 
655  Returns:
656  leResult - the result of the operation
657 */
668 virtual leResult stepBackward(leScrollBarWidget* _this);
669 
670 // *****************************************************************************
671 /* Virtual Member Function:
672  leResult stepForward(leScrollBarWidget* _this)
673 
674  Summary:
675  Steps the value forwards
676 
677  Description:
678  Steps the value forwards
679 
680  Parameters:
681  leScrollBarWidget* _this - The scroll bar widget to operate on
682 
683  Remarks:
684  Usage - _this->fn->stepForward(_this);
685 
686  Returns:
687  leResult - the result of the operation
688 */
699 virtual leResult stepForward(leScrollBarWidget* _this);
700 
711 virtual leScrollBarWidget_ValueChangedEvent getValueChangedEventCallback
712  (const leScrollBarWidget* _this);
713 
727 virtual leResult setValueChangedEventCallback(leScrollBarWidget* _this,
728  leScrollBarWidget_ValueChangedEvent cb);
729 
730 #undef THIS_TYPE
731 #endif
732 
733 #ifdef __cplusplus
734 }
735 #endif
736 
737 #endif // LE_SCROLLBAR_WIDGET_ENABLED
738 #endif /* LEGATO_SCROLLBAR_H */
Common macros and definitions used by Legato.
leResult
This enum represents function call results.
Definition: legato_common.h:123
Used to define a widget.
Definition: legato_widget.h:624
leOrientation
This enum represents the orientation modes for objects.
Definition: legato_common.h:329
This structure represents a integer Cartesian point.
Definition: legato_common.h:346
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
Definition: widget.py:1
Fixed string functions and definitions.