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

public Class CoolItem

extends Item
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*

Instances of this class are selectable user interface objects that represent the dynamically positionable areas of a CoolBar.
Styles:
DROP_DOWN
Events:
Selection

Important Note

This class is not intended to be subclassed.

See Also
Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv Image
pack-priv ToolBar
private int
private static final int
private static final int
private int
pack-priv Control
pack-priv static final int
pack-priv boolean
pack-priv Rectangle
pack-priv static final int
pack-priv static final int
pack-priv int
pack-priv int
pack-priv CoolBar
pack-priv int
pack-priv int
pack-priv int
pack-priv boolean
Inherited from org.eclipse.swt.widgets.Item:
ELLIPSISimagetextTEXT_LIMIT

Constructor Summary

AccessConstructor and Description
public
CoolItem(CoolBar
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 (which must be a CoolBar) and a style value describing its behavior and appearance.

public
CoolItem(CoolBar
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
,
int
the zero-relative index at which to store the receiver in its parent
index
)

Constructs a new instance of this class given its parent (which must be a CoolBar), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.

Method Summary

Modifier and TypeMethod and Description
public void
addSelectionListener(SelectionListener
the listener which should be notified when the control is selected by the user
listener
)

Adds the listener to the collection of listeners that will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

pack-priv void
protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Item.checkSubclass.

Checks that this class can be subclassed.
public Point

Returns:

the preferred size
computeSize
(int
the width hint (can be SWT.DEFAULT)
wHint
,
int
the height hint (can be SWT.DEFAULT)
hHint
)

Returns the preferred size of the receiver.

pack-priv Image
createArrowImage(int width, int height)

public void
dispose()

Overrides org.eclipse.swt.widgets.Widget.dispose.

Disposes of the operating system resources associated with the receiver and all its descendants.
public Rectangle

Returns:

the receiver's bounding rectangle
getBounds
()

Returns a rectangle describing the receiver's size and location relative to its parent.

public Control

Returns:

the control that is contained by the receiver
getControl
()

Returns the control that is associated with the receiver.

public Point

Returns:

a point containing the minimum width and height of the cool item, in SWT logical points
getMinimumSize
()

Returns the minimum size that the cool item can be resized to using the cool item's gripper.

public CoolBar

Returns:

the receiver's parent
getParent
()

Returns the receiver's parent, which must be a CoolBar.

public Point

Returns:

the receiver's ideal size
getPreferredSize
()

Returns a point describing the receiver's ideal size.

public Point

Returns:

the receiver's size
getSize
()

Returns a point describing the receiver's size.

pack-priv Rectangle
pack-priv int
pack-priv void
public void
removeSelectionListener(SelectionListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners that will be notified when the control is selected by the user.

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

public void
setControl(Control
the new control that will be contained by the receiver
control
)

Sets the control that is associated with the receiver to the argument.

public void
setMinimumSize(int
the minimum width of the cool item, in SWT logical points
width
,
int
the minimum height of the cool item, in SWT logical points
height
)

Sets the minimum size that the cool item can be resized to using the cool item's gripper, to the point specified by the arguments.

public void
setMinimumSize(Point
a point representing the minimum width and height of the cool item, in SWT logical points
size
)

Sets the minimum size that the cool item can be resized to using the cool item's gripper, to the point specified by the argument.

public void
setPreferredSize(int
the new ideal width for the receiver
width
,
int
the new ideal height for the receiver
height
)

Sets the receiver's ideal size to the point specified by the arguments.

public void
setPreferredSize(Point
the new ideal size for the receiver
size
)

Sets the receiver's ideal size to the point specified by the argument.

public void
setSize(int
the new width for the receiver
width
,
int
the new height for the receiver
height
)

Sets the receiver's size to the point specified by the arguments.

public void
setSize(Point
the new size for the receiver
size
)

Sets the receiver's size to the point specified by the argument.

pack-priv void
Inherited from org.eclipse.swt.widgets.Item:
getImagegetNameTextgetTextreleaseWidgetsetImagesetTextupdateTextDirection

Field Detail

arrowImageback to summary
pack-priv Image arrowImage
chevronback to summary
pack-priv ToolBar chevron
CHEVRON_HORIZONTAL_TRIMback to summary
private int CHEVRON_HORIZONTAL_TRIM
CHEVRON_IMAGE_WIDTHback to summary
private static final int CHEVRON_IMAGE_WIDTH
CHEVRON_LEFT_MARGINback to summary
private static final int CHEVRON_LEFT_MARGIN
CHEVRON_VERTICAL_TRIMback to summary
private int CHEVRON_VERTICAL_TRIM
controlback to summary
pack-priv Control control
GRABBER_WIDTHback to summary
pack-priv static final int GRABBER_WIDTH
idealback to summary
pack-priv boolean ideal
itemBoundsback to summary
pack-priv Rectangle itemBounds
MARGIN_WIDTHback to summary
pack-priv static final int MARGIN_WIDTH
MINIMUM_WIDTHback to summary
pack-priv static final int MINIMUM_WIDTH
minimumHeightback to summary
pack-priv int minimumHeight
minimumWidthback to summary
pack-priv int minimumWidth
parentback to summary
pack-priv CoolBar parent
preferredHeightback to summary
pack-priv int preferredHeight
preferredWidthback to summary
pack-priv int preferredWidth
requestedWidthback to summary
pack-priv int requestedWidth
wrapback to summary
pack-priv boolean wrap

Constructor Detail

CoolItemback to summary
public CoolItem(CoolBar parent, int style)

Constructs a new instance of this class given its parent (which must be a CoolBar) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.

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:CoolBar

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#DROP_DOWN, Widget#checkSubclass, Widget#getStyle
CoolItemback to summary
public CoolItem(CoolBar parent, int style, int index)

Constructs a new instance of this class given its parent (which must be a CoolBar), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.

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:CoolBar

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

style:int

the style of control to construct

index:int

the zero-relative index at which to store the receiver in its parent

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
  • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)
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#DROP_DOWN, Widget#checkSubclass, Widget#getStyle

Method Detail

addSelectionListenerback to summary
public void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners that will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

If widgetSelected is called when the mouse is over the drop-down arrow (or 'chevron') portion of the cool item, the event object detail field contains the value SWT.ARROW, and the x and y fields in the event object represent the point at the bottom left of the chevron, where the menu should be popped up. widgetDefaultSelected is not called.

Parameters
listener:SelectionListener

the listener which should be notified when the control is selected by the user

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener 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
Since
2.0
See Also
SelectionListener, removeSelectionListener, SelectionEvent
calculateChevronTrimback to summary
pack-priv void calculateChevronTrim()
checkSubclassback to summary
protected void checkSubclass()

Overrides org.eclipse.swt.widgets.Item.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)

