Crazy Eddie's GUI System  0.8.7
WidgetLookFeel.h
1 /***********************************************************************
2  created: Mon Jun 13 2005
3  author: Paul D Turner <paul@cegui.org.uk>
4  edited by Lukas E Meindl in Jul 2014
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIFalWidgetLookFeel_h_
29 #define _CEGUIFalWidgetLookFeel_h_
30 
31 #include "./StateImagery.h"
32 #include "./WidgetComponent.h"
33 #include "./ImagerySection.h"
34 #include "./PropertyInitialiser.h"
35 #include "./PropertyDefinition.h"
36 #include "./PropertyLinkDefinition.h"
37 #include "./EventLinkDefinition.h"
38 #include "./NamedArea.h"
39 #include "./NamedDefinitionCollator.h"
40 #include <map>
41 
42 #if defined(_MSC_VER)
43 # pragma warning(push)
44 # pragma warning(disable : 4251)
45 #endif
46 
47 
48 namespace CEGUI
49 {
54 class CEGUIEXPORT WidgetLookFeel :
55  public AllocatedObject<WidgetLookFeel>
56 {
57 public:
58  WidgetLookFeel(const String& name, const String& inherits);
59  WidgetLookFeel() {}
60  WidgetLookFeel(const WidgetLookFeel& other);
61  WidgetLookFeel& operator=(const WidgetLookFeel& other);
62 
63  virtual ~WidgetLookFeel();
72  const StateImagery& getStateImagery(const CEGUI::String& state) const;
73 
82  const ImagerySection& getImagerySection(const CEGUI::String& section) const;
83 
91  const String& getName() const;
92 
103  void addImagerySection(const ImagerySection& section);
104 
106  void renameImagerySection(const String& oldName, const String& newName);
107 
118  void addWidgetComponent(const WidgetComponent& widget);
119 
131 
142  void addPropertyInitialiser(const PropertyInitialiser& initialiser);
143 
152 
161 
170 
179 
191  void initialiseWidget(Window& widget) const;
192 
204  void cleanUpWidget(Window& widget) const;
205 
220  bool isStateImageryPresent(const String& state) const;
221 
232  void addNamedArea(const NamedArea& area);
233 
242 
253  const NamedArea& getNamedArea(const String& name) const;
254 
256  void renameNamedArea(const String& oldName, const String& newName);
257 
273  bool isNamedAreaDefined(const String& name) const;
274 
286  void layoutChildWidgets(const Window& owner) const;
287 
299 
311 
320 
329 
339  void addAnimationName(const String& anim_name);
340 
343 
346 
357  void writeXMLToStream(XMLSerializer& xml_stream) const;
358 
368  const PropertyInitialiser* findPropertyInitialiser(const String& propertyName) const;
369 
381  const WidgetComponent* findWidgetComponent(const String& name) const;
382 
383 
401  WidgetComponent* retrieveWidgetComponentFromList(const String& name, bool includeInheritedElements = false);
402 
420  PropertyInitialiser* retrievePropertyInitialiserFromList(const String& name, bool includeInheritedElements = false);
421 
439  PropertyDefinitionBase* retrievePropertyDefinitionFromList(const String& name, bool includeInheritedElements = false);
440 
458  PropertyDefinitionBase* retrievePropertyLinkDefinitionFromList(const String& name, bool includeInheritedElements = false);
459 
477  EventLinkDefinition* retrieveEventLinkDefinitionFromList(const String& name, bool includeInheritedElements = false);
478 
479 
480  typedef std::set<String, StringFastLessCompare
481  CEGUI_SET_ALLOC(String)> StringSet;
482 
485  typedef std::map<String, StateImagery*, StringFastLessCompare
488  typedef std::map<String, ImagerySection*, StringFastLessCompare
491  typedef std::map<String, NamedArea*, StringFastLessCompare
492  CEGUI_MAP_ALLOC(String, NamedArea*)> NamedAreaPointerMap;
494  typedef std::map<String, WidgetComponent*, StringFastLessCompare
502 
510 
511 
512 
515  typedef std::vector<PropertyInitialiser
516  CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList;
518  typedef std::vector<PropertyDefinitionBase*
521  typedef std::vector<PropertyDefinitionBase*
523 
524 
525 
537  {
538  return d_propertyDefinitions;
539  }
540 
552  {
553  return d_propertyLinkDefinitions;
554  }
555 
566  {
567  return d_properties;
568  }
569 
571  bool handleFontRenderSizeChange(Window& window, const Font* font) const;
572 
573 
574 
588  StateImageryPointerMap getStateImageryMap(bool includeInheritedElements = false);
589 
603  ImagerySectionPointerMap getImagerySectionMap(bool includeInheritedElements = false);
604 
618  NamedAreaPointerMap getNamedAreaMap(bool includeInheritedElements = false);
619 
633  WidgetComponentPointerMap getWidgetComponentMap(bool includeInheritedElements = false);
634 
648  PropertyInitialiserPointerMap getPropertyInitialiserMap(bool includeInheritedElements = false);
649 
663  PropertyDefinitionBasePointerMap getPropertyDefinitionMap(bool includeInheritedElements = false);
664 
678  PropertyDefinitionBasePointerMap getPropertyLinkDefinitionMap(bool includeInheritedElements = false);
679 
693  EventLinkDefinitionPointerMap getEventLinkDefinitionMap(bool includeInheritedElements = false);
694 
703 
704  StringSet getStateImageryNames(bool inherits = false) const;
706  StringSet getStateNames(bool inherits = false) const;
707  StringSet getImagerySectionNames(bool inherits = false) const;
709  StringSet getImageryNames(bool inherits = false) const;
710  StringSet getNamedAreaNames(bool inherits = false) const;
711  StringSet getWidgetComponentNames(bool inherits = false) const;
713  StringSet getWidgetNames(bool inherits = false) const;
714  StringSet getPropertyInitialiserNames(bool inherits = false) const;
715  StringSet getPropertyDefinitionNames(bool inherits = false) const;
716  StringSet getPropertyLinkDefinitionNames(bool inherits = false) const;
717  StringSet getEventLinkDefinitionNames(bool inherits = false) const;
718  StringSet getAnimationNames(bool inherits = false) const;
719 
720 private:
721 
729  WidgetLookFeel* getInheritedWidgetLookFeel();
730 
731 
732  typedef std::map<String, StateImagery, StringFastLessCompare
733  CEGUI_MAP_ALLOC(String, StateImagery)> StateList;
734  typedef std::map<String, ImagerySection, StringFastLessCompare
735  CEGUI_MAP_ALLOC(String, ImagerySection)> ImageryList;
736  typedef std::map<String, NamedArea, StringFastLessCompare
737  CEGUI_MAP_ALLOC(String, NamedArea)> NamedAreaList;
738 
740  typedef std::vector<WidgetComponent
741  CEGUI_VECTOR_ALLOC(WidgetComponent)> WidgetList;
742 
743  typedef std::vector<String
744  CEGUI_VECTOR_ALLOC(String)> AnimationList;
746  typedef std::multimap<Window*, AnimationInstance*
747  /*CEGUI_MULTIMAP_ALLOC(Window*, AnimationInstance*)*/> AnimationInstanceMap;
748 
750  typedef std::vector<EventLinkDefinition
751  CEGUI_VECTOR_ALLOC(EventLinkDefinition)> EventLinkDefinitionList;
752 
754  CEGUI::String d_lookName;
756  CEGUI::String d_inheritedLookName;
758  ImageryList d_imagerySections;
760  WidgetList d_childWidgets;
762  StateList d_stateImagery;
764  PropertyList d_properties;
766  NamedAreaList d_namedAreas;
768  mutable PropertyDefinitionList d_propertyDefinitions;
770  mutable PropertyLinkDefinitionList d_propertyLinkDefinitions;
772  AnimationList d_animations;
774  mutable AnimationInstanceMap d_animationInstances;
776  EventLinkDefinitionList d_eventLinkDefinitions;
777 
778  // these are container types used when composing final collections of
779  // objects that come via inheritence.
785  typedef std::set<String, StringFastLessCompare
786  CEGUI_SET_ALLOC(String)> AnimationNameSet;
787 
788  // functions to populate containers with collections of objects that we
789  // gain through inheritence.
790  void appendChildWidgetComponents(WidgetComponentCollator& col, bool inherits = true) const;
791  void appendPropertyDefinitions(PropertyDefinitionCollator& col, bool inherits = true) const;
792  void appendPropertyLinkDefinitions(PropertyLinkDefinitionCollator& col, bool inherits = true) const;
793  void appendPropertyInitialisers(PropertyInitialiserCollator& col, bool inherits = true) const;
794  void appendEventLinkDefinitions(EventLinkDefinitionCollator& col, bool inherits = true) const;
795  void appendAnimationNames(AnimationNameSet& set, bool inherits = true) const;
796 
797  void swap(WidgetLookFeel& other);
798 
799 public:
800  /*************************************************************************
801  Iterator stuff
802  *************************************************************************/
803 
810 
823 
831  StateIterator getStateIterator(bool inherits = false) const;
839  ImageryIterator getImageryIterator(bool inherits = false) const;
840 
848  NamedAreaIterator getNamedAreaIterator(bool inherits = false) const;
849 
858 
867 
876 
885 
894 
902  AnimationNameIterator getAnimationNameIterator(bool inherits = false) const;
903 };
904 
905 }
906 
907 
908 #if defined(_MSC_VER)
909 # pragma warning(pop)
910 #endif
911 
912 #endif
913 
Definition: MemoryAllocatedObject.h:110
Defines an 'animation instance' class.
Definition: AnimationInstance.h:75
iterator class for maps
Definition: IteratorBase.h:197
iterator for vectors
Definition: IteratorBase.h:288
Definition: EventLinkDefinition.h:45
Class that encapsulates a typeface.
Definition: Font.h:62
Class that encapsulates a re-usable collection of imagery specifications.
Definition: ImagerySection.h:49
NamedArea defines an area for a component which may later be obtained and referenced by a name unique...
Definition: NamedArea.h:42
Helper container used to implement inherited collections of component definitions specified in a Widg...
Definition: NamedDefinitionCollator.h:48
common base class used for types representing a new property to be available on all widgets that use ...
Definition: PropertyDefinitionBase.h:43
Class that holds information about a property and it's required initial value.
Definition: PropertyInitialiser.h:42
Class the encapsulates imagery for a given widget state.
Definition: StateImagery.h:48
String class used within the GUI system.
Definition: String.h:64
Class that encapsulates information regarding a sub-widget required for a widget.
Definition: WidgetComponent.h:52
Class that encapsulates Look N' Feel information for a widget.
Definition: WidgetLookFeel.h:56
void clearImagerySections()
Clear all ImagerySections from the WidgetLookFeel.
NamedAreaIterator getNamedAreaIterator(bool inherits=false) const
Returns an iterator for the NamedAreas of this WidgetLookFeel.
NamedAreaPointerMap getNamedAreaMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all NamedArea elements this WidgetLookFeel owns....
PropertyDefinitionBase * retrievePropertyDefinitionFromList(const String &name, bool includeInheritedElements=false)
Takes the name for a PropertyDefinition and returns a pointer to it if it exists or 0 if it doesn't.
void addImagerySection(const ImagerySection &section)
Add an ImagerySection to the WidgetLookFeel.
PropertyDefinitionBase * retrievePropertyLinkDefinitionFromList(const String &name, bool includeInheritedElements=false)
Takes the name for a PropertyLinkDefinition and returns a pointer to it if it exists or 0 if it doesn...
PropertyLinkDefinitionIterator getPropertyLinkDefinitionIterator(bool inherits=false) const
Returns an iterator for the PropertyLinkDefinitions of this WidgetLookFeel.
const PropertyLinkDefinitionList & getPropertyLinkDefinitions() const
Definition: WidgetLookFeel.h:551
WidgetComponentIterator getWidgetComponentIterator(bool inherits=false) const
Returns an iterator for the WidgetComponents of this WidgetLookFeel.
std::map< String, NamedArea *, StringFastLessCompare CEGUI_MAP_ALLOC(String, NamedArea *)> NamedAreaPointerMap
Map of Strings to NamedArea pointers.
Definition: WidgetLookFeel.h:492
const String & getName() const
Return the name of the widget look.
ConstVectorIterator< PropertyLinkDefinitionCollator > PropertyLinkDefinitionIterator
Definition: WidgetLookFeel.h:816
std::map< String, ImagerySection *, StringFastLessCompare CEGUI_MAP_ALLOC(String, ImagerySection *)> ImagerySectionPointerMap
Map of Strings to ImagerySection pointers.
Definition: WidgetLookFeel.h:489
ConstMapIterator< ImageryList > ImageryIterator
Definition: WidgetLookFeel.h:807
void renameNamedArea(const String &oldName, const String &newName)
void addStateSpecification(const StateImagery &state)
Add a state specification (StateImagery object) to the WidgetLookFeel.
void addEventLinkDefinition(const EventLinkDefinition &evtdef)
adds an event link definition to the WidgetLookFeel.
void addPropertyInitialiser(const PropertyInitialiser &initialiser)
Add a property initialiser to the WidgetLookFeel.
AnimationNameIterator getAnimationNameIterator(bool inherits=false) const
Returns an iterator for the AnimationNames of this WidgetLookFeel.
void addPropertyLinkDefinition(PropertyDefinitionBase *propdef)
Adds a property link definition to the WidgetLookFeel.
EventLinkDefinitionIterator getEventLinkDefinitionIterator(bool inherits=false) const
Returns an iterator for the EventLinkDefinitions of this WidgetLookFeel.
void addNamedArea(const NamedArea &area)
Adds a named area to the WidgetLookFeel.
PropertyInitialiserPointerMap getPropertyInitialiserMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all PropertyInitialiser elements this WidgetLookFeel owns....
void layoutChildWidgets(const Window &owner) const
Layout the child widgets defined for this WidgetLookFeel which are attached to the given window.
void addWidgetComponent(const WidgetComponent &widget)
Add a WidgetComponent to the WidgetLookFeel.
const PropertyList & getProperties() const
Definition: WidgetLookFeel.h:565
WidgetComponentPointerMap getWidgetComponentMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all WidgetComponent elements this WidgetLookFeel owns....
const NamedArea & getNamedArea(const String &name) const
Return the NamedArea with the specified name.
std::vector< PropertyDefinitionBase *CEGUI_VECTOR_ALLOC(PropertyDefinitionBase *)> PropertyLinkDefinitionList
Definition: WidgetLookFeel.h:522
void writeXMLToStream(XMLSerializer &xml_stream) const
Writes an xml representation of this WidgetLookFeel to out_stream.
bool isNamedAreaDefined(const String &name) const
return whether a NamedArea object with the specified name exists for this WidgetLookFeel.
void clearPropertyLinkDefinitions()
Clear all defined property link definitions from the WidgetLookFeel.
ImagerySectionPointerMap getImagerySectionMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all ImagerySection elements this WidgetLookFeel owns....
ConstMapIterator< StateList > StateIterator
Definition: WidgetLookFeel.h:805
ConstVectorIterator< EventLinkDefinitionCollator > EventLinkDefinitionIterator
Definition: WidgetLookFeel.h:820
void clearStateSpecifications()
Clear all StateImagery objects from the WidgetLookFeel.
ConstMapIterator< NamedAreaList > NamedAreaIterator
Definition: WidgetLookFeel.h:809
std::vector< PropertyDefinitionBase *CEGUI_VECTOR_ALLOC(PropertyDefinitionBase *)> PropertyDefinitionList
Definition: WidgetLookFeel.h:519
StateImageryPointerMap getStateImageryMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all StateImagery elements this WidgetLookFeel owns....
void clearWidgetComponents()
Clear all WidgetComponents from the WidgetLookFeel.
void addPropertyDefinition(PropertyDefinitionBase *propdef)
Adds a property definition to the WidgetLookFeel.
void addAnimationName(const String &anim_name)
Add the name of an animation that is associated with the WidgetLookFeel.
ConstVectorIterator< WidgetComponentCollator > WidgetComponentIterator
Definition: WidgetLookFeel.h:812
std::map< String, PropertyInitialiser *, StringFastLessCompare CEGUI_MAP_ALLOC(String, PropertyInitialiser *)> PropertyInitialiserPointerMap
Map of Strings to PropertyInitialiser pointers.
Definition: WidgetLookFeel.h:506
PropertyDefinitionBasePointerMap getPropertyLinkDefinitionMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all PropertyLinkDefinition elements this WidgetLookFeel owns....
ConstVectorIterator< PropertyInitialiserCollator > PropertyInitialiserIterator
Definition: WidgetLookFeel.h:818
ConstVectorIterator< PropertyDefinitionCollator > PropertyDefinitionIterator
Definition: WidgetLookFeel.h:814
EventLinkDefinition * retrieveEventLinkDefinitionFromList(const String &name, bool includeInheritedElements=false)
Takes the name for a EventLinkDefinition and returns a pointer to it if it exists or 0 if it doesn't.
void clearEventLinkDefinitions()
clear all defined event link definitions from the WidgetLookFeel.
void cleanUpWidget(Window &widget) const
Clean up the given window from all properties and component widgets created by this WidgetLookFeel.
const StateImagery & getStateImagery(const CEGUI::String &state) const
Return a const reference to the StateImagery object for the specified state.
void clearPropertyInitialisers()
Clear all PropertyInitialiser objects from the WidgetLookFeel.
StringSet getStateNames(bool inherits=false) const
const PropertyDefinitionList & getPropertyDefinitions() const
Definition: WidgetLookFeel.h:536
WidgetComponent * retrieveWidgetComponentFromList(const String &name, bool includeInheritedElements=false)
Takes the name for a WidgetComponent and returns a pointer to it if it exists or null pointer if it d...
PropertyDefinitionIterator getPropertyDefinitionIterator(bool inherits=false) const
Returns an iterator for the PropertyDefinitions of this WidgetLookFeel.
const WidgetComponent * findWidgetComponent(const String &name) const
Takes the name for a WidgetComponent and returns a pointer to it if it exists or a null pointer if it...
const CEGUI::String & getInheritedWidgetLookName() const
Returns a String containing the name of the inherited WidgetLookFeel.
std::map< String, PropertyDefinitionBase *, StringFastLessCompare CEGUI_MAP_ALLOC(String, PropertyDefinitionBase *)> PropertyDefinitionBasePointerMap
Map of Strings to PropertyDefinitionBase pointers.
Definition: WidgetLookFeel.h:509
void initialiseWidget(Window &widget) const
Initialise the given window using PropertyInitialsers and component widgets specified for this Widget...
StringSet getImageryNames(bool inherits=false) const
std::map< String, EventLinkDefinition *, StringFastLessCompare CEGUI_MAP_ALLOC(String, EventLinkDefinition *)> EventLinkDefinitionPointerMap
Map of Strings to EventLinkDefinition pointers.
Definition: WidgetLookFeel.h:501
bool handleFontRenderSizeChange(Window &window, const Font *font) const
perform any processing required due to the given font having changed.
std::map< String, StateImagery *, StringFastLessCompare CEGUI_MAP_ALLOC(String, StateImagery *)> StateImageryPointerMap
Map of Strings to StateImagery pointers.
Definition: WidgetLookFeel.h:486
const ImagerySection & getImagerySection(const CEGUI::String &section) const
Return a const reference to the ImagerySection object with the specified name.
std::map< String, WidgetComponent *, StringFastLessCompare CEGUI_MAP_ALLOC(String, WidgetComponent *)> WidgetComponentPointerMap
Map of Strings to WidgetComponent pointers.
Definition: WidgetLookFeel.h:495
ConstVectorIterator< AnimationNameSet > AnimationNameIterator
Definition: WidgetLookFeel.h:822
void clearPropertyDefinitions()
Clear all defined property definitions from the WidgetLookFeel.
StateIterator getStateIterator(bool inherits=false) const
Returns an iterator for the StateImageries of this WidgetLookFeel.
PropertyDefinitionBasePointerMap getPropertyDefinitionMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all PropertyDefinition elements this WidgetLookFeel owns....
void renameImagerySection(const String &oldName, const String &newName)
void clearNamedAreas()
Clear all defined named areas from the WidgetLookFeel.
std::vector< PropertyInitialiser CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList
Definition: WidgetLookFeel.h:516
StringSet getWidgetNames(bool inherits=false) const
ImageryIterator getImageryIterator(bool inherits=false) const
Returns an iterator for the ImagerySections of this WidgetLookFeel.
std::map< String, AnimationInstance *, StringFastLessCompare CEGUI_MAP_ALLOC(String, AnimationInstance *)> AnimationInstancePointerMap
Map of Strings to AnimationInstance pointers.
Definition: WidgetLookFeel.h:498
EventLinkDefinitionPointerMap getEventLinkDefinitionMap(bool includeInheritedElements=false)
Returns a map of names to pointers for all EventLinkDefinition elements this WidgetLookFeel owns....
PropertyInitialiserIterator getPropertyInitialiserIterator(bool inherits=false) const
Returns an iterator for the PropertyInitialisers of this WidgetLookFeel.
bool isStateImageryPresent(const String &state) const
Return whether imagery is defined for the given state.
PropertyInitialiser * retrievePropertyInitialiserFromList(const String &name, bool includeInheritedElements=false)
Takes the name for a Property (PropertyInitialiser) and returns a pointer to it if it exists or 0 if ...
const PropertyInitialiser * findPropertyInitialiser(const String &propertyName) const
Takes the name of a property and returns a pointer to the last PropertyInitialiser for this property ...
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Class used to create XML Document.
Definition: XMLSerializer.h:87
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
void CEGUIEXPORT swap(String &str1, String &str2)
Swap the contents for two String objects.
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5580