Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 30/10/2011 00003 author: Martin Preisler 00004 00005 purpose: Adds naming and name path traversal to Element 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 00030 #ifndef _CEGUINamedElement_h_ 00031 #define _CEGUINamedElement_h_ 00032 00033 #include "CEGUI/Element.h" 00034 00035 #if defined(_MSC_VER) 00036 # pragma warning(push) 00037 # pragma warning(disable : 4251) 00038 #endif 00039 00040 // Start of CEGUI namespace section 00041 namespace CEGUI 00042 { 00043 00049 class CEGUIEXPORT NamedElementEventArgs : public EventArgs 00050 { 00051 public: 00052 NamedElementEventArgs(NamedElement* element): 00053 element(element) 00054 {} 00055 00057 NamedElement* element; 00058 }; 00059 00074 class CEGUIEXPORT NamedElement : 00075 public Element 00076 { 00077 public: 00079 static const String EventNamespace; 00080 00081 // generated internally by NamedElement 00086 static const String EventNameChanged; 00087 00093 NamedElement(const String& name = ""); 00094 00098 virtual ~NamedElement(); 00099 00109 virtual void setName(const String& name); 00110 00114 inline const String& getName() const 00115 { 00116 return d_name; 00117 } 00118 00122 String getNamePath() const; 00123 00124 using Element::isChild; 00135 bool isChild(const String& name_path) const; 00136 00154 bool isChildRecursive(const String& name) const; 00155 00156 using Element::isAncestor; 00169 bool isAncestor(const String& name) const; 00170 00184 NamedElement* getChildElement(const String& name_path) const; 00185 00196 NamedElement* getChildElementRecursive(const String& name) const; 00197 00198 using Element::removeChild; 00209 void removeChild(const String& name_path); 00210 00211 protected: 00213 virtual void addChild_impl(Element* element); 00214 00218 virtual NamedElement* getChildByNamePath_impl(const String& name_path) const; 00219 00223 virtual NamedElement* getChildByNameRecursive_impl(const String& name) const; 00224 00228 void addNamedElementProperties(); 00229 00238 virtual void onNameChanged(NamedElementEventArgs& e); 00239 00241 String d_name; 00242 00243 private: 00244 /************************************************************************* 00245 May not copy or assign Element objects 00246 *************************************************************************/ 00247 NamedElement(const Element&) {} 00248 NamedElement& operator=(const NamedElement&) {return *this;} 00249 }; 00250 00251 } // End of CEGUI namespace section 00252 00253 00254 #if defined(_MSC_VER) 00255 # pragma warning(pop) 00256 #endif 00257 00258 #endif // end of guard _CEGUINamedElement_h_