|
From: andrew7 <bd...@us...> - 2007-06-19 01:14:43
|
Update of /cvsroot/smartwin/SmartWin/tests/TimerTest In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv29225 Modified Files: Main.cpp Log Message: Added a slower timer that can stop the faster scrolling timer. Tests killTimer() Index: Main.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/TimerTest/Main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Main.cpp 5 May 2006 17:21:45 -0000 1.5 +++ Main.cpp 19 Jun 2007 01:14:38 -0000 1.6 @@ -8,16 +8,34 @@ : public WidgetFactory< WidgetWindow, WidgetTest1 > { public: + enum param { delay= 100, // milliseconds between scrolling timer event. + delayMb= 10000 }; // milliseconds before message box event. + WidgetTest1() - {} + { + } - void timerTest( const CommandPtr & cmd ) + void timerRespondOnce( const CommandPtr & cmd ) + { + WidgetMessageBox msgBox1; + if ( WidgetMessageBox::RETBOX_CANCEL == + msgBox1.show( _T( "Keep the scrolling going ?"), _T("One time timer event"), + WidgetMessageBox::BOX_OKCANCEL ) ) { + // User want to cancel the scrolling. + Command com ( _T( "ScrollingTitle" ) ); + killTimer( com ); + } + } + + + void timerRespondMultiple( const CommandPtr & cmd ) { SmartUtil::tstring text = getText(); text = text.substr( 1 ) + text.substr( 0, 1 ); setText( text ); - Command com ( _T( "Testing" ) ); - createTimer( & WidgetTest1::timerTest, 100, com ); + + Command com ( _T( "ScrollingTitle" ) ); + createTimer( & WidgetTest1::timerRespondMultiple, delay, com ); } void initAndCreate() @@ -27,16 +45,22 @@ setText( _T( "WidgetWindow Timer compile and execute test" ) ); - Command com( _T( "Testing" ) ); - createTimer( & WidgetTest1::timerTest, 100, com ); + Command com( _T( "ScrollingTitle" ) ); + createTimer( & WidgetTest1::timerRespondMultiple, delay, com ); } + }; -// Unit test for WidgetSaveFile, tries to instantiate all different forms of WidgetSaveFile and also tries to use all functions + +// Unit test for timers int SmartWinMain( Application & app ) { // Widget (Factory) version WidgetTest1 * testWnd1 = new WidgetTest1; testWnd1->initAndCreate(); + + Command outCom( _T( "OnceTimer" ) ); + testWnd1->createTimer( & WidgetTest1::timerRespondOnce, WidgetTest1::delayMb, outCom ); + return app.run(); } |