home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / PowerPlant View / CTestView.cp < prev    next >
Encoding:
Text File  |  1996-12-20  |  2.3 KB  |  84 lines  |  [TEXT/CWIE]

  1. #include "ocheaders.h"
  2. #include "CBaseControl.h"
  3.  
  4. #include "CTestView.h"
  5. #include <URegistrar.h>
  6. #include <LCaption.h>
  7. #include <LEditField.h>
  8. #include <LPicture.h>
  9. #include <LStdControl.h>
  10. #include <LView.h>
  11. #include <UAttachments.h>
  12.  
  13. #include "CDirectoryTable.h"
  14. #include "CFixedScroller.h"
  15. #include "CCFragResource.h"
  16.  
  17. #include <LString.h>
  18.  
  19. const PaneIDT        kEditField = 1;
  20.  
  21. void InitPowerPlantControl();
  22.  
  23. // --
  24. // We include this because the CPPActiveX control expects it to exist.
  25. // Without it, things get deadstripped and this custom view would never
  26. // be created.
  27. // --
  28.  
  29. void InitPowerPlantControl()
  30. {
  31.     URegistrar::RegisterClass(CTestView::class_ID, (ClassCreatorFunc) CTestView::CreateFromStream);
  32.     URegistrar::RegisterClass(LCaption::class_ID,        (ClassCreatorFunc) LCaption::CreateCaptionStream);
  33.     URegistrar::RegisterClass(LEditField::class_ID,        (ClassCreatorFunc) LEditField::CreateEditFieldStream);
  34.     URegistrar::RegisterClass(LPicture::class_ID,        (ClassCreatorFunc) LPicture::CreatePictureStream);
  35.     URegistrar::RegisterClass(LStdButton::class_ID,        (ClassCreatorFunc) LStdButton::CreateStdButtonStream);
  36.     URegistrar::RegisterClass(LStdCheckBox::class_ID,    (ClassCreatorFunc) LStdCheckBox::CreateStdCheckBoxStream);
  37.     
  38.     // ----------
  39.     // Register the custom ones we're throwing in for show...
  40.     // ----------
  41.     
  42.     URegistrar::RegisterClass(CDirectoryTable::class_ID, (ClassCreatorFunc) CDirectoryTable::CreateFromStream);
  43.     URegistrar::RegisterClass(CFixedScroller::class_ID, (ClassCreatorFunc) CFixedScroller::CreateFromStream);    
  44. }
  45.  
  46. CTestView*
  47. CTestView::CreateFromStream(
  48.     LStream        *inStream)
  49. {
  50.     return (new CTestView(inStream));
  51. }
  52.  
  53. CTestView::CTestView(LStream *inStream)
  54.     : LView(inStream)
  55. {
  56.  
  57.     short            AppResFile = ::CurResFile();
  58.     CCFragResource    ResourceSetter;
  59.     short            CFragResFile = ::CurResFile();    
  60.     
  61. }
  62.  
  63. void
  64. CTestView::FinishCreateSelf()
  65. {
  66.     CDirectoryTable *table = (CDirectoryTable*) FindPaneByID('dirr');
  67.     if (table != nil)
  68.     {
  69.         FSSpec    fs;
  70.         FindFolder(kOnSystemDisk, 'macs', false, &fs.vRefNum, &fs.parID);
  71.         LString::CopyPStr("\pPreferences", fs.name);
  72.         table->BuildList(fs, 0);
  73.     }
  74.     
  75.     LEditField*    editField = (LEditField*) FindPaneByID(kEditField);
  76.     if (editField != nil)
  77.     {
  78.         LEraseAttachment*    theAttachment;
  79.         theAttachment = new LEraseAttachment();
  80.         if (theAttachment)
  81.             editField->AddAttachment(theAttachment, nil, true);
  82.     }
  83. }
  84.