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/gtkcombobox.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>
38 #include <calf/drawingutils.h>
43 /// PHASE GRAPH ////////////////////////////////////////////////////////
46 #define CALF_TYPE_PHASE_GRAPH (calf_phase_graph_get_type())
47 #define CALF_PHASE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_PHASE_GRAPH, CalfPhaseGraph))
48 #define CALF_IS_PHASE_GRAPH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_PHASE_GRAPH))
49 #define CALF_PHASE_GRAPH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_PHASE_GRAPH, CalfPhaseGraphClass))
50 #define CALF_IS_PHASE_GRAPH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_PHASE_GRAPH))
51 #define CALF_PHASE_GRAPH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CALF_TYPE_PHASE_GRAPH, CalfPhaseGraphClass))
55 GtkDrawingArea parent
;
56 const calf_plugins::phase_graph_iface
*source
;
58 cairo_surface_t
*background
, *cache
;
59 inline float _atan(float x
, float l
, float r
) {
62 else if(l
>= 0 and r
< 0)
63 return M_PI
+ atan(x
);
64 else if(l
< 0 and r
< 0)
65 return M_PI
+ atan(x
);
66 else if(l
< 0 and r
>= 0)
67 return (2.f
* M_PI
) + atan(x
);
72 struct CalfPhaseGraphClass
74 GtkDrawingAreaClass parent_class
;
77 extern GtkWidget
*calf_phase_graph_new();
79 extern GType
calf_phase_graph_get_type();
82 /// TOGGLE /////////////////////////////////////////////////////////////
85 #define CALF_TYPE_TOGGLE (calf_toggle_get_type())
86 #define CALF_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TOGGLE, CalfToggle))
87 #define CALF_IS_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TOGGLE))
88 #define CALF_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_TOGGLE, CalfToggleClass))
89 #define CALF_IS_TOGGLE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_TOGGLE))
97 GdkPixbuf
*toggle_image
[3];
100 struct CalfToggleClass
102 GtkRangeClass parent_class
;
105 extern GtkWidget
*calf_toggle_new();
106 extern GtkWidget
*calf_toggle_new_with_adjustment(GtkAdjustment
*_adjustment
);
108 extern GType
calf_toggle_get_type();
111 /// FRAME //////////////////////////////////////////////////////////////
114 #define CALF_TYPE_FRAME (calf_frame_get_type())
115 #define CALF_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_FRAME, CalfFrame))
116 #define CALF_IS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_FRAME))
117 #define CALF_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_FRAME, CalfFrameClass))
118 #define CALF_IS_FRAME_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_FRAME))
125 struct CalfFrameClass
127 GtkFrameClass parent_class
;
130 extern GtkWidget
*calf_frame_new(const char *label
);
131 extern GType
calf_frame_get_type();
134 /// COMBOBOX ///////////////////////////////////////////////////////////
137 #define CALF_TYPE_COMBOBOX (calf_combobox_get_type())
138 #define CALF_COMBOBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_COMBOBOX, CalfCombobox))
139 #define CALF_IS_COMBOBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_COMBOBOX))
140 #define CALF_COMBOBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_COMBOBOX, CalfComboboxClass))
141 #define CALF_IS_COMBOBOX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_COMBOBOX))
148 struct CalfComboboxClass
150 GtkComboBoxClass parent_class
;
153 extern GtkWidget
*calf_combobox_new();
154 extern GType
calf_combobox_get_type();
157 /// NOTEBOOK ///////////////////////////////////////////////////////////
160 #define CALF_TYPE_NOTEBOOK (calf_notebook_get_type())
161 #define CALF_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_NOTEBOOK, CalfNotebook))
162 #define CALF_IS_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_NOTEBOOK))
163 #define CALF_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_NOTEBOOK, CalfNotebookClass))
164 #define CALF_IS_NOTEBOOK_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_NOTEBOOK))
171 struct CalfNotebookClass
173 GtkNotebookClass parent_class
;
177 extern GtkWidget
*calf_notebook_new();
178 extern GType
calf_notebook_get_type();
181 /// FADER //////////////////////////////////////////////////////////////
184 #define CALF_TYPE_FADER (calf_fader_get_type())
185 #define CALF_FADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_FADER, CalfFader))
186 #define CALF_IS_FADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_FADER))
187 #define CALF_FADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_FADER, CalfFaderClass))
188 #define CALF_IS_FADER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_FADER))
190 struct CalfFaderLayout
193 int tx
, ty
, tw
, th
, tc
;
194 int scw
, sch
, scx1
, scy1
, scx2
, scy2
;
196 int slx
, sly
, slw
, slh
;
202 int horizontal
, size
;
205 GdkPixbuf
*sliderpre
;
206 CalfFaderLayout layout
;
210 struct CalfFaderClass
212 GtkScaleClass parent_class
;
217 extern GtkWidget
*calf_fader_new(const int horiz
, const int size
, const double min
, const double max
, const double step
);
218 extern GType
calf_fader_get_type();
221 /// BUTTON /////////////////////////////////////////////////////////////
224 #define CALF_TYPE_BUTTON (calf_button_get_type())
225 #define CALF_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_BUTTON, CalfButton))
226 #define CALF_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_BUTTON))
227 #define CALF_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_BUTTON, CalfButtonClass))
228 #define CALF_IS_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_BUTTON))
235 struct CalfButtonClass
237 GtkButtonClass parent_class
;
240 extern GtkWidget
*calf_button_new(const gchar
*label
);
241 extern GType
calf_button_get_type();
244 /// TOGGLE BUTTON //////////////////////////////////////////////////////
247 #define CALF_TYPE_TOGGLE_BUTTON (calf_toggle_button_get_type())
248 #define CALF_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TOGGLE_BUTTON, CalfToggleButton))
249 #define CALF_IS_TOGGLE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TOGGLE_BUTTON))
250 #define CALF_TOGGLE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_TOGGLE_BUTTON, CalfToggleButtonClass))
251 #define CALF_IS_TOGGLE_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_TOGGLE_BUTTON))
253 struct CalfToggleButton
255 GtkToggleButton parent
;
258 struct CalfToggleButtonClass
260 GtkToggleButtonClass parent_class
;
263 extern GtkWidget
*calf_toggle_button_new(const gchar
*label
);
264 extern GType
calf_toggle_button_get_type();
267 /// RADIO BUTTON //////////////////////////////////////////////////////
270 #define CALF_TYPE_RADIO_BUTTON (calf_radio_button_get_type())
271 #define CALF_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_RADIO_BUTTON, CalfRadioButton))
272 #define CALF_IS_RADIO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_RADIO_BUTTON))
273 #define CALF_RADIO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_RADIO_BUTTON, CalfRadioButtonClass))
274 #define CALF_IS_RADIO_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_RADIO_BUTTON))
276 struct CalfRadioButton
278 GtkRadioButton parent
;
281 struct CalfRadioButtonClass
283 GtkRadioButtonClass parent_class
;
286 extern GtkWidget
*calf_radio_button_new(const gchar
*label
);
287 extern GType
calf_radio_button_get_type();
290 /// TAP BUTTON /////////////////////////////////////////////////////////
293 #define CALF_TYPE_TAP_BUTTON (calf_tap_button_get_type())
294 #define CALF_TAP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TAP_BUTTON, CalfTapButton))
295 #define CALF_IS_TAP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TAP_BUTTON))
296 #define CALF_TAP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CALF_TYPE_TAP_BUTTON, CalfTapButtonClass))
297 #define CALF_IS_TAP_BUTTON_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), CALF_TYPE_TAP_BUTTON))
306 struct CalfTapButtonClass
308 GtkButtonClass parent_class
;
311 extern GtkWidget
*calf_tap_button_new();
312 extern GType
calf_tap_button_get_type();