Crazy Eddie's GUI System  0.8.7
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 
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 
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 
229 
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_
CEGUI::Element::isChild
bool isChild(const Element *element) const
Checks whether given element is attached to this Element.
CEGUI::NamedElementEventArgs::element
NamedElement * element
pointer to an Element object of relevance to the event.
Definition: NamedElement.h:57
CEGUI::NamedElement::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: NamedElement.h:79
CEGUI::NamedElement::EventNameChanged
static const String EventNameChanged
Definition: NamedElement.h:86
CEGUI::Element::isAncestor
bool isAncestor(const Element *element) const
Checks whether the specified Element is an ancestor of this Element.
CEGUI::NamedElement::onNameChanged
virtual void onNameChanged(NamedElementEventArgs &e)
Handler called when the element's name changes.
CEGUI::NamedElement::addNamedElementProperties
void addNamedElementProperties()
Add standard CEGUI::NamedElement properties.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::NamedElement::NamedElement
NamedElement(const String &name="")
Constructor.
CEGUI::NamedElement::setName
virtual void setName(const String &name)
Renames the element.
CEGUI::NamedElement::~NamedElement
virtual ~NamedElement()
Destructor.
CEGUI::NamedElementEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: NamedElement.h:50
CEGUI::NamedElement::d_name
String d_name
The name of the element, unique in the parent of this element.
Definition: NamedElement.h:241
CEGUI::Element::removeChild
void removeChild(Element *element)
Remove the Element Element's child list.
CEGUI::NamedElement::getChildElementRecursive
NamedElement * getChildElementRecursive(const String &name) const
Find the first child with the given name, recursively and breadth-first.
CEGUI::NamedElement::getChildElement
NamedElement * getChildElement(const String &name_path) const
Return the attached child element that the given name path references.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::NamedElement::getChildByNamePath_impl
virtual NamedElement * getChildByNamePath_impl(const String &name_path) const
Retrieves a child at name_path or 0 if none such exists.
CEGUI::NamedElement::getName
const String & getName() const
Return a String object holding the name of this Element.
Definition: NamedElement.h:114
CEGUI::NamedElement::getNamePath
String getNamePath() const
Return a String object that describes the name path for this Element.
CEGUI::NamedElement::getChildByNameRecursive_impl
virtual NamedElement * getChildByNameRecursive_impl(const String &name) const
Finds a child by name or 0 if none such exists.
CEGUI::NamedElement::addChild_impl
virtual void addChild_impl(Element *element)
Add given element to child list at an appropriate position.
CEGUI::EventArgs
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
CEGUI::NamedElement
Adds name to the Element class, including name path traversal.
Definition: NamedElement.h:76
CEGUI::Element
A positioned and sized rectangular node in a tree graph.
Definition: Element.h:246
CEGUI::NamedElement::isChildRecursive
bool isChildRecursive(const String &name) const
returns whether at least one window with the given name is attached to this Window or any of it's chi...