Crazy Eddies GUI System  0.7.1
CEGUIFalDimensions.h
1 /***********************************************************************
2  filename: CEGUIFalDimensions.h
3  created: Mon Jun 13 2005
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 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 _CEGUIFalDimensions_h_
29 #define _CEGUIFalDimensions_h_
30 
31 #include "CEGUIFalEnums.h"
32 #include "../CEGUIString.h"
33 #include "../CEGUIUDim.h"
34 #include "../CEGUIXMLSerializer.h"
35 
36 // Start of CEGUI namespace section
37 namespace CEGUI
38 {
43  class CEGUIEXPORT BaseDim
44  {
45  public:
46  BaseDim();
47 
48  virtual ~BaseDim();
49 
61  float getValue(const Window& wnd) const;
62 
80  float getValue(const Window& wnd, const Rect& container) const;
81 
94  BaseDim* clone() const;
95 
104  DimensionOperator getDimensionOperator() const;
105 
117  void setDimensionOperator(DimensionOperator op);
118 
126  const BaseDim* getOperand() const;
127 
139  void setOperand(const BaseDim& operand);
140 
151  void writeXMLToStream(XMLSerializer& xml_stream) const;
152 
153  protected:
159  virtual float getValue_impl(const Window& wnd) const = 0;
160 
166  virtual float getValue_impl(const Window& wnd, const Rect& container) const = 0;
167 
174  virtual BaseDim* clone_impl() const = 0;
175 
180  virtual void writeXMLElementName_impl(XMLSerializer& xml_stream) const = 0;
181 
186  virtual void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const = 0;
187 
188  private:
189  DimensionOperator d_operator;
190  BaseDim* d_operand;
191  };
192 
193 
198  class CEGUIEXPORT AbsoluteDim : public BaseDim
199  {
200  public:
208  AbsoluteDim(float val);
209 
214  void setValue(float val);
215 
216  protected:
217  // Implementation of the base class interface
218  float getValue_impl(const Window& wnd) const;
219  float getValue_impl(const Window& wnd, const Rect& container) const;
220  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
221  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
222 
223  BaseDim* clone_impl() const;
224 
225  private:
226  float d_val;
227  };
228 
229 
234  class CEGUIEXPORT ImageDim : public BaseDim
235  {
236  public:
251  ImageDim(const String& imageset, const String& image, DimensionType dim);
252 
266  void setSourceImage(const String& imageset, const String& image);
267 
279  void setSourceDimension(DimensionType dim);
280 
281  protected:
282  // Implementation of the base class interface
283  float getValue_impl(const Window& wnd) const;
284  float getValue_impl(const Window& wnd, const Rect& container) const;
285  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
286  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
287  BaseDim* clone_impl() const;
288 
289  private:
290  String d_imageset;
291  String d_image;
292  DimensionType d_what;
293  };
294 
295 
305  class CEGUIEXPORT WidgetDim : public BaseDim
306  {
307  public:
319  WidgetDim(const String& name, DimensionType dim);
320 
331  void setWidgetName(const String& name);
332 
344  void setSourceDimension(DimensionType dim);
345 
346  protected:
347  // Implementation of the base class interface
348  float getValue_impl(const Window& wnd) const;
349  float getValue_impl(const Window& wnd, const Rect& container) const;
350  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
351  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
352  BaseDim* clone_impl() const;
353 
354  private:
355  String d_widgetName;
356  DimensionType d_what;
357  };
358 
359 
364  class CEGUIEXPORT UnifiedDim : public BaseDim
365  {
366  public:
379  UnifiedDim(const UDim& value, DimensionType dim);
380 
381  protected:
382  // Implementation of the base class interface
383  float getValue_impl(const Window& wnd) const;
384  float getValue_impl(const Window& wnd, const Rect& container) const;
385  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
386  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
387  BaseDim* clone_impl() const;
388 
389  private:
390  UDim d_value;
391  DimensionType d_what;
392  };
393 
398  class CEGUIEXPORT FontDim : public BaseDim
399  {
400  public:
423  FontDim(const String& name, const String& font, const String& text, FontMetricType metric, float padding = 0);
424 
425  protected:
426  // Implementation of the base class interface
427  float getValue_impl(const Window& wnd) const;
428  float getValue_impl(const Window& wnd, const Rect& container) const;
429  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
430  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
431  BaseDim* clone_impl() const;
432 
433  private:
434  String d_font;
435  String d_text;
436  String d_childSuffix;
437  FontMetricType d_metric;
438  float d_padding;
439  };
440 
446  class CEGUIEXPORT PropertyDim : public BaseDim
447  {
448  public:
474  PropertyDim(const String& name, const String& property, DimensionType type);
475 
476  protected:
477  // Implementation of the base class interface
478  float getValue_impl(const Window& wnd) const;
479  float getValue_impl(const Window& wnd, const Rect& container) const;
480  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
481  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
482  BaseDim* clone_impl() const;
483 
484  private:
485  String d_property;
486  String d_childSuffix;
487  DimensionType d_type;
488  };
489 
498  class CEGUIEXPORT Dimension
499  {
500  public:
505  Dimension();
506 
511  ~Dimension();
512 
523  Dimension(const BaseDim& dim, DimensionType type);
524 
529  Dimension(const Dimension& other);
530 
535  Dimension& operator=(const Dimension& other);
536 
544  const BaseDim& getBaseDimension() const;
545 
556  void setBaseDimension(const BaseDim& dim);
557 
565  DimensionType getDimensionType() const;
566 
577  void setDimensionType(DimensionType type);
578 
589  void writeXMLToStream(XMLSerializer& xml_stream) const;
590 
591  private:
592  BaseDim* d_value;
593  DimensionType d_type;
594  };
595 
596 
606  class CEGUIEXPORT ComponentArea
607  {
608  public:
620  Rect getPixelRect(const Window& wnd) const;
621 
636  Rect getPixelRect(const Window& wnd, const Rect& container) const;
637 
649  void writeXMLToStream(XMLSerializer& xml_stream) const;
650 
659  bool isAreaFetchedFromProperty() const;
660 
668  const String& getAreaPropertySource() const;
669 
680  void setAreaPropertySource(const String& property);
681 
682 
687 
688  private:
689  String d_areaProperty;
690  };
691 
692 } // End of CEGUI namespace section
693 
694 
695 #endif // end of guard _CEGUIFalDimensions_h_