comparison ext/guichan-0.8.2/include/guichan/basiccontainer.hpp @ 378:64738befdf3b

bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 11 Jan 2010 23:34:52 +0000
parents
children
comparison
equal deleted inserted replaced
377:fe6fb0e0ed23 378:64738befdf3b
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_BASICCONTAINER_HPP
45 #define GCN_BASICCONTAINER_HPP
46
47 #include <list>
48
49 #include "guichan/deathlistener.hpp"
50 #include "guichan/platform.hpp"
51 #include "guichan/widget.hpp"
52
53 namespace gcn
54 {
55 /**
56 * A base class for containers. The class implements the most
57 * common things for a container. If you are implementing a
58 * container, consider inheriting from this class.
59 *
60 * @see Container
61 * @since 0.6.0
62 */
63 class GCN_CORE_DECLSPEC BasicContainer : public Widget, public DeathListener
64 {
65 public:
66 /**
67 * Destructor
68 */
69 virtual ~BasicContainer();
70
71 /**
72 * Shows a certain part of a widget in the basic container.
73 * Used when widgets want a specific part to be visible in
74 * its parent. An example is a TextArea that wants a specific
75 * part of its text to be visible when a TextArea is a child
76 * of a ScrollArea.
77 *
78 * @param widget The widget whom wants a specific part of
79 * itself to be visible.
80 * @param rectangle The rectangle to be visible.
81 */
82 virtual void showWidgetPart(Widget* widget, Rectangle area);
83
84
85 // Inherited from Widget
86
87 virtual void moveToTop(Widget* widget);
88
89 virtual void moveToBottom(Widget* widget);
90
91 virtual Rectangle getChildrenArea();
92
93 virtual void focusNext();
94
95 virtual void focusPrevious();
96
97 virtual void logic();
98
99 virtual void _setFocusHandler(FocusHandler* focusHandler);
100
101 void setInternalFocusHandler(FocusHandler* focusHandler);
102
103 virtual Widget *getWidgetAt(int x, int y);
104
105
106 // Inherited from DeathListener
107
108 virtual void death(const Event& event);
109
110 protected:
111 /**
112 * Adds a widget to the basic container.
113 *
114 * @param widget The widget to add.
115 * @see remove, clear
116 */
117 void add(Widget* widget);
118
119 /**
120 * Removes a widget from the basic container.
121 *
122 * @param widget The widget to remove.
123 * @see add, clear
124 */
125 virtual void remove(Widget* widget);
126
127 /**
128 * Clears the basic container from all widgets.
129 *
130 * @see remove, clear
131 */
132 virtual void clear();
133
134 /**
135 * Draws the children widgets of the basic container.
136 *
137 * @param graphics A graphics object to draw with.
138 */
139 virtual void drawChildren(Graphics* graphics);
140
141 /**
142 * Calls logic for the children widgets of the basic
143 * container.
144 */
145 virtual void logicChildren();
146
147 /**
148 * Finds a widget given an id. This function can be useful
149 * when implementing a GUI generator for Guichan, such as
150 * the ability to create a Guichan GUI from an XML file.
151 *
152 * @param id The id to find a widget by.
153 * @return The widget with the corrosponding id,
154 NULL of no widget is found.
155 */
156 virtual Widget* findWidgetById(const std::string& id);
157
158 /**
159 * Typedef.
160 */
161 typedef std::list<Widget *> WidgetList;
162
163 /**
164 * Typedef.
165 */
166 typedef WidgetList::iterator WidgetListIterator;
167
168 /**
169 * Typedef.
170 */
171 typedef WidgetList::reverse_iterator WidgetListReverseIterator;
172
173 /**
174 * Holds all widgets of the basic container.
175 */
176 WidgetList mWidgets;
177 };
178 }
179
180 #endif // end GCN_BASICCONTAINER_HPP