Package com.biglybt.ui.swt.twistie
Class TwistieLabel
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
com.biglybt.ui.swt.twistie.TwistieLabel
- All Implemented Interfaces:
ITwistieConstants
,org.eclipse.swt.graphics.Drawable
A Label with a twistie graphic at the beginning; every time this label is clicked the
twistie graphic toggles between pointing to the right and pointing down.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
A listener that intercepts mouseDown events from the control and the title label so we can fire a single event to the listener to signal that the control has been collapsed or expanded. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.eclipse.swt.widgets.Label
An optional Label to display the descriptionprivate boolean
The state of the control; callers can check this state by callingisCollapsed()
private List
(package private) static final int[]
An array of points for a triangle pointing to the right(package private) static final int[]
An array of points for a triangle pointing downwardprivate int
private org.eclipse.swt.widgets.Label
Label
to display the text for this twistieprivate org.eclipse.swt.graphics.Color
TheColor
to use for the twistie graphic itself; defaults to the same as the foreground color of the titleLabelFields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
Fields inherited from interface com.biglybt.ui.swt.twistie.ITwistieConstants
NONE, SHOW_DESCRIPTION, SHOW_EXPANDED, SHOW_SEPARATOR
-
Constructor Summary
ConstructorsConstructorDescriptionTwistieLabel
(org.eclipse.swt.widgets.Composite parent, int style) Create a twistie Label with the given style bit. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMouseListener
(org.eclipse.swt.events.MouseListener listener) Add a mouse listener to the control and also thetitleLabel
void
addTwistieListener
(ITwistieListener listener) Add a listener to be notified whenever this control is collapsed or expanded; listeners can check the collapsed/expanded state on the control and perform layout changes if need be.boolean
Returns whether this control is in a collapsed stateprivate void
void
removeMouseListener
(org.eclipse.swt.events.MouseListener listener) Remove the mouse listener from the control and also thetitleLabel
void
removeTwistieListener
(ITwistieListener listener) void
setBackground
(org.eclipse.swt.graphics.Color color) Sets the background color for the control and also all the text-base childrenvoid
setCollapsed
(boolean c) void
setDescription
(String string) Sets the text to display as the description; this is not in effect unless theITwistieConstants.SHOW_DESCRIPTION
flag is also setvoid
setEnabled
(boolean enabled) Sets the enablement for the control and also all the text-base childrenvoid
setForeground
(org.eclipse.swt.graphics.Color color) Sets the foreground color for the control and also all the text-base childrenvoid
Sets the text to display as the titlevoid
setToolTipText
(String string) Sets the tooltip for the control and also all the text-base childrenvoid
setTwistieForeground
(org.eclipse.swt.graphics.Color color) Sets the color to be used for drawing the twistie graphicprivate int[]
translate
(int[] data, int x, int y) Translates the twistie points array to compensate for the given x and y offsetMethods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setFont, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
style
private int style -
points_for_expanded
static final int[] points_for_expandedAn array of points for a triangle pointing downward -
points_for_collapsed
static final int[] points_for_collapsedAn array of points for a triangle pointing to the right -
titleLabel
private org.eclipse.swt.widgets.Label titleLabelLabel
to display the text for this twistie -
twistieColor
private org.eclipse.swt.graphics.Color twistieColorTheColor
to use for the twistie graphic itself; defaults to the same as the foreground color of the titleLabel -
isCollapsed
private boolean isCollapsedThe state of the control; callers can check this state by callingisCollapsed()
-
descriptionLabel
private org.eclipse.swt.widgets.Label descriptionLabelAn optional Label to display the description -
listeners
-
-
Constructor Details
-
TwistieLabel
public TwistieLabel(org.eclipse.swt.widgets.Composite parent, int style) Create a twistie Label with the given style bit.Style bit can be one or more of:
- TwistieLabel.NONE -- The default; does not show description and separator, and is collapsed
- TwistieLabel.SHOW_DESCRIPTION -- Show the description below the separator (or title if separator s not shown)
- TwistieLabel.SHOW_SEPARATOR -- Show a separator below the title
- TwistieLabel.SHOW_EXPANDED -- Show a separator below the title
- Parameters:
parent
-style
-
-
-
Method Details
-
translate
private int[] translate(int[] data, int x, int y) Translates the twistie points array to compensate for the given x and y offset- Parameters:
data
-x
-y
-- Returns:
-
addMouseListener
public void addMouseListener(org.eclipse.swt.events.MouseListener listener) Add a mouse listener to the control and also thetitleLabel
- Overrides:
addMouseListener
in classorg.eclipse.swt.widgets.Control
-
removeMouseListener
public void removeMouseListener(org.eclipse.swt.events.MouseListener listener) Remove the mouse listener from the control and also thetitleLabel
- Overrides:
removeMouseListener
in classorg.eclipse.swt.widgets.Control
-
setTwistieForeground
public void setTwistieForeground(org.eclipse.swt.graphics.Color color) Sets the color to be used for drawing the twistie graphic- Parameters:
color
-
-
setForeground
public void setForeground(org.eclipse.swt.graphics.Color color) Sets the foreground color for the control and also all the text-base children- Overrides:
setForeground
in classorg.eclipse.swt.widgets.Control
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color) Sets the background color for the control and also all the text-base children- Overrides:
setBackground
in classorg.eclipse.swt.widgets.Control
-
setTitle
Sets the text to display as the title- Parameters:
string
-
-
setDescription
Sets the text to display as the description; this is not in effect unless theITwistieConstants.SHOW_DESCRIPTION
flag is also set- Parameters:
string
-
-
setToolTipText
Sets the tooltip for the control and also all the text-base children- Overrides:
setToolTipText
in classorg.eclipse.swt.widgets.Control
-
setEnabled
public void setEnabled(boolean enabled) Sets the enablement for the control and also all the text-base children- Overrides:
setEnabled
in classorg.eclipse.swt.widgets.Control
-
isCollapsed
public boolean isCollapsed()Returns whether this control is in a collapsed state- Returns:
-
setCollapsed
public void setCollapsed(boolean c) -
addTwistieListener
Add a listener to be notified whenever this control is collapsed or expanded; listeners can check the collapsed/expanded state on the control and perform layout changes if need be.- Parameters:
listener
-
-
removeTwistieListener
-
notifyTwistieListeners
private void notifyTwistieListeners()
-