Implementation of a text entry menu.
More...
#include <EntryModel.hxx>
|
| void | auto_clamp (bool force=false) |
| | Calls clamp() only if automatic clamping is enabled (autoClamp_ = true).
|
| |
| virtual void | set_boundaries () |
| | Set min and max boundaries supported based on maxSize_ (digit count).
|
| |
| void | calculate_size () |
| | Calculate the size in digits.
|
| |
|
| DISALLOW_COPY_AND_ASSIGN (EntryModel) |
| |
|
| T | value_ |
| | present value held
|
| |
| T | valueMin_ |
| | minimum value representable by maxSize_
|
| |
| T | valueMax_ |
| | maximum value representable by maxSize_
|
| |
| unsigned | numLeadingZeros_: 5 |
| | number of leading zeros
|
| |
| unsigned | maxSize_: 5 |
| | maximum number of digits
|
| |
| unsigned | size_: 5 |
| | actual number of digits
|
| |
| unsigned | isAtInitialValue_: 1 |
| | true if still has the initial value
|
| |
| unsigned | empty_: 1 |
| | true if the value_ is "empty"
|
| |
| unsigned | base_: 6 |
| | radix base
|
| |
| unsigned | autoClamp_: 1 |
| | true to auto clamp the values
|
| |
template<class T>
class EntryModel< T >
Implementation of a text entry menu.
- Template Parameters
-
| T | the data type up to 64-bits in size, signed or unsigned |
Definition at line 49 of file EntryModel.hxx.
◆ EntryModel()
◆ append()
Append a value to the "back".
- Parameters
-
| val | value to append, base 10: 0 - 9, base 16: 0x0 - 0xF |
- Returns
- *this
Definition at line 168 of file EntryModel.hxx.
◆ append_char()
Append a character to the "back".
- Parameters
-
| c | character to append, base 10: 0 - 9, base 16: 0 - F |
- Returns
- *this
Definition at line 177 of file EntryModel.hxx.
◆ auto_clamp()
Calls clamp() only if automatic clamping is enabled (autoClamp_ = true).
- Parameters
-
| force | Normally, clamping doesn't occur if the entry is "empty". However, if force is set to true, we will clamp anyways. force also applies if the value is zero yet there is space for more leading zeros. |
Definition at line 459 of file EntryModel.hxx.
◆ calculate_size()
◆ change_sign()
◆ clamp()
Clamp the value at the min or max.
Clamping will not occur if the value is zero and there is space for more leading zeros.
- Parameters
-
| force | Normally, clamping doesn't occur if the entry is "empty". However, if force is set to true, we will clamp anyways. force also applies if the value is zero yet there is space for more leading zeros. |
Reimplemented in EntryModelBounded< T >.
Definition at line 400 of file EntryModel.hxx.
◆ clear()
◆ cursor_visible()
Test if cursor is visible.
- Returns
- true if cursor is visible, else false
Definition at line 273 of file EntryModel.hxx.
◆ empty()
Test if the entry is "empty".
Having an initial value is not empty.
- Returns
- true if empty, else false
Definition at line 266 of file EntryModel.hxx.
◆ get_string()
Get the value as a string.
The number of characters will not be trimmed to maxSize_. If trimming is required, it must be done by the caller.
- Parameters
-
| right_justify | true to right justify. |
Definition at line 321 of file EntryModel.hxx.
◆ get_value()
Get the entry as an unsigned integer value.
Note, that '0' is returned both when the actual value is '0' and when the entry is "empty". If the caller needs to distinguish between these two states, check for "empty()".
- Parameters
-
| force_clamp | Normally, clamping doesn't occur if the entry is "empty". However, if force is set to true, we will clamp anyways. This may be valuable when wanting an "empty" entry to return a valid value and '0' is out of bounds. The auto clamping setting is ignored. |
- Returns
- value representation of the entry
Definition at line 309 of file EntryModel.hxx.
◆ has_leading_zeros()
It is not always possible with get_string() to return the leading zeros.
Furthermore, get_value() does not tell the caller if there are leading zeros. Therefore, this API provides a definitive answer.
Definition at line 288 of file EntryModel.hxx.
◆ init() [1/2]
template<class T >
| void EntryModel< T >::init |
( |
unsigned |
max_size, |
|
|
int |
base |
|
) |
| |
|
inline |
Initialize empty.
- Parameters
-
| max_size | max number of digits in the base type |
| base | base type, 10 or 16 |
Definition at line 80 of file EntryModel.hxx.
◆ init() [2/2]
template<class T >
| void EntryModel< T >::init |
( |
unsigned |
max_size, |
|
|
int |
base, |
|
|
T |
value, |
|
|
bool |
automatic_clamp = true |
|
) |
| |
|
inline |
Initialize with a value.
- Parameters
-
| max_size | max number of digits in the base type |
| base | base type, 10 or 16 |
| value | value to initialize with |
| automatic_clamp | Unless otherwise specified by the API, enables automatic clamping of the value each time it is modified when true, else automatic clamping is not applied. |
Definition at line 96 of file EntryModel.hxx.
◆ is_at_initial_value()
Determine if this object is holding an initial or modified value.
- Returns
- true if if holding an initial value, else false if modified
Definition at line 280 of file EntryModel.hxx.
◆ max_size()
Get the max size (in digits).
- Returns
- max size in number of digits
Definition at line 259 of file EntryModel.hxx.
◆ operator++()
Pre-increment value.
While this method does prevent wrap around of the native type limits, it is incumbent on the caller to limit the resulting number of digits. Always clamps, the auto clamping setting is ignroed.
Definition at line 427 of file EntryModel.hxx.
◆ operator--()
Pre-decrement value.
While this method does prevent wrap around of the native type limits, it is incumbent on the caller to limit the resulting number of digits. Always clamps, the auto clamping setting is ignroed.
Definition at line 442 of file EntryModel.hxx.
◆ pop_back()
Removes (deletes) a character off the end.
Definition at line 184 of file EntryModel.hxx.
◆ push_back()
Append a value to the "back".
- Parameters
-
| val | value to append, base 10: 0 - 9, base 16: 0x0 - 0xF |
Definition at line 107 of file EntryModel.hxx.
◆ push_back_char()
Append a character to the "back".
- Parameters
-
| c | character to append, base 10: 0 - 9, base 16: 0 - F |
Definition at line 151 of file EntryModel.hxx.
◆ set_base() [1/2]
Set the radix base.
- Parameters
-
| base | new radix base to set. |
Definition at line 212 of file EntryModel.hxx.
◆ set_base() [2/2]
Set the radix base.
- Parameters
-
| base | new radix base to set. |
| convert | convert the current value, as a string, to the new base. |
Definition at line 222 of file EntryModel.hxx.
◆ set_boundaries()
◆ set_leading_zeros()
template<class T >
| void EntryModel< T >::set_leading_zeros |
( |
unsigned |
num | ) |
|
|
inline |
Sets the number of leading zeros without changing the value.
Definition at line 294 of file EntryModel.hxx.
◆ set_max()
◆ set_min()
◆ set_value()
Set the value, keep the max number of digits and base the same.
- Parameters
-
| value | value to initialize with |
Definition at line 244 of file EntryModel.hxx.
◆ size()
Get the size (actual number of digits).
Note, if the entry is still at its initial value, the result will be 0.
- Returns
- size actual size in number of digits
Definition at line 252 of file EntryModel.hxx.
◆ autoClamp_
◆ base_
◆ empty_
◆ isAtInitialValue_
◆ maxSize_
◆ numLeadingZeros_
◆ size_
◆ value_
◆ valueMax_
maximum value representable by maxSize_
Definition at line 495 of file EntryModel.hxx.
◆ valueMin_
minimum value representable by maxSize_
Definition at line 494 of file EntryModel.hxx.
The documentation for this class was generated from the following file: