Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
WidgetLookFeel.h
1 /***********************************************************************
2  filename: CEGUIWidgetLookFeel.h
3  created: Mon Jun 13 2005
4  author: Paul D Turner <paul@cegui.org.uk>
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 // Start of CEGUI namespace section
49 namespace CEGUI
50 {
56 class CEGUIEXPORT WidgetLookFeel :
57  public AllocatedObject<WidgetLookFeel>
58 {
59 public:
60  WidgetLookFeel(const String& name, const String& inherits);
61  WidgetLookFeel() {}
62  WidgetLookFeel(const WidgetLookFeel& other);
63  WidgetLookFeel& operator=(const WidgetLookFeel& other);
64 
65  virtual ~WidgetLookFeel();
74  const StateImagery& getStateImagery(const CEGUI::String& state) const;
75 
84  const ImagerySection& getImagerySection(const CEGUI::String& section) const;
85 
93  const String& getName() const;
94 
105  void addImagerySection(const ImagerySection& section);
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 
217  bool isStateImageryPresent(const String& state) const;
218 
229  void addNamedArea(const NamedArea& area);
230 
238  void clearNamedAreas();
239 
250  const NamedArea& getNamedArea(const String& name) const;
251 
252  void renameNamedArea(const String& oldName, const String& newName);
266  bool isNamedAreaDefined(const String& name) const;
267 
279  void layoutChildWidgets(const Window& owner) const;
280 
291  void addPropertyDefinition(PropertyDefinitionBase* propdef);
292 
303  void addPropertyLinkDefinition(PropertyDefinitionBase* propdef);
304 
312  void clearPropertyDefinitions();
313 
321  void clearPropertyLinkDefinitions();
322 
332  void addAnimationName(const String& anim_name);
333 
335  void addEventLinkDefinition(const EventLinkDefinition& evtdef);
336 
338  void clearEventLinkDefinitions();
339 
350  void writeXMLToStream(XMLSerializer& xml_stream) const;
351 
361  const PropertyInitialiser* findPropertyInitialiser(const String& propertyName) const;
362 
371  const WidgetComponent* findWidgetComponent(const String& name) const;
372 
374  typedef std::vector<PropertyInitialiser
375  CEGUI_VECTOR_ALLOC(PropertyInitialiser)> PropertyList;
376  typedef std::vector<PropertyDefinitionBase*
377  CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyDefinitionList;
378  typedef std::vector<PropertyDefinitionBase*
379  CEGUI_VECTOR_ALLOC(PropertyDefinitionBase*)> PropertyLinkDefinitionList;
380 
386  const PropertyDefinitionList& getPropertyDefinitions() const
387  {
388  return d_propertyDefinitions;
389  }
390 
396  const PropertyLinkDefinitionList& getPropertyLinkDefinitions() const
397  {
398  return d_propertyLinkDefinitions;
399  }
400 
405  const PropertyList& getProperties() const
406  {
407  return d_properties;
408  }
409 
411  bool handleFontRenderSizeChange(Window& window, const Font* font) const;
412 
413 private:
414  typedef std::map<String, StateImagery, StringFastLessCompare
415  CEGUI_MAP_ALLOC(String, StateImagery)> StateList;
416  typedef std::map<String, ImagerySection, StringFastLessCompare
417  CEGUI_MAP_ALLOC(String, ImagerySection)> ImageryList;
418  typedef std::map<String, NamedArea, StringFastLessCompare
419  CEGUI_MAP_ALLOC(String, NamedArea)> NamedAreaList;
420  typedef std::vector<WidgetComponent
421  CEGUI_VECTOR_ALLOC(WidgetComponent)> WidgetList;
422  typedef std::vector<String
423  CEGUI_VECTOR_ALLOC(String)> AnimationList;
424  typedef std::multimap<Window*, AnimationInstance*
425  /*CEGUI_MULTIMAP_ALLOC(Window*, AnimationInstance*)*/> AnimationInstanceMap;
426  typedef std::vector<EventLinkDefinition
427  CEGUI_VECTOR_ALLOC(EventLinkDefinition)> EventLinkDefinitionList;
428 
430  CEGUI::String d_lookName;
432  CEGUI::String d_inheritedLookName;
434  ImageryList d_imagerySections;
436  WidgetList d_childWidgets;
438  StateList d_stateImagery;
440  PropertyList d_properties;
442  NamedAreaList d_namedAreas;
444  mutable PropertyDefinitionList d_propertyDefinitions;
446  mutable PropertyLinkDefinitionList d_propertyLinkDefinitions;
448  AnimationList d_animations;
450  mutable AnimationInstanceMap d_animationInstances;
452  EventLinkDefinitionList d_eventLinkDefinitions;
453 
454  // these are container types used when composing final collections of
455  // objects that come via inheritence.
456  typedef NamedDefinitionCollator<String, const WidgetComponent*> WidgetComponentCollator;
457  typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyDefinitionCollator;
458  typedef NamedDefinitionCollator<String, PropertyDefinitionBase*> PropertyLinkDefinitionCollator;
459  typedef NamedDefinitionCollator<String, const PropertyInitialiser*> PropertyInitialiserCollator;
460  typedef NamedDefinitionCollator<String, const EventLinkDefinition*> EventLinkDefinitionCollator;
461  typedef std::set<String, StringFastLessCompare
462  CEGUI_SET_ALLOC(String)> AnimationNameSet;
463 
464  // functions to populate containers with collections of objects that we
465  // gain through inheritence.
466  void appendChildWidgetComponents(WidgetComponentCollator& col, bool inherits = true) const;
467  void appendPropertyDefinitions(PropertyDefinitionCollator& col, bool inherits = true) const;
468  void appendPropertyLinkDefinitions(PropertyLinkDefinitionCollator& col, bool inherits = true) const;
469  void appendPropertyInitialisers(PropertyInitialiserCollator& col, bool inherits = true) const;
470  void appendEventLinkDefinitions(EventLinkDefinitionCollator& col, bool inherits = true) const;
471  void appendAnimationNames(AnimationNameSet& set, bool inherits = true) const;
472 
473  void swap(WidgetLookFeel& other);
474 
475 public:
476  /*************************************************************************
477  Iterator stuff
478  *************************************************************************/
479  typedef std::set<String, StringFastLessCompare
480  CEGUI_SET_ALLOC(String)> StringSet;
481 
482  typedef ConstMapIterator<StateList> StateIterator;
483  typedef ConstMapIterator<ImageryList> ImageryIterator;
484  typedef ConstMapIterator<NamedAreaList> NamedAreaIterator;
485  typedef ConstVectorIterator<WidgetComponentCollator> WidgetComponentIterator;
486  typedef ConstVectorIterator<PropertyDefinitionCollator> PropertyDefinitionIterator;
487  typedef ConstVectorIterator<PropertyLinkDefinitionCollator> PropertyLinkDefinitionIterator;
488  typedef ConstVectorIterator<PropertyInitialiserCollator> PropertyInitialiserIterator;
489  typedef ConstVectorIterator<EventLinkDefinitionCollator> EventLinkDefinitionIterator;
490  typedef ConstVectorIterator<AnimationNameSet> AnimationNameIterator;
491 
492  StringSet getStateNames(bool inherits = false) const;
493  StringSet getImageryNames(bool inherits = false) const;
494  StringSet getNamedAreaNames(bool inherits = false) const;
495 
496  StringSet getWidgetNames(bool inherits = false) const;
497  StringSet getPropertyDefinitionNames(bool inherits = false) const;
498  StringSet getPropertyLinkDefinitionNames(bool inherits = false) const;
499  StringSet getPropertyInitialiserNames(bool inherits = false) const;
500  StringSet getEventLinkDefinitionNames(bool inherits = false) const;
501  StringSet getAnimationNames(bool inherits = false) const;
502 
503  StateIterator getStateIterator(bool inherits = false) const;
504  ImageryIterator getImageryIterator(bool inherits = false) const;
505  NamedAreaIterator getNamedAreaIterator(bool inherits = false) const;
506  WidgetComponentIterator getWidgetComponentIterator(bool inherits = false) const;
507  PropertyDefinitionIterator getPropertyDefinitionIterator(bool inherits = false) const;
508  PropertyLinkDefinitionIterator getPropertyLinkDefinitionIterator(bool inherits = false) const;
509  PropertyInitialiserIterator getPropertyInitialiserIterator(bool inherits = false) const;
510  EventLinkDefinitionIterator getEventLinkDefinitionIterator(bool inherits = false) const;
511  AnimationNameIterator getAnimationNameIterator(bool inherits = false) const;
512 };
513 
514 } // End of CEGUI namespace section
515 
516 
517 #if defined(_MSC_VER)
518 # pragma warning(pop)
519 #endif
520 
521 #endif // end of guard _CEGUIFalWidgetLookFeel_h_
522