Crazy Eddies GUI System  0.7.8
CEGUILayoutContainer.h
1 /***********************************************************************
2  filename: CEGUILayoutContainer.h
3  created: 29/7/2010
4  author: Martin Preisler
5 
6  purpose: Defines abstract base class for layout containers
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUILayoutContainer_h_
31 #define _CEGUILayoutContainer_h_
32 
33 #include "../CEGUIWindow.h"
34 
35 #include <map>
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 
54 class CEGUIEXPORT LayoutContainer : public Window
55 {
56 public:
57  /*************************************************************************
58  Event name constants
59  *************************************************************************/
61  static const String EventNamespace;
62 
73  LayoutContainer(const String& type, const String& name);
74 
79  virtual ~LayoutContainer(void);
80 
85  void markNeedsLayouting();
86 
91  bool needsLayouting() const;
92 
97  virtual void layout() = 0;
98 
104  virtual void layoutIfNecessary();
105 
107  virtual Rect getUnclippedInnerRect_impl(void) const;
108 
110  virtual void update(float elapsed);
111 
112 protected:
114  virtual Rect getClientChildWindowContentArea_impl() const;
115 
117  virtual bool testClassName_impl(const String& class_name) const
118  {
119  if (class_name == "LayoutContainer") return true;
120 
121  return Window::testClassName_impl(class_name);
122  }
123 
124  size_t getIdxOfChildWindow(Window* wnd) const;
125 
127  virtual void addChild_impl(Window* wnd);
129  virtual void removeChild_impl(Window* wnd);
130 
131  /*************************************************************************
132  Event trigger methods
133  *************************************************************************/
143  virtual bool handleChildSized(const EventArgs& e);
144 
154  virtual bool handleChildMarginChanged(const EventArgs& e);
155 
165  virtual bool handleChildAdded(const EventArgs& e);
166 
176  virtual bool handleChildRemoved(const EventArgs& e);
177 
182  virtual UVector2 getOffsetForWindow(Window* window) const;
183 
188  virtual UVector2 getBoundingSizeForWindow(Window* window) const;
189 
190  /*************************************************************************
191  Implementation Data
192  *************************************************************************/
193  // if true, we will relayout before rendering of this window starts
194  bool d_needsLayouting;
195 
196  typedef std::multimap<Window*, Event::Connection> ConnectionTracker;
198  ConnectionTracker d_eventConnections;
199 };
200 
201 } // End of CEGUI namespace section
202 
203 #if defined(_MSC_VER)
204 # pragma warning(pop)
205 #endif
206 
207 #endif // end of guard _CEGUILayoutContainer_h_
208