AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzTextSprite.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CCZ_TEXT_SPRITE_H_)
00015 #define _CCZ_TEXT_SPRITE_H_
00016 
00017 #include "CzSprite.h"
00018 
00019 //
00020 //
00021 //
00022 // CzTextSprite - A CzTextSprite is a text based visual representation of an on screen game object
00023 //
00024 //
00025 //
00026 class CzTextSprite : public CzSprite
00027 {
00028     // Properties
00029 protected:
00030     CzString            Text;                   // Text to display
00031     CzIRect             Rect;                   // Area where to draw the text
00032     CzFont*             Font;                   // Font
00033     bool                TextDirty;              // Dirty when text has changed
00034     eCzFontFlags        Flags;                  // Font flags
00035     eCzAlignH           AlignH;                 // Horiznotal alignment
00036     eCzAlignV           AlignV;                 // Vertical alignment
00037 public:
00038     void        setText(const char* text)
00039     {
00040         if (Text.getHash() != CZ_HASH(text))
00041         {
00042             Text = text;
00043             TextDirty = true;
00044         }
00045     }
00046     CzString&       getText()                                       { return Text; }
00047     void            setRect(const CzIRect& rect)                    { Rect = rect; TransformDirty = true; TextDirty = true; }
00048     CzIRect&        getRect()                                       { return Rect; }
00049     void            setFont(CzFont* font)
00050     {
00051         Font = font;
00052         TextDirty = true;
00053     }
00054     CzFont*         getFont()                                       { return Font; }
00055     void            setFlags(eCzFontFlags flags)                    { Flags = flags; }
00056     void            setAlignH(eCzAlignH align)                      { AlignH = align; }
00057     void            setAlignV(eCzAlignV align)                      { AlignV = align; }
00058     CzFontPreparedText getPreparedData()                            { return PreparedText; }
00059     // Properties End
00060 
00061 protected:
00062     CzFontPreparedText PreparedText;
00063     void            RebuildTransform();
00064     void            UpdateBindings();
00065     void            TransformVertices();
00066 
00067 public:
00068 
00069     CzTextSprite() : CzSprite(), Font(NULL), Flags(CzFontFlags_None), AlignH(AlignH_Centre), AlignV(AlignV_Middle), TextDirty(true), Rect(-128, -128, 256, 256), PreparedText(NULL)   { setSpriteType(ST_Text); }
00070     virtual ~CzTextSprite();
00071     
00072     void            Init(int vertex_count = 4);
00073     void            Draw();
00074 
00075     void            RebuildText();
00076 };
00077 
00078 
00079 
00080 
00081 
00082 #endif // _CCZ_TEXT_SPRITE_H_