home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ViewTester / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.8 KB  |  147 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Frame.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FRAME_H
  11. #include "Frame.h"
  12. #endif
  13.  
  14. #ifndef PART_H
  15. #include "Part.h"
  16. #endif
  17.  
  18. #ifndef DIALOG_H
  19. #include "Dialog.h"
  20. #endif
  21.  
  22. #ifndef DEFINES_K
  23. #include "Defines.k"
  24. #endif
  25.  
  26. // ----- Framework Includes -----
  27.  
  28. #ifndef FWUTIL_H
  29. #include "FWUtil.h"
  30. #endif
  31.  
  32. #ifndef FWCONTXT_H
  33. #include "FWContxt.h"
  34. #endif
  35.  
  36. #ifndef FWIDLE_H
  37. #include "FWIdle.h"
  38. #endif
  39.  
  40. #ifndef FWITERS_H
  41. #include "FWIters.h"
  42. #endif
  43.  
  44. #ifndef FWRECSHP_H
  45. #include "FWRecShp.h"
  46. #endif
  47.  
  48. // ----- PPob View Support -----
  49.  
  50. #if FW_PPOB_VIEWS
  51. #include "FWPPobRd.h"
  52. #endif
  53.  
  54. // ----- MacApp View Support -----
  55.  
  56. #if FW_MACAPP_VIEWS
  57. #include "FWMARead.h"
  58. #endif
  59.  
  60. //========================================================================================
  61. //    Runtime informations
  62. //========================================================================================
  63.  
  64. #ifdef FW_BUILD_MAC
  65. #pragma segment viewtester
  66. #endif
  67.  
  68. //========================================================================================
  69. //    CLASS CViewTesterFrame
  70. //========================================================================================
  71.  
  72. FW_DEFINE_AUTO(CViewTesterFrame)
  73.  
  74. //----------------------------------------------------------------------------------------
  75. //     CViewTesterFrame::CViewTesterFrame
  76. //----------------------------------------------------------------------------------------
  77.  
  78. CViewTesterFrame::CViewTesterFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, FW_CPart* part) :
  79.     FW_CFrame(ev, odFrame, presentation, part),
  80.     fPart(part)
  81. {
  82.     // Add an idler to see the caret blink in text-edit views
  83.     fIdler = FW_NEW(FW_CIdler, (this, 15));
  84.     fIdler->RegisterIdle(ev);                
  85.  
  86.     FW_END_CONSTRUCTOR
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------
  90. //     CViewTesterFrame::~CViewTesterFrame
  91. //----------------------------------------------------------------------------------------
  92.  
  93. CViewTesterFrame::~CViewTesterFrame()
  94. {
  95.     FW_START_DESTRUCTOR
  96.  
  97.     delete fIdler;
  98.     
  99.     // Must tell the part!
  100.     ((CViewTesterPart*)fPart)->ResetTestFrame();
  101. }
  102.  
  103. //----------------------------------------------------------------------------------------
  104. // CViewTesterFrame::CreateSubViews
  105. //----------------------------------------------------------------------------------------
  106.  
  107. void CViewTesterFrame::CreateSubViews(Environment* ev)
  108. {        
  109.     // This is called the first time the frame is created.
  110.     
  111.     CViewTesterPart* part = (CViewTesterPart*) GetPart(ev);
  112.     FW_PlatformError error;
  113.     
  114.     if (part->UsingMacApp())
  115.         error = FW_CMacAppReader::CreateSubViewsFromMacAppResource(ev, 
  116.                                                 part->GetTestViewID(), 
  117.                                                 this,            // frame is root view
  118.                                                 0,                 // don't use any receiver
  119.                                                 FW_CMacAppReader::kCurrentResFile,
  120.                                                 part->HasWarningsOn(ev));
  121.     else
  122.         error = FW_CPPobReader::CreateSubViewsFromPPobResource(ev, 
  123.                                                 part->GetTestViewID(), 
  124.                                                 this,
  125.                                                 0, 
  126.                                                 FW_CPPobReader::kCurrentResFile,
  127.                                                 part->HasWarningsOn(ev));
  128.     part->CheckForError(ev, error);
  129. }
  130.  
  131. //----------------------------------------------------------------------------------------
  132. //     CViewTesterFrame::Draw
  133. //----------------------------------------------------------------------------------------
  134.  
  135. void CViewTesterFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
  136. {
  137.     FW_CViewContext vc(ev, this, odFacet, invalidShape);
  138.  
  139.     FW_CRect rect;
  140.     vc.GetClipRect(rect);    
  141.  
  142.     // Keep a purple background for the frame to make subviews more visible
  143.     FW_CRectShape::RenderRect(vc, rect, FW_kFill, FW_CColor(204, 204, 255));
  144. }
  145.  
  146.  
  147.