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 classA 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.LabelAn optional Label to display the descriptionprivate booleanThe 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 intprivate org.eclipse.swt.widgets.LabelLabelto display the text for this twistieprivate org.eclipse.swt.graphics.ColorTheColorto 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
embeddedHandleFields inherited from class org.eclipse.swt.widgets.Widget
handleFields inherited from interface 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 TypeMethodDescriptionvoidaddMouseListener(org.eclipse.swt.events.MouseListener listener) Add a mouse listener to the control and also thetitleLabelvoidaddTwistieListener(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.booleanReturns whether this control is in a collapsed stateprivate voidvoidremoveMouseListener(org.eclipse.swt.events.MouseListener listener) Remove the mouse listener from the control and also thetitleLabelvoidremoveTwistieListener(ITwistieListener listener) voidsetBackground(org.eclipse.swt.graphics.Color color) Sets the background color for the control and also all the text-base childrenvoidsetCollapsed(boolean c) voidsetDescription(String string) Sets the text to display as the description; this is not in effect unless theITwistieConstants.SHOW_DESCRIPTIONflag is also setvoidsetEnabled(boolean enabled) Sets the enablement for the control and also all the text-base childrenvoidsetForeground(org.eclipse.swt.graphics.Color color) Sets the foreground color for the control and also all the text-base childrenvoidSets the text to display as the titlevoidsetToolTipText(String string) Sets the tooltip for the control and also all the text-base childrenvoidsetTwistieForeground(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, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, setScrollbarsModeMethods 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, updateMethods 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, removeListener, removeTypedListener, 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 titleLabelLabelto display the text for this twistie -
twistieColor
private org.eclipse.swt.graphics.Color twistieColorTheColorto 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:
addMouseListenerin 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:
removeMouseListenerin 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:
setForegroundin 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:
setBackgroundin classorg.eclipse.swt.widgets.Control
-
setTitle
-
setDescription
Sets the text to display as the description; this is not in effect unless theITwistieConstants.SHOW_DESCRIPTIONflag is also set- Parameters:
string-
-
setToolTipText
Sets the tooltip for the control and also all the text-base children- Overrides:
setToolTipTextin 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:
setEnabledin 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()
-