1 /* $Id: gtkdatabox_graph.h 4 2008-06-22 09:19:11Z rbock $ */
2 /* GtkDatabox - An extension to the gtk+ library
3  * Copyright (C) 1998 - 2008  Dr. Roland Bock
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public License
7  * as published by the Free Software Foundation; either version 2.1
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * SECTION:gtkdatabox_graph
22  * @short_description: An abstract anchestor for all "real" graphs.
23  * @include: gtkdatabox_graph.h
24  * @see_also: #GtkDatabox, #GtkDataboxPoints, #GtkDataboxLines, #GtkDataboxBars, #GtkDataboxGrid, #GtkDataboxCrossSimple
25  *
26  * GtkDataboxGraphs can display data or other things in a #GtkDatabox widget.
27  *
28  * This class is just the basic interface. Other graph classes are derived from this
29  * class and implement some real things.
30  *
31  */
32 
33 
34 #ifndef __GTK_DATABOX_GRAPH_H__
35 #define __GTK_DATABOX_GRAPH_H__
36 
37 #include <gdk/gdk.h>
38 #include <pango/pango.h>
39 #include <gtkdatabox.h>
40 
41 G_BEGIN_DECLS
42 #define GTK_DATABOX_TYPE_GRAPH		  (gtk_databox_graph_get_type ())
43 #define GTK_DATABOX_GRAPH(obj)		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
44                                            GTK_DATABOX_TYPE_GRAPH, \
45                                            GtkDataboxGraph))
46 #define GTK_DATABOX_GRAPH_CLASS(klass)	  (G_TYPE_CHECK_CLASS_CAST ((klass), \
47                                            GTK_DATABOX_TYPE_GRAPH, \
48                                            GtkDataboxGraphClass))
49 #define GTK_DATABOX_IS_GRAPH(obj)	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
50                                            GTK_DATABOX_TYPE_GRAPH))
51 #define GTK_DATABOX_IS_GRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
52                                            GTK_DATABOX_TYPE_GRAPH))
53 #define GTK_DATABOX_GRAPH_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
54                                            GTK_DATABOX_TYPE_GRAPH, \
55                                            GtkDataboxGraphClass))
56 #define GTK_DATABOX_GRAPH_GET_PRIVATE(obj) \
57 	G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_DATABOX_TYPE_GRAPH, GtkDataboxGraphPrivate)
58 
59    typedef struct _GtkDataboxGraphClass GtkDataboxGraphClass;
60 
61    /**
62     * _GtkDataboxGraph
63     * @parent: The parent object
64     *
65     * Implementation of #GtkDataboxGraph
66     *
67     **/
68    struct _GtkDataboxGraph
69    {
70       /*< private >*/
71       GObject parent;
72    };
73 
74    struct _GtkDataboxGraphClass
75    {
76       GObjectClass parent_class;
77 
78       /*
79        * public virtual drawing function
80        */
81       void (*draw) (GtkDataboxGraph * graph, GtkDatabox * box);
82 
83       gint (*calculate_extrema) (GtkDataboxGraph * graph,
84                                  gfloat * min_x, gfloat * max_x,
85 				 gfloat * min_y, gfloat * max_y);
86       cairo_t* (*create_gc) (GtkDataboxGraph * graph, GtkDatabox * box);
87    };
88 
89    GType gtk_databox_graph_get_type (void);
90 
91    void gtk_databox_graph_set_hide (GtkDataboxGraph * graph, gboolean hide);
92    gboolean gtk_databox_graph_get_hide (GtkDataboxGraph * graph);
93 
94    void gtk_databox_graph_set_color (GtkDataboxGraph * graph,
95 				     GdkRGBA * color);
96    GdkRGBA *gtk_databox_graph_get_color (GtkDataboxGraph * graph);
97 
98    void gtk_databox_graph_set_rgba (GtkDataboxGraph * graph,
99 				     GdkRGBA * rgba);
100    GdkRGBA *gtk_databox_graph_get_rgba (GtkDataboxGraph * graph);
101 
102    void gtk_databox_graph_set_size (GtkDataboxGraph * graph, gint size);
103    gint gtk_databox_graph_get_size (GtkDataboxGraph * graph);
104 
105    gint gtk_databox_graph_calculate_extrema (GtkDataboxGraph * graph,
106 					     gfloat * min_x, gfloat * max_x,
107 					     gfloat * min_y, gfloat * max_y);
108    /* This function is called by GtkDatabox */
109    void gtk_databox_graph_draw (GtkDataboxGraph * graph, GtkDatabox * box);
110 
111    /* This function is called by derived graph classes */
112    cairo_t* gtk_databox_graph_create_gc (GtkDataboxGraph * graph, GtkDatabox * box);
113 
114 G_END_DECLS
115 #endif				/* __GTK_DATABOX_GRAPH_H__ */
116