Xfce
Foundation Classes |
|||
« Main Page | Index | |||
ToolbarsToolbars are containers that hold instances of Gtk::ToolItem. Typically tool items are buttons with icons, labels and tooltips, but any other widget can also be put inside a tool item. Available ToolItems include ToolButton, ToggleToolButton and RadioToolButton. Toolbar items can be arranged horizontally or vertically and can be displayed with icons, labels, or both. Toolbar items can be visually grouped by adding instances of Gtk::SeparatorToolItem to the toolbar. If a separator tool item has its 'expand' property set to true and its 'draw' property set to false the effect is to force all following items to the end of the toolbar. You can create a Toolbar with the following constructors: Toolbar(); The first constructor creates a default horizontal toolbar that will display both icons and text. The second constructor creates a toolbar with the specified orientation that will display both icons and text. The last constructor creates a toolbar with the specified orientation and style. The 'orientation' argument specifies the whether to toolbar should be horizontal or vertical and can be one of the values from the Gtk::Orientation enum:
void append(ToolItem& item, const
String& tooltip); The 'item' argument is the ToolItem to add and 'tooltip' is the text tooltip for that item. The 'pos' argument is the position in the toolbar to insert the tool item. Separators can be placed between tool items with the following methods: void append_separator(); The 'pos' argument is the position in the toolbar to insert the separator. If it's required, the orientation of a toolbar and its style can be changed "on the fly" using the following methods: void
set_orientation(Gtk::Orientation orientation); You can set the text displayed as the tooltip for a tool item and the private text to be used, if any: void set_tooltip(ToolItem&
item, const String&
tip_text, const
String& tip_private = 0); You can set and retrieve the show_arrow property with the following methods: void set_show_arrow(bool show_arrow); If 'show_arrow' is true an overflow menu will be shown when the toolbar doesn't have enough room for all its tool items. A context menu for the toolbar can be created by connecting to the 'popup-context-menu' signal. This signal in emitted when the user right-clicks inside the toolbar to display a context menu. You can connect to the 'popup-context-menu' signal using its proxy signal function: const
PopupContextMenuSignalProxy signal_popup_context_menu(); Your connected slot function should have the following signature: bool function(int x, int y, int button); The 'x' and 'y' arguments are the coordinates of the point where the menu should appear. The 'button' argument is the mouse button the user pressed, or -1. The return value should be true if the signal was handled and false if not. Toolbar ExampleLet's take a look at a simple Toolbar example that shows you how to build a toolbar without using the Gtk::UIManager interface or stock items. It's an old example thathas been updated to use the new Gtk::TooItem API. The header file for the Toolbar example is <toolbar.hh>: #include <xfc/main.hh> and the source file is <toolbar.cc>: #include "toolbar.hh" Compiling Toolbar
If you compiled and installed XFC yourself, you will find the source
code for Toolbar in the
<examples/toolbar> source directory along with a Makefile. If
XFC came pre-installed, or you installed it from an RPM package, you
will
find the source code in the
</usr/share/doc/xfcui-X.X/examples/toolbar> subdirectory. In
this case you will have to create the Makefile yourself (replace X.X
with the
version number of the libXFCui library you have installed). |
Copyright © 2004-2005 The XFC Development Team | Top |
XFC
4.4 |