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

starinfodlg.cpp

Go to the documentation of this file.
00001 #include "../borqueror.h"
00002 
00003 void SunImageObject::Draw( void )
00004 {
00005         XBox::Draw();
00006 
00007         XRect   r( 0 , 0 , -1 , -1 );
00008         SDL_Surface     *suns = Graf::Img( id , &r );
00009 
00010         XRect   src( r.h * atSun , 0 , r.h , r.h );
00011         
00012         Graf::SDL_StretchBlt( suns , &src , GetGDI() , this );
00013 }
00014 
00016 StarInfoDlg::StarInfoDlg( const int aid , StarSystem *&aSs , Window *aParent )
00017 : ss( aSs ) , BqBase( eStarInfoDlg , aParent ) , id( aid )
00018 {
00019 }
00020 
00021 StarInfoDlg::~StarInfoDlg( void )
00022 {
00023 }
00024 
00025 const bool StarInfoDlg::SetupWindow( const Message &aMsg )
00026 {
00027         BqBase::SetupWindow( aMsg );
00028 
00029         if( f )
00030         {
00031                 SunImageObject  *img = dynamic_cast<SunImageObject *>( f->GetArsObject( 10 ) );
00032                 img->SetImageId( id );
00033                 img->SetSunIndex( ss->GetStarType() );
00034 
00035                 f->GetArsObject( 20 )->SetWndText( string( " " ) + ss->ssName );
00036                 string str = ss->starName;
00037                 if( !ss->starNameDescr.empty() )
00038                 {
00039                         str += " (";
00040                         str += ss->starNameDescr + ")";
00041                 }
00042                 f->GetArsObject( 21 )->SetWndText( string( " " ) + str );
00043 
00044                 int     thisId =  ss->GetStarType() << 8 | ss->GetStarSize() - 1;
00045                 vector<StarInfo *>::iterator pos = find_if( Parameters::starInfo.begin() , Parameters::starInfo.end() , bind2nd( mem_fun( &StarInfo::IsId ) , &thisId ) );
00046                 if( pos != Parameters::starInfo.end() )
00047                 {
00048                         f->GetArsObject( 22 )->SetWndText( string( " " ) + (*pos)->classInf );
00049 
00050                         f->GetArsObject( 23 )->SetWndText( string( " " ) + Parameters::sizeStr[(*pos)->ssize] );
00051                         f->GetArsObject( 24 )->SetWndText( string( " Approx. " ) + (*pos)->ageInf );
00052                         char    temp[128];
00053                         sprintf( temp , " Approx. %d C" , (*pos)->temperature );
00054                         f->GetArsObject( 25 )->SetWndText( temp );
00055                         f->GetArsObject( 30 )->SetWndText( (*pos)->descrInf + "\n" );
00056                 }
00057                 else
00058                 {
00059                         f->GetArsObject( 22 )->SetWndText( "" );
00060                         f->GetArsObject( 23 )->SetWndText( "" );
00061                         f->GetArsObject( 24 )->SetWndText( "" );
00062                         f->GetArsObject( 25 )->SetWndText( "" );
00063                         f->GetArsObject( 30 )->SetWndText( "" );
00064                 }
00065         }       
00066         return true;
00067 }
00068 
00069 const bool StarInfoDlg::MainLoop( void )
00070 {
00071         SetupDialog( "StarInfoDlg" );
00072 
00073         ans = true;
00074 
00075         BqBase::MainLoop();
00076 
00077         return ans;
00078 }
00079 
00080 const bool StarInfoDlg::evMouseLClick( const CtrlMessage &msg )
00081 {
00082         BqBase::evMouseLClick( msg );
00083 
00084         if( isDisplayed )
00085                 if( ((Window *)msg.source)->GetId() == 1 )
00086                         isDisplayed= false;     
00087                 else if( ((Window *)msg.source)->GetId() == 2 )
00088                 {
00089                         ans = isDisplayed= false;       
00090                 }
00091 
00092         return true;
00093 }

Generated on Fri Dec 5 04:06:00 2003 for Borqueror by doxygen 1.3.3