OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
unsigned maxBits_
 Maximum number of bits used by the returned value.
 

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}
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
unsigned maxBits_
Maximum number of bits used by the returned value.
NumberControl * value_
NumberControl for giving new values to memory.

◆ ~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}
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
static const long MODE_FLOAT
Style flag for float mode availability.
static const long MODE_BINARY
Style flag for binary mode availability.
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.

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}
double doubleValue() const

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}
int intValue() const

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}
long mode() const

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}
static std::string toBinary(unsigned int source, unsigned int stringWidth=0)
static wxString toWxString(const std::string &source)

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}
void setValue(const ULongWord value)

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: