Crazy Eddie's GUI System  0.8.4
WidgetLookFeel.h
00001 /***********************************************************************
00002     created:    Mon Jun 13 2005
00003     author:     Paul D Turner <paul@cegui.org.uk>
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software"), to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUIFalWidgetLookFeel_h_
00028 #define _CEGUIFalWidgetLookFeel_h_
00029 
00030 #include "./StateImagery.h"
00031 #include "./WidgetComponent.h"
00032 #include "./ImagerySection.h"
00033 #include "./PropertyInitialiser.h"
00034 #include "./PropertyDefinition.h"
00035 #include "./PropertyLinkDefinition.h"
00036 #include "./EventLinkDefinition.h"
00037 #include "./NamedArea.h"
00038 #include "./NamedDefinitionCollator.h"
00039 #include <map>
00040 
00041 #if defined(_MSC_VER)
00042 #   pragma warning(push)
00043 #   pragma warning(disable : 4251)
00044 #endif
00045 
00046 
00047 // Start of CEGUI namespace section
00048 namespace CEGUI
00049 {
00055 class CEGUIEXPORT WidgetLookFeel :
00056     public AllocatedObject<WidgetLookFeel>
00057 {
00058 public:
00059     WidgetLookFeel(const String& name, const String& inherits);
00060     WidgetLookFeel() {}
00061     WidgetLookFeel(const WidgetLookFeel& other);
00062     WidgetLookFeel& operator=(const WidgetLookFeel& other);
00063 
00064     virtual ~WidgetLookFeel();
00073     const StateImagery& getStateImagery(const CEGUI::String& state) const;
00074 
00083     const ImagerySection& getImagerySection(const CEGUI::String& section) const;
00084 
00092     const String& getName() const;
00093 
00104     void addImagerySection(const ImagerySection& section);
00105     void renameImagerySection(const String& oldName, const String& newName);
00106 
00117     void addWidgetComponent(const WidgetComponent& widget);
00118 
00129     void addStateSpecification(const StateImagery& state);
00130 
00141     void addPropertyInitialiser(const PropertyInitialiser& initialiser);
00142 
00150     void clearImagerySections();
00151 
00159     void clearWidgetComponents();
00160 
00168     void clearStateSpecifications();
00169 
00177     void clearPropertyInitialisers();
00178 
00190     void initialiseWidget(Window& widget) const;
00191 
00203     void cleanUpWidget(Window& widget) const;
00204 
00216     bool isStateImageryPresent(const String& state) const;
00217 
00228     void addNamedArea(const NamedArea& area);
00229 
00237     void clearNamedAreas();
00238 
00249     const NamedArea& getNamedArea(const String& name) const;
00250 
00251     void renameNamedArea(const String& oldName, const String& newName);
00265     bool isNamedAreaDefined(const String& name) const;
00266 
00278     void layoutChildWidgets(const Window& owner) const;
00279 
00290     void addPropertyDefinition(PropertyDefinitionBase* propdef);
00291 
00302     void addPropertyLinkDefinition(PropertyDefinitionBase* propdef);
00303 
00311     void clearPropertyDefinitions();
00312 
00320     void clearPropertyLinkDefinitions();
00321 
00331     void addAnimationName(const String& anim_name);
00332 
00334     void addEventLinkDefinition(const EventLinkDefinition& evtdef); 
00335 
00337     void clearEventLinkDefinitions();
00338 
00349     void writeXMLToStream(XMLSerializer& xml_stream) const;
00350 
00360     const PropertyInitialiser* findPropertyInitialiser(const String& propertyName) const;
00361 
00370     const WidgetComponent* findWidgetComponent(const String& name) const;
00371 
00373     typedef std::vector<PropertyInitialiser
00374         CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList;
00375     typedef std::vector<PropertyDefinitionBase*
00376         CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyDefinitionList;
00377     typedef std::vector<PropertyDefinitionBase*
00378         CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyLinkDefinitionList;
00379 
00385     const PropertyDefinitionList& getPropertyDefinitions() const
00386     {
00387         return d_propertyDefinitions;
00388     }
00389 
00395     const PropertyLinkDefinitionList& getPropertyLinkDefinitions() const
00396     {
00397         return d_propertyLinkDefinitions;
00398     }
00399 
00404     const PropertyList& getProperties() const
00405     {
00406         return d_properties;
00407     }
00408 
00410     bool handleFontRenderSizeChange(Window& window, const Font* font) const;
00411 
00412 private:
00413     typedef std::map<String, StateImagery, StringFastLessCompare
00414         CEGUI_MAP_ALLOC(String, StateImagery)> StateList;
00415     typedef std::map<String, ImagerySection, StringFastLessCompare
00416         CEGUI_MAP_ALLOC(String, ImagerySection)> ImageryList;
00417     typedef std::map<String, NamedArea, StringFastLessCompare
00418         CEGUI_MAP_ALLOC(String, NamedArea)> NamedAreaList;
00419     typedef std::vector<WidgetComponent
00420         CEGUI_VECTOR_ALLOC(WidgetComponent)> WidgetList;
00421     typedef std::vector<String
00422         CEGUI_VECTOR_ALLOC(String)> AnimationList;
00423     typedef std::multimap<Window*, AnimationInstance*
00424         /*CEGUI_MULTIMAP_ALLOC(Window*, AnimationInstance*)*/> AnimationInstanceMap;
00425     typedef std::vector<EventLinkDefinition
00426         CEGUI_VECTOR_ALLOC(EventLinkDefinition)> EventLinkDefinitionList;
00427 
00429     CEGUI::String d_lookName;
00431     CEGUI::String d_inheritedLookName;
00433     ImageryList d_imagerySections;
00435     WidgetList d_childWidgets;
00437     StateList d_stateImagery;
00439     PropertyList d_properties;
00441     NamedAreaList d_namedAreas;
00443     mutable PropertyDefinitionList  d_propertyDefinitions;
00445     mutable PropertyLinkDefinitionList d_propertyLinkDefinitions;
00447     AnimationList d_animations;
00449     mutable AnimationInstanceMap d_animationInstances;
00451     EventLinkDefinitionList d_eventLinkDefinitions;
00452 
00453     // these are container types used when composing final collections of
00454     // objects that come via inheritence.
00455     typedef NamedDefinitionCollator<String, const WidgetComponent*> WidgetComponentCollator;
00456     typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyDefinitionCollator;
00457     typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyLinkDefinitionCollator;
00458     typedef NamedDefinitionCollator<String, const PropertyInitialiser*> PropertyInitialiserCollator;
00459     typedef NamedDefinitionCollator<String, const EventLinkDefinition*> EventLinkDefinitionCollator;
00460     typedef std::set<String, StringFastLessCompare
00461         CEGUI_SET_ALLOC(String)> AnimationNameSet;
00462 
00463     // functions to populate containers with collections of objects that we
00464     // gain through inheritence.
00465     void appendChildWidgetComponents(WidgetComponentCollator& col, bool inherits = true) const;
00466     void appendPropertyDefinitions(PropertyDefinitionCollator& col, bool inherits = true) const;
00467     void appendPropertyLinkDefinitions(PropertyLinkDefinitionCollator& col, bool inherits = true) const;
00468     void appendPropertyInitialisers(PropertyInitialiserCollator& col, bool inherits = true) const;
00469     void appendEventLinkDefinitions(EventLinkDefinitionCollator& col, bool inherits = true) const;
00470     void appendAnimationNames(AnimationNameSet& set, bool inherits = true) const;
00471 
00472     void swap(WidgetLookFeel& other);
00473 
00474 public:
00475     /*************************************************************************
00476         Iterator stuff
00477     *************************************************************************/
00478     typedef std::set<String, StringFastLessCompare
00479             CEGUI_SET_ALLOC(String)> StringSet;
00480 
00481     typedef ConstMapIterator<StateList> StateIterator;
00482     typedef ConstMapIterator<ImageryList> ImageryIterator;
00483     typedef ConstMapIterator<NamedAreaList> NamedAreaIterator;
00484     typedef ConstVectorIterator<WidgetComponentCollator> WidgetComponentIterator;
00485     typedef ConstVectorIterator<PropertyDefinitionCollator> PropertyDefinitionIterator;
00486     typedef ConstVectorIterator<PropertyLinkDefinitionCollator> PropertyLinkDefinitionIterator;
00487     typedef ConstVectorIterator<PropertyInitialiserCollator> PropertyInitialiserIterator;
00488     typedef ConstVectorIterator<EventLinkDefinitionCollator> EventLinkDefinitionIterator;
00489     typedef ConstVectorIterator<AnimationNameSet> AnimationNameIterator;
00490 
00491     StringSet getStateNames(bool inherits = false) const;
00492     StringSet getImageryNames(bool inherits = false) const;
00493     StringSet getNamedAreaNames(bool inherits = false) const;
00494 
00495     StringSet getWidgetNames(bool inherits = false) const;
00496     StringSet getPropertyDefinitionNames(bool inherits = false) const;
00497     StringSet getPropertyLinkDefinitionNames(bool inherits = false) const;
00498     StringSet getPropertyInitialiserNames(bool inherits = false) const;
00499     StringSet getEventLinkDefinitionNames(bool inherits = false) const;
00500     StringSet getAnimationNames(bool inherits = false) const;
00501 
00502     StateIterator getStateIterator(bool inherits = false) const;
00503     ImageryIterator getImageryIterator(bool inherits = false) const;
00504     NamedAreaIterator getNamedAreaIterator(bool inherits = false) const;
00505     WidgetComponentIterator getWidgetComponentIterator(bool inherits = false) const;
00506     PropertyDefinitionIterator getPropertyDefinitionIterator(bool inherits = false) const;
00507     PropertyLinkDefinitionIterator getPropertyLinkDefinitionIterator(bool inherits = false) const;
00508     PropertyInitialiserIterator getPropertyInitialiserIterator(bool inherits = false) const;
00509     EventLinkDefinitionIterator getEventLinkDefinitionIterator(bool inherits = false) const;
00510     AnimationNameIterator getAnimationNameIterator(bool inherits = false) const;
00511 };
00512 
00513 } // End of  CEGUI namespace section
00514 
00515 
00516 #if defined(_MSC_VER)
00517 #   pragma warning(pop)
00518 #endif
00519 
00520 #endif  // end of guard _CEGUIFalWidgetLookFeel_h_
00521 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends