Class FloatingText
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class FloatingText
extends org.eclipse.swt.widgets.Composite
Style SEPARATOR leaves a gap between the label and the text of one pixel in
the color set by Control.setBackground(Color)
. To add more space use the
setSeparatorSpace(int)
method.
- Styles are inherited from Text and subclasses:
- CENTER, ICON_CANCEL, ICON_SEARCH, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP, BORDER, H_SCROLL, V_SCROLL, LEFT_TO_RIGT, RIGHT_TO_LEFT, FLIP_TEXT_DIRECTION, SEPARATOR
- Events:
- DefaultSelection, Modify, Verify, OrientationChange
Note: Only one of the styles MULTI and SINGLE may be specified, and only one of the styles LEFT, CENTER, and RIGHT may be specified.
Note: The styles ICON_CANCEL and ICON_SEARCH are hints used in combination with SEARCH. When the platform supports the hint, the text control shows these icons. When an icon is selected, a default selection event is sent with the detail field set to one of ICON_CANCEL or ICON_SEARCH. Normally, application code does not need to check the detail. In the case of ICON_CANCEL, the text is cleared before the default selection event is sent causing the application to search for an empty string.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FloatingText(org.eclipse.swt.widgets.Composite pParent, int pStyle)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. -
Method Summary
Modifier and Type Method Description org.eclipse.swt.graphics.Point
computeSize(int pWidthHint, int pHeightHint, boolean pChanged)
org.eclipse.swt.graphics.Font
findFittingFont(org.eclipse.swt.widgets.Label label)
org.eclipse.swt.widgets.Label
getLabel()
int
getLabelRatio()
The default is 90 which means that the label height is 90% of the text text height.org.eclipse.swt.layout.GridLayout
getLayout()
org.eclipse.swt.widgets.Text
getText()
void
setBackgroundColors(org.eclipse.swt.graphics.Color color)
Sets the backgrounds of the label and the text to the provided color.void
setEnabled(boolean pEnabled)
void
setForegroundColors(org.eclipse.swt.graphics.Color color)
Sets the foregrounds of the label and the text to the provided color.void
setRatio(int ratio)
Sets the height of the label as ratio of the text height where 100 means that the label and text are the same size.FloatingText
setSeparatorSpace(int space)
If you have used the SWT.SEPARATOR style hint then you can set the width of the separator here.Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, 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, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, 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, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, 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
-
Constructor Details
-
FloatingText
public FloatingText(org.eclipse.swt.widgets.Composite pParent, int pStyle)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 theint
"|" operator) two or more of thoseSWT
style constants. The class description lists the style constants that are applicable to the class. Style bits are NOT 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:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.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.SEPARATOR
,SWT.SINGLE
,SWT.MULTI
,SWT.READ_ONLY
,SWT.WRAP
,SWT.LEFT
,SWT.RIGHT
,SWT.CENTER
,SWT.PASSWORD
,SWT.SEARCH
,SWT.BORDER
,SWT.H_SCROLL
,SWT.V_SCROLL
,SWT.LEFT_TO_RIGHT
,SWT.RIGHT_TO_LEFT
,SWT.FLIP_TEXT_DIRECTION
,Widget.checkSubclass()
,Widget.getStyle()
-
-
Method Details
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int pWidthHint, int pHeightHint, boolean pChanged)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
-
findFittingFont
public org.eclipse.swt.graphics.Font findFittingFont(org.eclipse.swt.widgets.Label label) -
getLabel
public org.eclipse.swt.widgets.Label getLabel()- Returns:
- the label that floats above the text
-
getLabelRatio
public int getLabelRatio()The default is 90 which means that the label height is 90% of the text text height.- Returns:
- the label to text ratio.
- See Also:
setRatio(int)
-
getLayout
public org.eclipse.swt.layout.GridLayout getLayout()- Overrides:
getLayout
in classorg.eclipse.swt.widgets.Composite
-
getText
public org.eclipse.swt.widgets.Text getText()- Returns:
- the underlying text widget.
-
setBackgroundColors
public void setBackgroundColors(org.eclipse.swt.graphics.Color color)Sets the backgrounds of the label and the text to the provided color.- Parameters:
color
- the color.
-
setEnabled
public void setEnabled(boolean pEnabled)- Overrides:
setEnabled
in classorg.eclipse.swt.widgets.Control
-
setForegroundColors
public void setForegroundColors(org.eclipse.swt.graphics.Color color)Sets the foregrounds of the label and the text to the provided color.- Parameters:
color
- the color.
-
setRatio
public void setRatio(int ratio)Sets the height of the label as ratio of the text height where 100 means that the label and text are the same size.- Parameters:
ratio
- the ratio of the label versus the text height
-
setSeparatorSpace
If you have used the SWT.SEPARATOR style hint then you can set the width of the separator here.- Parameters:
space
- the amount of pixels- Returns:
- this
-