Class CoolItem
CoolBar
.
- Styles:
- DROP_DOWN
- Events:
- Selection
IMPORTANT: This class is not intended to be subclassed.
- See Also:
- Restriction:
- This class is not intended to be subclassed by clients.
-
Field Summary
Fields inherited from class org.eclipse.swt.widgets.Widget
nativeZoom
-
Constructor Summary
ConstructorDescriptionConstructs a new instance of this class given its parent (which must be aCoolBar
) and a style value describing its behavior and appearance.Constructs a new instance of this class given its parent (which must be aCoolBar
), 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 TypeMethodDescriptionvoid
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 theSelectionListener
interface.protected void
Checks that this class can be subclassed.computeSize
(int wHint, int hHint) Returns the preferred size of the receiver.Returns a rectangle describing the receiver's size and location relative to its parent.Returns the control that is associated with the receiver.Returns the minimum size that the cool item can be resized to using the cool item's gripper.Returns the receiver's parent, which must be aCoolBar
.Returns a point describing the receiver's ideal size.getSize()
Returns a point describing the receiver's size.void
removeSelectionListener
(SelectionListener listener) Removes the listener from the collection of listeners that will be notified when the control is selected by the user.void
setControl
(Control control) Sets the control that is associated with the receiver to the argument.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.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.void
setPreferredSize
(int width, int height) Sets the receiver's ideal size to the point specified by the arguments.void
setPreferredSize
(Point size) Sets the receiver's ideal size to the point specified by the argument.void
setSize
(int width, int height) Sets the receiver's size to the point specified by the arguments.void
Sets the receiver's size to the point specified by the argument.Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setData, toString
-
Constructor Details
-
CoolItem
Constructs a new instance of this class given its parent (which must be aCoolBar
) 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 theint
"|" operator) two or more of thoseSWT
style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent
- a composite control which will be the parent of the new instance (cannot be null)style
- the style of control to construct- Throws:
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:
-
CoolItem
Constructs a new instance of this class given its parent (which must be aCoolBar
), 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 theint
"|" operator) two or more of thoseSWT
style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent
- a composite control which will be the parent of the new instance (cannot be null)style
- the style of control to constructindex
- the zero-relative index at which to store the receiver in its parent- Throws:
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:
-
-
Method Details
-
addSelectionListener
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 theSelectionListener
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 valueSWT.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
- the listener which should be notified when the control is selected by the user- Throws:
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:
-
checkSubclass
protected void checkSubclass()Description copied from class:Widget
Checks that this class can be subclassed.The SWT class library is intended to be subclassed only at specific, controlled points (most notably,
Composite
andCanvas
when implementing new widgets). This method enforces this rule unless it is overridden.IMPORTANT: 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.
- Overrides:
checkSubclass
in classItem
-
computeSize
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 constantSWT.DEFAULT
is passed for the hint.- Parameters:
wHint
- the width hint (can beSWT.DEFAULT
)hHint
- the height hint (can beSWT.DEFAULT
)- Returns:
- the preferred size
- Throws:
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:
-
getBounds
Returns a rectangle describing the receiver's size and location relative to its parent.- Returns:
- the receiver's bounding rectangle
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getControl
Returns the control that is associated with the receiver.- Returns:
- the control that is contained by the receiver
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getParent
Returns the receiver's parent, which must be aCoolBar
.- Returns:
- the receiver's parent
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setControl
Sets the control that is associated with the receiver to the argument.- Parameters:
control
- the new control that will be contained by the receiver- Throws:
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
-
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:
- the receiver's ideal size
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setPreferredSize
public void setPreferredSize(int width, int height) Sets the receiver's ideal size to the point specified by the arguments.- Parameters:
width
- the new ideal width for the receiverheight
- the new ideal height for the receiver- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setPreferredSize
Sets the receiver's ideal size to the point specified by the argument.- Parameters:
size
- the new ideal size for the receiver- Throws:
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
-
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:
- the receiver's size
- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSize
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
- the new width for the receiverheight
- the new height for the receiver- Throws:
SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSize
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
- the new size for the receiver- Throws:
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
-
getMinimumSize
Returns the minimum size that the cool item can be resized to using the cool item's gripper.- Returns:
- a point containing the minimum width and height of the cool item, in SWT logical points
- Throws:
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
-
setMinimumSize
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
- the minimum width of the cool item, in SWT logical pointsheight
- the minimum height of the cool item, in SWT logical points- Throws:
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
-
setMinimumSize
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
- a point representing the minimum width and height of the cool item, in SWT logical points- Throws:
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
-
removeSelectionListener
Removes the listener from the collection of listeners that will be notified when the control is selected by the user.- Parameters:
listener
- the listener which should no longer be notified- Throws:
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:
-