1 /*
2  Copyright (C) 2010-2014 Kristian Duske
3 
4  This file is part of TrenchBroom.
5 
6  TrenchBroom is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  TrenchBroom is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "Inspector.h"
21 
22 #include "View/EntityInspector.h"
23 #include "View/FaceInspector.h"
24 #include "View/MapInspector.h"
25 #include "View/TabBook.h"
26 #include "View/TabBar.h"
27 
28 #include <wx/sizer.h>
29 
30 namespace TrenchBroom {
31     namespace View {
Inspector(wxWindow * parent,MapDocumentWPtr document,GLContextManager & contextManager)32         Inspector::Inspector(wxWindow* parent, MapDocumentWPtr document, GLContextManager& contextManager) :
33         wxPanel(parent),
34         m_tabBook(NULL),
35         m_mapInspector(NULL),
36         m_entityInspector(NULL),
37         m_faceInspector(NULL) {
38 
39             m_tabBook = new TabBook(this);
40 
41             m_mapInspector = new MapInspector(m_tabBook, document, contextManager);
42             m_entityInspector = new EntityInspector(m_tabBook, document, contextManager);
43             m_faceInspector = new FaceInspector(m_tabBook, document, contextManager);
44 
45             m_tabBook->addPage(m_mapInspector, "Map");
46             m_tabBook->addPage(m_entityInspector, "Entity");
47             m_tabBook->addPage(m_faceInspector, "Face");
48 
49             wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
50             sizer->Add(m_tabBook, 1, wxEXPAND);
51             SetSizer(sizer);
52         }
53 
connectTopWidgets(wxWindow * master)54         void Inspector::connectTopWidgets(wxWindow* master) {
55             master->Bind(wxEVT_SIZE, &Inspector::OnTopWidgetSize, this);
56         }
57 
switchToPage(const InspectorPage page)58         void Inspector::switchToPage(const InspectorPage page) {
59             m_tabBook->switchToPage(static_cast<size_t>(page));
60         }
61 
OnTopWidgetSize(wxSizeEvent & event)62         void Inspector::OnTopWidgetSize(wxSizeEvent& event) {
63             if (IsBeingDeleted()) return;
64             m_tabBook->setTabBarHeight(event.GetSize().y);
65             event.Skip();
66         }
67     }
68 }
69