MyGUI 3.0.1

MyGUI::Canvas Class Reference

#include <MyGUI_Canvas.h>

Inheritance diagram for MyGUI::Canvas:

Data Structures

struct  Event

Public Types

enum  TextureResizeMode { TRM_PT_CONST_SIZE, TRM_PT_VIEW_REQUESTED, TRM_PT_VIEW_ALL }
typedef RTTIBase Base
typedef Canvas RTTIBase
typedef delegates::CDelegate1
< Canvas * > 
EventInfo_Canvas
typedef delegates::CDelegate2
< Canvas *, Event
EventInfo_CanvasEvent

Public Member Functions

virtual const std::string & getTypeName () const
virtual bool isType (const std::type_info &_type) const
template<typename Type >
bool isType () const
 Canvas ()
void createTexture (TextureResizeMode _resizeMode, TextureUsage _usage=getDefaultTextureUsage(), PixelFormat _format=getDefaultTextureFormat())
 Creates texture.
void createTexture (int _width, int _height, TextureResizeMode _resizeMode, TextureUsage _usage=getDefaultTextureUsage(), PixelFormat _format=getDefaultTextureFormat())
 Creates texture.
void createTexture (const IntSize &_size, TextureResizeMode _resizeMode, TextureUsage _usage=getDefaultTextureUsage(), PixelFormat _format=getDefaultTextureFormat())
 Creates texture.
void destroyTexture ()
 Destroys texture.
void updateTexture ()
 Call user delegate update and removes old texture if it isn't original.
void * lock (TextureUsage _usage=TextureUsage::Write)
 Locks hardware pixel buffer.
void unlock ()
 Unlocks hardware pixel buffer.
bool isLocked () const
 Checks lockness of hardware _pixel buffer.
int getTextureRealWidth () const
 Returns real width of texture.
int getTextureRealHeight () const
 Returns real height of texture.
IntSize getTextureRealSize () const
 Returns real _size of texture.
int getTextureSrcWidth () const
 Returns needed width while creating texture.
int getTextureSrcHeight () const
 Returns needed height while creating texture.
IntSize getTextureSrcSize () const
 Returns needed sizes while creating texture.
PixelFormat getTextureFormat () const
 Returns needed sizes while creating texture.
const std::string & getTextureName () const
 Returns name of the current texture.
virtual void setSize (const IntSize &_value)
virtual void setCoord (const IntCoord &_value)
void setSize (int _width, int _height)
void setCoord (int _left, int _top, int _width, int _height)
TextureResizeMode getResizeMode () const
 Returns resize mode.
void setResizeMode (TextureResizeMode _set)
 Sets resize mode of texture.
bool isTextureSrcSize () const
 Checks if the texture has the source (required by user) size, otherwise real texture size are bigger.
bool isTextureCreated () const
 Returns true if the texture was created (and exists), otherwise false.
bool isTextureManaged () const
 Returns true if we own the texture, otherwise false.
ITexturegetTexture ()
 Reurns interface texture.
void setTextureManaged (bool _value)
 Sets the texture managed.
virtual void _initialise (WidgetStyle _style, const IntCoord &_coord, Align _align, ResourceSkin *_info, Widget *_parent, ICroppedRectangle *_croppedParent, IWidgetCreator *_creator, const std::string &_name)

Static Public Member Functions

static const std::string & getClassTypeName ()
static TextureUsage getDefaultTextureUsage ()
 Returns default GUI texture usage.
static PixelFormat getDefaultTextureFormat ()
 Returns default GUI texture format.

Data Fields

EventInfo_Canvas eventPreTextureChanges
EventInfo_CanvasEvent requestUpdateCanvas

Protected Member Functions

virtual ~Canvas ()
void _destroyTexture (bool _sendEvent)
 Destroys texture.
void validate (int &_width, int &_height, TextureUsage &_usage, PixelFormat &_format) const
 Update entered parameters according to current texture resize mode(size) and restore (if can) parameters of usage and format from texture.
void createExactTexture (int _width, int _height, TextureUsage _usage, PixelFormat _format)
 Creates the texture itself.
