1 /* Copyright (C) 2009 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. 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 * 0 A.D. 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 General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "precompiled.h"
19
20 #include "AtlasDialog.h"
21
22 #include "wx/statline.h"
23
24 IMPLEMENT_CLASS(AtlasDialog, wxDialog);
25
BEGIN_EVENT_TABLE(AtlasDialog,wxDialog)26 BEGIN_EVENT_TABLE(AtlasDialog, wxDialog)
27 EVT_MENU(wxID_UNDO, AtlasDialog::OnUndo)
28 EVT_MENU(wxID_REDO, AtlasDialog::OnRedo)
29 END_EVENT_TABLE()
30
31
32 AtlasDialog::AtlasDialog(wxWindow* parent, const wxString& title, const wxSize& size)
33 : wxDialog(parent, -1, title, wxDefaultPosition, size,
34 wxCAPTION | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCLOSE_BOX)
35 {
36 // Create generic dialog box, with OK/Cancel buttons, some horizontal
37 // dividing lines, and a wxPanel in the middle:
38
39 wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
40 SetSizer(mainSizer);
41
42 // -------------------------------------------------------------------------
43 mainSizer->Add(new wxStaticLine(this, -1), wxSizerFlags().Expand().Border(wxALL, 5));
44
45
46 m_MainPanel = new wxPanel(this);
47 mainSizer->Add(m_MainPanel, wxSizerFlags().Proportion(1).Expand().Border(wxLEFT|wxRIGHT, 5));
48
49 // -------------------------------------------------------------------------
50 mainSizer->Add(new wxStaticLine(this, -1), wxSizerFlags().Expand().Border(wxALL, 5));
51
52
53 wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
54 mainSizer->Add(buttonSizer, wxSizerFlags().Expand().Align(wxALIGN_RIGHT).Border(wxALL, 5));
55
56 buttonSizer->Add(new wxButton(this, wxID_OK, _("OK")), wxSizerFlags().Border(wxRIGHT, 25));
57 buttonSizer->Add(new wxButton(this, wxID_CANCEL, _("Cancel")), wxSizerFlags().Border(wxRIGHT, 5));
58
59 //////////////////////////////////////////////////////////////////////////
60
61 // Set up handlers for Ctrl+Z, Ctrl+Y (undo/redo), since dialogs don't
62 // have any menu entries for them (since they don't have menus at all).
63 wxAcceleratorEntry entries[2];
64 entries[0].Set(wxACCEL_CTRL, 'Z', wxID_UNDO);
65 entries[1].Set(wxACCEL_CTRL, 'Y', wxID_REDO);
66 wxAcceleratorTable accel(2, entries);
67 SetAcceleratorTable(accel);
68
69 m_CommandProc.Initialize();
70 }
71
OnUndo(wxCommandEvent & WXUNUSED (event))72 void AtlasDialog::OnUndo(wxCommandEvent& WXUNUSED(event))
73 {
74 m_CommandProc.Undo();
75 }
76
OnRedo(wxCommandEvent & WXUNUSED (event))77 void AtlasDialog::OnRedo(wxCommandEvent& WXUNUSED(event))
78 {
79 m_CommandProc.Redo();
80 }
81