📄 ceguifaldimensions.h
字号:
/***********************************************************************
filename: CEGUIFalDimensions.h
created: Mon Jun 13 2005
author: Paul D Turner <paul@cegui.org.uk>
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIFalDimensions_h_
#define _CEGUIFalDimensions_h_
#include "falagard/CEGUIFalEnums.h"
#include "CEGUIString.h"
#include "CEGUIUDim.h"
#include "CEGUIXMLSerializer.h"
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Abstract interface for a generic 'dimension' class.
*/
class CEGUIEXPORT BaseDim
{
public:
BaseDim();
virtual ~BaseDim();
/*!
\brief
Return a value that represents this dimension as absolute pixels.
\param wnd
Window object that may be used by the specialised class to aid in
calculating the final value.
\return
float value which represents, in pixels, the same value as this BaseDim.
*/
float getValue(const Window& wnd) const;
/*!
\brief
Return a value that represents this dimension as absolute pixels.
\param wnd
Window object that may be used by the specialised class to aid in
calculating the final value (typically would be used to obtain
window/widget dimensions).
\param container
Rect object which describes an area to be considered as the base area
when calculating the final value. Basically this means that relative values
are calculated from the dimensions of this Rect.
\return
float value which represents, in pixels, the same value as this BaseDim.
*/
float getValue(const Window& wnd, const Rect& container) const;
/*!
\brief
Create an exact copy of the specialised class and return it as a pointer to
a BaseDim object.
Since the system needs to be able to copy objects derived from BaseDim, but only
has knowledge of the BaseDim interface, this clone method is provided to prevent
slicing issues.
\return
BaseDim object pointer
*/
BaseDim* clone() const;
/*!
\brief
Return the DimensionOperator set for this BaseDim based object.
\return
One of the DimensionOperator enumerated values representing a mathematical operation to be
performed upon this BaseDim using the set operand.
*/
DimensionOperator getDimensionOperator() const;
/*!
\brief
Set the DimensionOperator set for this BaseDim based object.
\param op
One of the DimensionOperator enumerated values representing a mathematical operation to be
performed upon this BaseDim using the set operand.
\return
Nothing.
*/
void setDimensionOperator(DimensionOperator op);
/*!
\brief
Return a pointer to the BaseDim set to be used as the other operand.
\return
Pointer to the BaseDim object.
*/
const BaseDim* getOperand() const;
/*!
\brief
Set the BaseDim set to be used as the other operand in calculations for this BaseDim.
\param operand
sub-class of BaseDim representing the 'other' operand. The given object will be cloned; no
transfer of ownership occurrs for the passed object.
\return
Nothing.
*/
void setOperand(const BaseDim& operand);
/*!
\brief
Writes an xml representation of this BaseDim to \a out_stream.
\param xml_stream
Stream where xml data should be output.
\return
Nothing.
*/
void writeXMLToStream(XMLSerializer& xml_stream) const;
protected:
/*!
\brief
Implementataion method to return the base value for this BaseDim. This method should
not attempt to apply the mathematical operator; this is handled automatically.
*/
virtual float getValue_impl(const Window& wnd) const = 0;
/*!
\brief
Implementataion method to return the base value for this BaseDim. This method should
not attempt to apply the mathematical operator; this is handled automatically by BaseDim.
*/
virtual float getValue_impl(const Window& wnd, const Rect& container) const = 0;
/*!
\brief
Implementataion method to return a clone of this sub-class of BaseDim.
This method should not attempt to clone the mathematical operator or operand; theis is
handled automatically by BaseDim.
*/
virtual BaseDim* clone_impl() const = 0;
/*!
\brief
Implementataion method to output real xml element name.
*/
virtual void writeXMLElementName_impl(XMLSerializer& xml_stream) const = 0;
/*!
\brief
Implementataion method to create the element attributes
*/
virtual void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const = 0;
private:
DimensionOperator d_operator;
BaseDim* d_operand;
};
/*!
\brief
Dimension type that represents an absolute pixel value. Implements BaseDim interface.
*/
class CEGUIEXPORT AbsoluteDim : public BaseDim
{
public:
/*!
\brief
Constructor.
\param val
float value to be assigned to the AbsoluteDim.
*/
AbsoluteDim(float val);
/*!
\brief
Set the current value of the AbsoluteDim.
*/
void setValue(float val);
protected:
// Implementation of the base class interface
float getValue_impl(const Window& wnd) const;
float getValue_impl(const Window& wnd, const Rect& container) const;
void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
BaseDim* clone_impl() const;
private:
float d_val; //!< holds pixel value for the AbsoluteDim.
};
/*!
\brief
Dimension type that represents some dimension of a named Image. Implements BaseDim interface.
*/
class CEGUIEXPORT ImageDim : public BaseDim
{
public:
/*!
\brief
Constructor.
\param imageset
String object holding the name of the imagseset which contains the image.
\param image
String object holding the name of the image.
\param dim
DimensionType value indicating which dimension of the described image that this ImageDim
is to represent.
*/
ImageDim(const String& imageset, const String& image, DimensionType dim);
/*!
\brief
Sets the source image information for this ImageDim.
\param imageset
String object holding the name of the imagseset which contains the image.
\param image
String object holding the name of the image.
\return
Nothing.
*/
void setSourceImage(const String& imageset, const String& image);
/*!
\brief
Sets the source dimension type for this ImageDim.
\param dim
DimensionType value indicating which dimension of the described image that this ImageDim
is to represent.
\return
Nothing.
*/
void setSourceDimension(DimensionType dim);
protected:
// Implementation of the base class interface
float getValue_impl(const Window& wnd) const;
float getValue_impl(const Window& wnd, const Rect& container) const;
void writeXMLElementName_impl(XMLSerializer& xml_stream) const;
void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const;
BaseDim* clone_impl() const;
private:
String d_imageset; //!< name of the Imageset containing the image.
String d_image; //!< name of the Image.
DimensionType d_what; //!< the dimension of the image that we are to represent.
};
/*!
\brief
Dimension type that represents some dimension of a Window/widget. Implements BaseDim interface.
When calculating the final pixel value for the dimension, a target widget name is built by
appending the name suffix specified for the WidgetDim to the name of the window passed to
getValue, we then find the window/widget with that name - the final value of the dimension
is taken from this window/widget.
*/
class CEGUIEXPORT WidgetDim : public BaseDim
{
public:
/*!
\brief
Constructor.
\param name
String object holding the name suffix for a window/widget.
\param dim
DimensionType value indicating which dimension of the described image that this ImageDim
is to represent.
*/
WidgetDim(const String& name, DimensionType dim);
/*!
\brief
Set the name suffix to use for this WidgetDim.
\param name
String object holding the name suffix for a window/widget.
\return
Nothing.
*/
void setWidgetName(const String& name);
/*!
\brief
Sets the source dimension type for this WidgetDim.
\param dim
DimensionType value indicating which dimension of the described image that this WidgetDim
is to represent.
\return
Nothing.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -