2 terminatorX - realtime audio scratching software
3 Copyright (C) 1999-2011 Alexander König
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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 General Public License for more details.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "tX_extdial.h"
22 #include "tX_seqpar.h"
25 #define WID_DYN TRUE, TRUE, 0
26 #define WID_FIX FALSE, FALSE, 0
28 GCallback tX_extdial :: f_entry(GtkWidget *w, tX_extdial *ed)
30 strcpy(ed->sval, gtk_entry_get_text(GTK_ENTRY(ed->entry)));
32 gtk_adjustment_set_value(ed->adj, ed->fval);
36 GCallback tX_extdial :: f_adjustment(GtkWidget *w, tX_extdial *ed)
38 ed->fval=ed->adj->value;
40 gtk_entry_set_text(GTK_ENTRY(ed->entry), ed->sval);
44 tX_extdial :: tX_extdial(const char *l, GtkAdjustment *a, tX_seqpar * sp, bool text_below, bool hide_entry)
50 label=gtk_label_new(NULL);
51 gtk_label_set_markup(GTK_LABEL(label),l);
53 dial=gtk_tx_dial_new(adj);
54 entry=gtk_entry_new();
55 gtk_entry_set_max_length(GTK_ENTRY(entry), 5);
56 gtk_entry_set_text(GTK_ENTRY(entry), sval);
57 #if GTK_CHECK_VERSION(2,4,0)
58 gtk_entry_set_alignment(GTK_ENTRY(entry), 0.5);
62 eventbox=gtk_event_box_new();
63 mainbox=gtk_vbox_new(FALSE, text_below ? 5 : 0);
64 gtk_container_add(GTK_CONTAINER(eventbox), mainbox);
66 subbox=gtk_hbox_new(TRUE, 0);
67 gtk_box_pack_start(GTK_BOX(subbox), dial, WID_FIX);
68 gtk_box_pack_start(GTK_BOX(mainbox), subbox, WID_FIX);
69 gtk_box_pack_start(GTK_BOX(text_below ? mainbox : subbox), entry, WID_DYN);
70 if (l) gtk_box_pack_start(GTK_BOX(mainbox), label, WID_FIX);
72 if (l) gtk_widget_show(label);
73 if (!hide_entry){ gtk_widget_show(entry); }
74 gtk_entry_set_width_chars(GTK_ENTRY(entry), 4);
75 gtk_widget_show(dial);
76 gtk_widget_show(subbox);
77 gtk_widget_show(mainbox);
78 gtk_widget_show(eventbox);
80 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(tX_extdial::f_entry), (void *) this);
81 g_signal_connect(G_OBJECT(adj), "value_changed", G_CALLBACK(tX_extdial::f_adjustment), (void *) this);
84 g_signal_connect(G_OBJECT(dial), "button_press_event", G_CALLBACK(tX_seqpar::tX_seqpar_press), sp);
85 g_signal_connect(G_OBJECT(entry), "button_press_event", G_CALLBACK(tX_seqpar::tX_seqpar_press), sp);
86 g_signal_connect(G_OBJECT(eventbox), "button_press_event", G_CALLBACK(tX_seqpar::tX_seqpar_press), sp);
90 tX_extdial :: ~tX_extdial()
92 gtk_object_destroy(GTK_OBJECT(adj));
93 gtk_widget_destroy(entry);
94 gtk_widget_destroy(label);
95 gtk_widget_destroy(dial);
96 gtk_widget_destroy(subbox);
97 gtk_widget_destroy(mainbox);
98 gtk_widget_destroy(eventbox);