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

Ars::View Class Reference

A general view class. More...

#include <arsview.h>

Inheritance diagram for Ars::View:

Inheritance graph
[legend]
Collaboration diagram for Ars::View:

Collaboration graph
[legend]

Public Member Functions

 View (const XRect Rect, std::string sTitle, const bool bResizable=true)
virtual ~View (void)
 Standard Destructor.

virtual const bool SetupWindow (const Message &msg)
 Deregister the setup_window message.

bool IsResizable (void)
 true if the view is resizable

virtual void SetWndText (const std::string &sText)
virtual const bool wmResize (const ResizeMessage &Message)
 Resizes the window.

virtual void IdleProcess (void)

Static Public Member Functions

ViewGetMainFrame (void)
 a pointer to the current and unique View.


Protected Member Functions

virtual const bool MainLoop (void)

Protected Attributes

bool m_bResizable
 Indicates if the view is resizable.


Private Member Functions

void operator= (View)
 The assignment operator is not allowed for CWindow derived objects.


Static Private Attributes

Viewm_pInstance = 0
 A pointer to the one allowed view, this is due to the SDL limitation of having only one window.


Friends

class ArsApplication

Detailed Description

A general view class.

A View creates itself as a root window (it has no parent) and responds to APP_PAINT messages with itself or 0 as the destination, and will redraw all of it's children as well as itself Because of a limitation in SDL, there can be only one View

Definition at line 11 of file arsview.h.


Constructor & Destructor Documentation

Ars::View::View const XRect  Rect,
std::string  sTitle,
const bool  bResizable = true
 

Parameters:
Rect A CRect that defines the outer limits of the control
sTitle The window title, which will appear in the title bar of the view
bResizable If true, the window will be resizable

Definition at line 7 of file arsview.cpp.

References Cfg::GetCfg(), Cfg::Handler::GetCfgInt(), Ars::XRect::Height(), m_bResizable, m_pInstance, Ars::HPaint::m_pSurface, Ars::ArsApplication::scrH, Ars::ArsApplication::scrW, Ars::Window::SetWindowRect(), SetWndText(), tron, and Ars::XRect::Width().

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 }

Ars::View::~View void   )  [virtual]
 

Standard Destructor.

Definition at line 27 of file arsview.cpp.

References Ars::HPaint::m_pSurface.

00028 {
00029         SDL_FreeSurface( m_pSurface );
00030         m_pSurface = 0;
00031 }


Member Function Documentation

View* Ars::View::GetMainFrame void   )  [inline, static]
 

a pointer to the current and unique View.

Definition at line 29 of file arsview.h.

References m_pInstance.

00029 {       return m_pInstance;     }

virtual void Ars::View::IdleProcess void   )  [inline, virtual]
 

Definition at line 42 of file arsview.h.

Referenced by Ars::ArsApplication::MainLoop().

00042 {};

bool Ars::View::IsResizable void   )  [inline]
 

true if the view is resizable

Definition at line 32 of file arsview.h.

References m_bResizable.

00032 { return m_bResizable; }

const bool Ars::View::MainLoop void   )  [protected, virtual]
 

Definition at line 71 of file arsview.cpp.

Referenced by Ars::ArsApplication::Exec().

00072 {
00073         return ArsApplication::GetInstance()->MainLoop();
00074 }

void Ars::View::operator= View   )  [inline, private]
 

The assignment operator is not allowed for CWindow derived objects.

Definition at line 15 of file arsview.h.

const bool Ars::View::SetupWindow const Message msg  )  [virtual]
 

Deregister the setup_window message.

Reimplemented from Ars::Window.

Definition at line 33 of file arsview.cpp.

References Ars::Window::UpdateWindow().

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 }

void Ars::View::SetWndText const std::string &  sText  )  [virtual]
 

Set the WindowText of the view, which is used as the window caption

Parameters:
sText The text to assign to the view

Reimplemented from Ars::Window.

Definition at line 45 of file arsview.cpp.

References Ars::Window::GetWindowText().

Referenced by View().

00046 {
00047         Window::SetWndText( sText );
00048         SDL_WM_SetCaption( GetWindowText().c_str() , "" );
00049 }

const bool Ars::View::wmResize const ResizeMessage Message  )  [virtual]
 

Resizes the window.

Reimplemented from Ars::MessageClient.

Definition at line 51 of file arsview.cpp.

References Ars::Window::clientRect, Ars::XRect::Height(), m_bResizable, Ars::HPaint::m_pSurface, Ars::XRect::SetBottom(), Ars::Thing::SetDirty(), Ars::XRect::SetRight(), Ars::ResizeMessage::size, Ars::CtrlMessage::source, Ars::Window::UpdateWindow(), Ars::XRect::Width(), Ars::XPoint::x, Ars::XRect::XRect(), and Ars::XPoint::y.

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 }


Friends And Related Function Documentation

friend class ArsApplication [friend]
 

Definition at line 46 of file arsview.h.


Field Documentation

bool Ars::View::m_bResizable [protected]
 

Indicates if the view is resizable.

Definition at line 50 of file arsview.h.

Referenced by IsResizable(), View(), and wmResize().

View * Ars::View::m_pInstance = 0 [static, private]
 

A pointer to the one allowed view, this is due to the SDL limitation of having only one window.

Definition at line 5 of file arsview.cpp.

Referenced by GetMainFrame(), and View().


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:06:51 2003 for Borqueror by doxygen 1.3.3