1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD 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 Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.ToggleToolButton; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.ToolButton; 32 private import gtk.ToolItem; 33 public import gtkc.gdktypes; 34 private import gtkc.gtk; 35 public import gtkc.gtktypes; 36 37 38 /** 39 * A #GtkToggleToolButton is a #GtkToolItem that contains a toggle 40 * button. 41 * 42 * Use gtk_toggle_tool_button_new() to create a new 43 * #GtkToggleToolButton. 44 */ 45 public class ToggleToolButton : ToolButton 46 { 47 /** the main Gtk struct */ 48 protected GtkToggleToolButton* gtkToggleToolButton; 49 50 /** Get the main Gtk struct */ 51 public GtkToggleToolButton* getToggleToolButtonStruct() 52 { 53 return gtkToggleToolButton; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkToggleToolButton; 60 } 61 62 protected override void setStruct(GObject* obj) 63 { 64 gtkToggleToolButton = cast(GtkToggleToolButton*)obj; 65 super.setStruct(obj); 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkToggleToolButton* gtkToggleToolButton, bool ownedRef = false) 72 { 73 this.gtkToggleToolButton = gtkToggleToolButton; 74 super(cast(GtkToolButton*)gtkToggleToolButton, ownedRef); 75 } 76 77 /** 78 * Creates a new GtkToggleToolButton containing the image and text 79 * from a stock item. 80 */ 81 public this(StockID stockId) 82 { 83 this(cast(string)stockId); 84 } 85 86 /** 87 */ 88 89 public static GType getType() 90 { 91 return gtk_toggle_tool_button_get_type(); 92 } 93 94 /** 95 * Returns a new #GtkToggleToolButton 96 * 97 * Return: a newly created #GtkToggleToolButton 98 * 99 * Since: 2.4 100 * 101 * Throws: ConstructionException GTK+ fails to create the object. 102 */ 103 public this() 104 { 105 auto p = gtk_toggle_tool_button_new(); 106 107 if(p is null) 108 { 109 throw new ConstructionException("null returned by new"); 110 } 111 112 this(cast(GtkToggleToolButton*) p); 113 } 114 115 /** 116 * Creates a new #GtkToggleToolButton containing the image and text from a 117 * stock item. Some stock ids have preprocessor macros like #GTK_STOCK_OK 118 * and #GTK_STOCK_APPLY. 119 * 120 * It is an error if @stock_id is not a name of a stock item. 121 * 122 * Deprecated: Use gtk_toggle_tool_button_new() instead. 123 * 124 * Params: 125 * stockId = the name of the stock item 126 * 127 * Return: A new #GtkToggleToolButton 128 * 129 * Since: 2.4 130 * 131 * Throws: ConstructionException GTK+ fails to create the object. 132 */ 133 public this(string stockId) 134 { 135 auto p = gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId)); 136 137 if(p is null) 138 { 139 throw new ConstructionException("null returned by new_from_stock"); 140 } 141 142 this(cast(GtkToggleToolButton*) p); 143 } 144 145 /** 146 * Queries a #GtkToggleToolButton and returns its current state. 147 * Returns %TRUE if the toggle button is pressed in and %FALSE if it is raised. 148 * 149 * Return: %TRUE if the toggle tool button is pressed in, %FALSE if not 150 * 151 * Since: 2.4 152 */ 153 public bool getActive() 154 { 155 return gtk_toggle_tool_button_get_active(gtkToggleToolButton) != 0; 156 } 157 158 /** 159 * Sets the status of the toggle tool button. Set to %TRUE if you 160 * want the GtkToggleButton to be “pressed in”, and %FALSE to raise it. 161 * This action causes the toggled signal to be emitted. 162 * 163 * Params: 164 * isActive = whether @button should be active 165 * 166 * Since: 2.4 167 */ 168 public void setActive(bool isActive) 169 { 170 gtk_toggle_tool_button_set_active(gtkToggleToolButton, isActive); 171 } 172 173 int[string] connectedSignals; 174 175 void delegate(ToggleToolButton)[] onToggledListeners; 176 /** 177 * Emitted whenever the toggle tool button changes state. 178 */ 179 void addOnToggled(void delegate(ToggleToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 180 { 181 if ( "toggled" !in connectedSignals ) 182 { 183 Signals.connectData( 184 this, 185 "toggled", 186 cast(GCallback)&callBackToggled, 187 cast(void*)this, 188 null, 189 connectFlags); 190 connectedSignals["toggled"] = 1; 191 } 192 onToggledListeners ~= dlg; 193 } 194 extern(C) static void callBackToggled(GtkToggleToolButton* toggletoolbuttonStruct, ToggleToolButton _toggletoolbutton) 195 { 196 foreach ( void delegate(ToggleToolButton) dlg; _toggletoolbutton.onToggledListeners ) 197 { 198 dlg(_toggletoolbutton); 199 } 200 } 201 }