home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CScrollList 1.0 / Demo Classes / CScrollListDemoDir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  3.7 KB  |  141 lines  |  [TEXT/KAHL]

  1. /*************************************************************************************
  2.  
  3.  CScrollListDemoDir.c
  4.     
  5.         Director to create and manage the CScrollList demo window.
  6.     
  7.     SUPERCLASS = CShowcaseDemoDir
  8.     
  9.     REQUIRES : CScrollList
  10.     
  11.         © 1992 Dave Harkness
  12.  
  13. *************************************************************************************/
  14.  
  15.  
  16. /*************************************************************************************
  17.  
  18.     To install this Showcase demo, follow these two easy steps:
  19.     
  20.         1)  Add all source files to the CSApplication project.
  21.         
  22.                 CEditString
  23.                 CStringArray
  24.                 CStringEditList
  25.              *    CScrollList
  26.                 CScrollListDemoDir
  27.              *    CScrollListDragger
  28.              *    CStateArray
  29.             
  30.             [ Those marked with an * are the files necessary when using
  31.               the CScrollList class.  The other four are only for this demo. ]
  32.     
  33.         2)    Add all resources in "CScrollListDemo.rsrc" to the
  34.             Showcase resource file "CSApplication π.rsrc".
  35.  
  36. *************************************************************************************/
  37.  
  38.  
  39. #include "CScrollListDemoDir.h"
  40. #include "CStringEditList.h"
  41. #include "CScrollList.h"
  42. #include "CStringArray.h"
  43.  
  44. #include <CScrollPane.h>
  45. #include <CPaneBorder.h>
  46. #include <CWindow.h>
  47. #include <CDesktop.h>
  48. #include <CDecorator.h>
  49.  
  50.  
  51. extern CDesktop        *gDesktop;
  52. extern CDecorator    *gDecorator;
  53.  
  54. CursHandle        gCheckCursor, gHandCursor;
  55.  
  56.  
  57. /*************************************************************************************
  58.  INewDemo
  59. *************************************************************************************/
  60.  
  61. void
  62. CScrollListDemoDir::INewDemo( CDirectorOwner *aSupervisor)
  63.  
  64. {
  65.     CScrollPane            *scrollPane;
  66.     CStringEditList        *editList;
  67.     CPaneBorder            *listBorder;
  68.     Rect                sizeRect;
  69.     
  70.     inherited::INewDemo( aSupervisor);
  71.     
  72.                                                         // Get cursors for CScrollList
  73.     gCheckCursor = GetCursor( kCheckCursorID);
  74.     FailNILRes( gCheckCursor);
  75.     HNoPurge( (Handle) gCheckCursor);
  76.     gHandCursor = GetCursor( kHandCursorID);
  77.     FailNILRes( gHandCursor);
  78.     HNoPurge( (Handle) gHandCursor);
  79.     
  80.                                                         // Create the window
  81.     itsWindow = new(CWindow);
  82.     itsWindow->IWindow( kWINDScrollListDemo, false, gDesktop, this);
  83.  
  84.                                                         // Create the scrollPane
  85.     scrollPane = new CScrollPane;
  86.     scrollPane->IViewRes( 'ScPn', kScPnScrollListDemo, itsWindow, this);
  87.     scrollPane->FitToEnclosure( true, true);
  88.     SetRect( &sizeRect, -1, -1, 1, 1);
  89.     scrollPane->ChangeSize( &sizeRect, false);
  90.     
  91.                                                         // Create the scrollList
  92.     editList = new CStringEditList;
  93.     editList->IStringEditList( scrollPane, this, 0, 0, 0, 0,
  94.                                sizELASTIC, sizELASTIC,
  95.                                kSLSelectable | kSLDragable | kSLCheckable | kSLEditable);
  96.     
  97.                                                         // Setup the scrollList
  98.     editList->FitToEnclosure( true, true);
  99.     editList->SetDrawActiveBorder( false);
  100.     
  101.                                                         // Create the listBorder
  102.     listBorder = new( CPaneBorder);
  103.     listBorder->IPaneBorder( kBorderFrame);
  104.     editList->SetBorder( listBorder);
  105.     
  106.                                                         // Create the array
  107.     itsArray = new CStringArray;
  108.     itsArray->IRes( kSTRScrollListDemo);
  109.     editList->SetArray( itsArray);
  110.     editList->CheckCell( 15);
  111.     editList->CheckCell( 16);
  112.     editList->CheckCell( 18);
  113.     editList->CheckCell( 19);
  114.     
  115.                                                         // Install the scrollList
  116.     scrollPane->InstallPanorama( editList);
  117.     itsGopher = editList;
  118.     editList->SelectCell( 1, kDontRedraw);
  119.     
  120.                                                         // Show the window
  121.     gDecorator->CenterWindow(itsWindow);
  122.     itsWindow->Select();
  123.  
  124. }  /* CScrollListDemoDir::INewDemo */
  125.  
  126.  
  127. /*************************************************************************************
  128.  Dispose  {OVERRIDE}
  129. *************************************************************************************/
  130.  
  131. void
  132. CScrollListDemoDir::Dispose( void)
  133.  
  134. {
  135.     CStringArray    *anArray = itsArray;
  136.     
  137.     inherited::Dispose();
  138.     anArray->Dispose();
  139.  
  140. }  /* CScrollListDemoDir::Dispose */
  141.