Crazy Eddie's GUI System  0.8.5
NamedElement.h
1 /***********************************************************************
2  created: 30/10/2011
3  author: Martin Preisler
4 
5  purpose: Adds naming and name path traversal to Element
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 
30 #ifndef _CEGUINamedElement_h_
31 #define _CEGUINamedElement_h_
32 
33 #include "CEGUI/Element.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
43 
49 class CEGUIEXPORT NamedElementEventArgs : public EventArgs
50 {
51 public:
53  element(element)
54  {}
55 
58 };
59 
74 class CEGUIEXPORT NamedElement :
75  public Element
76 {
77 public:
79  static const String EventNamespace;
80 
81  // generated internally by NamedElement
86  static const String EventNameChanged;
87 
93  NamedElement(const String& name = "");
94 
98  virtual ~NamedElement();
99 
109  virtual void setName(const String& name);
110 
114  inline const String& getName() const
115  {
116  return d_name;
117  }
118 
122  String getNamePath() const;
123 
124  using Element::isChild;
135  bool isChild(const String& name_path) const;
136 
154  bool isChildRecursive(const String& name) const;
155 
156  using Element::isAncestor;
169  bool isAncestor(const String& name) const;
170 
184  NamedElement* getChildElement(const String& name_path) const;
185 
196  NamedElement* getChildElementRecursive(const String& name) const;
197 
198  using Element::removeChild;
209  void removeChild(const String& name_path);
210 
211 protected:
213  virtual void addChild_impl(Element* element);
214 
218  virtual NamedElement* getChildByNamePath_impl(const String& name_path) const;
219 
223  virtual NamedElement* getChildByNameRecursive_impl(const String& name) const;
224 
228  void addNamedElementProperties();
229 
238  virtual void onNameChanged(NamedElementEventArgs& e);
239 
242 
243 private:
244  /*************************************************************************
245  May not copy or assign Element objects
246  *************************************************************************/
247  NamedElement(const Element&) {}
248  NamedElement& operator=(const NamedElement&) {return *this;}
249 };
250 
251 } // End of CEGUI namespace section
252 
253 
254 #if defined(_MSC_VER)
255 # pragma warning(pop)
256 #endif
257 
258 #endif // end of guard _CEGUINamedElement_h_
const String & getName() const
Return a String object holding the name of this Element.
Definition: NamedElement.h:114
void removeChild(Element *element)
Remove the Element Element's child list.
bool isChild(const Element *element) const
Checks whether given element is attached to this Element.
Adds name to the Element class, including name path traversal.
Definition: NamedElement.h:74
static const String EventNamespace
Namespace for global events.
Definition: NamedElement.h:79
static const String EventNameChanged
Definition: NamedElement.h:86
bool isAncestor(const Element *element) const
Checks whether the specified Element is an ancestor of this Element.
String d_name
The name of the element, unique in the parent of this element.
Definition: NamedElement.h:241
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
A positioned and sized rectangular node in a tree graph.
Definition: Element.h:242
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
NamedElement * element
pointer to an Element object of relevance to the event.
Definition: NamedElement.h:57
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: NamedElement.h:49
String class used within the GUI system.
Definition: String.h:62