FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Chart.H
Go to the documentation of this file.
1//
2// Fl_Chart widget header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2023 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
20
21#ifndef Fl_Chart_H
22#define Fl_Chart_H
23
24#ifndef Fl_Widget_H
25#include "Fl_Widget.H"
26#endif
27
28// values for type()
29#define FL_BAR_CHART 0
30#define FL_HORBAR_CHART 1
31#define FL_LINE_CHART 2
32#define FL_FILL_CHART 3
33#define FL_SPIKE_CHART 4
34#define FL_PIE_CHART 5
35#define FL_SPECIALPIE_CHART 6
36
37#define FL_FILLED_CHART FL_FILL_CHART
38
39#define FL_CHART_MAX 128
40#define FL_CHART_LABEL_MAX 18
41
43 struct FL_CHART_ENTRY {
44 float val;
45 unsigned col;
46 char str[FL_CHART_LABEL_MAX + 1];
47};
48
71 class FL_EXPORT Fl_Chart : public Fl_Widget {
72 int numb;
73 int maxnumb;
74 int sizenumb;
75 FL_CHART_ENTRY *entries;
76 double min, max;
77 uchar autosize_;
78 Fl_Font textfont_;
79 Fl_Fontsize textsize_;
80 Fl_Color textcolor_;
81
82 protected:
83 void draw() FL_OVERRIDE;
84
85 // (static) protected draw methods (STR 2022)
86 // these methods are documented in src/Fl_Chart.cxx
87
88 static void draw_barchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[],
89 double min, double max, int autosize, int maxnumb, Fl_Color textcolor);
90
91 static void draw_horbarchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[],
92 double min, double max, int autosize, int maxnumb,
93 Fl_Color textcolor);
94
95 static void draw_linechart(int type, int x, int y, int w, int h, int numb,
96 FL_CHART_ENTRY entries[], double min, double max, int autosize,
97 int maxnumb, Fl_Color textcolor);
98
99 static void draw_piechart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[],
100 int special, Fl_Color textcolor);
101
102 public:
103 Fl_Chart(int X, int Y, int W, int H, const char *L = 0);
104
105 ~Fl_Chart();
106
107 void clear();
108
109 void add(double val, const char *str = 0, unsigned col = 0);
110
111 void insert(int ind, double val, const char *str = 0, unsigned col = 0);
112
113 void replace(int ind, double val, const char *str = 0, unsigned col = 0);
114
119 void bounds(double *a, double *b) const {
120 *a = min;
121 *b = max;
122 }
123
124 void bounds(double a, double b);
125
129 int size() const { return numb; }
130
138 void size(int W, int H) { Fl_Widget::size(W, H); }
139
143 int maxsize() const { return maxnumb; }
144
145 void maxsize(int m);
146
148 Fl_Font textfont() const { return textfont_; }
149
151 void textfont(Fl_Font s) { textfont_ = s; }
152
154 Fl_Fontsize textsize() const { return textsize_; }
155
157 void textsize(Fl_Fontsize s) { textsize_ = s; }
158
160 Fl_Color textcolor() const { return textcolor_; }
161
163 void textcolor(Fl_Color n) { textcolor_ = n; }
164
169 uchar autosize() const { return autosize_; }
170
175 void autosize(uchar n) { autosize_ = n; }
176};
177
178#endif
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1063
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1092
FL_CHART_LABEL_MAX
#define FL_CHART_LABEL_MAX
max label length for entry
Definition Fl_Chart.H:40
Fl_Widget.H
Fl_Widget and Fl_Label classes.
Fl_Chart::draw_horbarchart
static void draw_horbarchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], double min, double max, int autosize, int maxnumb, Fl_Color textcolor)
Draws a horizontal bar chart.
Definition Fl_Chart.cxx:100
Fl_Chart::textcolor
Fl_Color textcolor() const
Gets the chart's text color.
Definition Fl_Chart.H:160
Fl_Chart::insert
void insert(int ind, double val, const char *str=0, unsigned col=0)
Inserts a data value val at the given position ind.
Definition Fl_Chart.cxx:412
Fl_Chart::size
int size() const
Returns the number of data values in the chart.
Definition Fl_Chart.H:129
Fl_Chart::textfont
void textfont(Fl_Font s)
Sets the chart's text font to s.
Definition Fl_Chart.H:151
Fl_Chart::draw_piechart
static void draw_piechart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], int special, Fl_Color textcolor)
Draws a pie chart.
Definition Fl_Chart.cxx:225
Fl_Chart::autosize
void autosize(uchar n)
Sets whether the chart will automatically adjust the bounds of the chart.
Definition Fl_Chart.H:175
Fl_Chart::clear
void clear()
Removes all values from the chart.
Definition Fl_Chart.cxx:366
Fl_Chart::size
void size(int W, int H)
Sets the widget size (width, height).
Definition Fl_Chart.H:138
Fl_Chart::bounds
void bounds(double *a, double *b) const
Gets the lower and upper bounds of the chart values.
Definition Fl_Chart.H:119
Fl_Chart::draw_barchart
static void draw_barchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], double min, double max, int autosize, int maxnumb, Fl_Color textcolor)
Draws a bar chart.
Definition Fl_Chart.cxx:46
Fl_Chart::textsize
void textsize(Fl_Fontsize s)
Sets the chart's text size to s.
Definition Fl_Chart.H:157
Fl_Chart::textfont
Fl_Font textfont() const
Gets the chart's text font.
Definition Fl_Chart.H:148
Fl_Chart::replace
void replace(int ind, double val, const char *str=0, unsigned col=0)
Replaces a data value val at the given position ind.
Definition Fl_Chart.cxx:447
Fl_Chart::autosize
uchar autosize() const
Gets whether the chart will automatically adjust the bounds of the chart.
Definition Fl_Chart.H:169
Fl_Chart::add
void add(double val, const char *str=0, unsigned col=0)
Adds the data value val with optional label str and color col to the chart.
Definition Fl_Chart.cxx:380
Fl_Chart::Fl_Chart
Fl_Chart(int X, int Y, int W, int H, const char *L=0)
Create a new Fl_Chart widget using the given position, size and label string.
Definition Fl_Chart.cxx:341
Fl_Chart::maxsize
int maxsize() const
Gets the maximum number of data values for a chart.
Definition Fl_Chart.H:143
Fl_Chart::draw_linechart
static void draw_linechart(int type, int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], double min, double max, int autosize, int maxnumb, Fl_Color textcolor)
Draws a line chart.
Definition Fl_Chart.cxx:165
Fl_Chart::textcolor
void textcolor(Fl_Color n)
Sets the chart's text color to n.
Definition Fl_Chart.H:163
Fl_Chart::textsize
Fl_Fontsize textsize() const
Gets the chart's text size.
Definition Fl_Chart.H:154
Fl_Widget::draw
virtual void draw()=0
Draws the widget.
Fl_Widget::x
void x(int v)
Internal use only.
Definition Fl_Widget.H:150
Fl_Widget::w
void w(int v)
Internal use only.
Definition Fl_Widget.H:154
Fl_Widget::type
uchar type() const
Gets the widget type.
Definition Fl_Widget.H:351
Fl_Widget::size
void size(int W, int H)
Changes the size of the widget.
Definition Fl_Widget.H:418
Fl_Widget::y
void y(int v)
Internal use only.
Definition Fl_Widget.H:152
Fl_Widget::h
void h(int v)
Internal use only.
Definition Fl_Widget.H:156
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30
FL_CHART_ENTRY
For internal use only.
Definition Fl_Chart.H:43
FL_CHART_ENTRY::val
float val
For internal use only.
Definition Fl_Chart.H:44
FL_CHART_ENTRY::str
char str[FL_CHART_LABEL_MAX+1]
For internal use only.
Definition Fl_Chart.H:46
FL_CHART_ENTRY::col
unsigned col
For internal use only.
Definition Fl_Chart.H:45