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

public Class CoolBar

extends Composite
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.graphics.*

Instances of this class provide an area for dynamically positioning the items they contain.

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

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, HORIZONTAL, VERTICAL
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
CoolBar snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv Cursor
pack-priv static final int
pack-priv static final int
pack-priv Cursor
pack-priv CoolItem
pack-priv Cursor
pack-priv boolean
pack-priv boolean
pack-priv CoolItem[][]
pack-priv int
pack-priv int
pack-priv CoolItem[]
pack-priv static final int
Inherited from org.eclipse.swt.widgets.Composite:
backgroundModechildrenLoweredembeddedHandlefixClipHandlefixClipMapimHandlelayoutlayoutCountNO_INPUT_METHODnoChildDrawingpopupChildsocketHandletabList

Constructor Summary

AccessConstructor and Description
public
CoolBar(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 void
pack-priv static int
protected void
checkSubclass()

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

Checks that this class can be subclassed.
public Point
computeSize(int
the width hint (can be SWT.DEFAULT)
wHint
,
int
the height hint (can be SWT.DEFAULT)
hHint
,
boolean
true if the control's contents have changed, and false otherwise
changed
)

Overrides org.eclipse.swt.widgets.Control.computeSize.

Returns the preferred size (in points) of the receiver.
pack-priv void
createItem(CoolItem item, int index)

pack-priv void
pack-priv Point
pack-priv void
fixEvent(Event event)

pack-priv Point
fixPoint(int x, int y)

pack-priv Rectangle
fixRectangle(int x, int y, int width, int height)

pack-priv CoolItem
getGrabbedItem(int x, int y)

public CoolItem

Returns:

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

Returns the item that is currently displayed at the given, zero-relative index.

public int

Returns:

the number of items
getItemCount
()

Returns the number of items contained in the receiver.

public int[]

Returns:

the current visual order of the receiver's items
getItemOrder
()

Returns an array of zero-relative ints that map the creation order of the receiver's items to the order in which they are currently being displayed.

public CoolItem[]

Returns:

the receiver's items in their current visual order
getItems
()

Returns an array of CoolItems in the order in which they are currently being displayed.

public Point[]

Returns:

the receiver's item sizes in their current visual order
getItemSizes
()

Returns an array of points whose x and y coordinates describe the widths and heights (respectively) of the items in the receiver in the order in which they are currently being displayed.

public boolean

Returns:

true if the coolbar is locked, false otherwise
getLocked
()

Returns whether or not the receiver is 'locked'.

pack-priv int
public int[]

Returns:

an array containing the receiver's wrap indices, or an empty array if all items are in one row
getWrapIndices
()

Returns an array of ints that describe the zero-relative indices of any item(s) in the receiver that will begin on a new row.

public int

Returns:

the visual order index of the search item, or -1 if the item is not found
indexOf
(CoolItem
the search item
item
)

Searches the receiver's items in the order they are currently being displayed, 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
insertItemIntoRow(CoolItem item, int rowIndex, int x_root)

Insert the item into the row.

pack-priv void
internalRedraw(int x, int y, int width, int height)

pack-priv int
layoutItems()

Return the height of the bar after it has been properly laid out for the given width.

pack-priv void
moveDown(CoolItem item, int x_root)

pack-priv void
moveLeft(CoolItem item, int pixels)

pack-priv void
moveRight(CoolItem item, int pixels)

pack-priv void
moveUp(CoolItem item, int x_root)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
onPaint(Event event)

pack-priv void
pack-priv void
pack-priv void
pack-priv boolean
removeItemFromRow(CoolItem item, int rowIndex, boolean disposed)

Remove the item from the row.

pack-priv void
public void
setBackground(Color
the new color (or null)
color
)

Overrides org.eclipse.swt.widgets.Control.setBackground.

Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
public void
setCursor(Cursor
the new cursor (or null)
cursor
)

Overrides org.eclipse.swt.widgets.Control.setCursor.

Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.
public void
setItemLayout(int[]
an array of indices that describe the new order to display the items in
itemOrder
,
int[]
an array of wrap indices, or null
wrapIndices
,
Point[]
an array containing the new sizes for each of the receiver's items in visual order
sizes
)

Sets the receiver's item order, wrap indices, and item sizes all at once.

pack-priv void
setItemOrder(int[] itemOrder)

pack-priv void
public void
setLocked(boolean
lock the coolbar if true, otherwise unlock the coolbar
locked
)

Sets whether or not the receiver is 'locked'.

public void
setOrientation(int
new orientation style
orientation
)

Overrides org.eclipse.swt.widgets.Control.setOrientation.

Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
public void
setWrapIndices(int[]
an array of wrap indices, or null
indices
)

Sets the indices of all item(s) in the receiver that will begin on a new row.

pack-priv void
wrapItems(int maxWidth)

Inherited from org.eclipse.swt.widgets.Composite:
_getChildren_getTabListadjustChildClippingapplyThemeBackgroundchangedcheckBufferedcheckSubwindowcomputeSizeInPixelscomputeTabListconnectFixedHandleDrawcreateHandlecreateHandlederegisterdrawBackgrounddrawBackgroundInPixelsenableWidgetfindDeferredControlfindMenusfixChildrenfixClippingsfixModalfixParentGdkResourcefixStylefixTabListfixZOrderfocusHandleforceFocusgetBackgroundModegetChildrengetChildrenCountgetClientAreaInPixelsgetLayoutgetLayoutDeferredgetTabListgtk4_key_press_eventgtk_button_press_eventgtk_drawgtk_focusgtk_focus_in_eventgtk_focus_out_eventgtk_key_press_eventgtk_mapgtk_realizegtk_scroll_childgtk_style_updatedhasBorderhookEventshooksKeysimHandleisLayoutDeferredisTabGrouplayoutlayoutlayoutlayoutlayoutmarkLayoutminimumSizemoveAbovemoveBelowmoveChildrenmustBeVisibleOnInitBoundsparentingHandleprintWidgetpropagateDrawredrawChildrenregisterreleaseChildrenreleaseHandlereleaseWidgetresizeHandlesetBackgroundModesetBoundssetFocussetLayoutsetLayoutDeferredsetOrientationsetScrollBarVisiblesetTabGroupFocussetTabItemFocussetTabListshowWidgettoStringtranslateMnemonictranslateTraversaltraversalCodeupdateBackgroundModeupdateLayout

Field Detail

CLICK_DISTANCEback to summary
pack-priv static final int CLICK_DISTANCE
cursorback to summary
pack-priv Cursor cursor

Hides org.eclipse.swt.widgets.Control.cursor.

DEFAULT_COOLBAR_HEIGHTback to summary
pack-priv static final int DEFAULT_COOLBAR_HEIGHT
DEFAULT_COOLBAR_WIDTHback to summary
pack-priv static final int DEFAULT_COOLBAR_WIDTH
dragCursorback to summary
pack-priv Cursor dragCursor
draggingback to summary
pack-priv CoolItem dragging
hoverCursorback to summary
pack-priv Cursor hoverCursor
inDisposeback to summary
pack-priv boolean inDispose
isLockedback to summary
pack-priv boolean isLocked
itemsback to summary
pack-priv CoolItem[][] items
itemXOffsetback to summary
pack-priv int itemXOffset
mouseXOffsetback to summary
pack-priv int mouseXOffset
originalItemsback to summary
pack-priv CoolItem[] originalItems
ROW_SPACINGback to summary
pack-priv static final int ROW_SPACING

Constructor Detail

CoolBarback to summary
public CoolBar(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, SWT#FLAT, SWT#HORIZONTAL, SWT#VERTICAL, Widget#checkSubclass, Widget#getStyle

Method Detail

_setCursorback to summary
pack-priv void _setCursor(Cursor cursor)
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
computeSizeback to summary
public Point computeSize(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Control.computeSize.

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

Returns the preferred size (in points) of the receiver.

The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULT is passed for the hint.

If the changed flag is true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will be false, so layout manager caches can be retained.

Parameters
wHint:int

the width hint (can be SWT.DEFAULT)

hHint:int

the height hint (can be SWT.DEFAULT)

changed:boolean

true if the control's contents have changed, and false otherwise

Returns:Point

the preferred size of the control.

Annotations
@Override
createItemback to summary
pack-priv void createItem(CoolItem item, int index)
destroyItemback to summary
pack-priv void destroyItem(CoolItem item)
findItemback to summary
pack-priv Point findItem(CoolItem item)
fixEventback to summary
pack-priv void fixEvent(Event event)
fixPointback to summary
pack-priv Point fixPoint(int x, int y)
fixRectangleback to summary
pack-priv Rectangle fixRectangle(int x, int y, int width, int height)
getGrabbedItemback to summary
pack-priv CoolItem getGrabbedItem(int x, int y)
getItemback to summary
public CoolItem getItem(int index)

Returns the item that is currently displayed at the given, zero-relative index. Throws an exception if the index is out of range.

Parameters
index:int

the visual index of the item to return

Returns:CoolItem

the item at the given visual 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
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
getItemOrderback to summary
public int[] getItemOrder()

Returns an array of zero-relative ints that map the creation order of the receiver's items to the order in which they are currently being displayed.

Specifically, the indices of the returned array represent the current visual order of the items, and the contents of the array represent the creation order of the items.

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:int[]

the current visual order of the receiver's 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
getItemsback to summary
public CoolItem[] getItems()

Returns an array of CoolItems in the order in which they are currently being displayed.

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:CoolItem[]

the receiver's items in their current visual order

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
getItemSizesback to summary
public Point[] getItemSizes()

Returns an array of points whose x and y coordinates describe the widths and heights (respectively) of the items in the receiver in the order in which they are currently being displayed.

Returns:Point[]

the receiver's item sizes in their current visual order

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
getLockedback to summary
public boolean getLocked()

Returns whether or not the receiver is 'locked'. When a coolbar is locked, its items cannot be repositioned.

Returns:boolean

true if the coolbar is locked, false otherwise

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
Since
2.0
getWidthback to summary
pack-priv int getWidth()
getWrapIndicesback to summary
public int[] getWrapIndices()

Returns an array of ints that describe the zero-relative indices of any item(s) in the receiver that will begin on a new row. The 0th visible item always begins the first row, therefore it does not count as a wrap index.

Returns:int[]

an array containing the receiver's wrap indices, or an empty array if all items are in one row

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
indexOfback to summary
public int indexOf(CoolItem item)

Searches the receiver's items in the order they are currently being displayed, 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:CoolItem

the search item

Returns:int

the visual order index of the search item, or -1 if the item is not found

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the item is null
  • ERROR_INVALID_ARGUMENT - if the item is 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
insertItemIntoRowback to summary
pack-priv boolean insertItemIntoRow(CoolItem item, int rowIndex, int x_root)

Insert the item into the row. Adjust the x and width values appropriately.

internalRedrawback to summary
pack-priv void internalRedraw(int x, int y, int width, int height)
layoutItemsback to summary
pack-priv int layoutItems()

Return the height of the bar after it has been properly laid out for the given width.

moveDownback to summary
pack-priv void moveDown(CoolItem item, int x_root)
moveLeftback to summary
pack-priv void moveLeft(CoolItem item, int pixels)
moveRightback to summary
pack-priv void moveRight(CoolItem item, int pixels)
moveUpback to summary
pack-priv void moveUp(CoolItem item, int x_root)
onDisposeback to summary
pack-priv void onDispose(Event event)
onMouseDoubleClickback to summary
pack-priv void onMouseDoubleClick(Event event)
onMouseDownback to summary
pack-priv void onMouseDown(Event event)
onMouseExitback to summary
pack-priv void onMouseExit()
onMouseMoveback to summary
pack-priv void onMouseMove(Event event)
onMouseUpback to summary
pack-priv void onMouseUp(Event event)
onPaintback to summary
pack-priv void onPaint(Event event)
onResizeback to summary
pack-priv void onResize()
relayoutback to summary
pack-priv void relayout()
removeControlback to summary
pack-priv void removeControl(Control control)

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

Annotations
@Override
removeItemFromRowback to summary
pack-priv boolean removeItemFromRow(CoolItem item, int rowIndex, boolean disposed)

Remove the item from the row. Adjust the x and width values appropriately.

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

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

Annotations
@Override
setBackgroundback to summary
public void setBackground(Color color)

Overrides org.eclipse.swt.widgets.Control.setBackground.

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

Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Note

This operation is a hint and may be overridden by the platform.

Parameters
color:Color

the new color (or null)

Annotations
@Override
setCursorback to summary
public void setCursor(Cursor cursor)

Overrides org.eclipse.swt.widgets.Control.setCursor.

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

Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.

When the mouse pointer passes over a control its appearance is changed to match the control's cursor.

Parameters
cursor:Cursor

the new cursor (or null)

Annotations
@Override
setItemLayoutback to summary
public void setItemLayout(int[] itemOrder, int[] wrapIndices, Point[] sizes)

Sets the receiver's item order, wrap indices, and item sizes all at once. This method is typically used to restore the displayed state of the receiver to a previously stored state.

The item order is the order in which the items in the receiver should be displayed, given in terms of the zero-relative ordering of when the items were added.

The wrap indices are the indices of all item(s) in the receiver that will begin on a new row. The indices are given in the order specified by the item order. The 0th item always begins the first row, therefore it does not count as a wrap index. If wrap indices is null or empty, the items will be placed on one line.

The sizes are specified in an array of points whose x and y coordinates describe the new widths and heights (respectively) of the receiver's items in the order specified by the item order.

Parameters
itemOrder:int[]

an array of indices that describe the new order to display the items in

wrapIndices:int[]

an array of wrap indices, or null

sizes:Point[]

an array containing the new sizes for each of the receiver's items in visual order

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
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if item order or sizes is null
  • ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items
setItemOrderback to summary
pack-priv void setItemOrder(int[] itemOrder)
setItemSizesback to summary
pack-priv void setItemSizes(Point[] sizes)
setLockedback to summary
public void setLocked(boolean locked)

Sets whether or not the receiver is 'locked'. When a coolbar is locked, its items cannot be repositioned.

Parameters
locked:boolean

lock the coolbar if true, otherwise unlock the coolbar

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
Since
2.0
setOrientationback to summary
public void setOrientation(int orientation)

Overrides org.eclipse.swt.widgets.Control.setOrientation.

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

Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.

Parameters
orientation:int

new orientation style

Annotations
@Override
setWrapIndicesback to summary
public void setWrapIndices(int[] indices)

Sets the indices of all item(s) in the receiver that will begin on a new row. The indices are given in the order in which they are currently being displayed. The 0th item always begins the first row, therefore it does not count as a wrap index. If indices is null or empty, the items will be placed on one line.

Parameters
indices:int[]

an array of wrap indices, or null

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
wrapItemsback to summary
pack-priv void wrapItems(int maxWidth)