bool checkCreate (int _width, int _height) const
 Checks if we need to create a texture with such sizes.
void resize (const IntSize &_size)
 Calls when resize widget.
void correctUV ()
 Correct texture uv-coordinates.
void baseChangeWidgetSkin (ResourceSkin *_info)
void initialiseWidgetSkin (ResourceSkin *_info)
void shutdownWidgetSkin ()
void frameAdvise (bool _advise)
 For updating once per frame.
void frameEntered (float _time)
 For updating once per frame.
virtual void textureInvalidate (ITexture *_texture)

Protected Attributes

ITexturemTexture
 Current texture.
IntSize mReqTexSize
 Requested bu user sizes.
std::string mGenTexName
 Generated texture name.
TextureResizeMode mTexResizeMode
 Texture resize mode.
uint8mTexData
 Saved pointer from last calling lock.
bool mTexManaged
 true if we own the texture (can delete it or replace by another instance), otherwise false
bool mFrameAdvise
 For updating once per frame. True state means updating before next frame starts.

Detailed Description

Widget wrapper over Texture - shows the texture. Implemented: resizing of texture (see TextureResizeMode); recovery after lossing device;

Definition at line 37 of file MyGUI_Canvas.h.


Member Typedef Documentation

Definition at line 41 of file MyGUI_Canvas.h.

Reimplemented from MyGUI::Widget.

Definition at line 41 of file MyGUI_Canvas.h.


Member Enumeration Documentation

Available resize and view modes of texture

Remarks:
PT - Power of Two (size)
Enumerator:
TRM_PT_CONST_SIZE 
TRM_PT_VIEW_REQUESTED 

Texture doesn't resizes and fills all widget space.

TRM_PT_VIEW_ALL 

You can view all pixels of texture, texture cropped by sizes of widget.

Texture resizes and fills all widget space

Definition at line 70 of file MyGUI_Canvas.h.


Constructor & Destructor Documentation

MyGUI::Canvas::Canvas ( )

Definition at line 33 of file MyGUI_Canvas.cpp.

MyGUI::Canvas::~Canvas ( ) [protected, virtual]

Definition at line 48 of file MyGUI_Canvas.cpp.


Member Function Documentation

void MyGUI::Canvas::_destroyTexture ( bool  _sendEvent) [protected]

Destroys texture.

Definition at line 165 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::_initialise ( WidgetStyle  _style,
const IntCoord _coord,
Align  _align,
ResourceSkin _info,
Widget _parent,
ICroppedRectangle _croppedParent,
IWidgetCreator _creator,
const std::string &  _name 
) [virtual]

Reimplemented from MyGUI::Widget.

Definition at line 43 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::baseChangeWidgetSkin ( ResourceSkin _info) [protected, virtual]

Reimplemented from MyGUI::Widget.

Definition at line 210 of file MyGUI_Canvas.cpp.

bool MyGUI::Canvas::checkCreate ( int  _width,
int  _height 
) const [protected]

Checks if we need to create a texture with such sizes.

Definition at line 133 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::correctUV ( ) [protected]

Correct texture uv-coordinates.

Definition at line 180 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::createExactTexture ( int  _width,
int  _height,
TextureUsage  _usage,
PixelFormat  _format 
) [protected]

Creates the texture itself.

Definition at line 69 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::createTexture ( TextureResizeMode  _resizeMode,
TextureUsage  _usage = getDefaultTextureUsage(),
PixelFormat  _format = getDefaultTextureFormat() 
)

Creates texture.

Definition at line 53 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::createTexture ( int  _width,
int  _height,
TextureResizeMode  _resizeMode,
TextureUsage  _usage = getDefaultTextureUsage(),
PixelFormat  _format = getDefaultTextureFormat() 
)

Creates texture.

Definition at line 96 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::createTexture ( const IntSize _size,
TextureResizeMode  _resizeMode,
TextureUsage  _usage = getDefaultTextureUsage(),
PixelFormat  _format = getDefaultTextureFormat() 
)

Creates texture.

