public class Toolbar extends Container implements Orientable
In most cases, you will want to add some ToolButton
s to the
Toolbar, but you can also add other elements as well by creating a
ToolItem
and adding your own customized elements to it.
You can also group related items together by using a
SeparatorToolItem
to the Toolbar to create a separation between
them. Don't overdo that, however - too many separators result in a
cluttered appearance.
Note that the actual on screen appearance of the Toolbar is governed by the
user's theme and how they have configured Toolbars to appear. The choices
of "Text below Icons" (the usual default), "Text beside
Icons", "Icons only", and "Text only" are
available from the GNOME panel menu at System >
Menus
& Toolbars which runs the gnome-ui-properties
program.
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
Constructor and Description |
---|
Toolbar()
Create a new, empty, Toolbar.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Widget w)
Add a child Widget to this Container.
|
Orientation |
getOrientation()
Get the orientation of this Orientable.
|
void |
insert(ToolItem item,
int pos)
Insert a ToolItem in the Toolbar at a given position.
|
void |
setOrientation(Orientation orientation)
Sets the orientation of the Toolbar on screen.
|
void |
setStyle(ToolbarStyle style)
Set the appearance of a Toolbar.
|
getChildren, remove, setBorderWidth
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
public void add(Widget w)
Container
public Orientation getOrientation()
Orientable
getOrientation
in interface Orientable
public void insert(ToolItem item, int pos)
item
- The new item to add to the Toolbar.pos
- The position where the new item will be inserted. You can
use 0
to prepend the item at the beginning of
the Toolbar, or a negative value to append the item at the
end.public void setOrientation(Orientation orientation)
Horizontal Toolbars are commonly used. Usually you shouldn't use a vertical Toolbar it is more difficult to search for the user to find a specific control. When your application has several Toolbars, however, a vertical orientation can become useful as a technique to make a better usage of the available screen real estate.
setOrientation
in interface Orientable
public void setStyle(ToolbarStyle style)
Toolbars buttons can be customized to display either an icon, a text label, or both. As explained above, in the documentation for this class, the appearance of Toolbars is configured by the user as a desktop setting. This method will override those settings, so in most cases you should not use this method, and just let the user choose the appearance (s)he prefers.
However, some really complex applications might need several Toolbars and many buttons on each one, so configuring a compact Toolbar style can help to save screen space. In such cases this method may be useful, but the general advice is to use this with care, and avoid overriding of user settings unless you have a strong reason.
Finally, note that if you choose for example an ICONS
only
appearance, and a given ToolButton has no icon, its Label will be shown
instead, so GTK engine will do its best to keep Toolbar usable.