Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
WidgetLookFeel.h
1 /***********************************************************************
2  created: Mon Jun 13 2005
3  author: Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIFalWidgetLookFeel_h_
28 #define _CEGUIFalWidgetLookFeel_h_
29 
30 #include "./StateImagery.h"
31 #include "./WidgetComponent.h"
32 #include "./ImagerySection.h"
33 #include "./PropertyInitialiser.h"
34 #include "./PropertyDefinition.h"
35 #include "./PropertyLinkDefinition.h"
36 #include "./EventLinkDefinition.h"
37 #include "./NamedArea.h"
38 #include "./NamedDefinitionCollator.h"
39 #include <map>
40 
41 #if defined(_MSC_VER)
42 # pragma warning(push)
43 # pragma warning(disable : 4251)
44 #endif
45 
46 
47 // Start of CEGUI namespace section
48 namespace CEGUI
49 {
55 class CEGUIEXPORT WidgetLookFeel :
56  public AllocatedObject<WidgetLookFeel>
57 {
58 public:
59  WidgetLookFeel(const String& name, const String& inherits);
60  WidgetLookFeel() {}
61  WidgetLookFeel(const WidgetLookFeel& other);
62  WidgetLookFeel& operator=(const WidgetLookFeel& other);
63 
64  virtual ~WidgetLookFeel();
73  const StateImagery& getStateImagery(const CEGUI::String& state) const;
74 
83  const ImagerySection& getImagerySection(const CEGUI::String& section) const;
84 
92  const String& getName() const;
93 
104  void addImagerySection(const ImagerySection& section);
105  void renameImagerySection(const String& oldName, const String& newName);
106 
117  void addWidgetComponent(const WidgetComponent& widget);
118 
129  void addStateSpecification(const StateImagery& state);
130 
141  void addPropertyInitialiser(const PropertyInitialiser& initialiser);
142 
150  void clearImagerySections();
151 
159  void clearWidgetComponents();
160 
168  void clearStateSpecifications();
169 
177  void clearPropertyInitialisers();
178 
190  void initialiseWidget(Window& widget) const;
191 
203  void cleanUpWidget(Window& widget) const;
204 
216  bool isStateImageryPresent(const String& state) const;
217 
228  void addNamedArea(const NamedArea& area);
229 
237  void clearNamedAreas();
238 
249  const NamedArea& getNamedArea(const String& name) const;
250 
251  void renameNamedArea(const String& oldName, const String& newName);
265  bool isNamedAreaDefined(const String& name) const;
266 
278  void layoutChildWidgets(const Window& owner) const;
279 
290  void addPropertyDefinition(PropertyDefinitionBase* propdef);
291 
302  void addPropertyLinkDefinition(PropertyDefinitionBase* propdef);
303 
311  void clearPropertyDefinitions();
312 
320  void clearPropertyLinkDefinitions();
321 
331  void addAnimationName(const String& anim_name);
332 
334  void addEventLinkDefinition(const EventLinkDefinition& evtdef);
335 
337  void clearEventLinkDefinitions();
338 
349  void writeXMLToStream(XMLSerializer& xml_stream) const;
350 
360  const PropertyInitialiser* findPropertyInitialiser(const String& propertyName) const;
361 
370  const WidgetComponent* findWidgetComponent(const String& name) const;
371 
373  typedef std::vector<PropertyInitialiser
374  CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList;
375  typedef std::vector<PropertyDefinitionBase*
376  CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyDefinitionList;
377  typedef std::vector<PropertyDefinitionBase*
378  CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyLinkDefinitionList;
379 
385  const PropertyDefinitionList& getPropertyDefinitions() const
386  {
387  return d_propertyDefinitions;
388  }
389 
395  const PropertyLinkDefinitionList& getPropertyLinkDefinitions() const
396  {
397  return d_propertyLinkDefinitions;
398  }
399 
404  const PropertyList& getProperties() const
405  {
406  return d_properties;
407  }
408 
410  bool handleFontRenderSizeChange(Window& window, const Font* font) const;
411 
412 private:
413  typedef std::map<String, StateImagery, StringFastLessCompare
414  CEGUI_MAP_ALLOC(String, StateImagery)> StateList;
415  typedef std::map<String, ImagerySection, StringFastLessCompare
416  CEGUI_MAP_ALLOC(String, ImagerySection)> ImageryList;
417  typedef std::map<String, NamedArea, StringFastLessCompare
418  CEGUI_MAP_ALLOC(String, NamedArea)> NamedAreaList;
419  typedef std::vector<WidgetComponent
420  CEGUI_VECTOR_ALLOC(WidgetComponent)> WidgetList;
421  typedef std::vector<String
422  CEGUI_VECTOR_ALLOC(String)> AnimationList;
423  typedef std::multimap<Window*, AnimationInstance*
424  /*CEGUI_MULTIMAP_ALLOC(Window*, AnimationInstance*)*/> AnimationInstanceMap;
425  typedef std::vector<EventLinkDefinition
426  CEGUI_VECTOR_ALLOC(EventLinkDefinition)> EventLinkDefinitionList;
427 
429  CEGUI::String d_lookName;
431  CEGUI::String d_inheritedLookName;
433  ImageryList d_imagerySections;
435  WidgetList d_childWidgets;
437  StateList d_stateImagery;
439  PropertyList d_properties;
441  NamedAreaList d_namedAreas;
443  mutable PropertyDefinitionList d_propertyDefinitions;
445  mutable PropertyLinkDefinitionList d_propertyLinkDefinitions;
447  AnimationList d_animations;
449  mutable AnimationInstanceMap d_animationInstances;
451  EventLinkDefinitionList d_eventLinkDefinitions;
452 
453  // these are container types used when composing final collections of
454  // objects that come via inheritence.
455  typedef NamedDefinitionCollator<String, const WidgetComponent*> WidgetComponentCollator;
456  typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyDefinitionCollator;
457  typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyLinkDefinitionCollator;
458  typedef NamedDefinitionCollator<String, const PropertyInitialiser*> PropertyInitialiserCollator;
459  typedef NamedDefinitionCollator<String, const EventLinkDefinition*> EventLinkDefinitionCollator;
460  typedef std::set<String, StringFastLessCompare
461  CEGUI_SET_ALLOC(String)> AnimationNameSet;
462 
463  // functions to populate containers with collections of objects that we
464  // gain through inheritence.
465  void appendChildWidgetComponents(WidgetComponentCollator& col, bool inherits = true) const;
466  void appendPropertyDefinitions(PropertyDefinitionCollator& col, bool inherits = true) const;
467  void appendPropertyLinkDefinitions(PropertyLinkDefinitionCollator& col, bool inherits = true) const;
468  void appendPropertyInitialisers(PropertyInitialiserCollator& col, bool inherits = true) const;
469  void appendEventLinkDefinitions(EventLinkDefinitionCollator& col, bool inherits = true) const;
470  void appendAnimationNames(AnimationNameSet& set, bool inherits = true) const;
471 
472  void swap(WidgetLookFeel& other);
473 
474 public:
475  /*************************************************************************
476  Iterator stuff
477  *************************************************************************/
478  typedef std::set<String, StringFastLessCompare
479  CEGUI_SET_ALLOC(String)> StringSet;
480 
481  typedef ConstMapIterator<StateList> StateIterator;
482  typedef ConstMapIterator<ImageryList> ImageryIterator;
483  typedef ConstMapIterator<NamedAreaList> NamedAreaIterator;
484  typedef ConstVectorIterator<WidgetComponentCollator> WidgetComponentIterator;
485  typedef ConstVectorIterator<PropertyDefinitionCollator> PropertyDefinitionIterator;
486  typedef ConstVectorIterator<PropertyLinkDefinitionCollator> PropertyLinkDefinitionIterator;
487  typedef ConstVectorIterator<PropertyInitialiserCollator> PropertyInitialiserIterator;
488  typedef ConstVectorIterator<EventLinkDefinitionCollator> EventLinkDefinitionIterator;
489  typedef ConstVectorIterator<AnimationNameSet> AnimationNameIterator;
490 
491  StringSet getStateNames(bool inherits = false) const;
492  StringSet getImageryNames(bool inherits = false) const;
493  StringSet getNamedAreaNames(bool inherits = false) const;
494 
495  StringSet getWidgetNames(bool inherits = false) const;
496  StringSet getPropertyDefinitionNames(bool inherits = false) const;
497  StringSet getPropertyLinkDefinitionNames(bool inherits = false) const;
498  StringSet getPropertyInitialiserNames(bool inherits = false) const;
499  StringSet getEventLinkDefinitionNames(bool inherits = false) const;
500  StringSet getAnimationNames(bool inherits = false) const;
501 
502  StateIterator getStateIterator(bool inherits = false) const;
503  ImageryIterator getImageryIterator(bool inherits = false) const;
504  NamedAreaIterator getNamedAreaIterator(bool inherits = false) const;
505  WidgetComponentIterator getWidgetComponentIterator(bool inherits = false) const;
506  PropertyDefinitionIterator getPropertyDefinitionIterator(bool inherits = false) const;
507  PropertyLinkDefinitionIterator getPropertyLinkDefinitionIterator(bool inherits = false) const;
508  PropertyInitialiserIterator getPropertyInitialiserIterator(bool inherits = false) const;
509  EventLinkDefinitionIterator getEventLinkDefinitionIterator(bool inherits = false) const;
510  AnimationNameIterator getAnimationNameIterator(bool inherits = false) const;
511 };
512 
513 } // End of CEGUI namespace section
514 
515 
516 #if defined(_MSC_VER)
517 # pragma warning(pop)
518 #endif
519 
520 #endif // end of guard _CEGUIFalWidgetLookFeel_h_
521