home *** CD-ROM | disk | FTP | other *** search
/ PC Direkt 1995 March / PCD_395.iso / starview / pm2csci / german / task.cx_ / TASK.CXX
Encoding:
C/C++ Source or Header  |  1994-01-18  |  2.4 KB  |  106 lines

  1. /*******************************************************************
  2. *  TASK.CXX
  3. *  (c) 1992-1994 STAR DIVISION
  4. *******************************************************************/
  5.  
  6. #include <sv.hxx>
  7.  
  8. // --- class MyApp -------------------------------------------------
  9.  
  10. class MyApp : public Application
  11. {
  12. public:
  13.     virtual void Main( int, char*[] );
  14. };
  15.  
  16. // --- class TaskWindow --------------------------------------------
  17.  
  18. class TaskWindow : public WorkWindow
  19. {
  20. private:
  21.     PushButton  aStartButton;
  22.     PushButton  aStopButton;
  23.     BOOL        bEnd;
  24.  
  25. public:
  26.                 TaskWindow();
  27.  
  28.    void         Start( Button* );
  29.    void         Stop( Button* );
  30.  
  31.    void         DrawNumber();
  32. };
  33.  
  34. // --- TaskWindow::TaskWindow() ------------------------------------
  35.  
  36. TaskWindow::TaskWindow() :
  37.                 WorkWindow( NULL, WB_APP | WB_STDWORK ),
  38.                 aStartButton( this ),
  39.                 aStopButton( this )
  40. {
  41.     aStartButton.ChangePosPixel( Point( 10, 15 ) );
  42.     aStartButton.ChangeSizePixel( Size( 40, 20 ) );
  43.     aStartButton.SetText( "Start" );
  44.     aStartButton.ChangeClickHdl( LINK( this, TaskWindow, Start ) );
  45.     aStartButton.Show();
  46.  
  47.     aStopButton.ChangePosPixel( Point( 60, 15 ) );
  48.     aStopButton.ChangeSizePixel( Size( 40, 20 ) );
  49.     aStopButton.SetText( "Stop" );
  50.     aStopButton.Disable();
  51.     aStopButton.ChangeClickHdl( LINK( this, TaskWindow, Stop ) );
  52.     aStopButton.Show();
  53.  
  54.     SetText( "Reschedule-Demo" );
  55.     Show();
  56. }
  57.  
  58. // --- TaskWindow::Start() -----------------------------------------
  59.  
  60. void TaskWindow::Start( Button* )
  61. {
  62.     DrawNumber();
  63. }
  64.  
  65. // --- TaskWindow::Stop() ------------------------------------------
  66.  
  67. void TaskWindow::Stop( Button* )
  68. {
  69.     bEnd = TRUE;
  70. }
  71.  
  72. // --- TaskWindow::DrawNumber() ------------------------------------
  73.  
  74. void TaskWindow::DrawNumber()
  75. {
  76.     Invalidate();
  77.     Update();
  78.  
  79.     aStartButton.Disable();
  80.     aStopButton.Enable();
  81.     bEnd = FALSE;
  82.  
  83.     USHORT i = 0;
  84.     while ( i <= 9999 && !bEnd )
  85.     {
  86.         DrawText( Point( 45, 60 ), i );
  87.         pApp->Reschedule();
  88.         i++;
  89.     }
  90.  
  91.     aStopButton.Disable();
  92.     aStartButton.Enable();
  93. }
  94.  
  95. // --- MyApp::Main() -----------------------------------------------
  96.  
  97. void MyApp::Main( int, char*[] )
  98. {
  99.     TaskWindow aWindow;
  100.     Execute();
  101. }
  102.  
  103. // --- aMyApp ------------------------------------------------------
  104.  
  105. MyApp aMyApp;
  106.