Mana
Loading...
Searching...
No Matches
tabbedarea.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2008-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include <guichan/widget.hpp>
25#include <guichan/widgetlistener.hpp>
26#include <guichan/widgets/container.hpp>
27#include <guichan/widgets/tabbedarea.hpp>
28
29#include "gui/widgets/button.h"
30
31#include <memory>
32#include <string>
33
34class Tab;
35
39class TabbedArea final : public gcn::TabbedArea, public gcn::WidgetListener
40{
41 public:
42 TabbedArea();
43
47 void draw(gcn::Graphics *graphics) override;
48
54 int getNumberOfTabs() const;
55
59 Tab *getTab(const std::string &name) const;
60
64 gcn::Widget *getWidget(const std::string &name) const;
65
69 gcn::Widget *getCurrentWidget();
70
77 void addTab(gcn::Tab* tab, gcn::Widget* widget) override;
78
86 void addTab(const std::string &caption, gcn::Widget *widget) override;
87
91 void removeTab(gcn::Tab *tab) override;
92
96 void logic() override;
97
99 { return mWidgetContainer->getHeight(); }
100
101 void setSelectedTab(unsigned int index) override
102 { gcn::TabbedArea::setSelectedTab(index); }
103
104 void setSelectedTab(gcn::Tab *tab) override;
105
106 void widgetResized(const gcn::Event &event) override;
107
108 void adjustTabPositions();
109
110 void action(const gcn::ActionEvent& actionEvent) override;
111
112 // Inherited from MouseListener
113
114 void mousePressed(gcn::MouseEvent &mouseEvent) override;
115
116 private:
118 std::unique_ptr<Button> mArrowButton[2];
119
122
127 void updateTabsWidth();
128
132 int mTabsWidth = 0;
133
139
144
145
152 unsigned mTabScrollIndex = 0;
153};
A tab, the same as the Guichan tab in 0.8, but extended to allow transparency.
Definition tab.h:33
A tabbed area, the same as the guichan tabbed area in 0.8, but extended.
Definition tabbedarea.h:40
void draw(gcn::Graphics *graphics) override
Draw the tabbed area.
void updateVisibleTabsWidth()
Update the overall width of visible tab.
int mVisibleTabsWidth
The overall width of visible tab.
Definition tabbedarea.h:143
void action(const gcn::ActionEvent &actionEvent) override
void logic() override
Override the logic function since it's broken in guichan 0.8.
int getContainerHeight() const
Definition tabbedarea.h:98
void widgetResized(const gcn::Event &event) override
void addTab(gcn::Tab *tab, gcn::Widget *widget) override
Add a tab.
int mTabsWidth
The overall width of all tab.
Definition tabbedarea.h:132
void mousePressed(gcn::MouseEvent &mouseEvent) override
gcn::Widget * getCurrentWidget()
Returns the widget for the current tab.
void removeTab(gcn::Tab *tab) override
Override the remove tab function as it's broken in guichan 0.8.
void updateTabsWidth()
Update the overall width of all tab.
void setSelectedTab(unsigned int index) override
Definition tabbedarea.h:101
Tab * getTab(const std::string &name) const
Return tab with specified name as caption.
void adjustTabPositions()
int getNumberOfTabs() const
Return how many tabs have been created.
gcn::Widget * getWidget(const std::string &name) const
Returns the widget with the tab that has specified caption.
void updateArrowEnableState()
Check whether the arrow should be clickable.
std::unique_ptr< Button > mArrowButton[2]
The tab arrows.
Definition tabbedarea.h:118
unsigned mTabScrollIndex
The tab scroll index.
Definition tabbedarea.h:152
Graphics * graphics
Definition client.cpp:104