OpenASIP 2.2
Loading...
Searching...
No Matches
NumberControl.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file NumberControl.hh
26 *
27 * Declaration of NumberControl class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_NUMBER_CONTROL_HH
34#define TTA_NUMBER_CONTROL_HH
35
36#include <wx/wx.h>
37
38#include "Exception.hh"
40#include "BaseType.hh"
41
42/**
43 * Text field widget for numeric value input.
44 *
45 * The widget value can be modified in hexadecimal, binary, int, unsigned int
46 * and floating point format. The widget value is always the same four
47 * bytes of memory, and the bit pattern is interpreted depending on the
48 * selected mode. Text field mode can be selected using an optional
49 * mode choicer. Available modes for the choicer are selected by passing the
50 * following style flags to the constructor:
51 * MODE_HEXADECIMAL, MODE_BINARY, MODE_INT, MODE_UNSIGNED, MODE_FLOAT and
52 * MODE_DOUBLE
53 *
54 * Note that the extra bits in the double value is ignored when the mode
55 * is changed from double to any of the other modes.
56 *
57 * The mode choicer widget can be disabled by using NO_MODE_CHOICER style flag.
58 */
59class NumberControl : public wxPanel {
60public:
62 wxWindow* parent,
63 wxWindowID id = -1,
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize,
66 long style = (MODE_HEXADECIMAL | MODE_BINARY |
68 int initial = 0,
69 const wxString& name = _T("NumberControl"));
70 virtual ~NumberControl();
71
72 int intValue() const;
73 unsigned int unsignedValue() const;
74 float floatValue() const;
75 double doubleValue() const;
77
78 long mode() const;
79
80 void setBinMode();
81 void setHexMode();
82 void setIntMode();
83 void setUnsignedMode();
84 void setFloatMode();
85 void setDoubleMode();
86
87 void setValue(const ULongWord value);
88 void setValue(const unsigned int value);
89 void setValue(const int value);
90 void setValue(const float value);
91 void setValue(const double value);
92
93 /// Style flag for binary mode availability.
94 static const long MODE_BINARY;
95 /// Style flag for signed integer mode availablity.
96 static const long MODE_INT;
97 /// Style flag for unsigned integer mode availability.
98 static const long MODE_UNSIGNED;
99 /// Style flag for hexadecimal mode availability.
100 static const long MODE_HEXADECIMAL;
101 /// Style flag for float mode availability.
102 static const long MODE_FLOAT;
103 /// Style flag for double mode availability.
104 static const long MODE_DOUBLE;
105 /// Style flag for base choicer visibility.
106 static const long NO_MODE_CHOICER;
107
108private:
109 void create(const wxSize& size);
110 void update();
111 void onModeChoice(wxCommandEvent& event);
112 void onText(wxCommandEvent& event);
113
114 /// Text field widget.
116 /// Mode choicer widget.
117 wxChoice* modeChoice_;
118
119 /// Current style flags of the widget.
120 long style_;
121
129
130 /// Current value of the widget.
132
133 /// Dummy value string for the validators.
134 wxString stringValue_;
135
136 /// Current mode of the widget.
137 long mode_;
138
139 /// Choicer item string for the binary mode.
140 static const wxString MODE_STRING_BIN;
141 /// Choicer item string for the hexadecimal mode.
142 static const wxString MODE_STRING_HEX;
143 /// Choicer item string for the integer mode.
144 static const wxString MODE_STRING_INT;
145 /// Choicer item string for the unsigned mode.
146 static const wxString MODE_STRING_UNSIGNED;
147 /// Choicer item string for the float mode.
148 static const wxString MODE_STRING_FLOAT;
149 /// Choicer item string for the double mode.
150 static const wxString MODE_STRING_DOUBLE;
151 /// Mode choicer width.
152 static const int CHOICER_WIDTH;
153
154 /// Binary input validator.
155 wxTextValidator* binValidator_;
156 /// Hexadecimal input validator.
157 wxTextValidator* hexValidator_;
158 /// Signed integer input validator.
159 wxTextValidator* intValidator_;
160 /// Unsigned integer input validator.
161 wxTextValidator* unsignedValidator_;
162 /// Float input validator.
163 wxTextValidator* floatValidator_;
164
165 /// IDs for the subwidgets.
166 enum {
167 ID_BASE = 20000,
168 ID_TEXT
169 };
170
171 DECLARE_EVENT_TABLE()
172};
173
174#endif
unsigned long ULongWord
Definition BaseType.hh:51
int intValue() const
static const long NO_MODE_CHOICER
Style flag for base choicer visibility.
wxString stringValue_
Dummy value string for the validators.
static const wxString MODE_STRING_BIN
Choicer item string for the binary mode.
unsigned int unsignedValue() const
static const long MODE_INT
Style flag for signed integer mode availablity.
wxTextValidator * hexValidator_
Hexadecimal input validator.
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
static const wxString MODE_STRING_DOUBLE
Choicer item string for the double mode.
FocusTrackingTextCtrl * text_
Text field widget.
void onModeChoice(wxCommandEvent &event)
ULongWord uLongValue() const
static const long MODE_DOUBLE
Style flag for double mode availability.
static const long MODE_FLOAT
Style flag for float mode availability.
virtual ~NumberControl()
wxTextValidator * intValidator_
Signed integer input validator.
void create(const wxSize &size)
static const wxString MODE_STRING_UNSIGNED
Choicer item string for the unsigned mode.
wxTextValidator * binValidator_
Binary input validator.
double doubleValue() const
void setValue(const ULongWord value)
static const long MODE_BINARY
Style flag for binary mode availability.
static const wxString MODE_STRING_INT
Choicer item string for the integer mode.
wxTextValidator * unsignedValidator_
Unsigned integer input validator.
wxChoice * modeChoice_
Mode choicer widget.
long style_
Current style flags of the widget.
void onText(wxCommandEvent &event)
long mode() const
wxTextValidator * floatValidator_
Float input validator.
float floatValue() const
static const wxString MODE_STRING_HEX
Choicer item string for the hexadecimal mode.
long mode_
Current mode of the widget.
static const wxString MODE_STRING_FLOAT
Choicer item string for the float mode.
Value value_
Current value of the widget.
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.
static const int CHOICER_WIDTH
Mode choicer width.
unsigned int unsignedValue