| 1 | /* |
|---|
| 2 | * Copyright (c) 2007-2008 Mat Booth |
|---|
| 3 | * |
|---|
| 4 | * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | * it under the terms of the GNU General Public License as published by |
|---|
| 6 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | * (at your option) any later version. |
|---|
| 8 | * |
|---|
| 9 | * This program is distributed in the hope that it will be useful, |
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | * GNU Library General Public License for more details. |
|---|
| 13 | * |
|---|
| 14 | * You should have received a copy of the GNU General Public License |
|---|
| 15 | * along with this program. If not, write to: |
|---|
| 16 | * The Free Software Foundation, Inc., |
|---|
| 17 | * 51 Franklin Street, Fifth Floor |
|---|
| 18 | * Boston, MA 02110-1301, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #include <wx/confbase.h> |
|---|
| 22 | #include "VmPanel.h" |
|---|
| 23 | |
|---|
| 24 | BEGIN_EVENT_TABLE(M3VmPanel, wxPanel) |
|---|
| 25 | END_EVENT_TABLE() |
|---|
| 26 | |
|---|
| 27 | M3VmPanel::M3VmPanel(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) |
|---|
| 28 | : wxPanel(parent, id, pos, size, style) |
|---|
| 29 | { |
|---|
| 30 | //create controls |
|---|
| 31 | wxPanel *regPanel = new wxPanel(this, -1); |
|---|
| 32 | wxPanel *memPanel = new wxPanel(this, -1); |
|---|
| 33 | |
|---|
| 34 | wxStaticText *terLabel = new wxStaticText(regPanel, -1, wxT("Ternary:")); |
|---|
| 35 | wxStaticText *hexLabel = new wxStaticText(regPanel, -1, wxT("Hex:")); |
|---|
| 36 | wxStaticText *decLabel = new wxStaticText(regPanel, -1, wxT("Decimal:")); |
|---|
| 37 | wxStaticText *aLabel = new wxStaticText(regPanel, -1, wxT("(A)ccumulator:")); |
|---|
| 38 | wxStaticText *cLabel = new wxStaticText(regPanel, -1, wxT("(C)ode Pointer:")); |
|---|
| 39 | wxStaticText *dLabel = new wxStaticText(regPanel, -1, wxT("(D)ata Pointer:")); |
|---|
| 40 | for(int i = 0; i < 3; i++) |
|---|
| 41 | { |
|---|
| 42 | m_RegA[i] = new wxTextCtrl(regPanel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); |
|---|
| 43 | m_RegC[i] = new wxTextCtrl(regPanel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); |
|---|
| 44 | m_RegD[i] = new wxTextCtrl(regPanel, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | //register layout |
|---|
| 48 | wxFlexGridSizer *regSizer = new wxFlexGridSizer(3, 4, 0, 0); |
|---|
| 49 | regSizer->AddGrowableCol(1); |
|---|
| 50 | regSizer->AddGrowableCol(2); |
|---|
| 51 | regSizer->AddGrowableCol(3); |
|---|
| 52 | |
|---|
| 53 | regSizer->AddStretchSpacer(0); |
|---|
| 54 | regSizer->Add(terLabel, 0, wxALL, 5); |
|---|
| 55 | regSizer->Add(hexLabel, 0, wxALL, 5); |
|---|
| 56 | regSizer->Add(decLabel, 0, wxALL, 5); |
|---|
| 57 | |
|---|
| 58 | regSizer->Add(aLabel, 0, wxALL, 5); |
|---|
| 59 | for(int i = 0; i < 3; i++) |
|---|
| 60 | regSizer->Add(m_RegA[i], 0, wxALL, 0); |
|---|
| 61 | |
|---|
| 62 | regSizer->Add(cLabel, 0, wxALL, 5); |
|---|
| 63 | for(int i = 0; i < 3; i++) |
|---|
| 64 | regSizer->Add(m_RegC[i], 0, wxALL, 0); |
|---|
| 65 | |
|---|
| 66 | regSizer->Add(dLabel, 0, wxALL, 5); |
|---|
| 67 | for(int i = 0; i < 3; i++) |
|---|
| 68 | regSizer->Add(m_RegD[i], 0, wxALL, 0); |
|---|
| 69 | |
|---|
| 70 | regPanel->SetSizer(regSizer); |
|---|
| 71 | regPanel->SetAutoLayout(true); |
|---|
| 72 | |
|---|
| 73 | //memory layout |
|---|
| 74 | //TODO |
|---|
| 75 | |
|---|
| 76 | //main layout |
|---|
| 77 | wxFlexGridSizer *mainSizer = new wxFlexGridSizer(2, 1, 0, 0); |
|---|
| 78 | mainSizer->AddGrowableCol(0); |
|---|
| 79 | mainSizer->AddGrowableRow(1); |
|---|
| 80 | mainSizer->Add(regPanel, 0, wxEXPAND, 0); |
|---|
| 81 | mainSizer->Add(memPanel, 0, wxEXPAND, 0); |
|---|
| 82 | SetSizer(mainSizer); |
|---|
| 83 | SetAutoLayout(true); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | M3VmPanel::~M3VmPanel() |
|---|
| 87 | { |
|---|
| 88 | //save before the window is destroyed |
|---|
| 89 | SaveConf(); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | void M3VmPanel::LoadConf() |
|---|
| 93 | { |
|---|
| 94 | //save config path |
|---|
| 95 | wxConfigBase* conf = wxConfigBase::Get(); |
|---|
| 96 | wxString oldPath = conf->GetPath(); |
|---|
| 97 | |
|---|
| 98 | //load |
|---|
| 99 | |
|---|
| 100 | //restore config path |
|---|
| 101 | conf->SetPath(oldPath); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | void M3VmPanel::SaveConf() |
|---|
| 105 | { |
|---|
| 106 | //save config path |
|---|
| 107 | wxConfigBase* conf = wxConfigBase::Get(); |
|---|
| 108 | wxString oldPath = conf->GetPath(); |
|---|
| 109 | |
|---|
| 110 | //save |
|---|
| 111 | |
|---|
| 112 | //restore config path |
|---|
| 113 | conf->SetPath(oldPath); |
|---|
| 114 | } |
|---|