comparison ext/guichan-0.8.2/include/guichan/widgets/container.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_CONTAINER_HPP
45 #define GCN_CONTAINER_HPP
46
47 #include <list>
48
49 #include "guichan/basiccontainer.hpp"
50 #include "guichan/graphics.hpp"
51 #include "guichan/platform.hpp"
52
53 namespace gcn
54 {
55 /**
56 * An implementation of a container able to contain other widgets. A widget's
57 * position in the container is relative to the container itself and not the screen.
58 * A container is the most common widget to use as the Gui's top widget as makes the Gui
59 * able to contain more than one widget.
60 *
61 * @see Gui::setTop
62 */
63 class GCN_CORE_DECLSPEC Container: public BasicContainer
64 {
65 public:
66
67 /**
68 * Constructor. A container is opauqe as default, if you want a
69 * none opaque container call setQpaque(false).
70 *
71 * @see setOpaque, isOpaque
72 */
73 Container();
74
75 /**
76 * Destructor.
77 */
78 virtual ~Container();
79
80 /**
81 * Sets the container to be opaque or not. If the container
82 * is opaque its background will be drawn, if it's not opaque
83 * its background will not be drawn, and thus making the container
84 * completely transparent.
85 *
86 * NOTE: This is not the same as to set visibility. A non visible
87 * container will not itself nor will it draw its content.
88 *
89 * @param opaque True if the container should be opaque, false otherwise.
90 * @see isOpaque
91 */
92 void setOpaque(bool opaque);
93
94 /**
95 * Checks if the container is opaque or not.
96 *
97 * @return True if the container is opaque, false otherwise.
98 * @see setOpaque
99 */
100 bool isOpaque() const;
101
102 /**
103 * Adds a widget to the container.
104 *
105 * @param widget The widget to add.
106 * @see remove, clear
107 */
108 virtual void add(Widget* widget);
109
110 /**
111 * Adds a widget to the container and also specifies the widget's
112 * position in the container. The position is relative to the container
113 * and not relative to the screen.
114 *
115 * @param widget The widget to add.
116 * @param x The x coordinate for the widget.
117 * @param y The y coordinate for the widget.
118 * @see remove, clear
119 */
120 virtual void add(Widget* widget, int x, int y);
121
122 /**
123 * Removes a widget from the Container.
124 *
125 * @param widget The widget to remove.
126 * @throws Exception when the widget has not been added to the
127 * container.
128 * @see add, clear
129 */
130 virtual void remove(Widget* widget);
131
132 /**
133 * Clears the container of all widgets.
134 *
135 * @see add, remove
136 */
137 virtual void clear();
138
139 /**
140 * Finds a widget given an id.
141 *
142 * @param id The id to find a widget by.
143 * @return A widget with a corrosponding id, NULL if no widget
144 * is found.
145 * @see Widget::setId
146 */
147 virtual Widget* findWidgetById(const std::string &id);
148
149
150 // Inherited from Widget
151
152 virtual void draw(Graphics* graphics);
153
154 protected:
155 /**
156 * True if the container is opaque, false otherwise.
157 */
158 bool mOpaque;
159 };
160 }
161
162 #endif // end GCN_CONTAINER_HPP