2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkToggleButton.html
27 * outFile = ToggleButton
28 * strct = GtkToggleButton
39 * - gtk_toggle_button_
44 * - gtk_toggle_button_new_with_label
45 * - gtk_toggle_button_new_with_mnemonic
52 module gtk
.ToggleButton
;
54 private import gtk
.gtktypes
;
56 private import lib
.gtk
;
58 private import glib
.Str
;
62 * A GtkToggleButton is a GtkButton which will remain 'pressed-in' when
63 * clicked. Clicking again will cause the toggle button to return to its
65 * A toggle button is created by calling either gtk_toggle_button_new() or
66 * gtk_toggle_button_new_with_label(). If using the former, it is advisable to
67 * pack a widget, (such as a GtkLabel and/or a GtkPixmap), into the toggle
68 * button's container. (See GtkButton for more information).
69 * The state of a GtkToggleButton can be set specifically using
70 * gtk_toggle_button_set_active(), and retrieved using
71 * gtk_toggle_button_get_active().
72 * To simply switch the state of a toggle button, use gtk_toggle_button_toggled.
73 * Example2.Creating two GtkToggleButton widgets.
74 * void make_toggles (void) {
75 * GtkWidget *dialog, *toggle1, *toggle2;
76 * dialog = gtk_dialog_new ();
77 * toggle1 = gtk_toggle_button_new_with_label ("Hi, i'm a toggle button.");
78 * /+* Makes this toggle button invisible +/
79 * gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle1), TRUE);
80 * g_signal_connect (toggle1, "toggled",
81 * G_CALLBACK (output_state), NULL);
82 * gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
83 * toggle1, FALSE, FALSE, 2);
84 * toggle2 = gtk_toggle_button_new_with_label ("Hi, i'm another toggle button.");
85 * gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2), FALSE);
86 * g_signal_connect (toggle2, "toggled",
87 * G_CALLBACK (output_state), NULL);
88 * gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
89 * toggle2, FALSE, FALSE, 2);
90 * gtk_widget_show_all (dialog);
93 private import gtk
.Button
;
94 public class ToggleButton
: Button
97 /** the main Gtk struct */
98 protected GtkToggleButton
* gtkToggleButton
;
101 public GtkToggleButton
* getToggleButtonStruct()
103 return gtkToggleButton
;
107 /** the main Gtk struct as a void* */
108 protected void* getStruct()
110 return cast(void*)gtkToggleButton
;
114 * Sets our main struct and passes it to the parent class
116 public this (GtkToggleButton
* gtkToggleButton
)
118 super(cast(GtkButton
*)gtkToggleButton
);
119 this.gtkToggleButton
= gtkToggleButton
;
123 * Creates a new toggle button with a text label.
124 * If mnemonic is true the label
125 * will be created using gtk_label_new_with_mnemonic(), so underscores
126 * in label indicate the mnemonic for the button.
128 * a string containing the message to be placed in the toggle button.
130 * a new toggle button.
132 public this (char[] label
, bit mnemonic
=true)
136 // GtkWidget* gtk_toggle_button_new_with_mnemonic (const gchar *label);
137 this(cast(GtkToggleButton
*)gtk_toggle_button_new_with_mnemonic(Str
.toStringz(label
)) );
141 // GtkWidget* gtk_toggle_button_new_with_label (const gchar *label);
142 this(cast(GtkToggleButton
*)gtk_toggle_button_new_with_label(Str
.toStringz(label
)) );
149 // imports for the signal processing
150 private import gobject
.Signals
;
151 private import gdk
.gdktypes
;
152 int[char[]] connectedSignals
;
154 void delegate(ToggleButton
)[] onToggledListeners
;
155 void addOnToggled(void delegate(ToggleButton
) dlg
)
157 if ( !("toggled" in connectedSignals
) )
162 cast(GCallback
)&callBackToggled
,
165 cast(ConnectFlags
)0);
166 connectedSignals
["toggled"] = 1;
168 onToggledListeners
~= dlg
;
170 extern(C
) static void callBackToggled(GtkToggleButton
* togglebuttonStruct
, ToggleButton toggleButton
)
172 bit consumed
= false;
174 foreach ( void delegate(ToggleButton
) dlg
; toggleButton
.onToggledListeners
)
185 * Creates a new toggle button. A widget should be packed into the button, as in gtk_button_new().
187 * a new toggle button.
191 // GtkWidget* gtk_toggle_button_new (void);
192 this(cast(GtkToggleButton
*)gtk_toggle_button_new() );
198 * Sets whether the button is displayed as a separate indicator and label.
199 * You can call this function on a checkbutton or a radiobutton with
200 * draw_indicator = FALSE to make the button look like a normal button
201 * This function only affects instances of classes like GtkCheckButton
202 * and GtkRadioButton that derive from GtkToggleButton,
203 * not instances of GtkToggleButton itself.
207 * if TRUE, draw the button as a separate indicator
208 * and label; if FALSE, draw the button like a normal button
210 public void setMode(int drawIndicator
)
212 // void gtk_toggle_button_set_mode (GtkToggleButton *toggle_button, gboolean draw_indicator);
213 gtk_toggle_button_set_mode(gtkToggleButton
, drawIndicator
);
217 * Retrieves whether the button is displayed as a separate indicator
218 * and label. See gtk_toggle_button_set_mode().
222 * TRUE if the togglebutton is drawn as a separate indicator
227 // gboolean gtk_toggle_button_get_mode (GtkToggleButton *toggle_button);
228 return gtk_toggle_button_get_mode(gtkToggleButton
);
234 * signal on the GtkToggleButton. There is no good reason for an
235 * application ever to call this function.
239 public void toggled()
241 // void gtk_toggle_button_toggled (GtkToggleButton *toggle_button);
242 gtk_toggle_button_toggled(gtkToggleButton
);
246 * Queries a GtkToggleButton and returns its current state. Returns TRUE if
247 * the toggle button is pressed in and FALSE if it is raised.
253 public int getActive()
255 // gboolean gtk_toggle_button_get_active (GtkToggleButton *toggle_button);
256 return gtk_toggle_button_get_active(gtkToggleButton
);
260 * Sets the status of the toggle button. Set to TRUE if you want the
261 * GtkToggleButton to be 'pressed in', and FALSE to raise it.
262 * This action causes the toggled signal to be emitted.
268 public void setActive(int isActive
)
270 // void gtk_toggle_button_set_active (GtkToggleButton *toggle_button, gboolean is_active);
271 gtk_toggle_button_set_active(gtkToggleButton
, isActive
);
275 * Gets the value set by gtk_toggle_button_set_inconsistent().
279 * TRUE if the button is displayed as inconsistent, FALSE otherwise
281 public int getInconsistent()
283 // gboolean gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button);
284 return gtk_toggle_button_get_inconsistent(gtkToggleButton
);
288 * If the user has selected a range of elements (such as some text or
289 * spreadsheet cells) that are affected by a toggle button, and the
290 * current values in that range are inconsistent, you may want to
291 * display the toggle in an "in between" state. This function turns on
292 * "in between" display. Normally you would turn off the inconsistent
293 * state again if the user toggles the toggle button. This has to be
294 * done manually, gtk_toggle_button_set_inconsistent() only affects
295 * visual appearance, it doesn't affect the semantics of the button.
299 * TRUE if state is inconsistent
301 * The "active" property
302 * "active" gboolean : Read / Write
303 * If the toggle button should be pressed in or not.
304 * Default value: FALSE
306 public void setInconsistent(int setting
)
308 // void gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button, gboolean setting);
309 gtk_toggle_button_set_inconsistent(gtkToggleButton
, setting
);