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
41namespace CEGUI
42{
43
49class CEGUIEXPORT NamedElementEventArgs : public EventArgs
50{
51public:
53 element(element)
54 {}
55
58};
59
74class CEGUIEXPORT NamedElement :
75 public Element
76{
77public:
79 static const String EventNamespace;
80
81 // generated internally by NamedElement
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
169 bool isAncestor(const String& name) const;
170
184 NamedElement* getChildElement(const String& name_path) const;
185
197
209 void removeChild(const String& name_path);
210
211protected:
213 virtual void addChild_impl(Element* element);
214
218 virtual NamedElement* getChildByNamePath_impl(const String& name_path) const;
219
224
229
239
242
243private:
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_
A positioned and sized rectangular node in a tree graph.
Definition: Element.h:246
bool isAncestor(const Element *element) const
Checks whether the specified Element is an ancestor of this Element.
bool isChild(const Element *element) const
Checks whether given element is attached to this Element.
void removeChild(Element *element)
Remove the Element Element's child list.
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: NamedElement.h:50
NamedElement * element
pointer to an Element object of relevance to the event.
Definition: NamedElement.h:57
Adds name to the Element class, including name path traversal.
Definition: NamedElement.h:76
const String & getName() const
Return a String object holding the name of this Element.
Definition: NamedElement.h:114
virtual ~NamedElement()
Destructor.
static const String EventNamespace
Namespace for global events.
Definition: NamedElement.h:79
void addNamedElementProperties()
Add standard CEGUI::NamedElement properties.
bool isAncestor(const String &name) const
Return true if the specified element name is a name of some ancestor of this Element.
bool isChild(const String &name_path) const
Checks whether given name path references a NamedElement that is attached to this Element.
String getNamePath() const
Return a String object that describes the name path for this Element.
NamedElement * getChildElement(const String &name_path) const
Return the attached child element that the given name path references.
virtual void onNameChanged(NamedElementEventArgs &e)
Handler called when the element's name changes.
virtual void setName(const String &name)
Renames the element.
virtual NamedElement * getChildByNamePath_impl(const String &name_path) const
Retrieves a child at name_path or 0 if none such exists.
static const String EventNameChanged
Definition: NamedElement.h:86
NamedElement(const String &name="")
Constructor.
NamedElement * getChildElementRecursive(const String &name) const
Find the first child with the given name, recursively and breadth-first.
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...
virtual void addChild_impl(Element *element)
Add given element to child list at an appropriate position.
String d_name
The name of the element, unique in the parent of this element.
Definition: NamedElement.h:241
void removeChild(const String &name_path)
Remove the Element referenced by the given name path from this Element's child list.
virtual NamedElement * getChildByNameRecursive_impl(const String &name) const
Finds a child by name or 0 if none such exists.
String class used within the GUI system.
Definition: String.h:64
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1