Returns the preferred size of the receiver.

The preferred size of a CoolItem is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask the instance questions such as "Given a particular width, how high does it 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.

Parameters
wHint:int

the width hint (can be SWT.DEFAULT)

hHint:int

the height hint (can be SWT.DEFAULT)

Returns:Point

the preferred size

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
See Also
Layout, getBounds, getSize, Control#getBorderWidth, Scrollable#computeTrim, Scrollable#getClientArea
createArrowImageback to summary
pack-priv Image createArrowImage(int width, int height)
disposeback to summary
public void dispose()

Overrides org.eclipse.swt.widgets.Widget.dispose.

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

Disposes of the operating system resources associated with the receiver and all its descendants. After this method has been invoked, the receiver and all descendants will answer true when sent the message isDisposed(). Any internal connections between the widgets in the tree will have been removed to facilitate garbage collection. This method does nothing if the widget is already disposed.

Note

This method is not called recursively on the descendants of the receiver. This means that, widget implementers can not detect when a widget is being disposed of by re-implementing this method, but should instead listen for the Dispose event.

Annotations
@Override
getBoundsback to summary
public Rectangle getBounds()

Returns a rectangle describing the receiver's size and location relative to its parent.

Returns:Rectangle

the receiver's bounding rectangle

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
getControlback to summary
public Control getControl()

Returns the control that is associated with the receiver.

Returns:Control

the control that is contained by 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
getMinimumSizeback to summary
public Point getMinimumSize()

Returns the minimum size that the cool item can be resized to using the cool item's gripper.

Returns:Point

a point containing the minimum width and height of the cool item, in SWT logical points

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
getParentback to summary
public CoolBar getParent()

Returns the receiver's parent, which must be a CoolBar.

Returns:CoolBar

the receiver's parent

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
getPreferredSizeback to summary
public Point getPreferredSize()

Returns a point describing the receiver's ideal size. The x coordinate of the result is the ideal width of the receiver. The y coordinate of the result is the ideal height of the receiver.

Returns:Point

the receiver's ideal size

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
getSizeback to summary
public Point getSize()

Returns a point describing the receiver's size. The x coordinate of the result is the width of the receiver. The y coordinate of the result is the height of the receiver.

Returns:Point

the receiver's size

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
internalGetBoundsback to summary
pack-priv Rectangle internalGetBounds()
internalGetMinimumWidthback to summary
pack-priv int internalGetMinimumWidth()
onSelectionback to summary
pack-priv void onSelection(Event ev)
removeSelectionListenerback to summary
public void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners that will be notified when the control is selected by the user.

Parameters
listener:SelectionListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener 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
Since
2.0
See Also
SelectionListener, addSelectionListener
setBoundsback to summary
pack-priv void setBounds(int x, int y, int width, int height)
setControlback to summary
public void setControl(Control control)

Sets the control that is associated with the receiver to the argument.

Parameters
control:Control

the new control that will be contained by the receiver

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the control has been disposed
  • ERROR_INVALID_PARENT - if the control is not in the same widget tree
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setMinimumSizeback to summary
public void setMinimumSize(int width, int height)

Sets the minimum size that the cool item can be resized to using the cool item's gripper, to the point specified by the arguments.

Parameters
width:int

the minimum width of the cool item, in SWT logical points

height:int

the minimum height of the cool item, in SWT logical points

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
setMinimumSizeback to summary
public void setMinimumSize(Point size)

Sets the minimum size that the cool item can be resized to using the cool item's gripper, to the point specified by the argument.

Parameters
size:Point

a point representing the minimum width and height of the cool item, in SWT logical points

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
Since
2.0
setPreferredSizeback to summary
public void setPreferredSize(int width, int height)

Sets the receiver's ideal size to the point specified by the arguments.

Parameters
width:int

the new ideal width for the receiver

height:int

the new ideal height for 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
setPreferredSizeback to summary
public void setPreferredSize(Point size)

Sets the receiver's ideal size to the point specified by the argument.

Parameters
size:Point

the new ideal size for the receiver

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
setSizeback to summary
public void setSize(int width, int height)

Sets the receiver's size to the point specified by the arguments.

Note

Attempting to set the width or height of the receiver to a negative number will cause that value to be set to zero instead.

Parameters
width:int

the new width for the receiver

height:int

the new height for 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
setSizeback to summary
public void setSize(Point size)

Sets the receiver's size to the point specified by the argument.

Note

Attempting to set the width or height of the receiver to a negative number will cause them to be set to zero instead.

Parameters
size:Point

the new size for the receiver

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
updateChevronback to summary
pack-priv void updateChevron()