26 #include <initializer_list> 30 #include <QDoubleSpinBox> 33 #include "ginteractor.h" 37 class _Internal_QLineEdit;
38 class _Internal_QSpinBox;
39 class _Internal_QDoubleSpinBox;
61 GTextField(
const string& text =
"",
int charsWide = 0, QWidget* parent =
nullptr);
66 GTextField(
int charsWide, QWidget* parent =
nullptr);
74 GTextField(
int value,
int min,
int max,
int step = 1, QWidget* parent =
nullptr);
82 GTextField(
double value,
double min,
double max,
double step, QWidget* parent =
nullptr);
123 virtual string
getText()
const;
126 string
getType()
const override;
257 virtual void setText(
const string& text);
289 virtual void setValue(
double value);
302 virtual void setValue(
const string& value);
355 string getActionEventType()
const override;
362 _Internal_QLineEdit* _iqlineedit;
363 _Internal_QSpinBox* _iqspinbox;
364 _Internal_QDoubleSpinBox* _iqdoublespinbox;
370 friend class _Internal_QLineEdit;
371 friend class _Internal_QSpinBox;
372 friend class _Internal_QDoubleSpinBox;
379 class _Internal_QLineEdit :
public QLineEdit,
public _Internal_QWidget {
383 _Internal_QLineEdit(GTextField* gtextField, QWidget* parent =
nullptr);
384 void detach()
override;
385 void keyPressEvent(QKeyEvent* event)
override;
386 void keyReleaseEvent(QKeyEvent* event)
override;
387 QSize sizeHint()
const override;
390 void handleTextChange(
const QString&);
393 GTextField* _gtextfield;
395 friend class GTextField;
402 class _Internal_QSpinBox :
public QSpinBox,
public _Internal_QWidget {
406 _Internal_QSpinBox(GTextField* qgtextField,
int min,
int max,
int step = 1, QWidget* parent =
nullptr);
407 void detach()
override;
408 void keyPressEvent(QKeyEvent* event)
override;
409 void keyReleaseEvent(QKeyEvent* event)
override;
410 virtual QLineEdit* lineEdit()
const;
411 QSize sizeHint()
const override;
414 void handleTextChange(
const QString&);
417 GTextField* _gtextfield;
419 friend class GTextField;
426 class _Internal_QDoubleSpinBox :
public QDoubleSpinBox,
public _Internal_QWidget {
430 _Internal_QDoubleSpinBox(GTextField* qgtextField,
double min,
double max,
double step = 0.1, QWidget* parent =
nullptr);
431 void detach()
override;
432 void keyPressEvent(QKeyEvent* event)
override;
433 void keyReleaseEvent(QKeyEvent* event)
override;
434 virtual QLineEdit* lineEdit()
const;
435 QSize sizeHint()
const override;
438 void handleTextChange(
const QString&);
441 GTextField* _gtextfield;
443 friend class GTextField;
448 #endif // _gtextfield_h virtual bool valueIsInteger() const
Returns true if the currently typed value in the text field can be interpreted as an integer...
Definition: gtextfield.cpp:394
virtual int getCharsWide() const
Returns the number of characters that can fit in the visible area of this text field.
Definition: gtextfield.cpp:111
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:244
virtual double getValueAsDouble() const
Returns the currently typed value in the text field, interpreted as a real number value...
Definition: gtextfield.cpp:196
virtual int getValueAsInt() const
Returns the currently typed value in the text field, interpreted as an integer value.
Definition: gtextfield.cpp:201
This interactor subclass represents a text field for entering short text strings. ...
Definition: gtextfield.h:45
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:386
string getType() const override
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
Definition: gtextfield.cpp:174
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:240
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:288
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:182
Definition: gtextfield.h:53
std::function< void(GEvent)> GEventListener
Types for the event listener functions to be passed to various interactors.
Definition: gevent.h:38
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:358
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:52
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:398
Definition: gtextfield.h:52
virtual void setMaxLength(int maxLength)
Sets the maximum number of characters that can be typed into the field.
Definition: gtextfield.cpp:314
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:220
virtual bool isEditable() const
Returns true if the text field's value can be edited.
Definition: gtextfield.cpp:230
virtual int getMaxLength() const
Returns the maximum length of string allowed in the text field.
Definition: gtextfield.cpp:135
QWidget* getWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gtextfield.cpp:210
virtual void setAutocompleteEnabled(bool enabled)
Sets whether the autocompletion feature is enabled for this text field.
Definition: gtextfield.cpp:273
std::function< void()> GEventListenerVoid
Types for the event listener functions to be passed to various interactors.
Definition: gevent.h:44
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:350
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:154
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:382
virtual char getValueAsChar() const
Returns the currently typed value in the text field as a char value.
Definition: gtextfield.cpp:187
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:378
virtual InputType getInputType() const
Returns the type of input accepted by this text field.
Definition: gtextfield.cpp:121
~GTextField() override
Frees memory allocated internally by the text field.
Definition: gtextfield.cpp:91
virtual int getValueAsInteger() const
Returns the currently typed value in the text field, interpreted as an integer value.
Definition: gtextfield.cpp:205
Definition: gtextfield.h:51
virtual string getText() const
Returns the text field's current text.
Definition: gtextfield.cpp:164
virtual void setText(string text)
Sets the current text value in the text field.
Definition: gtextfield.cpp:338
virtual void setEditable(bool value)
Sets whether the value in the text box can be edited.
Definition: gtextfield.cpp:302
_Internal_QWidget* getInternalWidget() const override
Returns a direct pointer to the internal Qt widget being wrapped by this interactor.
Definition: gtextfield.cpp:125
virtual string getValue() const
Returns the text field's current text.
Definition: gtextfield.cpp:178
InputType
Constants for the valid types of text field input.
Definition: gtextfield.h:50
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:326
virtual bool valueIsInt() const
Returns true if the currently typed value in the text field can be interpreted as an integer...
Definition: gtextfield.cpp:390
GTextField(string text="", int charsWide=0, QWidget* parent=nullptr)
Creates a text field with the given initial text.
Definition: gtextfield.cpp:38