home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / Aidan's Class Libraries / Source / Layout Classes / PicControls.cpp < prev    next >
Encoding:
Text File  |  1997-05-31  |  1.4 KB  |  74 lines  |  [TEXT/CWIE]

  1. //Copyright (c) 1997 Aidan Cully
  2. //All rights reserved
  3.  
  4. #include "CLPicControl.h"
  5.  
  6. TPicControl::TPicControl( TLayoutBranch *super, SInt16 resID ):
  7.     TControl( super )
  8. {
  9.     mhResid= resID;
  10.     picture= 0l;
  11. }
  12.  
  13. Boolean TPicControl::Init()
  14. {
  15.     picture= GetCIcon( mhResid );
  16.     if( picture != 0 )
  17.         return( TControl::Init() );
  18.     return( 0 );
  19. }
  20.  
  21. void TPicControl::DrawSelf( TDrawSlate *gr )
  22. {
  23.     Rect localRect= GetLocalRect();
  24.     Rect iconRect;
  25.  
  26.     iconRect.left= (localRect.left+localRect.right)/2;
  27.     iconRect.top= (localRect.top+localRect.bottom)/2;
  28.     iconRect.left -= 16;
  29.     iconRect.right= iconRect.left+32;
  30.     iconRect.top -= 16;
  31.     iconRect.bottom= iconRect.top+32;
  32.     EraseRect( &localRect );
  33.     FrameRoundRect( &localRect, 16, 16 );
  34.     PlotCIcon( &iconRect, picture );
  35. }
  36.  
  37. Boolean TPicControl::Close()
  38. {
  39.     if( picture )
  40.         DisposeCIcon( picture );
  41.     return( TControl::Close() );
  42. }
  43.  
  44. void TPicControl::TrackMouseChange( TMouseEvent *event, Boolean within )
  45. {
  46.     Rect rect= GetLocalRect();
  47.  
  48.     ::InsetRect( &rect, 1, 1 );
  49.     InvertRoundRect( &rect, 14, 14 );
  50. }
  51.  
  52. void TPicControl::TrackMouseUp( TMouseEvent *event )
  53. {
  54.     Rect rect= GetLocalRect();
  55.  
  56.     ::InsetRect( &rect, 1, 1 );
  57.     InvertRoundRect( &rect, 14, 14 );
  58. }
  59.  
  60. void TPicControl::TrackMouseDown( TMouseEvent *event )
  61. {
  62.     Rect rect= GetLocalRect();
  63.  
  64.     ::InsetRect( &rect, 1, 1 );
  65.     InvertRoundRect( &rect, 14, 14 );
  66. }
  67.  
  68. Rect TPicControl::GetLargestSize()
  69. {
  70.     Rect retRect;
  71.  
  72.     ::SetRect( &retRect, 0, 0, 40, 40 );
  73.     return( retRect );
  74. }