OpenASIP  2.0
ProDeOptionsDialog.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 ProDeOptionsDialog.cc
26  *
27  * Implementation of ProDeOptionsDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <boost/format.hpp>
34 #include <wx/notebook.h>
35 #include "ProDeOptionsDialog.hh"
36 #include "ProDeOptions.hh"
37 #include "WxConversion.hh"
38 #include "ProDe.hh"
39 #include "Conversion.hh"
40 #include "UserManualCmd.hh"
41 #include "WidgetTools.hh"
42 #include "GUITextGenerator.hh"
43 #include "ProDeTextGenerator.hh"
44 #include "ProDeConstants.hh"
45 
46 using boost::format;
47 using std::string;
48 using std::vector;
49 
50 
51 BEGIN_EVENT_TABLE(ProDeOptionsDialog, OptionsDialog)
54 
55 
56 /**
57  * The Constructor.
58  *
59  * @param parent Parent window of the dialog.
60  * @param options Options to be modified.
61  */
63  wxWindow* parent, ProDeOptions& options, CommandRegistry& registry):
64  OptionsDialog(parent, options, registry),
65  parent_(parent), options_(options) {
66 
67  wxPanel* generalPage = new wxPanel(notebook_, -1);
68  createGeneralPage(generalPage, true, true);
69  addPage(generalPage, _T("General"));
70 
71  undoStackSize_ = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_UNDO_LEVELS));
72 
73  readProDeOptions();
74 
75 }
76 
77 
78 /**
79  * The Destructor.
80  */
82 }
83 
84 /**
85  * Reads the options in options_ to dialog attributes.
86  */
87 void
90 }
91 
92 
93 /**
94  * Writes the options from dialog attributes to the current options object.
95  */
96 void
99 }
100 
101 
102 /**
103  * Validates input in the controls, and updates the options.
104  */
105 void
106 ProDeOptionsDialog::onOK(wxCommandEvent&) {
107 
108  if (!Validate()) {
109  return;
110  }
111 
112  if (!TransferDataFromWindow()) {
113  return;
114  }
115 
116  writeOptions();
118 
119  EndModal(wxID_OK);
120 }
121 
122 
123 /**
124  * Creates the 'General' page for the dialog.
125  *
126  * This function was initially generated by wxDesigner.
127  * @return Main sizer of the created contents.
128  * @param parent The dialog window.
129  * @param call_fit If true, fits the contents inside the dialog.
130  * @param set_sizer If true, sets the main sizer as dialog contents.
131  */
132 wxSizer*
134  wxWindow *parent, bool call_fit, bool set_sizer ) {
135 
136  wxBoxSizer *item0 = new wxBoxSizer( wxHORIZONTAL );
137 
138  item0->Add( 50, 20, 0, wxALIGN_CENTER|wxALL, 5 );
139 
140  wxStaticText *item1 = new wxStaticText( parent, ID_LABEL_UNDO_LEVELS, wxT("Undo levels:"), wxDefaultPosition, wxDefaultSize, 0 );
141  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
142 
143  wxSpinCtrl *item2 = new wxSpinCtrl( parent, ID_UNDO_LEVELS, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 100, 0 );
144  item0->Add( item2, 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 }
ProDeOptionsDialog::createGeneralPage
wxSizer * createGeneralPage(wxWindow *parent, bool callFit, bool set_sizer)
Definition: ProDeOptionsDialog.cc:133
ProDe.hh
ProDeOptions
Definition: ProDeOptions.hh:44
ProDeOptionsDialog::onOK
void onOK(wxCommandEvent &event)
Definition: ProDeOptionsDialog.cc:106
OptionsDialog::writeOptions
virtual void writeOptions()
Definition: OptionsDialog.cc:286
ProDeOptionsDialog::ID_LABEL_UNDO_LEVELS
@ ID_LABEL_UNDO_LEVELS
Definition: ProDeOptionsDialog.hh:77
WidgetTools.hh
OptionsDialog
Definition: OptionsDialog.hh:60
FindWindow
Definition: FindWindow.hh:49
ProDeTextGenerator.hh
ProDeOptionsDialog::options_
ProDeOptions & options_
current editor options
Definition: ProDeOptionsDialog.hh:69
ProDeOptions::setUndoStackSize
void setUndoStackSize(int size)
Definition: ProDeOptions.cc:106
ProDeOptionsDialog::writeProDeOptions
void writeProDeOptions()
Definition: ProDeOptionsDialog.cc:97
ProDeOptionsDialog::~ProDeOptionsDialog
virtual ~ProDeOptionsDialog()
Definition: ProDeOptionsDialog.cc:81
Conversion.hh
CommandRegistry
Definition: CommandRegistry.hh:47
ProDeOptionsDialog
Definition: ProDeOptionsDialog.hh:48
ProDeOptionsDialog::undoStackSize_
wxSpinCtrl * undoStackSize_
Undo levels.
Definition: ProDeOptionsDialog.hh:72
ProDeConstants.hh
GUITextGenerator.hh
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
ProDeOptionsDialog::ID_UNDO_LEVELS
@ ID_UNDO_LEVELS
Definition: ProDeOptionsDialog.hh:76
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
ProDeOptions.hh
ProDeOptions::undoStackSize
int undoStackSize() const
Definition: ProDeOptions.cc:95
WxConversion.hh
ProDeOptionsDialog::readProDeOptions
void readProDeOptions()
Definition: ProDeOptionsDialog.cc:88
UserManualCmd.hh
ProDeOptionsDialog.hh
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF