home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / Papers / aSEPiA example source / Application / CPluginTable.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-25  |  2.3 KB  |  95 lines  |  [TEXT/CWIE]

  1. /*---------------------------------------------------------------
  2.  
  3.     CPluginTable.cpp
  4.     
  5.     A table listing plugins
  6.  
  7. ---------------------------------------------------------------*/
  8.  
  9. #include "CPluginTable.h"
  10. #include <LTableMultiGeometry.h>
  11. #include <LTableSingleSelector.h>
  12. #include <LTableArrayStorage.h>
  13. #include "UGAColorRamp.h"
  14. #include <UDrawingState.h>
  15. #include <UTextTraits.h>
  16. #include "CPluginManager.h"
  17.  
  18. extern CPluginManager*    gPluginManager;
  19.  
  20.  
  21. CPluginTable::CPluginTable(LStream *inStream)
  22.     :LTableView( inStream )
  23. {
  24.     mTableGeometry = new LTableMultiGeometry(this, mFrameSize.width, 16);
  25.     mTableSelector = new LTableSingleSelector(this);
  26.     mTableStorage = new LTableArrayStorage(this, (unsigned long)0);
  27.  
  28.     InsertCols( 1, 0, NULL );
  29.     
  30.     short count = gPluginManager->GetPluginCount();
  31.     InsertRows( count, 0, NULL );
  32.     
  33.     STableCell    firstCell( 1, 1 );
  34.     SelectCell( firstCell);
  35.     gPluginManager->SetCurrentPluginIndex(1);        
  36. }
  37.  
  38. // ---------------------------------------------------------------------------
  39. //    ClickCell
  40. // ---------------------------------------------------------------------------
  41. //    Description
  42.  
  43. void 
  44. CPluginTable::ClickCell(    const STableCell        &inCell,
  45.                             const SMouseDownEvent    &inMouseDown)
  46. {
  47.     switch ( inCell.col ) 
  48.     {
  49.         case 1:
  50.         {
  51.             gPluginManager->SetCurrentPluginIndex( inCell.row );
  52.         } break;
  53.     };        
  54. }
  55.  
  56. // ---------------------------------------------------------------------------
  57. //    DrawCell
  58. // ---------------------------------------------------------------------------
  59. //    Description
  60.  
  61. void 
  62. CPluginTable::DrawCell( const STableCell        &inCell,
  63.                                 const Rect        &inLocalRect)
  64. {
  65.     StTextState    theState;
  66.     StColorState theColorState;
  67.     
  68.     UTextTraits::SetPortTextTraits( 130 );
  69.  
  70.     switch ( inCell.col ) 
  71.     {
  72.         case 1:
  73.         {
  74.             char    name[256];
  75.             gPluginManager->GetPluginDescriptorbyIndex( inCell.row, name );
  76.             
  77.             
  78.             c2pstr( name );
  79.              ::MoveTo( inLocalRect.left + 2, inLocalRect.bottom - 2 );
  80.             ::DrawString( (StringPtr)name );
  81.         } break;
  82.     };
  83.  
  84.     ::RGBForeColor( &UGAColorRamp::GetColor(colorRamp_Gray3) );        
  85.     
  86.     ::MoveTo( inLocalRect.left, inLocalRect.top);
  87.     ::LineTo( inLocalRect.left, inLocalRect.bottom);
  88.  
  89.     ::RGBForeColor( &UGAColorRamp::GetColor(colorRamp_White) );        
  90.     
  91.     ::MoveTo( inLocalRect.left, inLocalRect.bottom);
  92.     ::LineTo( inLocalRect.right, inLocalRect.bottom);
  93.     
  94. }
  95.