Crazy Eddie's GUI System  0.8.5
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 
130  void addStateSpecification(const StateImagery& state);
131 
142  void addPropertyInitialiser(const PropertyInitialiser& initialiser);
143 
151  void clearImagerySections();
152 
160  void clearWidgetComponents();
161 
169  void clearStateSpecifications();
170 
178  void clearPropertyInitialisers();
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 
241  void clearNamedAreas();
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 
298  void addPropertyDefinition(PropertyDefinitionBase* propdef);
299 
310  void addPropertyLinkDefinition(PropertyDefinitionBase* propdef);
311 
319  void clearPropertyDefinitions();
320 
328  void clearPropertyLinkDefinitions();
329 
339  void addAnimationName(const String& anim_name);
340 
342  void addEventLinkDefinition(const EventLinkDefinition& evtdef);
343 
345  void clearEventLinkDefinitions();
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 
484  typedef std::map<String, StateImagery*, StringFastLessCompare
486  CEGUI_MAP_ALLOC(String, StateImagery*)> StateImageryPointerMap;
488  typedef std::map<String, ImagerySection*, StringFastLessCompare
489  CEGUI_MAP_ALLOC(String, ImagerySection*)> ImagerySectionPointerMap;
491  typedef std::map<String, NamedArea*, StringFastLessCompare
492  CEGUI_MAP_ALLOC(String, NamedArea*)> NamedAreaPointerMap;
494  typedef std::map<String, WidgetComponent*, StringFastLessCompare
495  CEGUI_MAP_ALLOC(String, WidgetComponent*)> WidgetComponentPointerMap;
497  typedef std::map<String, AnimationInstance*, StringFastLessCompare
498  CEGUI_MAP_ALLOC(String, AnimationInstance*)> AnimationInstancePointerMap;
500  typedef std::map<String, EventLinkDefinition*, StringFastLessCompare
501  CEGUI_MAP_ALLOC(String, EventLinkDefinition*)> EventLinkDefinitionPointerMap;
502 
504  typedef std::map<String, PropertyInitialiser*, StringFastLessCompare
506  CEGUI_MAP_ALLOC(String, PropertyInitialiser*)> PropertyInitialiserPointerMap;
508  typedef std::map<String, PropertyDefinitionBase*, StringFastLessCompare
509  CEGUI_MAP_ALLOC(String, PropertyDefinitionBase*)> PropertyDefinitionBasePointerMap;
510 
511 
512 
514  typedef std::vector<PropertyInitialiser
516  CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList;
518  typedef std::vector<PropertyDefinitionBase*
519  CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyDefinitionList;
521  typedef std::vector<PropertyDefinitionBase*
522  CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyLinkDefinitionList;
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 
702  const CEGUI::String& getInheritedWidgetLookName() const;
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.
780  typedef NamedDefinitionCollator<String, const WidgetComponent*> WidgetComponentCollator;
781  typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyDefinitionCollator;
782  typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyLinkDefinitionCollator;
783  typedef NamedDefinitionCollator<String, const PropertyInitialiser*> PropertyInitialiserCollator;
784  typedef NamedDefinitionCollator<String, const EventLinkDefinition*> EventLinkDefinitionCollator;
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 
857  WidgetComponentIterator getWidgetComponentIterator(bool inherits = false) const;
858 
866  PropertyDefinitionIterator getPropertyDefinitionIterator(bool inherits = false) const;
867 
875  PropertyLinkDefinitionIterator getPropertyLinkDefinitionIterator(bool inherits = false) const;
876 
884  PropertyInitialiserIterator getPropertyInitialiserIterator(bool inherits = false) const;
885 
893  EventLinkDefinitionIterator getEventLinkDefinitionIterator(bool inherits = false) const;
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 
std::map< String, AnimationInstance *, StringFastLessCompare CEGUI_MAP_ALLOC(String, AnimationInstance *)> AnimationInstancePointerMap
Map of Strings to AnimationInstance pointers.
Definition: WidgetLookFeel.h:498
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5579
void CEGUIEXPORT swap(String &str1, String &str2)
Swap the contents for two String objects.
ConstVectorIterator< WidgetComponentCollator > WidgetComponentIterator
Definition: WidgetLookFeel.h:812
common base class used for types representing a new property to be available on all widgets that use ...
Definition: PropertyDefinitionBase.h:42
Definition: MemoryAllocatedObject.h:109
ConstVectorIterator< AnimationNameSet > AnimationNameIterator
Definition: WidgetLookFeel.h:822
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
std::map< String, NamedArea *, StringFastLessCompare CEGUI_MAP_ALLOC(String, NamedArea *)> NamedAreaPointerMap
Map of Strings to NamedArea pointers.
Definition: WidgetLookFeel.h:492
std::map< String, EventLinkDefinition *, StringFastLessCompare CEGUI_MAP_ALLOC(String, EventLinkDefinition *)> EventLinkDefinitionPointerMap
Map of Strings to EventLinkDefinition pointers.
Definition: WidgetLookFeel.h:501
std::map< String, WidgetComponent *, StringFastLessCompare CEGUI_MAP_ALLOC(String, WidgetComponent *)> WidgetComponentPointerMap
Map of Strings to WidgetComponent pointers.
Definition: WidgetLookFeel.h:495
iterator for vectors
Definition: IteratorBase.h:287
ConstVectorIterator< EventLinkDefinitionCollator > EventLinkDefinitionIterator
Definition: WidgetLookFeel.h:820
ConstVectorIterator< PropertyInitialiserCollator > PropertyInitialiserIterator
Definition: WidgetLookFeel.h:818
NamedArea defines an area for a component which may later be obtained and referenced by a name unique...
Definition: NamedArea.h:40
Class the encapsulates imagery for a given widget state.
Definition: StateImagery.h:46
Class that holds information about a property and it's required initial value.
Definition: PropertyInitialiser.h:40
std::map< String, PropertyInitialiser *, StringFastLessCompare CEGUI_MAP_ALLOC(String, PropertyInitialiser *)> PropertyInitialiserPointerMap
Map of Strings to PropertyInitialiser pointers.
Definition: WidgetLookFeel.h:506
Class that encapsulates information regarding a sub-widget required for a widget. ...
Definition: WidgetComponent.h:50
Class that encapsulates a typeface.
Definition: Font.h:58
ConstVectorIterator< PropertyLinkDefinitionCollator > PropertyLinkDefinitionIterator
Definition: WidgetLookFeel.h:816
std::vector< PropertyInitialiser CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList
Definition: WidgetLookFeel.h:516
const PropertyList & getProperties() const
Definition: WidgetLookFeel.h:565
ConstMapIterator< ImageryList > ImageryIterator
Definition: WidgetLookFeel.h:807
ConstVectorIterator< PropertyDefinitionCollator > PropertyDefinitionIterator
Definition: WidgetLookFeel.h:814
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
std::map< String, ImagerySection *, StringFastLessCompare CEGUI_MAP_ALLOC(String, ImagerySection *)> ImagerySectionPointerMap
Map of Strings to ImagerySection pointers.
Definition: WidgetLookFeel.h:489
std::vector< PropertyDefinitionBase *CEGUI_VECTOR_ALLOC(PropertyDefinitionBase *)> PropertyLinkDefinitionList
Definition: WidgetLookFeel.h:522
Helper container used to implement inherited collections of component definitions specified in a Widg...
Definition: NamedDefinitionCollator.h:47
const PropertyDefinitionList & getPropertyDefinitions() const
Definition: WidgetLookFeel.h:536
iterator class for maps
Definition: IteratorBase.h:196
Class that encapsulates Look N' Feel information for a widget.
Definition: WidgetLookFeel.h:54
ConstMapIterator< NamedAreaList > NamedAreaIterator
Definition: WidgetLookFeel.h:809
const PropertyLinkDefinitionList & getPropertyLinkDefinitions() const
Definition: WidgetLookFeel.h:551
ConstMapIterator< StateList > StateIterator
Definition: WidgetLookFeel.h:805
std::vector< PropertyDefinitionBase *CEGUI_VECTOR_ALLOC(PropertyDefinitionBase *)> PropertyDefinitionList
Definition: WidgetLookFeel.h:519
Class used to create XML Document.
Definition: XMLSerializer.h:85
Class that encapsulates a re-usable collection of imagery specifications.
Definition: ImagerySection.h:47
Definition: EventLinkDefinition.h:43
std::map< String, PropertyDefinitionBase *, StringFastLessCompare CEGUI_MAP_ALLOC(String, PropertyDefinitionBase *)> PropertyDefinitionBasePointerMap
Map of Strings to PropertyDefinitionBase pointers.
Definition: WidgetLookFeel.h:509
Defines an 'animation instance' class.
Definition: AnimationInstance.h:73
std::map< String, StateImagery *, StringFastLessCompare CEGUI_MAP_ALLOC(String, StateImagery *)> StateImageryPointerMap
Map of Strings to StateImagery pointers.
Definition: WidgetLookFeel.h:486
String class used within the GUI system.
Definition: String.h:62