public class ToolButton extends ToolItem
This is the item you will want to add in most cases to your application Toolbar(s). It is a acts a like a normal Button, but its appearance is designed to look better on a Toolbar.
A ToolButton has an image or icon and a Label. The user Toolbar preferences determine whether the Label is actually shown on screen. Even if you disable the Label in your desktop preferences, you should provide a valid Label to your application ToolButtons, as other users will have them showing and your program will look a bit silly without textual labels.
Modifier and Type | Class and Description |
---|---|
static interface |
ToolButton.Clicked
Signal generated when a user presses and releases a ToolButton, causing
it to activate.
|
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 |
---|
ToolButton(Stock stock)
Creates a new stock ToolButton.
|
ToolButton(Widget iconWidget,
String label)
Creates a new ToolButton using the given icon and Label.
|
Modifier and Type | Method and Description |
---|---|
void |
connect(ToolButton.Clicked handler)
Connect a handler to the
ToolButton.Clicked signal. |
String |
getLabel()
Get the text Label previously set with
setLabel() . |
Widget |
getLabelWidget()
Get the Widget used as "label", if any.
|
void |
setLabel(String label)
Set the Label of the Button.
|
void |
setLabelWidget(Widget labelWidget)
Set the Widget to be used as the "label" for this ToolButton.
|
getExpand, getRelatedAction, setExpand, setIsImportant, setRelatedAction
add, 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 ToolButton(Stock stock)
stock
- The Stock that will determine the Label and icon on the
ToolButton.public ToolButton(Widget iconWidget, String label)
iconWidget
- The Widget to be used as the icon for the ToolButton.
Usually you will want to use a Widget that displays a
graphic, such as Image
.label
- The Label for the ToolButton.public void connect(ToolButton.Clicked handler)
ToolButton.Clicked
signal.public String getLabel()
setLabel()
.null
if not Label has been set. Note
that a null
return value doesn't mean that the
ToolButton doesn't have a Label, as it can have a Widget Label
or a Label taken from a stock item.public Widget getLabelWidget()
null
if this
ToolButton doesn't have a Widget overriding its label.setLabelWidget(Widget)
public void setLabel(String label)
Note that any value of the Label set by this method won't be actually
displayed if you have set a Widget Label using
setLabelWidget()
label
- The String to be used as Label, or null
.public void setLabelWidget(Widget labelWidget)
Please check setLabel()
before using this,
because in most cases that is what you want.
Usually ToolButtons have either a text Label set with
setLabel()
, or text automatically determined by a stock
item. However, in some cases you will want to provide another kind of
Widget as the label, and this method is how.
labelWidget
- A Widget to be used as a Label, or null
to not
use the Widget Label (in this case, the text Label will be
used. If the text Label is also null
, the
default stock item label is used. In this later case, if
this ToolButton has no stock item, then no Label will be
used at all). Note that if you do pass a non-
null
Widget here, this argument will be used as
the label despite the text in the normal Label or one
generated as a result of using a stock item.