MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_widget_pie_chart.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_pie_chart.h
32 
33  Summary:
34 
35 
36  Description:
37  This module implements pie chart drawing widget functions.
38 *******************************************************************************/
45 #ifndef LEGATO_WIDGET_PIE_CHART_H
46 #define LEGATO_WIDGET_PIE_CHART_H
47 
49 
50 #if LE_PIECHART_WIDGET_ENABLED == 1
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
58 
59 // *****************************************************************************
60 // *****************************************************************************
61 // Section: Data Types and Constants
62 // *****************************************************************************
63 // *****************************************************************************
68 typedef struct lePieChartPie
69 {
70  uint32_t value;
71  uint32_t radius;
72  uint32_t offset;
73  const leScheme* scheme;
74  uint32_t startAngle;
75  uint32_t spanAngle;
76  uint32_t percentOffset;
77  uint32_t percentValue;
78 } lePieChartPie;
79 
80 typedef struct lePieChartWidget lePieChartWidget;
81 
82 // *****************************************************************************
83 /* Function Pointer:
84  lePieChartWidget_PressedEvent
85 
86  Summary:
87  Chart pressed event function callback type
88 */
93 typedef void (* lePieChartWidget_PressedEvent)(lePieChartWidget*, uint32_t);
94 
95 
96 /* internal use only */
101 typedef struct lePieChartWidget lePieChartWidget;
102 
103 #define LE_PIECHARTWIDGET_VTABLE(THIS_TYPE) \
104  LE_WIDGET_VTABLE(THIS_TYPE) \
105  \
106  int32_t (*getStartAngle)(const THIS_TYPE* _this); \
107  leResult (*setStartAngle)(THIS_TYPE* _this, int32_t ang); \
108  int32_t (*getCenterAngle)(const THIS_TYPE* _this); \
109  leResult (*setCenterAngle)(THIS_TYPE* _this, int32_t ang); \
110  int32_t (*addEntry)(THIS_TYPE* _this); \
111  leResult (*clear)(THIS_TYPE* _this); \
112  uint32_t (*getEntryValue)(const THIS_TYPE* _this, int32_t idx); \
113  leResult (*setEntryValue)(THIS_TYPE* _this, int32_t idx, uint32_t val); \
114  uint32_t (*getEntryRadius)(const THIS_TYPE* _this, int32_t idx); \
115  leResult (*setEntryRadius)(THIS_TYPE* _this, int32_t idx, uint32_t rad); \
116  uint32_t (*getEntryOffset)(const THIS_TYPE* _this, int32_t idx); \
117  leResult (*setEntryOffset)(THIS_TYPE* _this, int32_t idx, uint32_t offs); \
118  leScheme* (*getEntryScheme)(const THIS_TYPE* _this, int32_t idx); \
119  leResult (*setEntryScheme)(THIS_TYPE* _this, int32_t idx, const leScheme* schm); \
120  lePieChartWidget_PressedEvent (*getPressedEventCallback)(const THIS_TYPE* _this); \
121  leResult (*setPressedEventCallback)(THIS_TYPE* _this, lePieChartWidget_PressedEvent cb); \
122  leFont* (*getLabelFont)(const THIS_TYPE* _this); \
123  leResult (*setLabelFont)(THIS_TYPE* _this, const leFont* fnt); \
124  leBool (*getLabelsVisible)(const THIS_TYPE* _this); \
125  leResult (*setLabelsVisible)(THIS_TYPE* _this, leBool vis); \
126  uint32_t (*getLabelsOffset)(const THIS_TYPE* _this); \
127  leResult (*setLabelsOffset)(THIS_TYPE* _this, uint32_t offs); \
128 
129 typedef struct lePieChartWidgetVTable
130 {
131  LE_PIECHARTWIDGET_VTABLE(lePieChartWidget)
132 } lePieChartWidgetVTable;
133 
139 // *****************************************************************************
146 typedef struct lePieChartWidget
147 {
148  leWidget widget; // base widget header
149 
150  const lePieChartWidgetVTable* fn;
151 
152  uint32_t startAngle; //the start angle of the chart
153  int32_t centerAngle; //the center angle of the chart
154 
155  leArray pieArray; //list of pie/data
156 
157  //Label properties
158  leBool labelsVisible; // are labels visible
159  uint32_t labelsOffset; // offset of labels from center of pie
160  const leFont* labelFont; // label
161 
162  lePieChartWidget_PressedEvent pressedCallback;
163 } lePieChartWidget;
164 
165 // *****************************************************************************
166 // *****************************************************************************
167 // Section: Routines
168 // *****************************************************************************
169 // *****************************************************************************
170 
182 lePieChartWidget* lePieChartWidget_New(void);
183 
194 void lePieChartWidget_Constructor(lePieChartWidget* wgt);
195 
196 #ifdef _DOXYGEN_
197 #define THIS_TYPE struct leWidget
198 
199 // *****************************************************************************
200 /* Virtual Member Function:
201  int32_t getStartAngle(const lePieChartWidget* _this)
202 
203  Summary:
204  Gets the start angle
205 
206  Description:
207  Gets the start angle
208 
209  Parameters:
210  const lePieChartWidget* _this - The pie chart widget to operate on
211 
212  Remarks:
213  Usage - _this->fn->getStartAngle(_this);
214 
215  Returns:
216  int32_t - the angle value
217 */
228 virtual int32_t getStartAngle(const lePieChartWidget* _this);
229 
230 
231 // *****************************************************************************
232 /* Virtual Member Function:
233  leResult setStartAngle(lePieChartWidget* _this,
234  int32_t ang)
235 
236  Summary:
237  Sets the start angle
238 
239  Description:
240  Sets the start angle
241 
242  Parameters:
243  lePieChartWidget* _this - The pie chart widget to operate on
244  int32_t ang - the angle value
245 
246  Remarks:
247  Usage - _this->fn->setStartAngle(_this, ang);
248 
249  Returns:
250  leResult - the result of the operation
251 */
264 virtual leResult setVisibleItemCount(lePieChartWidget* _this,
265  uint32_t cnt);
266 
267 
268 // *****************************************************************************
269 /* Virtual Member Function:
270  int32_t getCenterAngle(const lePieChartWidget* _this)
271 
272  Summary:
273  Gets the center angle
274 
275  Description:
276  Gets the center angle
277 
278  Parameters:
279  const lePieChartWidget* _this - The pie chart widget to operate on
280 
281  Remarks:
282  Usage - _this->fn->getCenterAngle(_this);
283 
284  Returns:
285  int32_t - the angle value
286 */
297 virtual int32_t getCenterAngle(const lePieChartWidget* _this);
298 
299 // *****************************************************************************
300 /* Virtual Member Function:
301  leResult setCenterAngle(lePieChartWidget* _this,
302  int32_t ang)
303 
304  Summary:
305  Sets the start angle
306 
307  Description:
308  Sets the start angle
309 
310  Parameters:
311  lePieChartWidget* _this - The pie chart widget to operate on
312  int32_t ang - the angle value
313 
314  Remarks:
315  Usage - _this->fn->setCenterAngle(_this, ang);
316 
317  Returns:
318  leResult - the result of the operation
319 */
332 virtual leResult setVisibleItemCount(lePieChartWidget* _this,
333  uint32_t cnt);
334 
335 // *****************************************************************************
336 /* Virtual Member Function:
337  int32_t addEntry(lePieChartWidget* _this)
338 
339  Summary:
340  Adds a pie entry
341 
342  Description:
343  Adds a pie entry
344 
345  Parameters:
346  lePieChartWidget* _this - The pie chart widget to operate on
347 
348  Remarks:
349  Usage - _this->fn->addEntry(_this);
350 
351  Returns:
352  int32_t - the index of the new entry
353 */
364 virtual int32_t getCenterAngle(const lePieChartWidget* _this);
365 
366 // *****************************************************************************
367 /* Virtual Member Function:
368  leResult clear(lePieChartWidget* _this)
369 
370  Summary:
371  Clears all pie entries
372 
373  Description:
374  Clears all pie entries
375 
376  Parameters:
377  lePieChartWidget* _this - The pie chart widget to operate on
378 
379  Remarks:
380  Usage - _this->fn->clear(_this);
381 
382  Returns:
383  leResult - the result of the operation
384 */
395 virtual leResult clear(lePieChartWidget* _this);
396 
397 // *****************************************************************************
398 /* Virtual Member Function:
399  uint32_t getEntryValue(const lePieChartWidget* _this,
400  int32_t idx)
401 
402  Summary:
403  Gets an entry value
404 
405  Description:
406  Gets an entry value
407 
408  Parameters:
409  const lePieChartWidget* _this - The pie chart widget to operate on
410  int32_t idx - the index
411 
412  Remarks:
413  Usage - _this->fn->getEntryValue(_this, idx);
414 
415  Returns:
416  uint32_t - the value
417 */
429 virtual uint32_t getEntryValue(const lePieChartWidget* _this,
430  int32_t idx);
431 
432 // *****************************************************************************
433 /* Virtual Member Function:
434  leResult setEntryValue(lePieChartWidget* _this,
435  int32_t idx,
436  uint32_t val)
437 
438  Summary:
439  Sets an entry value
440 
441  Description:
442  Sets an entry value
443 
444  Parameters:
445  lePieChartWidget* _this - The pie chart widget to operate on
446  int32_t idx - the index
447  uint32_t val - the value
448 
449  Remarks:
450  Usage - _this->fn->setEntryValue(_this, idx, val);
451 
452  Returns:
453  leResult - the result of the operation
454 */
468 virtual leResult setEntryValue(lePieChartWidget* _this,
469  int32_t idx,
470  uint32_t val);
471 
472 // *****************************************************************************
473 /* Virtual Member Function:
474  uint32_t getEntryRadius(const lePieChartWidget* _this,
475  int32_t idx)
476 
477  Summary:
478  Gets an entry radius
479 
480  Description:
481  Gets an entry radius
482 
483  Parameters:
484  const lePieChartWidget* _this - The pie chart widget to operate on
485  int32_t idx - the index
486 
487  Remarks:
488  Usage - _this->fn->getEntryRadius(_this, idx);
489 
490  Returns:
491  uint32_t - the radius value
492 */
504 virtual uint32_t getEntryRadius(const lePieChartWidget* _this,
505  int32_t idx);
506 
507 // *****************************************************************************
508 /* Virtual Member Function:
509  leResult setEntryRadius(lePieChartWidget* _this,
510  int32_t idx,
511  uint32_t rad)
512 
513  Summary:
514  Sets an entry radius
515 
516  Description:
517  Sets an entry radius
518 
519  Parameters:
520  lePieChartWidget* _this - The pie chart widget to operate on
521  int32_t idx - the index
522  uint32_t rad - the radius value
523 
524  Remarks:
525  Usage - _this->fn->setEntryRadius(_this, idx, rad);
526 
527  Returns:
528  leResult - the result of the operation
529 */
543 virtual leResult setEntryRadius(lePieChartWidget* _this,
544  int32_t idx,
545  uint32_t rad);
546 
547 // *****************************************************************************
548 /* Virtual Member Function:
549  uint32_t getEntryOffset(const lePieChartWidget* _this,
550  int32_t idx)
551 
552  Summary:
553  Gets an entry offset
554 
555  Description:
556  Gets an entry offset
557 
558  Parameters:
559  const lePieChartWidget* _this - The pie chart widget to operate on
560  int32_t idx - the index
561 
562  Remarks:
563  Usage - _this->fn->getEntryOffset(_this, idx);
564 
565  Returns:
566  uint32_t - the offset value
567 */
580 virtual uint32_t getEntryOffset(const lePieChartWidget* _this,
581  int32_t idx);
582 
583 // *****************************************************************************
584 /* Virtual Member Function:
585  leResult setEntryOffset(lePieChartWidget* _this,
586  int32_t idx,
587  uint32_t offs)
588 
589  Summary:
590  Sets an entry offset
591 
592  Description:
593  Sets an entry offset
594 
595  Parameters:
596  lePieChartWidget* _this - The pie chart widget to operate on
597  int32_t idx - the index
598  uint32_t offs - the offset value
599 
600  Remarks:
601  Usage - _this->fn->setEntryOffset(_this, idx, offs);
602 
603  Returns:
604  leResult - the result of the operation
605 */
619 virtual leResult setEntryOffset(lePieChartWidget* _this,
620  int32_t idx,
621  uint32_t offs);
622 
623 // *****************************************************************************
624 /* Virtual Member Function:
625  leScheme* getEntryScheme(const lePieChartWidget* _this,
626  int32_t idx)
627 
628  Summary:
629  Gets an entry scheme
630 
631  Description:
632  Gets an entry scheme
633 
634  Parameters:
635  const lePieChartWidget* _this - The pie chart widget to operate on
636  int32_t idx - the index
637 
638  Remarks:
639  Usage - _this->fn->getEntryScheme(_this, idx);
640 
641  Returns:
642  leScheme* - the scheme pointer
643 */
656 virtual leScheme* getEntryScheme(const lePieChartWidget* _this,
657  int32_t idx);
658 
659 // *****************************************************************************
660 /* Virtual Member Function:
661  leResult setEntryScheme(lePieChartWidget* _this,
662  int32_t idx,
663  const leScheme* schm)
664 
665  Summary:
666  Sets an entry scheme
667 
668  Description:
669  Sets an entry scheme
670 
671  Parameters:
672  lePieChartWidget* _this - The pie chart widget to operate on
673  int32_t idx - the index
674  const leScheme* schm - the scheme pointer
675 
676  Remarks:
677  Usage - _this->fn->setEntryScheme(_this, idx, schm);
678 
679  Returns:
680  leResult - the result of the operation
681 */
697 virtual leResult setEntryScheme(lePieChartWidget* _this,
698  int32_t idx,
699  const leScheme* schm);
700 
701 // *****************************************************************************
702 /* Virtual Member Function:
703  leFont* getLabelFont(const lePieChartWidget* _this)
704 
705  Summary:
706  Gets the label font
707 
708  Description:
709  Gets the label font
710 
711  Parameters:
712  const lePieChartWidget* _this - The pie chart widget to operate on
713 
714  Remarks:
715  Usage - _this->fn->getLabelFont(_this);
716 
717  Returns:
718  leFont* - the font pointer
719 */
730 virtual leFont* getLabelFont(const lePieChartWidget* _this);
731 
732 // *****************************************************************************
733 /* Virtual Member Function:
734  leResult setLabelFont(lePieChartWidget* _this,
735  const leFont* fnt)
736 
737  Summary:
738  Sets the label font
739 
740  Description:
741  Sets the label font
742 
743  Parameters:
744  lePieChartWidget* _this - The pie chart widget to operate on
745  const leFont* fnt - the font pointer
746 
747  Remarks:
748  Usage - _this->fn->setLabelFont(_this, fnt);
749 
750  Returns:
751  leResult - the result of the operation
752 */
767 virtual leResult setLabelFont(lePieChartWidget* _this,
768  const leFont* fnt);
769 
770 // *****************************************************************************
771 /* Virtual Member Function:
772  leBool getLabelsVisible(const lePieChartWidget* _this)
773 
774  Summary:
775  Gets the label visible setting value
776 
777  Description:
778  Gets the label visible setting value
779 
780  Parameters:
781  const lePieChartWidget* _this - The pie chart widget to operate on
782 
783  Remarks:
784  Usage - _this->fn->getLabelsVisible(_this);
785 
786  Returns:
787  leBool - the visibility setting
788 */
799 virtual leBool getLabelsVisible(const lePieChartWidget* _this);
800 
801 // *****************************************************************************
802 /* Virtual Member Function:
803  leResult setLabelsVisible(lePieChartWidget* _this,
804  leBool vis)
805 
806  Summary:
807  Sets the label visible setting value
808 
809  Description:
810  Sets the label visible setting value
811 
812  Parameters:
813  lePieChartWidget* _this - The pie chart widget to operate on
814  leBool vis - the visibility setting
815 
816  Remarks:
817  Usage - _this->fn->setLabelsVisible(_this, vis);
818 
819  Returns:
820  leResult - the result of the operation
821 */
835 virtual leResult setLabelsVisible(lePieChartWidget* _this,
836  leBool vis);
837 
838 // *****************************************************************************
839 /* Virtual Member Function:
840  uint32_t getLabelsOffset(const lePieChartWidget* _this)
841 
842  Summary:
843  Gets the label offset value
844 
845  Description:
846  Gets the label offset value
847 
848  Parameters:
849  const lePieChartWidget* _this - The pie chart widget to operate on
850 
851  Remarks:
852  Usage - _this->fn->getLabelsOffset(_this);
853 
854  Returns:
855  uint32_t - the offset value
856 */
867 virtual uint32_t getLabelsOffset(const lePieChartWidget* _this);
868 
869 // *****************************************************************************
870 /* Virtual Member Function:
871  leResult setLabelsOffset(lePieChartWidget* _this,
872  uint32_t offs)
873 
874  Summary:
875  Sets the label offset value
876 
877  Description:
878  Sets the label offset value
879 
880  Parameters:
881  lePieChartWidget* _this - The pie chart widget to operate on
882  uint32_t offs - the offset value
883 
884  Remarks:
885  Usage - _this->fn->setLabelsOffset(_this, offs);
886 
887  Returns:
888  leResult - the result of the operation
889 */
903 virtual leResult setLabelsOffset(lePieChartWidget* _this,
904  uint32_t offs);
905 
916 virtual lePieChartWidget_PressedEvent getPressedEventCallback
917  (const lePieChartWidget* _this);
918 
932 virtual leResult setPressedEventCallback(lePieChartWidget* _this,
933  lePieChartWidget_PressedEvent cb);
934 
935 #undef THIS_TYPE
936 #endif
937 
938 #ifdef __cplusplus
939 }
940 #endif
941 
942 #endif // LE_PIECHART_WIDGET_ENABLED
943 #endif /* LEGATO_WIDGET_PIE_CHART_H */
Common macros and definitions used by Legato.
Font functions and definitions.
This struct represents a font object.
Definition: legato_font.h:156
virtual int32_t getCenterAngle(const leArcWidget *_this)
Get thickness of an arc.
leResult
This enum represents function call results.
Definition: legato_common.h:123
This struct represents a array.
Definition: legato_array.h:64
Used to define a widget.
Definition: legato_widget.h:624
virtual void clear(leString *_this)
Clear string.
Legato widget definitions.
leBool
This enum represents booleans.
Definition: legato_common.h:146
virtual int32_t getStartAngle(const leArcWidget *_this)
Get start angle of the arc.
Definition: scheme.py:1
Definition: legato_scheme.h:154
Definition: widget.py:1