summary refs log tree commit diff stats
path: root/tools/mapedit/src/frame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mapedit/src/frame.cpp')
-rw-r--r--tools/mapedit/src/frame.cpp55
1 files changed, 50 insertions, 5 deletions
diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 858620e..537cd16 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp
@@ -1,30 +1,75 @@
1#include "frame.h" 1#include "frame.h"
2#include "widget.h" 2#include "widget.h"
3#include "tile_widget.h" 3#include "tile_widget.h"
4#include <wx/splitter.h>
5#include "panel.h"
6
7enum {
8 MENU_VIEW_ZOOM_IN,
9 MENU_VIEW_ZOOM_OUT
10};
4 11
5wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) 12wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame)
6 EVT_MENU(wxID_EXIT, MapeditFrame::OnExit) 13 EVT_MENU(wxID_EXIT, MapeditFrame::OnExit)
14 EVT_MENU(MENU_VIEW_ZOOM_IN, MapeditFrame::ZoomIn)
15 EVT_MENU(MENU_VIEW_ZOOM_OUT, MapeditFrame::ZoomOut)
7wxEND_EVENT_TABLE() 16wxEND_EVENT_TABLE()
8 17
9MapeditFrame::MapeditFrame(Map map) : wxFrame(NULL, wxID_ANY, "Map Editor", wxPoint(50, 50), wxSize(GAME_WIDTH*3, GAME_HEIGHT*2)), map(map) 18MapeditFrame::MapeditFrame(Map map) : wxFrame(NULL, wxID_ANY, "Map Editor", wxPoint(50, 50), wxSize(GAME_WIDTH*3, GAME_HEIGHT*2)), map(map)
10{ 19{
11 wxMenu* menuFile = new wxMenu; 20 wxMenu* menuFile = new wxMenu;
12 menuFile->Append(wxID_EXIT); 21 menuFile->Append(wxID_EXIT);
22
23 wxMenu* menuView = new wxMenu;
24 menuView->Append(MENU_VIEW_ZOOM_IN, "Zoom In\tCtrl-+");
25 menuView->Append(MENU_VIEW_ZOOM_OUT, "Zoom Out\tCtrl--");
13 26
14 wxMenuBar* menuBar = new wxMenuBar; 27 wxMenuBar* menuBar = new wxMenuBar;
15 menuBar->Append(menuFile, "&File"); 28 menuBar->Append(menuFile, "&File");
29 menuBar->Append(menuView, "&View");
16 30
17 SetMenuBar(menuBar); 31 SetMenuBar(menuBar);
18 32
19 wxPanel* panel = new wxPanel(this, wxID_ANY); 33 wxBoxSizer* sizermain = new wxBoxSizer(wxVERTICAL);
20 int clientWidth, clientHeight; 34 wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY);
21 GetClientSize(&clientWidth, &clientHeight); 35 splitter->SetSashGravity(0.0);
36 splitter->SetMinimumPaneSize(50);
37 sizermain->Add(splitter, 1, wxEXPAND, 0);
38
39 wxPanel* tileEditorPanel = new wxPanel(splitter, wxID_ANY);
40 tileEditor = new TileWidget(tileEditorPanel, wxID_ANY, 6, 6, wxPoint(0,0));
41 wxBoxSizer* tileSizer = new wxBoxSizer(wxVERTICAL);
42 tileSizer->Add(tileEditor, 1, wxEXPAND, 0);
43 tileEditorPanel->SetSizer(tileSizer);
44
45 wxPanel* mapEditorPanel = new wxPanel(splitter, wxID_ANY);
46 mapEditor = new MapeditWidget(mapEditorPanel, wxID_ANY, &this->map, tileEditor, wxPoint(0,0));
47 wxBoxSizer* mapSizer = new wxBoxSizer(wxVERTICAL);
48 mapSizer->Add(mapEditor, 1, wxEXPAND, 0);
49 mapEditorPanel->SetSizer(mapSizer);
22 50
23 TileWidget* tileEdit = new TileWidget(panel, wxID_ANY, 6, wxPoint(0,0), wxSize(TILE_WIDTH*3*6, clientHeight)); 51 splitter->SplitVertically(tileEditorPanel, mapEditorPanel);
24 MapeditWidget* wid = new MapeditWidget(panel, wxID_ANY, &this->map, tileEdit, wxPoint(TILE_WIDTH*3*6+8,0), wxSize(GAME_WIDTH*1.5, GAME_HEIGHT*1.5)); 52
53 this->SetSizer(sizermain);
54 sizermain->SetSizeHints(this);
25} 55}
26 56
27void MapeditFrame::OnExit(wxCommandEvent& event) 57void MapeditFrame::OnExit(wxCommandEvent& event)
28{ 58{
29 Close(true); 59 Close(true);
30} 60}
61
62MapeditWidget* MapeditFrame::GetMapEditor()
63{
64 return mapEditor;
65}
66
67void MapeditFrame::ZoomIn(wxCommandEvent& event)
68{
69 mapEditor->ZoomIn();
70}
71
72void MapeditFrame::ZoomOut(wxCommandEvent& event)
73{
74 mapEditor->ZoomOut();
75}