public class ExpandableComposite extends Canvas
The widget can be instantiated as-is, or subclassed to modify some aspects of it.
Since 3.1, left/right arrow keys can be used to control the expansion state. If several expandable composites are created in the same parent, up/down arrow keys can be used to traverse between them. Expandable text accepts mnemonics and mnemonic activation will toggle the expansion state.
Section
Modifier and Type | Field and Description |
---|---|
static int |
CLIENT_INDENT
If this style is used, the client origin will be vertically aligned with
the title text.
|
int |
clientVerticalSpacing
Vertical spacing between the title area and the composite client control
(default is 3).
|
static int |
COMPACT
If this style is used, computed size of the composite will take the
client width into consideration only in the expanded state.
|
static int |
EXPANDED
If this style is used, the control will be created in the expanded state.
|
static int |
FOCUS_TITLE
If this style is used, the title text will be rendered as a hyperlink
that can individually accept focus.
|
protected int |
GAP |
static int |
LEFT_TEXT_CLIENT_ALIGNMENT
By default, text client is right-aligned.
|
int |
marginHeight
Height of the margin that will be added around the control (default is
0).
|
int |
marginWidth
Width of the margin that will be added around the control (default is 0).
|
static int |
NO_TITLE
If this style is used, title will not be rendered.
|
static int |
SHORT_TITLE_BAR
If this style is used, a short version of the title bar decoration will
be painted behind the text.
|
protected Control |
textLabel |
static int |
TITLE_BAR
If this style is used, title bar decoration will be painted behind the
text.
|
protected ToggleHyperlink |
toggle |
static int |
TREE_NODE
If this style is used, a tree node with either + or - signs will be used
to render the expansion toggle.
|
static int |
TWISTIE
If this style is used, a twistie will be used to render the expansion
toggle.
|
Constructor and Description |
---|
ExpandableComposite(Composite parent,
int style)
Creates an expandable composite using a TWISTIE toggle.
|
ExpandableComposite(Composite parent,
int style,
int expansionStyle)
Creates the expandable composite in the provided parent.
|
Modifier and Type | Method and Description |
---|---|
void |
addExpansionListener(IExpansionListener listener)
Adds the listener that will be notified when the expansion state changes.
|
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Computes the size of the expandable composite.
|
Control |
getClient()
Returns the current expandable client.
|
protected Control |
getDescriptionControl()
Returns description control that will be placed under the title if
present.
|
int |
getExpansionStyle()
Returns the bitwise-ORed style bits for the expansion control.
|
protected Control |
getSeparatorControl()
Returns the separator control that will be placed between the title and
the description if present.
|
String |
getText()
Returns the title string.
|
Control |
getTextClient()
Returns the text client control.
|
Color |
getTitleBarForeground()
Returns the title bar foreground when TITLE_BAR style is used.
|
protected boolean |
hasTitleBar() |
protected void |
internalSetExpanded(boolean expanded)
Performs the expansion state change for the expandable control.
|
boolean |
isExpanded()
Tests the expanded state of the composite.
|
protected boolean |
isFixedStyle()
Returns true if the composite is fixed i.e. cannot be
expanded or collapsed.
|
protected void |
onPaint(PaintEvent e)
If TITLE_BAR or SHORT_TITLE_BAR style is used, title bar decoration will
be painted behind the text in this method.
|
void |
removeExpansionListener(IExpansionListener listener)
Removes the expansion listener.
|
void |
setActiveToggleColor(Color c)
Sets the active color of the toggle control (when the mouse enters the
toggle area).
|
void |
setBackground(Color bg)
Sets the background of all the custom controls in the expandable.
|
void |
setClient(Control client)
Sets the client of this expandable composite.
|
void |
setExpanded(boolean expanded)
Programmatically changes expanded state.
|
void |
setFont(Font font)
Sets the fonts of all the custom controls in the expandable.
|
void |
setForeground(Color fg)
Sets the foreground of all the custom controls in the expandable.
|
void |
setLayout(Layout layout)
Prevents assignment of the layout manager - expandable composite uses its
own layout.
|
void |
setMenu(Menu menu)
Overrides 'super' to pass the menu to the text label.
|
void |
setText(String title)
Sets the title of the expandable composite.
|
void |
setTextClient(Control textClient)
Sets the text client control.
|
void |
setTitleBarForeground(Color color)
Sets the color of the title bar foreground when TITLE_BAR style is used.
|
void |
setToggleColor(Color c)
Sets the color of the toggle control.
|
drawBackground, getCaret, scroll, setCaret
changed, checkSubclass, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, setLayoutData, setLocation, setLocation, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
public static final int TWISTIE
public static final int TREE_NODE
public static final int FOCUS_TITLE
public static final int CLIENT_INDENT
public static final int COMPACT
public static final int EXPANDED
public static final int TITLE_BAR
public static final int SHORT_TITLE_BAR
public static final int NO_TITLE
public static final int LEFT_TEXT_CLIENT_ALIGNMENT
public int marginWidth
public int marginHeight
public int clientVerticalSpacing
protected int GAP
protected ToggleHyperlink toggle
protected Control textLabel
public ExpandableComposite(Composite parent, int style)
parent
- the parent compositestyle
- SWT style bitspublic ExpandableComposite(Composite parent, int style, int expansionStyle)
parent
- the parentstyle
- the control styleexpansionStyle
- the style of the expansion widget (TREE_NODE, TWISTIE,
CLIENT_INDENT, COMPACT, FOCUS_TITLE)public void setMenu(Menu menu)
public final void setLayout(Layout layout)
public void setBackground(Color bg)
setBackground
in class Control
bg
- the new color (or null)public void setForeground(Color fg)
setForeground
in class Control
fg
- the new color (or null)public void setToggleColor(Color c)
c
- the color objectpublic void setActiveToggleColor(Color c)
c
- the active color objectpublic void setFont(Font font)
public void setClient(Control client)
client
- the client that will be expanded or collapsedpublic Control getClient()
public void setText(String title)
title
- the new title stringgetText()
public String getText()
setText(String)
public boolean isExpanded()
public int getExpansionStyle()
public void setExpanded(boolean expanded)
expanded
- the new expanded stateprotected void internalSetExpanded(boolean expanded)
expanded
- the expansion statepublic void addExpansionListener(IExpansionListener listener)
listener
- the listener to addpublic void removeExpansionListener(IExpansionListener listener)
listener
- the listner to removeprotected void onPaint(PaintEvent e)
e
- the paint eventprotected Control getDescriptionControl()
protected Control getSeparatorControl()
public Point computeSize(int wHint, int hHint, boolean changed)
computeSize
in class Composite
wHint
- the width hint (can be SWT.DEFAULT
)hHint
- the height hint (can be SWT.DEFAULT
)changed
- true
if the control's contents have changed, and false
otherwiseComposite.computeSize(int, int, boolean)
protected boolean isFixedStyle()
public Control getTextClient()
null
if not.public void setTextClient(Control textClient)
textClient
- the textClient to set or null
if not needed any
more.protected boolean hasTitleBar()
public void setTitleBarForeground(Color color)
color
- the title bar foregroundpublic Color getTitleBarForeground()
Guidelines for using Eclipse APIs. Copyright (c) IBM Corp. and others 2000, 2006. All rights reserved.