OpenASIP
2.0
|
#include <NumberControl.hh>
Classes | |
union | Value |
Public Member Functions | |
NumberControl (wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=(MODE_HEXADECIMAL|MODE_BINARY|MODE_INT|MODE_UNSIGNED|MODE_FLOAT), int initial=0, const wxString &name=_T("NumberControl")) | |
virtual | ~NumberControl () |
int | intValue () const |
unsigned int | unsignedValue () const |
float | floatValue () const |
double | doubleValue () const |
ULongWord | uLongValue () const |
long | mode () const |
void | setBinMode () |
void | setHexMode () |
void | setIntMode () |
void | setUnsignedMode () |
void | setFloatMode () |
void | setDoubleMode () |
void | setValue (const ULongWord value) |
void | setValue (const unsigned int value) |
void | setValue (const int value) |
void | setValue (const float value) |
void | setValue (const double value) |
Static Public Attributes | |
static const long | MODE_BINARY = 1 |
Style flag for binary mode availability. More... | |
static const long | MODE_INT = 4 |
Style flag for signed integer mode availablity. More... | |
static const long | MODE_UNSIGNED = 8 |
Style flag for unsigned integer mode availability. More... | |
static const long | MODE_HEXADECIMAL = 2 |
Style flag for hexadecimal mode availability. More... | |
static const long | MODE_FLOAT = 16 |
Style flag for float mode availability. More... | |
static const long | MODE_DOUBLE = 32 |
Style flag for double mode availability. More... | |
static const long | NO_MODE_CHOICER = 64 |
Style flag for base choicer visibility. More... | |
Private Types | |
enum | { ID_BASE = 20000, ID_TEXT } |
IDs for the subwidgets. More... | |
Private Member Functions | |
void | create (const wxSize &size) |
void | update () |
void | onModeChoice (wxCommandEvent &event) |
void | onText (wxCommandEvent &event) |
Private Attributes | |
FocusTrackingTextCtrl * | text_ |
Text field widget. More... | |
wxChoice * | modeChoice_ |
Mode choicer widget. More... | |
long | style_ |
Current style flags of the widget. More... | |
Value | value_ |
Current value of the widget. More... | |
wxString | stringValue_ |
Dummy value string for the validators. More... | |
long | mode_ |
Current mode of the widget. More... | |
wxTextValidator * | binValidator_ |
Binary input validator. More... | |
wxTextValidator * | hexValidator_ |
Hexadecimal input validator. More... | |
wxTextValidator * | intValidator_ |
Signed integer input validator. More... | |
wxTextValidator * | unsignedValidator_ |
Unsigned integer input validator. More... | |
wxTextValidator * | floatValidator_ |
Float input validator. More... | |
Static Private Attributes | |
static const wxString | MODE_STRING_BIN = _T("bin") |
Choicer item string for the binary mode. More... | |
static const wxString | MODE_STRING_HEX = _T("hex") |
Choicer item string for the hexadecimal mode. More... | |
static const wxString | MODE_STRING_INT = _T("int") |
Choicer item string for the integer mode. More... | |
static const wxString | MODE_STRING_UNSIGNED = _T("unsigned") |
Choicer item string for the unsigned mode. More... | |
static const wxString | MODE_STRING_FLOAT = _T("float") |
Choicer item string for the float mode. More... | |
static const wxString | MODE_STRING_DOUBLE = _T("double") |
Choicer item string for the double mode. More... | |
static const int | CHOICER_WIDTH = 100 |
Mode choicer width. More... | |
Text field widget for numeric value input.
The widget value can be modified in hexadecimal, binary, int, unsigned int and floating point format. The widget value is always the same four bytes of memory, and the bit pattern is interpreted depending on the selected mode. Text field mode can be selected using an optional mode choicer. Available modes for the choicer are selected by passing the following style flags to the constructor: MODE_HEXADECIMAL, MODE_BINARY, MODE_INT, MODE_UNSIGNED, MODE_FLOAT and MODE_DOUBLE
Note that the extra bits in the double value is ignored when the mode is changed from double to any of the other modes.
The mode choicer widget can be disabled by using NO_MODE_CHOICER style flag.
Definition at line 59 of file NumberControl.hh.
|
private |
NumberControl::NumberControl | ( | wxWindow * | parent, |
wxWindowID | id = -1 , |
||
const wxPoint & | pos = wxDefaultPosition , |
||
const wxSize & | size = wxDefaultSize , |
||
long | style = (MODE_HEXADECIMAL | MODE_BINARY | MODE_INT | MODE_UNSIGNED | MODE_FLOAT) , |
||
int | initial = 0 , |
||
const wxString & | name = _T("NumberControl") |
||
) |
The Constructor.
window | Parent window of the widget. |
id | ID of the widget. |
pos | Position of the widget. |
size | Size of the widget. |
style | Style flags for the widget, see class comment for list of available flags. |
value | Initial value of the input. |
name | Name identifier for the widget. |
OutOfRange | If the value is out of the range. |
InvalidData | If the minimum value is higher than the maximum. |
Definition at line 83 of file NumberControl.cc.
References unsignedValue().
|
virtual |
The destructor.
Definition at line 113 of file NumberControl.cc.
References binValidator_, floatValidator_, hexValidator_, intValidator_, and unsignedValidator_.
|
private |
Creates the textfield and optional base choicer subwidgets for the control.
Definition at line 136 of file NumberControl.cc.
References assert, CHOICER_WIDTH, ID_BASE, ID_TEXT, MODE_BINARY, MODE_DOUBLE, MODE_FLOAT, MODE_HEXADECIMAL, MODE_INT, MODE_STRING_BIN, MODE_STRING_DOUBLE, MODE_STRING_FLOAT, MODE_STRING_HEX, MODE_STRING_INT, MODE_STRING_UNSIGNED, MODE_UNSIGNED, modeChoice_, NO_MODE_CHOICER, setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), setUnsignedMode(), style_, and text_.
double NumberControl::doubleValue | ( | ) | const |
Returns the current value.
Definition at line 450 of file NumberControl.cc.
References NumberControl::Value::doubleValue, and value_.
Referenced by MemoryValueDialog::doubleValue(), and SimulateDialog::onUpdateValue().
float NumberControl::floatValue | ( | ) | const |
Returns the current value.
Definition at line 439 of file NumberControl.cc.
References NumberControl::Value::floatValue, and value_.
int NumberControl::intValue | ( | ) | const |
Returns the current value.
Definition at line 417 of file NumberControl.cc.
References NumberControl::Value::intValue, and value_.
Referenced by MemoryValueDialog::intValue(), and SimulateDialog::onUpdateValue().
long NumberControl::mode | ( | ) | const |
Returns the widget mode style flag.
Definition at line 764 of file NumberControl.cc.
References mode_.
Referenced by MemoryValueDialog::mode(), and SimulateDialog::onUpdateValue().
|
private |
Event handler for the mode choicer.
Updates text field according to the selected mode.
Definition at line 327 of file NumberControl.cc.
References assert, dummy, MODE_STRING_BIN, MODE_STRING_DOUBLE, MODE_STRING_FLOAT, MODE_STRING_HEX, MODE_STRING_INT, MODE_STRING_UNSIGNED, modeChoice_, onText(), setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), and setUnsignedMode().
|
private |
Event handler, which validates the text field value and transfers data from the text field to the value variable.
This event handler is called when user has input new value to the text field.
Definition at line 270 of file NumberControl.cc.
References assert, NumberControl::Value::doubleValue, NumberControl::Value::floatValue, NumberControl::Value::intValue, mode_, MODE_BINARY, MODE_DOUBLE, MODE_FLOAT, MODE_HEXADECIMAL, MODE_INT, MODE_UNSIGNED, text_, Conversion::toDouble(), Conversion::toFloat(), Conversion::toInt(), WxConversion::toString(), Conversion::toUnsignedInt(), NumberControl::Value::unsignedValue, update(), and value_.
Referenced by onModeChoice().
void NumberControl::setBinMode | ( | ) |
Sets the widget to binary mode.
NotAvailable | If the MODE_BINARY style was not specified to the contructor. |
Definition at line 493 of file NumberControl.cc.
References binValidator_, mode_, MODE_BINARY, MODE_STRING_BIN, modeChoice_, stringValue_, style_, text_, and update().
Referenced by create(), and onModeChoice().
void NumberControl::setDoubleMode | ( | ) |
Sets the widget to double mode.
NotAvailable | If the MODE_DOUBLE style was not specified to the constructor. |
Definition at line 709 of file NumberControl.cc.
References floatValidator_, mode_, MODE_DOUBLE, MODE_STRING_DOUBLE, modeChoice_, stringValue_, style_, text_, and update().
Referenced by create(), and onModeChoice().
void NumberControl::setFloatMode | ( | ) |
Sets the widget to float mode.
NotAvailable | If the MODE_FLOAT style was not specified to the constructor. |
Definition at line 653 of file NumberControl.cc.
References floatValidator_, mode_, MODE_FLOAT, MODE_STRING_FLOAT, modeChoice_, stringValue_, style_, text_, and update().
Referenced by create(), and onModeChoice().
void NumberControl::setHexMode | ( | ) |
Sets the widget to hexadecimal mode.
NotAvailable | If the MODE_HEXADECIMAL was not specified to the constructor. |
Definition at line 536 of file NumberControl.cc.
References hexValidator_, mode_, MODE_HEXADECIMAL, MODE_STRING_HEX, modeChoice_, stringValue_, style_, text_, and update().
Referenced by create(), and onModeChoice().
void NumberControl::setIntMode | ( | ) |
Sets the widget to int mode.
NotAvailable | If the MODE_INT style was not specified to the constructor. |
Definition at line 462 of file NumberControl.cc.
References intValidator_, mode_, MODE_INT, MODE_STRING_INT, modeChoice_, stringValue_, style_, text_, and update().
Referenced by create(), and onModeChoice().
void NumberControl::setUnsignedMode | ( | ) |
Sets the widget to unsigned int mode.
NotAvailable | If the MODE_UNSIGNED style was not specified to the constructor. |
Definition at line 602 of file NumberControl.cc.
References mode_, MODE_STRING_UNSIGNED, MODE_UNSIGNED, modeChoice_, stringValue_, style_, text_, unsignedValidator_, and update().
Referenced by create(), and onModeChoice().
void NumberControl::setValue | ( | const double | value | ) |
Sets the value on the widget.
value | Double value to set. |
Definition at line 405 of file NumberControl.cc.
References NumberControl::Value::doubleValue, update(), and value_.
void NumberControl::setValue | ( | const float | value | ) |
Sets the value on the widget.
value | Float value to set. |
Definition at line 393 of file NumberControl.cc.
References NumberControl::Value::floatValue, update(), and value_.
void NumberControl::setValue | ( | const int | value | ) |
Sets the value on the widget.
value | Unsigned value to set. |
Definition at line 358 of file NumberControl.cc.
References NumberControl::Value::intValue, update(), and value_.
void NumberControl::setValue | ( | const ULongWord | value | ) |
Sets the value on the widget.
value | Integer value to set. |
Definition at line 381 of file NumberControl.cc.
References NumberControl::Value::uLongValue, update(), and value_.
Referenced by MemoryValueDialog::setValue().
void NumberControl::setValue | ( | const unsigned int | value | ) |
Sets the value on the widget.
value | Integer value to set. |
Definition at line 370 of file NumberControl.cc.
References NumberControl::Value::unsignedValue, update(), and value_.
ULongWord NumberControl::uLongValue | ( | ) | const |
unsigned int NumberControl::unsignedValue | ( | ) | const |
Returns the current value.
Definition at line 428 of file NumberControl.cc.
References NumberControl::Value::unsignedValue, and value_.
Referenced by NumberControl().
|
private |
Updates the value on the text field according to the selected mode.
Definition at line 209 of file NumberControl.cc.
References assert, NumberControl::Value::doubleValue, NumberControl::Value::floatValue, NumberControl::Value::intValue, mode_, MODE_BINARY, MODE_DOUBLE, MODE_FLOAT, MODE_HEXADECIMAL, MODE_INT, MODE_UNSIGNED, text_, Conversion::toBinString(), Conversion::toHexString(), Conversion::toString(), WxConversion::toWxString(), NumberControl::Value::unsignedValue, and value_.
Referenced by onText(), setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), setUnsignedMode(), and setValue().
|
private |
Binary input validator.
Definition at line 155 of file NumberControl.hh.
Referenced by setBinMode(), and ~NumberControl().
|
staticprivate |
|
private |
Float input validator.
Definition at line 163 of file NumberControl.hh.
Referenced by setDoubleMode(), setFloatMode(), and ~NumberControl().
|
private |
Hexadecimal input validator.
Definition at line 157 of file NumberControl.hh.
Referenced by setHexMode(), and ~NumberControl().
|
private |
Signed integer input validator.
Definition at line 159 of file NumberControl.hh.
Referenced by setIntMode(), and ~NumberControl().
|
private |
Current mode of the widget.
Definition at line 137 of file NumberControl.hh.
Referenced by mode(), onText(), setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), setUnsignedMode(), and update().
|
static |
Style flag for binary mode availability.
Definition at line 94 of file NumberControl.hh.
Referenced by create(), MemoryValueDialog::createContents(), SimulateDialog::createContents(), onText(), setBinMode(), and update().
|
static |
Style flag for double mode availability.
Definition at line 104 of file NumberControl.hh.
Referenced by create(), SimulateDialog::createContents(), onText(), SimulateDialog::onUpdateValue(), MemoryControl::onWriteMemory(), setDoubleMode(), and update().
|
static |
Style flag for float mode availability.
Definition at line 102 of file NumberControl.hh.
Referenced by create(), MemoryValueDialog::createContents(), SimulateDialog::createContents(), onText(), setFloatMode(), and update().
|
static |
Style flag for hexadecimal mode availability.
Definition at line 100 of file NumberControl.hh.
Referenced by create(), MemoryValueDialog::createContents(), AddressSpaceDialog::createContents(), SimulateDialog::createContents(), onText(), setHexMode(), and update().
|
static |
Style flag for signed integer mode availablity.
Definition at line 96 of file NumberControl.hh.
Referenced by create(), SimulateDialog::createContents(), onText(), setIntMode(), and update().
|
staticprivate |
Choicer item string for the binary mode.
Definition at line 140 of file NumberControl.hh.
Referenced by create(), onModeChoice(), and setBinMode().
|
staticprivate |
Choicer item string for the double mode.
Definition at line 150 of file NumberControl.hh.
Referenced by create(), onModeChoice(), and setDoubleMode().
|
staticprivate |
Choicer item string for the float mode.
Definition at line 148 of file NumberControl.hh.
Referenced by create(), onModeChoice(), and setFloatMode().
|
staticprivate |
Choicer item string for the hexadecimal mode.
Definition at line 142 of file NumberControl.hh.
Referenced by create(), onModeChoice(), and setHexMode().
|
staticprivate |
Choicer item string for the integer mode.
Definition at line 144 of file NumberControl.hh.
Referenced by create(), onModeChoice(), and setIntMode().
|
staticprivate |
Choicer item string for the unsigned mode.
Definition at line 146 of file NumberControl.hh.
Referenced by create(), onModeChoice(), and setUnsignedMode().
|
static |
Style flag for unsigned integer mode availability.
Definition at line 98 of file NumberControl.hh.
Referenced by create(), MemoryValueDialog::createContents(), AddressSpaceDialog::createContents(), SimulateDialog::createContents(), onText(), setUnsignedMode(), and update().
|
private |
Mode choicer widget.
Definition at line 117 of file NumberControl.hh.
Referenced by create(), onModeChoice(), setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), and setUnsignedMode().
|
static |
Style flag for base choicer visibility.
Definition at line 106 of file NumberControl.hh.
Referenced by create().
|
private |
Dummy value string for the validators.
Definition at line 134 of file NumberControl.hh.
Referenced by setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), and setUnsignedMode().
|
private |
Current style flags of the widget.
Definition at line 120 of file NumberControl.hh.
Referenced by create(), setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), and setUnsignedMode().
|
private |
Text field widget.
Definition at line 115 of file NumberControl.hh.
Referenced by create(), onText(), setBinMode(), setDoubleMode(), setFloatMode(), setHexMode(), setIntMode(), setUnsignedMode(), and update().
|
private |
Unsigned integer input validator.
Definition at line 161 of file NumberControl.hh.
Referenced by setUnsignedMode(), and ~NumberControl().
|
private |
Current value of the widget.
Definition at line 131 of file NumberControl.hh.
Referenced by doubleValue(), floatValue(), intValue(), onText(), setValue(), unsignedValue(), and update().