]> Dogcows Code - chaz/homebank/blob - src/gtk-chart.h
import homebank-5.1.3
[chaz/homebank] / src / gtk-chart.h
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2017 Maxime DOYEN
3 *
4 * This file is part of HomeBank.
5 *
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __GTK_CHART_H__
21 #define __GTK_CHART_H__
22
23 #include "gtk-chart-colors.h"
24
25 G_BEGIN_DECLS
26 #define GTK_TYPE_CHART (gtk_chart_get_type ())
27 #define GTK_CHART(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CHART, GtkChart))
28 #define GTK_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CHART, GtkChartClass)
29 #define GTK_IS_CHART(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CHART))
30 #define GTK_IS_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CHART))
31 #define GTK_CHART_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CHART, GtkChartClass))
32
33 typedef struct _GtkChart GtkChart;
34 typedef struct _GtkChartClass GtkChartClass;
35 //typedef struct _GtkChartPrivate GtkChartPrivate;
36
37 typedef struct _ChartItem ChartItem;
38 typedef gchar (* GtkChartPrintIntFunc) (gint value, gboolean minor);
39 typedef gchar (* GtkChartPrintDoubleFunc) (gdouble value, gboolean minor);
40
41 /* = = = = = = = = = = */
42 /* = = = = = = = = = = = = = = = = = = = = */
43 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
44 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
45
46 /* phi value */
47 #define PHI 1.61803399
48
49
50 /* default zoomx for charts */
51 #define GTK_CHART_BARW 24
52
53 #define GTK_CHART_MINBARW 4
54 #define GTK_CHART_MAXBARW 128
55
56 #define GTK_CHART_MINRADIUS 64
57
58
59 #define CHART_BUFFER_LENGTH 128
60
61 // for cairo pie
62 #define PIE_LINE_SLICE 0
63 #define SOFT_LIGHT 0
64 #define GRADIENT 0
65 #define CHART_PIE_DONUT 1
66
67
68 /* new stuff */
69 #define CHART_MARGIN 18 //standard a4 margin
70 #define CHART_SPACING 6
71
72 //#define PROP_SHOW_MINOR 6
73 //#define PROP_SHOW_LEGEND 7
74
75 enum
76 {
77 CHART_TYPE_NONE,
78 CHART_TYPE_COL,
79 CHART_TYPE_PIE,
80 CHART_TYPE_LINE,
81 CHART_TYPE_MAX
82 };
83
84
85 enum
86 {
87 LST_LEGEND_FAKE,
88 LST_LEGEND_COLOR,
89 LST_LEGEND_TITLE,
90 LST_LEGEND_AMOUNT,
91 LST_LEGEND_RATE,
92 NUM_LST_LEGEND
93 };
94
95
96 struct _ChartItem
97 {
98 /* data part */
99 gchar *label;
100 gdouble serie1;
101 gdouble serie2;
102 gdouble rate;
103
104 /* draw stuffs */
105 gchar *legend;
106 double angle2; /* rate for pie */
107 double height; /* for column */
108 };
109
110
111 struct _GtkChart
112 {
113 //own widget here
114
115 /*< private >*/
116 //GtkChartPrivate *priv;
117
118
119 /* all below should be in priv normally */
120 GtkBox hbox;
121
122 GtkWidget *drawarea;
123 GtkAdjustment *adjustment;
124 GtkWidget *scrollbar;
125
126 GtkWidget *scrollwin;
127 GtkWidget *treeview;
128 GtkTreeModel *legend;
129
130 /* data storage */
131 gint nb_items;
132 GArray *items;
133
134 gchar *title;
135 gchar *subtitle;
136
137 /* chart properties */
138 gint type;
139 gboolean dual;
140 gboolean abs;
141 gboolean show_over;
142 gboolean show_xval;
143 gboolean show_mono;
144 gint every_xval;
145 guint32 kcur;
146 gboolean minor;
147 gdouble minor_rate;
148 gchar *minor_symbol;
149
150 /* color datas */
151 GtkColorScheme color_scheme;
152
153 /* cairo default value */
154 PangoFontDescription *pfd;
155 gint pfd_size;
156
157 /* buffer surface */
158 cairo_surface_t *surface;
159
160 /* draw area coordinates */
161 double l, t, b, r, w, h;
162 /* our drawing rectangle with margin */
163 double label_w;
164 double legend_w;
165
166 /* zones height */
167 double title_zh;
168 double subtitle_zh, subtitle_y;
169
170
171 double ox, oy;
172 gint lastx, lasty, lastactive;
173 gint lastpress_x, lastpress_y;
174 gint active;
175 guint timer_tag;
176
177 /* pie specifics */
178 gdouble total;
179 gint rayon, left, top;
180
181 /* bar specifics */
182 double rawmin, rawmax, range, min, max, unit, minimum;
183 gint div;
184 gint visible;
185
186 double font_h;
187
188 double scale_x, scale_y, scale_w, scale_h;
189 double graph_x, graph_y, graph_width, graph_height; //graph dimension
190 double barw, blkw, posbarh, negbarh;
191
192 gchar buffer1[CHART_BUFFER_LENGTH];
193 gchar buffer2[CHART_BUFFER_LENGTH];
194 };
195
196 struct _GtkChartClass
197 {
198 GtkBoxClass parent_class;
199
200 /* Padding for future expansion */
201 void (*_gtk_reserved1) (void);
202 void (*_gtk_reserved2) (void);
203 void (*_gtk_reserved3) (void);
204 void (*_gtk_reserved4) (void);
205 };
206
207 GType gtk_chart_get_type (void) G_GNUC_CONST;
208
209 /* public function */
210 GtkWidget *gtk_chart_new(gint type);
211
212 void gtk_chart_set_type(GtkChart *chart, gint type);
213 void gtk_chart_set_color_scheme(GtkChart * chart, gint colorscheme);
214
215 void gtk_chart_queue_redraw(GtkChart *chart);
216
217 void gtk_chart_set_datas(GtkChart *chart, GtkTreeModel *model, guint column, gchar *title, gchar *subtitle);
218 void gtk_chart_set_dualdatas(GtkChart *chart, GtkTreeModel *model, guint column1, guint column2, gchar *title, gchar *subtitle);
219
220 void gtk_chart_set_minor_prefs(GtkChart * chart, gdouble rate, gchar *symbol);
221 void gtk_chart_set_currency(GtkChart * chart, guint32 kcur);
222
223 void gtk_chart_set_overdrawn(GtkChart * chart, gdouble minimum);
224 void gtk_chart_set_every_xval(GtkChart * chart, gint decay);
225 void gtk_chart_set_barw(GtkChart * chart, gdouble barw);
226 void gtk_chart_set_showmono(GtkChart * chart, gboolean mono);
227
228 void gtk_chart_show_legend(GtkChart * chart, gboolean visible, gboolean showextracol);
229 void gtk_chart_show_overdrawn(GtkChart * chart, gboolean visible);
230 void gtk_chart_show_xval(GtkChart * chart, gboolean visible);
231 void gtk_chart_show_minor(GtkChart * chart, gboolean minor);
232 void gtk_chart_set_absolute(GtkChart * chart, gboolean abs);
233
234 G_END_DECLS
235 #endif /* __GTK_CHART_H__ */
This page took 0.042626 seconds and 5 git commands to generate.