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
CzUITextView.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_UI_TEXT_VIEW_H_)
00015 #define _CCZ_UI_TEXT_VIEW_H_
00016 
00017 #include "CzUIBase.h"
00018 #include "CzUILabel.h"
00019 #include "CzScene.h"
00020 #include "CzBrush.h"
00021 #include "CzInput.h"
00022 
00023 //
00024 //
00025 //
00026 //
00027 // CzUITextView - UI class that allows the user to view and edit multi-line scrolling text
00028 //
00029 //
00030 //
00031 //
00032 class CzUITextView : public CzUILabel
00033 {
00034 public:
00035     // Properties
00036 protected:
00037     CzIVec2             Area;                           ///< The area that the etxt should fit into
00038     float               Zoom;                           ///< Current zoom
00039     float               MinZoom;                        ///< The minimum zoom point
00040     float               MaxZoom;                        ///< The maximum zoom point
00041 public:
00042     void                setArea(CzIVec2& size);
00043     CzIVec2             getArea() const                 { return Area; }
00044     void                setZoom(float scale);
00045     float               getZoom() const                 { return Zoom; }
00046     void                setMinZoom(float scale)         { MinZoom = scale; }
00047     float               getMinZoom() const              { return MinZoom; }
00048     void                setMaxZoom(float scale)         { MaxZoom = scale; }
00049     float               getMaxZoom() const              { return MaxZoom; }
00050     bool                setProperty(unsigned int property_name, const CzXomlProperty& data, bool delta);
00051     bool                setProperty(unsigned int property_name, const CzString& data, bool delta);
00052     bool                getProperty(unsigned int property_name, CzXomlProperty& prop);
00053 
00054     // Properties end
00055 protected:
00056     float               PrevZoom;
00057     CzVec2              Midpoint;
00058     bool                ZoomValid;
00059     float               PreviousDist;
00060     float               CompoundScale;
00061     CzVec2              CompoundPosition;
00062     float               SavedCompoundScale;
00063     CzVec2              SavedCompoundPosition;
00064     CzVec2              PanVelocity;
00065     int                 TouchIndices[2];
00066     int                 NumTouches;
00067     bool                UpdateBinding(unsigned int property_name, CzXomlVariable* var);
00068 public:
00069     CzUITextView();
00070 
00071     virtual bool        InitView(bool native_res, float min_scale, float max_scale);
00072 
00073     bool                Update(float dt);
00074     bool                UpdateVisual();
00075 
00076     // Event handlers
00077     void                NotifyBeginTouch(int index, int x, int y, bool allow_bubble);
00078     void                NotifyEndTouch(int index, int x, int y, bool allow_bubble);
00079 
00080     // Implementation of IzXomlClass interface
00081     int                 LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00082 
00083     // Implementation of IzAnimTarget interface
00084     bool                UpdateFromAnimation(CzAnimInstance *animation);
00085 
00086     // Internal (used by XOML system to setup and cleanup the XOML class properties system
00087 protected:
00088     static CzXomlClassDef*  TextViewClassDef;                               // XOML class definition
00089 public:
00090     static void             InitClass();
00091     static void             ReleaseClass();
00092 
00093     static bool             _setMinZoom(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00094     static CzXomlProperty   _getMinZoom(IzXomlResource* target);
00095     static bool             _setMaxZoom(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00096     static CzXomlProperty   _getMaxZoom(IzXomlResource* target);
00097     static bool             _setZoom(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00098     static CzXomlProperty   _getZoom(IzXomlResource* target);
00099     static bool             _setArea(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00100     static CzXomlProperty   _getArea(IzXomlResource* target);
00101 };
00102 
00103 //
00104 //  CzUITextViewCreator - Creates an instance of a TextView actor object
00105 //
00106 class CzUITextViewCreator : public IzXomlClassCreator
00107 {
00108 public:
00109     CzUITextViewCreator()
00110     {
00111         setClassName("textview");
00112     }
00113     IzXomlResource* CreateInstance(IzXomlResource* parent)  { return new CzUITextView(); }
00114 };
00115 
00116 
00117 #endif  // _CCZ_UI_TEXT_VIEW_H_
00118