home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / COSEmulator / COSEmulator- SRC / src / FloatWindow.cpp < prev    next >
Encoding:
Text File  |  1998-06-21  |  3.9 KB  |  159 lines  |  [TEXT/CWIE]

  1. //===================================================================
  2. //=======================  Headers        =============================
  3.  
  4. #include "FloatWindow.h"
  5. #include "GameUtilities.h"
  6. #include "Screen.h"
  7.  
  8. //===================================================================
  9. //=======================  Globals        =============================
  10.  
  11.  
  12. //===================================================================
  13. //=======================  #define        =============================
  14.  
  15.  
  16. //===================================================================
  17. //=======================  Function Prototypes    =====================
  18.  
  19. /*----------------------------------------------------------------------------\
  20.  
  21.     FloatWindow :: Constructor
  22.  
  23. \----------------------------------------------------------------------------*/
  24.     FloatWindow :: FloatWindow( void )
  25. {
  26.     
  27. }
  28.  
  29. /*----------------------------------------------------------------------------\
  30.  
  31.     FloatWindow :: Init
  32.  
  33. \----------------------------------------------------------------------------*/
  34. Boolean    FloatWindow :: SetUp( short pic , short w , short h , short xLoc , short yLoc )
  35. {
  36.     width = w;
  37.     height = h;
  38.     
  39.     screenLoc.left = xLoc;
  40.     screenLoc.top = yLoc;
  41.     screenLoc.right = screenLoc.left + width;
  42.     screenLoc.bottom = screenLoc.top + height;
  43.     
  44.     return window.LoadPicBuff( pic );
  45.     
  46. }
  47.  
  48. /*----------------------------------------------------------------------------\
  49.  
  50.     FloatWindow :: HandleMouseClick
  51.  
  52. \----------------------------------------------------------------------------*/
  53. void    FloatWindow :: HandleMouseClick( Boolean down , point where )
  54. {
  55.     if( down )
  56.     {
  57.         draging = true;
  58.         start = where;
  59.     }
  60.     else
  61.     {
  62.         if( draging )
  63.         {
  64.             screen.AddRectToUpdate( screenLoc );
  65.             
  66.             MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  67.  
  68.             screen.AddRectToUpdate( screenLoc );
  69.             
  70.             draging = false;
  71.         }
  72.     }
  73. }
  74.  
  75. /*----------------------------------------------------------------------------\
  76.  
  77.     FloatWindow :: HandleMouseMove
  78.  
  79. \----------------------------------------------------------------------------*/
  80. void    FloatWindow :: HandleMouseMove( point where )
  81. {
  82.     if( draging )
  83.     {
  84.         screen.AddRectToUpdate( screenLoc );
  85.         
  86.         MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  87.         start = where;
  88.         
  89.         screen.AddRectToUpdate( screenLoc );
  90.     }
  91. }
  92.  
  93. /*----------------------------------------------------------------------------\
  94.  
  95.     FloatWindow :: PointInWindow
  96.  
  97. - just saids if the point it inside the window area or not
  98. \----------------------------------------------------------------------------*/
  99. Boolean    FloatWindow :: PointInWindow( point where )
  100. {
  101.     return SectPtRect( where , screenLoc );
  102. }
  103.  
  104. /*----------------------------------------------------------------------------\
  105.  
  106.     FloatWindow :: Active
  107.  
  108. \----------------------------------------------------------------------------*/
  109. Boolean    FloatWindow :: Front( void )
  110. {
  111.     return( front );
  112. }
  113.  
  114. /*----------------------------------------------------------------------------\
  115.  
  116.     FloatWindow :: SetFront
  117.  
  118. \----------------------------------------------------------------------------*/
  119. void    FloatWindow :: SetFront( Boolean f )
  120. {
  121.     front = f;
  122. }
  123.  
  124. /*----------------------------------------------------------------------------\
  125.  
  126.     FloatWindow :: DrawToScreen
  127.  
  128. \----------------------------------------------------------------------------*/
  129. void    FloatWindow :: DrawToScreen( rect *where , Boolean backGround )
  130. {
  131.     if( !backGround )
  132.     {
  133.         if( where == NULL )
  134.         {
  135.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  136.                         NULL , 0 , 0 , 0 );
  137.         }
  138.         else
  139.         {
  140.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  141.                         where , 0 , 0 , 0 );
  142.         }
  143.     }
  144.     else
  145.     {
  146.         if( where == NULL )
  147.         {
  148.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  149.                         NULL , kDrawTint , 16 , 0xffff );
  150.         }
  151.         else
  152.         {
  153.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  154.                         where , kDrawTint , 16 , 0xffff );
  155.         }
  156.     }
  157.  
  158. }
  159.