From: Thomas H. <pol...@us...> - 2006-03-28 12:39:36
|
Update of /cvsroot/smartwin/SmartWin/tests/TicTacToe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24408/tests/TicTacToe Modified Files: .cvsignore MainWindow.cpp MainWindow.h Log Message: Fixed support in WSDL parser of "nil" in addition to creating recursive lookup for namespace in XML parser plus fixed bug in namespaces serialization ++++++...... Index: .cvsignore =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/TicTacToe/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- .cvsignore 30 Aug 2005 12:29:51 -0000 1.2 +++ .cvsignore 28 Mar 2006 12:39:30 -0000 1.3 @@ -4,4 +4,6 @@ TicTacToe_private.rc ReleaseUnicode DebugUnicode -Release \ No newline at end of file +Release +TicTacToe.exe +TicTacToe.vcproj.BARBAR.Thomas\ Hansen.user \ No newline at end of file Index: MainWindow.cpp =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/TicTacToe/MainWindow.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- MainWindow.cpp 20 Mar 2006 13:57:00 -0000 1.6 +++ MainWindow.cpp 28 Mar 2006 12:39:30 -0000 1.7 @@ -167,6 +167,39 @@ color = RGB( rand()%255, rand()%255, rand()%255 ); } +void MainWindow::onClickedForFileChange( const SmartWin::MouseEventResult & mouse ) +{ + if (itsHandleFileChange == INVALID_HANDLE_VALUE) + { + createMessageBox().show(_T("Waiting now...")); + + itsHandleFileChange = ::FindFirstChangeNotification( + SmartWin::Application::instance().getModulePath().c_str(), + FALSE, //bSubTree + FILE_NOTIFY_CHANGE_FILE_NAME); + + // specify the event handler + itsSignalConnection = + itsPtrSignalFileChange->connect(boost::bind(&MainWindow::onFileChanged, this)); + // register the wait event in the application + SmartWin::Application::instance().addWaitEvent(itsHandleFileChange, itsPtrSignalFileChange); + } +} + +void MainWindow::onFileChanged() +{ + SmartWin::Application::instance().removeWaitEvent(itsHandleFileChange); + + ::FindCloseChangeNotification(itsHandleFileChange); + + itsSignalConnection.disconnect(); + //itsPtrSignalFileChange->disconnect(0); + + createMessageBox().show(_T("A file has changed!")); + + itsHandleFileChange = INVALID_HANDLE_VALUE; +} + void MainWindow::activate( bool active ) { isActive = active; @@ -174,7 +207,9 @@ } MainWindow::MainWindow() - : isActive(true) + : isActive(true), + itsHandleFileChange(INVALID_HANDLE_VALUE), + itsPtrSignalFileChange(new Signal) { SmartWin::CreationalStruct cs; cs.style = WS_VISIBLE | WS_OVERLAPPEDWINDOW; @@ -189,9 +224,9 @@ setText( _T("Tic Tac SmartWin") ); onPainting( &MainWindow::painting ); onLeftMouseUp( &MainWindow::clicked ); - onRightMouseUp( &MainWindow::clicked2 ); + //onRightMouseUp( &MainWindow::clicked2 ); onLeftMouseDown( &MainWindow::clicked3 ); - onRightMouseDown( &MainWindow::clicked3 ); + onRightMouseDown( &MainWindow::onClickedForFileChange ); setIconSmall( IDI_ICON1 ); setIconLarge( IDI_ICON1 ); setCursor( IDC_CURSOR1 ); @@ -211,4 +246,8 @@ MainWindow::~MainWindow() { + if (itsHandleFileChange != INVALID_HANDLE_VALUE) + { + ::FindCloseChangeNotification(itsHandleFileChange); + } } Index: MainWindow.h =================================================================== RCS file: /cvsroot/smartwin/SmartWin/tests/TicTacToe/MainWindow.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- MainWindow.h 20 Mar 2006 13:57:00 -0000 1.7 +++ MainWindow.h 28 Mar 2006 12:39:30 -0000 1.8 @@ -6,6 +6,9 @@ : public sw::WidgetFactory<sw::WidgetWindow, MainWindow>, public sw::HeartBeat { + typedef boost::signal< void () > Signal; + typedef boost::shared_ptr< Signal > SignalPtr; + bool isActive; private: COLORREF color; @@ -20,8 +23,15 @@ void clicked( const SmartWin::MouseEventResult & mouse ); void clicked2( const SmartWin::MouseEventResult & mouse ); void clicked3( const SmartWin::MouseEventResult & mouse ); + void onClickedForFileChange( const SmartWin::MouseEventResult & mouse ); void activate( bool isActive ); + // in order to test the synchronization objects + HANDLE itsHandleFileChange; + SignalPtr itsPtrSignalFileChange; + boost::signals::connection itsSignalConnection; + void onFileChanged(); + public: void init(); virtual void tick() |