home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************
- * CONNECT.CXX
- * (c) 1992 STAR DIVISION
- *******************************************************************/
-
- #include <sv.hxx>
-
- #define MAXPOINTS 500
-
- // --- class MyApp -------------------------------------------------
-
- class MyApp : public Application
- {
- public:
- virtual void Main( int, char*[] );
- };
-
- // --- class ConnectWindow -----------------------------------------
-
- class ConnectWindow : public WorkWindow
- {
- private:
- Point aPointArray[MAXPOINTS];
- short nPointCount;
-
- public:
- ConnectWindow();
-
- virtual void MouseButtonDown( const MouseEvent& );
- virtual void MouseMove( const MouseEvent& );
- virtual void MouseButtonUp( const MouseEvent& );
- virtual void Paint( const Rectangle& );
- };
-
- // --- ConnectWindow::ConnectWindow() ------------------------------
-
- ConnectWindow::ConnectWindow() :
- WorkWindow( NULL, WB_APP | WB_STDWORK )
- {
- nPointCount = 0;
- SetText( "Connect" );
- Show();
- }
-
- // --- ConnectWindow::MouseMove() ----------------------------------
-
- void ConnectWindow::MouseMove( const MouseEvent& rMEvt )
- {
- if ( (rMEvt.GetMode() == MOUSE_SIMPLEDRAG) &&
- (nPointCount < MAXPOINTS) )
- {
- aPointArray[nPointCount] = rMEvt.GetPosPixel();
- DrawPoint( aPointArray[nPointCount] );
- nPointCount++;
- }
- }
-
- // --- ConnectWindow::MouseButtonDown() ----------------------------
-
- void ConnectWindow::MouseButtonDown( const MouseEvent& )
- {
- nPointCount = 0;
- Invalidate();
- Update();
- CaptureMouse();
- }
-
- // --- ConnectWindow::MouseButtonUp() ------------------------------
-
- void ConnectWindow::MouseButtonUp( const MouseEvent& )
- {
- ReleaseMouse();
- Invalidate();
- }
-
- // --- ConnectWindow::Paint() --------------------------------------
-
- void ConnectWindow::Paint( const Rectangle& )
- {
- for ( short i = 0; i < (nPointCount-1); i++ )
- for ( short j = 0; j < nPointCount; j++ )
- DrawLine( aPointArray[i], aPointArray[j] );
- }
-
- // --- MyApp:Main() ------------------------------------------------
-
- void MyApp::Main( int, char*[] )
- {
- ConnectWindow aWindow;
- Execute();
- }
-
- // --- aMyApp ------------------------------------------------------
-
- MyApp aMyApp;
-
- #ifdef MAC
- Application* pApp = &aMyApp;
- #endif
-