From: Andrew C. <ac...@us...> - 2004-02-08 01:30:48
|
Update of /cvsroot/planeshift/planeshift/src/common/paws In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22855/src/common/paws Modified Files: pawswidget.cpp pawswidget.h Log Message: Added title bar and quit buttons to petition windows. Index: pawswidget.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/paws/pawswidget.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pawswidget.cpp 7 Feb 2004 20:10:09 -0000 1.24 --- pawswidget.cpp 8 Feb 2004 01:27:47 -0000 1.25 *************** *** 352,389 **** if (titleNode) { ! border->SetTitle( titleNode->GetAttributeValue("text") ); ! csString image = titleNode->GetAttributeValue("resource"); ! psImageDescription* imageDesc = windowManager->GetTextureManager()->GetImageDescription( image ); ! pawsImage *titleImage = new pawsImage( windowManager->GetObjectRegistry() ); ! titleImage->Description( imageDesc ); ! border->SetTitleImage(titleImage); ! ! const char *al = titleNode->GetAttributeValue("align"); ! int align = ALIGN_LEFT; ! if (al) ! { ! if (!strcmp(al,"center")) ! align = ALIGN_CENTER; ! else if (!strcmp(al,"right")) ! align = ALIGN_RIGHT; ! } ! border->SetTitleAlign(align); ! csString close = titleNode->GetAttributeValue( "close_button" ); ! if ( close == "yes" ) ! { ! pawsButton* button = (pawsButton*)WindowManager()->CreateWidget("pawsButton"); ! button->SetParent( this ); ! button->SetBackground( "quit" ); ! csString name( GetName() ); ! name.Append( "_close" ); ! button->SetName( name ); ! button->SetRelativeFrame( defaultFrame.Width() - 20, - 16, 16, 16 ); ! ! int flags = ATTACH_TOP | ATTACH_RIGHT; ! button->SetAttachFlags( flags ); ! AddChild( button ); ! } } --- 352,361 ---- if (titleNode) { ! csString title = titleNode->GetAttributeValue("text"); csString image = titleNode->GetAttributeValue("resource"); ! csString align = titleNode->GetAttributeValue("align"); csString close = titleNode->GetAttributeValue( "close_button" ); ! ! SetTitle( title, image, align, close ); } *************** *** 1837,1839 **** --- 1809,1853 ---- } + bool pawsWidget::SetTitle( const char* text, const char* image, const char* align, const char* close_button ) + { + if( !border ) + { + return false; + } + else + { + border->SetTitle( text ); + psImageDescription* imageDesc = windowManager->GetTextureManager()->GetImageDescription( image ); + pawsImage *titleImage = new pawsImage( windowManager->GetObjectRegistry() ); + titleImage->Description( imageDesc ); + border->SetTitleImage(titleImage); + int alignValue = ALIGN_LEFT; + if (align) + { + if (!strcmp(align,"center")) + alignValue = ALIGN_CENTER; + else if (!strcmp(align,"right")) + alignValue = ALIGN_RIGHT; + } + border->SetTitleAlign(alignValue); + + + if ( close_button && (strcmp(close_button,"yes") == 0) ) + { + pawsButton* button = (pawsButton*)WindowManager()->CreateWidget("pawsButton"); + button->SetParent( this ); + button->SetBackground( "quit" ); + csString name( GetName() ); + name.Append( "_close" ); + button->SetName( name ); + button->SetRelativeFrame( defaultFrame.Width() - 20, - 16, 16, 16 ); + + int flags = ATTACH_TOP | ATTACH_RIGHT; + button->SetAttachFlags( flags ); + AddChild( button ); + } + } + + return true; + } Index: pawswidget.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/paws/pawswidget.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pawswidget.h 7 Feb 2004 00:32:16 -0000 1.14 --- pawswidget.h 8 Feb 2004 01:27:47 -0000 1.15 *************** *** 507,510 **** --- 507,521 ---- protected: + /** Sets up the title bar for the widget. + * + * @param text The name that should go in the title. + * @param image The name of the backround image for the title + * @param align The alignment of the text + * @param close_button "yes" means to add a close button to the title bar. + * + * @return true if all was successful. + */ + bool SetTitle( const char* text, const char* image, const char* align, const char* close_button ); + /** This will check to see if the mouse is over the resize hot spot. */ |