Class FloatingText
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Control
-
- org.eclipse.swt.widgets.Scrollable
-
- org.eclipse.swt.widgets.Composite
-
- org.eclipse.nebula.widgets.floatingtext.FloatingText
-
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class FloatingText extends org.eclipse.swt.widgets.CompositeInstances of this class are selectable user interface objects that allow the user to enter and modify text with a label floating above the input area. FloatingText controls can be either single or multi-line. In contrast to a Text widget, when a floating text control is created with a border, a custom drawn inset will be painted INSTEAD OF the platform specific inset.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 thesetSeparatorSpace(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
Fields Modifier and Type Field Description private org.eclipse.swt.widgets.LabelfLabelprivate org.eclipse.swt.graphics.FontfLabelFontprivate intfLabelToTextRatioprivate intfStyleprivate org.eclipse.swt.widgets.TextfText
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.swt.graphics.PointcomputeSize(int pWidthHint, int pHeightHint, boolean pChanged)private org.eclipse.swt.widgets.LabelcreateLabel(int pStyle)private org.eclipse.swt.layout.GridLayoutcreateLayout(int pStyle)private voiddoSetLabelText()org.eclipse.swt.widgets.LabelgetLabel()private org.eclipse.swt.layout.GridDatagetLabelLayoutData()intgetLabelRatio()The default is 90 which means that the label height is 90% of the text text height.org.eclipse.swt.layout.GridLayoutgetLayout()private java.lang.StringgetMessage()org.eclipse.swt.widgets.TextgetText()private org.eclipse.swt.layout.GridDatagetTextLayoutData()private intremoveStyles(int pStyle, int... styles)voidsetBackgroundColors(org.eclipse.swt.graphics.Color color)Sets the backgrounds of the label and the text to the provided color.voidsetEnabled(boolean pEnabled)voidsetForegroundColors(org.eclipse.swt.graphics.Color color)Sets the foregrounds of the label and the text to the provided color.private voidsetLabelText(boolean pFocus)voidsetRatio(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.FloatingTextsetSeparatorSpace(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
-
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, isAutoScalable, 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, toString
-
-
-
-
Constructor Detail
-
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
SWTwhich 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 thoseSWTstyle 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 Detail
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int pWidthHint, int pHeightHint, boolean pChanged)- Overrides:
computeSizein classorg.eclipse.swt.widgets.Control
-
getLabel
public org.eclipse.swt.widgets.Label getLabel()
- Returns:
- the label that floats above the text
-
getLayout
public org.eclipse.swt.layout.GridLayout getLayout()
- Overrides:
getLayoutin classorg.eclipse.swt.widgets.Composite
-
getText
public org.eclipse.swt.widgets.Text getText()
- Returns:
- the underlying text widget.
-
setEnabled
public void setEnabled(boolean pEnabled)
- Overrides:
setEnabledin classorg.eclipse.swt.widgets.Control
-
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.
-
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
-
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)
-
setSeparatorSpace
public FloatingText setSeparatorSpace(int space)
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
-
createLabel
private org.eclipse.swt.widgets.Label createLabel(int pStyle)
-
createLayout
private org.eclipse.swt.layout.GridLayout createLayout(int pStyle)
-
doSetLabelText
private void doSetLabelText()
-
getLabelLayoutData
private org.eclipse.swt.layout.GridData getLabelLayoutData()
-
getMessage
private java.lang.String getMessage()
-
getTextLayoutData
private org.eclipse.swt.layout.GridData getTextLayoutData()
-
removeStyles
private int removeStyles(int pStyle, int... styles)
-
setLabelText
private void setLabelText(boolean pFocus)
-
-