FLTK
Fl_Chart.H
1 //
2 // Forms chart header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2010 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 /* \file
18  Fl_Chart widget . */
19 
20 #ifndef Fl_Chart_H
21 #define Fl_Chart_H
22 
23 #ifndef Fl_Widget_H
24 #include "Fl_Widget.H"
25 #endif
26 
27 // values for type()
28 #define FL_BAR_CHART 0
29 #define FL_HORBAR_CHART 1
30 #define FL_LINE_CHART 2
31 #define FL_FILL_CHART 3
32 #define FL_SPIKE_CHART 4
33 #define FL_PIE_CHART 5
34 #define FL_SPECIALPIE_CHART 6
36 #define FL_FILLED_CHART FL_FILL_CHART
38 #define FL_CHART_MAX 128
39 #define FL_CHART_LABEL_MAX 18
42 struct FL_CHART_ENTRY {
43  float val;
44  unsigned col;
45  char str[FL_CHART_LABEL_MAX+1];
46 };
47 
70 class FL_EXPORT Fl_Chart : public Fl_Widget {
71  int numb;
72  int maxnumb;
73  int sizenumb;
74  FL_CHART_ENTRY *entries;
75  double min,max;
76  uchar autosize_;
77  Fl_Font textfont_;
78  Fl_Fontsize textsize_;
79  Fl_Color textcolor_;
80 protected:
81  void draw();
82 public:
83  Fl_Chart(int X, int Y, int W, int H, const char *L = 0);
84 
85  ~Fl_Chart();
86 
87  void clear();
88 
89  void add(double val, const char *str = 0, unsigned col = 0);
90 
91  void insert(int ind, double val, const char *str = 0, unsigned col = 0);
92 
93  void replace(int ind, double val, const char *str = 0, unsigned col = 0);
94 
99  void bounds(double *a,double *b) const {*a = min; *b = max;}
100 
101  void bounds(double a,double b);
102 
106  int size() const {return numb;}
107 
108  void size(int W, int H) { Fl_Widget::size(W, H); }
109 
113  int maxsize() const {return maxnumb;}
114 
115  void maxsize(int m);
116 
118  Fl_Font textfont() const {return textfont_;}
120  void textfont(Fl_Font s) {textfont_ = s;}
121 
123  Fl_Fontsize textsize() const {return textsize_;}
125  void textsize(Fl_Fontsize s) {textsize_ = s;}
126 
128  Fl_Color textcolor() const {return textcolor_;}
130  void textcolor(Fl_Color n) {textcolor_ = n;}
131 
136  uchar autosize() const {return autosize_;}
137 
142  void autosize(uchar n) {autosize_ = n;}
143 };
144 
145 #endif
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
float val
For internal use only.
Definition: Fl_Chart.H:43
Fl_Color textcolor() const
Gets the chart's text color.
Definition: Fl_Chart.H:128
virtual void draw()=0
Draws the widget.
Fl_Chart displays simple charts.
Definition: Fl_Chart.H:70
void textfont(Fl_Font s)
Sets the chart's text font to s.
Definition: Fl_Chart.H:120
void size(int W, int H)
Changes the size of the widget.
Definition: Fl_Widget.H:328
int maxsize() const
Gets the maximum number of data values for a chart.
Definition: Fl_Chart.H:113
void bounds(double *a, double *b) const
Gets the lower and upper bounds of the chart values.
Definition: Fl_Chart.H:99
For internal use only.
Definition: Fl_Chart.H:42
int size() const
Returns the number of data values in the chart.
Definition: Fl_Chart.H:106
unsigned col
For internal use only.
Definition: Fl_Chart.H:44
Fl_Widget, Fl_Label classes .
Fl_Font textfont() const
Gets the chart's text font.
Definition: Fl_Chart.H:118
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:1014
void autosize(uchar n)
Set whether the chart will automatically adjust the bounds of the chart.
Definition: Fl_Chart.H:142
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:1042
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:985
void textcolor(Fl_Color n)
gets the chart's text color to n.
Definition: Fl_Chart.H:130
Fl_Fontsize textsize() const
Gets the chart's text size.
Definition: Fl_Chart.H:123
uchar autosize() const
Get whether the chart will automatically adjust the bounds of the chart.
Definition: Fl_Chart.H:136
void textsize(Fl_Fontsize s)
gets the chart's text size to s.
Definition: Fl_Chart.H:125
unsigned char uchar
unsigned char
Definition: fl_types.h:28