00001 //--------------------------------------------------------------------------- 00002 /// \file CATSkin.h 00003 /// \brief Root skin class 00004 /// \ingroup CATGUI 00005 /// 00006 /// Copyright (c) 2003-2008 by Michael Ellison. 00007 /// See COPYING.txt for the \ref gaslicense License (MIT License). 00008 /// 00009 // $Author: mikeellison $ 00010 // $Date: 2008-01-29 07:01:23 -0600 (Tue, 29 Jan 2008) $ 00011 // $Revision: $ 00012 // $NoKeywords: $ 00013 // 00014 // 00015 //--------------------------------------------------------------------------- 00016 #ifndef _GGSkin_H_ 00017 #define _GGSkin_H_ 00018 00019 #include <time.h> 00020 00021 #include "CATImage.h" 00022 #include "CATGuiObj.h" 00023 #include "CATStack.h" 00024 00025 class CATSkin; 00026 class CATWindow; 00027 class CATControl; 00028 00029 /// \class CATSkin CATSkin.h 00030 /// \brief Basic windowing class 00031 /// \ingroup CATGUI 00032 class CATSkin : public CATGuiObj 00033 { 00034 public: 00035 /// CATSkin constructor - base CATXMLObject contructor, 00036 /// but with the root directory of the skin and the 00037 /// full path of the skin's .XML file. 00038 /// 00039 CATSkin( const CATString& element, 00040 const CATString& skinRootDir, 00041 const CATString& skinPath); 00042 00043 virtual ~CATSkin(); 00044 00045 /// Retrieve the root directory of the skin. 00046 CATString GetRootDir(); 00047 00048 /// Retrieve the full path to the skin's .XML file. 00049 CATString GetPath(); 00050 00051 /// Retrieve the author's name for the skin 00052 CATString GetAuthor(); 00053 00054 /// Retrieve the author's URL 00055 CATString GetUrl(); 00056 00057 /// Retrieve the skin's copyright string. 00058 CATString GetCopyright(); 00059 00060 /// Retrieve a window by name 00061 /// \param name - name of the window to get 00062 /// \return CATWindow* - ptr to named window or 0 if not found 00063 CATWindow* GetWindowByName(const CATString& name); 00064 00065 00066 /// GetControlsByCommand() gets a stack of all the controls 00067 /// that reference a specific command. 00068 /// 00069 /// \param windowName - name of the window 00070 /// \param command - the string command of the controls to get 00071 /// \param controlStack - a stack to add the controls to 00072 /// \return CAT_SUCCESS on success. 00073 CATResult GetControlsByCommand( const CATString& windowName, 00074 const CATString& command, 00075 CATStack<CATControl*>& controlStack); 00076 00077 /// GetControlsByCommand() gets a stack of all the controls 00078 /// that reference a specific command. 00079 /// 00080 /// \param wnd - ptr to specific window 00081 /// \param command - the string command of the controls to get 00082 /// \param controlStack - a stack to add the controls to 00083 /// \return CAT_SUCCESS on success. 00084 CATResult GetControlsByCommand( CATWindow* wnd, 00085 const CATString& command, 00086 CATStack<CATControl*>& controlStack); 00087 00088 /// Event handler 00089 /// If an event is sent to the skin, it is sent to *all* windows. 00090 virtual CATResult OnEvent(const CATEvent& event, CATInt32& retVal); 00091 00092 00093 /// OpenWindow() opens a window from the skin by name. 00094 /// If the window is already open, then it just returns the handle. 00095 /// 00096 /// \param wndName - name of the window to open 00097 /// \param window - ref to receive window if opened or already open. 00098 /// \return CATResult - CAT_SUCCESS on success 00099 /// CAT_STAT_SKIN_WINDOW_ALREADY_OPEN if the window is already open 00100 /// CAT_ERR_SKIN_WINDOW_NOT_FOUND if window not found 00101 CATResult OpenWindow(const CATString& wndName, CATWindow*& window, CATWindow* parent = 0, CATPOINT* origin = 0); 00102 00103 /// CloseWindow() closes the window from the skin by name. 00104 /// 00105 /// \param wndName - name of window to close 00106 /// \return CATResult - CAT_SUCCESS on success. 00107 /// 00108 /// Returns an error if the window is not open (CAT_ERR_SKIN_WINDOW_NOT_OPEN) 00109 /// Or CAT_ERR_SKIN_WINDOW_NOT_FOUND if the window does not exist. 00110 virtual CATResult CloseWindow(const CATString& wndName); 00111 00112 // Upwards command from control 00113 virtual void OnCommand( CATCommand& command, 00114 CATControl* ctrl, 00115 CATWindow* wnd); 00116 00117 /// CloseAll() closes all the windows. Remember, this can kill the process 00118 /// if a window is set to primary... Of course, typically it's called 00119 /// by the skin's destructor anyway, so that's fine. 00120 virtual void CloseAll(); 00121 00122 /// Load() loads the skin in. 00123 virtual CATResult Load( CATPROGRESSCB progressCB = 0, 00124 void* progressParam= 0, 00125 CATFloat32 progMin = 0.0f, 00126 CATFloat32 progMax = 1.0f); 00127 00128 protected: 00129 /// ParseAttributes() parses the known attributes for an object. 00130 virtual CATResult ParseAttributes(); 00131 00132 /// RectFromAttribs() recalculates the control's rectangle from 00133 /// the attributes. This can only be called after ParseAttributes() has 00134 /// loaded the images. 00135 virtual CATResult RectFromAttribs(); 00136 00137 // MarkDirty() has no meaning for skins currently. Maybe make it force everything 00138 // to redraw for after a skin change? 00139 virtual void MarkDirty(CATRect* dirtyRect = 0, bool force = false) {} 00140 // Hit Testing skins is pretty useless at the moment as well... maybe 00141 // later allow full screen coords and all windows? hmmm... 00142 virtual CATControl* HitTest(const CATPOINT& pt) { return 0;} 00143 00144 00145 clock_t fUpdateTime; 00146 00147 CATString fSkinRoot; 00148 CATString fSkinPath; 00149 CATString fAuthor; 00150 CATString fURL; 00151 CATString fCopyright; 00152 CATUInt32 fTemplateCtr; 00153 }; 00154 00155 #endif // _GGSkin_H_ 00156 00157