Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

arsview.cpp

Go to the documentation of this file.
00001 #include "SdlArs.h"
00002 
00003 namespace Ars
00004 {
00005 View *View::m_pInstance = 0;
00006 
00007 View::View( const XRect Rect , std::string sTitle , const bool bResizable ) 
00008 : m_bResizable(bResizable)
00009 {
00010         SetWindowRect( Rect );
00011 
00012         m_pInstance = this;
00013         Uint32 iFlags = SDL_HWSURFACE | SDL_ANYFORMAT;
00014         if(m_bResizable)
00015                 iFlags |= SDL_RESIZABLE;
00016 //      else            iFlags |= SDL_FULLSCREEN;
00017         m_pSurface = SDL_SetVideoMode( Width(),  Height(), 32, iFlags);
00018         if (m_pSurface == NULL)
00019                 tron << "Could not set video mode : " <<  SDL_GetError() << "\n";
00020         SetWndText( sTitle );
00021 
00022         Cfg::Handler    &h = Cfg::GetCfg();
00023         Ars::ArsApplication::scrW = h.GetCfgInt( "SetupScreen" , "ScreenW" );
00024         Ars::ArsApplication::scrH = h.GetCfgInt( "SetupScreen" , "ScreenH" );
00025 }
00026 
00027 View::~View(void)
00028 {
00029         SDL_FreeSurface( m_pSurface );
00030         m_pSurface = 0;
00031 }
00032 
00033 const bool View::SetupWindow( const Message &msg )
00034 {
00035         Window::SetupWindow( msg );
00036 
00037         MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_RESIZE);
00038         
00039         // Send a message to the queue so that the view gets painted as soon as the app starts up
00040         UpdateWindow();
00041 
00042         return true;
00043 }
00044 
00045 void View::SetWndText( const std::string& sText )
00046 {
00047         Window::SetWndText( sText );
00048         SDL_WM_SetCaption( GetWindowText().c_str() , "" );
00049 }
00050 
00051 const bool View::wmResize( const ResizeMessage &Message )
00052 {
00053         if( Message.source == 0 )
00054         {
00055                 Uint32 iFlags = SDL_HWSURFACE | SDL_ANYFORMAT;
00056                 if(m_bResizable)
00057                         iFlags |= SDL_RESIZABLE;
00058                 
00059                 SetBottom( y + Message.size.y);
00060                 SetRight( x + Message.size.x);
00061                 clientRect = XRect(0, 0, Width(), Height());
00062                 m_pSurface = SDL_SetVideoMode( Width(), Height(), 32, iFlags);
00063                 SetDirty();
00064                 UpdateWindow( true );
00065                 return true;
00066         }
00067 
00068         return false;
00069 }
00070 
00071 const bool View::MainLoop( void )
00072 {
00073         return ArsApplication::GetInstance()->MainLoop();
00074 }
00075 
00076 }

Generated on Fri Dec 5 04:05:59 2003 for Borqueror by doxygen 1.3.3