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.Expander; 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.Bin; 32 private import gtk.Widget; 33 public import gtkc.gdktypes; 34 private import gtkc.gtk; 35 public import gtkc.gtktypes; 36 37 38 /** 39 * A #GtkExpander allows the user to hide or show its child by clicking 40 * on an expander triangle similar to the triangles used in a #GtkTreeView. 41 * 42 * Normally you use an expander as you would use any other descendant 43 * of #GtkBin; you create the child widget and use gtk_container_add() 44 * to add it to the expander. When the expander is toggled, it will take 45 * care of showing and hiding the child automatically. 46 * 47 * # Special Usage 48 * 49 * There are situations in which you may prefer to show and hide the 50 * expanded widget yourself, such as when you want to actually create 51 * the widget at expansion time. In this case, create a #GtkExpander 52 * but do not add a child to it. The expander widget has an 53 * #GtkExpander:expanded property which can be used to monitor 54 * its expansion state. You should watch this property with a signal 55 * connection as follows: 56 * 57 * |[<!-- language="C" --> 58 * expander = gtk_expander_new_with_mnemonic ("_More Options"); 59 * g_signal_connect (expander, "notify::expanded", 60 * G_CALLBACK (expander_callback), NULL); 61 * 62 * ... 63 * 64 * static void 65 * expander_callback (GObject *object, 66 * GParamSpec *param_spec, 67 * gpointer user_data) 68 * { 69 * GtkExpander *expander; 70 * 71 * expander = GTK_EXPANDER (object); 72 * 73 * if (gtk_expander_get_expanded (expander)) 74 * { 75 * // Show or create widgets 76 * } 77 * else 78 * { 79 * // Hide or destroy widgets 80 * } 81 * } 82 * ]| 83 * 84 * # GtkExpander as GtkBuildable 85 * 86 * The GtkExpander implementation of the GtkBuildable interface supports 87 * placing a child in the label position by specifying “label” as the 88 * “type” attribute of a <child> element. A normal content child can be 89 * specified without specifying a <child> type attribute. 90 * 91 * An example of a UI definition fragment with GtkExpander: 92 * |[ 93 * <object class="GtkExpander"> 94 * <child type="label"> 95 * <object class="GtkLabel" id="expander-label"/> 96 * </child> 97 * <child> 98 * <object class="GtkEntry" id="expander-content"/> 99 * </child> 100 * </object> 101 * ]| 102 */ 103 public class Expander : Bin 104 { 105 /** the main Gtk struct */ 106 protected GtkExpander* gtkExpander; 107 108 /** Get the main Gtk struct */ 109 public GtkExpander* getExpanderStruct() 110 { 111 return gtkExpander; 112 } 113 114 /** the main Gtk struct as a void* */ 115 protected override void* getStruct() 116 { 117 return cast(void*)gtkExpander; 118 } 119 120 protected override void setStruct(GObject* obj) 121 { 122 gtkExpander = cast(GtkExpander*)obj; 123 super.setStruct(obj); 124 } 125 126 /** 127 * Sets our main struct and passes it to the parent class. 128 */ 129 public this (GtkExpander* gtkExpander, bool ownedRef = false) 130 { 131 this.gtkExpander = gtkExpander; 132 super(cast(GtkBin*)gtkExpander, ownedRef); 133 } 134 135 /** 136 * Creates a new expander using label as the text of the label. 137 * Since 2.4 138 * Params: 139 * label = the text of the label 140 * mnemonic = if true characters in label that are preceded by an underscore, 141 * are underlined. 142 * If you need a literal underscore character in a label, use '__' (two 143 * underscores). The first underlined character represents a keyboard 144 * accelerator called a mnemonic. 145 * Throws: ConstructionException GTK+ fails to create the object. 146 */ 147 public this (string label, bool mnemonic=true) 148 { 149 GtkExpander* p; 150 151 if ( mnemonic ) 152 { 153 p = cast(GtkExpander*)gtk_expander_new_with_mnemonic(Str.toStringz(label)); 154 } 155 else 156 { 157 p = cast(GtkExpander*)gtk_expander_new(Str.toStringz(label)); 158 } 159 160 if(p is null) 161 { 162 throw new ConstructionException("null returned by gtk_expander_new"); 163 } 164 165 this(p); 166 } 167 168 /** 169 */ 170 171 /** */ 172 public static GType getType() 173 { 174 return gtk_expander_get_type(); 175 } 176 177 /** 178 * Queries a #GtkExpander and returns its current state. Returns %TRUE 179 * if the child widget is revealed. 180 * 181 * See gtk_expander_set_expanded(). 182 * 183 * Return: the current state of the expander 184 * 185 * Since: 2.4 186 */ 187 public bool getExpanded() 188 { 189 return gtk_expander_get_expanded(gtkExpander) != 0; 190 } 191 192 /** 193 * Fetches the text from a label widget including any embedded 194 * underlines indicating mnemonics and Pango markup, as set by 195 * gtk_expander_set_label(). If the label text has not been set the 196 * return value will be %NULL. This will be the case if you create an 197 * empty button with gtk_button_new() to use as a container. 198 * 199 * Note that this function behaved differently in versions prior to 200 * 2.14 and used to return the label text stripped of embedded 201 * underlines indicating mnemonics and Pango markup. This problem can 202 * be avoided by fetching the label text directly from the label 203 * widget. 204 * 205 * Return: The text of the label widget. This string is owned 206 * by the widget and must not be modified or freed. 207 * 208 * Since: 2.4 209 */ 210 public string getLabel() 211 { 212 return Str.toString(gtk_expander_get_label(gtkExpander)); 213 } 214 215 /** 216 * Returns whether the label widget will fill all available 217 * horizontal space allocated to @expander. 218 * 219 * Return: %TRUE if the label widget will fill all 220 * available horizontal space 221 * 222 * Since: 2.22 223 */ 224 public bool getLabelFill() 225 { 226 return gtk_expander_get_label_fill(gtkExpander) != 0; 227 } 228 229 /** 230 * Retrieves the label widget for the frame. See 231 * gtk_expander_set_label_widget(). 232 * 233 * Return: the label widget, 234 * or %NULL if there is none 235 * 236 * Since: 2.4 237 */ 238 public Widget getLabelWidget() 239 { 240 auto p = gtk_expander_get_label_widget(gtkExpander); 241 242 if(p is null) 243 { 244 return null; 245 } 246 247 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 248 } 249 250 /** 251 * Returns whether the expander will resize the toplevel widget 252 * containing the expander upon resizing and collpasing. 253 * 254 * Return: the “resize toplevel” setting. 255 * 256 * Since: 3.2 257 */ 258 public bool getResizeToplevel() 259 { 260 return gtk_expander_get_resize_toplevel(gtkExpander) != 0; 261 } 262 263 /** 264 * Gets the value set by gtk_expander_set_spacing(). 265 * 266 * Return: spacing between the expander and child 267 * 268 * Since: 2.4 269 */ 270 public int getSpacing() 271 { 272 return gtk_expander_get_spacing(gtkExpander); 273 } 274 275 /** 276 * Returns whether the label’s text is interpreted as marked up with 277 * the [Pango text markup language][PangoMarkupFormat]. 278 * See gtk_expander_set_use_markup(). 279 * 280 * Return: %TRUE if the label’s text will be parsed for markup 281 * 282 * Since: 2.4 283 */ 284 public bool getUseMarkup() 285 { 286 return gtk_expander_get_use_markup(gtkExpander) != 0; 287 } 288 289 /** 290 * Returns whether an embedded underline in the expander label 291 * indicates a mnemonic. See gtk_expander_set_use_underline(). 292 * 293 * Return: %TRUE if an embedded underline in the expander 294 * label indicates the mnemonic accelerator keys 295 * 296 * Since: 2.4 297 */ 298 public bool getUseUnderline() 299 { 300 return gtk_expander_get_use_underline(gtkExpander) != 0; 301 } 302 303 /** 304 * Sets the state of the expander. Set to %TRUE, if you want 305 * the child widget to be revealed, and %FALSE if you want the 306 * child widget to be hidden. 307 * 308 * Params: 309 * expanded = whether the child widget is revealed 310 * 311 * Since: 2.4 312 */ 313 public void setExpanded(bool expanded) 314 { 315 gtk_expander_set_expanded(gtkExpander, expanded); 316 } 317 318 /** 319 * Sets the text of the label of the expander to @label. 320 * 321 * This will also clear any previously set labels. 322 * 323 * Params: 324 * label = a string 325 * 326 * Since: 2.4 327 */ 328 public void setLabel(string label) 329 { 330 gtk_expander_set_label(gtkExpander, Str.toStringz(label)); 331 } 332 333 /** 334 * Sets whether the label widget should fill all available 335 * horizontal space allocated to @expander. 336 * 337 * Params: 338 * labelFill = %TRUE if the label should should fill 339 * all available horizontal space 340 * 341 * Since: 2.22 342 */ 343 public void setLabelFill(bool labelFill) 344 { 345 gtk_expander_set_label_fill(gtkExpander, labelFill); 346 } 347 348 /** 349 * Set the label widget for the expander. This is the widget 350 * that will appear embedded alongside the expander arrow. 351 * 352 * Params: 353 * labelWidget = the new label widget 354 * 355 * Since: 2.4 356 */ 357 public void setLabelWidget(Widget labelWidget) 358 { 359 gtk_expander_set_label_widget(gtkExpander, (labelWidget is null) ? null : labelWidget.getWidgetStruct()); 360 } 361 362 /** 363 * Sets whether the expander will resize the toplevel widget 364 * containing the expander upon resizing and collpasing. 365 * 366 * Params: 367 * resizeToplevel = whether to resize the toplevel 368 * 369 * Since: 3.2 370 */ 371 public void setResizeToplevel(bool resizeToplevel) 372 { 373 gtk_expander_set_resize_toplevel(gtkExpander, resizeToplevel); 374 } 375 376 /** 377 * Sets the spacing field of @expander, which is the number of 378 * pixels to place between expander and the child. 379 * 380 * Params: 381 * spacing = distance between the expander and child in pixels 382 * 383 * Since: 2.4 384 */ 385 public void setSpacing(int spacing) 386 { 387 gtk_expander_set_spacing(gtkExpander, spacing); 388 } 389 390 /** 391 * Sets whether the text of the label contains markup in 392 * [Pango’s text markup language][PangoMarkupFormat]. 393 * See gtk_label_set_markup(). 394 * 395 * Params: 396 * useMarkup = %TRUE if the label’s text should be parsed for markup 397 * 398 * Since: 2.4 399 */ 400 public void setUseMarkup(bool useMarkup) 401 { 402 gtk_expander_set_use_markup(gtkExpander, useMarkup); 403 } 404 405 /** 406 * If true, an underline in the text of the expander label indicates 407 * the next character should be used for the mnemonic accelerator key. 408 * 409 * Params: 410 * useUnderline = %TRUE if underlines in the text indicate mnemonics 411 * 412 * Since: 2.4 413 */ 414 public void setUseUnderline(bool useUnderline) 415 { 416 gtk_expander_set_use_underline(gtkExpander, useUnderline); 417 } 418 419 int[string] connectedSignals; 420 421 void delegate(Expander)[] onActivateListeners; 422 /** */ 423 void addOnActivate(void delegate(Expander) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 424 { 425 if ( "activate" !in connectedSignals ) 426 { 427 Signals.connectData( 428 this, 429 "activate", 430 cast(GCallback)&callBackActivate, 431 cast(void*)this, 432 null, 433 connectFlags); 434 connectedSignals["activate"] = 1; 435 } 436 onActivateListeners ~= dlg; 437 } 438 extern(C) static void callBackActivate(GtkExpander* expanderStruct, Expander _expander) 439 { 440 foreach ( void delegate(Expander) dlg; _expander.onActivateListeners ) 441 { 442 dlg(_expander); 443 } 444 } 445 }