Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
Dimensions.h
1/***********************************************************************
2 created: Mon Jun 13 2005
3 author: Paul D Turner <paul@cegui.org.uk>
4*************************************************************************/
5/***************************************************************************
6 * Copyright (C) 2004 - 2012 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 _CEGUIFalDimensions_h_
28#define _CEGUIFalDimensions_h_
29
30#include "./Enums.h"
31#include "../String.h"
32#include "../UDim.h"
33#include "../Rect.h"
34#include "../XMLSerializer.h"
35
36// Start of CEGUI namespace section
37namespace CEGUI
38{
40class CEGUIEXPORT BaseDim :
41 public AllocatedObject<BaseDim>
42{
43public:
44 BaseDim();
45
46 virtual ~BaseDim();
47
59 virtual float getValue(const Window& wnd) const = 0;
60
78 virtual float getValue(const Window& wnd, const Rectf& container) const = 0;
79
89 virtual BaseDim* clone() const = 0;
90
98 virtual void writeXMLToStream(XMLSerializer& xml_stream) const;
99
101 virtual bool handleFontRenderSizeChange(Window& window,
102 const Font* font) const;
103protected:
105 virtual void writeXMLElementName_impl(XMLSerializer& xml_stream) const = 0;
106
108 virtual void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const = 0;
109};
110
116class CEGUIEXPORT OperatorDim : public BaseDim
117{
118public:
119 OperatorDim();
121 OperatorDim(DimensionOperator op, BaseDim* left, BaseDim* right);
122 ~OperatorDim();
123
125 void setLeftOperand(const BaseDim* operand);
126
129
131 void setRightOperand(const BaseDim* operand);
132
135
138
141
143 void setNextOperand(const BaseDim* operand);
144
145 // Implementation of the base class interface
146 float getValue(const Window& wnd) const;
147 float getValue(const Window& wnd, const Rectf& container) const;
148 BaseDim* clone() const;
149
150protected:
151 float getValueImpl(const float lval, const float rval) const;
152 // Implementation of the base class interface
153 void writeXMLToStream(XMLSerializer& xml_stream) const;
156
157 BaseDim* d_left;
158 BaseDim* d_right;
160};
161
167class CEGUIEXPORT AbsoluteDim : public BaseDim
168{
169public:
170 AbsoluteDim() {};
171 AbsoluteDim(float val);
172
174 float getBaseValue() const;
175
177 void setBaseValue(float val);
178
179 // Implementation of the base class interface
180 float getValue(const Window& wnd) const;
181 float getValue(const Window& wnd, const Rectf& container) const;
182 BaseDim* clone() const;
183
184protected:
185 // Implementation of the base class interface
188
189private:
191 float d_val;
192};
193
199class CEGUIEXPORT ImageDimBase : public BaseDim
200{
201public:
202 ImageDimBase() {};
203
213
223
233
234 // Implementation of the base class interface
235 float getValue(const Window& wnd) const;
236 float getValue(const Window& wnd, const Rectf& container) const;
237
238protected:
240 virtual const Image* getSourceImage(const Window& wnd) const = 0;
241
242 // Implementation of the base class interface
244
247};
248
250class CEGUIEXPORT ImageDim : public ImageDimBase
251{
252public:
253 ImageDim() {};
254 ImageDim(const String& image_name, DimensionType dim);
255
257 const String& getSourceImage() const;
259 void setSourceImage(const String& image_name);
260
261 // Implementation of the base class interface
262 BaseDim* clone() const;
263
264protected:
265 // Implementation / overrides of functions in superclasses
266 const Image* getSourceImage(const Window& wnd) const;
269
272};
273
275class CEGUIEXPORT ImagePropertyDim : public ImageDimBase
276{
277public:
278 ImagePropertyDim() {};
279
293 ImagePropertyDim(const String& property_name, DimensionType dim);
294
296 const String& getSourceProperty() const;
298 void setSourceProperty(const String& property_name);
299
300 // Implementation of the base class interface
301 BaseDim* clone() const;
302
303protected:
304 // Implementation / overrides of functions in superclasses
305 const Image* getSourceImage(const Window& wnd) const;
308
311};
312
323class CEGUIEXPORT WidgetDim : public BaseDim
324{
325public:
326 WidgetDim() {};
338 WidgetDim(const String& name, DimensionType dim);
339
347 const String& getWidgetName() const;
348
359 void setWidgetName(const String& name);
360
370
380
381 // Implementation of the base class interface
382 float getValue(const Window& wnd) const;
383 float getValue(const Window& wnd, const Rectf& container) const;
384 BaseDim* clone() const;
385
386protected:
387 // Implementation of the base class interface
390
391private:
393 String d_widgetName;
395 DimensionType d_what;
396};
397
403class CEGUIEXPORT UnifiedDim : public BaseDim
404{
405public:
406 UnifiedDim(){};
419 UnifiedDim(const UDim& value, DimensionType dim);
420
422 const UDim& getBaseValue() const;
423
425 void setBaseValue(const UDim& val);
426
437
448
449 // Implementation of the base class interface
450 float getValue(const Window& wnd) const;
451 float getValue(const Window& wnd, const Rectf& container) const;
452 BaseDim* clone() const;
453
454protected:
455 // Implementation of the base class interface
458
459private:
461 UDim d_value;
463 DimensionType d_what;
464};
465
471class CEGUIEXPORT FontDim : public BaseDim
472{
473public:
474 FontDim() {};
499 FontDim(const String& name, const String& font, const String& text,
500 FontMetricType metric, float padding = 0);
501
503 const String& getName() const;
504
506 void setName(const String& name);
507
509 const String& getFont() const;
510
512 void setFont(const String& font);
513
515 const String& getText() const;
516
518 void setText(const String& text);
519
522
525
527 float getPadding() const;
528
530 void setPadding(float padding);
531
532 // overridden from BaseDim.
534 const Font* font) const;
535
536 // Implementation of the base class interface
537 float getValue(const Window& wnd) const;
538 float getValue(const Window& wnd, const Rectf& container) const;
539 BaseDim* clone() const;
540
541protected:
542 // Implementation of the base class interface
545
546 const Font* getFontObject(const Window& window) const;
547
548private:
550 String d_font;
552 String d_text;
554 String d_childName;
556 FontMetricType d_metric;
558 float d_padding;
559};
560
566class CEGUIEXPORT PropertyDim : public BaseDim
567{
568public:
569 PropertyDim() {};
595 PropertyDim(const String& name, const String& property, DimensionType type);
603 const String& getWidgetName() const;
604
615 void setWidgetName(const String& name);
616
624 const String& getPropertyName() const;
625
636 void setPropertyName(const String& property);
637
651
665
666 // Implementation of the base class interface
667 float getValue(const Window& wnd) const;
668 float getValue(const Window& wnd, const Rectf& container) const;
669 BaseDim* clone() const;
670
671protected:
672 // Implementation of the base class interface
675
676private:
678 String d_property;
680 String d_childName;
682 DimensionType d_type;
683};
684
693class CEGUIEXPORT Dimension :
694 public AllocatedObject<Dimension>
695{
696public:
697 Dimension();
698 ~Dimension();
699 Dimension(const Dimension& other);
700 Dimension& operator=(const Dimension& other);
701
712 Dimension(const BaseDim& dim, DimensionType type);
713
722 const BaseDim& getBaseDimension() const;
723
731 void setBaseDimension(const BaseDim& dim);
732
741
750
758 void writeXMLToStream(XMLSerializer& xml_stream) const;
759
762 const Font* font) const;
763
764private:
766 BaseDim* d_value;
768 DimensionType d_type;
769};
770
780class CEGUIEXPORT ComponentArea :
781 public AllocatedObject<ComponentArea>
782{
783public:
785
799 Rectf getPixelRect(const Window& wnd) const;
800
818 Rectf getPixelRect(const Window& wnd, const Rectf& container) const;
819
827 void writeXMLToStream(XMLSerializer& xml_stream) const;
828
839
849
862 void setAreaPropertySource(const String& property);
863
872
874 void setNamedAreaSouce(const String& widget_look, const String& area_name);
875
886
888 bool handleFontRenderSizeChange(Window& window, const Font* font) const;
889
898
899private:
901 String d_namedSource;
903 String d_namedAreaSourceLook;
904};
905
906} // End of CEGUI namespace section
907
908
909#endif // end of guard _CEGUIFalDimensions_h_
910
Dimension type that represents an absolute pixel value. Implements BaseDim interface.
Definition Dimensions.h:168
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
float getBaseValue() const
Get the current value of the AbsoluteDim.
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
void setBaseValue(float val)
Set the current value of the AbsoluteDim.
Definition MemoryAllocatedObject.h:110
Abstract interface for a generic 'dimension' class.
Definition Dimensions.h:42
virtual float getValue(const Window &wnd) const =0
Return a value that represents this dimension as absolute pixels.
virtual float getValue(const Window &wnd, const Rectf &container) const =0
Return a value that represents this dimension as absolute pixels.
virtual BaseDim * clone() const =0
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
virtual bool handleFontRenderSizeChange(Window &window, const Font *font) const
perform any processing required due to the given font having changed.
virtual void writeXMLToStream(XMLSerializer &xml_stream) const
Writes an xml representation of this BaseDim to out_stream.
virtual void writeXMLElementName_impl(XMLSerializer &xml_stream) const =0
Implementataion method to output real xml element name.
virtual void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const =0
Implementataion method to create the element attributes.
Class that represents a target area for a widget or imagery component.
Definition Dimensions.h:782
void setNamedAreaSouce(const String &widget_look, const String &area_name)
Set the named area source of the ComponentArea.
bool isAreaFetchedFromProperty() const
Return whether this ComponentArea fetches it's area via a property on the target window.
bool isAreaFetchedFromNamedArea() const
Return whether this ComponentArea fetches it's area via a named area defined.
Dimension d_left
Left edge of the area.
Definition Dimensions.h:891
bool handleFontRenderSizeChange(Window &window, const Font *font) const
perform any processing required due to the given font having changed.
void writeXMLToStream(XMLSerializer &xml_stream) const
Writes an xml representation of this ComponentArea to out_stream.
const String & getNamedAreaSourceLook() const
Return the name of the look to which the NamedArea, which is defined as source, belongs to.
Dimension d_right_or_width
Either the right edge or the width of the area.
Definition Dimensions.h:895
Rectf getPixelRect(const Window &wnd, const Rectf &container) const
Return a Rectd describing the absolute pixel area represented by this ComponentArea.
void setAreaPropertySource(const String &property)
Set the name of the property that will be used to determine the pixel area for this ComponentArea.
const String & getAreaPropertySource() const
Return the name of the property that will be used to determine the pixel area for this ComponentArea.
Dimension d_top
Top edge of the area.
Definition Dimensions.h:893
Rectf getPixelRect(const Window &wnd) const
Return a Rect describing the absolute pixel area represented by this ComponentArea.
Dimension d_bottom_or_height
Either the bototm edge or the height of the area.
Definition Dimensions.h:897
Class representing some kind of dimension.
Definition Dimensions.h:695
const BaseDim & getBaseDimension() const
return the BaseDim object currently used as the value for this Dimension.
void writeXMLToStream(XMLSerializer &xml_stream) const
Writes an xml representation of this Dimension to out_stream.
void setDimensionType(DimensionType type)
Sets what this Dimension represents.
DimensionType getDimensionType() const
Return a DimensionType value indicating what this Dimension represents.
Dimension(const BaseDim &dim, DimensionType type)
Constructor.
void setBaseDimension(const BaseDim &dim)
set the current value for this Dimension.
bool handleFontRenderSizeChange(Window &window, const Font *font) const
perform any processing required due to the given font having changed.
Dimension type that represents some metric of a Font. Implements BaseDim interface.
Definition Dimensions.h:472
const String & getText() const
Get the current text of the FontDim.
const String & getFont() const
Get the current font of the FontDim.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
float getPadding() const
Get the current padding of the FontDim.
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
void setText(const String &text)
Set the current text of the FontDim.
FontMetricType getMetric() const
Get the current metric of the FontDim.
void setFont(const String &font)
Set the current font of the FontDim.
void setPadding(float padding)
Set the current padding of the FontDim.
FontDim(const String &name, const String &font, const String &text, FontMetricType metric, float padding=0)
Constructor.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
bool handleFontRenderSizeChange(Window &window, const Font *font) const
perform any processing required due to the given font having changed.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
void setMetric(FontMetricType metric)
Set the current metric of the FontDim.
const String & getName() const
Get the current name of the FontDim.
void setName(const String &name)
Set the current name of the FontDim.
Class that encapsulates a typeface.
Definition Font.h:62
Dimension type that represents some dimension of an Image. Implements BaseDim interface.
Definition Dimensions.h:200
ImageDimBase(DimensionType dim)
Constructor.
DimensionType getSourceDimension() const
Gets the source dimension type for this WidgetDim.
virtual const Image * getSourceImage(const Window &wnd) const =0
return the image instance to access
void setSourceDimension(DimensionType dim)
Sets the source dimension type for this ImageDim.
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
DimensionType d_what
the dimension of the image that we are to represent.
Definition Dimensions.h:246
ImageDimBase subclass that accesses an image by its name.
Definition Dimensions.h:251
void setSourceImage(const String &image_name)
set the name of the image accessed by this ImageDim.
const String & getSourceImage() const
return the name of the image accessed by this ImageDim.
const Image * getSourceImage(const Window &wnd) const
return the image instance to access
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
String d_imageName
name of the Image.
Definition Dimensions.h:271
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
ImageDimBase subclass that accesses an image fetched via a property.
Definition Dimensions.h:276
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
ImagePropertyDim(const String &property_name, DimensionType dim)
Constructor.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
void setSourceProperty(const String &property_name)
set the name of the property accessed by this ImagePropertyDim.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
const Image * getSourceImage(const Window &wnd) const
return the image instance to access
String d_propertyName
name of the property from which to fetch the image name.
Definition Dimensions.h:310
const String & getSourceProperty() const
return the name of the property accessed by this ImagePropertyDim.
Interface for Image.
Definition Image.h:161
Dimension type that represents the result of an operation performed on two other dimension values....
Definition Dimensions.h:117
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
void setOperator(DimensionOperator op)
Set the operation to be performed.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
BaseDim * getRightOperand() const
return pointer to the right hand side operand
void setNextOperand(const BaseDim *operand)
helper to set the next free operand, will throw after 2 are set
void writeXMLToStream(XMLSerializer &xml_stream) const
Writes an xml representation of this BaseDim to out_stream.
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
void setRightOperand(const BaseDim *operand)
set the right hand side operand (passed object is cloned)
void setLeftOperand(const BaseDim *operand)
set the left hand side operand (passed object is cloned)
DimensionOperator getOperator() const
Get the current operation that will be performed.
BaseDim * getLeftOperand() const
return pointer to the left hand side operand
Dimension type that represents the value of a Window property. Implements BaseDim interface.
Definition Dimensions.h:567
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
void setPropertyName(const String &property)
Set the name of the property to use for this WidgetDim.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
DimensionType getSourceDimension() const
Gets the source dimension type for this WidgetDim.
void setWidgetName(const String &name)
Set the name suffix to use for this WidgetDim.
const String & getPropertyName() const
Get the name of the property to use for this WidgetDim.
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
const String & getWidgetName() const
Get the name suffix to use for this WidgetDim.
void setSourceDimension(DimensionType dim)
Sets the source dimension type for this WidgetDim.
PropertyDim(const String &name, const String &property, DimensionType type)
Constructor.
String class used within the GUI system.
Definition String.h:64
Dimension that has both a relative 'scale' portion and and absolute 'offset' portion.
Definition UDim.h:94
Dimension type that represents an Unified dimension. Implements BaseDim interface.
Definition Dimensions.h:404
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
void setBaseValue(const UDim &val)
Set the current value of the UnifiedDim.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
void setSourceDimension(DimensionType dim)
Sets the source dimension type for this WidgetDim.
UnifiedDim(const UDim &value, DimensionType dim)
Constructor.
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
DimensionType getSourceDimension() const
Gets the source dimension type for this WidgetDim.
const UDim & getBaseValue() const
Get the current value of the UnifiedDim.
Dimension type that represents some dimension of a Window/widget. Implements BaseDim interface.
Definition Dimensions.h:324
WidgetDim(const String &name, DimensionType dim)
Constructor.
float getValue(const Window &wnd) const
Return a value that represents this dimension as absolute pixels.
void writeXMLElementName_impl(XMLSerializer &xml_stream) const
Implementataion method to output real xml element name.
void writeXMLElementAttributes_impl(XMLSerializer &xml_stream) const
Implementataion method to create the element attributes.
DimensionType getSourceDimension() const
Gets the source dimension type for this WidgetDim.
float getValue(const Window &wnd, const Rectf &container) const
Return a value that represents this dimension as absolute pixels.
const String & getWidgetName() const
Get the name suffix to use for this WidgetDim.
void setWidgetName(const String &name)
Set the name suffix to use for this WidgetDim.
void setSourceDimension(DimensionType dim)
Sets the source dimension type for this WidgetDim.
BaseDim * clone() const
Create an exact copy of the specialised object and return it as a pointer to a BaseDim object.
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition Window.h:151
Class used to create XML Document.
Definition XMLSerializer.h:87
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1
DimensionOperator
Enumeration of values representing mathematical operations on dimensions.
Definition Enums.h:123
DimensionType
Enumeration of possible values to indicate what a given dimension represents.
Definition Enums.h:40
FontMetricType
Enumeration of possible values to indicate a particular font metric.
Definition Enums.h:112