home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / bento / headers / part.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-02  |  18.0 KB  |  581 lines

  1. /*
  2.     File:        XMPPart.h
  3.  
  4.     Contains:    Class definition for XMPPart
  5.  
  6.     Written by:    Joshua Susser
  7.  
  8.     Protocols:    DragAndDrop, Embedding, Frames, Imaging, Linking,
  9.                 Memory Management, Part Activation, Storage, UI Events, Undo
  10.  
  11.     Copyright:    ⌐ 1993 by Apple Computer, Inc., all rights reserved.
  12.  
  13.     Change History (most recent first):
  14.  
  15.         <34>      2/2/94    JBS        removed sourceFrame from AddDisplayFrame();
  16.                                     added AttachSourceFrame()
  17.         <33>      2/2/94    NP        Added methods for new linking protocol
  18.                                     APIs.
  19.         <32>      2/1/94    CC        Added RevealLink method.
  20.         <31>     1/31/94    JBS        added GetPrintResolution()
  21.         <30>     1/27/94    VL        Changed CloneTo to CloneInto.
  22.         <29>     1/24/94    CC        Added XMPChangeID parameter to
  23.                                     LinkUpdated().
  24.         <28>     1/20/94    SS        ::Open returns a window id
  25.         <27>     1/11/94    Té        Init... changes
  26.         <26>    12/21/93    JBS        add viewType and presentation calls
  27.         <25>    12/16/93    JBS        added RevealFrame(), EmbeddedFrameSpec(),
  28.                                     CanvasUpdated()
  29.         <24>    12/13/93    Té        InitPart changes
  30.         <23>    12/12/93    Té        Added ExternalizeKinds, and ChangeKind
  31.         <22>    11/30/93    LM        Added an XMPFrame parameter to ReadPartInfo
  32.         <21>    11/16/93    RR        Added AdjustMenus (not yet called), and
  33.                                     MouseWithin. Removed point from MouseLeave
  34.         <20>    11/15/93    CC        Changed parms of CreateLink() to XMPPtr &
  35.                                     XMPULong
  36.         <19>    11/12/93    JBS        use Facets
  37.         <18>    10/21/93    PH        Change FulfillPromise call
  38.         <17>    10/18/93    CG        Put con/de-structor defs back the way they
  39.                                     were.
  40.         <16>    10/14/93    RR        Added sourceFrame parameter to
  41.                                     AddDisplayFrame
  42.         <15>    10/12/93    PH        Remove DragDrop.h
  43.         <13>     10/7/93    CG        ASLM wants constructor impl in .cp.
  44.         <12>     10/6/93    JBS        remove fSession field; inline
  45.                                     con/de-structor
  46.         <11>     9/30/93    PH        Add support for multiple drag items
  47.         <10>     9/29/93    VL        Added InitializePersistent.
  48.          <9>      8/9/93    NP        Added class id string.
  49.          <8>      8/6/93    JBS        add HighlightChanged() method
  50.          <7>     7/21/93    NP        Added a virtual keyword (temporary for
  51.                                     ASLM).
  52.          <6>      7/9/93    JBS        replaced with prototype version
  53.          <5>     6/23/93    RCR        Use Tokenized strings
  54.          <4>     4/29/93    Té        change names of includefiles
  55.          <3>     4/21/93    JBS        remove fSU; add friend class
  56.                                     XMPEmbeddedFramesIterator
  57.          <2>      4/13/93    RCR        Removed XMPInclude.h
  58.          <1>      4/9/93    JBS        first checked in
  59. */
  60.  
  61. #ifndef _PART_
  62. #define _PART_
  63.  
  64. #ifndef _PLFMDEF_
  65. #include "PlfmDef.h"
  66. #endif
  67.  
  68. #ifndef _PSTOBJ_
  69. #include "PstObj.h"
  70. #endif
  71.  
  72. #ifndef _XMPTYPES_
  73. #include "XMPTypes.h"
  74. #endif
  75.  
  76. #ifndef _DRAFT_
  77. #include "Draft.h"    // For XMPDraftKey
  78. #endif
  79.  
  80.  
  81. //==============================================================================
  82. // Theory of Operation
  83. //==============================================================================
  84.  
  85. /*
  86.     This file defines class XMPPart.  Part behavior is implemented in Part
  87.     Handlers.  A given Handler may handle many Parts, but there is one XMPPart
  88.     instance for each individual Part.
  89. */
  90.  
  91. //==============================================================================
  92. // Constants
  93. //==============================================================================
  94.  
  95. const XMPID kNewGroup = 0;
  96.  
  97. //==============================================================================
  98. // Classes defined in this interface
  99. //==============================================================================
  100.  
  101. class XMPPart;
  102. class XMPEmbeddedFramesIterator;
  103.  
  104. //==============================================================================
  105. // Classes used by this interface
  106. //==============================================================================
  107.  
  108. class XMPCanvas;
  109. class XMPFacet;
  110. class XMPFrame;
  111. class XMPLink;
  112. class XMPPersistentObject;
  113. class XMPShape;
  114. class XMPStorageUnit;
  115. class XMPStorageUnitView;
  116. class XMPTransform;
  117. class XMPDragItemIterator;
  118. class XMPSession;
  119. class XMPTypeSet;
  120.  
  121. struct XMPPoint;
  122.  
  123. //==============================================================================
  124. // XMPPart
  125. //==============================================================================
  126.  
  127. #define kXMPPartID "appl:part$class,1.0.0"
  128.  
  129. class XMPPart : public XMPPersistentObject
  130. {
  131.     friend class XMPDraft;
  132.     friend class XMPEmbeddedFramesIterator;
  133.  
  134. public:
  135.  
  136.     //-------------------------------------------------------------------------
  137.     // From DragAndDrop protocol
  138.     //-------------------------------------------------------------------------
  139.  
  140.     XMPVMethod void FulfillPromise(XMPStorageUnitView *promiseSUView)
  141.         = 0;
  142.     
  143.         // fulfills a promise which has been put out.
  144.     
  145.     XMPVMethod void DropCompleted(XMPPart* destPart, XMPDropResult dropResult)
  146.         = 0;
  147.         
  148.         // NotifyDropComplete is a peculiar method. If DragAndDrop::StartDrag 
  149.         // is synchronous, the return code to DragAndDrop::StartDrag is the 
  150.         // drop result. Part::NotifyDropComplete does not need to be called. 
  151.         // However, if it is required that DragAndDrop::StartDrag returns
  152.         // immediately, there needs to be a way to notify the result of 
  153.         // the drop.
  154.  
  155.     XMPVMethod void DragEnter(XMPDragItemIterator* dragInfo,
  156.                               XMPFacet* facet,
  157.                               XMPPoint where)
  158.         = 0;
  159.  
  160.         // the mouse has entered a frame of this part during a drag
  161.  
  162.     XMPVMethod void DragWithin(XMPDragItemIterator* dragInfo,
  163.                                XMPFacet* facet,
  164.                                XMPPoint where)
  165.         = 0;
  166.  
  167.         // the mouse has moved in a frame of this part during a drag
  168.  
  169.     XMPVMethod void DragLeave(XMPFacet* facet,
  170.                               XMPPoint where)
  171.         = 0;
  172.  
  173.         // the mouse has left a frame of this part during a drag
  174.  
  175.     XMPVMethod XMPDropResult Drop(XMPDragItemIterator* dropInfo,
  176.                                   XMPFacet* facet,
  177.                                   XMPPoint where)
  178.         = 0;
  179.  
  180.         // dragging finished, something was dropped in a frame of this part
  181.  
  182.     //-------------------------------------------------------------------------
  183.     // From Embedding protocol
  184.     //-------------------------------------------------------------------------
  185.  
  186.     XMPVMethod void ContainingPartPropertiesChanged(XMPFrame* frame,
  187.                                                     XMPStorageUnit* propertyUnit)
  188.         = 0;
  189.  
  190.         // Used by my ContainingPart to inform me of changes to content
  191.         // properties of its proxy for me.
  192.  
  193.     // ********* for containing parts *********
  194.  
  195.     XMPVMethod XMPStorageUnit* GetContainingPartProperties(XMPFrame* frame)
  196.         = 0;
  197.  
  198.         // Used by an embedded Part to ask me of changes to content
  199.         // properties of my proxy for it.
  200.  
  201.     XMPVMethod void RevealFrame(XMPFrame* embeddedFrame)
  202.         = 0;
  203.         
  204.         // scroll my contents to reveal an embedded frame.
  205.         // ask my containing part to help if I'm not revealed yet.
  206.  
  207.     XMPVMethod void EmbeddedFrameSpec(XMPFrame* embeddedFrame, XMPObjectSpec* spec)
  208.         = 0;
  209.         
  210.         // construct an object specifier describing an embedded frame.
  211.         // ask my containing part to help by constructing a specifier
  212.         // for my display frame
  213.  
  214.     XMPVMethod XMPEmbeddedFramesIterator* CreateEmbeddedFramesIterator()
  215.         = 0;
  216.  
  217.         // create and return an iterator for my embedded frames list
  218.  
  219.     //-------------------------------------------------------------------------
  220.     // From Frames protocol
  221.     //-------------------------------------------------------------------------
  222.  
  223.     XMPVMethod void AddDisplayFrame(XMPFrame* frame)
  224.         = 0;
  225.  
  226.         // add a new frame viewing the part
  227.  
  228.     XMPVMethod void AttachSourceFrame(XMPFrame* frame, XMPFrame* sourceFrame)
  229.         = 0;
  230.  
  231.         // If sourceFrame is not NULL, this part should replicate the embedded
  232.         // frames of sourceFrame in the new frame
  233.  
  234.     XMPVMethod void RemoveDisplayFrame(XMPFrame* frame)
  235.         = 0;
  236.  
  237.         // remove a frame viewing the part
  238.  
  239.     XMPVMethod void CloseDisplayFrame(XMPFrame* frame)
  240.         = 0;
  241.  
  242.         // close embedded frames in specified display frame
  243.  
  244.     XMPVMethod void FrameShapeChanged(XMPFrame* frame)
  245.         = 0;
  246.  
  247.         // inform the part that a view of it has been reshaped
  248.  
  249.     XMPVMethod void ViewTypeChanged(XMPFrame* frame)
  250.         = 0;
  251.  
  252.         // change the type of view in one of my frames
  253.         // may be used to collapse a "frame view" into an "icon view"
  254.  
  255.     XMPVMethod void PresentationChanged(XMPFrame* frame)
  256.         = 0;
  257.  
  258.         // change the kind of presentation in one of my frames
  259.         // used to distinguish between content/palette/dialog/etc.
  260.         // part may correct frame's presentation if not supported
  261.  
  262.     XMPVMethod void WritePartInfo(XMPPtr partInfo,
  263.                                   XMPStorageUnitView* storageUnitView)
  264.         = 0;
  265.  
  266.         // write out the partInfo data onto a pre-focused StorageUnitView
  267.  
  268.     XMPVMethod XMPPtr ReadPartInfo(XMPFrame* frame, XMPStorageUnitView* storageUnitView)
  269.         = 0;
  270.  
  271.         // read the partInfo data from a pre-focused StorageUnitView
  272.  
  273.     XMPVMethod XMPID Open(XMPFrame* frame)
  274.         = 0;
  275.  
  276.         // open a window and add a display frame for me into it
  277.         // if frame == nil, open in a new frame
  278.         // return ID of the window created
  279.  
  280.     //---------------------------------
  281.     // for containing parts
  282.  
  283.     XMPVMethod XMPFrame* CreateEmbeddedFrame(XMPFrame* containingFrame,
  284.                                              XMPShape* frameShape,
  285.                                              XMPTransform* externalTransform,
  286.                                              XMPPart* embedPart,
  287.                                              XMPTypeToken viewType,
  288.                                              XMPTypeToken presentation,
  289.                                              XMPID frameGroupID,
  290.                                              XMPBoolean isOverlaid)
  291.         = 0;
  292.  
  293.         // create a new frame and embed a part in it.
  294.         
  295.     XMPVMethod void RemoveEmbeddedFrame(XMPFrame* embeddedFrame)
  296.         = 0;
  297.  
  298.         // remove a frame viewing an embedded part
  299.  
  300.     XMPVMethod XMPShape* RequestFrameShape(XMPFrame* embeddedFrame, XMPShape* frameShape)
  301.         = 0;
  302.  
  303.         // an embedded part asks to change the shape of its frame
  304.  
  305.     XMPVMethod void UsedShapeChanged(XMPFrame* embeddedFrame)
  306.         = 0;
  307.  
  308.         // inform the part that a view of it has been reshaped
  309.  
  310.     XMPVMethod XMPShape* AdjustBorderShape(XMPFrame* embeddedFrame, XMPShape* shape)
  311.         = 0;
  312.  
  313.         // adjust the display of the active frame border of an
  314.         // embedded frame.  shape param is requsted shape. return
  315.         // value is that shape obscured by other contents.
  316.  
  317.     //-------------------------------------------------------------------------
  318.     // From Facet protocol
  319.     //-------------------------------------------------------------------------
  320.  
  321.     XMPVMethod void FacetAdded(XMPFacet* facet)
  322.         = 0;
  323.  
  324.         // inform the part that a facet has been added to one of its frames
  325.  
  326.     XMPVMethod void FacetRemoved(XMPFacet* facet)
  327.         = 0;
  328.  
  329.         // inform the part that a facet has been removed from one of its frames
  330.  
  331.     XMPVMethod void ClipShapeChanged(XMPFacet* facet)
  332.         = 0;
  333.  
  334.         // inform the part that a view of it has been re-clipped
  335.  
  336.     XMPVMethod void ExternalTransformChanged(XMPFacet* facet)
  337.         = 0;
  338.  
  339.         // inform the part that a view of it has been re-positioned
  340.  
  341.     //-------------------------------------------------------------------------
  342.     // From Imaging protocol
  343.     //-------------------------------------------------------------------------
  344.  
  345.     XMPVMethod void Draw(XMPFacet* facet, XMPShape* invalidShape)
  346.         = 0;
  347.  
  348.         // image the part in the specified facet of one of its frames
  349.         // only pixels in the invalidShape need to be painted
  350.  
  351.     XMPVMethod void CanvasUpdated(XMPCanvas* canvas)
  352.         = 0 ;
  353.  
  354.         // the canvas has been drawn on asynchronously. this part is
  355.         // the owner of the canvas, so it must copy the bits up to
  356.         // the parent canvas.
  357.  
  358.     XMPVMethod void HighlightChanged(XMPFrame* frame)
  359.         = 0 ;
  360.  
  361.         // notification that the highlight state of a display frame
  362.         // of this part has been changed.  part can get new value
  363.         // with frame->GetHightlight().
  364.  
  365.     XMPVMethod XMPULong GetPrintResolution(XMPFrame* frame)
  366.         = 0 ;
  367.  
  368.         // answer the resolution in dots per inch the part requires
  369.         // to image the specified frame on a printer canvas
  370.  
  371.     //-------------------------------------------------------------------------
  372.     // From Linking protocol
  373.     //-------------------------------------------------------------------------
  374.  
  375.     XMPVMethod XMPLink* CreateLink(XMPPtr data, XMPULong size)
  376.             = 0;
  377.  
  378.         // create a new link object, put in the initial data
  379.         // and return it to the caller.
  380.         // This call to be implemented for the real or proxy source part
  381.         // created by the destination part. 
  382.  
  383.     XMPVMethod void LinkUpdated(XMPLink* updatedLink, XMPChangeID id)
  384.             = 0;
  385.  
  386.         // the specified link has been updated, please read and use
  387.         // the incoming data.
  388.         // The link object makes this call.
  389.  
  390.     XMPVMethod void RevealLink(XMPLinkSource* linkSource)
  391.             = 0;
  392.  
  393.     XMPVMethod void    EmbeddedFrameChanged(XMPFrame* frame, XMPChangeID change)
  394.             = 0;
  395.  
  396.     XMPVMethod void    LinkStatusChanged(XMPFrame* frame)
  397.             = 0;
  398.  
  399.     //-------------------------------------------------------------------------
  400.     // From Part Activation protocol
  401.     //-------------------------------------------------------------------------
  402.  
  403.     XMPVMethod XMPBoolean BeginRelinquishFocus(XMPTypeToken focus,
  404.                                                XMPFrame* ownerFrame,
  405.                                                XMPFrame* proposedFrame)
  406.             = 0;
  407.  
  408.         // Default is to return TRUE
  409.         
  410.     XMPVMethod void CommitRelinquishFocus(XMPTypeToken focus, 
  411.                                           XMPFrame* ownerFrame,
  412.                                           XMPFrame* proposedFrame)
  413.             = 0;
  414.                             
  415.         // Must succeed
  416.         // If part of proposedFrame is self then flicker can be avoided by doing nothing
  417.         
  418.     XMPVMethod void AbortRelinquishFocus(XMPTypeToken focus,
  419.                                          XMPFrame* ownerFrame,
  420.                                          XMPFrame* proposedFrame)
  421.             = 0;
  422.                                   
  423.         // Default is a noop
  424.         // Part handlers must implement this if they do more in the Prepare method
  425.         // than simply return TRUE
  426.         // For example, a part requests a focus set owned by several different parts.
  427.         // One part is downloading some data. It is willing to stop downloading, but if other
  428.         // parts refuse to relinquish their focus set, the downloading part would like to resume
  429.         // downloading.
  430.  
  431.     XMPVMethod void FocusAcquired(XMPTypeToken focus,
  432.                                   XMPFrame* ownerFrame)
  433.             = 0;
  434.     
  435.         // A notification to the part that one of its frames has acquired
  436.         // the specified focus set
  437.         // Called when a document is opened, for example
  438.  
  439.     XMPVMethod void FocusLost(XMPTypeToken focus,
  440.                               XMPFrame* ownerFrame)
  441.             = 0;
  442.                                     
  443.         // A notification to the part that a focus has been forcibly removed from it.
  444.         // This might be done because a communication connection has been broken, for example    
  445.                 
  446.  
  447.     //-------------------------------------------------------------------------
  448.     // From Storage protocol
  449.     //-------------------------------------------------------------------------
  450.  
  451.     XMPVMethod void CloneInto(XMPDraftKey key, XMPStorageUnit* storageUnit, XMPStorageUnit* initiatingFrame)
  452.         = 0;
  453.  
  454.         // copy this part to another storage unit
  455.         
  456.     //-------------------------------------------------------------------------
  457.     // From Binding protocol
  458.     //-------------------------------------------------------------------------
  459.  
  460.     XMPVMethod void ExternalizeKinds(XMPTypeSet* kindset)
  461.         = 0;
  462.  
  463.         // Externalize all of the kinds in kindset that this part know how to
  464.  
  465.     XMPVMethod void ChangeKind(XMPType kind)
  466.         = 0;
  467.  
  468.         // Set the preferred kind of the part to 'kind' and perform whatever 
  469.         // storage operations necessary
  470.         
  471.     //-------------------------------------------------------------------------
  472.     // From UI Events protocol
  473.     //-------------------------------------------------------------------------
  474.  
  475.     XMPVMethod XMPBoolean HandleEvent(XMPEventData event,
  476.                                       XMPFrame* frame,
  477.                                       XMPFacet* facet)
  478.         = 0;
  479.  
  480.         // some event happened in one of my frames.  answer whether i handled it.
  481.                 
  482.     XMPVMethod void MouseEnter(XMPFacet* facet, XMPPoint where)
  483.         = 0;
  484.     
  485.         // Called when the mouse is moved over a facet (mouse button up)
  486.  
  487.     XMPVMethod void MouseWithin(XMPFacet* facet, XMPPoint where)
  488.         = 0;
  489.     
  490.         // Called when the mouse is moved within a facet (mouse button up)
  491.             
  492.     XMPVMethod void MouseLeave(XMPFacet* facet)
  493.         = 0;
  494.     
  495.         // Called when the mouse is moved out of a facet (mouse button up)
  496.  
  497.     XMPVMethod void AdjustMenus(XMPFrame* frame)
  498.         = 0;
  499.         
  500.         // Called by the shell (on Macintosh), just before calling MenuSelect
  501.         // or MenuKey, so that the part can enable/disable items
  502.  
  503.     //-------------------------------------------------------------------------
  504.     // From Undo protocol
  505.     //-------------------------------------------------------------------------
  506.  
  507.     XMPVMethod void UndoAction(XMPActionData actionState)
  508.         = 0;
  509.  
  510.         // Tells the part to Undo the action described by actionState
  511.         
  512.     XMPVMethod void RedoAction(XMPActionData actionState)
  513.         = 0;
  514.  
  515.         // Tells the part to Redo the action described by actionState
  516.     
  517.     XMPVMethod void DisposeActionState(XMPActionData actionState,
  518.                                        XMPDoneState doneState)
  519.         = 0;
  520.  
  521.         // Tells the part to dispose of the action data.
  522.         // itsDoneState is kDone or kReDone if the action was on the document's,
  523.         // Undo stack and kUndone if it was on the Redo stack
  524.     
  525.     XMPVMethod void WriteActionState(XMPPtr actionState,
  526.                                      XMPStorageUnitView* storageUnitView)
  527.         = 0;
  528.  
  529.         // write out the actionState data onto a pre-focused StorageUnitView
  530.  
  531.     XMPVMethod XMPPtr ReadActionState(XMPStorageUnitView* storageUnitView)
  532.         = 0;
  533.  
  534.         // read the actionState data from a pre-focused StorageUnitView
  535.  
  536. protected:
  537.  
  538.     //-------------------------------------------------------------------------
  539.     // constructors/destructors
  540.     //-------------------------------------------------------------------------
  541.  
  542.     XMPPart();
  543.  
  544.         // constructor - called only by XMPDraft
  545.  
  546.     virtual ~XMPPart();
  547.  
  548.         // destructor - called only by XMPDraft
  549.         
  550.     XMPVMethod void InitPart(XMPStorageUnit* storageUnit)
  551.         = 0;
  552.         
  553.         // first time initializer - called only by XMPDraft
  554.         
  555.     XMPVMethod void InitPartFromStorage(XMPStorageUnit* storageUnit)
  556.         = 0;
  557.  
  558.         // persistent store initializer - called only by XMPDraft
  559. };
  560.  
  561.  
  562. //==============================================================================
  563. // XMPEmbeddedFramesIterator
  564. //==============================================================================
  565.  
  566. class XMPEmbeddedFramesIterator
  567. {
  568.  
  569. public:
  570.  
  571.     //-------------------------------------------------------------------------
  572.     // from Embedding protocol:
  573.     //-------------------------------------------------------------------------
  574.  
  575.     XMPVMethod XMPFrame*    First() = 0;
  576.     XMPVMethod XMPFrame*    Next() = 0;
  577.     XMPVMethod XMPBoolean    IsNotComplete() = 0;
  578. };
  579.  
  580. #endif // _PART_
  581.