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 / ODF / Other View Systems / MacApp Views / FWMAObjs.cpp next >
Encoding:
Text File  |  1996-09-17  |  46.0 KB  |  1,393 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWMAObjs.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //========================================================================================
  8.  
  9. #ifndef FWMAOBJS_H
  10. #include "FWMAObjs.h"
  11. #endif
  12.  
  13. #ifndef FWSVIEW_H
  14. #include "FWSView.h"
  15. #endif
  16.  
  17. #ifndef FWFRAME_H
  18. #include "FWFrame.h"
  19. #endif
  20.  
  21. #ifndef FWSTATIC_H
  22. #include "FWStatic.h"
  23. #endif
  24.  
  25. #ifndef FWEDVIEW_H
  26. #include "FWEdView.h"
  27. #endif
  28.  
  29. #ifndef FWSCLBAR_H
  30. #include "FWSclBar.h"
  31. #endif
  32.  
  33. #ifndef FWSCROLR_H
  34. #include "FWScrolr.h"
  35. #endif
  36.  
  37. #ifndef FWPOPUP_H
  38. #include "FWPopup.h"
  39. #endif
  40.  
  41. #ifndef FWLISTBX_H
  42. #include "FWListBx.h"
  43. #endif
  44.  
  45. #ifndef FWCLUSTR_H
  46. #include "FWClustr.h"
  47. #endif
  48.  
  49. #ifndef FWTABBER_H
  50. #include "FWTabber.h"
  51. #endif
  52.  
  53. #ifndef FWUNKNOW_H
  54. #include "FWUnknow.h"
  55. #endif
  56.  
  57. #ifndef FWPICTSV_H
  58. #include "FWPictSv.h"
  59. #endif
  60.  
  61. #ifndef FWGROWBX_H
  62. #include "FWGrowBx.h"
  63. #endif
  64.  
  65. #ifndef FWWINDOW_H
  66. #include "FWWindow.h"
  67. #endif
  68.  
  69. #ifndef FWRANSIN_H
  70. #include "FWRanSin.h"
  71. #endif
  72.  
  73. //========================================================================================
  74. // MacApp types and constants
  75. //========================================================================================
  76.  
  77. typedef unsigned short WindowFlags;
  78.  
  79. const long mOKHit = 1;
  80. const long mCancelHit = 2;
  81. const long mButtonHit = 3;
  82. const long mCheckBoxHit = 4;
  83. const long mClusterHit = 5;
  84. const long mEditTextHit = 6;
  85. const long mIconHit = 7;
  86. const long mListItemHit = 8;
  87. const long mListScrollBarHit = 9;
  88. const long mPictureHit = 10;
  89. const long mPopupHit = 11;
  90. const long mRadioHit = 12;
  91. const long mStaticTextHit = 13;
  92. const long mHScrollBarHit = 14;
  93. const long mVScrollBarHit = 15;
  94.  
  95. //========================================================================================
  96. // 
  97. //========================================================================================
  98.  
  99. #ifdef FW_BUILD_MAC
  100. #pragma segment fwmacapp
  101. #endif
  102.  
  103. //----------------------------------------------------------------------------------------
  104. //    FW_CMAObject::FW_CMAObject
  105. //----------------------------------------------------------------------------------------
  106.  
  107. FW_CMAObject::FW_CMAObject(ResType type) :
  108.     fClassID(type),
  109.     fEndOfObject(0)
  110. {    
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    FW_CMAObject::ReadFrom
  115. //----------------------------------------------------------------------------------------
  116.  
  117. void FW_CMAObject::ReadFrom(Environment* ev, FW_CReadableStream& stream, 
  118.                             FW_CSuperView* superview, FW_MReceiver* receiver)
  119. {
  120. FW_UNUSED(ev);
  121. FW_UNUSED(stream);
  122. FW_UNUSED(superview);
  123. FW_UNUSED(receiver);
  124.     // nothing to do for ODF
  125. }  
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    FW_CMABehavior::FW_CMABehavior
  129. //----------------------------------------------------------------------------------------
  130.  
  131. FW_CMABehavior::FW_CMABehavior(ResType type) :
  132.     FW_CMAObject(type)
  133. {    
  134. }
  135.  
  136. //----------------------------------------------------------------------------------------
  137. //    FW_CMABehavior::ReadFrom
  138. //----------------------------------------------------------------------------------------
  139.  
  140. void FW_CMABehavior::ReadFrom(Environment* ev, FW_CReadableStream& stream, 
  141.                             FW_CSuperView* superview, FW_MReceiver* receiver)
  142. {
  143.     inherited::ReadFrom(ev, stream, superview, receiver);
  144.  
  145.     ResType                identifier;
  146.     Boolean                enabled;
  147.     long                idleFreq;
  148.  
  149.     stream >> identifier >> enabled >> idleFreq;        // ignored by ODF
  150. }  
  151.  
  152. //----------------------------------------------------------------------------------------
  153. //    FW_CMADialogBehavior::FW_CMADialogBehavior
  154. //----------------------------------------------------------------------------------------
  155.  
  156. FW_CMADialogBehavior::FW_CMADialogBehavior(ResType type) :
  157.     FW_CMABehavior(type)
  158. {    
  159. }
  160.  
  161. //----------------------------------------------------------------------------------------
  162. //    FW_CMADialogBehavior::ReadFrom
  163. //----------------------------------------------------------------------------------------
  164.  
  165. void FW_CMADialogBehavior::ReadFrom(Environment* ev, FW_CReadableStream& stream, 
  166.                             FW_CSuperView* superview, FW_MReceiver* receiver)
  167. {
  168.     inherited::ReadFrom(ev, stream, superview, receiver);
  169.  
  170.     // Read TDialogBehavior fields: 
  171.     // - the OK and Cancel button ids will be used when creating buttons in this window.
  172.     // - the modal field is ignored since the creation of the ODF dialog is done by program
  173.     Boolean modal;
  174.     
  175.     stream >>  modal;
  176.     stream >> FW_CMacAppReader::gDefaultButtonID;
  177.     stream >> FW_CMacAppReader::gCancelButtonID;
  178. }  
  179.  
  180. //----------------------------------------------------------------------------------------
  181. //    FW_CMADialogBehavior::Create
  182. //----------------------------------------------------------------------------------------
  183.  
  184. FW_CMAObject*    FW_CMADialogBehavior::Create(ResType type)
  185. {
  186.     return new FW_CMADialogBehavior(type);
  187. }
  188.  
  189. //----------------------------------------------------------------------------------------
  190. //    FW_CMAEventHandler::FW_CMAEventHandler
  191. //----------------------------------------------------------------------------------------
  192.  
  193. FW_CMAEventHandler::FW_CMAEventHandler(ResType type) :
  194.     FW_CMAObject(type)
  195. {    
  196. }
  197.  
  198. //----------------------------------------------------------------------------------------
  199. //    FW_CMAEventHandler::ReadFrom
  200. //----------------------------------------------------------------------------------------
  201. // [LSD] this should never be called directly from FW_CMacAppReader::ReadStreamObject, right?
  202. //         Pure EventHandler objects are not persistent, right?
  203.  
  204. void FW_CMAEventHandler::ReadFrom(Environment* ev, FW_CReadableStream& stream, 
  205.                             FW_CSuperView* superview, FW_MReceiver* receiver)
  206. {
  207.     inherited::ReadFrom(ev, stream, superview, receiver);
  208.     
  209.     // Read in TEventHandler fields
  210.     long idleFreq;
  211.     
  212.     stream >> fIdentifier >> fEnabled >> idleFreq;
  213.  
  214.     short numBehaviors;
  215.     stream >> numBehaviors;
  216.  
  217.     for (short count = 0; count < numBehaviors; ++count)
  218.     {
  219.         // OFD only uses TDialogBehavior objects for now
  220.         FW_CMacAppReader::ReadStreamObject(ev, stream, superview, receiver, 
  221.                                             FW_CMacAppReader::kBehavior);
  222.     }
  223. }  
  224.  
  225. //----------------------------------------------------------------------------------------
  226. //    FW_CMAView::FW_CMAView
  227. //----------------------------------------------------------------------------------------
  228.  
  229. FW_CMAView::FW_CMAView(ResType type) :
  230.     FW_CMAEventHandler(type),
  231.     fIsContentView(false),
  232. //    fScrollingDirection(FW_kNoScrolling),
  233.     fIsScroller(false)
  234. {    
  235.     // If gScroller is not null this is the first view following TScroller in the stream
  236.     if (FW_CMacAppReader::gScroller != 0)
  237.         fIsContentView = true;
  238. }
  239.  
  240. //----------------------------------------------------------------------------------------
  241. //    FW_CMAView::ReadFrom
  242. //----------------------------------------------------------------------------------------
  243. // Main entry point for reading MacApp view resources.
  244. // It's much more complex than the original MacApp ReadFrom method because of all the
  245. // work-arounds necessary to map MacApp views to ODF views, especially when dealing
  246. // with unregistered classes, scrollers and clusters.
  247.  
  248. void FW_CMAView::ReadFrom(Environment* ev, FW_CReadableStream& stream, 
  249.                         FW_CSuperView* superview, FW_MReceiver* receiver) 
  250. {
  251.     FW_ASSERT(superview);
  252.     FW_ASSERT(fIsScroller == false || FW_CMacAppReader::gScroller != 0);
  253.     
  254.     FW_TRY
  255.     {
  256.         inherited::ReadFrom(ev, stream, superview, receiver);    // read in TEventHandler info
  257.  
  258.         // Read MacApp fields for each class
  259.         ReadFields(ev, stream);                                            
  260.  
  261.         // Create the ODF view corresponding to the MacApp view.
  262.         // New controls will also be linked to the supplied receiver (if not null)
  263.         FW_CView* newView = CreateODFView(ev, superview, receiver);    
  264.         
  265.         // Save the current globale offset and update it with the current view location
  266.         // in case the MacApp view is not translated into and ODF view (cases of TScroller
  267.         // TCluster, TView,...)
  268.         FW_CPoint currentOffset = FW_CMacAppReader::gOffset;
  269.         if (newView == superview)
  270.             FW_CMacAppReader::gOffset += fBounds.TopLeft();
  271.         else 
  272.             FW_CMacAppReader::gOffset = FW_kZeroPoint;
  273.             
  274.         // In case we are reading an unknown view class we need to skip the rest of
  275.         // the object data at this point (including subviews... too bad)
  276.         if (fEndOfObject != 0)
  277.         {
  278.             ((FW_ORandomAccessSink *)stream.GetSink())->SetPosition(ev, fEndOfObject);
  279.  
  280.             // If the unknown view was the scroller's subview we do take the time to
  281.             // make it the content view and create an ODF ScrollBarScroller
  282.             PostCreateODFView(ev, (FW_CSuperView*)newView);
  283.         }
  284.         else
  285.         {
  286.             short numSubViews;
  287.             stream >> numSubViews;
  288.                 
  289.             if (numSubViews > 0)
  290.             {
  291.                 // This first part is a big workaround to deal with MacApp views which don't
  292.                 // map to ODF superviews, like radio clusters and list boxes.
  293.                 // MacApp clusters contain subviews, but ODF FW_CGroupBox is just a decoration,
  294.                 // not a superview, so we cannot create nested subviews. 
  295.                 // We must:
  296.                 // - Use the same superview instead of newView
  297.                 // - Set gOffset to the groupBox location
  298.                 // - Keep track of the current FW_CRadioCluster to link radio buttons
  299.                 // - Deal with nested clusters ...
  300.                 
  301.                 FW_CRadioCluster* currentCluster = 0;            
  302.                 
  303.                 FW_CSuperView* newSuperview = FW_DYNAMIC_CAST(FW_CSuperView, newView);
  304.                 if(newSuperview == 0)
  305.                 {
  306.                     newSuperview = superview;        
  307.  
  308.                     // If we just created a GroupBox it's because we read a MacApp cluster.
  309.                     // We now create an ODF RadioCluster to be used by nested radio buttons
  310.                     // but we must also save the current cluster to handle nested clusters!
  311.  
  312.                     if (fClassID == kStdCluster)
  313.                     {
  314.                         currentCluster = FW_CMacAppReader::gCluster;
  315.                         FW_CMacAppReader::gCluster = FW_NEW(FW_CRadioCluster, (ev));
  316.  
  317.                         FW_CMacAppReader::gOffset = currentOffset + fBounds.TopLeft();
  318.                     }
  319.                 }
  320.                 else if (newSuperview == superview && FW_CMacAppReader::gScroller != 0 &&
  321.                         fIsContentView == true)
  322.                 {
  323.                     // Handle cases where a scroller contains a dialog view
  324.                     MACAPP_WARNING("MacAppReader Warning: Scroller's subview cannot be mapped to ODF content view");
  325.                     FW_CMacAppReader::gScroller = 0;
  326.                 }
  327.                 else
  328.                 {
  329.                     // Declare the content view and create the ODF scroller if necessary
  330.                     PostCreateODFView(ev, newSuperview);
  331.                 }
  332.                 
  333.                 // Read subviews recursively in the MacApp stream
  334.                 for (short count = 0; count < numSubViews; ++count)
  335.                 {
  336.                     FW_CMacAppReader::ReadStreamObject(ev, stream, newSuperview, 
  337.                                                     receiver, FW_CMacAppReader::kView);
  338.                 }
  339.                 
  340.                 // Delete empty clusters (rare case where no radio buttons were added)
  341.                 if(FW_CMacAppReader::gCluster != 0 && 
  342.                         FW_CMacAppReader::gCluster->GetButtonOn(ev) == 0)
  343.                     delete FW_CMacAppReader::gCluster;
  344.                 
  345.                 // Restore the previous cluster
  346.                 FW_CMacAppReader::gCluster = currentCluster;
  347.             }
  348.             
  349.             if (fIsScroller == true && FW_CMacAppReader::gScroller != 0)
  350.             {
  351.                 // If we get here it means that the TScroller didn't contain any subview
  352.                 // or that its subview wasn't one of the views supporting scrolling in ODF,
  353.                 // i.e. not a scrolling content view or not a list-box
  354.                 // (Note: we avoid this error for TTEView with a scroller)
  355.                 MACAPP_WARNING("MacAppReader Warning: Scroller's subview is missing or doesn't support scrolling in ODF");
  356.                 
  357.                 FW_CMacAppReader::gScroller = 0;
  358.             }
  359.         }
  360.         
  361.         // Restore the previous offset
  362.         FW_CMacAppReader::gOffset = currentOffset;
  363.  
  364.         delete this;    // We don't need our factory object anymore
  365.     }
  366.     FW_CATCH_BEGIN
  367.     FW_CATCH_EVERYTHING()
  368.     {
  369.         delete this;
  370.         FW_THROW_SAME();
  371.     }
  372.     FW_CATCH_END
  373. }
  374.  
  375. //----------------------------------------------------------------------------------------
  376. //    FW_CMAView::ReadFields
  377. //----------------------------------------------------------------------------------------
  378.  
  379. void FW_CMAView::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  380. {
  381.     short     templateVersion;
  382.     VPoint     itsLocation, itsSize;
  383.     Byte     itsHSizeDet, itsVSizeDet;
  384.     Boolean handlesCursor, letsSubViewsHandleCursor;
  385.     Boolean handlesHelp, letsSubViewsHandleHelp;
  386.     short    helpID, helpIndex, cursorID;
  387.     long    userArea;
  388.     ResType    dummyID;
  389.         
  390.     // Read TView fields
  391.     
  392.     stream >> templateVersion;                                // ignored by ODF
  393.     stream.Read(&itsLocation, sizeof(VPoint));
  394.     stream.Read(&itsSize, sizeof(VPoint));
  395.     stream >> itsHSizeDet >> itsVSizeDet;                    // ignored by ODF
  396.     stream >> fVisible >> fWantsToBeTarget;
  397.     stream >> handlesCursor >> letsSubViewsHandleCursor;    // ignored by ODF
  398.     stream >> cursorID;                                        // ignored by ODF
  399.     stream >> handlesHelp >> letsSubViewsHandleHelp;        // ignored by ODF
  400.     stream >> helpID >> helpIndex;                            // ignored by ODF
  401.     
  402.     // Drawing environment and adorners are ignored by ODF
  403.     FW_CMacAppReader::ReadStreamObject(ev, stream, 0, 0, FW_CMacAppReader::kDrawingEnv);    
  404.     FW_CMacAppReader::ReadStreamObject(ev, stream, 0, 0,  FW_CMacAppReader::kAdorner);
  405.     
  406.     stream >> userArea;                                        // ignored by ODF
  407.     stream >> dummyID;                                        // ignored by ODF
  408.         
  409.     // ODF doesn't support 32 bit coordinates yet...
  410.     if (itsLocation.h > FW_MAXINT16 || itsLocation.h < FW_MININT16 ||
  411.         itsLocation.v > FW_MAXINT16  || itsLocation.v < FW_MININT16 ||
  412.         itsSize.h > FW_MAXINT16 || itsSize.v > FW_MAXINT16)
  413.             MACAPP_WARNING("MacAppReader Warning: Found a view out of 16 bit space. ODF will adjust its bounds.");
  414.  
  415.     // Manual corrections. This will make it easier to spot the offending views
  416.     if (itsLocation.h > FW_MAXINT16)
  417.         itsLocation.h = 0;
  418.     if (itsLocation.h < FW_MININT16)
  419.         itsLocation.h = 0;
  420.     if (itsLocation.v > FW_MAXINT16)
  421.         itsLocation.v = 0;
  422.     if (itsLocation.v < FW_MININT16)
  423.         itsLocation.v = 0;
  424.     if (itsSize.h > FW_MAXINT16)
  425.         itsSize.h = FW_MAXINT16 / 2;
  426.     if (itsSize.v > FW_MAXINT16)
  427.         itsSize.v = FW_MAXINT16 / 2;
  428.     
  429.     fExtent.Set(FW_IntToFixed(itsSize.h), FW_IntToFixed(itsSize.v));
  430.  
  431.     // If there is a scroller this is the first subview read after the scroller so
  432.     // it must be the scrolling view.  We adjust its bounds to scroller's bounds
  433.     if (FW_CMacAppReader::gScroller != 0 && fIsScroller == false)
  434.     {    
  435.         fBounds = FW_CMacAppReader::gScroller->fBounds;
  436. //        fBounds.left += FW_kFixedPos1;
  437. //        fBounds.top += FW_kFixedPos1;
  438.         
  439. //        fBindings = FW_CMacAppReader::gScroller->fBindings;
  440.     }
  441.     else
  442.     {
  443.         // The view location takes the current cluster offset into account
  444.         FW_CPoint topLeft(FW_IntToFixed(itsLocation.h), FW_IntToFixed(itsLocation.v));
  445.         fBounds.Set(topLeft+FW_CMacAppReader::gOffset, fExtent.x, fExtent.y);
  446.     }
  447. }
  448.  
  449. //----------------------------------------------------------------------------------------
  450. //    FW_CMAView::Create
  451. //----------------------------------------------------------------------------------------
  452.  
  453. FW_CMAObject*    FW_CMAView::Create(ResType type)
  454. {
  455.     return new FW_CMAView(type);
  456. }
  457.  
  458. //----------------------------------------------------------------------------------------
  459. //    FW_CMAView::CreateODFView
  460. //----------------------------------------------------------------------------------------
  461.  
  462. FW_CView* FW_CMAView::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  463. {
  464. FW_UNUSED(ev);
  465. FW_UNUSED(receiver);
  466.     // We don't create any ODF view for a TView, we just return the same superview to be
  467.     // propagated to the subviews in FW_CMAView::ReadFrom. 
  468.     
  469.     // Note: There should be only 2 cases where the MacApp stream contains a TView:
  470.     // - At the top level, when the root was created as TView instead of TWindow
  471.     // - When declaring a listbox (TView with a TScroller with a TTextListView) see Form.
  472.  
  473.     return superview;
  474. }
  475.  
  476. //----------------------------------------------------------------------------------------
  477. //    FW_CMAView::PostCreateODFView
  478. //----------------------------------------------------------------------------------------
  479.  
  480. void FW_CMAView::PostCreateODFView(Environment* ev, FW_CSuperView* view)
  481. {
  482.     // This method is used to declare the frame's content view and create the
  483.     // associated ODF scroller and its scroll bars.
  484.     
  485.     if (fIsContentView == true && FW_CMacAppReader::gScroller != 0)
  486.     {
  487.         // Since we may get here because an unknown TView was found in the stream
  488.         // we do an extra check to make sure we have created the content view yet.
  489.         
  490.         FW_CFrame* frame = view->GetFrame(ev);
  491.         if (frame->IsContentView(ev))
  492.         {
  493.             FW_CMAScrollBarScroller* scroller = FW_CMacAppReader::gScroller;
  494.             
  495.             // Declare the content view (will fail if it's not the first scroller!)
  496.             view->BecomeContentView(ev);
  497.             
  498.             // Create the scroll bars inside the view's superview.
  499.             // Our convention is to create scroll bars only if their id is not '   '
  500.             // (the MacApp scroller resource doesn't contain this information, scroll bar
  501.             // objects are stored further down the stream)
  502.             FW_CSuperView* superview = view->GetSuperView(ev);
  503.             FW_ASSERT(superview);
  504.             
  505.             FW_CScrollBar* horzSB = 0;
  506.             if (scroller->fHorzSbID != kNullSignature)
  507.             {    
  508.                 FW_CRect bounds = scroller->fBounds;
  509.                 bounds.left += FW_IntToFixed(scroller->fSBarOffsets.left) - FW_kFixedPos1;
  510.                 bounds.right += FW_IntToFixed(scroller->fSBarOffsets.right) + FW_kFixedPos1;
  511.                 bounds.top = bounds.bottom;
  512.                 bounds.bottom += FW_IntToFixed(16); 
  513.  
  514.                 horzSB = FW_NEW(FW_CScrollBar, (ev, superview, bounds, scroller->fHorzSbID));        
  515.             }
  516.  
  517.             FW_CScrollBar* vertSB = 0;
  518.             if (scroller->fVertSbID != kNullSignature)
  519.             {    
  520.                 FW_CRect bounds = scroller->fBounds;
  521.                 bounds.top += FW_IntToFixed(scroller->fSBarOffsets.top) - FW_kFixedPos1;
  522.                 bounds.bottom += FW_IntToFixed(scroller->fSBarOffsets.bottom) + FW_kFixedPos1;
  523.                 bounds.left = bounds.right;
  524.                 bounds.right += FW_IntToFixed(16);
  525.  
  526.                 vertSB = FW_NEW(FW_CScrollBar, (ev, superview, bounds, scroller->fVertSbID));        
  527.             }
  528.  
  529.             // Create the scroller and declare it to the frame
  530.             FW_CFrame* frame = view->GetFrame(ev);
  531.             scroller->fODFScroller = FW_NEW(FW_CScrollBarScroller, 
  532.                                             (ev, frame, scroller->fLiveScrolling, horzSB, vertSB));
  533.  
  534.             frame->AdoptScroller(ev, scroller->fODFScroller);
  535.         }
  536.         
  537.         // Reset the globale to show that we used the scroller
  538.         // (FW_CMAScrollBarScroller object itself will be deleted when returning from
  539.         // FW_CMAView::ReadFrom like all MacApp objects) 
  540.         FW_CMacAppReader::gScroller = 0;
  541.     }
  542. }
  543.  
  544. //----------------------------------------------------------------------------------------
  545. //    FW_CMAWindow::FW_CMAWindow
  546. //----------------------------------------------------------------------------------------
  547.  
  548. FW_CMAWindow::FW_CMAWindow(ResType type) :
  549.     FW_CMAView(type)
  550. {    
  551. }
  552.  
  553. //----------------------------------------------------------------------------------------
  554. //    FW_CMAWindow::ReadFields
  555. //----------------------------------------------------------------------------------------
  556.  
  557. void FW_CMAWindow::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  558. {
  559.     inherited::ReadFields(ev, stream);
  560.  
  561.     // Read in TWindow fields
  562.     ResType targetID;
  563.     WindowFlags itsFlags;
  564.     short strListID, index;
  565.     
  566.     stream >> fProcID >> targetID;
  567.     stream >> itsFlags;
  568.     stream >> strListID >> index;
  569.     
  570. }
  571.  
  572. //----------------------------------------------------------------------------------------
  573. //    FW_CMAWindow::Create
  574. //----------------------------------------------------------------------------------------
  575.  
  576. FW_CMAObject*    FW_CMAWindow::Create(ResType type)
  577. {
  578.     return new FW_CMAWindow(type);
  579. }
  580.  
  581. //----------------------------------------------------------------------------------------
  582. //    FW_CMAWindow::CreateODFView
  583. //----------------------------------------------------------------------------------------
  584.  
  585. FW_CView*    FW_CMAWindow::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  586. {
  587. FW_UNUSED(receiver);
  588.     // Set root frame's window size and location    
  589.     FW_CFrame* frame = superview->GetFrame(ev);
  590.     if (frame->IsRoot(ev))
  591.     {
  592.         // For MacApp fBounds is the position of the window content, not its frame
  593.         // so we must offset by the title bar height
  594.         FW_CWindow* win = frame->GetWindow(ev);
  595.         fBounds.Offset(FW_kFixed0, -FW_IntToFixed(18));
  596.         win->SetWindowPosition(ev, fBounds.TopLeft());
  597.         win->SetWindowSize(ev, fBounds.Size());
  598.  
  599.         // Add a grow box when the MacApp window has one
  600.         if ((fProcID & 0x000F) == documentProc)
  601.         {
  602.             // Grow box location is hard-coded to bottom right corner of frame
  603.             // View id is hard-coded to 'grow' (non-root frames need to remove it)
  604.             FW_CPoint loc = frame->GetSize(ev);
  605.             loc.x -= FW_IntToFixed(15);
  606.             loc.y -= FW_IntToFixed(15);
  607.             FW_CGrowBox* growBox = new FW_CGrowBox(ev, frame, 'grow', loc);    
  608.         } 
  609.     }
  610.     
  611.     
  612.     // We don't create any ODF view for a TWindow, just return superview to be
  613.     // propagated to the subviews in FW_CMAView::ReadFrom.
  614.     // But we need to reset fBounds to 0 to avoid changing FW_CMacAppReader::gOffset
  615.     fBounds.Place(FW_kFixed0, FW_kFixed0);
  616.     
  617.     return superview;
  618. }
  619.  
  620. //----------------------------------------------------------------------------------------
  621. //    FW_CMADialog::FW_CMADialog
  622. //----------------------------------------------------------------------------------------
  623.  
  624. FW_CMADialog::FW_CMADialog(ResType type) :
  625.     FW_CMAView(type)
  626. {    
  627. }
  628.  
  629. //----------------------------------------------------------------------------------------
  630. //    FW_CMADialog::ReadFields
  631. //----------------------------------------------------------------------------------------
  632.  
  633. void FW_CMADialog::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  634. {
  635.     inherited::ReadFields(ev, stream);
  636.  
  637.     // Read OK and Cancel button ids.
  638.     stream >> FW_CMacAppReader::gDefaultButtonID;
  639.     stream >> FW_CMacAppReader::gCancelButtonID;
  640. }
  641.  
  642. //----------------------------------------------------------------------------------------
  643. //    FW_CMADialog::Create
  644. //----------------------------------------------------------------------------------------
  645.  
  646. FW_CMAObject*    FW_CMADialog::Create(ResType type)
  647. {
  648.     return new FW_CMADialog(type);
  649. }
  650.  
  651. //----------------------------------------------------------------------------------------
  652. //    FW_CMADialog::CreateODFView
  653. //----------------------------------------------------------------------------------------
  654.  
  655. FW_CView*    FW_CMADialog::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  656. {
  657. FW_UNUSED(ev);
  658. FW_UNUSED(receiver);
  659.     // we don't create any ODF view for a TDialog, just return superview to be
  660.     // propagated to the subviews in FW_CMAView::ReadFrom
  661.     return superview;
  662. }
  663.  
  664. //----------------------------------------------------------------------------------------
  665. //    FW_CMAStaticText::FW_CMAStaticText
  666. //----------------------------------------------------------------------------------------
  667.  
  668. FW_CMAStaticText::FW_CMAStaticText(ResType type) :
  669.     FW_CMAControl(type)
  670. {    
  671.     // A static text cannot be the content view
  672.     fIsContentView = false;
  673. }
  674.  
  675. //----------------------------------------------------------------------------------------
  676. //    FW_CMAStaticText::ReadFields
  677. //----------------------------------------------------------------------------------------
  678.  
  679. void FW_CMAStaticText::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  680. {
  681.     inherited::ReadFields(ev, stream);
  682.  
  683.     // Read in Static Text fields
  684.     Boolean eraseFirst;
  685.     short    strListID, index, justitication;
  686.     
  687.     stream >> fAutoWrap >> eraseFirst;
  688.     stream >> justitication;
  689.     stream >> strListID >> index;
  690.     
  691.     if (strListID != -1)                // retrieve the text from a STR# resource
  692.         ::GetIndString(fText, strListID, index);
  693.     else
  694.         fText[0] = 0;
  695. }
  696.  
  697. //----------------------------------------------------------------------------------------
  698. //    FW_CMAStaticText::Create
  699. //----------------------------------------------------------------------------------------
  700.  
  701. FW_CMAObject*    FW_CMAStaticText::Create(ResType type)
  702. {
  703.     return new FW_CMAStaticText(type);
  704. }
  705.  
  706.  
  707. //----------------------------------------------------------------------------------------
  708. //    FW_CMAStaticText::CreateODFView
  709. //----------------------------------------------------------------------------------------
  710.  
  711. FW_CView*    FW_CMAStaticText::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  712. {
  713. FW_UNUSED(receiver);
  714.     FW_CFont font;
  715.     FW_CColor color;
  716.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  717.     FW_TextBoxOptions options = FW_kTextBoxClipToBox;
  718.     if (fAutoWrap)
  719.          options |= FW_kTextBoxWordWrap;
  720.     FW_CString text((char *)&fText[1], (FW_ByteCount)fText[0]);
  721.     FW_CInk textInk(color, FW_kRGBWhite, FW_kOr);
  722.     
  723.     FW_CStaticText* view = FW_NEW(FW_CStaticText, (ev, superview, fBounds, fIdentifier, text, font,
  724.                                                                     options, textInk));
  725. //    view->SetBindings(ev, fBindings);
  726.  
  727.     return view;    
  728. }
  729.  
  730. //----------------------------------------------------------------------------------------
  731. //    FW_CMAEditText::FW_CMAEditText
  732. //----------------------------------------------------------------------------------------
  733.  
  734. FW_CMAEditText::FW_CMAEditText(ResType type) :
  735.     FW_CMAStaticText(type)
  736. {    
  737.     // A TEditText cannot be the content view
  738.     fIsContentView = false;
  739. }
  740.  
  741. //----------------------------------------------------------------------------------------
  742. //    FW_CMAEditText::ReadFields
  743. //----------------------------------------------------------------------------------------
  744.  
  745. void FW_CMAEditText::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  746. {
  747.     inherited::ReadFields(ev, stream);
  748.  
  749.     // Read in TEditText fields
  750.     long controlChars;
  751.     
  752.     stream >> fMaxChars;
  753.     stream >> controlChars;                // ignored by ODF
  754. }
  755.  
  756. //----------------------------------------------------------------------------------------
  757. //    FW_CMAEditText::Create
  758. //----------------------------------------------------------------------------------------
  759.  
  760. FW_CMAObject*    FW_CMAEditText::Create(ResType type)
  761. {
  762.     return new FW_CMAEditText(type);
  763. }
  764.  
  765. //----------------------------------------------------------------------------------------
  766. //    FW_CMAEditText::CreateODFView
  767. //----------------------------------------------------------------------------------------
  768.  
  769. FW_CView*    FW_CMAEditText::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  770. {
  771. FW_UNUSED(receiver);
  772.     FW_CFont font;
  773.     FW_CColor color;
  774.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  775.     FW_CString text((char *)&fText[1], (FW_ByteCount)fText[0]);
  776.  
  777.     unsigned short attributes = FW_CEditView::kDrawBox + FW_CEditView::kAutoScroll;
  778.     if (fAutoWrap)
  779.         attributes += FW_CEditView::kWordWrap;
  780.     
  781.     FW_CEditView* view = FW_NEW(FW_CEditView, (ev, superview, fBounds, fIdentifier, text, 
  782.                                                 font, fMaxChars, attributes));
  783. //    view->SetBindings(ev, fBindings);
  784.  
  785.     return view;    
  786. }
  787.  
  788. //----------------------------------------------------------------------------------------
  789. //    FW_CMATEView::FW_CMATEView
  790. //----------------------------------------------------------------------------------------
  791.  
  792. FW_CMATEView::FW_CMATEView(ResType type) :
  793.     FW_CMAView(type)
  794. {    
  795.     // A TTEView cannot be the content view
  796.     fIsContentView = false;
  797. }
  798.  
  799. //----------------------------------------------------------------------------------------
  800. //    FW_CMATEView::ReadFields
  801. //----------------------------------------------------------------------------------------
  802.  
  803. void FW_CMATEView::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  804. {
  805.     inherited::ReadFields(ev, stream);
  806.  
  807.     // Read in TTEView fields
  808.     Boolean styleType, acceptsChanges, freeText, preferOutline;
  809.     long    commandNumber;
  810.     VRect    inset;
  811.     short     justification;
  812.     
  813.     stream >> styleType >> fAutoWrap;
  814.     stream >> acceptsChanges >> freeText;            // ignored by ODF    
  815.     stream >> commandNumber;                        // ignored by ODF    
  816.     stream >> fMaxChars;
  817.     stream.Read(&inset, sizeof(VRect));                // ignored by ODF
  818.     stream >> justification;                        // ignored by ODF
  819.     stream >> fTextStyleID;
  820.     stream >> preferOutline;
  821.     
  822. }
  823.  
  824. //----------------------------------------------------------------------------------------
  825. //    FW_CMATEView::Create
  826. //----------------------------------------------------------------------------------------
  827.  
  828. FW_CMAObject*    FW_CMATEView::Create(ResType type)
  829. {
  830.     return new FW_CMATEView(type);
  831. }
  832.  
  833. //----------------------------------------------------------------------------------------
  834. //    FW_CMATEView::CreateODFView
  835. //----------------------------------------------------------------------------------------
  836.  
  837. FW_CView*    FW_CMATEView::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  838. {
  839. FW_UNUSED(receiver);
  840.     FW_CFont font;
  841.     FW_CColor color;
  842.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  843.     FW_CString text("");
  844.  
  845.     unsigned short attributes = FW_CEditView::kDrawBox + FW_CEditView::kAutoScroll;
  846.     if (fAutoWrap)
  847.         attributes += FW_CEditView::kWordWrap;
  848.     
  849.     FW_CEditView* view = FW_NEW(FW_CEditView, (ev, superview, fBounds, fIdentifier, text, 
  850.                                                 font, fMaxChars, attributes));
  851. //    view->SetBindings(ev, fBindings);
  852.  
  853.     // Reset the scroller global to 0 to "pretend" that we used it
  854.     // (if we don't do it we'll get an ASSERT in ReadFrom)
  855.     FW_CMacAppReader::gScroller = 0;
  856.  
  857.     return view;    
  858. }
  859.  
  860. //----------------------------------------------------------------------------------------
  861. //    FW_CMACluster::FW_CMACluster
  862. //----------------------------------------------------------------------------------------
  863.  
  864. FW_CMACluster::FW_CMACluster(ResType type) :
  865.     FW_CMAControl(type)
  866. {    
  867. }
  868.  
  869. //----------------------------------------------------------------------------------------
  870. //    FW_CMACluster::ReadFields
  871. //----------------------------------------------------------------------------------------
  872.  
  873. void FW_CMACluster::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  874. {
  875.     inherited::ReadFields(ev, stream);
  876.  
  877.     // Read in Cluster fields
  878.     short    strListID, index;
  879.     
  880.     stream >> strListID >> index;
  881.     
  882.     if (strListID != -1)                // retrieve the label from a STR# resource
  883.         ::GetIndString(fLabel, strListID, index);
  884.     else
  885.         fLabel[0] = 0;
  886. }
  887.  
  888. //----------------------------------------------------------------------------------------
  889. //    FW_CMACluster::Create
  890. //----------------------------------------------------------------------------------------
  891.  
  892. FW_CMAObject*    FW_CMACluster::Create(ResType type)
  893. {
  894.     return new FW_CMACluster(type);
  895. }
  896.  
  897. //----------------------------------------------------------------------------------------
  898. //    FW_CMACluster::CreateODFView
  899. //----------------------------------------------------------------------------------------
  900. // MacApp's TCluster combines ODF GroupBox and RadioCluster objects. We only create the
  901. // FW_CGroupBox here.  See hack in FW_CMAView::ReadFrom to handle RadioClusters...
  902.  
  903. FW_CView*    FW_CMACluster::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  904. {
  905. FW_UNUSED(receiver);
  906.     FW_CFont font;
  907.     FW_CColor color;
  908.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  909.  
  910.     FW_TextBoxOptions options = FW_kTextBoxClipToBox | FW_kTextBoxWordWrap;
  911.     FW_CString label((char *)&fLabel[1], (FW_ByteCount)fLabel[0]);
  912.     FW_CInk textInk(color, FW_kRGBWhite, FW_kOr);
  913.     
  914.     FW_CGroupBox* view = FW_NEW(FW_CGroupBox, (ev, superview, fBounds, fIdentifier, label, font, 
  915.                                             options, textInk, color));
  916. //    view->SetBindings(ev, fBindings);
  917.  
  918.     return view;    
  919. }
  920.  
  921. //----------------------------------------------------------------------------------------
  922. //    FW_CMAControl::FW_CMAControl
  923. //----------------------------------------------------------------------------------------
  924.  
  925. FW_CMAControl::FW_CMAControl(ResType type) :
  926.     FW_CMAView(type),
  927.     fTextStyleID(-1)
  928. {    
  929. }
  930.  
  931. //----------------------------------------------------------------------------------------
  932. //    FW_CMAControl::ReadFields
  933. //----------------------------------------------------------------------------------------
  934.  
  935. void FW_CMAControl::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  936. {
  937.     inherited::ReadFields(ev, stream);
  938.  
  939.     // Read TControl fields
  940.  
  941.     Boolean hiliteState, dimState, sizeable;
  942.     VRect itsInset;
  943.     Boolean preferOutline;
  944.     
  945.     stream >> fEventNumber;                                
  946.     stream >> hiliteState >> dimState >> sizeable;        // ignored by ODF
  947.     stream.Read(&itsInset, sizeof(VRect));                // ignored by ODF
  948.     stream >> fTextStyleID;
  949.     stream >> preferOutline;                            // ignored by ODF
  950. }
  951.  
  952. //----------------------------------------------------------------------------------------
  953. //    FW_CMAControl::Create
  954. //----------------------------------------------------------------------------------------
  955.  
  956. FW_CMAObject*    FW_CMAControl::Create(ResType type)
  957. {
  958.     return new FW_CMAControl(type);
  959. }
  960.  
  961. //----------------------------------------------------------------------------------------
  962. //    FW_CMAControl::CreateODFView
  963. //----------------------------------------------------------------------------------------
  964.  
  965. FW_CView*    FW_CMAControl::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  966. {
  967. FW_UNUSED(receiver);
  968.     // A MacApp TControl cannot be mapped to the pure virtual ODF FW_CControl
  969.     // so we create a FW_CUnknownView instead
  970.     FW_CString name((char*)&fClassID, 4);
  971.     FW_CUnknownView* view = FW_NEW(FW_CUnknownView, (ev, superview, fIdentifier, fBounds, name));
  972.  
  973. //    view->SetBindings(ev, fBindings);
  974.  
  975.     return view;    
  976. }
  977.  
  978. //----------------------------------------------------------------------------------------
  979. //    FW_CMAButton::FW_CMAButton
  980. //----------------------------------------------------------------------------------------
  981.  
  982. FW_CMAButton::FW_CMAButton(ResType type) :
  983.     FW_CMAControl(type),
  984.     fIsOn(0)
  985. {
  986.     // A button cannot be the content view
  987.     fIsContentView = false;
  988. }
  989.  
  990. //----------------------------------------------------------------------------------------
  991. //    FW_CMAButton::ReadFields
  992. //----------------------------------------------------------------------------------------
  993.  
  994. void FW_CMAButton::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  995. {
  996.     inherited::ReadFields(ev, stream);
  997.  
  998.     // Combines TButton, TCheckBox and TRadio fields here
  999.  
  1000.     short    strListID, index;
  1001.     
  1002.     if (fClassID == kStdButton)
  1003.     {
  1004.         fKind = FW_kPushButton;
  1005.     }
  1006.     else
  1007.     {
  1008.         stream >> fIsOn;                // only for TRadio and TCheckBox
  1009.         if (fClassID == kStdCheckBox)
  1010.             fKind = FW_kCheckButton;
  1011.         else
  1012.             fKind = FW_kRadioButton;
  1013.     }
  1014.     
  1015.     stream >> strListID >> index;
  1016.     
  1017.     if (strListID != -1)                // retrieve the buttons's label from a STR# resource
  1018.         ::GetIndString(fLabel, strListID, index);
  1019.     else
  1020.         fLabel[0] = 0;
  1021.         
  1022.     // Convert all MacApp default button events to the ODF default FW_kButtonPressedMsg
  1023.     
  1024.     if (fEventNumber == mButtonHit || fEventNumber == mCheckBoxHit || fEventNumber == mRadioHit)
  1025.         fEventNumber = FW_kButtonPressedMsg;    
  1026.  
  1027.     // Special case of default and cancel buttons in dialogs
  1028.     
  1029.     if (FW_CMacAppReader::gDefaultButtonID != 0 &&
  1030.             FW_CMacAppReader::gDefaultButtonID == fIdentifier &&
  1031.             fKind == FW_kPushButton)
  1032.     {
  1033.         fKind = FW_kDefaultPushButton;
  1034.         fEventNumber = FW_kDefaultButtonMsg;
  1035.         FW_CMacAppReader::gDefaultButtonID = 0; 
  1036.     }
  1037.     if (FW_CMacAppReader::gCancelButtonID != 0 &&
  1038.             FW_CMacAppReader::gCancelButtonID == fIdentifier &&
  1039.             fKind == FW_kPushButton)
  1040.     {
  1041.         fEventNumber = FW_kCancelButtonMsg;
  1042.         FW_CMacAppReader::gCancelButtonID = 0; 
  1043.     }
  1044. }
  1045.  
  1046. //----------------------------------------------------------------------------------------
  1047. //    FW_CMAButton::Create
  1048. //----------------------------------------------------------------------------------------
  1049.  
  1050. FW_CMAObject*    FW_CMAButton::Create(ResType type)
  1051. {
  1052.     return new FW_CMAButton(type);
  1053. }
  1054.  
  1055. //----------------------------------------------------------------------------------------
  1056. //    FW_CMAButton::CreateODFView
  1057. //----------------------------------------------------------------------------------------
  1058.  
  1059. FW_CView*    FW_CMAButton::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  1060. {
  1061.     FW_CFont font;
  1062.     FW_CColor color;
  1063.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  1064.  
  1065.     FW_ControlValue value = fIsOn ? 1 : 0;
  1066.     FW_CString label((char *)&fLabel[1], (FW_ByteCount)fLabel[0]);
  1067.  
  1068.     FW_CButton* view = FW_NEW(FW_CButton, 
  1069.                 (ev, superview, fBounds, fIdentifier, fKind, label, font, fEventNumber, value));
  1070. //    view->SetBindings(ev, fBindings);
  1071.  
  1072.     // Connect our new button to the supplied receiver
  1073.     if (receiver)
  1074.         view->LinkControlTo(ev, receiver);
  1075.     
  1076.     // Radio buttons are usually connected to clusters too
  1077.     if (fKind == FW_kRadioButton)
  1078.     {
  1079.         if (FW_CMacAppReader::gCluster == 0)
  1080.         {
  1081.             // Rare case where there is not Cluster preceding the radio button in the 
  1082.             // stream.  We create one on the fly, it will be used by other radio buttons
  1083.             // at the same level of this one.
  1084.             FW_CMacAppReader::gCluster = FW_NEW(FW_CRadioCluster, (ev));
  1085.         }
  1086.         FW_CMacAppReader::gCluster->AddRadio(ev, view);
  1087.     }
  1088.     
  1089.     return view;
  1090. }
  1091.  
  1092. //----------------------------------------------------------------------------------------
  1093. //    FW_CMAPopupMenu::FW_CMAPopupMenu
  1094. //----------------------------------------------------------------------------------------
  1095.  
  1096. FW_CMAPopupMenu::FW_CMAPopupMenu(ResType type) :
  1097.     FW_CMAControl(type)
  1098. {
  1099.     // A popup cannot be the content view
  1100.     fIsContentView = false;
  1101. }
  1102.  
  1103. //----------------------------------------------------------------------------------------
  1104. //    FW_CMAPopupMenu::ReadFields
  1105. //----------------------------------------------------------------------------------------
  1106.  
  1107. void FW_CMAPopupMenu::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  1108. {
  1109.     inherited::ReadFields(ev, stream);
  1110.  
  1111.     // Read in Popup fields
  1112.     short titleJust;
  1113.     char  titleStyle;
  1114.     short strListID, index;
  1115.     
  1116.     stream >> fMenuID >> fCurrentItem >> fLabelWidth;
  1117.     stream >> titleStyle >> titleJust;                    // not used by ODF
  1118.     stream >> fUseAddResMenu >> fUseAddResMenuResType;
  1119.     stream >> strListID >> index;
  1120.     
  1121.     if (strListID != -1)        // retrieve the buttons's label from a STR# resource
  1122.         ::GetIndString(fLabel, strListID, index);
  1123.     else
  1124.         fLabel[0] = 0;            // ODF doesn't try to get the label from the MenuRef itself
  1125.  
  1126. }
  1127.  
  1128. //----------------------------------------------------------------------------------------
  1129. //    FW_CMAPopupMenu::Create
  1130. //----------------------------------------------------------------------------------------
  1131.  
  1132. FW_CMAObject*    FW_CMAPopupMenu::Create(ResType type)
  1133. {
  1134.     return new FW_CMAPopupMenu(type);
  1135. }
  1136.  
  1137. //----------------------------------------------------------------------------------------
  1138. //    FW_CMAPopupMenu::CreateODFView
  1139. //----------------------------------------------------------------------------------------
  1140.  
  1141. FW_CView*    FW_CMAPopupMenu::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  1142. {
  1143.     FW_CFont font;
  1144.     FW_CColor color;
  1145.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  1146.     FW_CString label((char *)&fLabel[1], (FW_ByteCount)fLabel[0]);
  1147.     FW_PopupMenuStyle popupVariation =  fUseAddResMenu ? popupUseAddResMenu : 0;
  1148.     long popupRefCon = fUseAddResMenu ? fUseAddResMenuResType : 0;
  1149.     
  1150.     // MenuID and titleWidth were stored in the MinValue & MaxValue fields of Control
  1151.     FW_CPopupMenu* view = FW_NEW(FW_CPopupMenu, (ev, superview, fBounds, fIdentifier,
  1152.              fMenuID, label, fLabelWidth, fCurrentItem, popupVariation, font, popupRefCon));
  1153. //    view->SetBindings(ev, fBindings);
  1154.  
  1155.     // Connect our new popup to the supplied receiver
  1156.     if (receiver)
  1157.         view->LinkControlTo(ev, receiver);
  1158.  
  1159.     return view;    
  1160. }
  1161.  
  1162. //----------------------------------------------------------------------------------------
  1163. //    FW_CMAScrollBarScroller::FW_CMAScrollBarScroller
  1164. //----------------------------------------------------------------------------------------
  1165.  
  1166. FW_CMAScrollBarScroller::FW_CMAScrollBarScroller(ResType type) :
  1167.     FW_CMAView(type),
  1168.     fODFScroller(0),
  1169.     fLiveScrolling(false)
  1170. {
  1171.     // Use globale variable also as a flag for the next view in the stream which will
  1172.     // be the scrolling view;
  1173.     FW_CMacAppReader::gScroller = this;
  1174.  
  1175.     fIsScroller = true;
  1176. }
  1177.  
  1178. //----------------------------------------------------------------------------------------
  1179. //    FW_CMAScrollBarScroller::ReadFields
  1180. //----------------------------------------------------------------------------------------
  1181.  
  1182. void FW_CMAScrollBarScroller::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  1183. {
  1184.     inherited::ReadFields(ev, stream);
  1185.  
  1186.     // Read in TScroller fields
  1187.     VPoint scrollLimits, scrollUnits;
  1188.     Boolean    vertConstraint, horzConstraint;
  1189.     Boolean respondsToFunctionKeys;
  1190.     
  1191.     stream >>fVertSbID >> fHorzSbID;
  1192.     stream.Read(&scrollLimits, sizeof(VPoint));            // SEE LATER
  1193.     stream.Read(&scrollUnits, sizeof(VPoint));            // SEE LATER
  1194.     stream >>     vertConstraint >> horzConstraint;        // not used by ODF
  1195.     stream.Read(&fSBarOffsets, sizeof(VRect));
  1196.     stream >> respondsToFunctionKeys;                    // not used by ODF
  1197. }
  1198.  
  1199. //----------------------------------------------------------------------------------------
  1200. //    FW_CMAScrollBarScroller::Create
  1201. //----------------------------------------------------------------------------------------
  1202.  
  1203. FW_CMAObject*    FW_CMAScrollBarScroller::Create(ResType type)
  1204. {
  1205.     return new FW_CMAScrollBarScroller(type);
  1206. }
  1207.  
  1208. //----------------------------------------------------------------------------------------
  1209. //    FW_CMAScrollBarScroller::CreateODFView
  1210. //----------------------------------------------------------------------------------------
  1211.  
  1212. FW_CView*    FW_CMAScrollBarScroller::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  1213. {
  1214. FW_UNUSED(ev);
  1215. FW_UNUSED(receiver);
  1216.     // We defer the creation of the ODF scroller when we read the next view in the stream,
  1217.     // which must be the scrolling view.  This allows to handle list boxes.
  1218.  
  1219.     return superview;
  1220. }
  1221.  
  1222. //----------------------------------------------------------------------------------------
  1223. //    FW_CMATextGridView::FW_CMATextGridView
  1224. //----------------------------------------------------------------------------------------
  1225.  
  1226. FW_CMATextGridView::FW_CMATextGridView(ResType type) :
  1227.     FW_CMAView(type)
  1228. {
  1229.     // A TTextGridView cannot be the content view
  1230.     fIsContentView = false;
  1231. }
  1232.  
  1233. //----------------------------------------------------------------------------------------
  1234. //    FW_CMATextGridView::ReadFields
  1235. //----------------------------------------------------------------------------------------
  1236.  
  1237. void FW_CMATextGridView::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  1238. {
  1239.     inherited::ReadFields(ev, stream);
  1240.  
  1241.     // We read first the TGridView fields since FW_CMATextGridView derives from FW_MAView
  1242.     // (no need to use a FW_CMAGridView class until ODF supports multi-column lists)
  1243.  
  1244.     short    numOfCols, rowHeight, colWidth, rowInset, colInset;
  1245.     Boolean    adornRows, adornCols;
  1246.     
  1247.     stream >> fNumOfRows;
  1248.     stream >> numOfCols;                                        // ignored by ODF
  1249.     stream >> rowHeight >> colWidth >> rowInset >> colInset;    // ignored by ODF
  1250.     stream >> adornRows >> adornCols;                            // ignored by ODF
  1251.     stream >> fSingleSelection;
  1252.     
  1253.     // Read now the TTextGridView fields
  1254.     
  1255.     Boolean preferOutlineFont;
  1256.     
  1257.     stream >> fTextStyleID;
  1258.     stream >> preferOutlineFont;                                // ignored by ODF
  1259. }
  1260.  
  1261. //----------------------------------------------------------------------------------------
  1262. //    FW_CMATextGridView::Create
  1263. //----------------------------------------------------------------------------------------
  1264.  
  1265. FW_CMAObject*    FW_CMATextGridView::Create(ResType type)
  1266. {
  1267.     return new FW_CMATextGridView(type);
  1268. }
  1269.  
  1270. //----------------------------------------------------------------------------------------
  1271. //    FW_CMATextGridView::CreateODFView
  1272. //----------------------------------------------------------------------------------------
  1273.  
  1274. FW_CView*    FW_CMATextGridView::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  1275. {
  1276. FW_UNUSED(receiver);
  1277.     FW_CFont font;
  1278.     FW_CColor color;
  1279.     FW_CMacAppReader::GetTextStyle(fTextStyleID, font, color);
  1280.     
  1281.     // Adjust fBounds to include the vertical scrollbar
  1282.     fBounds.right += FW_IntToFixed(16);
  1283.     
  1284.     // Create the ODF listbox
  1285.     // (vertical SB, dbl-click message and focus frame are hard coded)
  1286.     FW_CListBox* view = FW_NEW(FW_CListBox, (ev, superview, fBounds, fIdentifier, fNumOfRows, 
  1287.                 true, font, FW_kListBoxDoubleClickedMsg, fSingleSelection, true, false));
  1288. //    view->SetBindings(ev, fBindings);
  1289.  
  1290.     // Reset the scroller globale to 0 to show that we used it
  1291.     FW_CMacAppReader::gScroller = 0;
  1292.     
  1293.     return view;    
  1294. }
  1295.  
  1296. //----------------------------------------------------------------------------------------
  1297. //    FW_CMAPictSView::FW_CMAPictSView
  1298. //----------------------------------------------------------------------------------------
  1299.  
  1300. FW_CMAPictSView::FW_CMAPictSView(ResType type) :
  1301.     FW_CMAControl(type),
  1302.     fPictID(-1)
  1303. {
  1304. }
  1305.  
  1306. //----------------------------------------------------------------------------------------
  1307. //    FW_CMAPictSView::ReadFields
  1308. //----------------------------------------------------------------------------------------
  1309.  
  1310. void FW_CMAPictSView::ReadFields(Environment* ev, FW_CReadableStream& stream) 
  1311. {
  1312.     inherited::ReadFields(ev, stream);
  1313.  
  1314.     // Read in TPicture fields
  1315.     stream >> fPictID;
  1316. }
  1317.  
  1318. //----------------------------------------------------------------------------------------
  1319. //    FW_CMAPictSView::Create
  1320. //----------------------------------------------------------------------------------------
  1321.  
  1322. FW_CMAObject*    FW_CMAPictSView::Create(ResType type)
  1323. {
  1324.     return new FW_CMAPictSView(type);
  1325. }
  1326.  
  1327. //----------------------------------------------------------------------------------------
  1328. //    FW_CMAPictSView::CreateODFView
  1329. //----------------------------------------------------------------------------------------
  1330.  
  1331. FW_CView*    FW_CMAPictSView::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  1332. {
  1333. FW_UNUSED(receiver);
  1334.     // Load the Mac picture resource manually instead of using FW_CPicture API because
  1335.     // we don't have the resource file here
  1336.     FW_PlatformPict    macPictHdl = ::GetPicture(fPictID);
  1337.     FW_CPictSView* view;
  1338.     
  1339.     if (macPictHdl)
  1340.     {
  1341.         // Must detach the resource manually because we loaded it manually
  1342.         ::DetachResource((Handle)macPictHdl);
  1343.         
  1344.         // Create the FW_CPictSView view
  1345.         view = FW_NEW(FW_CPictSView, (ev, superview, fBounds, fIdentifier, 
  1346.                                                     FW_CPicture(macPictHdl)));
  1347.     }
  1348.     else
  1349.     {
  1350.         // If the picture cannot be loaded here we create a FW_CPictSView with the same
  1351.         // pict ID, the FW_CPictSView class will display an error message
  1352.         view = FW_NEW(FW_CPictSView, (ev, superview, fBounds, fIdentifier, fPictID));
  1353.     }
  1354. //        view->SetBindings(ev, fBindings);
  1355.  
  1356.     return view;    
  1357. }
  1358.  
  1359. //----------------------------------------------------------------------------------------
  1360. //    FW_CMAUnknownView::FW_CMAUnknownView
  1361. //----------------------------------------------------------------------------------------
  1362. FW_DEFINE_AUTO(FW_CMAUnknownView)
  1363.  
  1364. FW_CMAUnknownView::FW_CMAUnknownView(ResType type, FW_CString& name) :
  1365.     FW_CMAView(type),
  1366.     fName(name)
  1367. {
  1368. }
  1369.  
  1370. //----------------------------------------------------------------------------------------
  1371. //    FW_CMAUnknownView::Create
  1372. //----------------------------------------------------------------------------------------
  1373.  
  1374. FW_CMAObject*    FW_CMAUnknownView::Create(ResType type, FW_CString& name)
  1375. {
  1376.     return FW_NEW(FW_CMAUnknownView, (type, name));
  1377. }
  1378.  
  1379. //----------------------------------------------------------------------------------------
  1380. //    FW_CMAUnknownView::CreateODFView
  1381. //----------------------------------------------------------------------------------------
  1382.  
  1383. FW_CView*    FW_CMAUnknownView::CreateODFView(Environment* ev, FW_CSuperView* superview, FW_MReceiver* receiver)
  1384. {
  1385. FW_UNUSED(receiver);
  1386.     FW_CUnknownView* view = FW_NEW(FW_CUnknownView, (ev, superview, fIdentifier, fBounds, fName));
  1387. //    view->SetBindings(ev, fBindings);
  1388.  
  1389.     return view;
  1390. }
  1391.  
  1392.  
  1393.