OpenASIP  2.0
NumberControl.cc
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.cc
26  *
27  * Implementation 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 #include <string>
34 
35 #include "Application.hh"
36 #include "NumberControl.hh"
37 #include "Conversion.hh"
38 #include "WxConversion.hh"
39 
40 
41 using std::string;
42 
43 // Widget style flags.
44 const long NumberControl::MODE_BINARY = 1;
45 const long NumberControl::MODE_HEXADECIMAL = 2;
46 const long NumberControl::MODE_INT = 4;
47 const long NumberControl::MODE_UNSIGNED = 8;
48 const long NumberControl::MODE_FLOAT = 16;
49 const long NumberControl::MODE_DOUBLE = 32;
50 const long NumberControl::NO_MODE_CHOICER = 64;
51 
52 // String labels for the mode choicer.
53 const wxString NumberControl::MODE_STRING_BIN = _T("bin");
54 const wxString NumberControl::MODE_STRING_HEX = _T("hex");
55 const wxString NumberControl::MODE_STRING_INT = _T("int");
56 const wxString NumberControl::MODE_STRING_UNSIGNED = _T("unsigned");
57 const wxString NumberControl::MODE_STRING_FLOAT = _T("float");
58 const wxString NumberControl::MODE_STRING_DOUBLE = _T("double");
59 
60 // width of the base choicer
61 const int NumberControl::CHOICER_WIDTH = 100;
62 
63 BEGIN_EVENT_TABLE(NumberControl, wxPanel)
64  EVT_CHOICE(ID_BASE, NumberControl::onModeChoice)
65  EVT_TEXT_ENTER(ID_TEXT, NumberControl::onText)
67 
68 
69 /**
70  * The Constructor.
71  *
72  * @param window Parent window of the widget.
73  * @param id ID of the widget.
74  * @param pos Position of the widget.
75  * @param size Size of the widget.
76  * @param style Style flags for the widget, see class comment for list of
77  * available flags.
78  * @param value Initial value of the input.
79  * @param name Name identifier for the widget.
80  * @exception OutOfRange If the value is out of the range.
81  * @exception InvalidData If the minimum value is higher than the maximum.
82  */
84  wxWindow* parent,
85  wxWindowID id,
86  const wxPoint& pos,
87  const wxSize& size,
88  long style,
89  int initial,
90  const wxString& name) :
91  wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL, name),
92  text_(NULL),
93  modeChoice_(NULL),
94  style_(style),
95  stringValue_(_T("")),
96  mode_(0),
97  binValidator_(NULL),
98  hexValidator_(NULL),
99  intValidator_(NULL),
100  unsignedValidator_(NULL),
101  floatValidator_(NULL) {
102 
103  value_.unsignedValue =initial;
104 
105  // Create subwidgets.
106  create(size);
107 }
108 
109 
110 /**
111  * The destructor.
112  */
114  if (binValidator_ != NULL) {
115  delete binValidator_;
116  }
117  if (hexValidator_ != NULL) {
118  delete hexValidator_;
119  }
120  if (intValidator_ != NULL) {
121  delete intValidator_;
122  }
123  if (unsignedValidator_ != NULL) {
124  delete unsignedValidator_;
125  }
126  if (floatValidator_ != NULL) {
127  delete floatValidator_;
128  }
129 }
130 
131 
132 /**
133  * Creates the textfield and optional base choicer subwidgets for the control.
134  */
135 void
136 NumberControl::create(const wxSize& size) {
137 
138  wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
139 
140  int textWidth = size.GetWidth();
141  if ((style_ & NO_MODE_CHOICER) == 0) {
142  textWidth = textWidth - CHOICER_WIDTH;
143  if (textWidth < 20) {
144  textWidth = 20;
145  }
146  }
147 
148  // Create text field widget.
149  text_ =
150  new FocusTrackingTextCtrl(this, ID_TEXT, _T(""), wxDefaultPosition,
151  wxSize(textWidth, -1));
152 
153  sizer->Add(text_, 0, wxALIGN_CENTER_VERTICAL);
154 
155  if ((style_ & NO_MODE_CHOICER) == 0) {
156  // Create base choicer.
157  modeChoice_ = new wxChoice(this, ID_BASE, wxDefaultPosition,
158  wxSize(CHOICER_WIDTH, -1));
159 
160  // append base choices
161  if ((style_ & MODE_BINARY) != 0) {
162  modeChoice_->Append(MODE_STRING_BIN);
163  }
164  if ((style_ & MODE_HEXADECIMAL) != 0) {
165  modeChoice_->Append(MODE_STRING_HEX);
166  }
167  if ((style_ & MODE_INT) != 0) {
168  modeChoice_->Append(MODE_STRING_INT);
169  }
170  if ((style_ & MODE_UNSIGNED) != 0) {
172  }
173  if ((style_ & MODE_FLOAT) != 0) {
175  }
176  if ((style_ & MODE_DOUBLE) != 0) {
178  }
179 
180  sizer->Add(modeChoice_, 0, wxALIGN_CENTER_VERTICAL);
181 
182  // set initial mode
183  if ((style_ & MODE_INT) != 0) {
184  setIntMode();
185  } else if ((style_ & MODE_UNSIGNED) != 0) {
186  setUnsignedMode();
187  } else if ((style_ & MODE_FLOAT) != 0) {
188  setFloatMode();
189  } else if ((style_ & MODE_HEXADECIMAL) != 0) {
190  setHexMode();
191  } else if ((style_ & MODE_BINARY) != 0) {
192  setBinMode();
193  } else if ((style_ & MODE_DOUBLE) != 0) {
194  setDoubleMode();
195  } else {
196  assert(false);
197  }
198  }
199 
200  SetSizer(sizer);
201  Fit();
202 }
203 
204 
205 /**
206  * Updates the value on the text field according to the selected mode.
207  */
208 void
210 
211  // binary mode
212  if (mode_ == MODE_BINARY) {
213  string binString = Conversion::toBinString(value_.intValue);
214  // Strip trailing 'b' from the binary string.
215  binString = binString.substr(0, binString.length() - 1);
216  text_->SetValue(WxConversion::toWxString(binString));
217  return;
218  }
219 
220  // hexadecimal mode
221  if (mode_ == MODE_HEXADECIMAL) {
222  string hexString = Conversion::toHexString(value_.intValue);
223  // Strip '0x' from the begining of the hexstring.
224  hexString = hexString.substr(2, hexString.length() - 2);
225  text_->SetValue(WxConversion::toWxString(hexString));
226  return;
227  }
228 
229  // int mode
230  if (mode_ == MODE_INT) {
231  string intString = Conversion::toString(value_.intValue);
232  text_->SetValue(WxConversion::toWxString(intString));
233  return;
234  }
235 
236  // unsigned mode
237  if (mode_ == MODE_UNSIGNED) {
238  string unsignedString = Conversion::toString(value_.unsignedValue);
239  text_->SetValue(WxConversion::toWxString(unsignedString));
240  return;
241  }
242 
243  // float mode
244  if (mode_ == MODE_FLOAT) {
245  string floatString = Conversion::toString(value_.floatValue);
246  text_->SetValue(WxConversion::toWxString(floatString));
247  return;
248  }
249 
250  // float mode
251  if (mode_ == MODE_DOUBLE) {
252  string doubleString = Conversion::toString(value_.doubleValue);
253  text_->SetValue(WxConversion::toWxString(doubleString));
254  return;
255  }
256 
257  // Error: no mode selected.
258  assert(false);
259 }
260 
261 
262 /**
263  * Event handler, which validates the text field value and transfers data
264  * from the text field to the value variable.
265  *
266  * This event handler is called when user has input new value to the text
267  * field.
268  */
269 void
270 NumberControl::onText(wxCommandEvent&) {
271 
272  string stringValue = WxConversion::toString(text_->GetValue());
273 
274  if (stringValue == "") {
275  value_.intValue = 0;
276  update();
277  wxCommandEvent textEvent(wxEVT_COMMAND_TEXT_UPDATED, GetId());
278  GetParent()->GetEventHandler()->AddPendingEvent(textEvent);
279 
280  return;
281  }
282 
283  try {
284  if (mode_ == MODE_INT) {
285  // int mode
286  value_.intValue = Conversion::toInt(stringValue);
287  } else if (mode_ == MODE_BINARY) {
288  // binary mode
289  stringValue = stringValue + "b";
290  value_.intValue = Conversion::toInt(stringValue);
291  } else if (mode_ == MODE_HEXADECIMAL) {
292  // hexadecimal mode
293  stringValue = "0x" + stringValue;
294  value_.intValue = Conversion::toInt(stringValue);
295  } else if (mode_ == MODE_UNSIGNED) {
296  // unsigned mode
298  } else if (mode_ == MODE_FLOAT) {
299  // float mode
300  value_.floatValue = Conversion::toFloat(stringValue);
301  } else if (mode_ == MODE_DOUBLE) {
302  // double mode
303  value_.doubleValue = Conversion::toDouble(stringValue);
304  } else {
305  assert(false);
306  }
307  } catch (NumberFormatException& e) {
308  // invalid input in the text field
309  value_.intValue = 0;
310  }
311 
312  wxCommandEvent textEvent(wxEVT_COMMAND_TEXT_UPDATED, GetId());
313  GetParent()->GetEventHandler()->AddPendingEvent(textEvent);
314 
315  if (text_->IsModified()) {
316  update();
317  }
318 }
319 
320 
321 /**
322  * Event handler for the mode choicer.
323  *
324  * Updates text field according to the selected mode.
325  */
326 void
327 NumberControl::onModeChoice(wxCommandEvent&) {
328 
329  // Udate the value from the textfield input.
330  wxCommandEvent dummy;
331  onText(dummy);
332 
333  // Set the selected mode.
334  if (modeChoice_->GetStringSelection() == MODE_STRING_BIN) {
335  setBinMode();
336  }else if (modeChoice_->GetStringSelection() == MODE_STRING_HEX) {
337  setHexMode();
338  } else if (modeChoice_->GetStringSelection() == MODE_STRING_INT) {
339  setIntMode();
340  } else if (modeChoice_->GetStringSelection() == MODE_STRING_UNSIGNED) {
341  setUnsignedMode();
342  } else if (modeChoice_->GetStringSelection() == MODE_STRING_FLOAT) {
343  setFloatMode();
344  } else if (modeChoice_->GetStringSelection() == MODE_STRING_DOUBLE) {
345  setDoubleMode();
346  } else {
347  assert(false);
348  }
349 }
350 
351 
352 /**
353  * Sets the value on the widget.
354  *
355  * @param value Unsigned value to set.
356  */
357 void
358 NumberControl::setValue(const int value) {
359  value_.intValue = value;
360  update();
361 }
362 
363 
364 /**
365  * Sets the value on the widget.
366  *
367  * @param value Integer value to set.
368  */
369 void
370 NumberControl::setValue(const unsigned int value) {
371  value_.unsignedValue = value;
372  update();
373 }
374 
375 /**
376  * Sets the value on the widget.
377  *
378  * @param value Integer value to set.
379  */
380 void
382  value_.uLongValue = value;
383  update();
384 }
385 
386 
387 /**
388  * Sets the value on the widget.
389  *
390  * @param value Float value to set.
391  */
392 void
393 NumberControl::setValue(const float value) {
394  value_.floatValue = value;
395  update();
396 }
397 
398 
399 /**
400  * Sets the value on the widget.
401  *
402  * @param value Double value to set.
403  */
404 void
405 NumberControl::setValue(const double value) {
406  value_.doubleValue = value;
407  update();
408 }
409 
410 
411 /**
412  * Returns the current value.
413  *
414  * @return Current value of the widget as int.
415  */
416 int
418  return value_.intValue;
419 }
420 
421 
422 /**
423  * Returns the current value.
424  *
425  * @return Current value of the widget as unsigned int
426  */
427 unsigned int
429  return value_.unsignedValue;
430 }
431 
432 
433 /**
434  * Returns the current value.
435  *
436  * @return Current value of the widget as float.
437  */
438 float
440  return value_.floatValue;
441 }
442 
443 
444 /**
445  * Returns the current value.
446  *
447  * @return Current value of the widget as double.
448  */
449 double
451  return value_.doubleValue;
452 }
453 
454 
455 /**
456  * Sets the widget to int mode.
457  *
458  * @exception NotAvailable If the MODE_INT style was not specified to the
459  * constructor.
460  */
461 void
463  // Check that the int mode is available.
464  if ((style_ & MODE_INT) == 0) {
465  // Int mode not available.
466  string procName = "NubmerControl::setIntMode";
467  throw NotAvailable(__FILE__, __LINE__, procName);
468  }
469 
470  // Create decimal input validator if necessary.
471  if (intValidator_ == NULL) {
472  intValidator_ = new wxTextValidator(wxFILTER_NUMERIC, &stringValue_);
473  }
474 
475  // Set the decimal validator and update the widget.
476  text_->SetValidator(*intValidator_);
477  mode_ = MODE_INT;
478  if (modeChoice_ != NULL &&
479  modeChoice_->GetStringSelection() != MODE_STRING_INT) {
480 
481  modeChoice_->SetStringSelection(MODE_STRING_INT);
482  }
483  update();
484 }
485 
486 /**
487  * Sets the widget to binary mode.
488  *
489  * @exception NotAvailable If the MODE_BINARY style was not specified to the
490  * contructor.
491  */
492 void
494  // Check that the binary mode is available.
495  if ((style_ & MODE_BINARY) == 0) {
496  // Binary mode not available.
497  string procName = "NubmerControl::setBinMode";
498  throw NotAvailable(__FILE__, __LINE__, procName);
499  }
500 
501  // Create binary input validator if necessary.
502  if (binValidator_ == NULL) {
503  binValidator_ =
504  new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST, &stringValue_);
505 
506 #if wxCHECK_VERSION(2, 5, 4)
507  wxArrayString includes;
508  includes.Add(_T("0"));
509  includes.Add(_T("1"));
510  binValidator_->SetIncludes(includes);
511 #else
512  binValidator_->SetIncludeList(
513  wxStringList(_T("0"), _T("1"), NULL));
514 #endif
515 
516  }
517 
518  // Set the binary validator and update the widget.
519  text_->SetValidator(*binValidator_);
520  mode_ = MODE_BINARY;
521  if (modeChoice_ != NULL &&
522  modeChoice_->GetStringSelection() != MODE_STRING_BIN) {
523 
524  modeChoice_->SetStringSelection(MODE_STRING_BIN);
525  }
526  update();
527 }
528 
529 /**
530  * Sets the widget to hexadecimal mode.
531  *
532  * @exception NotAvailable If the MODE_HEXADECIMAL was not specified to the
533  * constructor.
534  */
535 void
537  // Check that the hexadecimal mode is available.
538  if ((style_ & MODE_HEXADECIMAL) == 0) {
539  // Hexadecimal mode not available.
540  string procName = "NubmerControl::setHexMode";
541  throw NotAvailable(__FILE__, __LINE__, procName);
542  }
543 
544  // Create hexadecimal input validator if necessary.
545  if (hexValidator_ == NULL) {
546  hexValidator_ =
547  new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST, &stringValue_);
548 
549 #if wxCHECK_VERSION(2, 5, 4)
550  wxArrayString includes;
551  includes.Add(_T("0"));
552  includes.Add(_T("1"));
553  includes.Add(_T("2"));
554  includes.Add(_T("3"));
555  includes.Add(_T("4"));
556  includes.Add(_T("5"));
557  includes.Add(_T("6"));
558  includes.Add(_T("7"));
559  includes.Add(_T("8"));
560  includes.Add(_T("9"));
561  includes.Add(_T("a"));
562  includes.Add(_T("b"));
563  includes.Add(_T("c"));
564  includes.Add(_T("d"));
565  includes.Add(_T("e"));
566  includes.Add(_T("f"));
567  includes.Add(_T("A"));
568  includes.Add(_T("B"));
569  includes.Add(_T("C"));
570  includes.Add(_T("D"));
571  includes.Add(_T("E"));
572  includes.Add(_T("F"));
573  hexValidator_->SetIncludes(includes);
574 #else
575  hexValidator_->SetIncludeList(
576  wxStringList(_T("0"), _T("1"), _T("2"), _T("3"), _T("4"), _T("5"),
577  _T("6"), _T("7"), _T("8"), _T("9"),
578  _T("a"), _T("b"), _T("c"), _T("d"), _T("e"), _T("f"),
579  _T("A"), _T("B"), _T("C"), _T("D"),
580  _T("E"), _T("F"), NULL));
581 #endif
582  }
583 
584  // Set the hexadecimal validator and update the widget.
585  text_->SetValidator(*hexValidator_);
587  if (modeChoice_ != NULL &&
588  modeChoice_->GetStringSelection() != MODE_STRING_HEX) {
589 
590  modeChoice_->SetStringSelection(MODE_STRING_HEX);
591  }
592  update();
593 }
594 
595 /**
596  * Sets the widget to unsigned int mode.
597  *
598  * @exception NotAvailable If the MODE_UNSIGNED style was not specified to the
599  * constructor.
600  */
601 void
603  // Check that the unsigned mode is available.
604  if ((style_ & MODE_UNSIGNED) == 0) {
605  // Unsigned mode not available.
606  string procName = "NubmerControl::setUnsignedMode";
607  throw NotAvailable(__FILE__, __LINE__, procName);
608  }
609 
610  // Create decimal input validator if necessary.
611  if (unsignedValidator_ == NULL) {
613  new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST, &stringValue_);
614 
615 #if wxCHECK_VERSION(2, 5, 4)
616  wxArrayString includes;
617  includes.Add(_T("0"));
618  includes.Add(_T("1"));
619  includes.Add(_T("2"));
620  includes.Add(_T("3"));
621  includes.Add(_T("4"));
622  includes.Add(_T("5"));
623  includes.Add(_T("6"));
624  includes.Add(_T("7"));
625  includes.Add(_T("8"));
626  includes.Add(_T("9"));
627  unsignedValidator_->SetIncludes(includes);
628 #else
629  unsignedValidator_->SetIncludeList(
630  wxStringList(_T("0"), _T("1"), _T("2"), _T("3"), _T("4"), _T("5"),
631  _T("6"), _T("7"), _T("8"), _T("9"), NULL));
632 #endif
633  }
634 
635  // Set the decimal validator and update the widget.
636  text_->SetValidator(*unsignedValidator_);
638  if (modeChoice_ != NULL &&
639  modeChoice_->GetStringSelection() != MODE_STRING_UNSIGNED) {
640 
641  modeChoice_->SetStringSelection(MODE_STRING_UNSIGNED);
642  }
643  update();
644 }
645 
646 /**
647  * Sets the widget to float mode.
648  *
649  * @exception NotAvailable If the MODE_FLOAT style was not specified to the
650  * constructor.
651  */
652 void
654  // Check that the float mode is available.
655  if ((style_ & MODE_FLOAT) == 0) {
656  // Float mode not available.
657  string procName = "NubmerControl::setFloatMode";
658  throw NotAvailable(__FILE__, __LINE__, procName);
659  }
660 
661  // Create float input validator if necessary.
662  if (floatValidator_ == NULL) {
664  new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST, &stringValue_);
665 
666 #if wxCHECK_VERSION(2, 5, 4)
667  wxArrayString includes;
668  includes.Add(_T("0"));
669  includes.Add(_T("1"));
670  includes.Add(_T("2"));
671  includes.Add(_T("3"));
672  includes.Add(_T("4"));
673  includes.Add(_T("5"));
674  includes.Add(_T("6"));
675  includes.Add(_T("7"));
676  includes.Add(_T("8"));
677  includes.Add(_T("9"));
678  includes.Add(_T("e"));
679  includes.Add(_T("."));
680  includes.Add(_T("-"));
681  includes.Add(_T("+"));
682  floatValidator_->SetIncludes(includes);
683 #else
684  floatValidator_->SetIncludeList(
685  wxStringList(_T("0"), _T("1"), _T("2"), _T("3"), _T("4"),
686  _T("5"), _T("6"), _T("7"), _T("8"), _T("9"),
687  _T("e"), _T("."), _T("-"), _T("+"), NULL));
688 #endif
689  }
690 
691  // Set the float validator and update the widget.
692  text_->SetValidator(*floatValidator_);
693  mode_ = MODE_FLOAT;
694  if (modeChoice_ != NULL &&
695  modeChoice_->GetStringSelection() != MODE_STRING_FLOAT) {
696 
697  modeChoice_->SetStringSelection(MODE_STRING_FLOAT);
698  }
699  update();
700 }
701 
702 /**
703  * Sets the widget to double mode.
704  *
705  * @exception NotAvailable If the MODE_DOUBLE style was not specified to the
706  * constructor.
707  */
708 void
710  // Check that the double mode is available.
711  if ((style_ & MODE_DOUBLE) == 0) {
712  // Double mode not available.
713  string procName = "NubmerControl::setDoubleMode";
714  throw NotAvailable(__FILE__, __LINE__, procName);
715  }
716 
717  // Create float/double input validator if necessary.
718  if (floatValidator_ == NULL) {
720  new wxTextValidator(wxFILTER_INCLUDE_CHAR_LIST, &stringValue_);
721 
722 #if wxCHECK_VERSION(2, 5, 4)
723  wxArrayString includes;
724  includes.Add(_T("0"));
725  includes.Add(_T("1"));
726  includes.Add(_T("2"));
727  includes.Add(_T("3"));
728  includes.Add(_T("4"));
729  includes.Add(_T("5"));
730  includes.Add(_T("6"));
731  includes.Add(_T("7"));
732  includes.Add(_T("8"));
733  includes.Add(_T("9"));
734  includes.Add(_T("e"));
735  includes.Add(_T("."));
736  includes.Add(_T("-"));
737  includes.Add(_T("+"));
738  floatValidator_->SetIncludes(includes);
739 #else
740  floatValidator_->SetIncludeList(
741  wxStringList(_T("0"), _T("1"), _T("2"), _T("3"), _T("4"),
742  _T("5"), _T("6"), _T("7"), _T("8"), _T("9"),
743  _T("e"), _T("."), _T("-"), _T("+"), NULL));
744 #endif
745  }
746 
747  // Set the float/double validator and update the widget.
748  text_->SetValidator(*floatValidator_);
749  mode_ = MODE_DOUBLE;
750  if (modeChoice_ != NULL &&
751  modeChoice_->GetStringSelection() != MODE_STRING_DOUBLE) {
752 
753  modeChoice_->SetStringSelection(MODE_STRING_DOUBLE);
754  }
755  update();
756 }
757 
758 /**
759  * Returns the widget mode style flag.
760  *
761  * @return Current mode of the widget.
762  */
763 long
765  return mode_;
766 }
NumberControl::update
void update()
Definition: NumberControl.cc:209
NumberControl::unsignedValue
unsigned int unsignedValue() const
Definition: NumberControl.cc:428
NumberControl::value_
Value value_
Current value of the widget.
Definition: NumberControl.hh:131
WxConversion::toWxString
static wxString toWxString(const std::string &source)
NumberFormatException
Definition: Exception.hh:421
NumberControl::MODE_STRING_DOUBLE
static const wxString MODE_STRING_DOUBLE
Choicer item string for the double mode.
Definition: NumberControl.hh:150
NumberControl::CHOICER_WIDTH
static const int CHOICER_WIDTH
Mode choicer width.
Definition: NumberControl.hh:152
NumberControl::MODE_STRING_INT
static const wxString MODE_STRING_INT
Choicer item string for the integer mode.
Definition: NumberControl.hh:144
NumberControl::setUnsignedMode
void setUnsignedMode()
Definition: NumberControl.cc:602
NumberControl::floatValidator_
wxTextValidator * floatValidator_
Float input validator.
Definition: NumberControl.hh:163
NumberControl::MODE_STRING_HEX
static const wxString MODE_STRING_HEX
Choicer item string for the hexadecimal mode.
Definition: NumberControl.hh:142
NumberControl::setValue
void setValue(const ULongWord value)
Definition: NumberControl.cc:381
NumberControl::setIntMode
void setIntMode()
Definition: NumberControl.cc:462
NumberControl::mode
long mode() const
Definition: NumberControl.cc:764
Conversion::toString
static std::string toString(const T &source)
NotAvailable
Definition: Exception.hh:728
NumberControl::style_
long style_
Current style flags of the widget.
Definition: NumberControl.hh:120
assert
#define assert(condition)
Definition: Application.hh:86
Conversion::toDouble
static double toDouble(const T &source)
NumberControl::Value::intValue
int intValue
Definition: NumberControl.hh:125
NumberControl::onText
void onText(wxCommandEvent &event)
Definition: NumberControl.cc:270
NumberControl::Value::unsignedValue
unsigned int unsignedValue
Definition: NumberControl.hh:124
NumberControl::intValue
int intValue() const
Definition: NumberControl.cc:417
NumberControl::doubleValue
double doubleValue() const
Definition: NumberControl.cc:450
NumberControl.hh
Conversion.hh
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
NumberControl::setDoubleMode
void setDoubleMode()
Definition: NumberControl.cc:709
Application.hh
NumberControl::floatValue
float floatValue() const
Definition: NumberControl.cc:439
NumberControl::setBinMode
void setBinMode()
Definition: NumberControl.cc:493
NumberControl::~NumberControl
virtual ~NumberControl()
Definition: NumberControl.cc:113
NumberControl::Value::doubleValue
double doubleValue
Definition: NumberControl.hh:127
NumberControl::MODE_STRING_UNSIGNED
static const wxString MODE_STRING_UNSIGNED
Choicer item string for the unsigned mode.
Definition: NumberControl.hh:146
NumberControl::text_
FocusTrackingTextCtrl * text_
Text field widget.
Definition: NumberControl.hh:115
NumberControl::MODE_INT
static const long MODE_INT
Style flag for signed integer mode availablity.
Definition: NumberControl.hh:96
Conversion::toHexString
static std::string toHexString(T source, std::size_t digits=0, bool include0x=true)
NumberControl::MODE_STRING_FLOAT
static const wxString MODE_STRING_FLOAT
Choicer item string for the float mode.
Definition: NumberControl.hh:148
NumberControl::NO_MODE_CHOICER
static const long NO_MODE_CHOICER
Style flag for base choicer visibility.
Definition: NumberControl.hh:106
NumberControl::MODE_UNSIGNED
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
Definition: NumberControl.hh:98
NumberControl::hexValidator_
wxTextValidator * hexValidator_
Hexadecimal input validator.
Definition: NumberControl.hh:157
Conversion::toUnsignedInt
static unsigned int toUnsignedInt(const T &source)
NumberControl::MODE_STRING_BIN
static const wxString MODE_STRING_BIN
Choicer item string for the binary mode.
Definition: NumberControl.hh:140
NumberControl::MODE_HEXADECIMAL
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.
Definition: NumberControl.hh:100
NumberControl::modeChoice_
wxChoice * modeChoice_
Mode choicer widget.
Definition: NumberControl.hh:117
NumberControl::mode_
long mode_
Current mode of the widget.
Definition: NumberControl.hh:137
NumberControl::MODE_BINARY
static const long MODE_BINARY
Style flag for binary mode availability.
Definition: NumberControl.hh:94
NumberControl::Value::floatValue
float floatValue
Definition: NumberControl.hh:126
Conversion::toBinString
static std::string toBinString(int source)
Definition: Conversion.cc:81
NumberControl
Definition: NumberControl.hh:59
NumberControl::ID_BASE
@ ID_BASE
Definition: NumberControl.hh:167
ULongWord
unsigned long ULongWord
Definition: BaseType.hh:51
WxConversion.hh
NumberControl::unsignedValidator_
wxTextValidator * unsignedValidator_
Unsigned integer input validator.
Definition: NumberControl.hh:161
NumberControl::setHexMode
void setHexMode()
Definition: NumberControl.cc:536
NumberControl::Value::uLongValue
ULongWord uLongValue
Definition: NumberControl.hh:123
Conversion::toInt
static int toInt(const T &source)
NumberControl::intValidator_
wxTextValidator * intValidator_
Signed integer input validator.
Definition: NumberControl.hh:159
FocusTrackingTextCtrl
Definition: FocusTrackingTextCtrl.hh:47
NumberControl::binValidator_
wxTextValidator * binValidator_
Binary input validator.
Definition: NumberControl.hh:155
NumberControl::ID_TEXT
@ ID_TEXT
Definition: NumberControl.hh:168
WxConversion::toString
static std::string toString(const wxString &source)
NumberControl::setFloatMode
void setFloatMode()
Definition: NumberControl.cc:653
NumberControl::MODE_FLOAT
static const long MODE_FLOAT
Style flag for float mode availability.
Definition: NumberControl.hh:102
NumberControl::stringValue_
wxString stringValue_
Dummy value string for the validators.
Definition: NumberControl.hh:134
NumberControl::create
void create(const wxSize &size)
Definition: NumberControl.cc:136
NumberControl::MODE_DOUBLE
static const long MODE_DOUBLE
Style flag for double mode availability.
Definition: NumberControl.hh:104
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
Conversion::toFloat
static float toFloat(const T &source)
NumberControl::onModeChoice
void onModeChoice(wxCommandEvent &event)
Definition: NumberControl.cc:327