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
CzUITabBar.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_TABBAR_H_)
00015 #define _CCZ_UI_TABBAR_H_
00016 
00017 #include "CzUIBase.h"
00018 #include "CzUILabel.h"
00019 #include "CzScene.h"
00020 #include "CzBrush.h"
00021 #include "CzInput.h"
00022 #include "CzUIListBox.h"
00023 #include "CzUICanvas.h"
00024 
00025 class CzUITabBar;
00026 
00027 //
00028 //
00029 //
00030 //
00031 // CzUITab - A UI element that represents a tab
00032 //
00033 //
00034 //
00035 //
00036 class CzUITab : public CzUILabel
00037 {
00038     // Properties
00039 protected:
00040     CzUIBase*           View;
00041     CzUITabBar*         TabBar;
00042 public:
00043     void                setView(CzUIBase* view)         { View = view; }
00044     CzUIBase*           getView()                       { return View; }
00045     bool                setProperty(unsigned int property_name, const CzXomlProperty& data, bool delta);
00046     bool                setProperty(unsigned int property_name, const CzString& data, bool delta);
00047     bool                getProperty(unsigned int property_name, CzXomlProperty& prop);
00048     // Properties end
00049 protected:
00050     bool                UpdateBinding(unsigned int property_name, CzXomlVariable* var);
00051 public:
00052     CzUITab() : CzUILabel(), View(NULL), TabBar(NULL)
00053     {
00054         setActualClassType("tab");
00055     }
00056 
00057     void                InitTab();
00058     void                PostInitTab(CzUITabBar* tabbar);            // Called after views have been created
00059 
00060     // Event handlers
00061     void                NotifyToggledOn();
00062     void                NotifyToggledOff();
00063     void                NotifyOrientationChange(CzScene::eOrientation old_orientation, CzScene::eOrientation new_orientation);
00064 
00065     // Implementation of IzXomlClass interface
00066     int                 LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00067 
00068     // Implementation of IzAnimTarget interface
00069     bool                UpdateFromAnimation(CzAnimInstance *animation);
00070 
00071     // Internal (used by XOML system to setup and cleanup the XOML class properties system
00072 protected:
00073     static CzXomlClassDef*  UITabClassDef;                              // XOML class definition
00074 public:
00075     static void             InitClass();
00076     static void             ReleaseClass();
00077 
00078     static CzXomlProperty   _getView(IzXomlResource* target);
00079     static bool             _setView(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00080 };
00081 
00082 //
00083 //  CzUITabCreator - Creates an instance of a tab actor object
00084 //
00085 class CzUITabCreator : public IzXomlClassCreator
00086 {
00087 public:
00088     CzUITabCreator()
00089     {
00090         setClassName("tab");
00091     }
00092     IzXomlResource* CreateInstance(IzXomlResource* parent)  { return new CzUITab(); }
00093 };
00094 
00095 //
00096 //
00097 //
00098 //
00099 // CzUITabs - A UI element that represents a collection of tabs
00100 //
00101 //
00102 //
00103 //
00104 class CzUITabs : public CzUIListBox
00105 {
00106     // Properties
00107 protected:
00108 public:
00109     // Properties end
00110 protected:
00111 public:
00112     CzUITabs() : CzUIListBox()
00113     {
00114         setActualClassType("tabs");
00115     }
00116 
00117     void                InitTabs();
00118     void                PostInitTabs();     // Called after views have been created
00119 
00120     // Implementation of IzXomlClass interface
00121     int                 LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00122 };
00123 
00124 //
00125 //  CzUITabsCreator - Creates an instance of a tabs actor object
00126 //
00127 class CzUITabsCreator : public IzXomlClassCreator
00128 {
00129 public:
00130     CzUITabsCreator()
00131     {
00132         setClassName("tabs");
00133     }
00134     IzXomlResource* CreateInstance(IzXomlResource* parent)  { return new CzUITabs(); }
00135 };
00136 
00137 
00138 
00139 //
00140 //
00141 //
00142 //
00143 // CzUITabBar - UI class that allows the user to select between different groups of controls using tabs
00144 //
00145 //
00146 //
00147 //
00148 class CzUITabBar : public CzUICanvas
00149 {
00150 public:
00151     // Properties
00152 protected:
00153     eCzOrientation              Orientation;            ///< Stacking orientation (set from the tabs list box)
00154     bool                        AutoHide;               ///< If set to true then the outgoing view will automatically be hidden
00155 public:
00156     void                        setAutoHide(bool enable)        { AutoHide = enable; }
00157     bool                        isAutoHide() const              { return AutoHide; }
00158     eCzOrientation              getOrientation() const          { return Orientation; }
00159     bool                        setProperty(unsigned int property_name, const CzXomlProperty& data, bool delta);
00160     bool                        setProperty(unsigned int property_name, const CzString& data, bool delta);
00161     bool                        getProperty(unsigned int property_name, CzXomlProperty& prop);
00162     CzUITabs*                   getTabs();
00163     bool                        UpdateBinding(unsigned int property_name, CzXomlVariable* var);
00164     // Properties end
00165 protected:
00166     bool                        UpdateLayout();
00167     bool                        UpdatePanels();
00168     CzUIBase*                   PrevView;
00169     void                        LinkChanged(CzActor* child, bool remove);
00170 
00171 public:
00172     CzUITabBar() : CzUICanvas(), PrevView(NULL), AutoHide(true), Orientation(Orientation_Vertical)  { setActualClassType("tabbar"); }
00173 
00174     void                InitTabBar();
00175     bool                Update(float dt);
00176 
00177     // Event handlers
00178     void                NotifyViewChanged(CzUIBase* prev_view, CzUIBase* new_view);
00179 
00180     // Implementation of IzXomlClass interface
00181     int                 LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00182 
00183     // Implementation of IzAnimTarget interface
00184     bool                UpdateFromAnimation(CzAnimInstance *animation);
00185 
00186     void                ShowView(CzUIBase* view, bool show);
00187 
00188     // Internal (used by XOML system to setup and cleanup the XOML class properties system
00189 protected:
00190     static CzXomlClassDef*  UITabBarClassDef;                               // XOML class definition
00191 public:
00192     static void             InitClass();
00193     static void             ReleaseClass();
00194 
00195     static CzXomlProperty   _getOrientation(IzXomlResource* target);
00196     static bool             _setAutoHide(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00197     static CzXomlProperty   _getAutoHide(IzXomlResource* target);
00198     static bool             _addTab(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00199     static bool             _removeTab(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00200     static bool             _setOnViewChanged(IzXomlResource* target, const CzXomlProperty& prop, bool add);
00201 };
00202 
00203 //
00204 //  CzUITabBarCreator - Creates an instance of a tabbar actor object
00205 //
00206 class CzUITabBarCreator : public IzXomlClassCreator
00207 {
00208 public:
00209     CzUITabBarCreator()
00210     {
00211         setClassName("tabbar");
00212     }
00213     IzXomlResource* CreateInstance(IzXomlResource* parent)  { return new CzUITabBar(); }
00214 };
00215 
00216 
00217 #endif  // _CCZ_UI_TABBAR_H_
00218