home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / OOFILE / PhoneControl OOFILE sample / PowerPlant Goodies / LStrTableView.cp < prev    next >
Encoding:
Text File  |  1995-10-10  |  1.8 KB  |  92 lines  |  [TEXT/CWIE]

  1. // LStrTableView
  2. // simple subclass of LTableView, that just draws strings
  3. // ©1995 A.D. Software, all rights reserved
  4. // freely licensed for any use
  5. // contact dent@highway1.com.au  or http://www.highway1.com.au/adsoftware/
  6.  
  7. #include "LStrTableView.h"
  8.  
  9. #pragma mark --- Construction/Destruction ---
  10.  
  11. LStrTableView*
  12. LStrTableView::CreateStrTableViewStream(
  13.     LStream    *inStream)
  14. {
  15.     return (new LStrTableView(inStream));
  16. }
  17.  
  18.  
  19. LStrTableView::LStrTableView(
  20.     const SPaneInfo    &inPaneInfo,
  21.     const SViewInfo    &inViewInfo,
  22.     LTableGeometry    *inTableGeometry,
  23.     LTableSelector    *inTableSelector,
  24.     LTableStorage    *inTableStorage) :
  25. LTableView(inPaneInfo,inViewInfo,inTableGeometry,inTableSelector,inTableStorage)
  26. {
  27. }
  28.  
  29.  
  30. LStrTableView::LStrTableView(
  31.     LStream    *inStream) : 
  32. LTableView(inStream)
  33. {
  34. }
  35.  
  36.  
  37. MessageT
  38. LStrTableView::GetDoubleClickMessage() const
  39. {
  40.     return mDoubleClickMessage;
  41. }
  42.  
  43.  
  44. //    Specify the message broadcasted when a cell is double-clicked
  45. void
  46. LStrTableView::SetDoubleClickMessage(
  47.     MessageT    inMessage)
  48. {
  49.     mDoubleClickMessage = inMessage;
  50. }
  51.  
  52.  
  53.  
  54.  
  55. #pragma mark --- Clicking ---
  56.  
  57. void
  58. LStrTableView::ClickCell(
  59.     const STableCell&        /* inCell */,
  60.     const SMouseDownEvent&    /* inMouseDown */)
  61. {
  62.     if (GetClickCount() > 1) 
  63.         BroadcastMessage(mDoubleClickMessage, this);
  64. }
  65.  
  66.  
  67. #pragma mark --- Drawing ---
  68.  
  69. void
  70. LStrTableView::DrawCell(
  71.     const STableCell    &inCell,
  72.     const Rect            &inLocalRect)
  73. {
  74.     Uint32        dataSize = 17;  // crude way to get clipping
  75.     char*        theStr = new char[dataSize];  
  76.     GetCellData(inCell, theStr, dataSize);
  77. /*    ResIDT    textTraitsID = mLeafTextTraits;
  78.     if (mCollapsableTree->IsCollapsable(woRow)) {
  79.         textTraitsID = mParentTextTraits;
  80.     }
  81.     UTextTraits::SetPortTextTraits(textTraitsID);
  82. */    
  83.     // HORRIBLE HACK FOR NOW
  84.         ::TextFont(applFont);
  85.         ::TextSize(9);
  86.  
  87.     ::MoveTo(inLocalRect.left, inLocalRect.bottom - 4);
  88.     ::DrawText(theStr, 0, dataSize);
  89.     delete[] theStr;
  90. }
  91.  
  92.