Mercurial > fife-parpg
comparison ext/guichan-0.8.1/include/guichan/widgets/tabbedarea.hpp @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /* _______ __ __ __ ______ __ __ _______ __ __ | |
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ | |
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / | |
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / | |
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / | |
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / | |
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ | |
8 * | |
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson | |
10 * | |
11 * | |
12 * Per Larsson a.k.a finalman | |
13 * Olof Naessén a.k.a jansem/yakslem | |
14 * | |
15 * Visit: http://guichan.sourceforge.net | |
16 * | |
17 * License: (BSD) | |
18 * Redistribution and use in source and binary forms, with or without | |
19 * modification, are permitted provided that the following conditions | |
20 * are met: | |
21 * 1. Redistributions of source code must retain the above copyright | |
22 * notice, this list of conditions and the following disclaimer. | |
23 * 2. Redistributions in binary form must reproduce the above copyright | |
24 * notice, this list of conditions and the following disclaimer in | |
25 * the documentation and/or other materials provided with the | |
26 * distribution. | |
27 * 3. Neither the name of Guichan nor the names of its contributors may | |
28 * be used to endorse or promote products derived from this software | |
29 * without specific prior written permission. | |
30 * | |
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
42 */ | |
43 | |
44 #ifndef GCN_TABBEDAREA_HPP | |
45 #define GCN_TABBEDAREA_HPP | |
46 | |
47 #include <map> | |
48 #include <string> | |
49 #include <vector> | |
50 | |
51 #include "guichan/actionlistener.hpp" | |
52 #include "guichan/basiccontainer.hpp" | |
53 #include "guichan/keylistener.hpp" | |
54 #include "guichan/mouselistener.hpp" | |
55 #include "guichan/platform.hpp" | |
56 | |
57 namespace gcn | |
58 { | |
59 class Container; | |
60 class Tab; | |
61 | |
62 /** | |
63 * An implementation of a tabbed area where a user can display a widget by | |
64 * selecting a tab. | |
65 */ | |
66 class GCN_CORE_DECLSPEC TabbedArea: | |
67 public ActionListener, | |
68 public BasicContainer, | |
69 public KeyListener, | |
70 public MouseListener | |
71 { | |
72 friend class Tab; | |
73 | |
74 public: | |
75 /** | |
76 * Constructor. | |
77 */ | |
78 TabbedArea(); | |
79 | |
80 /** | |
81 * Destructor. | |
82 */ | |
83 virtual ~TabbedArea(); | |
84 | |
85 /** | |
86 * Adds a tab to the tabbed area. | |
87 * | |
88 * @param caption The caption of the tab to add. | |
89 * @param widget The widget to view when the tab is selected. | |
90 * @see removeTab, removeTabWithIndex | |
91 */ | |
92 virtual void addTab(const std::string& caption, Widget* widget); | |
93 | |
94 /** | |
95 * Adds a tab to the tabbed area. | |
96 * | |
97 * @param tab The tab widget for the tab. | |
98 * @param widget The widget to view when the tab is selected. | |
99 * @see removeTab, removeTabWithIndex | |
100 */ | |
101 virtual void addTab(Tab* tab, Widget* widget); | |
102 | |
103 /** | |
104 * Removes a tab from the tabbed area. | |
105 * | |
106 * @param index The index of the tab to remove. | |
107 * @see addTab | |
108 */ | |
109 virtual void removeTabWithIndex(unsigned int index); | |
110 | |
111 /** | |
112 * Removes a tab from the tabbed area. | |
113 * | |
114 * @param index The tab to remove. | |
115 * @see addTab | |
116 */ | |
117 virtual void removeTab(Tab* tab); | |
118 | |
119 /** | |
120 * Checks if a tab given an index is selected or not. | |
121 * | |
122 * @param index The index of the tab to check. | |
123 * @return True if the tab is selected, false otherwise. | |
124 * @see setSelectedTab | |
125 */ | |
126 virtual bool isTabSelected(unsigned int index) const; | |
127 | |
128 /** | |
129 * Checks if a tab is selected or not. | |
130 * | |
131 * @param index The tab to check. | |
132 * @return True if the tab is selected, false otherwise. | |
133 * @see setSelectedTab | |
134 */ | |
135 virtual bool isTabSelected(Tab* tab); | |
136 | |
137 /** | |
138 * Sets a tab given an index to be selected. | |
139 * | |
140 * @param index The index of the tab to be selected. | |
141 * @see isTabSelected, getSelectedTab | |
142 */ | |
143 virtual void setSelectedTab(unsigned int index); | |
144 | |
145 /** | |
146 * Sets a tab to be selected or not. | |
147 * | |
148 * @param index The tab to be selected. | |
149 * @see isTabSelected, getSelectedTab | |
150 */ | |
151 virtual void setSelectedTab(Tab* tab); | |
152 | |
153 /** | |
154 * Gets the index of the selected tab. | |
155 * | |
156 * @return The undex of the selected tab. | |
157 * If no tab is selected -1 will be returned. | |
158 * @see isTabSelected, setSelectedTab | |
159 */ | |
160 virtual int getSelectedTabIndex() const; | |
161 | |
162 /** | |
163 * Gets the selected tab. | |
164 * | |
165 * @return The selected tab. | |
166 * @see isTabSelected, setSelectedTab | |
167 */ | |
168 Tab* getSelectedTab(); | |
169 | |
170 | |
171 // Inherited from Widget | |
172 | |
173 virtual void draw(Graphics *graphics); | |
174 | |
175 virtual void logic(); | |
176 | |
177 void setWidth(int width); | |
178 | |
179 void setHeight(int height); | |
180 | |
181 void setSize(int width, int height); | |
182 | |
183 void setDimension(const Rectangle& dimension); | |
184 | |
185 | |
186 // Inherited from ActionListener | |
187 | |
188 void action(const ActionEvent& actionEvent); | |
189 | |
190 | |
191 // Inherited from DeathListener | |
192 | |
193 virtual void death(const Event& event); | |
194 | |
195 | |
196 // Inherited from KeyListener | |
197 | |
198 virtual void keyPressed(KeyEvent& keyEvent); | |
199 | |
200 | |
201 // Inherited from MouseListener | |
202 | |
203 virtual void mousePressed(MouseEvent& mouseEvent); | |
204 | |
205 | |
206 protected: | |
207 /** | |
208 * Adjusts the size of the tabbed area. | |
209 */ | |
210 void adjustSize(); | |
211 | |
212 /** | |
213 * Adjusts the positions of the tabs. | |
214 */ | |
215 void adjustTabPositions(); | |
216 | |
217 /** | |
218 * Holds the selected tab. | |
219 */ | |
220 Tab* mSelectedTab; | |
221 | |
222 /** | |
223 * Holds the container for the tabs. | |
224 */ | |
225 Container* mTabContainer; | |
226 | |
227 /** | |
228 * Holds the container for the widgets. | |
229 */ | |
230 Container* mWidgetContainer; | |
231 | |
232 /** | |
233 * Holds a vector of tabs to delete in the destructor. | |
234 * A tab that is to be deleted is a tab that has been | |
235 * internally created by the tabbed area. | |
236 */ | |
237 std::vector<Tab*> mTabsToDelete; | |
238 | |
239 /** | |
240 * A map between a tab and a widget to display when the | |
241 * tab is selected. | |
242 */ | |
243 std::vector<std::pair<Tab*, Widget*> > mTabs; | |
244 }; | |
245 } | |
246 | |
247 #endif // end GCN_TABBEDAREA_HPP |