home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / Papers / aSEPiA example source / plugin / Plugin 2 / CPluginDrawing2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-25  |  1.3 KB  |  79 lines  |  [TEXT/CWIE]

  1. /*---------------------------------------------------------------
  2.  
  3.     CPluginDrawing.cpp
  4.     
  5.     Draws stuff in the window.
  6.  
  7. ---------------------------------------------------------------*/
  8.  
  9.  
  10. #include "CPluginDrawing2.h"
  11. #include "UDrawingState.h"
  12. #include <stdio.h>
  13.  
  14. short    CPluginDrawing::sCount = 0;    
  15.  
  16.  
  17. CPluginDrawing::CPluginDrawing()
  18. {
  19.     sCount++;
  20. }
  21.  
  22. void CPluginDrawing::Initialize()
  23. {
  24.  
  25.     mFirstTime = true;
  26.     
  27.     ::GetDateTime( &mNextTime );
  28.     mNextTime =+ 10;
  29. }
  30.  
  31. void CPluginDrawing::SetDrawingRect( Rect    inRect )
  32. {
  33.     mFrameRect = inRect;
  34.     mWidth = inRect.right - inRect.left; 
  35.     mHeight = inRect.bottom - inRect.top;
  36.     
  37. }
  38. void CPluginDrawing::DrawFrame()
  39. {
  40.     StColorState    theState;
  41.     StTextState        theText;
  42.     
  43.     ::RGBForeColor(&Color_White);
  44.     ::RGBBackColor(&Color_Black);
  45.  
  46.     if ( mFirstTime ) {
  47.         ::EraseRect( &mFrameRect );
  48.         mFirstTime = false;
  49.     }
  50.     
  51.     ::TextSize( 15 );
  52.  
  53.     unsigned long now;
  54.     ::GetDateTime( &now );
  55.     
  56.     if ( now > mNextTime ) {
  57.         mNextTime = now;// + 1;
  58.         long newTop, newLeft; 
  59.         newTop = Random();    newLeft = Random();
  60.         newTop = ((newTop+32767) * mFrameRect.bottom)/65536;
  61.         newLeft = ((newLeft+32767) * mFrameRect.right)/65536;
  62.  
  63.  
  64.         ::MoveTo( newLeft, newTop );
  65.         Str255    string;
  66.  
  67.         sprintf( (char*)string, "Wow! #%d", sCount );    
  68.         c2pstr( (char*) string );
  69.         ::DrawString( string );
  70.  
  71.     }
  72. }
  73.  
  74. void CPluginDrawing::Terminate()
  75. {
  76.  
  77. }
  78.  
  79.