From: Thomas H. <pol...@us...> - 2005-08-31 11:22:15
|
Update of /cvsroot/smartwin/SmartWin/tests/WidgetRadioButtonGroup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8946/tests/WidgetRadioButtonGroup Modified Files: Main.cpp Log Message: WidgetRadioButton is finished implementing all Aspects... Index: Main.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/WidgetRadioButtonGroup/Main.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Main.cpp 31 Aug 2005 07:34:56 -0000 1.6 +++ Main.cpp 31 Aug 2005 11:22:07 -0000 1.7 @@ -32,6 +32,29 @@ void radioClicked( WidgetRadioButton * btn ) { + // Since one of those buttons are ownerdrawned we need to do this... + // BS_OWNERDRAW RadioButtons doesn't maintain state at all + if( btn == radio21 ) + { + checked21 = true; + radio22->setChecked( false ); + radio23->setChecked( false ); + radio21->updateWidget(); + } + else if( btn == radio22 ) + { + checked21 = false; + radio22->setChecked( true ); + radio23->setChecked( false ); + radio21->updateWidget(); + } + else if( btn == radio23 ) + { + checked21 = false; + radio22->setChecked( false ); + radio23->setChecked( true ); + radio21->updateWidget(); + } if( btn->getText() == _T("Radio 1 - 1") ) group->setEnabled( false ); else @@ -39,6 +62,11 @@ txt->setText( btn->getText() ); } + void radioDblClicked( WidgetRadioButton * btn ) + { + txt->setText( btn->getText()+_T(" double clicked") ); + } + void isResized( const SmartWin::WindowSizedEventResult & sz ) { layout( sz.newSize ); @@ -131,8 +159,28 @@ this->setText( _T("NOT Enabled") ); } + bool checked21; + + void painting( WidgetRadioButton * btn, Canvas & canvas ) + { + FontPtr font = btn->getFont(); + canvas.selectFont( font ); + canvas.setBkMode( true ); + tstring txt = btn->getText(); + if( checked21 ) + { + canvas.setTextColor( RGB( 255, 0, 0 ) ); + } + else + { + canvas.setTextColor( RGB( 128, 128, 128 ) ); + } + canvas.drawText( txt, btn->getSize(), 0 ); + } + void initAndCreate() { + checked21 = false; createWindow(); setText( _T("WidgetRadioButtonGroup compile and execute test") ); onEraseBackground( &RadioButGroupLayout::eraseBackground ); @@ -160,9 +208,12 @@ font = createFont( _T("Book Antiqua"), 25, 12 ); radio1->setFont( font ); - radio2 = createRadioButton( group ); + cs = getDefaultRadioButtonCreationalStruct(); + cs.style |= BS_NOTIFY; // In order to get the dblClicked Event!! + radio2 = createRadioButton( group, cs ); radio2->setText( _T("Radio 2 - 1") ); radio2->onClicked( &RadioButGroupLayout::radioClicked ); + radio2->onDblClicked( &RadioButGroupLayout::radioDblClicked ); font = createFont( _T("Blackadder ITC"), 25, 12 ); radio2->setFont( font ); @@ -170,6 +221,7 @@ radio3 = createRadioButton( group ); radio3->setText( _T("Radio 3 - 1") ); radio3->onClicked( &RadioButGroupLayout::radioClicked ); + radio3->setEnabled( false ); font = createFont( _T("Calisto MT"), 25, 12 ); radio3->setFont( font ); @@ -179,11 +231,14 @@ font = createFont( _T("Times New Roman"), 25, 15 ); group2->setFont( font ); - radio21 = createRadioButton( group2 ); + cs = getDefaultRadioButtonCreationalStruct(); + cs.style |= BS_OWNERDRAW; // In order to get the painting Event!! + radio21 = createRadioButton( group2, cs ); radio21->setText( _T("Radio 1 - 2") ); radio21->onClicked( &RadioButGroupLayout::radioClicked ); font = createFont( _T("Comic Sans MS"), 25, 12 ); radio21->setFont( font ); + radio21->onPainting( painting ); radio22 = createRadioButton( group2 ); radio22->setText( _T("Radio 2 - 2") ); |