_tests/fsWinApp/main.cpp

00001 
00002 //---------------------------------------------------------------------------
00003 #include <fs/rap/fsWinApp.h>
00004 
00005 #include <stdio.h> // sprintf
00006 #include <cassert>
00007 //---------------------------------------------------------------------------
00008 #if (_MSC_VER >= 1400) // MSVC8
00009 #   pragma warning(disable : 4996) // function was marked as deprecated
00010 #endif
00011 //---------------------------------------------------------------------------
00012 using namespace fs::rap;
00013 //---------------------------------------------------------------------------
00014 namespace test {
00015 //---------------------------------------------------------------------------
00016 struct Client_t : public WinApp_t::EvRcvr_i
00017 {
00018     virtual void OnEvent(const WinApp_t::SizeEv_t &, WinApp_t &);
00019     virtual void OnEvent(const WinApp_t::KeyEv_t &, WinApp_t &);
00020     virtual void OnEvent(const WinApp_t::MouseEv_t &, WinApp_t &);
00021 };
00022 //---------------------------------------------------------------------------
00023 void Client_t::OnEvent(const WinApp_t::SizeEv_t &SizeEv, WinApp_t &App)
00024 {
00025     char szBuf[64];
00026     
00027     ::sprintf(szBuf, "Size Event: width = %d, height = %d",
00028      SizeEv.m_nClW, SizeEv.m_nClH);
00029 
00030     App.SetTitle(szBuf);
00031 }
00032 //---------------------------------------------------------------------------
00033 void Client_t::OnEvent(const WinApp_t::KeyEv_t &KeyEv, WinApp_t &App)
00034 {
00035     char szBuf[64];
00036     
00037     ::sprintf(szBuf, "Key Event: key code = %d (%s), mouse (%d, %d)",
00038      KeyEv.m_nKeyCode, KeyEv.m_bDown ? "down" : "up", KeyEv.m_nCurX,
00039      KeyEv.m_nCurY);
00040 
00041     App.SetTitle(szBuf);
00042 }
00043 //---------------------------------------------------------------------------
00044 void Client_t::OnEvent(const WinApp_t::MouseEv_t &MouseEv, WinApp_t &App)
00045 {
00046     char szBuf[64];
00047     
00048     ::sprintf(szBuf, "Mouse Event: x = %d, y = %d",
00049      MouseEv.m_nCurX, MouseEv.m_nCurY);
00050 
00051     App.SetTitle(szBuf);
00052 }
00053 //---------------------------------------------------------------------------
00054 } // namespace test
00055 //---------------------------------------------------------------------------
00056 namespace fs { namespace rap {
00057 //---------------------------------------------------------------------------
00058 bool WinAppInit(WinApp_t &App, WinApp_t::InitCfg_t &Cfg)
00059 {
00060     // modify default configuration
00061     Cfg.m_nClW = 512;
00062     Cfg.m_nClH = 512;
00063         
00064     // register event receivers (clients)
00065     static test::Client_t Client;
00066     App.RegEvRcvr(&Client);
00067 
00068     return true;
00069 }
00070 //---------------------------------------------------------------------------
00071 }} // namespace fs::rap
00072 //---------------------------------------------------------------------------

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