public class GralTextField extends GralWidget implements GralTextField_ifc
Modifier and Type | Class and Description |
---|---|
private static class |
GralTextField.CalculatorAngle16 |
private static class |
GralTextField.CalculatorAngle32 |
class |
GralTextField.GraphicImplAccess |
static class |
GralTextField.Type |
GralWidget.ActionChangeSelect, GralWidget.ConfigData, GralWidget.DynamicData, GralWidget.ImplAccess
GralWidgetBase.GralWidgComposite, GralWidgetBase.TimeOrderCreateImplWidget
GralWidget_ifc.ActionChange, GralWidget_ifc.ActionChangeWhen
Modifier and Type | Field and Description |
---|---|
protected int |
borderwidth
The width of an extra border arround the text field to mark it.
0: initially, no border.
|
(package private) boolean |
bPassword |
private CalculatorExpr |
calculator
A calculator to show calculated float values.
|
private int |
caretPos |
private int |
cursorCol |
private int |
cursorLine |
protected GralKeyListener |
gralKeyListener |
protected java.lang.StringBuffer |
newText
Buffer for new text which is set or appended in another thread than the graphic thread.
|
private java.lang.String |
sFormat2 |
protected java.lang.String |
sPrompt
The prompt to the text field.
|
protected java.lang.String |
sPromptStylePosition
The prompt to the text field.
|
protected GralTextFieldUser_ifc |
user |
static java.lang.String |
version
Version, history and license .
|
_wdgImpl, bEditable, bShouldInitialize, cfg, contextMenu, dateUser, dyda, htmlHelp, lastTimeSetVisible, redrawDelayMax, redrawtDelay, sCmd, sFormat, showWidgetInfo, sToolTip, sVersion, whatIs, XXXbuildMng
_cdata, _wdgPos, bVisibleState, gralMng, name, pixSize
sVersion
Constructor and Description |
---|
GralTextField(GralPos refPos,
java.lang.String posName,
GralTextField.Type... property)
Constructs a text field with given properties
|
GralTextField(GralPos refPos,
java.lang.String posName,
java.lang.String sPrompt,
java.lang.String promptStylePos,
GralTextField.Type... property)
Constructs a text field with prompt and given properties
|
Modifier and Type | Method and Description |
---|---|
int |
getCursorCol() |
int |
getCursorLine() |
int |
getCursorPos() |
java.lang.String |
getPrompt()
Returns the Label for a prompt or null if there isn't used a prompt
|
java.lang.String |
getValue()
Gets the current value of the text field thread-independent.
|
int |
setBorderWidth(int width)
Sets a new border width and returns the old one.
|
int |
setCursorPos(int pos) |
void |
setFormat(java.lang.String sFormat) |
void |
setLongValue(long valueP)
Sets a long value into a text field.
|
void |
setPrompt(java.lang.String sPrompt)
Sets a prompt text per default left top of the widget
|
void |
setPrompt(java.lang.String sPrompt,
java.lang.String sPromptPos)
This operation can be called only for a non activated widget in the implementation level,
because the promt position cannnot be changed if the widget is already visible.
|
void |
setText(java.lang.CharSequence arg)
Set the text of the widget.
|
void |
setText(java.lang.CharSequence arg,
int caretPos)
Sets the textual content.
|
void |
setText(java.lang.CharSequence arg,
int caretPosP,
boolean bSetAlways)
Sets the textual content.
|
void |
setTextStyle(GralColor color,
GralFont font)
Sets the style of all new set and added texts.
|
void |
setTextStyle(java.lang.String color,
char font,
int size) |
void |
setUser(GralTextFieldUser_ifc user)
Sets a callback instance which is invoked on any key press event except writing keys on a editable field.
|
void |
setValue(double valueP)
Sets a float value into a text field.
|
void |
setValue(float valueP)
Sets a float value into a text field.
|
void |
setValue(java.lang.Object[] value)
Sets some value to show any content.
|
clearShowParam, createImplWidget_Gthread, getActionChange, getActionChangeStrict, getActionDrag, getActionDrop, getActionFocused, getActionShow, getBackColor, getCfgElement, getCmd, getCmd, getContentIdent, getContentInfo, getContextMenu, getData, getDataIx, getDataPath, getDataPath, getFloatValue, getFocusedWidget, getFormat, getGralWidget, getHtmlHelp, getImplAccess, getImplWidget, getItsPanel, getLongValue, getName, getShowMethod, getShowParam, getsToolTip, getText, getVariable, getVariableFromContentInfo, isChanged, isEditable, isGraphicDisposed, isInFocus, isNotEditableOrShouldInitialize, isVisible, redraw, redraw, redraw, redraw1, redrawOnlyDynamics, refreshFromVariable, refreshFromVariable, removeImplWidget_Gthread, requestNewValueForVariable, setActionChange, setActionFocused, setActionMouse, setActionShow, setBackColor, setBackgroundColor, setBoundsPixel, setCfgElement, setCmd, setContentIdent, setContentInfo, setData, setDataIx, setDataPath, setDragEnable, setDropEnable, setEditable, setFocus, setFocus, setFocusedWidget, setForegroundColor, setHtmlHelp, setLineColor, setMinMax, setPrimaryWidgetOfPanel, setTextColor, setToolTip, setToPanel, setValue, setValue, setVariable, setVisible, specifyActionChange, specifyContextMenu, stop, toString, toString, XXXgetWidgetImplementation, XXXremoveWidgetImplementation, XXXrepaintGthread, XXXsetFocusGThread
checkImplWidgetCreation, createImplWidget, gralMng, hasFocus, pos, remove, resizePostPreparation, setFocused
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getText
getActionChange, getBackColor, getCmd, getContentIdent, getContentInfo, getData, getDataPath, getImplWidget, isChanged, isEditable, isGraphicDisposed, isNotEditableOrShouldInitialize, redraw, redraw, refreshFromVariable, refreshFromVariable, setBackColor, setBackgroundColor, setBoundsPixel, setCmd, setContentIdent, setData, setDataPath, setEditable, setFocus, setForegroundColor, setHtmlHelp, setLineColor, setTextColor
getFocusedWidget, getImplAccess, getName, gralMng, isInFocus, isVisible, pos, setFocus, setFocused, setFocusedWidget, setVisible
public static final java.lang.String version
setText(CharSequence, int, boolean)
now also with negative charetPos count from left.
setText(CharSequence, int, boolean)
for unconditional write, this is if a text field itself
causes the operation which the call setText().
GralTextField.GraphicImplAccess
by SwtTextFieldWrapper
(and AwtTextField
)
for a GralTextBox
and this class. Most is the same, few things are tuned.
The newText
is moved from the GralTextBox
to here
because should be handled from the implementation GralTextField.GraphicImplAccess.getAndClearNewText()
.
cursorLine
, cursorCol
, GralTextField.GraphicImplAccess.caretPos(int, int, int)
etc.
setBorderWidth(int)
to show the text field with a border.
setLongValue(long)
is more complexly, a calculation can result in a float value. Fixed.
GralTextField.GraphicImplAccess.posPrompt
and ...posField is processed
in this class commonly for SWT and AWT implementation.
GralTextField.Type
, supports password field.
GralTextField
uses the new concept of instantiation: It is not
the super class of the implementation class. But it provides GralTextField.GraphicImplAccess
as the super class.
setText(CharSequence, int)
: supports GralWidget_ifc.isNotEditableOrShouldInitialize()
to support
edit field handling.
setText(CharSequence, int)
overwriting concept is faulty.
Because an accidentally change of text prevents setting the correct text. Check of #bTextChg
removed. The preventing of overwriting an edit field should be prevented outside as condition of
call of setText(CharSequence)
.
#bTextChg
detects whether any input is taken. GralWidget.isChanged(boolean)
returns this information
and resets #bTextChg
. setText(CharSequence, int)
only sets if the text is unchanged.
Therefore a changed text won't be over-written by an setText().
setValue(double)
and setValue(Object[])
for double values.
sFormat2
etc: Now format "int16AngleDegree" etc. are recognized
as special format. Improved calling calculator
in setValue(float)
.
#isChanged()
, setUser(GralTextFieldUser_ifc)
setValue(float)
now supports formatting view.
This algorithm was used for the InspcGui
before.
#setMouseAction(GralUserAction)
. This method should be
an abstract method of all GralWidget
but it is used yet only here.
private int caretPos
private int cursorLine
private int cursorCol
protected int borderwidth
GralWidget.DynamicData.lineColor
protected java.lang.String sPrompt
protected java.lang.String sPromptStylePosition
private CalculatorExpr calculator
private java.lang.String sFormat2
protected GralTextFieldUser_ifc user
final boolean bPassword
protected java.lang.StringBuffer newText
GralGraphicOrder
after calling #append(CharSequence)
or setText(CharSequence)
.
It is filled only temporary. It is used only by a GralTextBoxprotected GralKeyListener gralKeyListener
public GralTextField(GralPos refPos, java.lang.String posName, GralTextField.Type... property)
refPos
- Reference position contains the parent widget (panel) and the GralMng.posName
- Position and Name of the field. Maybe null if it is not need in management by name
See GralWidget#GralWidget(String, char)
.property
- password, editable, maybe left empty.public GralTextField(GralPos refPos, java.lang.String posName, java.lang.String sPrompt, java.lang.String promptStylePos, GralTextField.Type... property)
refPos
- Reference position contains the parent widget (panel) and the GralMng.posName
- can contain "@sPrompt
- prompt textpromptStylePos
- "t" or "r"property
- see GralTextField.Type
, password or editablepublic void setPrompt(java.lang.String sPrompt)
sPrompt
- public void setPrompt(java.lang.String sPrompt, java.lang.String sPromptPos)
sPrompt
- sPromptPos
- "r" or "t", left is not supported because the start position is not determined.
To show a text field with a prompt left side add a GralLabel
to the proper position.public void setUser(GralTextFieldUser_ifc user)
user
- callback instance due to the interface.public void setFormat(java.lang.String sFormat)
setFormat
in class GralWidget
public void setValue(float valueP)
setFormat(String)
of this widget starts with '!' and contains a second '!',
the String between that is used as expression to calculate the float value
using CalculatorExpr
. Therewith any calculation can be done.
setValue
in interface GralSetValue_ifc
setValue
in class GralWidget
valueP
- This routine may be overridden by some specialized widgets.GralWidget.setValue(float)
public void setLongValue(long valueP)
setFormat(String)
of this widget starts with '!' and contains a second '!',
the String between that is used as expression to calculate the long value
using CalculatorExpr
. Therewith any calculation can be done. The result may be a float or double.
int32AngleDegree
and int16AngleDegree
is supported, if that text is contained in the format string. The value should come from an integer,
which contains an angle value with wrap-around-presentation: 0x7fffffff (32 bit) or 0x7fff (16 bit) and
0x80000000 which is exactly 180 degree. This format helps to calculate with angle values in range
of -180...+179.99999 degree. The presentation in the text field is shown as degree angle value.
setLongValue
in interface GralSetValue_ifc
setLongValue
in class GralWidget
valueP
- This routine may be overridden by some specialized widgets.GralWidget.setValue(float)
public void setValue(double valueP)
setFormat(String)
of this widget starts with '!' and contains a second '!',
the String between that is used as expression to calculate the float value
using CalculatorExpr
. Therewith any calculation can be done.
GralWidget.setValue(float)
public void setValue(java.lang.Object[] value)
GralWidget
setValue
in interface GralSetValue_ifc
setValue
in class GralWidget
value
- This routine may be overridden by some specialized widgets.public void setText(java.lang.CharSequence arg)
GralWidget_ifc
GralWidget_ifc.setBackColor(GralColor, int)
etc.
GralWidget_ifc.redraw(int, int)
is invoked with the standard delay of #redrawtDelay
and #redrawDelayMax
.
With that the widget-specific private instance of #repaintRequ
is added to the queue of requests
in the GralGraphicThread#addTimeEntry(GralGraphicOrder)
. In the requested time that
dispatch order is executed in the graphic thread. It calls GralWidgImplAccess_ifc.redrawGthread()
.
That method is implemented in the graphic implementation layer of the widget. It sets the appropriate values
from the independent Gral attributes to the implementation specifics and invoke a redraw of the graphic layer.
GralGraphicOrder
is queued. All changed attributes are stored in DynamicData#whatIsChanged
and the
GralWidgImplAccess_ifc.redrawGthread()
quests all changes one after another.
It means that a thread switch is invoked only one time per widget for more as one change.
DynamicData
. That composite part of a widget stores all standard dynamic data of a widget.setText
in interface GralSetValue_ifc
setText
in interface GralTextField_ifc
setText
in interface GralWidget_ifc
setText
in class GralWidget
arg
- The contentpublic void setText(java.lang.CharSequence arg, int caretPos)
GralWidget.redraw(int, int)
in 100 ms
if the content is changed in another thread than the graphical thread. It invokes a #redrawGthread()
if the content was changed in the graphical thread.
Note: If the current content is equals with the new one, a repaint request is not forced.
Therewith the cursor can be positioned inside. But if the content is changed, it is set with this given one.setText
in interface GralTextField_ifc
arg
- The text to show in the widget.caretPos
- 0 for left, -1 for right, 0 to Integer.MAXINT for a given position.
If the caret position is greater then the number of chars, it is set right.
That character which is left from the caret position is shown guaranteed in the text field.
Especially -1 can be given to show the text right-aligned.GralTextField_ifc.setText(java.lang.CharSequence, int)
public void setText(java.lang.CharSequence arg, int caretPosP, boolean bSetAlways)
GralWidget.redraw(int, int)
in 100 ms
if the content is changed in another thread than the graphical thread. It invokes a #redrawGthread()
if the content was changed in the graphical thread.
Note: If the current content is equals with the new one with the same cursor position, a repaint request is not forced.
Therewith the cursor can be positioned inside. But if the content is changed, it is set with this given one.arg
- the new textcaretPos
- >=0 the caret position, <0 the caret pos counted from left, -1 is after last char.
If too less or to big, correct it to left or right.bSetAlways
- if not true then the text is not set if typing of the field is in progress.
Then DynamicData#bTouchedField
is true. set a text from outside will be attack this typing.
Typing by the user has a higher priority. It is important for example for currently shown values,
which are also editable.
if true than always the text is set. This is especially if this invocation comes from the typing itself,
for example type a control-Key during edit to force actions on this text field itself.GralTextField_ifc.setText(java.lang.CharSequence, int)
public java.lang.String getValue()
GralWidget.DynamicData.displayedText
which is updated while typing the text
or if the focus is changed (depending on implementation).getValue
in class GralWidget
public int getCursorPos()
getCursorPos
in interface GralTextField_ifc
public int getCursorLine()
getCursorLine
in interface GralTextField_ifc
public int getCursorCol()
getCursorCol
in interface GralTextField_ifc
public int setCursorPos(int pos)
setCursorPos
in interface GralTextField_ifc
public void setTextStyle(GralColor color, GralFont font)
GralTextField_ifc
setTextStyle
in interface GralTextField_ifc
public void setTextStyle(java.lang.String color, char font, int size)
public int setBorderWidth(int width)
width
- 0: No border, 1... number of pixel for border.public final java.lang.String getPrompt()