OpenASIP  2.0
ProximUnitWindow.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 ProximUnitWindow.cc
26  *
27  * Definition of ProximUnitWindow class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 
34 #include <string>
35 #include <wx/statline.h>
36 #include <wx/listctrl.h>
37 
38 #include "ProximUnitWindow.hh"
39 #include "Proxim.hh"
40 #include "WxConversion.hh"
43 
44 
45 BEGIN_EVENT_TABLE(ProximUnitWindow, wxPanel)
48  EVT_CHOICE(ID_UNIT_CHOICE, ProximUnitWindow::onChoice)
49  EVT_CHOICE(ID_MODE_CHOICE, ProximUnitWindow::onChoice)
52 
53 using std::string;
54 using namespace TTAMachine;
55 
56 const wxString ProximUnitWindow::MODE_INT = _T("Int");
57 const wxString ProximUnitWindow::MODE_UNSIGNED = _T("Unsigned");
58 const wxString ProximUnitWindow::MODE_HEX = _T("Hex");
59 const wxString ProximUnitWindow::MODE_BIN = _T("Binary");
60 
61 /**
62  * Constructor.
63  *
64  * @param parent Parent window of the window.
65  * @param id Window identifier.
66  */
68  ProximMainFrame* parent, int id):
69  ProximSimulatorWindow(parent, id),
70  unitChoice_(NULL),
71  valueList_(NULL) {
72 
73  createContents(this, true, true);
74 
75  simulator_ = wxGetApp().simulation()->frontend();
76 
77  unitChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_UNIT_CHOICE));
78  modeChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_MODE_CHOICE));
79  valueList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_VALUE_LIST));
80 
81  modeChoice_->Append(MODE_INT);
82  modeChoice_->Append(MODE_UNSIGNED);
83  modeChoice_->Append(MODE_HEX);
84  modeChoice_->Append(MODE_BIN);
85  modeChoice_->SetSelection(0);
86 
87 }
88 
89 
90 /**
91  * Destructor.
92  */
94 }
95 
96 
97 /**
98  * Called when the unit choicer needs to be reinitialized.
99  */
100 void
102 }
103 
104 
105 /**
106  * Event handler which is called when a new program is loaded in the simulator.
107  */
108 void
110  reinitialize();
111 }
112 
113 
114 /**
115  * Called when the value list needs to be updated.
116  */
117 void
119 }
120 
121 
122 /**
123  * Event handler for simulation stop.
124  *
125  * Updates the value list.
126  */
127 void
129  update();
130 }
131 
132 
133 /**
134  * Event handler for the dialog mode and unit choicers.
135  *
136  * Updates the values list.
137  */
138 void
139 ProximUnitWindow::onChoice(wxCommandEvent&) {
140  update();
141 }
142 
143 /**
144  * Event handler for the Close button.
145  *
146  * Closes the window by destroying the parent frame of the window.
147  */
148 void
149 ProximUnitWindow::onClose(wxCommandEvent&) {
150  wxFrame* parent = dynamic_cast<wxFrame*>(GetParent());
151  if (parent != NULL) {
152  parent->Destroy();
153  }
154 }
155 
156 
157 /**
158  * Creates the window contents.
159  *
160  * Code generated by wxWidgets.
161  *
162  * @param parent Parent window of the dialog contents.
163  * @param call_fit If true, created contents are fit inside the parent window.
164  * @param set_sizer If true, created top level sizer is set as the parent
165  * window contents.
166  * @return Top level sizer of the created widgets.
167  */
168 wxSizer*
170  wxWindow* parent, bool call_fit, bool set_sizer) {
171 
172  wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
173  item0->AddGrowableCol( 0 );
174  item0->AddGrowableRow( 2 );
175 
176  wxGridSizer *item1 = new wxGridSizer( 2, 0, 0 );
177 
178  wxString *strs2 = (wxString*) NULL;
179  wxChoice *item2 = new wxChoice( parent, ID_UNIT_CHOICE, wxDefaultPosition, wxSize(120,-1), 0, strs2, 0 );
180  item1->Add( item2, 0, wxGROW|wxALL, 5 );
181 
182  wxString *strs3 = (wxString*) NULL;
183  wxChoice *item3 = new wxChoice( parent, ID_MODE_CHOICE, wxDefaultPosition, wxSize(120,-1), 0, strs3, 0 );
184  item1->Add( item3, 0, wxGROW|wxALL, 5 );
185 
186  item0->Add( item1, 0, wxGROW|wxALL, 5 );
187 
188  wxStaticLine *item4 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
189  item0->Add( item4, 0, wxGROW|wxALL, 5 );
190 
191  wxListCtrl *item5 = new wxListCtrl( parent, ID_VALUE_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER );
192  item0->Add( item5, 0, wxGROW|wxALL, 5 );
193 
194  wxStaticLine *item6 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
195  item0->Add( item6, 0, wxGROW|wxALL, 5 );
196 
197  wxGridSizer *item7 = new wxGridSizer( 2, 0, 0 );
198 
199  wxButton *item8 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
200  item7->Add( item8, 0, wxALIGN_CENTER_VERTICAL, 5 );
201 
202  wxButton *item9 = new wxButton( parent, ID_CLOSE, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
203  item7->Add( item9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
204 
205  item0->Add( item7, 0, wxGROW|wxALL, 5 );
206 
207  if (set_sizer)
208  {
209  parent->SetSizer( item0 );
210  if (call_fit)
211  item0->SetSizeHints( parent );
212  }
213 
214  return item0;
215 }
ProximMainFrame
Definition: ProximMainFrame.hh:58
ProximUnitWindow::~ProximUnitWindow
virtual ~ProximUnitWindow()
Definition: ProximUnitWindow.cc:93
ProximUnitWindow::ID_LINE
@ ID_LINE
Definition: ProximUnitWindow.hh:92
ProximUnitWindow::onChoice
void onChoice(wxCommandEvent &event)
Definition: ProximUnitWindow.cc:139
FindWindow
Definition: FindWindow.hh:49
ProximSimulationThread.hh
Proxim.hh
ProximUnitWindow.hh
ProximUnitWindow::ID_MODE_CHOICE
@ ID_MODE_CHOICE
Definition: ProximUnitWindow.hh:89
ProximSimulatorWindow
Definition: ProximSimulatorWindow.hh:47
ProximUnitWindow::ID_HELP
@ ID_HELP
Definition: ProximUnitWindow.hh:90
ProximUnitWindow::ID_CLOSE
@ ID_CLOSE
Definition: ProximUnitWindow.hh:91
ProximUnitWindow
Definition: ProximUnitWindow.hh:51
ProximUnitWindow::onClose
void onClose(wxCommandEvent &event)
Definition: ProximUnitWindow.cc:149
ProximUnitWindow::reinitialize
virtual void reinitialize()
Definition: ProximUnitWindow.cc:101
ProximUnitWindow::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: ProximUnitWindow.cc:169
TracedSimulatorFrontend.hh
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
ProximUnitWindow::ID_UNIT_CHOICE
@ ID_UNIT_CHOICE
Definition: ProximUnitWindow.hh:88
ProximUnitWindow::onSimulationStop
void onSimulationStop(const SimulatorEvent &event)
Definition: ProximUnitWindow.cc:128
ProximUnitWindow::update
virtual void update()
Definition: ProximUnitWindow.cc:118
ProximUnitWindow::ID_VALUE_LIST
@ ID_VALUE_LIST
Definition: ProximUnitWindow.hh:93
WxConversion.hh
EVT_SIMULATOR_PROGRAM_LOADED
#define EVT_SIMULATOR_PROGRAM_LOADED(id, fn)
Definition: SimulatorEvent.hh:151
SimulatorEvent
Definition: SimulatorEvent.hh:42
TTAMachine
Definition: Assembler.hh:48
EVT_SIMULATOR_STOP
#define EVT_SIMULATOR_STOP(id, fn)
Definition: SimulatorEvent.hh:106
ProximUnitWindow::onProgramLoaded
void onProgramLoaded(const SimulatorEvent &event)
Definition: ProximUnitWindow.cc:109
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF