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

Ars::Form Class Reference

#include <arsform.h>


Public Member Functions

 Form (const int aId=-1)
 ~Form (void)
const bool HasId (const int *aId) const
WindowFindWindowParent (const XRect &r)
WindowGetArsObject (const int obId)
void Draw (void)
void InitDialog (Window *This)
void ShutdownDialog (Window *This)
void DoDialog (const int aWait=10)

Protected Member Functions

void HandleTillRoot (Message &msg)
void ProcessMessage (void)

Protected Attributes

int id

Friends

class MessageServer


Constructor & Destructor Documentation

Ars::Form::Form const int  aId = -1  )  [inline]
 

Definition at line 16 of file arsform.h.

References id.

00016 : id( aId )     {}

Ars::Form::~Form void   ) 
 

Definition at line 6 of file arsform.cpp.

00007 {
00008         for( vector<Window *>::iterator it = begin() ; it != end() ; ++it )
00009         {
00010                 if( (*it)->GetParent() == 0 )
00011                         delete *it;
00012         }
00013         clear();
00014 }


Member Function Documentation

void Ars::Form::DoDialog const int  aWait = 10  ) 
 

Definition at line 88 of file arsform.cpp.

References ProcessMessage().

00089 {
00090         SDL_Event event;
00091         if( ArsApplication::GetInstance()->IsRunning() )
00092         {
00093                 while( SDL_PollEvent( &event ) )
00094                         ArsApplication::GetInstance()->HandleSDLEvent( event );
00095 
00096                 while( !MessageServer::Instance().empty() )
00097                         ProcessMessage();
00098 
00099                 if( aWait )
00100                         SDL_Delay( aWait );
00101         }
00102 }

void Ars::Form::Draw void   ) 
 

Definition at line 42 of file arsform.cpp.

References ArsSendMessage, and F_HIDETREE.

00043 {
00044         for( vector<Window *>::iterator it = begin() ; it != end() ; ++it )
00045                 (*it)->ResetFlags( F_HIDETREE );
00046         
00047         if( !empty() )
00048                 ArsSendMessage( Message( Message::APP_PAINT  , *begin() ) );
00049 }

Window * Ars::Form::FindWindowParent const XRect r  ) 
 

Definition at line 16 of file arsform.cpp.

References Ars::XRect::Bottom(), Ars::Thing::GetWindowRect(), and Ars::XRect::Right().

Referenced by InitDialog().

00017 {
00018         Window  *ans = 0;
00019 
00020         for( vector<Window *>::iterator it = begin() ; it != end() ; ++it )
00021         {
00022                 if( (*it)->x == r.x && (*it)->y == r.y && (*it)->Bottom() == r.Bottom() && (*it)->Right() == r.Right() )
00023                         continue;
00024                 if( r.x >= (*it)->x && r.Right() <= (*it)->Right() && r.y >= (*it)->y && r.Bottom() <= (*it)->Bottom() )
00025                         if( ans == 0 ||
00026                                 ((*it)->x >= ans->GetWindowRect().x && (*it)->Right() <= ans->GetWindowRect().Right() && (*it)->y >= ans->GetWindowRect().y && (*it)->Bottom() <= ans->GetWindowRect().Bottom()) )
00027                                 ans = (*it);
00028         }
00029 
00030         return ans;
00031 }

Window * Ars::Form::GetArsObject const int  obId  ) 
 

Definition at line 33 of file arsform.cpp.

00034 {
00035         for( vector<Window *>::iterator it = begin() ; it != end() ; ++it )
00036                 if( (*it)->GetId() == obId )
00037                         return (*it);
00038 
00039         return 0;
00040 }

void Ars::Form::HandleTillRoot Message msg  )  [protected]
 

Definition at line 157 of file arsform.cpp.

References Ars::Message::Destination(), Ars::Window::GetParent(), Ars::MessageClient::HandleMessage(), Ars::Message::MessageType(), and Ars::Message::SetTarget().

Referenced by ProcessMessage().

00158 {
00159         bool stopLoop = false;
00160 
00161         while( !stopLoop )
00162         {
00163                 if( MessageServer::Instance().IsRegistered( msg.MessageType() , msg.Destination() ) && (*begin())->IsChild( dynamic_cast<Window *>( msg.Destination() ) ) )
00164                         stopLoop = msg.Destination()->HandleMessage( msg );
00165 
00166                 if( !stopLoop )
00167                 {
00168                         Window *wnd = dynamic_cast<Window *>( msg.Destination() );
00169 
00170                         if( wnd && wnd->GetParent() )
00171                                 msg.SetTarget( wnd->GetParent() );
00172                         else
00173                                 stopLoop = true;
00174                 }
00175         }
00176 }

const bool Ars::Form::HasId const int *  aId  )  const [inline]
 

Definition at line 20 of file arsform.h.

References id.

00020 {       return id == *aId;      };

void Ars::Form::InitDialog Window This  ) 
 

Definition at line 51 of file arsform.cpp.

References ArsSendMessage, F_HIDETREE, FindWindowParent(), and Ars::Window::SetParent().

00052 {
00053         while( !MessageServer::Instance().empty() )
00054                 MessageServer::Instance().ProcessMessage();
00055 
00056         for( vector<Window *>::iterator it = begin() ; it != end() ; ++it )
00057         {
00058                 ArsSendMessage( Message( Message::SETUP_WINDOW , (*it) ) );
00059                 (*it)->SetFlags( F_HIDETREE );
00060                 if( (*it)->GetParent() == 0 )
00061                 {
00062                         Window  *w = FindWindowParent( (*it)->GetWindowRect() );
00063                         if( w == 0 || w == (*it) )
00064                                 (*it)->SetParent( This );
00065                         else
00066                                 (*it)->SetParent( w );
00067                 }
00068         }
00069 
00070         while( !MessageServer::Instance().empty() )
00071                 MessageServer::Instance().ProcessMessage();
00072 }

void Ars::Form::ProcessMessage void   )  [protected]
 

Broadcast to all if no specific targets....

Definition at line 104 of file arsform.cpp.

References Ars::Message::Destination(), HandleTillRoot(), Ars::Window::IsChild(), and Ars::Message::MessageType().

Referenced by DoDialog().

00105 {
00106         if( !MessageServer::Instance().empty() )
00107         {
00108                 Message *msg2 = MessageServer::Instance().front();
00109                 Message &msg = *msg2;
00110                 MessageServer::Instance().pop_front();
00111                 std::map<Message::EMessageType,std::vector< std::pair<MessageClient *, bool> > >::iterator at = MessageServer::Instance().messageClients.find( msg.MessageType() );
00113                 if( at != MessageServer::Instance().messageClients.end() )
00114                 {
00115                         if( msg.Destination() == 0 )
00116                         {
00117                                 bool ans = false;
00118                                 std::vector< std::pair<MessageClient *, bool> > tmp = at->second;
00119                                 for( std::vector< std::pair<MessageClient *, bool> >::iterator it = tmp.begin() ; it != tmp.end() ; ++it )
00120                                 {
00121                                         if( it->second )
00122                                         {
00123                                                 Window  *wnd = *begin();
00124                                                 Window  *tgt = 0;
00125                                                 XToolTip        *tt = 0;
00126                                                 try{    
00127                                                         tgt = dynamic_cast<Window *>( it->first );
00128                                                         tt = dynamic_cast<XToolTip *>( it->first );
00129                                                 }catch( ... ) 
00130                                                 { 
00131                                                         tgt = 0;        tt = 0; 
00132                                                         MessageServer::Instance().DeregisterMessageClient( it->first );
00133                                                 }
00134                                                 if( wnd->IsChild( tgt ) || tt != 0 )
00135                                                         if( it->first->HandleMessage( msg ) )
00136                                                                 ans = true;
00137                                         }
00138                                 }
00139                         }
00140                         else 
00141                                 HandleTillRoot( msg );
00142                 }
00143                 delete msg2;
00144         }
00145 
00146         for( std::map<Message::EMessageType,std::vector< std::pair<MessageClient *, bool> > >::iterator at = MessageServer::Instance().messageClients.begin() ; at != MessageServer::Instance().messageClients.end() ; ++at )
00147                 for( std::vector< std::pair<MessageClient *, bool> >::iterator it = at->second.begin() ; it != at->second.end() ; )
00148                         if( !it->second )
00149                         {
00150                                 at->second.erase( it );
00151                                 it = at->second.begin();
00152                         }
00153                         else
00154                                 ++it;
00155 }

void Ars::Form::ShutdownDialog Window This  ) 
 

Definition at line 74 of file arsform.cpp.

References ArsSendMessage, and Ars::Thing::SetDirty().

00075 {
00076         while( !MessageServer::Instance().empty() )
00077                 MessageServer::Instance().ProcessMessage();
00078 
00079         (*begin())->SetParent( 0 );
00080 
00081         while( !MessageServer::Instance().empty() )
00082                 MessageServer::Instance().ProcessMessage();
00083         
00084         This->SetDirty();
00085         ArsSendMessage( Message( Message::APP_PAINT  , This ) );
00086 }


Friends And Related Function Documentation

friend class MessageServer [friend]
 

Definition at line 32 of file arsform.h.


Field Documentation

int Ars::Form::id [protected]
 

Definition at line 12 of file arsform.h.

Referenced by Form(), and HasId().


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