Crazy Eddies GUI System  0.7.2
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 
109 protected:
111  virtual Rect getClientChildWindowContentArea_impl() const;
112 
114  virtual bool testClassName_impl(const String& class_name) const
115  {
116  if (class_name == "LayoutContainer") return true;
117 
118  return Window::testClassName_impl(class_name);
119  }
120 
121  size_t getIdxOfChildWindow(Window* wnd) const;
122 
124  virtual void addChild_impl(Window* wnd);
126  virtual void removeChild_impl(Window* wnd);
128  virtual void drawSelf(const RenderingContext& ctx);
129 
130  /*************************************************************************
131  Event trigger methods
132  *************************************************************************/
142  virtual bool handleChildSized(const EventArgs& e);
143 
153  virtual bool handleChildMarginChanged(const EventArgs& e);
154 
164  virtual bool handleChildAdded(const EventArgs& e);
165 
175  virtual bool handleChildRemoved(const EventArgs& e);
176 
181  virtual UVector2 getOffsetForWindow(Window* window) const;
182 
187  virtual UVector2 getBoundingSizeForWindow(Window* window) const;
188 
189  /*************************************************************************
190  Implementation Data
191  *************************************************************************/
192  // if true, we will relayout before rendering of this window starts
193  bool d_needsLayouting;
194 
195  typedef std::multimap<Window*, Event::Connection> ConnectionTracker;
197  ConnectionTracker d_eventConnections;
198 };
199 
200 } // End of CEGUI namespace section
201 
202 #if defined(_MSC_VER)
203 # pragma warning(pop)
204 #endif
205 
206 #endif // end of guard _CEGUILayoutContainer_h_
207