Definition at line 58 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::destroyTexture ( )

Destroys texture.

Definition at line 160 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::frameAdvise ( bool  _advise) [protected]

For updating once per frame.

Definition at line 228 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::frameEntered ( float  _time) [protected]

For updating once per frame.

Reimplemented from MyGUI::Widget.

Definition at line 248 of file MyGUI_Canvas.cpp.

static const std::string& MyGUI::Canvas::getClassTypeName ( ) [inline, static]

Reimplemented from MyGUI::Widget.

Definition at line 41 of file MyGUI_Canvas.h.

static PixelFormat MyGUI::Canvas::getDefaultTextureFormat ( ) [inline, static]

Returns default GUI texture format.

Definition at line 163 of file MyGUI_Canvas.h.

static TextureUsage MyGUI::Canvas::getDefaultTextureUsage ( ) [inline, static]

Returns default GUI texture usage.

Definition at line 160 of file MyGUI_Canvas.h.

TextureResizeMode MyGUI::Canvas::getResizeMode ( ) const [inline]

Returns resize mode.

Definition at line 139 of file MyGUI_Canvas.h.

ITexture* MyGUI::Canvas::getTexture ( ) [inline]

Reurns interface texture.

Definition at line 154 of file MyGUI_Canvas.h.

PixelFormat MyGUI::Canvas::getTextureFormat ( ) const [inline]

Returns needed sizes while creating texture.

Definition at line 123 of file MyGUI_Canvas.h.

const std::string& MyGUI::Canvas::getTextureName ( ) const [inline]

Returns name of the current texture.

Definition at line 126 of file MyGUI_Canvas.h.

int MyGUI::Canvas::getTextureRealHeight ( ) const [inline]

Returns real height of texture.

Definition at line 108 of file MyGUI_Canvas.h.

IntSize MyGUI::Canvas::getTextureRealSize ( ) const [inline]

Returns real _size of texture.

Definition at line 111 of file MyGUI_Canvas.h.

int MyGUI::Canvas::getTextureRealWidth ( ) const [inline]

Returns real width of texture.

Definition at line 105 of file MyGUI_Canvas.h.

int MyGUI::Canvas::getTextureSrcHeight ( ) const [inline]

Returns needed height while creating texture.

Definition at line 117 of file MyGUI_Canvas.h.

IntSize MyGUI::Canvas::getTextureSrcSize ( ) const [inline]

Returns needed sizes while creating texture.

Definition at line 120 of file MyGUI_Canvas.h.

int MyGUI::Canvas::getTextureSrcWidth ( ) const [inline]

Returns needed width while creating texture.

Definition at line 114 of file MyGUI_Canvas.h.

virtual const std::string& MyGUI::Canvas::getTypeName ( ) const [inline, virtual]

Get type name as string

Reimplemented from MyGUI::Widget.

Definition at line 41 of file MyGUI_Canvas.h.

void MyGUI::Canvas::initialiseWidgetSkin ( ResourceSkin _info) [protected]

Definition at line 215 of file MyGUI_Canvas.cpp.

bool MyGUI::Canvas::isLocked ( ) const [inline]

Checks lockness of hardware _pixel buffer.

Definition at line 102 of file MyGUI_Canvas.h.

bool MyGUI::Canvas::isTextureCreated ( ) const [inline]

Returns true if the texture was created (and exists), otherwise false.

Definition at line 148 of file MyGUI_Canvas.h.

bool MyGUI::Canvas::isTextureManaged ( ) const [inline]

Returns true if we own the texture, otherwise false.

See also:
mManaged

Definition at line 151 of file MyGUI_Canvas.h.

bool MyGUI::Canvas::isTextureSrcSize ( ) const

Checks if the texture has the source (required by user) size, otherwise real texture size are bigger.

Definition at line 223 of file MyGUI_Canvas.cpp.

template<typename Type >
bool MyGUI::Canvas::isType ( ) const [inline]

Compare with selected type

Reimplemented from MyGUI::Widget.

Definition at line 41 of file MyGUI_Canvas.h.

