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 * Conversion parameters: 26 * inFile = GtkToolItem.html 27 * outPack = gtk 28 * outFile = ToolItem 29 * strct = GtkToolItem 30 * realStrct= 31 * ctorStrct= 32 * clss = ToolItem 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - ActivatableIF 40 * prefixes: 41 * - gtk_tool_item_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.SizeGroup 49 * - gtk.Widget 50 * - gtk.ActivatableT 51 * - gtk.ActivatableIF 52 * structWrap: 53 * - GtkSizeGroup* -> SizeGroup 54 * - GtkWidget* -> Widget 55 * module aliases: 56 * local aliases: 57 * overrides: 58 * - setTooltipText 59 * - setTooltipMarkup 60 */ 61 62 module gtk.ToolItem; 63 64 public import gtkc.gtktypes; 65 66 private import gtkc.gtk; 67 private import glib.ConstructionException; 68 private import gobject.ObjectG; 69 70 private import gobject.Signals; 71 public import gtkc.gdktypes; 72 73 private import glib.Str; 74 private import gtk.SizeGroup; 75 private import gtk.Widget; 76 private import gtk.ActivatableT; 77 private import gtk.ActivatableIF; 78 79 80 81 private import gtk.Bin; 82 83 /** 84 * GtkToolItems are widgets that can appear on a toolbar. To 85 * create a toolbar item that contain something else than a button, use 86 * gtk_tool_item_new(). Use gtk_container_add() to add a child 87 * widget to the tool item. 88 * 89 * For toolbar items that contain buttons, see the GtkToolButton, 90 * GtkToggleToolButton and GtkRadioToolButton classes. 91 * 92 * See the GtkToolbar class for a description of the toolbar widget, and 93 * GtkToolShell for a description of the tool shell interface. 94 */ 95 public class ToolItem : Bin, ActivatableIF 96 { 97 98 /** the main Gtk struct */ 99 protected GtkToolItem* gtkToolItem; 100 101 102 public GtkToolItem* getToolItemStruct() 103 { 104 return gtkToolItem; 105 } 106 107 108 /** the main Gtk struct as a void* */ 109 protected override void* getStruct() 110 { 111 return cast(void*)gtkToolItem; 112 } 113 114 /** 115 * Sets our main struct and passes it to the parent class 116 */ 117 public this (GtkToolItem* gtkToolItem) 118 { 119 super(cast(GtkBin*)gtkToolItem); 120 this.gtkToolItem = gtkToolItem; 121 } 122 123 protected override void setStruct(GObject* obj) 124 { 125 super.setStruct(obj); 126 gtkToolItem = cast(GtkToolItem*)obj; 127 } 128 129 // add the Activatable capabilities 130 mixin ActivatableT!(GtkToolItem); 131 132 /** 133 */ 134 int[string] connectedSignals; 135 136 bool delegate(ToolItem)[] onCreateMenuProxyListeners; 137 /** 138 * This signal is emitted when the toolbar needs information from tool_item 139 * about whether the item should appear in the toolbar overflow menu. In 140 * response the tool item should either 141 * call gtk_tool_item_set_proxy_menu_item() with a NULL 142 * pointer and return TRUE to indicate that the item should not appear 143 * in the overflow menu 144 * call gtk_tool_item_set_proxy_menu_item() with a new menu 145 * item and return TRUE, or 146 * return FALSE to indicate that the signal was not 147 * handled by the item. This means that 148 * the item will not appear in the overflow menu unless a later handler 149 * installs a menu item. 150 * The toolbar may cache the result of this signal. When the tool item changes 151 * how it will respond to this signal it must call gtk_tool_item_rebuild_menu() 152 * to invalidate the cache and ensure that the toolbar rebuilds its overflow 153 * menu. 154 * TRUE if the signal was handled, FALSE if not 155 */ 156 void addOnCreateMenuProxy(bool delegate(ToolItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 157 { 158 if ( !("create-menu-proxy" in connectedSignals) ) 159 { 160 Signals.connectData( 161 getStruct(), 162 "create-menu-proxy", 163 cast(GCallback)&callBackCreateMenuProxy, 164 cast(void*)this, 165 null, 166 connectFlags); 167 connectedSignals["create-menu-proxy"] = 1; 168 } 169 onCreateMenuProxyListeners ~= dlg; 170 } 171 extern(C) static gboolean callBackCreateMenuProxy(GtkToolItem* toolItemStruct, ToolItem _toolItem) 172 { 173 foreach ( bool delegate(ToolItem) dlg ; _toolItem.onCreateMenuProxyListeners ) 174 { 175 if ( dlg(_toolItem) ) 176 { 177 return 1; 178 } 179 } 180 181 return 0; 182 } 183 184 void delegate(ToolItem)[] onToolbarReconfiguredListeners; 185 /** 186 * This signal is emitted when some property of the toolbar that the 187 * item is a child of changes. For custom subclasses of GtkToolItem, 188 * the default handler of this signal use the functions 189 * gtk_tool_shell_get_orientation() 190 * gtk_tool_shell_get_style() 191 * gtk_tool_shell_get_icon_size() 192 * gtk_tool_shell_get_relief_style() 193 * to find out what the toolbar should look like and change 194 * themselves accordingly. 195 * See Also 196 * GtkToolbar 197 * The toolbar widget 198 * GtkToolButton 199 * A subclass of GtkToolItem that displays buttons on 200 * the toolbar 201 * GtkSeparatorToolItem 202 * A subclass of GtkToolItem that separates groups of 203 * items on a toolbar 204 */ 205 void addOnToolbarReconfigured(void delegate(ToolItem) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 206 { 207 if ( !("toolbar-reconfigured" in connectedSignals) ) 208 { 209 Signals.connectData( 210 getStruct(), 211 "toolbar-reconfigured", 212 cast(GCallback)&callBackToolbarReconfigured, 213 cast(void*)this, 214 null, 215 connectFlags); 216 connectedSignals["toolbar-reconfigured"] = 1; 217 } 218 onToolbarReconfiguredListeners ~= dlg; 219 } 220 extern(C) static void callBackToolbarReconfigured(GtkToolItem* toolItemStruct, ToolItem _toolItem) 221 { 222 foreach ( void delegate(ToolItem) dlg ; _toolItem.onToolbarReconfiguredListeners ) 223 { 224 dlg(_toolItem); 225 } 226 } 227 228 229 /** 230 * Creates a new GtkToolItem 231 * Since 2.4 232 * Throws: ConstructionException GTK+ fails to create the object. 233 */ 234 public this () 235 { 236 // GtkToolItem * gtk_tool_item_new (void); 237 auto p = gtk_tool_item_new(); 238 if(p is null) 239 { 240 throw new ConstructionException("null returned by gtk_tool_item_new()"); 241 } 242 this(cast(GtkToolItem*) p); 243 } 244 245 /** 246 * Sets whether tool_item is to be allocated the same size as other 247 * homogeneous items. The effect is that all homogeneous items will have 248 * the same width as the widest of the items. 249 * Since 2.4 250 * Params: 251 * homogeneous = whether tool_item is the same size as other homogeneous items 252 */ 253 public void setHomogeneous(int homogeneous) 254 { 255 // void gtk_tool_item_set_homogeneous (GtkToolItem *tool_item, gboolean homogeneous); 256 gtk_tool_item_set_homogeneous(gtkToolItem, homogeneous); 257 } 258 259 /** 260 * Returns whether tool_item is the same size as other homogeneous 261 * items. See gtk_tool_item_set_homogeneous(). 262 * Since 2.4 263 * Returns: TRUE if the item is the same size as other homogeneous items. 264 */ 265 public int getHomogeneous() 266 { 267 // gboolean gtk_tool_item_get_homogeneous (GtkToolItem *tool_item); 268 return gtk_tool_item_get_homogeneous(gtkToolItem); 269 } 270 271 /** 272 * Sets whether tool_item is allocated extra space when there 273 * is more room on the toolbar then needed for the items. The 274 * effect is that the item gets bigger when the toolbar gets bigger 275 * and smaller when the toolbar gets smaller. 276 * Since 2.4 277 * Params: 278 * expand = Whether tool_item is allocated extra space 279 */ 280 public void setExpand(int expand) 281 { 282 // void gtk_tool_item_set_expand (GtkToolItem *tool_item, gboolean expand); 283 gtk_tool_item_set_expand(gtkToolItem, expand); 284 } 285 286 /** 287 * Returns whether tool_item is allocated extra space. 288 * See gtk_tool_item_set_expand(). 289 * Since 2.4 290 * Returns: TRUE if tool_item is allocated extra space. 291 */ 292 public int getExpand() 293 { 294 // gboolean gtk_tool_item_get_expand (GtkToolItem *tool_item); 295 return gtk_tool_item_get_expand(gtkToolItem); 296 } 297 298 /** 299 * Sets the text to be displayed as tooltip on the item. 300 * See gtk_widget_set_tooltip_text(). 301 * Since 2.12 302 * Params: 303 * text = text to be used as tooltip for tool_item 304 */ 305 public override void setTooltipText(string text) 306 { 307 // void gtk_tool_item_set_tooltip_text (GtkToolItem *tool_item, const gchar *text); 308 gtk_tool_item_set_tooltip_text(gtkToolItem, Str.toStringz(text)); 309 } 310 311 /** 312 * Sets the markup text to be displayed as tooltip on the item. 313 * See gtk_widget_set_tooltip_markup(). 314 * Since 2.12 315 * Params: 316 * markup = markup text to be used as tooltip for tool_item 317 */ 318 public override void setTooltipMarkup(string markup) 319 { 320 // void gtk_tool_item_set_tooltip_markup (GtkToolItem *tool_item, const gchar *markup); 321 gtk_tool_item_set_tooltip_markup(gtkToolItem, Str.toStringz(markup)); 322 } 323 324 /** 325 * Sets whether tool_item has a drag window. When TRUE the 326 * toolitem can be used as a drag source through gtk_drag_source_set(). 327 * When tool_item has a drag window it will intercept all events, 328 * even those that would otherwise be sent to a child of tool_item. 329 * Since 2.4 330 * Params: 331 * useDragWindow = Whether tool_item has a drag window. 332 */ 333 public void setUseDragWindow(int useDragWindow) 334 { 335 // void gtk_tool_item_set_use_drag_window (GtkToolItem *tool_item, gboolean use_drag_window); 336 gtk_tool_item_set_use_drag_window(gtkToolItem, useDragWindow); 337 } 338 339 /** 340 * Returns whether tool_item has a drag window. See 341 * gtk_tool_item_set_use_drag_window(). 342 * Since 2.4 343 * Returns: TRUE if tool_item uses a drag window. 344 */ 345 public int getUseDragWindow() 346 { 347 // gboolean gtk_tool_item_get_use_drag_window (GtkToolItem *tool_item); 348 return gtk_tool_item_get_use_drag_window(gtkToolItem); 349 } 350 351 /** 352 * Sets whether tool_item is visible when the toolbar is docked horizontally. 353 * Since 2.4 354 * Params: 355 * visibleHorizontal = Whether tool_item is visible when in horizontal mode 356 */ 357 public void setVisibleHorizontal(int visibleHorizontal) 358 { 359 // void gtk_tool_item_set_visible_horizontal (GtkToolItem *tool_item, gboolean visible_horizontal); 360 gtk_tool_item_set_visible_horizontal(gtkToolItem, visibleHorizontal); 361 } 362 363 /** 364 * Returns whether the tool_item is visible on toolbars that are 365 * docked horizontally. 366 * Since 2.4 367 * Returns: TRUE if tool_item is visible on toolbars that are docked horizontally. 368 */ 369 public int getVisibleHorizontal() 370 { 371 // gboolean gtk_tool_item_get_visible_horizontal (GtkToolItem *tool_item); 372 return gtk_tool_item_get_visible_horizontal(gtkToolItem); 373 } 374 375 /** 376 * Sets whether tool_item is visible when the toolbar is docked 377 * vertically. Some tool items, such as text entries, are too wide to be 378 * useful on a vertically docked toolbar. If visible_vertical is FALSE 379 * tool_item will not appear on toolbars that are docked vertically. 380 * Since 2.4 381 * Params: 382 * visibleVertical = whether tool_item is visible when the toolbar 383 * is in vertical mode 384 */ 385 public void setVisibleVertical(int visibleVertical) 386 { 387 // void gtk_tool_item_set_visible_vertical (GtkToolItem *tool_item, gboolean visible_vertical); 388 gtk_tool_item_set_visible_vertical(gtkToolItem, visibleVertical); 389 } 390 391 /** 392 * Returns whether tool_item is visible when the toolbar is docked vertically. 393 * See gtk_tool_item_set_visible_vertical(). 394 * Since 2.4 395 * Returns: Whether tool_item is visible when the toolbar is docked vertically 396 */ 397 public int getVisibleVertical() 398 { 399 // gboolean gtk_tool_item_get_visible_vertical (GtkToolItem *tool_item); 400 return gtk_tool_item_get_visible_vertical(gtkToolItem); 401 } 402 403 /** 404 * Sets whether tool_item should be considered important. The GtkToolButton 405 * class uses this property to determine whether to show or hide its label 406 * when the toolbar style is GTK_TOOLBAR_BOTH_HORIZ. The result is that 407 * only tool buttons with the "is_important" property set have labels, an 408 * effect known as "priority text" 409 * Since 2.4 410 * Params: 411 * isImportant = whether the tool item should be considered important 412 */ 413 public void setIsImportant(int isImportant) 414 { 415 // void gtk_tool_item_set_is_important (GtkToolItem *tool_item, gboolean is_important); 416 gtk_tool_item_set_is_important(gtkToolItem, isImportant); 417 } 418 419 /** 420 * Returns whether tool_item is considered important. See 421 * gtk_tool_item_set_is_important() 422 * Since 2.4 423 * Returns: TRUE if tool_item is considered important. 424 */ 425 public int getIsImportant() 426 { 427 // gboolean gtk_tool_item_get_is_important (GtkToolItem *tool_item); 428 return gtk_tool_item_get_is_important(gtkToolItem); 429 } 430 431 /** 432 * Returns the ellipsize mode used for tool_item. Custom subclasses of 433 * GtkToolItem should call this function to find out how text should 434 * be ellipsized. 435 * Since 2.20 436 * Returns: a PangoEllipsizeMode indicating how text in tool_item should be ellipsized. 437 */ 438 public PangoEllipsizeMode getEllipsizeMode() 439 { 440 // PangoEllipsizeMode gtk_tool_item_get_ellipsize_mode (GtkToolItem *tool_item); 441 return gtk_tool_item_get_ellipsize_mode(gtkToolItem); 442 } 443 444 /** 445 * Returns the icon size used for tool_item. Custom subclasses of 446 * GtkToolItem should call this function to find out what size icons 447 * they should use. 448 * Since 2.4 449 * Returns: a GtkIconSize indicating the icon size used for tool_item. [type int] 450 */ 451 public GtkIconSize getIconSize() 452 { 453 // GtkIconSize gtk_tool_item_get_icon_size (GtkToolItem *tool_item); 454 return gtk_tool_item_get_icon_size(gtkToolItem); 455 } 456 457 /** 458 * Returns the orientation used for tool_item. Custom subclasses of 459 * GtkToolItem should call this function to find out what size icons 460 * they should use. 461 * Since 2.4 462 * Returns: a GtkOrientation indicating the orientation used for tool_item 463 */ 464 public GtkOrientation getOrientation() 465 { 466 // GtkOrientation gtk_tool_item_get_orientation (GtkToolItem *tool_item); 467 return gtk_tool_item_get_orientation(gtkToolItem); 468 } 469 470 /** 471 * Returns the toolbar style used for tool_item. Custom subclasses of 472 * GtkToolItem should call this function in the handler of the 473 * GtkToolItem::toolbar_reconfigured signal to find out in what style 474 * the toolbar is displayed and change themselves accordingly 475 * Since 2.4 476 * Returns: A GtkToolbarStyle indicating the toolbar style used for tool_item. 477 */ 478 public GtkToolbarStyle getToolbarStyle() 479 { 480 // GtkToolbarStyle gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item); 481 return gtk_tool_item_get_toolbar_style(gtkToolItem); 482 } 483 484 /** 485 * Returns the relief style of tool_item. See gtk_button_set_relief(). 486 * Custom subclasses of GtkToolItem should call this function in the handler 487 * of the "toolbar_reconfigured" signal to find out the 488 * relief style of buttons. 489 * Since 2.4 490 * Returns: a GtkReliefStyle indicating the relief style used for tool_item. 491 */ 492 public GtkReliefStyle getReliefStyle() 493 { 494 // GtkReliefStyle gtk_tool_item_get_relief_style (GtkToolItem *tool_item); 495 return gtk_tool_item_get_relief_style(gtkToolItem); 496 } 497 498 /** 499 * Returns the text alignment used for tool_item. Custom subclasses of 500 * GtkToolItem should call this function to find out how text should 501 * be aligned. 502 * Since 2.20 503 * Returns: a gfloat indicating the horizontal text alignment used for tool_item 504 */ 505 public float getTextAlignment() 506 { 507 // gfloat gtk_tool_item_get_text_alignment (GtkToolItem *tool_item); 508 return gtk_tool_item_get_text_alignment(gtkToolItem); 509 } 510 511 /** 512 * Returns the text orientation used for tool_item. Custom subclasses of 513 * GtkToolItem should call this function to find out how text should 514 * be orientated. 515 * Since 2.20 516 * Returns: a GtkOrientation indicating the text orientation used for tool_item 517 */ 518 public GtkOrientation getTextOrientation() 519 { 520 // GtkOrientation gtk_tool_item_get_text_orientation (GtkToolItem *tool_item); 521 return gtk_tool_item_get_text_orientation(gtkToolItem); 522 } 523 524 /** 525 * Returns the GtkMenuItem that was last set by 526 * gtk_tool_item_set_proxy_menu_item(), ie. the GtkMenuItem 527 * that is going to appear in the overflow menu. 528 * Since 2.4 529 * Returns: The GtkMenuItem that is going to appear in the overflow menu for tool_item. [transfer none] 530 */ 531 public Widget retrieveProxyMenuItem() 532 { 533 // GtkWidget * gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item); 534 auto p = gtk_tool_item_retrieve_proxy_menu_item(gtkToolItem); 535 536 if(p is null) 537 { 538 return null; 539 } 540 541 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 542 } 543 544 /** 545 * If menu_item_id matches the string passed to 546 * gtk_tool_item_set_proxy_menu_item() return the corresponding GtkMenuItem. 547 * Custom subclasses of GtkToolItem should use this function to 548 * update their menu item when the GtkToolItem changes. That the 549 * menu_item_ids must match ensures that a GtkToolItem 550 * will not inadvertently change a menu item that they did not create. 551 * Since 2.4 552 * Params: 553 * menuItemId = a string used to identify the menu item 554 * Returns: The GtkMenuItem passed to gtk_tool_item_set_proxy_menu_item(), if the menu_item_ids match. [transfer none] 555 */ 556 public Widget getProxyMenuItem(string menuItemId) 557 { 558 // GtkWidget * gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item, const gchar *menu_item_id); 559 auto p = gtk_tool_item_get_proxy_menu_item(gtkToolItem, Str.toStringz(menuItemId)); 560 561 if(p is null) 562 { 563 return null; 564 } 565 566 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 567 } 568 569 /** 570 * Sets the GtkMenuItem used in the toolbar overflow menu. The 571 * menu_item_id is used to identify the caller of this function and 572 * should also be used with gtk_tool_item_get_proxy_menu_item(). 573 * Since 2.4 574 * Params: 575 * menuItemId = a string used to identify menu_item 576 * menuItem = a GtkMenuItem to be used in the overflow menu 577 */ 578 public void setProxyMenuItem(string menuItemId, Widget menuItem) 579 { 580 // void gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item, const gchar *menu_item_id, GtkWidget *menu_item); 581 gtk_tool_item_set_proxy_menu_item(gtkToolItem, Str.toStringz(menuItemId), (menuItem is null) ? null : menuItem.getWidgetStruct()); 582 } 583 584 /** 585 * Calling this function signals to the toolbar that the 586 * overflow menu item for tool_item has changed. If the 587 * overflow menu is visible when this function it called, 588 * the menu will be rebuilt. 589 * The function must be called when the tool item changes what it 590 * will do in response to the "create-menu-proxy" signal. 591 * Since 2.6 592 */ 593 public void rebuildMenu() 594 { 595 // void gtk_tool_item_rebuild_menu (GtkToolItem *tool_item); 596 gtk_tool_item_rebuild_menu(gtkToolItem); 597 } 598 599 /** 600 * Emits the signal "toolbar_reconfigured" on tool_item. 601 * GtkToolbar and other GtkToolShell implementations use this function 602 * to notify children, when some aspect of their configuration changes. 603 * Since 2.14 604 */ 605 public void toolbarReconfigured() 606 { 607 // void gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item); 608 gtk_tool_item_toolbar_reconfigured(gtkToolItem); 609 } 610 611 /** 612 * Returns the size group used for labels in tool_item. 613 * Custom subclasses of GtkToolItem should call this function 614 * and use the size group for labels. 615 * Since 2.20 616 * Returns: a GtkSizeGroup. [transfer none] 617 */ 618 public SizeGroup getTextSizeGroup() 619 { 620 // GtkSizeGroup * gtk_tool_item_get_text_size_group (GtkToolItem *tool_item); 621 auto p = gtk_tool_item_get_text_size_group(gtkToolItem); 622 623 if(p is null) 624 { 625 return null; 626 } 627 628 return ObjectG.getDObject!(SizeGroup)(cast(GtkSizeGroup*) p); 629 } 630 }