home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / Lookup 1.0d2 / Sources / CListBox.cp < prev    next >
Encoding:
Text File  |  1994-07-25  |  3.8 KB  |  127 lines  |  [TEXT/CWIE]

  1. // =================================================================================
  2. //    CListBox.cp            ©1994 Harold Ekstrom, AG Group, Inc. All rights reserved.
  3. // =================================================================================
  4. //    CListBox.h    
  5.  
  6. #include "CListBox.h"
  7.  
  8.  
  9. // ---------------------------------------------------------------------------------
  10. //        • CListBox
  11. // ---------------------------------------------------------------------------------
  12.  
  13. CListBox::CListBox()
  14. {
  15.     mLDEFProc = nil;
  16. }
  17.  
  18.  
  19. // ---------------------------------------------------------------------------------
  20. //        • CListBox(LStream*)
  21. // ---------------------------------------------------------------------------------
  22.  
  23. CListBox::CListBox( LStream *inStream ) : LListBox(inStream)
  24. {
  25.     mLDEFProc = nil;
  26. }
  27.  
  28.  
  29. // ---------------------------------------------------------------------------------
  30. //        • ~CListBox
  31. // ---------------------------------------------------------------------------------
  32.  
  33. CListBox::~CListBox()
  34. {
  35.     // Dispose Toolbox ListHandle before LListBox gets a chance.
  36.     // That way, we're still around to get the lCloseMsg.
  37.     if (mMacListH != nil) {
  38.         LDispose( mMacListH );
  39.         mMacListH = nil;
  40.     }
  41. }
  42.  
  43.  
  44. // ---------------------------------------------------------------------------------
  45. //        • FinishCreateSelf
  46. // ---------------------------------------------------------------------------------
  47. // This code could have gone in the constructor for CListBox, but then
  48. // derived class's ldef initialization code wouldn't get called.
  49.  
  50. void
  51. CListBox::FinishCreateSelf()
  52. {
  53.     // Store a pointer to this object in the list handle's userHandle field.
  54.     (**mMacListH).userHandle = (Handle) this;    
  55.  
  56.     // Call the ldef with the lInitMsg.
  57.     Cell    dummyCell = {0,0};
  58.     MyLDEF( lInitMsg, false, nil, dummyCell, 0, 0, mMacListH );
  59. }
  60.  
  61.  
  62. // ---------------------------------------------------------------------------------
  63. //        • MyLDEF
  64. // ---------------------------------------------------------------------------------
  65.  
  66. pascal void
  67. MyLDEF(  short lMessage, Boolean lSelect, Rect *lRect, Cell lCell,
  68.     short lDataOffset, short lDataLen, ListHandle lList )
  69. {
  70.     // Get the real object out of the list handle's userHandle field.
  71.     CListBox    *theListBox = (CListBox *) (**lList).userHandle;
  72.  
  73.     if ( theListBox ) {
  74.     
  75.         switch ( lMessage ) {
  76.         
  77.             case lInitMsg:
  78.                 // Set up the callback mechanism by placing a UPP or ProcPtr in
  79.                 // the list's refCon. The ldef stub will call this routine back
  80.                 // for other messages. (The lInitMsg was called manually.)
  81. #ifdef    __powerc
  82.                 theListBox->mLDEFProc = (ListDefProcPtr) NewListDefProc( MyLDEF );
  83. #else
  84.                 theListBox->mLDEFProc = (ListDefProcPtr) MyLDEF;
  85. #endif
  86.                 (**lList).refCon = (long) theListBox->mLDEFProc;
  87.                 
  88.                 // Calling through to the subobject's initialize routine
  89.                 // is ok since it should have been created by now, or our own
  90.                 // will be called anyway.
  91.                 theListBox->LDEFInitialize();
  92.                 break;
  93.                 
  94.             case lDrawMsg:
  95.                 // Call the real object's draw routine.
  96.                 theListBox->LDEFDraw( lSelect, lRect, lCell, lDataOffset, lDataLen );
  97.                 break;
  98.                     
  99.             case lHiliteMsg:
  100.                 // Call the real object's hilite routine.
  101.                 theListBox->LDEFHilite( lSelect, lRect, lCell, lDataOffset, lDataLen );
  102.                 break;
  103.  
  104.             case lCloseMsg:
  105.                 // Unfortunately, any derived object has probably been
  106.                 // destroyed at this point, so we can't call through
  107.                 // to it for the lCloseMsg.
  108. #ifdef    __powerc
  109.                 //    Dispose of the ldef's routine descriptor.
  110.                 DisposeRoutineDescriptor( (UniversalProcPtr) theListBox->mLDEFProc );
  111.                 theListBox->mLDEFProc = nil;
  112. #endif
  113.                 break;
  114.         }
  115.     }
  116. }
  117.  
  118.  
  119. // ---------------------------------------------------------------------------------
  120. //        • LDEFInitialize
  121. // ---------------------------------------------------------------------------------
  122.  
  123. void
  124. CListBox::LDEFInitialize()
  125. {
  126. }
  127.