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 #ifndef TrenchBroom_TabBar
21 #define TrenchBroom_TabBar
22 
23 #include "View/ContainerBar.h"
24 
25 #include <wx/stattext.h>
26 
27 #include <vector>
28 
29 class wxBookCtrlEvent;
30 class wxSimplebook;
31 
32 namespace TrenchBroom {
33     namespace View {
34         class TabBook;
35         class TabBookPage;
36 
37         class TabBarButton : public wxStaticText {
38         private:
39             bool m_pressed;
40         public:
41             TabBarButton(wxWindow* parent, const wxString& label);
42 
43             void setPressed(bool pressed);
44 
45             void OnClick(wxMouseEvent& event);
46         private:
47             void updateLabel();
48         };
49 
50         class TabBar : public ContainerBar {
51         private:
52             typedef std::vector<TabBarButton*> ButtonList;
53 
54             TabBook* m_tabBook;
55             wxSimplebook* m_barBook;
56             wxSizer* m_controlSizer;
57             ButtonList m_buttons;
58         public:
59             TabBar(TabBook* tabBook);
60 
61             void addTab(TabBookPage* bookPage, const wxString& title);
62 
63             void OnButtonClicked(wxCommandEvent& event);
64             void OnTabBookPageChanged(wxBookCtrlEvent& event);
65         private:
66             size_t findButtonIndex(wxWindow* button) const;
67             void setButtonActive(int index);
68             void setButtonInactive(int index);
69         };
70     }
71 }
72 
73 #endif /* defined(TrenchBroom_TabBar) */
74