1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor 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 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor 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 this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_PALETTE_HOUSE_H_
19#define RME_PALETTE_HOUSE_H_
20
21#include "palette_common.h"
22
23class House;
24
25class HousePalettePanel : public PalettePanel {
26public:
27 HousePalettePanel(wxWindow* parent, wxWindowID id = wxID_ANY);
28 ~HousePalettePanel();
29
30 PaletteType GetType() const;
31
32 // Select the first brush
33 void SelectFirstBrush();
34 // Returns the currently selected brush (first brush if panel is not loaded)
35 Brush* GetSelectedBrush() const;
36 // Returns the currently selected brush size
37 int GetSelectedBrushSize() const;
38 // Select the brush in the parameter, this only changes the look of the panel
39 bool SelectBrush(const Brush* whatbrush);
40
41 // Called sometimes?
42 void OnUpdate();
43 // Called when this page is about to be displayed
44 void OnSwitchIn();
45
46 void OnLayoutFixTimer(wxTimerEvent& event);
47
48 void SetMap(Map* map);
49
50protected:
51 // Internal use
52 void SaveHouse();
53 void SelectTown(size_t index);
54 void SelectHouse(size_t index);
55
56 House* GetCurrentlySelectedHouse() const;
57
58 void SelectHouseBrush();
59 void SelectExitBrush();
60 void RefreshHouseList();
61
62public:
63 // wxWidgets event handling
64 void OnTownChange(wxCommandEvent& event);
65 void OnListBoxChange(wxCommandEvent& event);
66 void OnListBoxDoubleClick(wxCommandEvent& event);
67 void OnClickHouseBrushButton(wxCommandEvent& event);
68 void OnClickSelectExitButton(wxCommandEvent& event);
69 void OnClickAddHouse(wxCommandEvent& event);
70 void OnClickEditHouse(wxCommandEvent& event);
71 void OnClickRemoveHouse(wxCommandEvent& event);
72 void OnListBoxContextMenu(wxContextMenuEvent& event);
73 void OnMoveHouseToTown(wxCommandEvent& event);
74
75#ifdef __APPLE__
76 // Used for detecting a deselect
77 void OnListBoxClick(wxMouseEvent& event);
78#endif
79
80protected:
81 Map* map;
82 wxChoice* town_choice;
83 SortableListBox* house_list;
84 wxToggleButton* house_brush_button;
85 wxToggleButton* select_position_button;
86 wxButton* add_house_button;
87 wxButton* edit_house_button;
88 wxButton* remove_house_button;
89 wxMenu* context_menu;
90
91 // Used for ugly hack
92 bool do_resize_on_display;
93 wxTimer fix_size_timer;
94
95 DECLARE_EVENT_TABLE()
96};
97
98class EditHouseDialog : public wxDialog {
99public:
100 EditHouseDialog(wxWindow* parent, Map* map, House* house);
101 virtual ~EditHouseDialog();
102
103 void OnFocusChange(wxFocusEvent&);
104
105 void OnClickOK(wxCommandEvent&);
106 void OnClickCancel(wxCommandEvent&);
107
108protected:
109 Map* map;
110 House* what_house;
111
112 wxString house_name, house_id, house_rent;
113
114 wxTextCtrl* name_field;
115 wxChoice* town_id_field;
116 wxSpinCtrl* id_field;
117 wxTextCtrl* rent_field;
118 wxCheckBox* guildhall_field;
119
120 DECLARE_EVENT_TABLE();
121};
122
123#endif
124