Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class ToolBar

extends Composite
Class Inheritance
Imports
java.util.*, org.eclipse.swt.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class support the layout of selectable tool bar items.

The item children that may be added to instances of this class must be of type ToolItem.

Note that although this class is a subclass of Composite, it does not make sense to add Control children to it, or set a layout on it.

Styles:
FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL, SHADOW_OUT
Events:
(none)

Note

Only one of the styles HORIZONTAL and VERTICAL may be specified.

Important Note

This class is not intended to be subclassed.

See Also
ToolBar, ToolItem snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv String
pack-priv ToolItem
pack-priv boolean
pack-priv ImageList
pack-priv ToolItem[]
Inherited from org.eclipse.swt.widgets.Composite:
backgroundModechildrenLoweredembeddedHandlefixClipHandlefixClipMapimHandlelayoutlayoutCountNO_INPUT_METHODnoChildDrawingpopupChildsocketHandletabList

Constructor Summary

AccessConstructor and Description
public
ToolBar(Composite
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
pack-priv ToolItem[]
pack-priv ToolItem[]
pack-priv int
pack-priv static int
protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

Checks that this class can be subclassed.
pack-priv Point
computeSizeInPixels(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Composite.computeSizeInPixels.

pack-priv Widget
pack-priv Widget[]
pack-priv void
pack-priv long
pack-priv long
pack-priv boolean
public ToolItem

Returns:

the item at the given index
getItem
(int
the index of the item to return
index
)

Returns the item at the given, zero-relative index in the receiver.

public ToolItem

Returns:

the item at the given point
getItem
(Point
the point used to locate the item
point
)

Returns the item at the given point in the receiver or null if no such item exists.

public int

Returns:

the number of items
getItemCount
()

Returns the number of items contained in the receiver.

pack-priv ToolItem
public ToolItem[]

Returns:

the items in the receiver
getItems
()

Returns an array of ToolItems which are the items in the receiver.

public int

Returns:

the number of items
getRowCount
()

Returns the number of rows in the receiver.

pack-priv long
gtk_focus(long widget, long directionType)

Overrides org.eclipse.swt.widgets.Composite.gtk_focus.

pack-priv long
pack-priv boolean
public int

Returns:

the index of the item
indexOf
(ToolItem
the search item
item
)

Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item.

pack-priv boolean
pack-priv boolean
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv int
setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Composite.setBounds.

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public void
setToolTipText(String
the new tool tip text (or null)
string
)

Overrides org.eclipse.swt.widgets.Control.setToolTipText.

Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.
Inherited from org.eclipse.swt.widgets.Composite:
_getChildren_getTabListadjustChildClippingchangedcheckBufferedcheckSubwindowconnectFixedHandleDrawcreateHandlederegisterdrawBackgrounddrawBackgroundInPixelsenableWidgetfindDeferredControlfindMenusfixChildrenfixClippingsfixModalfixParentGdkResourcefixStylefixTabListfixZOrderfocusHandlegetBackgroundModegetChildrengetChildrenCountgetClientAreaInPixelsgetLayoutgetLayoutDeferredgetTabListgtk4_key_press_eventgtk_button_press_eventgtk_drawgtk_focus_in_eventgtk_focus_out_eventgtk_mapgtk_realizegtk_scroll_childgtk_style_updatedhasBorderhookEventshooksKeysimHandleisLayoutDeferredisTabGrouplayoutlayoutlayoutlayoutlayoutmarkLayoutminimumSizemoveAbovemoveBelowmoveChildrenmustBeVisibleOnInitBoundsparentingHandleprintWidgetpropagateDrawredrawChildrenregisterreleaseHandleresizeHandlesetBackgroundModesetFocussetLayoutsetLayoutDeferredsetScrollBarVisiblesetTabGroupFocussetTabItemFocussetTabListshowWidgettoStringtranslateMnemonictranslateTraversaltraversalCodeupdateBackgroundModeupdateLayout

Field Detail

cssBackgroundback to summary
pack-priv String cssBackground

Hides org.eclipse.swt.widgets.Control.cssBackground.

cssForegroundback to summary
pack-priv String cssForeground

Hides org.eclipse.swt.widgets.Control.cssForeground.

currentFocusItemback to summary
pack-priv ToolItem currentFocusItem
hasChildFocusback to summary
pack-priv boolean hasChildFocus
imageListback to summary
pack-priv ImageList imageList
tabItemListback to summary
pack-priv ToolItem[] tabItemList

Constructor Detail

ToolBarback to summary
public ToolBar(Composite parent, int style)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters
parent:Composite

a composite control which will be the parent of the new instance (cannot be null)

style:int

the style of control to construct

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
See Also
SWT#FLAT, SWT#WRAP, SWT#RIGHT, SWT#HORIZONTAL, SWT#SHADOW_OUT, SWT#VERTICAL, Widget#checkSubclass(), Widget#getStyle()

Method Detail

_getItemsback to summary
pack-priv ToolItem[] _getItems()
_getTabItemListback to summary
pack-priv ToolItem[] _getTabItemList()
applyThemeBackgroundback to summary
pack-priv int applyThemeBackground()

Overrides org.eclipse.swt.widgets.Composite.applyThemeBackground.

Returns:int

Doc from org.eclipse.swt.widgets.Scrollable.applyThemeBackground.

  • 0 to remove THEME_BACKGROUND
  • 1 to apply THEME_BACKGROUND
  • otherwise don't change THEME_BACKGROUND state
  • Annotations
    @Override
    checkStyleback to summary
    pack-priv static int checkStyle(int style)

    Hides org.eclipse.swt.widgets.Composite.checkStyle.

    checkSubclassback to summary
    protected void checkSubclass()

    Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

    Doc from org.eclipse.swt.widgets.Widget.checkSubclass.

    Checks that this class can be subclassed.

    The SWT class library is intended to be subclassed only at specific, controlled points (most notably, Composite and Canvas when implementing new widgets). This method enforces this rule unless it is overridden.

    Important Note

    By providing an implementation of this method that allows a subclass of a class which does not normally allow subclassing to be created, the implementer agrees to be fully responsible for the fact that any such subclass will likely fail between SWT releases and will be strongly platform specific. No support is provided for user-written classes which are implemented in this fashion.

    The ability to subclass outside of the allowed SWT classes is intended purely to enable those not on the SWT development team to implement patches in order to get around specific limitations in advance of when those limitations can be addressed by the team. Subclassing should not be attempted without an intimate and detailed understanding of the hierarchy.

    Annotations
    @Override
    computeSizeInPixelsback to summary
    pack-priv Point computeSizeInPixels(int wHint, int hHint, boolean changed)

    Overrides org.eclipse.swt.widgets.Composite.computeSizeInPixels.

    Annotations
    @Override
    computeTabGroupback to summary
    pack-priv Widget computeTabGroup()

    Overrides org.eclipse.swt.widgets.Control.computeTabGroup.

    Annotations
    @Override
    computeTabListback to summary
    pack-priv Widget[] computeTabList()

    Overrides org.eclipse.swt.widgets.Composite.computeTabList.

    Annotations
    @Override
    createHandleback to summary
    pack-priv void createHandle(int index)

    Overrides org.eclipse.swt.widgets.Composite.createHandle.

    Annotations
    @Override
    enterExitHandleback to summary
    pack-priv long enterExitHandle()

    Overrides org.eclipse.swt.widgets.Control.enterExitHandle.

    Annotations
    @Override
    eventHandleback to summary
    pack-priv long eventHandle()

    Overrides org.eclipse.swt.widgets.Control.eventHandle.

    Annotations
    @Override
    forceFocusback to summary
    pack-priv boolean forceFocus(long focusHandle)

    Overrides org.eclipse.swt.widgets.Composite.forceFocus.

    Annotations
    @Override
    getItemback to summary
    public ToolItem getItem(int index)

    Returns the item at the given, zero-relative index in the receiver. Throws an exception if the index is out of range.

    Parameters
    index:int

    the index of the item to return

    Returns:ToolItem

    the item at the given index

    Exceptions
    IllegalArgumentException:
    • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
    SWTException:
    • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    getItemback to summary
    public ToolItem getItem(Point point)

    Returns the item at the given point in the receiver or null if no such item exists. The point is in the coordinate system of the receiver.

    Parameters
    point:Point

    the point used to locate the item

    Returns:ToolItem

    the item at the given point

    Exceptions
    IllegalArgumentException:
    • ERROR_NULL_ARGUMENT - if the point is null
    SWTException:
    • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    getItemCountback to summary
    public int getItemCount()

    Returns the number of items contained in the receiver.

    Returns:int

    the number of items

    Exceptions
    SWTException:
    • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    getItemInPixelsback to summary
    pack-priv ToolItem getItemInPixels(Point point)
    getItemsback to summary
    public ToolItem[] getItems()

    Returns an array of ToolItems which are the items in the receiver.

    Note

    This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.

    Returns:ToolItem[]

    the items in the receiver

    Exceptions
    SWTException:
    • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    getRowCountback to summary
    public int getRowCount()

    Returns the number of rows in the receiver. When the receiver has the WRAP style, the number of rows can be greater than one. Otherwise, the number of rows is always one.

    Returns:int

    the number of items

    Exceptions
    SWTException:
    • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    gtk_focusback to summary
    pack-priv long gtk_focus(long widget, long directionType)

    Overrides org.eclipse.swt.widgets.Composite.gtk_focus.

    Annotations
    @Override
    gtk_key_press_eventback to summary
    pack-priv long gtk_key_press_event(long widget, long eventPtr)

    Overrides org.eclipse.swt.widgets.Composite.gtk_key_press_event.

    Annotations
    @Override
    hasFocusback to summary
    pack-priv boolean hasFocus()

    Overrides org.eclipse.swt.widgets.Control.hasFocus.

    Annotations
    @Override
    indexOfback to summary
    public int indexOf(ToolItem item)

    Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. If no item is found, returns -1.

    Parameters
    item:ToolItem

    the search item

    Returns:int

    the index of the item

    Exceptions
    IllegalArgumentException:
    • ERROR_NULL_ARGUMENT - if the tool item is null
    • ERROR_INVALID_ARGUMENT - if the tool item has been disposed
    SWTException:
    • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
    • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    mnemonicHitback to summary
    pack-priv boolean mnemonicHit(char key)

    Overrides org.eclipse.swt.widgets.Control.mnemonicHit.

    Annotations
    @Override
    mnemonicMatchback to summary
    pack-priv boolean mnemonicMatch(char key)

    Overrides org.eclipse.swt.widgets.Control.mnemonicMatch.

    Annotations
    @Override
    relayoutback to summary
    pack-priv void relayout()
    releaseChildrenback to summary
    pack-priv void releaseChildren(boolean destroy)

    Overrides org.eclipse.swt.widgets.Composite.releaseChildren.

    Annotations
    @Override
    releaseWidgetback to summary
    pack-priv void releaseWidget()

    Overrides org.eclipse.swt.widgets.Composite.releaseWidget.

    Annotations
    @Override
    removeControlback to summary
    pack-priv void removeControl(Control control)

    Overrides org.eclipse.swt.widgets.Composite.removeControl.

    Annotations
    @Override
    reskinChildrenback to summary
    pack-priv void reskinChildren(int flags)

    Overrides org.eclipse.swt.widgets.Composite.reskinChildren.

    Annotations
    @Override
    setBackgroundGdkRGBAback to summary
    pack-priv void setBackgroundGdkRGBA(long context, long handle, GdkRGBA rgba)

    Overrides org.eclipse.swt.widgets.Control.setBackgroundGdkRGBA.

    Annotations
    @Override
    setBoundsback to summary
    pack-priv int setBounds(int x, int y, int width, int height, boolean move, boolean resize)

    Overrides org.eclipse.swt.widgets.Composite.setBounds.

    Annotations
    @Override
    setFontDescriptionback to summary
    pack-priv void setFontDescription(long font)

    Overrides org.eclipse.swt.widgets.Control.setFontDescription.

    Annotations
    @Override
    setForegroundGdkRGBAback to summary
    pack-priv void setForegroundGdkRGBA(long handle, GdkRGBA rgba)

    Overrides org.eclipse.swt.widgets.Control.setForegroundGdkRGBA.

    Annotations
    @Override
    setForegroundGdkRGBAback to summary
    pack-priv void setForegroundGdkRGBA(GdkRGBA rgba)

    Overrides org.eclipse.swt.widgets.Control.setForegroundGdkRGBA.

    Annotations
    @Override
    setOrientationback to summary
    pack-priv void setOrientation(boolean create)

    Overrides org.eclipse.swt.widgets.Composite.setOrientation.

    Annotations
    @Override
    setParentBackgroundback to summary
    pack-priv void setParentBackground()

    Overrides org.eclipse.swt.widgets.Control.setParentBackground.

    Annotations
    @Override
    setTabItemListback to summary
    pack-priv void setTabItemList(ToolItem[] tabList)
    setToolTipTextback to summary
    public void setToolTipText(String string)

    Overrides org.eclipse.swt.widgets.Control.setToolTipText.

    Doc from org.eclipse.swt.widgets.Control.setToolTipText.

    Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.

    The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.

    Note

    This operation is a hint and behavior is platform specific, on Windows for CJK-style mnemonics of the form " (&C)" at the end of the tooltip text are not shown in tooltip.

    Parameters
    string:String

    the new tool tip text (or null)

    Annotations
    @Override