OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MemoryValueDialog Class Reference

#include <MemoryValueDialog.hh>

Inheritance diagram for MemoryValueDialog:
Inheritance graph
Collaboration diagram for MemoryValueDialog:
Collaboration graph

Public Member Functions

 MemoryValueDialog (wxWindow *parent, unsigned maxBits=64)
 
virtual ~MemoryValueDialog ()
 
void setValue (int value)
 
long mode ()
 
int intValue ()
 
double doubleValue ()
 

Private Types

enum  { ID_VALUE = 10000 }
 

Private Member Functions

void onOK (wxCommandEvent &event)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

NumberControlvalue_
 NumberControl for giving new values to memory. More...
 
unsigned maxBits_
 Maximum number of bits used by the returned value. More...
 

Detailed Description

Class for giving new values to memory addresses.

Definition at line 44 of file MemoryValueDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Widget ids.

Enumerator
ID_VALUE 

Definition at line 62 of file MemoryValueDialog.hh.

62  {
63  ID_VALUE = 10000
64  };

Constructor & Destructor Documentation

◆ MemoryValueDialog()

MemoryValueDialog::MemoryValueDialog ( wxWindow *  parent,
unsigned  maxBits = 64 
)

Constructor.

Parameters
parentParent window.
posPosition of the dialog.

Definition at line 51 of file MemoryValueDialog.cc.

51  :
52  wxDialog(parent, -1, _T("Memory value"), wxDefaultPosition,
53  wxDefaultSize),
54  maxBits_(maxBits) {
55 
56  createContents(this, true, true);
57  value_ = dynamic_cast<NumberControl*>(FindWindow(ID_VALUE));
58 }

◆ ~MemoryValueDialog()

MemoryValueDialog::~MemoryValueDialog ( )
virtual

Destructor.

Definition at line 63 of file MemoryValueDialog.cc.

63  {
64 }

Member Function Documentation

◆ createContents()

wxSizer * MemoryValueDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the contents of the dialog.

Parameters
parentThe parent window.
call_fitIf true fits the contents inside the dialog.
set_sizerIf true sets the main sizer as dialog contents.
Returns
The created sizer.

Definition at line 137 of file MemoryValueDialog.cc.

140  {
141 
142  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
143 
144  wxWindow *item1 = new NumberControl(
145  parent, ID_VALUE, wxDefaultPosition,
146  wxSize(240, -1), NumberControl::MODE_BINARY |
149 
150  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
151 
152  wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
153 
154  wxButton *item3 = new wxButton( parent, wxID_OK, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );
155  item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
156 
157  wxButton *item4 = new wxButton( parent, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
158  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
159 
160  item0->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
161 
162  if (set_sizer)
163  {
164  parent->SetSizer( item0 );
165  if (call_fit)
166  item0->SetSizeHints( parent );
167  }
168 
169  return item0;
170 }

References ID_VALUE, NumberControl::MODE_BINARY, NumberControl::MODE_FLOAT, NumberControl::MODE_HEXADECIMAL, and NumberControl::MODE_UNSIGNED.

◆ doubleValue()

double MemoryValueDialog::doubleValue ( )

Returns the value user typed.

Returns
User given value as double.

Definition at line 102 of file MemoryValueDialog.cc.

102  {
103  return value_->doubleValue();
104 }

References NumberControl::doubleValue(), and value_.

Referenced by MemoryControl::onWriteMemory().

Here is the call graph for this function:

◆ intValue()

int MemoryValueDialog::intValue ( )

Returns the value user typed.

Returns
User given value.

Definition at line 92 of file MemoryValueDialog.cc.

92  {
93  return value_->intValue();
94 }

References NumberControl::intValue(), and value_.

Referenced by onOK(), and MemoryControl::onWriteMemory().

Here is the call graph for this function:

◆ mode()

long MemoryValueDialog::mode ( )

Returns the mode of the number control.

Returns
The mode.

Definition at line 72 of file MemoryValueDialog.cc.

72  {
73  return value_->mode();
74 }

References NumberControl::mode(), and value_.

Referenced by MemoryControl::onWriteMemory().

Here is the call graph for this function:

◆ onOK()

void MemoryValueDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the OK button.

Checks that the value doesn't use more than maximum number of bits allowed.

Definition at line 112 of file MemoryValueDialog.cc.

112  {
113 
114  std::string binary = Conversion::toBinary(intValue());
115  if (binary.length() > maxBits_) {
116  wxString message = _T("Bit width of the value exceeds the maximum");
117  message.Append(_T(" bit width of "));
118  message.Append(WxConversion::toWxString(maxBits_));
119  message.Append(_T("."));
120  InformationDialog dialog(this, message);
121  dialog.ShowModal();
122  return;
123  }
124 
125  EndModal(wxID_OK);
126 }

References intValue(), maxBits_, Conversion::toBinary(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ setValue()

void MemoryValueDialog::setValue ( int  value)

Sets the value.

Parameters
valueValue to be set.

Definition at line 82 of file MemoryValueDialog.cc.

82  {
83  value_->setValue(value);
84 }

References NumberControl::setValue(), and value_.

Referenced by MemoryControl::onWriteMemory().

Here is the call graph for this function:

Member Data Documentation

◆ maxBits_

unsigned MemoryValueDialog::maxBits_
private

Maximum number of bits used by the returned value.

Definition at line 69 of file MemoryValueDialog.hh.

Referenced by onOK().

◆ value_

NumberControl* MemoryValueDialog::value_
private

NumberControl for giving new values to memory.

Definition at line 67 of file MemoryValueDialog.hh.

Referenced by doubleValue(), intValue(), mode(), and setValue().


The documentation for this class was generated from the following files:
MemoryValueDialog::intValue
int intValue()
Definition: MemoryValueDialog.cc:92
WxConversion::toWxString
static wxString toWxString(const std::string &source)
MemoryValueDialog::maxBits_
unsigned maxBits_
Maximum number of bits used by the returned value.
Definition: MemoryValueDialog.hh:69
MemoryValueDialog::ID_VALUE
@ ID_VALUE
Definition: MemoryValueDialog.hh:63
MemoryValueDialog::value_
NumberControl * value_
NumberControl for giving new values to memory.
Definition: MemoryValueDialog.hh:67
NumberControl::setValue
void setValue(const ULongWord value)
Definition: NumberControl.cc:381
MemoryValueDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: MemoryValueDialog.cc:137
FindWindow
Definition: FindWindow.hh:49
NumberControl::mode
long mode() const
Definition: NumberControl.cc:764
Conversion::toBinary
static std::string toBinary(unsigned int source, unsigned int stringWidth=0)
Definition: Conversion.cc:155
NumberControl::intValue
int intValue() const
Definition: NumberControl.cc:417
NumberControl::doubleValue
double doubleValue() const
Definition: NumberControl.cc:450
NumberControl::MODE_UNSIGNED
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
Definition: NumberControl.hh:98
NumberControl::MODE_HEXADECIMAL
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.
Definition: NumberControl.hh:100
NumberControl::MODE_BINARY
static const long MODE_BINARY
Style flag for binary mode availability.
Definition: NumberControl.hh:94
NumberControl
Definition: NumberControl.hh:59
InformationDialog
Definition: InformationDialog.hh:42
NumberControl::MODE_FLOAT
static const long MODE_FLOAT
Style flag for float mode availability.
Definition: NumberControl.hh:102