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

public class TwistieLabel extends org.eclipse.swt.widgets.Composite implements ITwistieConstants
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 Classes
    Modifier and Type
    Class
    Description
    private 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

    Fields
    Modifier and Type
    Field
    Description
    private org.eclipse.swt.widgets.Label
    An optional Label to display the description
    private boolean
    The state of the control; callers can check this state by calling isCollapsed()
    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 downward
    private int
     
    private org.eclipse.swt.widgets.Label
    Label to display the text for this twistie
    private org.eclipse.swt.graphics.Color
    The Color to use for the twistie graphic itself; defaults to the same as the foreground color of the titleLabel

    Fields 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

    Constructors
    Constructor
    Description
    TwistieLabel(org.eclipse.swt.widgets.Composite parent, int style)
    Create a twistie Label with the given style bit.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addMouseListener(org.eclipse.swt.events.MouseListener listener)
    Add a mouse listener to the control and also the titleLabel
    void
    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 state
    private void
     
    void
    removeMouseListener(org.eclipse.swt.events.MouseListener listener)
    Remove the mouse listener from the control and also the titleLabel
    void
     
    void
    setBackground(org.eclipse.swt.graphics.Color color)
    Sets the background color for the control and also all the text-base children
    void
    setCollapsed(boolean c)
     
    void
    Sets the text to display as the description; this is not in effect unless the ITwistieConstants.SHOW_DESCRIPTION flag is also set
    void
    setEnabled(boolean enabled)
    Sets the enablement for the control and also all the text-base children
    void
    setForeground(org.eclipse.swt.graphics.Color color)
    Sets the foreground color for the control and also all the text-base children
    void
    setTitle(String string)
    Sets the text to display as the title
    void
    Sets the tooltip for the control and also all the text-base children
    void
    setTwistieForeground(org.eclipse.swt.graphics.Color color)
    Sets the color to be used for drawing the twistie graphic
    private int[]
    translate(int[] data, int x, int y)
    Translates the twistie points array to compensate for the given x and y offset

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • style

      private int style
    • points_for_expanded

      static final int[] points_for_expanded
      An array of points for a triangle pointing downward
    • points_for_collapsed

      static final int[] points_for_collapsed
      An array of points for a triangle pointing to the right
    • titleLabel

      private org.eclipse.swt.widgets.Label titleLabel
      Label to display the text for this twistie
    • twistieColor

      private org.eclipse.swt.graphics.Color twistieColor
      The Color to use for the twistie graphic itself; defaults to the same as the foreground color of the titleLabel
    • isCollapsed

      private boolean isCollapsed
      The state of the control; callers can check this state by calling isCollapsed()
    • descriptionLabel

      private org.eclipse.swt.widgets.Label descriptionLabel
      An optional Label to display the description
    • listeners

      private List 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 the titleLabel
      Overrides:
      addMouseListener in class org.eclipse.swt.widgets.Control
    • removeMouseListener

      public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)
      Remove the mouse listener from the control and also the titleLabel
      Overrides:
      removeMouseListener in class org.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 class org.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 class org.eclipse.swt.widgets.Control
    • setTitle

      public void setTitle(String string)
      Sets the text to display as the title
      Parameters:
      string -
    • setDescription

      public void setDescription(String string)
      Sets the text to display as the description; this is not in effect unless the ITwistieConstants.SHOW_DESCRIPTION flag is also set
      Parameters:
      string -
    • setToolTipText

      public void setToolTipText(String string)
      Sets the tooltip for the control and also all the text-base children
      Overrides:
      setToolTipText in class org.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 class org.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

      public 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.
      Parameters:
      listener -
    • removeTwistieListener

      public void removeTwistieListener(ITwistieListener listener)
    • notifyTwistieListeners

      private void notifyTwistieListeners()