00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "nanoFrame.hpp"
00022 #include "ruleView.hpp"
00023 #include "forbiddenPatternView.hpp"
00024 #include "layoutView.hpp"
00025 #include "truthTableView.hpp"
00026 #include "resources/fileopen.xpm"
00027 #include "resources/filesave.xpm"
00028 #include "resources/filesaveas.xpm"
00029 #include "resources/new.xpm"
00030 #include <wx/notebook.h>
00031 #include "nanoStatusBar.hpp"
00032
00033
00034 enum
00035 {
00036 ID_BUTTON_NEW,
00037 ID_BUTTON_OPEN,
00038 ID_BUTTON_SAVE,
00039 ID_BUTTON_SAVEAS,
00040 ID_LEGEND_ENABLED,
00041 ID_LEGEND_DISABLED,
00042 ID_LEGEND_INPUT,
00043 ID_LEGEND_OUTPUT,
00044 ID_LEGEND_NOSPACE
00045 };
00046
00047
00048 BEGIN_EVENT_TABLE(NanoFrame, wxFrame)
00049 EVT_TOOL (ID_BUTTON_SAVE, NanoFrame::OnSave)
00050 EVT_TOOL (ID_BUTTON_SAVEAS, NanoFrame::OnSaveAs)
00051 EVT_TOOL (ID_BUTTON_NEW, NanoFrame::OnNew)
00052 EVT_TOOL (ID_BUTTON_OPEN, NanoFrame::OnOpen)
00053 END_EVENT_TABLE()
00054
00055
00057
00060 NanoFrame::NanoFrame(MainController *controller)
00061 : wxFrame( (wxFrame *) NULL, -1, _("NanoComp"), wxPoint(50, 50), wxSize(450, 300) ), nanoController(controller)
00062 {
00063 this->nanoController = controller;
00064 initMenubar();
00065 initToolbar();
00066 initStatusbar();
00067 wxBoxSizer *mainSizer = new wxBoxSizer( wxVERTICAL );
00068
00069 SetSizer(mainSizer);
00070
00071 wxNotebook *notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
00072 RuleView *ruleTab = new RuleView(notebook, wxID_ANY, nanoController->getRules());
00073 ForbiddenPatternView *FPTab = new ForbiddenPatternView(notebook, wxID_ANY, nanoController->getForbiddenPatterns());
00074 LayoutView *LayoutTab = new LayoutView(notebook, wxID_ANY, nanoController->getLayouts());
00075 TruthTableView *TTTab = new TruthTableView(notebook, wxID_ANY, nanoController->getTruthTables());
00076
00077 notebook->AddPage(ruleTab, wxT("Rules"), true);
00078 notebook->AddPage(FPTab, wxT("Forbidden Patterns"), false);
00079 notebook->AddPage(TTTab, wxT("Truth Tables"), false);
00080 notebook->AddPage(LayoutTab, wxT("Layouts"), false);
00081
00082 mainSizer->Add(notebook, 1, wxEXPAND | wxALL, 0);
00083
00084 SetSizer(mainSizer);
00085 mainSizer->SetSizeHints(this);
00086 setTitleBar(_("Untitled"));
00087 Center();
00088 }
00089
00090
00092 NanoFrame::~NanoFrame()
00093 {
00094 }
00095
00096
00098 void NanoFrame::initMenubar()
00099 {
00100 wxMenu *fileMenu = new wxMenu;
00101
00102
00103 wxMenu *helpMenu = new wxMenu;
00104 helpMenu->Append(wxID_ANY, _T("&About..."), _T("Show about dialog"));
00105
00106 fileMenu->Append(wxID_ANY, _T("E&xit"), _T("Quit this program"));
00107
00108
00109 wxMenuBar *menuBar = new wxMenuBar();
00110 menuBar->Append(fileMenu, _T("&File"));
00111 menuBar->Append(helpMenu, _T("&Help"));
00112
00113
00114 SetMenuBar(menuBar);
00115 }
00116
00117
00119 void NanoFrame::initToolbar()
00120 {
00121 wxToolBar *toolBar = new wxToolBar(this,
00122 wxID_ANY,
00123 wxDefaultPosition,
00124 wxDefaultSize);
00125 wxBitmap bmpOpen(fileopen_xpm);
00126 wxBitmap bmpNew(new_xpm);
00127 wxBitmap bmpSave(filesave_xpm);
00128 wxBitmap bmpSaveAs(filesaveas_xpm);
00129
00130 toolBar->AddTool(ID_BUTTON_NEW, bmpNew, _("New"));
00131 toolBar->AddTool(ID_BUTTON_OPEN, bmpOpen, _("Open"));
00132 toolBar->AddTool(ID_BUTTON_SAVE, bmpSave, _("Save"));
00133 toolBar->AddTool(ID_BUTTON_SAVEAS, bmpSaveAs, _("Save As"));
00134
00135 toolBar->Realize();
00136 SetToolBar(toolBar);
00137 }
00138
00139
00141 void NanoFrame::initStatusbar()
00142 {
00143 NanoStatusBar *statusBar = new NanoStatusBar(this);
00144 SetStatusBar(statusBar);
00145 setStatusMessage(_T("NanoComp"));
00146 }
00147
00148
00150
00153 void NanoFrame::setStatusMessage(wxString message)
00154 {
00155 SetStatusText(message, 0);
00156 }
00157
00158
00160
00163 void NanoFrame::OnSave(wxCommandEvent &event)
00164 {
00165 nanoController->save();
00166 }
00167
00168
00170
00173 void NanoFrame::OnSaveAs(wxCommandEvent &event)
00174 {
00175 nanoController->saveAs();
00176 }
00177
00178
00180
00183 void NanoFrame::OnOpen(wxCommandEvent &event)
00184 {
00185 nanoController->open();
00186 }
00187
00188
00190
00193 void NanoFrame::OnNew(wxCommandEvent &event)
00194 {
00195 nanoController->newFile();
00196 }
00197
00198
00200
00203 void NanoFrame::errorMsg(wxString message)
00204 {
00205 wxMessageDialog dialog(this,
00206 message,
00207 _("Error"),
00208 wxOK | wxICON_ERROR);
00209 dialog.ShowModal();
00210 }
00211
00212
00214
00217 void NanoFrame::setTitleBar(wxString title)
00218 {
00219 SetTitle(title + _(" - NanoComp"));
00220 }