|
org.eclipse.swt.widgets
Class Decorations
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.swt.widgets.Decorations
-
All Implemented Interfaces:
-
Drawable
-
Direct Known Subclasses:
-
Shell
-
public class Decorations
- extends
Canvas
Instances of this class provide the appearance and
behavior of Shells , but are not top
level shells or dialogs. Class Shell
shares a significant amount of code with this class,
and is a subclass.
IMPORTANT: This class was intended to be abstract and
should never be referenced or instantiated.
Instead, the class Shell should be used.
Instances are always displayed in one of the maximized,
minimized or normal states:
-
When an instance is marked as maximized, the
window manager will typically resize it to fill the
entire visible area of the display, and the instance
is usually put in a state where it can not be resized
(even if it has style
RESIZE ) until it is
no longer maximized.
-
When an instance is in the normal state (neither
maximized or minimized), its appearance is controlled by
the style constants which were specified when it was created
and the restrictions of the window manager (see below).
-
When an instance has been marked as minimized,
its contents (client area) will usually not be visible,
and depending on the window manager, it may be
"iconified" (that is, replaced on the desktop by a small
simplified representation of itself), relocated to a
distinguished area of the screen, or hidden. Combinations
of these changes are also possible.
Note: The styles supported by this class must be treated
as HINTs, since the window manager for the
desktop on which the instance is visible has ultimate
control over the appearance and behavior of decorations.
For example, some window managers only support resizable
windows and will always assume the RESIZE style, even if
it is not set.
-
Styles:
- BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL
-
Events:
- (none)
Class SWT provides two "convenience constants"
for the most commonly required style combinations:
-
SHELL_TRIM
-
the result of combining the constants which are required
to produce a typical application top level shell: (that
is,
CLOSE | TITLE | MIN | MAX | RESIZE )
-
DIALOG_TRIM
-
the result of combining the constants which are required
to produce a typical application dialog shell: (that
is,
TITLE | CLOSE | BORDER )
IMPORTANT: This class is intended to be subclassed only
within the SWT implementation.
-
See Also:
-
getMinimized() ,
getMaximized() ,
Shell ,
SWT ,
Sample code and further information
-
Restriction:
- This class is not intended to be subclassed by clients.
Fields inherited from class org.eclipse.swt.widgets.
Control
|
handle
|
Constructor Summary
|
Decorations
(
Composite parent,
int style)
Constructs a new instance of this class given its parent
and a style value describing its behavior and appearance. |
Method Summary
|
protected void
|
checkSubclass
()
Checks that this class can be subclassed. |
Rectangle
|
computeTrim
(int x,
int y,
int width,
int height)
Given a desired client area for the receiver
(as described by the arguments), returns the bounding
rectangle which would be required to produce that client
area. |
void
|
dispose
()
Disposes of the operating system resources associated with
the receiver and all its descendants. |
Rectangle
|
getBounds
()
Returns a rectangle describing the receiver's size and location
relative to its parent (or its display if its parent is null),
unless the receiver is a shell. |
Rectangle
|
getClientArea
()
Returns a rectangle which describes the area of the
receiver which is capable of displaying data (that is,
not covered by the "trimmings"). |
Button
|
getDefaultButton
()
Returns the receiver's default button if one had
previously been set, otherwise returns null. |
Image
|
getImage
()
Returns the receiver's image if it had previously been
set using setImage() . |
Image[]
|
getImages
()
Returns the receiver's images if they had previously been
set using setImages() . |
Point
|
getLocation
()
Returns a point describing the receiver's location relative
to its parent (or its display if its parent is null), unless
the receiver is a shell. |
boolean
|
getMaximized
()
Returns true if the receiver is currently
maximized, and false otherwise. |
Menu
|
getMenuBar
()
Returns the receiver's menu bar if one had previously
been set, otherwise returns null. |
boolean
|
getMinimized
()
Returns true if the receiver is currently
minimized, and false otherwise. |
Point
|
getSize
()
Returns a point describing the receiver's size. |
String
|
getText
()
Returns the receiver's text, which is the string that the
window manager will typically display as the receiver's
title. |
boolean
|
isReparentable
()
Returns true if the underlying operating
system supports this reparenting, otherwise false
|
void
|
setDefaultButton
(
Button button)
If the argument is not null, sets the receiver's default
button to the argument, and if the argument is null, sets
the receiver's default button to the first button which
was set as the receiver's default button (called the
saved default button). |
void
|
setImage
(
Image image)
Sets the receiver's image to the argument, which may
be null. |
void
|
setImages
(
Image[] images)
Sets the receiver's images to the argument, which may
be an empty array. |
void
|
setMaximized
(boolean maximized)
Sets the maximized state of the receiver. |
void
|
setMenuBar
(
Menu menu)
Sets the receiver's menu bar to the argument, which
may be null. |
void
|
setMinimized
(boolean minimized)
Sets the minimized stated of the receiver. |
void
|
setText
(
String string)
Sets the receiver's text, which is the string that the
window manager will typically display as the receiver's
title, to the argument, which must not be null. |
void
|
setVisible
(boolean visible)
Marks the receiver as visible if the argument is true ,
and marks it invisible otherwise. |
Methods inherited from class org.eclipse.swt.widgets.
Composite
|
changed,
computeSize,
getBackgroundMode,
getChildren,
getLayout,
getLayoutDeferred,
getTabList,
isLayoutDeferred,
layout,
layout,
layout,
layout,
setBackgroundMode,
setFocus,
setLayout,
setLayoutDeferred,
setTabList
|
Methods inherited from class org.eclipse.swt.widgets.
Control
|
addControlListener,
addDragDetectListener,
addFocusListener,
addHelpListener,
addKeyListener,
addMenuDetectListener,
addMouseListener,
addMouseMoveListener,
addMouseTrackListener,
addMouseWheelListener,
addPaintListener,
addTraverseListener,
computeSize,
dragDetect,
dragDetect,
forceFocus,
getAccessible,
getBackground,
getBackgroundImage,
getBorderWidth,
getCursor,
getDragDetect,
getEnabled,
getFont,
getForeground,
getLayoutData,
getMenu,
getMonitor,
getParent,
getRegion,
getShell,
getToolTipText,
getVisible,
internal_dispose_GC,
internal_new_GC,
isEnabled,
isFocusControl,
isVisible,
moveAbove,
moveBelow,
pack,
pack,
print,
redraw,
redraw,
removeControlListener,
removeDragDetectListener,
removeFocusListener,
removeHelpListener,
removeKeyListener,
removeMenuDetectListener,
removeMouseListener,
removeMouseMoveListener,
removeMouseTrackListener,
removeMouseWheelListener,
removePaintListener,
removeTraverseListener,
setBackground,
setBackgroundImage,
setBounds,
setBounds,
setCapture,
setCursor,
setDragDetect,
setEnabled,
setForeground,
setLayoutData,
setLocation,
setLocation,
setMenu,
setParent,
setRedraw,
setRegion,
setSize,
setSize,
setToolTipText,
toControl,
toControl,
toDisplay,
toDisplay,
traverse,
update
|
Methods inherited from class org.eclipse.swt.widgets.
Widget
|
addDisposeListener,
addListener,
checkWidget,
getData,
getData,
getDisplay,
getListeners,
getStyle,
isDisposed,
isListening,
notifyListeners,
removeDisposeListener,
removeListener,
removeListener,
setData,
setData,
toString
|
Decorations
public Decorations(
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 - 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:
-
SWT.BORDER ,
SWT.CLOSE ,
SWT.MIN ,
SWT.MAX ,
SWT.RESIZE ,
SWT.TITLE ,
SWT.NO_TRIM ,
SWT.SHELL_TRIM ,
SWT.DIALOG_TRIM ,
SWT.ON_TOP ,
SWT.TOOL ,
Widget.checkSubclass() ,
Widget.getStyle()
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 and Canvas 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 class
Composite
-
computeTrim
public
Rectangle computeTrim(int x,
int y,
int width,
int height)
-
Description copied from class:
Scrollable
- Given a desired client area for the receiver
(as described by the arguments), returns the bounding
rectangle which would be required to produce that client
area.
In other words, it returns a rectangle such that, if the
receiver's bounds were set to that rectangle, the area
of the receiver which is capable of displaying data
(that is, not covered by the "trimmings") would be the
rectangle described by the arguments (relative to the
receiver's parent).
-
-
Overrides:
-
computeTrim
in class
Scrollable
-
-
Parameters:
-
x - the desired x coordinate of the client area -
y - the desired y coordinate of the client area -
width - the desired width of the client area -
height - the desired height of the client area
-
Returns:
- the required bounds to produce the given client area
-
See Also:
-
Scrollable.getClientArea()
dispose
public void dispose()
-
Description copied from class:
Widget
- 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.
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.
-
-
Overrides:
-
dispose
in class
Widget
-
-
See Also:
-
Widget.addDisposeListener(org.eclipse.swt.events.DisposeListener) ,
Widget.removeDisposeListener(org.eclipse.swt.events.DisposeListener) ,
Widget.checkWidget()
getBounds
public
Rectangle getBounds()
-
Description copied from class:
Control
- Returns a rectangle describing the receiver's size and location
relative to its parent (or its display if its parent is null),
unless the receiver is a shell. In this case, the location is
relative to the display.
-
-
Overrides:
-
getBounds
in class
Control
-
-
Returns:
- the receiver's bounding rectangle
getClientArea
public
Rectangle getClientArea()
-
Description copied from class:
Scrollable
- Returns a rectangle which describes the area of the
receiver which is capable of displaying data (that is,
not covered by the "trimmings").
-
-
Overrides:
-
getClientArea
in class
Scrollable
-
-
Returns:
- the client area
-
See Also:
-
Scrollable.computeTrim(int, int, int, int)
getDefaultButton
public
Button getDefaultButton()
- Returns the receiver's default button if one had
previously been set, otherwise returns null.
-
-
Returns:
- the default button or null
-
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:
-
setDefaultButton(Button)
getImage
public
Image getImage()
- Returns the receiver's image if it had previously been
set using
setImage() . The image is typically
displayed by the window manager when the instance is
marked as iconified, and may also be displayed somewhere
in the trim when the instance is in normal or maximized
states.
Note: This method will return null if called before
setImage() is called. It does not provide
access to a window manager provided, "default" image
even if one exists.
-
-
Returns:
- the image
-
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
getImages
public
Image[] getImages()
- Returns the receiver's images if they had previously been
set using
setImages() . Images are typically
displayed by the window manager when the instance is
marked as iconified, and may also be displayed somewhere
in the trim when the instance is in normal or maximized
states. Depending where the icon is displayed, the platform
chooses the icon with the "best" attributes. It is expected
that the array will contain the same icon rendered at different
sizes, with different depth and transparency attributes.
Note: This method will return an empty array if called before
setImages() is called. It does not provide
access to a window manager provided, "default" image
even if one exists.
-
-
Returns:
- the images
-
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:
- 3.0
getLocation
public
Point getLocation()
-
Description copied from class:
Control
- Returns a point describing the receiver's location relative
to its parent (or its display if its parent is null), unless
the receiver is a shell. In this case, the point is
relative to the display.
-
-
Overrides:
-
getLocation
in class
Control
-
-
Returns:
- the receiver's location
getMaximized
public boolean getMaximized()
- Returns
true if the receiver is currently
maximized, and false otherwise.
-
-
Returns:
- the maximized state
-
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:
-
setMaximized(boolean)
getMenuBar
public
Menu getMenuBar()
- Returns the receiver's menu bar if one had previously
been set, otherwise returns null.
-
-
Returns:
- the menu bar or null
-
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
getMinimized
public boolean getMinimized()
- Returns
true if the receiver is currently
minimized, and false otherwise.
-
-
Returns:
- the minimized state
-
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:
-
setMinimized(boolean)
getSize
public
Point getSize()
-
Description copied from class:
Control
- 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.
-
-
Overrides:
-
getSize
in class
Control
-
-
Returns:
- the receiver's size
getText
public
String getText()
- Returns the receiver's text, which is the string that the
window manager will typically display as the receiver's
title. If the text has not previously been set,
returns an empty string.
-
-
Returns:
- the text
-
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
isReparentable
public boolean isReparentable()
-
Description copied from class:
Control
- Returns
true if the underlying operating
system supports this reparenting, otherwise false
-
-
Overrides:
-
isReparentable
in class
Control
-
-
Returns:
-
true if the widget can be reparented, otherwise false
setDefaultButton
public void setDefaultButton(
Button button)
- If the argument is not null, sets the receiver's default
button to the argument, and if the argument is null, sets
the receiver's default button to the first button which
was set as the receiver's default button (called the
saved default button). If no default button had
previously been set, or the saved default button was
disposed, the receiver's default button will be set to
null.
The default button is the button that is selected when
the receiver is active and the user presses ENTER.
-
-
Parameters:
-
button - the new default button
-
Throws:
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT - if the button 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
setImage
public void setImage(
Image image)
- Sets the receiver's image to the argument, which may
be null. The image is typically displayed by the window
manager when the instance is marked as iconified, and
may also be displayed somewhere in the trim when the
instance is in normal or maximized states.
-
-
Parameters:
-
image - the new image (or null)
-
Throws:
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT - if the image 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
setImages
public void setImages(
Image[] images)
- Sets the receiver's images to the argument, which may
be an empty array. Images are typically displayed by the
window manager when the instance is marked as iconified,
and may also be displayed somewhere in the trim when the
instance is in normal or maximized states. Depending where
the icon is displayed, the platform chooses the icon with
the "best" attributes. It is expected that the array will
contain the same icon rendered at different sizes, with
different depth and transparency attributes.
-
-
Parameters:
-
images - the new image array
-
Throws:
-
IllegalArgumentException
-
- ERROR_NULL_ARGUMENT - if the array of images is null
- ERROR_INVALID_ARGUMENT - if one of the images is null or 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
-
Since:
- 3.0
setMaximized
public void setMaximized(boolean maximized)
- Sets the maximized state of the receiver.
If the argument is
true causes the receiver
to switch to the maximized state, and if the argument is
false and the receiver was previously maximized,
causes the receiver to switch back to either the minimized
or normal states.
Note: The result of intermixing calls to setMaximized(true)
and setMinimized(true) will vary by platform. Typically,
the behavior will match the platform user's expectations, but not
always. This should be avoided if possible.
-
-
Parameters:
-
maximized - the new maximized state
-
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:
-
setMinimized(boolean)
setMenuBar
public void setMenuBar(
Menu menu)
- Sets the receiver's menu bar to the argument, which
may be null.
-
-
Parameters:
-
menu - the new menu bar
-
Throws:
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT - if the menu has been disposed
- ERROR_INVALID_PARENT - if the menu 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
setMinimized
public void setMinimized(boolean minimized)
- Sets the minimized stated of the receiver.
If the argument is
true causes the receiver
to switch to the minimized state, and if the argument is
false and the receiver was previously minimized,
causes the receiver to switch back to either the maximized
or normal states.
Note: The result of intermixing calls to setMaximized(true)
and setMinimized(true) will vary by platform. Typically,
the behavior will match the platform user's expectations, but not
always. This should be avoided if possible.
-
-
Parameters:
-
minimized - the new maximized state
-
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:
-
setMaximized(boolean)
setText
public void setText(
String string)
- Sets the receiver's text, which is the string that the
window manager will typically display as the receiver's
title, to the argument, which must not be null.
-
-
Parameters:
-
string - the new text
-
Throws:
-
IllegalArgumentException
-
- ERROR_NULL_ARGUMENT - if the text 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
setVisible
public void setVisible(boolean visible)
-
Description copied from class:
Control
- Marks the receiver as visible if the argument is
true ,
and marks it invisible otherwise.
If one of the receiver's ancestors is not visible or some
other condition makes the receiver not visible, marking
it visible may not actually cause it to be displayed.
-
-
Overrides:
-
setVisible
in class
Control
-
-
Parameters:
-
visible - the new visibility state
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.
|
|