2 * A few useful widgets - a line graph, a knob, a tube - Panama!
4 * Copyright (C) 2008-2010 Krzysztof Foltman, Torben Hohn, Markus
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this program; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02111-1307, USA.
23 #ifndef _USE_MATH_DEFINES
24 #define _USE_MATH_DEFINES
26 #ifndef __CALF_CUSTOM_CTL
27 #define __CALF_CUSTOM_CTL
29 #include <cairo/cairo.h>
31 #include <gtk/gtkframe.h>
32 #include <gtk/gtkcomboboxtext.h>
33 #include <gtk/gtknotebook.h>
34 #include <gtk/gtkrange.h>
35 #include <gtk/gtkscale.h>
36 #include <gtk/gtkbutton.h>
37 #include <calf/giface.h>
39 void line_graph_background(cairo_t
* c
, int x
, int y
, int sx
, int sy
, int ox
, int oy
, float brightness
= 1, int shadow
= 7, float lights
= 0.9, float dull
= 0.15) ;
44 /// PHASE GRAPH ////////////////////////////////////////////////////////
47 #define CALF_TYPE_PHASE_GRAPH (calf_phase_graph_get_type())
48 #define CALF_PHASE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_PHASE_GRAPH, CalfPhaseGraph))
49 #define CALF_IS_PHASE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_PHASE_GRAPH))
50 #define CALF_PHASE_GRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_PHASE_GRAPH, CalfPhaseGraphClass))
51 #define CALF_IS_PHASE_GRAPH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_PHASE_GRAPH))
52 #define CALF_PHASE_GRAPH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALF_TYPE_PHASE_GRAPH, CalfPhaseGraphClass))
56 GtkDrawingArea parent
;
57 const calf_plugins::phase_graph_iface
*source
;
59 cairo_surface_t
*background
, *cache
;
60 inline float _atan(float x
, float l
, float r
) {
63 else if(l
>= 0 and r
< 0)
64 return M_PI
+ atan(x
);
65 else if(l
< 0 and r
< 0)
66 return M_PI
+ atan(x
);
67 else if(l
< 0 and r
>= 0)
68 return (2.f
* M_PI
) + atan(x
);
73 struct CalfPhaseGraphClass
75 GtkDrawingAreaClass parent_class
;
78 extern GtkWidget
*calf_phase_graph_new();
80 extern GType
calf_phase_graph_get_type();
83 /// TOGGLE /////////////////////////////////////////////////////////////
86 #define CALF_TYPE_TOGGLE (calf_toggle_get_type())
87 #define CALF_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TOGGLE, CalfToggle))
88 #define CALF_IS_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TOGGLE))
89 #define CALF_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_TOGGLE, CalfToggleClass))
90 #define CALF_IS_TOGGLE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_TOGGLE))
98 GdkPixbuf
*toggle_image
[3];
101 struct CalfToggleClass
103 GtkRangeClass parent_class
;
106 extern GtkWidget
*calf_toggle_new();
107 extern GtkWidget
*calf_toggle_new_with_adjustment(GtkAdjustment
*_adjustment
);
109 extern GType
calf_toggle_get_type();
112 /// FRAME //////////////////////////////////////////////////////////////
115 #define CALF_TYPE_FRAME (calf_frame_get_type())
116 #define CALF_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_FRAME, CalfFrame))
117 #define CALF_IS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_FRAME))
118 #define CALF_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_FRAME, CalfFrameClass))
119 #define CALF_IS_FRAME_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_FRAME))
126 struct CalfFrameClass
128 GtkFrameClass parent_class
;
131 extern GtkWidget
*calf_frame_new(const char *label
);
132 extern GType
calf_frame_get_type();
135 /// COMBOBOX ///////////////////////////////////////////////////////////
138 #define CALF_TYPE_COMBOBOX (calf_combobox_get_type())
139 #define CALF_COMBOBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_COMBOBOX, CalfCombobox))
140 #define CALF_IS_COMBOBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_COMBOBOX))
141 #define CALF_COMBOBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_COMBOBOX, CalfComboboxClass))
142 #define CALF_IS_COMBOBOX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_COMBOBOX))
146 GtkComboBoxText parent
;
149 struct CalfComboboxClass
151 GtkComboBoxTextClass parent_class
;
154 extern GtkWidget
*calf_combobox_new();
155 extern GType
calf_combobox_get_type();
158 /// NOTEBOOK ///////////////////////////////////////////////////////////
161 #define CALF_TYPE_NOTEBOOK (calf_notebook_get_type())
162 #define CALF_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_NOTEBOOK, CalfNotebook))
163 #define CALF_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_NOTEBOOK))
164 #define CALF_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_NOTEBOOK, CalfNotebookClass))
165 #define CALF_IS_NOTEBOOK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_NOTEBOOK))
172 struct CalfNotebookClass
174 GtkNotebookClass parent_class
;
178 extern GtkWidget
*calf_notebook_new();
179 extern GType
calf_notebook_get_type();
182 /// FADER //////////////////////////////////////////////////////////////
185 #define CALF_TYPE_FADER (calf_fader_get_type())
186 #define CALF_FADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_FADER, CalfFader))
187 #define CALF_IS_FADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_FADER))
188 #define CALF_FADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_FADER, CalfFaderClass))
189 #define CALF_IS_FADER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_FADER))
191 struct CalfFaderLayout
194 int tx
, ty
, tw
, th
, tc
;
195 int scw
, sch
, scx1
, scy1
, scx2
, scy2
;
197 int slx
, sly
, slw
, slh
;
203 int horizontal
, size
;
206 GdkPixbuf
*sliderpre
;
207 CalfFaderLayout layout
;
211 struct CalfFaderClass
213 GtkScaleClass parent_class
;
218 extern GtkWidget
*calf_fader_new(const int horiz
, const int size
, const double min
, const double max
, const double step
);
219 extern GType
calf_fader_get_type();
222 /// BUTTON /////////////////////////////////////////////////////////////
225 #define CALF_TYPE_BUTTON (calf_button_get_type())
226 #define CALF_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_BUTTON, CalfButton))
227 #define CALF_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_BUTTON))
228 #define CALF_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_BUTTON, CalfButtonClass))
229 #define CALF_IS_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_BUTTON))
236 struct CalfButtonClass
238 GtkButtonClass parent_class
;
241 extern GtkWidget
*calf_button_new(const gchar
*label
);
242 extern GType
calf_button_get_type();
245 /// TOGGLE BUTTON //////////////////////////////////////////////////////
248 #define CALF_TYPE_TOGGLE_BUTTON (calf_toggle_button_get_type())
249 #define CALF_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TOGGLE_BUTTON, CalfToggleButton))
250 #define CALF_IS_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TOGGLE_BUTTON))
251 #define CALF_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_TOGGLE_BUTTON, CalfToggleButtonClass))
252 #define CALF_IS_TOGGLE_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_TOGGLE_BUTTON))
254 struct CalfToggleButton
256 GtkToggleButton parent
;
259 struct CalfToggleButtonClass
261 GtkToggleButtonClass parent_class
;
264 extern GtkWidget
*calf_toggle_button_new(const gchar
*label
);
265 extern GType
calf_toggle_button_get_type();
268 /// RADIO BUTTON //////////////////////////////////////////////////////
271 #define CALF_TYPE_RADIO_BUTTON (calf_radio_button_get_type())
272 #define CALF_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_RADIO_BUTTON, CalfRadioButton))
273 #define CALF_IS_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_RADIO_BUTTON))
274 #define CALF_RADIO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_RADIO_BUTTON, CalfRadioButtonClass))
275 #define CALF_IS_RADIO_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_RADIO_BUTTON))
277 struct CalfRadioButton
279 GtkRadioButton parent
;
282 struct CalfRadioButtonClass
284 GtkRadioButtonClass parent_class
;
287 extern GtkWidget
*calf_radio_button_new(const gchar
*label
);
288 extern GType
calf_radio_button_get_type();
291 /// TAP BUTTON /////////////////////////////////////////////////////////
294 #define CALF_TYPE_TAP_BUTTON (calf_tap_button_get_type())
295 #define CALF_TAP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TAP_BUTTON, CalfTapButton))
296 #define CALF_IS_TAP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TAP_BUTTON))
297 #define CALF_TAP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_TAP_BUTTON, CalfTapButtonClass))
298 #define CALF_IS_TAP_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_TAP_BUTTON))
307 struct CalfTapButtonClass
309 GtkButtonClass parent_class
;
312 extern GtkWidget
*calf_tap_button_new();
313 extern GType
calf_tap_button_get_type();