-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlgorithmDocumentFrame.cpp
67 lines (58 loc) · 2.08 KB
/
AlgorithmDocumentFrame.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "AlgorithmDocumentFrame.h"
#include "MainFrame.h"
#include "AlgorithmDocument.h"
wxBEGIN_EVENT_TABLE(AlgorithmDocumentFrame, wxFrame)
EVT_BUTTON(ID_Save, AlgorithmDocumentFrame::OnSave)
EVT_BUTTON(ID_Submit, AlgorithmDocumentFrame::OnSubmit)
EVT_BUTTON(ID_Close, AlgorithmDocumentFrame::OnClose)
wxEND_EVENT_TABLE()
AlgorithmDocumentFrame::AlgorithmDocumentFrame(MainFrame *parent):DocumentFrame(parent, "Algorithm Document", wxDefaultPosition, wxDefaultSize)
{
CreateInterface();
}
AlgorithmDocumentFrame::~AlgorithmDocumentFrame(void)
{
}
void AlgorithmDocumentFrame::CreateInterface()
{
wxBoxSizer* verticalSizer = new wxBoxSizer(wxVERTICAL);
AddButtonBarTo(verticalSizer);
_textbox = new wxTextCtrl(this,wxID_ANY,"",wxDefaultPosition, wxSize(600,800),wxTE_MULTILINE | wxTE_RICH,wxDefaultValidator, wxTextCtrlNameStr);
verticalSizer->Add(_textbox,1, wxALL | wxEXPAND);
this->SetSizer(verticalSizer);
this->Layout();
verticalSizer->Fit(this);
}
void AlgorithmDocumentFrame::CreateDocument()
{
_document = new AlgorithmDocument();
}
void AlgorithmDocumentFrame::OnSave(wxCommandEvent &event)
{
_document->Save();
}
void AlgorithmDocumentFrame::OnSubmit(wxCommandEvent &event)
{
wxString content = _textbox->GetValue();
_document->SetSourceString(content.mb_str());
_parent->InterpretDocument(_document);
}
void AlgorithmDocumentFrame::OnClose(wxCommandEvent &event)
{
Close();
}
void AlgorithmDocumentFrame::AddButtonBarTo(wxBoxSizer *verticalSizer)
{
wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
verticalSizer->Add(horizontalSizer, 0, wxALL | wxEXPAND);
// TODO - fix this so its not hard coded
int width,height, min;
GetClientSize(&width, &height);
wxCoord x(width/3);
wxCoord y(height-40);
wxCoord start(width/12);
_save = AddButtonWithDefaultSettings(ButtonWidget(ID_Save,"Save",wxPoint(start,y)), horizontalSizer);
_submit = AddButtonWithDefaultSettings(ButtonWidget(ID_Submit,"Submit",wxPoint(start+x,y)), horizontalSizer);
_close = AddButtonWithDefaultSettings(ButtonWidget(ID_Close,"Close",wxPoint(start+x*2,y)), horizontalSizer);
_close->SetDefault();
}