24 #include <initializer_list> 28 #include <QDoubleSpinBox> 31 #include "ginteractor.h" 33 class _Internal_QLineEdit;
34 class _Internal_QSpinBox;
35 class _Internal_QDoubleSpinBox;
57 GTextField(
const string& text =
"",
int charsWide = 0, QWidget* parent =
nullptr);
62 GTextField(
int charsWide, QWidget* parent =
nullptr);
70 GTextField(
int value,
int min,
int max,
int step = 1, QWidget* parent =
nullptr);
78 GTextField(
double value,
double min,
double max,
double step, QWidget* parent =
nullptr);
119 virtual string
getText()
const;
122 string
getType()
const override;
253 virtual void setText(
const string& text);
285 virtual void setValue(
double value);
298 virtual void setValue(
const string& value);
351 string getActionEventType()
const override;
358 _Internal_QLineEdit* _iqlineedit;
359 _Internal_QSpinBox* _iqspinbox;
360 _Internal_QDoubleSpinBox* _iqdoublespinbox;
366 friend class _Internal_QLineEdit;
367 friend class _Internal_QSpinBox;
368 friend class _Internal_QDoubleSpinBox;
375 class _Internal_QLineEdit :
public QLineEdit,
public _Internal_QWidget {
379 _Internal_QLineEdit(
GTextField* gtextField, QWidget* parent =
nullptr);
380 void detach()
override;
381 void keyPressEvent(QKeyEvent* event)
override;
382 void keyReleaseEvent(QKeyEvent* event)
override;
383 QSize sizeHint()
const override;
386 void handleTextChange(
const QString&);
398 class _Internal_QSpinBox :
public QSpinBox,
public _Internal_QWidget {
402 _Internal_QSpinBox(
GTextField* qgtextField,
int min,
int max,
int step = 1, QWidget* parent =
nullptr);
403 void detach()
override;
404 void keyPressEvent(QKeyEvent* event)
override;
405 void keyReleaseEvent(QKeyEvent* event)
override;
406 virtual QLineEdit* lineEdit()
const;
407 QSize sizeHint()
const override;
410 void handleTextChange(
const QString&);
422 class _Internal_QDoubleSpinBox :
public QDoubleSpinBox,
public _Internal_QWidget {
426 _Internal_QDoubleSpinBox(
GTextField* qgtextField,
double min,
double max,
double step = 0.1, QWidget* parent =
nullptr);
427 void detach()
override;
428 void keyPressEvent(QKeyEvent* event)
override;
429 void keyReleaseEvent(QKeyEvent* event)
override;
430 virtual QLineEdit* lineEdit()
const;
431 QSize sizeHint()
const override;
434 void handleTextChange(
const QString&);
442 #endif // _gtextfield_h virtual void setCharsWide(int charsWide)
Sets the width of this text field to be exactly wide enough to display the given number of characters...
Definition: gtextfield.cpp:283
virtual bool valueIsInteger() const
Returns true if the currently typed value in the text field can be interpreted as an integer...
Definition: gtextfield.cpp:389
virtual string getText() const
Returns the text field's current text.
Definition: gtextfield.cpp:159
virtual char getValueAsChar() const
Returns the currently typed value in the text field as a char value.
Definition: gtextfield.cpp:182
virtual string getValue() const
Returns the text field's current text.
Definition: gtextfield.cpp:173
virtual bool getValueAsBool() const
Returns the currently typed value in the text field, interpreted as a bool value of true or false...
Definition: gtextfield.cpp:177
This interactor subclass represents a text field for entering short text strings. ...
Definition: gtextfield.h:41
InputType
Constants for the valid types of text field input.
Definition: gtextfield.h:46
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gtextfield.cpp:120
virtual void setEditable(bool value)
Sets whether the value in the text box can be edited.
Definition: gtextfield.cpp:297
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gtextfield.cpp:169
Definition: gtextfield.h:48
virtual void setMaxLength(int maxLength)
Sets the maximum number of characters that can be typed into the field.
Definition: gtextfield.cpp:309
virtual bool valueIsDouble() const
Returns true if the currently typed value in the text field can be interpreted as a real number...
Definition: gtextfield.cpp:381
virtual bool isAutocompleteEnabled() const
Returns true if this text field has an autocompletion list of options that will pop up as the user be...
Definition: gtextfield.cpp:215
virtual bool valueIsReal() const
Returns true if the currently typed value in the text field can be interpreted as a real number...
Definition: gtextfield.cpp:393
virtual void setAutocompleteEnabled(bool enabled)
Sets whether the autocompletion feature is enabled for this text field.
Definition: gtextfield.cpp:268
Definition: gtextfield.h:49
virtual void removeTextChangeListener()
Removes the text change listener from this text field so that it will no longer call it when the user...
Definition: gtextfield.cpp:235
virtual double getValueAsDouble() const
Returns the currently typed value in the text field, interpreted as a real number value...
Definition: gtextfield.cpp:191
virtual void setPlaceholder(string text)
Sets a gray message that is displayed in the background of the text field before the user has typed a...
Definition: gtextfield.cpp:321
virtual string getPlaceholder() const
Returns the text field's placeholder text, which is usually displayed as a light gray text in the fie...
Definition: gtextfield.cpp:149
virtual int getMaxLength() const
Returns the maximum length of string allowed in the text field.
Definition: gtextfield.cpp:130
virtual int getCharsWide() const
Returns the number of characters that can fit in the visible area of this text field.
Definition: gtextfield.cpp:106
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48
virtual InputType getInputType() const
Returns the type of input accepted by this text field.
Definition: gtextfield.cpp:116
Definition: gtextfield.h:47
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gtextfield.cpp:205
virtual bool valueIsBool() const
Returns true if the currently typed value in the text field can be interpreted as a bool value of tru...
Definition: gtextfield.cpp:373
GTextField(string text="", int charsWide=0, QWidget* parent=nullptr)
Creates a text field with the given initial text.
Definition: gtextfield.cpp:33
virtual void setValue(bool value)
Sets the current text value in the text field to the string representation of the given value...
Definition: gtextfield.cpp:353
virtual bool valueIsChar() const
Returns true if the currently typed value in the text field can be interpreted as a char value...
Definition: gtextfield.cpp:377
virtual int getValueAsInt() const
Returns the currently typed value in the text field, interpreted as an integer value.
Definition: gtextfield.cpp:196
virtual void setText(string text)
Sets the current text value in the text field.
Definition: gtextfield.cpp:333
virtual bool isEditable() const
Returns true if the text field's value can be edited.
Definition: gtextfield.cpp:225
virtual int getValueAsInteger() const
Returns the currently typed value in the text field, interpreted as an integer value.
Definition: gtextfield.cpp:200
~GTextField() override
Frees memory allocated internally by the text field.
Definition: gtextfield.cpp:86
virtual void setTextChangeListener(GEventListener func)
Sets a text-change listener on this text field so that it will be called when the value in the field ...
Definition: gtextfield.cpp:345
virtual bool valueIsInt() const
Returns true if the currently typed value in the text field can be interpreted as an integer...
Definition: gtextfield.cpp:385
virtual void setAutocompleteList(std::initializer_list< string > strings)
Sets the given list of strings to be used as an autocompletion list for this text field...
Definition: gtextfield.cpp:239