Crazy Eddie's GUI System  0.8.4
CEGUI::NamedElement Class Reference

Adds name to the Element class, including name path traversal. More...

+ Inheritance diagram for CEGUI::NamedElement:
+ Collaboration diagram for CEGUI::NamedElement:

List of all members.

Public Member Functions

 NamedElement (const String &name="")
 Constructor.
virtual ~NamedElement ()
 Destructor.
virtual void setName (const String &name)
 Renames the element.
const StringgetName () const
 Return a String object holding the name of this Element.
String getNamePath () const
 Return a String object that describes the name path for this Element.
bool isChild (const String &name_path) const
 Checks whether given name path references a NamedElement that is attached to this Element.
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 children as a child.
bool isAncestor (const String &name) const
 Return true if the specified element name is a name of some ancestor of this Element.
NamedElementgetChildElement (const String &name_path) const
 Return the attached child element that the given name path references.
NamedElementgetChildElementRecursive (const String &name) const
 Find the first child with the given name, recursively and breadth-first.
void removeChild (const String &name_path)
 Remove the Element referenced by the given name path from this Element's child list.

Static Public Attributes

static const String EventNamespace
 Namespace for global events.
static const String EventNameChanged

Protected Member Functions

virtual void addChild_impl (Element *element)
virtual NamedElementgetChildByNamePath_impl (const String &name_path) const
 Retrieves a child at name_path or 0 if none such exists.
virtual NamedElementgetChildByNameRecursive_impl (const String &name) const
 Finds a child by name or 0 if none such exists.
void addNamedElementProperties ()
 Add standard CEGUI::NamedElement properties.
virtual void onNameChanged (NamedElementEventArgs &e)
 Handler called when the element's name changes.

Protected Attributes

String d_name
 The name of the element, unique in the parent of this element.

Detailed Description

Adds name to the Element class, including name path traversal.

Name path
A name path is a string that describes a path down the element hierarchy using names and the forward slash '/' as a separator. For example, if this element has a child attached to it named "Panel" which has its own children attached named "Okay" and "Cancel", you can check for the element "Okay" from this element by using the name path "Panel/Okay". To check for "Panel", you would simply pass the name "Panel".
See also:
Element

Constructor & Destructor Documentation

CEGUI::NamedElement::NamedElement ( const String name = "")

Constructor.

Parameters:
nameThe initial name this element will have

Member Function Documentation

virtual void CEGUI::NamedElement::addChild_impl ( Element element) [protected, virtual]

Add given element to child list at an appropriate position.

Reimplemented from CEGUI::Element.

Reimplemented in CEGUI::Window, CEGUI::ScrollablePane, CEGUI::TabControl, CEGUI::GridLayoutContainer, CEGUI::LayoutContainer, CEGUI::LayoutCell, and CEGUI::GroupBox.

Return the attached child element that the given name path references.

Parameters:
name_pathString object holding the name path of the child element to return.
Returns:
the NamedElement object referenced by name_path.
Exceptions:
UnknownObjectExceptionthrown if name_path does not reference an Element attached to this Element.

Find the first child with the given name, recursively and breadth-first.

Parameters:
nameString object holding the name of the child element to find.
Returns:
Pointer to the (first) Element object attached to this Element that has the name name
bool CEGUI::NamedElement::isAncestor ( const String name) const

Return true if the specified element name is a name of some ancestor of this Element.

Parameters:
nameString object holding the name to check for.
Returns:
  • true if an element named name is an ancestor (parent, or parent of parent, etc) of this element.
  • false if an element named name is in no way an ancestor of this element.
bool CEGUI::NamedElement::isChild ( const String name_path) const

Checks whether given name path references a NamedElement that is attached to this Element.

Parameters:
name_pathString object holding the name path of the child element to test.
Returns:
  • true if the element referenced by name_path is attached.
  • false if the element referenced by name_path is not attached.
bool CEGUI::NamedElement::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 children as a child.

Note:
WARNING! This function can be very expensive and should only be used when you have no other option available. If you decide to use it anyway, make sure the window hierarchy from the entry point is small.
Parameters:
IDuint ID code to look for.
Returns:
  • true if at least one child window was found with the name name
    • false if no child window was found with the name name.
virtual void CEGUI::NamedElement::onNameChanged ( NamedElementEventArgs e) [protected, virtual]

Handler called when the element's name changes.

Parameters:
eNamedElementEventArgs object whose 'element' pointer field is set to the element that triggered the event. For this event the trigger element is always 'this'.
void CEGUI::NamedElement::removeChild ( const String name_path)

Remove the Element referenced by the given name path from this Element's child list.

Parameters:
name_pathString the name path that references the the Element to be removed. If the Element specified is not attached to this Window, UnknownObjectException is thrown
virtual void CEGUI::NamedElement::setName ( const String name) [virtual]

Renames the element.

Parameters:
nameString object holding the new name for the element.
Exceptions:
AlreadyExistsExceptionthrown if an element named name already exists in the parent of this element.

Member Data Documentation

Event fired when the Element name has changed. Handlers are passed a const NamedElementEventArgs reference with NamedElementEventArgs::element set to the Element whose name was changed.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends