ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

tab.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GUI_WIDGETS_TAB_H
00024 #define GUI_WIDGETS_TAB_H
00025 
00026 #include "gui/widget.h"
00027 #include "common/str.h"
00028 #include "common/array.h"
00029 
00030 namespace GUI {
00031 
00032 enum {
00033     kTabForwards = 1,
00034     kTabBackwards = -1
00035 };
00036 
00037 class TabWidget : public Widget {
00038     typedef Common::String String;
00039     struct Tab {
00040         String title;
00041         Widget *firstWidget;
00042         int _tabWidth;
00043     };
00044     typedef Common::Array<Tab> TabList;
00045 
00046 protected:
00047     int _activeTab;
00048     int _firstVisibleTab;
00049     int _lastVisibleTab;
00050     TabList _tabs;
00051     int _tabHeight;
00052     int _minTabWidth;
00053 
00054     int _bodyRP, _bodyTP, _bodyLP, _bodyBP;
00055     ThemeEngine::DialogBackground _bodyBackgroundType;
00056 
00057     int _titleVPad;
00058 
00059     int _butRP, _butTP, _butW, _butH;
00060 
00061     ButtonWidget *_navLeft, *_navRight;
00062     bool _navButtonsVisible;
00063 
00064 public:
00065     TabWidget(GuiObject *boss, int x, int y, int w, int h);
00066     TabWidget(GuiObject *boss, const String &name);
00067     ~TabWidget();
00068 
00069     void init();
00070 
00075     int addTab(const String &title);
00076 
00086     void removeTab(int tabID);
00087 
00088     int getActiveTab() {
00089         return _activeTab;
00090     }
00091 
00097     void setActiveTab(int tabID);
00098 
00099     void setTabTitle(int tabID, const String &title) {
00100         assert(0 <= tabID && tabID < (int)_tabs.size());
00101         _tabs[tabID].title = title;
00102     }
00103 
00104     virtual void handleMouseDown(int x, int y, int button, int clickCount) override;
00105     virtual bool handleKeyDown(Common::KeyState state) override;
00106     virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
00107     virtual int getFirstVisible() const;
00108     virtual void setFirstVisible(int tabID, bool adjustIfRoom = false);
00109 
00110     virtual bool containsWidget(Widget *) const override;
00111 
00112     virtual void reflowLayout() override;
00113 
00114     void draw() override;
00115     void markAsDirty() override;
00116 
00117 protected:
00118     // We overload getChildY to make sure child widgets are positioned correctly.
00119     // Essentially this compensates for the space taken up by the tab title header.
00120     virtual int16 getChildY() const override;
00121     virtual uint16 getHeight() const override;
00122 
00123     virtual void drawWidget() override;
00124 
00125     virtual Widget *findWidget(int x, int y) override;
00126 
00127     virtual void adjustTabs(int value);
00128 
00129     virtual void computeLastVisibleTab(bool adjustFirstIfRoom);
00130 };
00131 
00132 } // End of namespace GUI
00133 
00134 #endif


Generated on Sat Feb 16 2019 05:01:08 for ResidualVM by doxygen 1.7.1
curved edge   curved edge