MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_bar_graph.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_bar_graph.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements bar graph drawing widget functions.
38 *******************************************************************************/
45 #ifndef LEGATO_WIDGET_BAR_GRAPH_H
46 #define LEGATO_WIDGET_BAR_GRAPH_H
47 
49 
50 #if LE_BARGRAPH_WIDGET_ENABLED == 1
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
58 
59 // *****************************************************************************
60 // *****************************************************************************
61 // Section: Data Types and Constants
62 // *****************************************************************************
63 // *****************************************************************************
64 
65 
66 // *****************************************************************************
67 /* Enumeration:
68  leBarGraphValueAxis
69 
70  Summary:
71  The value axis index value
72 */
77 typedef enum leBarGraphValueAxis
78 {
79  BAR_GRAPH_AXIS_0 = 0,
80 // BAR_GRAPH_AXIS_1, //unsupported
81 } leBarGraphValueAxis;
82 
83 // *****************************************************************************
84 /* Enumeration:
85  leBarGraphTickPosition
86 
87  Summary:
88  The tick position relative to axis
89 */
95 typedef enum leBarGraphTickPosition
96 {
97  BAR_GRAPH_TICK_IN,
98  BAR_GRAPH_TICK_OUT,
99  BAR_GRAPH_TICK_CENTER,
100 } leBarGraphTickPosition;
101 
102 // *****************************************************************************
103 /* Structure:
104  leBarGraphDataSeries
105 
106  Summary:
107  The data series object that contains the series properties and data
108 
109  Description:
110 
111 
112  Remarks:
113  None.
114 */
120 typedef struct leBarGraphDataSeries
121 {
122  const leScheme* scheme;
123  leArray data;
124  leBarGraphValueAxis axis;
125 } leBarGraphDataSeries;
126 
127 typedef struct leBarGraphCategory
128 {
129  const leString* str;
130  uint32_t drawX;
131 } leBarGraphCategory;
132 
133 /* internal use only */typedef struct leBarGraphWidget leBarGraphWidget;
138 
139 #define LE_BARGRAPHWIDGET_VTABLE(THIS_TYPE) \
140  LE_WIDGET_VTABLE(THIS_TYPE) \
141  \
142  uint32_t (*getTickLength)(const THIS_TYPE* _this); \
143  leResult (*setTickLength)(THIS_TYPE* _this, uint32_t len); \
144  uint32_t (*getMinValue)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
145  leResult (*setMinValue)(THIS_TYPE* _this, leBarGraphValueAxis axis, int32_t min); \
146  uint32_t (*getMaxValue)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
147  leResult (*setMaxValue)(THIS_TYPE* _this, leBarGraphValueAxis axis, int32_t max); \
148  leBool (*getValueAxisLabelsVisible)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
149  leResult (*setValueAxisLabelsVisible)(THIS_TYPE* _this, leBarGraphValueAxis axis, leBool vis); \
150  leBool (*getValueAxisTicksVisible)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
151  leResult (*setValueAxisTicksVisible)(THIS_TYPE* _this, leBarGraphValueAxis axis, leBool vis); \
152  uint32_t (*getValueAxisTicksInterval)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
153  leResult (*setValueAxisTicksInterval)(THIS_TYPE* _this, leBarGraphValueAxis axis, uint32_t itv); \
154  leBarGraphTickPosition (*getValueAxisTicksPosition)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
155  leResult (*setValueAxisTicksPosition)(THIS_TYPE* _this, leBarGraphValueAxis axis, leBarGraphTickPosition pos); \
156  leBool (*getValueAxisSubticksVisible)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
157  leResult (*setValueAxisSubticksVisible)(THIS_TYPE* _this, leBarGraphValueAxis axis, leBool vis); \
158  uint32_t (*getValueAxisSubticksInterval)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
159  leResult (*setValueAxisSubticksInterval)(THIS_TYPE* _this, leBarGraphValueAxis axis, uint32_t itv); \
160  leBarGraphTickPosition (*getValueAxisSubticksPosition)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
161  leResult (*setValueAxisSubticksPosition)(THIS_TYPE* _this, leBarGraphValueAxis axis, leBarGraphTickPosition pos); \
162  leBool (*getCategoryAxisTicksVisible)(const THIS_TYPE* _this); \
163  leResult (*setCategoryAxisTicksVisible)(THIS_TYPE* _this, leBool vis); \
164  leBarGraphTickPosition (*getCategoryAxisTicksPosition)(const THIS_TYPE* _this); \
165  leResult (*setCategoryAxisTicksPosition)(THIS_TYPE* _this, leBarGraphTickPosition pos); \
166  leBool (*getCategoryAxisLabelsVisible)(const THIS_TYPE* _this); \
167  leResult (*setCategoryAxisLabelsVisible)(THIS_TYPE* _this, leBool vis); \
168  leResult (*addSeries)(THIS_TYPE* _this, uint32_t* seriesID); \
169  leScheme* (*getSeriesScheme)(const THIS_TYPE* _this, uint32_t seriesID); \
170  leResult (*setSeriesScheme)(THIS_TYPE* _this, uint32_t seriesID, const leScheme* schm); \
171  leResult (*addDataToSeries)(THIS_TYPE* _this, uint32_t seriesID, int32_t val, uint32_t* idx); \
172  leResult (*setDataInSeries)(THIS_TYPE* _this, uint32_t seriesID, uint32_t index, int32_t value); \
173  leResult (*clearData)(THIS_TYPE* _this); \
174  leFont* (*getTicksLabelFont)(THIS_TYPE* _this); \
175  leResult (*setTicksLabelFont)(THIS_TYPE* _this, const leFont* font); \
176  leBool (*getGridLinesVisible)(const THIS_TYPE* _this, leBarGraphValueAxis axis); \
177  leResult (*setGridLinesVisible)(THIS_TYPE* _this, leBarGraphValueAxis axis, leBool vis); \
178  leResult (*addCategory)(THIS_TYPE* _this, uint32_t* id); \
179  leString* (*getCategoryString)(const THIS_TYPE* _this, uint32_t id); \
180  leResult (*setCategoryString)(THIS_TYPE* _this, uint32_t id, const leString* str); \
181  leBool (*getStacked)(const THIS_TYPE* _this); \
182  leResult (*setStacked)(THIS_TYPE* _this, leBool stk); \
183  leBool (*getFillGraphArea)(const THIS_TYPE* _this); \
184  leResult (*setFillGraphArea)(THIS_TYPE* _this, leBool fill); \
185 
186 
187 typedef struct leBarGraphWidgetVTable
188 {
189  LE_BARGRAPHWIDGET_VTABLE(leBarGraphWidget)
190 } leBarGraphWidgetVTable;
191 
197 // *****************************************************************************
198 /* Structure:
199  leBarGraphWidget
200 
201  Summary:
202  Implementation of a bar graph widget.
203 
204  Description:
205  A bar graph widget draws a bar graph. All coordinates are expressed in local widget space.
206 
207  The color of the graph is determined by the widget scheme's 'foreground'
208  color.
209 
210  Remarks:
211  None.
212 */
219 typedef struct leBarGraphWidget
220 {
221  leWidget widget; // base widget header
222 
223  const leBarGraphWidgetVTable* fn;
224 
225  uint32_t tickLength;
226  leBool fillGraphArea;
227 
228  //Value axis properties
229  int32_t maxValue;
230  int32_t minValue;
231  uint32_t tickInterval;
232  uint32_t subtickInterval;
233  leBool valueAxisLabelsVisible;
234  leBool valueAxisTicksVisible;
235  leBool valueAxisSubticksVisible;
236  leBool valueGridLinesVisible;
237  leBool stacked;
238  leArray dataSeriesArray;
239  const leFont* ticksLabelFont;
240  leBarGraphTickPosition valueAxisTicksPosition;
241  leBarGraphTickPosition valueAxisSubticksPosition;
242 
243  //Category axis properties
244  leBool categAxisLabelsVisible;
245  leBool categAxisTicksVisible;
246  leBarGraphTickPosition categAxisTicksPosition;
247  leArray categories;
248 } leBarGraphWidget;
249 
250 // *****************************************************************************
251 // *****************************************************************************
252 // Section: Routines
253 // *****************************************************************************
254 // *****************************************************************************
255 
267 leBarGraphWidget* leBarGraphWidget_New(void);
268 
279 void leBarGraphWidget_Constructor(leBarGraphWidget* wgt);
280 
281 #ifdef _DOXYGEN_
282 #define THIS_TYPE struct leWidget
283 
295 uint32_t getTickLength(const leBarGraphWidget* _this);
296 
297 
312 virtual leResult setTickLength(leBarGraphWidget* _this,
313  uint32_t len);
314 
315 
329 virtual uint32_t getMinValue(const leBarGraphWidget* _this,
330  leBarGraphValueAxis axis);
331 
348 virtual leResult setMinValue(leBarGraphWidget* _this,
349  leBarGraphValueAxis axis,
350  int32_t min);
351 
352 
366 virtual uint32_t getMaxValue(const leBarGraphWidget* _this,
367  leBarGraphValueAxis axis);
368 
385 virtual leResult setMaxValue(leBarGraphWidget* _this,
386  leBarGraphValueAxis axis,
387  int32_t max);
388 
402 virtual leBool getValueAxisLabelsVisible(const leBarGraphWidget* _this,
403  leBarGraphValueAxis axis);
404 
405 
422 virtual leResult setValueAxisLabelsVisible(leBarGraphWidget* _this,
423  leBarGraphValueAxis axis,
424  leBool vis);
425 
426 
440 virtual leBool getValueAxisTicksVisible(const leBarGraphWidget* _this,
441  leBarGraphValueAxis axis);
442 
443 
460 virtual leResult setValueAxisTicksVisible(leBarGraphWidget* _this,
461  leBarGraphValueAxis axis,
462  leBool vis);
463 
464 
478 virtual uint32_t getValueAxisTicksInterval(const leBarGraphWidget* _this,
479  leBarGraphValueAxis axis);
480 
481 
498 virtual leResult setValueAxisTicksInterval(leBarGraphWidget* _this,
499  leBarGraphValueAxis axis,
500  uint32_t itv);
501 
502 
503 
517 virtual leBarGraphTickPosition getValueAxisTicksPosition(const leBarGraphWidget* _this,
518  leBarGraphValueAxis axis);
519 
536 virtual leResult setValueAxisTicksPosition(leBarGraphWidget* _this,
537  leBarGraphValueAxis axis,
538  leBarGraphTickPosition pos);
539 
540 
541 
555 virtual leBool getValueAxisSubticksVisible(const leBarGraphWidget* _this,
556  leBarGraphValueAxis axis);
557 
558 
575 virtual leResult setValueAxisSubticksVisible(leBarGraphWidget* _this,
576  leBarGraphValueAxis axis,
577  leBool vis);
578 
579 
580 
594 virtual uint32_t getValueAxisSubticksInterval(const leBarGraphWidget* _this,
595  leBarGraphValueAxis axis);
596 
597 
614 virtual leResult setValueAxisSubticksInterval(leBarGraphWidget* _this,
615  leBarGraphValueAxis axis,
616  uint32_t itv);
617 
618 
632 virtual leBarGraphTickPosition getValueAxisSubticksPosition(const leBarGraphWidget* _this,
633  leBarGraphValueAxis axis);
634 
635 
651 virtual leResult setValueAxisSubticksPosition(leBarGraphWidget* _this,
652  leBarGraphValueAxis axis,
653  leBarGraphTickPosition pos);
654 
655 
667 virtual leBool getCategoryAxisTicksVisible(const leBarGraphWidget* _this);
668 
682 virtual leResult setCategoryAxisTicksVisible(leBarGraphWidget* _this,
683  leBool vis);
684 
696 virtual leBarGraphTickPosition getCategoryAxisTicksPosition(const leBarGraphWidget* _this);
697 
711 virtual leResult setCategoryAxisTicksPosition(leBarGraphWidget* _this,
712  leBarGraphTickPosition pos)
713 
714 
729 virtual leResult setCategoryAxisLabelsVisible(leBarGraphWidget* _this,
730  leBool vis)
731 
732 
745 virtual leResult addSeries(leBarGraphWidget* _this,
746  uint32_t* seriesID);
747 
760 virtual leScheme* getSeriesScheme(const leBarGraphWidget* _this,
761  uint32_t seriesID);
762 
779 leResult setSeriesScheme(leBarGraphWidget* _this,
780  uint32_t seriesID,
781  const leScheme* schm);
782 
801  leResult setDataInSeries(leBarGraphWidget* _this,
802  uint32_t seriesID,
803  uint32_t index,
804  int32_t value)
805 
806 
816 virtual leResult clearData(leBarGraphWidget* _this);
817 
818 
829 virtual leFont* getTicksLabelFont(leBarGraphWidget* _this);
830 
831 
845 virtual leResult setTicksLabelFont(const leBarGraphWidget* _this,
846  const leFont* font);
847 
861 virtual leBool getGridLinesVisible(const leBarGraphWidget* _this,
862  leBarGraphValueAxis axis);
863 
880 virtual leResult setGridLinesVisible(leBarGraphWidget* _this,
881  leBarGraphValueAxis axis,
882  leBool vis);
883 
897 virtual leResult addCategory(leBarGraphWidget* _this,
898  uint32_t* id);
899 
913 virtual leString* getCategoryString(const leBarGraphWidget* _this,
914  uint32_t id);
915 
931 virtual leResult setCategoryString(leBarGraphWidget* _this,
932  uint32_t id,
933  const leString* str);
934 
945 virtual leBool getStacked(const leBarGraphWidget* _this);
946 
960 virtual leResult setStacked(leBarGraphWidget* _this,
961  leBool stk);
962 
973 virtual leBool getFillGraphArea(const leBarGraphWidget* _this);
974 
987 virtual leResult setFillGraphArea(THIS_TYPE* _this,
988  leBool fill);
989 #undef THIS_TYPE
990 #endif
991 
992 #ifdef __cplusplus
993 }
994 #endif
995 
996 #endif // LE_BARGRAPH_WIDGET_ENABLED
997 #endif /* LEGATO_WIDGET_BAR_GRAPH_H */
Common macros and definitions used by Legato.
This struct represents a string.
Definition: legato_string.h:107
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.
Used to define a widget.
Definition: legato_widget.h:624
This struct represents a array.
Definition: legato_array.h:64
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
Definition: scheme.py:1
Definition: legato_scheme.h:154
Definition: widget.py:1