Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
NamedElement.h
1 /***********************************************************************
2  filename: CEGUI/NamedElement.h
3  created: 30/10/2011
4  author: Martin Preisler
5 
6  purpose: Adds naming and name path traversal to Element
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2011 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 
31 #ifndef _CEGUINamedElement_h_
32 #define _CEGUINamedElement_h_
33 
34 #include "CEGUI/Element.h"
35 
36 #if defined(_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
44 
50 class CEGUIEXPORT NamedElementEventArgs : public EventArgs
51 {
52 public:
54  element(element)
55  {}
56 
59 };
60 
75 class CEGUIEXPORT NamedElement :
76  public Element
77 {
78 public:
80  static const String EventNamespace;
81 
82  // generated internally by NamedElement
87  static const String EventNameChanged;
88 
94  NamedElement(const String& name = "");
95 
99  virtual ~NamedElement();
100 
110  virtual void setName(const String& name);
111 
115  inline const String& getName() const
116  {
117  return d_name;
118  }
119 
123  String getNamePath() const;
124 
125  using Element::isChild;
136  bool isChild(const String& name_path) const;
137 
155  bool isChildRecursive(const String& name) const;
156 
157  using Element::isAncestor;
170  bool isAncestor(const String& name) const;
171 
185  NamedElement* getChildElement(const String& name_path) const;
186 
197  NamedElement* getChildElementRecursive(const String& name) const;
198 
199  using Element::removeChild;
210  void removeChild(const String& name_path);
211 
212 protected:
214  virtual void addChild_impl(Element* element);
215 
219  virtual NamedElement* getChildByNamePath_impl(const String& name_path) const;
220 
224  virtual NamedElement* getChildByNameRecursive_impl(const String& name) const;
225 
229  void addNamedElementProperties();
230 
239  virtual void onNameChanged(NamedElementEventArgs& e);
240 
243 
244 private:
245  /*************************************************************************
246  May not copy or assign Element objects
247  *************************************************************************/
248  NamedElement(const Element&) {}
249  NamedElement& operator=(const NamedElement&) {return *this;}
250 };
251 
252 } // End of CEGUI namespace section
253 
254 
255 #if defined(_MSC_VER)
256 # pragma warning(pop)
257 #endif
258 
259 #endif // end of guard _CEGUINamedElement_h_