1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2018 Maxime DOYEN
4 * This file is part of HomeBank.
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.
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.
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/>.
20 #ifndef __GTK_CHART_H__
21 #define __GTK_CHART_H__
23 #include "gtk-chart-colors.h"
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))
33 typedef struct _GtkChart GtkChart
;
34 typedef struct _GtkChartClass GtkChartClass
;
35 //typedef struct _GtkChartPrivate GtkChartPrivate;
37 typedef struct _ChartItem ChartItem
;
38 typedef gchar (* GtkChartPrintIntFunc
) (gint value
, gboolean minor
);
39 typedef gchar (* GtkChartPrintDoubleFunc
) (gdouble value
, gboolean minor
);
41 /* = = = = = = = = = = */
42 /* = = = = = = = = = = = = = = = = = = = = */
43 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
44 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
47 #define PHI 1.61803399
50 /* default zoomx for charts */
51 #define GTK_CHART_BARW 41 //24
53 #define GTK_CHART_MINBARW 8 //4
54 #define GTK_CHART_MAXBARW 41 //128
55 #define GTK_CHART_SPANBARW GTK_CHART_MAXBARW+1
57 #define GTK_CHART_MINRADIUS 64
59 #define CHART_BUFFER_LENGTH 128
63 #define CHART_PARAM_PIE_DONUT TRUE
64 #define CHART_PARAM_PIE_LINE FALSE
65 #define CHART_PARAM_PIE_MARK FALSE
66 #define CHART_PARAM_PIE_HOLEVALUE 0.5
72 #define CHART_MARGIN 12 //standard a4 margin is 18
73 #define CHART_SPACING 6
75 #define CHART_LINE_SPACING 1.25
77 //#define PROP_SHOW_MINOR 6
78 //#define PROP_SHOW_LEGEND 7
80 #define ROUNDHALF(x) floor(x *2) / 2
116 double angle2
; /* rate for pie */
117 double height
; /* for column */
126 //GtkChartPrivate *priv;
129 /* all below should be in priv normally */
133 GtkAdjustment
*adjustment
;
134 GtkWidget
*scrollbar
;
145 /* chart properties */
146 gint type
; // column/pie/line
150 gboolean show_legend
;
151 gboolean show_legend_wide
;
162 GtkColorScheme color_scheme
;
164 /* cairo default value */
165 PangoFontDescription
*pfd
;
169 cairo_surface_t
*surface
;
173 int l
, t
, b
, r
, w
, h
;
174 cairo_rectangle_t graph
;
175 cairo_rectangle_t legend
;
177 /* legend dimension */
179 double legend_font_h
;
180 double legend_label_w
;
181 double legend_value_w
;
182 double legend_rate_w
;
186 double subtitle_zh
, subtitle_y
;
187 double header_zh
, header_y
;
193 gint lastx
, lasty
, lastactive
;
194 gint lastpress_x
, lastpress_y
;
200 gint rayon
, mark
, left
, top
;
201 gint leg_nb_l
, leg_width_l
, leg_vspace_l
;
202 gint leg_nb_r
, leg_width_r
, leg_vspace_r
;
205 double rawmin
, rawmax
, range
, min
, max
, unit
, minimum
;
211 double scale_x
, scale_y
, scale_w
, scale_h
;
212 double item_x
, item_y
, item_w
;
213 double barw
, blkw
, posbarh
, negbarh
;
216 gchar buffer1
[CHART_BUFFER_LENGTH
];
217 gchar buffer2
[CHART_BUFFER_LENGTH
];
221 struct _GtkChartClass
223 GtkBoxClass parent_class
;
225 /* Padding for future expansion */
226 void (*_gtk_reserved1
) (void);
227 void (*_gtk_reserved2
) (void);
228 void (*_gtk_reserved3
) (void);
229 void (*_gtk_reserved4
) (void);
232 GType
gtk_chart_get_type (void) G_GNUC_CONST
;
234 /* public function */
235 GtkWidget
*gtk_chart_new(gint type
);
237 void gtk_chart_set_type(GtkChart
*chart
, gint type
);
238 void gtk_chart_set_color_scheme(GtkChart
* chart
, gint colorscheme
);
240 void gtk_chart_queue_redraw(GtkChart
*chart
);
242 void gtk_chart_set_datas(GtkChart
*chart
, GtkTreeModel
*model
, guint column
, gchar
*title
, gchar
*subtitle
);
243 void gtk_chart_set_dualdatas(GtkChart
*chart
, GtkTreeModel
*model
, guint column1
, guint column2
, gchar
*title
, gchar
*subtitle
);
245 void gtk_chart_set_minor_prefs(GtkChart
* chart
, gdouble rate
, gchar
*symbol
);
246 void gtk_chart_set_currency(GtkChart
* chart
, guint32 kcur
);
248 void gtk_chart_set_overdrawn(GtkChart
* chart
, gdouble minimum
);
249 //void gtk_chart_set_every_xval(GtkChart * chart, gint decay);
250 void gtk_chart_set_barw(GtkChart
* chart
, gdouble barw
);
251 void gtk_chart_set_showmono(GtkChart
* chart
, gboolean mono
);
253 void gtk_chart_show_legend(GtkChart
* chart
, gboolean visible
, gboolean showextracol
);
254 void gtk_chart_show_overdrawn(GtkChart
* chart
, gboolean visible
);
255 void gtk_chart_show_xval(GtkChart
* chart
, gboolean visible
);
256 void gtk_chart_show_minor(GtkChart
* chart
, gboolean minor
);
257 void gtk_chart_set_absolute(GtkChart
* chart
, gboolean abs
);
260 #endif /* __GTK_CHART_H__ */