virtual bool MyGUI::Canvas::isType ( const std::type_info &  _type) const [inline, virtual]

Compare with selected type

Reimplemented from MyGUI::Widget.

Definition at line 41 of file MyGUI_Canvas.h.

void * MyGUI::Canvas::lock ( TextureUsage  _usage = TextureUsage::Write)

Locks hardware pixel buffer.

Definition at line 196 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::resize ( const IntSize _size) [protected]

Calls when resize widget.

Definition at line 86 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::setCoord ( int  _left,
int  _top,
int  _width,
int  _height 
) [inline]

See Widget::setCoord(const IntCoord& _coord)

Reimplemented from MyGUI::Widget.

Definition at line 136 of file MyGUI_Canvas.h.

void MyGUI::Canvas::setCoord ( const IntCoord _value) [virtual]

Set widget position and size

Reimplemented from MyGUI::Widget.

Definition at line 121 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::setResizeMode ( TextureResizeMode  _set) [inline]

Sets resize mode of texture.

See also:
TextureResizeMode

Definition at line 142 of file MyGUI_Canvas.h.

void MyGUI::Canvas::setSize ( int  _width,
int  _height 
) [inline]

See Widget::setSize(const IntSize& _size)

Reimplemented from MyGUI::Widget.

Definition at line 134 of file MyGUI_Canvas.h.

void MyGUI::Canvas::setSize ( const IntSize _value) [virtual]

Set widget size

Reimplemented from MyGUI::Widget.

Definition at line 114 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::setTextureManaged ( bool  _value) [inline]

Sets the texture managed.

Remarks:
Be careful with assigning managed status to texture, which wasn't created in Canvas!
See also:
mManaged

Definition at line 157 of file MyGUI_Canvas.h.

void MyGUI::Canvas::shutdownWidgetSkin ( ) [protected]

Definition at line 219 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::textureInvalidate ( ITexture _texture) [protected, virtual]

Implements MyGUI::ITextureInvalidateListener.

Definition at line 276 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::unlock ( )

Unlocks hardware pixel buffer.

Definition at line 205 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::updateTexture ( )

Call user delegate update and removes old texture if it isn't original.

Definition at line 128 of file MyGUI_Canvas.cpp.

void MyGUI::Canvas::validate ( int &  _width,
int &  _height,
TextureUsage _usage,
PixelFormat _format 
) const [protected]

Update entered parameters according to current texture resize mode(size) and restore (if can) parameters of usage and format from texture.

Definition at line 144 of file MyGUI_Canvas.cpp.


Field Documentation

Event : Notify user texture instance will be changed

See also:
requestUpdateCanvas
signature : void method(MyGUI::Canvas* _canvas)
Parameters:
_canvas,whichwill be updated

Definition at line 170 of file MyGUI_Canvas.h.

bool MyGUI::Canvas::mFrameAdvise [protected]

For updating once per frame. True state means updating before next frame starts.

Definition at line 240 of file MyGUI_Canvas.h.

std::string MyGUI::Canvas::mGenTexName [protected]

Generated texture name.

Definition at line 228 of file MyGUI_Canvas.h.

Requested bu user sizes.

Definition at line 225 of file MyGUI_Canvas.h.

Saved pointer from last calling lock.

See also:
lock

Definition at line 234 of file MyGUI_Canvas.h.

bool MyGUI::Canvas::mTexManaged [protected]

true if we own the texture (can delete it or replace by another instance), otherwise false

Definition at line 237 of file MyGUI_Canvas.h.

Texture resize mode.

See also:
TextureResizeMode

Definition at line 231 of file MyGUI_Canvas.h.

Current texture.

Reimplemented from MyGUI::Widget.

Definition at line 222 of file MyGUI_Canvas.h.

Event : Texture instance was changed (May be caused by resizing texture or lossing device). User have to update all references to new instance of texture.
signature : void method(MyGUI::Canvas* _canvas, MyGUI::Canvas::Event _event)

Parameters:
_canvas,whichneeds to update
_event

Definition at line 177 of file MyGUI_Canvas.h.


The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines