1 | /************************************************************************
|
---|
2 | filename: CEGUIScrolledContainer.h
|
---|
3 | created: 1/3/2005
|
---|
4 | author: Paul D Turner
|
---|
5 | *************************************************************************/
|
---|
6 | /*************************************************************************
|
---|
7 | Crazy Eddie's GUI System (http://www.cegui.org.uk)
|
---|
8 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2.1 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public
|
---|
21 | License along with this library; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | *************************************************************************/
|
---|
24 | #ifndef _CEGUIScrolledContainer_h_
|
---|
25 | #define _CEGUIScrolledContainer_h_
|
---|
26 |
|
---|
27 | #include "CEGUIWindow.h"
|
---|
28 | #include "CEGUIWindowFactory.h"
|
---|
29 | #include "elements/CEGUIScrolledContainerProperties.h"
|
---|
30 | #include <map>
|
---|
31 |
|
---|
32 | // Start of CEGUI namespace section
|
---|
33 | namespace CEGUI
|
---|
34 | {
|
---|
35 | /*!
|
---|
36 | \brief
|
---|
37 | Helper container window class which is used in the implementation of the
|
---|
38 | ScrollablePane widget class.
|
---|
39 | */
|
---|
40 | class CEGUIEXPORT ScrolledContainer : public Window
|
---|
41 | {
|
---|
42 | public:
|
---|
43 | /*************************************************************************
|
---|
44 | Constants
|
---|
45 | *************************************************************************/
|
---|
46 | static const String WidgetTypeName; //!< Type name for ScrolledContainer.
|
---|
47 | static const String EventNamespace; //!< Namespace for global events
|
---|
48 | static const String EventContentChanged; //!< Event fired whenever some child changes.
|
---|
49 | static const String EventAutoSizeSettingChanged; //!< Event fired when the autosize setting changes.
|
---|
50 |
|
---|
51 | /*************************************************************************
|
---|
52 | Object construction and destruction
|
---|
53 | *************************************************************************/
|
---|
54 | /*!
|
---|
55 | \brief
|
---|
56 | Constructor for ScrolledContainer objects.
|
---|
57 | */
|
---|
58 | ScrolledContainer(const String& type, const String& name);
|
---|
59 |
|
---|
60 | /*!
|
---|
61 | \brief
|
---|
62 | Destructor for ScrolledContainer objects.
|
---|
63 | */
|
---|
64 | ~ScrolledContainer(void);
|
---|
65 |
|
---|
66 | /*************************************************************************
|
---|
67 | Public interface methods
|
---|
68 | *************************************************************************/
|
---|
69 | /*!
|
---|
70 | \brief
|
---|
71 | Return whether the content pane is auto sized.
|
---|
72 |
|
---|
73 | \return
|
---|
74 | - true to indicate the content pane will automatically resize itself.
|
---|
75 | - false to indicate the content pane will not automatically resize itself.
|
---|
76 | */
|
---|
77 | bool isContentPaneAutoSized(void) const;
|
---|
78 |
|
---|
79 | /*!
|
---|
80 | \brief
|
---|
81 | Set whether the content pane should be auto-sized.
|
---|
82 |
|
---|
83 | \param setting
|
---|
84 | - true to indicate the content pane should automatically resize itself.
|
---|
85 | - false to indicate the content pane should not automatically resize itself.
|
---|
86 |
|
---|
87 | \return
|
---|
88 | Nothing.
|
---|
89 | */
|
---|
90 | void setContentPaneAutoSized(bool setting);
|
---|
91 |
|
---|
92 | /*!
|
---|
93 | \brief
|
---|
94 | Return the current content pane area for the ScrolledContainer.
|
---|
95 |
|
---|
96 | \return
|
---|
97 | Rect object that details the current pixel extents of the content
|
---|
98 | pane represented by this ScrolledContainer.
|
---|
99 | */
|
---|
100 | const Rect& getContentArea(void) const;
|
---|
101 |
|
---|
102 | /*!
|
---|
103 | \brief
|
---|
104 | Set the current content pane area for the ScrolledContainer.
|
---|
105 |
|
---|
106 | \note
|
---|
107 | If the ScrolledContainer is configured to auto-size the content pane
|
---|
108 | this call will have no effect.
|
---|
109 |
|
---|
110 | \param area
|
---|
111 | Rect object that details the pixel extents to use for the content
|
---|
112 | pane represented by this ScrolledContainer.
|
---|
113 |
|
---|
114 | \return
|
---|
115 | Nothing.
|
---|
116 | */
|
---|
117 | void setContentArea(const Rect& area);
|
---|
118 |
|
---|
119 | /*!
|
---|
120 | \brief
|
---|
121 | Return the current extents of the attached content.
|
---|
122 |
|
---|
123 | \return
|
---|
124 | Rect object that describes the pixel extents of the attached
|
---|
125 | child windows. This is effectively the smallest bounding box
|
---|
126 | that could contain all the attached windows.
|
---|
127 | */
|
---|
128 | Rect getChildExtentsArea(void) const;
|
---|
129 |
|
---|
130 | protected:
|
---|
131 | /*************************************************************************
|
---|
132 | Implementation methods
|
---|
133 | *************************************************************************/
|
---|
134 | /*!
|
---|
135 | \brief
|
---|
136 | Adds events for this widget type.
|
---|
137 | */
|
---|
138 | void addScrolledContainerEvents(void);
|
---|
139 |
|
---|
140 |
|
---|
141 | /*!
|
---|
142 | \brief
|
---|
143 | Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
|
---|
144 |
|
---|
145 | \param class_name
|
---|
146 | The class name that is to be checked.
|
---|
147 |
|
---|
148 | \return
|
---|
149 | true if this window was inherited from \a class_name. false if not.
|
---|
150 | */
|
---|
151 | virtual bool testClassName_impl(const String& class_name) const
|
---|
152 | {
|
---|
153 | if (class_name==(const utf8*)"ScrolledContainer") return true;
|
---|
154 | return Window::testClassName_impl(class_name);
|
---|
155 | }
|
---|
156 |
|
---|
157 | /*************************************************************************
|
---|
158 | Implementation of abstract methods from Window
|
---|
159 | *************************************************************************/
|
---|
160 | void drawSelf(float z) {};
|
---|
161 |
|
---|
162 | /*************************************************************************
|
---|
163 | Event trigger methods.
|
---|
164 | *************************************************************************/
|
---|
165 | /*!
|
---|
166 | \brief
|
---|
167 | Notification method called whenever the content size may have changed.
|
---|
168 |
|
---|
169 | \param e
|
---|
170 | WindowEventArgs object.
|
---|
171 |
|
---|
172 | \return
|
---|
173 | Nothing.
|
---|
174 | */
|
---|
175 | virtual void onContentChanged(WindowEventArgs& e);
|
---|
176 |
|
---|
177 | /*!
|
---|
178 | \brief
|
---|
179 | Notification method called whenever the setting that controls whether
|
---|
180 | the content pane is automatically sized is changed.
|
---|
181 |
|
---|
182 | \param e
|
---|
183 | WindowEventArgs object.
|
---|
184 |
|
---|
185 | \return
|
---|
186 | Nothing.
|
---|
187 | */
|
---|
188 | virtual void onAutoSizeSettingChanged(WindowEventArgs& e);
|
---|
189 |
|
---|
190 | /*************************************************************************
|
---|
191 | Event callbacks
|
---|
192 | *************************************************************************/
|
---|
193 | /*!
|
---|
194 | \brief
|
---|
195 | Method which receives notifications about child windows being moved.
|
---|
196 | */
|
---|
197 | bool handleChildSized(const EventArgs& e);
|
---|
198 |
|
---|
199 | /*!
|
---|
200 | \brief
|
---|
201 | Method which receives notifications about child windows being sized.
|
---|
202 | */
|
---|
203 | bool handleChildMoved(const EventArgs& e);
|
---|
204 |
|
---|
205 | /*************************************************************************
|
---|
206 | Overridden from Window.
|
---|
207 | *************************************************************************/
|
---|
208 | Rect getUnclippedInnerRect(void) const;
|
---|
209 | void onChildAdded(WindowEventArgs& e);
|
---|
210 | void onChildRemoved(WindowEventArgs& e);
|
---|
211 | void onParentSized(WindowEventArgs& e);
|
---|
212 |
|
---|
213 | /*************************************************************************
|
---|
214 | Data fields
|
---|
215 | *************************************************************************/
|
---|
216 | typedef std::multimap<Window*, Event::Connection> ConnectionTracker;
|
---|
217 | ConnectionTracker d_eventConnections; //!< Tracks event connections we make.
|
---|
218 | Rect d_contentArea; //!< Holds extents of the content pane.
|
---|
219 | bool d_autosizePane; //!< true if the pane auto-sizes itself.
|
---|
220 |
|
---|
221 | private:
|
---|
222 | /*************************************************************************
|
---|
223 | Static Properties for this class
|
---|
224 | *************************************************************************/
|
---|
225 | static ScrolledContainerProperties::ContentPaneAutoSized d_autoSizedProperty;
|
---|
226 | static ScrolledContainerProperties::ContentArea d_contentAreaProperty;
|
---|
227 | static ScrolledContainerProperties::ChildExtentsArea d_childExtentsAreaProperty;
|
---|
228 |
|
---|
229 | /*************************************************************************
|
---|
230 | Private methods
|
---|
231 | *************************************************************************/
|
---|
232 | void addScrolledContainerProperties(void);
|
---|
233 | };
|
---|
234 |
|
---|
235 | /*!
|
---|
236 | \brief
|
---|
237 | Factory class for producing ScrolledContainer windows
|
---|
238 | */
|
---|
239 | class ScrolledContainerFactory : public WindowFactory
|
---|
240 | {
|
---|
241 | public:
|
---|
242 | ScrolledContainerFactory(void) : WindowFactory(ScrolledContainer::WidgetTypeName) { }
|
---|
243 | ~ScrolledContainerFactory(void){}
|
---|
244 |
|
---|
245 | Window* createWindow(const String& name)
|
---|
246 | {
|
---|
247 | ScrolledContainer* wnd = new ScrolledContainer(d_type, name);
|
---|
248 | return wnd;
|
---|
249 | }
|
---|
250 |
|
---|
251 | void destroyWindow(Window* window)
|
---|
252 | {
|
---|
253 | if (window->getType() == d_type)
|
---|
254 | delete window;
|
---|
255 | }
|
---|
256 |
|
---|
257 | };
|
---|
258 |
|
---|
259 | } // End of CEGUI namespace section
|
---|
260 |
|
---|
261 |
|
---|
262 | #endif // end of guard _CEGUIScrolledContainer_h_
|
---|