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