fs/rap/fsWinApp.h

Go to the documentation of this file.
00001 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
00002 /*                          _______      ______    ______          __      */
00003 /*  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~    / ____(_)___ / ___ /)  / ____/___  ____/ /__    */
00004 /*     [fsWinApp]         / /_  / / __ \\__ \|/  / /   / __ \/ __  / _ \   */
00005 /*       rev. 4          / __/ / / /_/ /__/ /   / /___/ /_/ / /_/ /  __/   */
00006 /*    9th Feb 2007      /_/   /_/ ,___/____/    \____/\____/\__,_/\___/    */
00007 /*     [ ] stable              /_/ (c) 2006-7 Filip STOKLAS (FipS)         */
00008 /*  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~       http://HOLE.4FipS.com/fips_code.php          */
00009 /*                                                                         */
00010 /* This code is free for personal and commercial use. You may redistribute */
00011 /* it by any means. If you use the code for your own projects please give  */
00012 /* me credit. Please send a bug report. Don't alter or remove this header! */
00013 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
00014 #ifndef FS_RAP_FSWINAPP_H
00015 #define FS_RAP_FSWINAPP_H
00016 //---------------------------------------------------------------------------
00017 #if defined(FS_INCLUDE_USERDEFS) // inject user definition file on request
00018 #   include <fs/fsUserDefs.h>
00019 #endif 
00020 //---------------------------------------------------------------------------
00021 namespace fs { namespace rap {
00022 //---------------------------------------------------------------------------
00024 
00059 class WinApp_t
00060 {
00061  public:
00062  
00064     struct InitEv_t {};
00066     struct QuitEv_t {};
00068     struct RunEv_t {};
00070     struct DrawEv_t {};
00071     struct SizeEv_t;
00072     struct KeyEv_t;
00073     struct MouseEv_t;
00074     struct EvRcvr_i;
00075     
00077     bool IsValid() const;
00078         
00080     const char * GetCmdLine() const;
00082     void SetTitle(const char *pszTitle);
00083     
00085     void Redraw();
00087     void Fscrn(bool bOn);
00089     void Quit();
00090     
00092     void RegEvRcvr(EvRcvr_i *pEvRcvr);
00093     
00095     void * GetWinHdle() const;
00096             
00098     struct EvRcvr_i
00099     {
00100         virtual ~EvRcvr_i() {}
00101         virtual void OnEvent(const InitEv_t &, WinApp_t &) {}
00102         virtual void OnEvent(const QuitEv_t &, WinApp_t &) {}
00103         virtual void OnEvent(const RunEv_t &, WinApp_t &) {}
00104         virtual void OnEvent(const DrawEv_t &, WinApp_t &) {}
00105         virtual void OnEvent(const SizeEv_t &, WinApp_t &) {}
00106         virtual void OnEvent(const KeyEv_t &, WinApp_t &) {}
00107         virtual void OnEvent(const MouseEv_t &, WinApp_t &) {}
00108     };
00109  
00111     struct InitCfg_t
00112     {
00113         const char *m_pszTitle; 
00114         int m_nClW; 
00115         int m_nClH; 
00116         bool m_bSzbl; 
00117         bool m_bClrBgr; 
00118         bool m_bRtm; 
00119         bool m_bFscrn; 
00120         int m_nFscrnW; 
00121         int m_nFscrnH; 
00122                 
00123         InitCfg_t():
00124         m_pszTitle("FipS' Rapid Window Application"),
00125         m_nClW(640),
00126         m_nClH(480),
00127         m_bSzbl(true),
00128         m_bClrBgr(true),
00129         m_bRtm(false),
00130         m_bFscrn(false),
00131         m_nFscrnW(-1),
00132         m_nFscrnH(-1)
00133         {}
00134     };
00135 
00137     struct SizeEv_t
00138     {
00139         int m_nClW, m_nClH;
00140 
00141         SizeEv_t(int nClW, int nClH):
00142         m_nClW(nClW), m_nClH(nClH) {}
00143 
00144      private:
00145      
00146         SizeEv_t();
00147     };
00148  
00150     struct KeyEv_t
00151     {
00153         enum Key_e
00154         {
00155             KEY_LMBTN = -1, 
00156             KEY_RMBTN = -2, 
00157             KEY_MMBTN = -3, 
00158         };
00159     
00160         int m_nKeyCode;
00161         bool m_bDown;
00162         int m_nCurX, m_nCurY;
00163     
00164         KeyEv_t(int nKeyCode, bool bDown, int nCurX, int nCurY):
00165         m_nKeyCode(nKeyCode),
00166         m_bDown(bDown),
00167         m_nCurX(nCurX), m_nCurY(nCurY)
00168         {}
00169         
00170      private:
00171      
00172         KeyEv_t();
00173     };
00174     
00176     struct MouseEv_t
00177     {
00178         int m_nCurX, m_nCurY;
00179 
00180         MouseEv_t(int nCurX, int nCurY):
00181         m_nCurX(nCurX), m_nCurY(nCurY) {}
00182 
00183      private:
00184      
00185         MouseEv_t();
00186     };
00187     
00188  private:
00189  
00190     friend WinApp_t & WinAppInst();
00191  
00192     WinApp_t() {}
00193     WinApp_t(const WinApp_t &); 
00194     WinApp_t & operator = (const WinApp_t &); 
00195 };
00196 //---------------------------------------------------------------------------
00197 extern bool WinAppInit(WinApp_t &App, WinApp_t::InitCfg_t &Cfg);
00198 //---------------------------------------------------------------------------
00199 }} // namespace fs::rap
00200 //---------------------------------------------------------------------------
00201 #endif // FS_RAP_FSWINAPP_H

FipS' Code (Thu Feb 15 22:43:35 2007) - (c) Filip STOKLAS (FipS) - [ www ] [ Guest Book ]