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
68
69
70
71
72
73
74
75
|
#include "frame.h"
#include "widget.h"
#include "tile_widget.h"
#include <wx/splitter.h>
#include "panel.h"
enum {
MENU_VIEW_ZOOM_IN,
MENU_VIEW_ZOOM_OUT
};
wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame)
EVT_MENU(wxID_EXIT, MapeditFrame::OnExit)
EVT_MENU(MENU_VIEW_ZOOM_IN, MapeditFrame::ZoomIn)
EVT_MENU(MENU_VIEW_ZOOM_OUT, MapeditFrame::ZoomOut)
wxEND_EVENT_TABLE()
MapeditFrame::MapeditFrame(Map map) : wxFrame(NULL, wxID_ANY, "Map Editor", wxPoint(50, 50), wxSize(GAME_WIDTH*3, GAME_HEIGHT*2)), map(map)
{
wxMenu* menuFile = new wxMenu;
menuFile->Append(wxID_EXIT);
wxMenu* menuView = new wxMenu;
menuView->Append(MENU_VIEW_ZOOM_IN, "Zoom In\tCtrl-+");
menuView->Append(MENU_VIEW_ZOOM_OUT, "Zoom Out\tCtrl--");
wxMenuBar* menuBar = new wxMenuBar;
menuBar->Append(menuFile, "&File");
menuBar->Append(menuView, "&View");
SetMenuBar(menuBar);
wxBoxSizer* sizermain = new wxBoxSizer(wxVERTICAL);
wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY);
splitter->SetSashGravity(0.0);
splitter->SetMinimumPaneSize(50);
sizermain->Add(splitter, 1, wxEXPAND, 0);
wxPanel* tileEditorPanel = new wxPanel(splitter, wxID_ANY);
tileEditor = new TileWidget(tileEditorPanel, wxID_ANY, 6, 6, wxPoint(0,0));
wxBoxSizer* tileSizer = new wxBoxSizer(wxVERTICAL);
tileSizer->Add(tileEditor, 1, wxEXPAND, 0);
tileEditorPanel->SetSizer(tileSizer);
wxPanel* mapEditorPanel = new wxPanel(splitter, wxID_ANY);
mapEditor = new MapeditWidget(mapEditorPanel, wxID_ANY, &this->map, tileEditor, wxPoint(0,0));
wxBoxSizer* mapSizer = new wxBoxSizer(wxVERTICAL);
mapSizer->Add(mapEditor, 1, wxEXPAND, 0);
mapEditorPanel->SetSizer(mapSizer);
splitter->SplitVertically(tileEditorPanel, mapEditorPanel);
this->SetSizer(sizermain);
sizermain->SetSizeHints(this);
}
void MapeditFrame::OnExit(wxCommandEvent& event)
{
Close(true);
}
MapeditWidget* MapeditFrame::GetMapEditor()
{
return mapEditor;
}
void MapeditFrame::ZoomIn(wxCommandEvent& event)
{
mapEditor->ZoomIn();
}
void MapeditFrame::ZoomOut(wxCommandEvent& event)
{
mapEditor->ZoomOut();
}
|