Crazy Eddies GUI System  0.6.0
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 "falagard/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 
445  class CEGUIEXPORT PropertyDim : public BaseDim
446  {
447  public:
462  PropertyDim(const String& name, const String& property, DimensionType type);
463 
464  protected:
465  // Implementation of the base class interface
466  float getValue_impl(const Window& wnd) const;
467  float getValue_impl(const Window& wnd, const Rect& container) const;
468  void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
469  void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
470  BaseDim* clone_impl() const;
471 
472  private:
473  String d_property;
474  String d_childSuffix;
475  DimensionType d_type;
476  };
477 
486  class CEGUIEXPORT Dimension
487  {
488  public:
493  Dimension();
494 
499  ~Dimension();
500 
511  Dimension(const BaseDim& dim, DimensionType type);
512 
517  Dimension(const Dimension& other);
518 
523  Dimension& operator=(const Dimension& other);
524 
532  const BaseDim& getBaseDimension() const;
533 
544  void setBaseDimension(const BaseDim& dim);
545 
553  DimensionType getDimensionType() const;
554 
565  void setDimensionType(DimensionType type);
566 
577  void writeXMLToStream(XMLSerializer& xml_stream) const;
578 
579  private:
580  BaseDim* d_value;
581  DimensionType d_type;
582  };
583 
584 
594  class CEGUIEXPORT ComponentArea
595  {
596  public:
608  Rect getPixelRect(const Window& wnd) const;
609 
624  Rect getPixelRect(const Window& wnd, const Rect& container) const;
625 
637  void writeXMLToStream(XMLSerializer& xml_stream) const;
638 
647  bool isAreaFetchedFromProperty() const;
648 
656  const String& getAreaPropertySource() const;
657 
668  void setAreaPropertySource(const String& property);
669 
670 
675 
676  private:
677  String d_areaProperty;
678  };
679 
680 } // End of CEGUI namespace section
681 
682 
683 #endif // end of guard _CEGUIFalDimensions_h_