OpenASIP  2.0
MemoryDialog.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 MemoryTools.cc
26  *
27  * Definition of MemoryTools class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <boost/format.hpp>
34 #include <string>
35 
36 #include "MemoryDialog.hh"
37 #include "OSEdTextGenerator.hh"
38 #include "WxConversion.hh"
39 #include "WidgetTools.hh"
40 #include "DialogPosition.hh"
41 #include "OperationContainer.hh"
42 #include "Conversion.hh"
43 #include "MemoryControl.hh"
44 #include "OSEd.hh"
45 
46 using boost::format;
47 using std::string;
48 
49 BEGIN_EVENT_TABLE(MemoryDialog, wxDialog)
50  EVT_BUTTON(ID_BUTTON_CLOSE, MemoryDialog::onClose)
52 
53 /**
54  * Constructor.
55  *
56  * @param window Parent window.
57  */
58 MemoryDialog::MemoryDialog(wxWindow* window) :
59  wxDialog(window, -1, _T(""),
60  DialogPosition::getPosition(DialogPosition::DIALOG_MEMORY),
61  wxDefaultSize, wxRESIZE_BORDER) {
62 
63  createContents(this, true, true);
64  setTexts();
65 
66  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
68 }
69 
70 /**
71  * Destructor.
72  */
74  int x, y;
75  GetPosition(&x, &y);
76  wxPoint point(x, y);
78 }
79 
80 /**
81  * Set texts to widgets.
82  */
83 void
85 
87 
88  // title
89  format fmt = osedText.text(OSEdTextGenerator::TXT_MEMORY_DIALOG_TITLE);
90  SetTitle(WxConversion::toWxString(fmt.str()));
91 
92  // buttons
95 }
96 
97 /**
98  * Handles the event when dialog is closed.
99  */
100 void
101 MemoryDialog::onClose(wxCommandEvent&) {
102  OSEdInformer* informer = wxGetApp().mainFrame()->informer();
104  Close();
105 }
106 
107 /**
108  * Handles event when the contents of the memory might have changed.
109  */
110 void
112  switch(event) {
115  break;
116  default:
117  break;
118  }
119 }
120 
121 /**
122  * Creates the contents of the MemoryDialog.
123  *
124  * @param parent Parent window.
125  * @param call_fit If true, fits the contents inside the dialog.
126  * @param set_sizer If true, sets the the main sizer as dialog contents.
127  * @return The created sizer.
128  */
129 wxSizer*
131  wxWindow* parent,
132  bool call_fit,
133  bool set_sizer) {
134 
135  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
136 
139 
140  item0->Add(memoryWindow_, 1, wxGROW|wxALL, 5);
141 
142  wxButton *item1 = new wxButton( parent, ID_BUTTON_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0 );
143 
144  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
145 
146  if (set_sizer)
147  {
148  parent->SetSizer( item0 );
149  if (call_fit)
150  item0->SetSizeHints( parent );
151  }
152 
153  return item0;
154 
155 }
MemoryDialog::ID_BUTTON_CLOSE
@ ID_BUTTON_CLOSE
Definition: MemoryDialog.hh:72
OSEdInformer::EventId
EventId
Definition: OSEdInformer.hh:52
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdTextGenerator::TXT_BUTTON_CLOSE
@ TXT_BUTTON_CLOSE
Close button label.
Definition: OSEdTextGenerator.hh:81
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
DialogPosition::DIALOG_MEMORY
@ DIALOG_MEMORY
Memory dialog.
Definition: DialogPosition.hh:56
MemoryDialog::ID_CONTROL_MEMORY
@ ID_CONTROL_MEMORY
Definition: MemoryDialog.hh:73
MemoryDialog::setTexts
void setTexts()
Definition: MemoryDialog.cc:84
WidgetTools.hh
OSEd.hh
FindWindow
Definition: FindWindow.hh:49
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
MemoryDialog::createContents
wxSizer * createContents(wxWindow *window, bool call_fit, bool set_sizer)
Definition: MemoryDialog.cc:130
OSEdInformer::EVENT_MEMORY
@ EVENT_MEMORY
Event when memory may be changed.
Definition: OSEdInformer.hh:55
MemoryDialog::onClose
void onClose(wxCommandEvent &)
Definition: MemoryDialog.cc:101
MemoryControl::updateView
void updateView()
Definition: MemoryControl.cc:290
OSEdInformer::registerListener
void registerListener(EventId event, OSEdListener *listener)
Definition: OSEdInformer.cc:74
MemoryControl
Definition: MemoryControl.hh:53
Conversion.hh
DialogPosition
Definition: DialogPosition.hh:42
MemoryControl.hh
MemoryDialog
Definition: MemoryDialog.hh:51
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
MemoryDialog.hh
MemoryDialog::handleEvent
virtual void handleEvent(OSEdInformer::EventId event)
Definition: MemoryDialog.cc:111
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
OperationContainer::memory
static Memory & memory()
Definition: OperationContainer.cc:134
WxConversion.hh
OSEdInformer::unregisterListener
void unregisterListener(EventId event, OSEdListener *listener)
Definition: OSEdInformer.cc:92
OSEdInformer
Definition: OSEdInformer.hh:47
OSEdTextGenerator::TXT_MEMORY_DIALOG_TITLE
@ TXT_MEMORY_DIALOG_TITLE
Memory dialog title.
Definition: OSEdTextGenerator.hh:120
OSEdTextGenerator.hh
MemoryDialog::~MemoryDialog
virtual ~MemoryDialog()
Definition: MemoryDialog.cc:73
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
OperationContainer.hh
DialogPosition.hh
MemoryDialog::memoryWindow_
MemoryControl * memoryWindow_
Memory control of the dialog.
Definition: MemoryDialog.hh:77