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

  1. /*
  2.     File:        XMPFrame.h
  3.  
  4.     Contains:    Definition of class XMPFrame
  5.  
  6.     Written by:    Joshua Susser & Sepp Friedrich
  7.  
  8.     Copyright:    ⌐ 1993 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <29>     2/14/94    JBS        RADAR bug# 1143608 - remove SetRoot(),
  13.                                     SetOverlaid(), fUsesCachedImage & accessors
  14.         <28>      2/2/94    RR        Added isRoot to InitFrame
  15.         <27>      2/2/94    NP        Added methods and XMPLinkStatus type for
  16.                                     new linking protocol APIs.
  17.         <26>     1/27/94    VL        Added CloneTo.
  18.         <25>     1/15/94    VL        Added fGettingPart to prevent recursive
  19.                                     GetPart.
  20.         <24>     1/13/94    JBS        add fIsSubframe, IsSubframe(),
  21.                                     SetSubframe()
  22.         <23>     1/11/94    Té        Init... changes
  23.         <22>    12/21/93    JBS        InitFrame with viewType & presentation
  24.         <21>    12/15/93    JBS        remove fActiveShape, fWindow
  25.         <20>    12/14/93    Té        InitFrame changes
  26.         <19>    11/19/93    PH        Add virtual keyword and fix for ASLM
  27.         <18>    11/18/93    JBS        add fWindow and accessors
  28.         <17>    11/16/93    JBS        remove fHighlight, add fViewType and
  29.                                     get/set
  30.         <16>    11/12/93    JBS        use Facets
  31.         <15>    10/12/93    PH        Remove DragDrop.h
  32.         <14>     9/30/93    PH        Support new Drag and Drop protocol
  33.         <13>     9/29/93    Té        with RCR, added Close()
  34.         <12>     9/29/93    VL        Added InitializePersistent.
  35.         <11>     9/21/93    PH        Remove De/RegisterDroppableFrame
  36.         <10>     9/17/93    JBS        added fIsDroppable & fIsDragging &
  37.                                     get/setters
  38.          <9>      9/3/93    JBS        removed fWindow, fCanvas; added fLayout
  39.          <8>     8/10/93    PH        Add release
  40.          <7>      8/9/93    NP        Added class id string.
  41.          <6>      8/6/93    JBS        add fHighlight and related methods
  42.          <5>      7/8/93    JBS        replaced with prototype version
  43.  
  44.         <45>     5/13/93    JBS        add ChangeActiveShape()
  45.         <44>      5/7/93    JBS        namesmith
  46.         <43>     4/29/93    JBS        8.3 file names
  47.         <42>     4/28/93    JBS        8.3 file names
  48.         <39>     4/19/93    NP        NameSmithing.
  49.         <38>     4/19/93    NP        NameSmithing.
  50.         <37>     4/19/93    NP        Namesmithing.
  51.         <36>      4/1/93    SF        privatized constructor/destructor/initialize                    
  52.         <35>      4/1/93    SF        Updated "Theory of Operation"
  53.         <34>     3/30/93    SF        Correct constructor/Internalize usage and removal of Restore
  54.         <33>     3/29/93    SF        new GetAggregateClipShape().
  55.         <32>     3/29/93    JBS        add IntersectClipShape()
  56.         <31>     3/23/93    SF        subclass of XMPObject
  57.         <30>     3/22/93    SF        Creation broke up into XMPFrame(), Initialize / Restore
  58.         <29>     3/19/93    SF        Changed ChangedFrameShape to ChangeFrameShape ChangedUsedShape
  59.                                     to ChangeUseShape; ChangeFrameShape returns void now.
  60.         <28>     3/18/93    SF        Changed names: NotifyReshape->ChangedUsedShape;
  61.                                     Reshape->ChangedFrameShape; Added: RequestFrameShape
  62.         <27>     3/11/93    SF        Removed fCachedPresentation, XMPImage, fInvalidShape, and
  63.                                     Get/SetCachedRepresentation
  64.         <26>     3/11/93    SF        Reshape returns a Shape
  65.         <25>     3/10/93    SF        don't know any more
  66.         <24>      3/2/93    SF        Removed 2 creation function; made remaining creators temporarly
  67.                                     public for Window.cp and ContainingPartRCR.cp
  68.         <23>      3/2/93    SF        update with March 1 API documentation
  69.         <22>     2/26/93    TIé        remove partInfo from XMPFrame constructor
  70.         <21>     2/25/93    VL        XMPFrame::DragLeave takes the mouse position now.
  71.         <20>      2/9/93    SF        Added creation: XMPFrame(XMPStorageUnit* su); changed
  72.                                     GetFrameID() to GetID();
  73.         <19>      2/3/93    SF        Fixed comments.
  74.         <17>      2/3/93    SF        Added "Theory of Operation"
  75.         <16>      2/2/93    SF        remove XMPDisplayFramesIterator()
  76.         <15>      2/2/93    SF        Added protected GetStorageUnit() and GetFrameID(); removed class
  77.                                     XMPEmbeddedFrameIterator;
  78.         <14>      2/1/93    RCR        Merge with prototype shell
  79.         <13>     1/29/93    SF        Changed fInvalid to fCachedTransfomValid + extended usage text
  80.                                     for InvalidateCachedTransform();
  81.         <12>     1/28/93    SF        Changed "...FrameIterator" to "...FramesIterator"
  82.         <11>     1/27/93    SF        Adopt to Richard's JediShell: temporary create
  83.         <10>     1/27/93    SF        return value of Purge: XMPSize; cached transform is now the
  84.                                     composite transform of contained frames with the contained
  85.                                     frame's Inner and this frame's External transfom.
  86.          <9>     1/26/93    VL        Changed __XXXX__ to _XXXX_.
  87.          <8>     1/21/93    SF        Added comments about what to change
  88.          <7>     1/20/93    SF        Added Internalize/Externalize, simple Draw(),
  89.                                      fFrozen, fDisplayMyImage ("as is" and don't
  90.                                     call partHandler). creation/destruction
  91.                                     became protected. friend class XMPDraft.
  92.                                     StorageUnit added to creation parameters.
  93.          <6>     1/16/93    SF        Added creation parameters. Removed get/set
  94.                                      for embedded frames.
  95.                                     Added size parameter for purging. Updated
  96.                                     XMPEmbeddedFrameIterator class.
  97.          <5>     1/12/93    SF        Added class XMPEmbeddedFrameIterator and 
  98.                                     creator function in XMPFrame.
  99.          <4>     1/11/93    SF        Moved XMPXform to platform types.
  100.          <3>     1/10/93    SF        Cosmetics
  101.          <2>      1/7/93    SF        Changed headers, names ...
  102.          <1>    12/22/92    SF        first checked in
  103. */
  104.  
  105. #ifndef _FRAME_
  106. #define _FRAME_
  107.  
  108. #ifndef _PSTOBJ_
  109. #include "PstObj.h"    // base class
  110. #endif
  111.  
  112. #ifndef _XMPTYPES_
  113. #include "XMPTypes.h"
  114. #endif
  115.  
  116. #ifndef _DRAFT_
  117. #include "Draft.h"    // For XMPDraftKey
  118. #endif
  119.  
  120. //==============================================================================
  121. // Theory of Operation
  122. //==============================================================================
  123. /*
  124. If an XMPPart╒s contents needs to become visible, it provides to the embedding
  125. XMPPart an XMPFrame with a desired frameShape and an XMPCanvas,  in which╒
  126. coordinate space the frameShape is defined, and an XMPWindow, in which
  127. eventually the XMPPart╒s contents will be rendered.
  128.  
  129. The embedding XMPPart╒s Part Handler then reshapes the XMPFrame╒s bounding
  130. FrameShape and also sets the ClipShape to be used for clipping drawings or
  131. cached images rendered within the XMPFrame.  It also decides about proper
  132. alignment within its own space and, therefore, sets the XMPFrame╒s External
  133. Transform (c.f. below) accordingly.
  134.  
  135. The Part Handler having created an XMPFrame object adds it to the XMPWindow╒s
  136. list of visible XMPFrames.
  137.  
  138. Invalidation concerns two cases:  an XMPFrame╒s XMPTransfom or a (partial) area
  139. of the XMPFrame can be affected as described below.
  140.  
  141. First, an XMPFrame╒s position and shape within its containing Root XMPFrame
  142. (which is equal to the XMPWindow╒s frame) is determined by its Aggregate
  143. Transfoms, which consists of the Frame╒s External and Internal Transform
  144. pre-composed with the containing Frame╒s Aggregate Transforms.  For
  145. mapping a point given in Window coordinates to a frame╒s local space, XMPFrame
  146. transforms it by using its Aggregate Internal Transform. Similarly, for
  147. representing an XMPShape object, given in a containing Frame╒s coordinate
  148. space, into this Frame╒s coordinate space, the given shape becomes transformed
  149. by applying this Frame╒s External Transform. For this release, it is required
  150. that the local coordinate spaces have the same metric as the Root Frame╒s
  151. canvas. In other words, the Frames╒ associated XMPCanvas objects must have the
  152. same type as the Root Frame╒s XMPCanvas object.  Independently, a part handler
  153. can come up with its own private canvases and mappings to the XMPCanvas object
  154. given to its XMPFrame object.
  155.  
  156. Whenever a Part Handler for a containing XMPPart changes a contained XMPFrame╒s
  157. External Transform (e.g. moving the XMPFrame to a new position) or the
  158. XMPFrame╒s own Part Handler changes the Internal Transform (e.g. scrolling the
  159. visible XMPPart  contents within the XMPFrame), the XMPFrame╒s Aggregate
  160. Transforms are invalidated or get updated.
  161.  
  162. Furthermore, to assist a containing Part Handler in finding a fine-tuned
  163. layout between adjacent contained Frames, the UsedShape, set by its Part, may
  164. be used by the embedding Part.  It describes the XMPShape of an XMPFrame which
  165. is used by its actual contents, versus the FrameShape, that reflects rather the
  166. required XMPShape as defined by the contained Part Handler.
  167.  
  168. ActiveShape, also set by this XMPFrame╒s XMPPart╒s Part Hanlder, defines the
  169. area within the UsedShape which reacts to mouse clicks which it receives when
  170. the Frame is not set to Frozen.
  171.  
  172. All Shapes are given in their Frame╒s local coordinate space.
  173. */
  174.  
  175.                               
  176. //==============================================================================
  177. // Types
  178. //==============================================================================
  179.  
  180. enum XMPLinkStatus
  181. {
  182.     kXMPInLinkDestination,
  183.     kXMPInLinkSource,
  184.     kXMPNotInLink
  185. };
  186.  
  187. //==============================================================================
  188. // Classes defined in this interface
  189. //==============================================================================
  190.  
  191. class XMPFrame;
  192. class XMPFrameFacetIterator;
  193.  
  194. //==============================================================================
  195. // Classes used by this interface
  196. //==============================================================================
  197.  
  198. class OrderedCollection;
  199. class OrderedCollectionIterator;
  200. class XMPCanvas;
  201. class XMPDraft;
  202. class XMPFacet;
  203. class XMPPart;
  204. class XMPPersistentObject;
  205. class XMPShape;
  206. class XMPStorageUnit;
  207. class XMPTransform;
  208. class XMPDragItemIterator;
  209. class XMPWindow;
  210.  
  211. struct XMPPoint;
  212.  
  213. //==============================================================================
  214. // XMPFrame
  215. //==============================================================================
  216.  
  217. #define kXMPFrameID "appl:xmpframe$class,1.0.0"
  218.  
  219. class XMPFrame : public XMPPersistentObject
  220. {
  221.     friend class XMPDraft;
  222.     friend class XMPFrameFacetIterator;
  223.  
  224. public:
  225.  
  226. // getters/setters:
  227.  
  228.     XMPVMethod XMPFrame*    GetContainingFrame();
  229.     XMPVMethod void         SetContainingFrame(XMPFrame* frame);
  230.  
  231.     XMPVMethod XMPULong        GetFrameGroup();
  232.     XMPVMethod void            SetFrameGroup(XMPULong groupID);
  233.  
  234.     XMPVMethod XMPBoolean    IsRoot();
  235.  
  236.     XMPVMethod XMPBoolean    IsSubframe();
  237.     XMPVMethod void            SetSubframe(XMPBoolean isSubframe);
  238.  
  239.     XMPVMethod XMPBoolean    IsOverlaid();
  240.  
  241.     XMPVMethod XMPBoolean    IsFrozen();
  242.     XMPVMethod void            SetFrozen(XMPBoolean isFrozen);
  243.  
  244.     XMPVMethod XMPBoolean    DoesPropagateEvents();
  245.     XMPVMethod void            SetPropagateEvents(XMPBoolean doesPropagateEvents);
  246.  
  247.  
  248. // part
  249.  
  250.     XMPVMethod XMPPart* GetPart();
  251.  
  252.     XMPVMethod void ChangePart(XMPPart* part);
  253.         // change the part this frame views
  254.  
  255.     XMPVMethod XMPInfoType    GetPartInfo();
  256.     XMPVMethod void            SetPartInfo(XMPInfoType partInfo);
  257.  
  258.     XMPVMethod XMPTypeToken GetViewType();
  259.     XMPVMethod void            SetViewType(XMPTypeToken viewType);
  260.         // should be called only by my part
  261.     XMPVMethod void            ChangeViewType(XMPTypeToken viewType);
  262.         // called by container, etc. to request part to change type
  263.  
  264.     XMPVMethod XMPTypeToken GetPresentation();
  265.     XMPVMethod void            SetPresentation(XMPTypeToken presentation);
  266.         // should be called only by my part
  267.     XMPVMethod void            ChangePresentation(XMPTypeToken presentation);
  268.         // called by container, etc. to request part to change presentation kind
  269.  
  270. // facets
  271.  
  272.     XMPVMethod void FacetAdded(XMPFacet* facet);
  273.  
  274.     XMPVMethod void FacetRemoved(XMPFacet* facet);
  275.  
  276.     XMPVMethod XMPFrameFacetIterator* CreateFacetIterator();
  277.  
  278. // shapes:
  279.  
  280.     // frame shape
  281.     
  282.     XMPVMethod XMPShape* GetFrameShape();
  283.  
  284.     XMPVMethod void ChangeFrameShape(XMPShape* shape);
  285.         // Containing Part picks a new Frame Shape for this embedded frame.
  286.  
  287.     XMPVMethod XMPShape* RequestFrameShape(XMPShape* shape);
  288.         // Embedded Part asks to change the Frame Shape for this frame.
  289.  
  290.     // used shape
  291.     
  292.     XMPVMethod XMPShape* GetUsedShape();
  293.  
  294.     XMPVMethod void ChangeUsedShape(XMPShape* shape);
  295.         // Embedded Part changes the Used Shape of this frame.
  296.  
  297. // transformations:
  298.  
  299.     XMPVMethod XMPTransform* GetInternalTransform();
  300.  
  301.     XMPVMethod void ChangeInternalTransform(XMPTransform* transform);
  302.         // change internalTransform to new value, notify facets of change
  303.  
  304. // drag&drop:
  305.  
  306.     XMPVMethod XMPBoolean    IsDroppable();
  307.     XMPVMethod void            SetDroppable(XMPBoolean isDroppable);
  308.  
  309.     XMPVMethod XMPBoolean    IsDragging();
  310.     XMPVMethod void            SetDragging(XMPBoolean isDragging);
  311.  
  312. // linking:
  313.  
  314.     XMPVMethod void                ContentChanged(XMPChangeID change);
  315.     XMPVMethod void                ChangeLinkStatus(XMPLinkStatus status);
  316.     XMPVMethod XMPLinkStatus    GetLinkStatus();
  317.  
  318. // invalidation/draw:
  319.  
  320.     XMPVMethod void Invalidate(XMPShape* invalidShape);
  321.         // invalidate the area in all my facets
  322.  
  323.     XMPVMethod void Validate(XMPShape* validShape);
  324.         // validate the area in all my facets
  325.  
  326.     XMPVMethod void InvalidateActiveBorder();
  327.         // invalidate the active border on all my facets
  328.  
  329.     XMPVMethod void DrawActiveBorder();
  330.         // draw the active border on all my facets
  331.  
  332. // memory management:
  333.  
  334.     XMPVMethod XMPSize Purge(XMPSize numBytes);        // override
  335.         //    gets rid of any unnecessary memory by purging memory blocks
  336.         //    or flushing structures out to disk.
  337.  
  338.     XMPVMethod XMPStorageUnit*    CloneTo(XMPDraftKey key, XMPDraft* destDraft);
  339.     
  340.     XMPVMethod void Externalize();                    // override
  341.  
  342. // ref counting
  343.     
  344.     XMPVMethod void Release();                        // override
  345.  
  346.     XMPVMethod void Close();
  347.         
  348.         // tell the frame to release references
  349.  
  350.     XMPVMethod void Remove();
  351.         
  352.         // tell the frame to release references and remove from Draft
  353.  
  354. protected:    // only to be called by XMPDraft
  355.  
  356.     XMPFrame();
  357.     XMPVMethod ~XMPFrame();
  358.  
  359.     XMPNVMethod void    InitFrame(
  360.                 XMPStorageUnit*    storageUnit,
  361.                 XMPFrame*         containingFrame,
  362.                 XMPShape*         frameShape,
  363.                 XMPPart*         part,
  364.                 XMPTypeToken    viewType,
  365.                 XMPTypeToken    presentation,
  366.                 XMPULong         frameGroup,
  367.                 XMPBoolean        isRoot,
  368.                 XMPBoolean         isOverlaid);
  369.                 
  370.     XMPNVMethod void    InitFrameFromStorage(XMPStorageUnit*    storageUnit);
  371.  
  372. protected:    // only to be called by XMPFrameFacetIterator
  373.  
  374.     XMPVMethod OrderedCollection* GetFacets();
  375.  
  376. protected:
  377.  
  378.     void    CommonInitFrame();
  379.  
  380.     XMPFrame*            fContainingFrame;    // parent in frame hierarchy
  381.     OrderedCollection*    fFacets;            // list of current facets
  382.  
  383.     XMPShape*        fFrameShape;            // basic shape of frame
  384.     XMPShape*        fUsedShape;                // region to wrap around
  385.  
  386.     XMPTransform*    fInternalTransform;        // viewing transform
  387.  
  388.     XMPPart*        fPart;                    // part the frame is displaying
  389.     XMPInfoType        fPartInfo;                // data type of part
  390.     XMPTypeToken    fViewType;                // type of view of part (icon, etc.)
  391.     XMPTypeToken    fPresentation;            // kind of frame (content, palette, etc.)
  392.  
  393.     XMPULong        fFrameGroup;            // ID of group this frame is in
  394.  
  395.     XMPBoolean        fIsRoot;                // is this a window's root frame?
  396.     XMPBoolean        fIsSubframe;            // is this subframe of conglomerate frame?
  397.     XMPBoolean        fIsOverlaid;            // is this an overlaid frame?
  398.     XMPBoolean        fIsFrozen;                // mouse events go to my containing frame
  399.     XMPBoolean        fIsDroppable;            // accepts drag/drop events
  400.     XMPBoolean        fIsDragging;            // is being dragged
  401.     XMPBoolean        fDoesPropagateEvents;    // frame can't handle delegated events
  402.     
  403.     XMPBoolean        fGettingPart;            // Semaphore to ensure that GetPart is not called recursively.
  404. };
  405.  
  406. //==============================================================================
  407. // XMPFrameFacetIterator
  408. //==============================================================================
  409.  
  410. #define kXMPFrameFacetIteratorID "appl:xmpframefacetiterator$class,1.0.0"
  411.  
  412. class XMPFrameFacetIterator
  413. {
  414.  
  415. public:
  416.  
  417.     XMPFrameFacetIterator(XMPFrame* frame);
  418.  
  419.     virtual ~XMPFrameFacetIterator();
  420.  
  421.     XMPVMethod XMPFacet* First();
  422.         // Returns the first visible facet
  423.     
  424.     XMPVMethod XMPFacet* Next();
  425.         // Returns the next visible facet
  426.     
  427.     XMPVMethod XMPBoolean IsNotComplete();
  428.         // Returns TRUE as long as there are more facets
  429.  
  430.     XMPFrame*                    fFrame;
  431.     OrderedCollectionIterator*    fIter;
  432. };
  433.  
  434. #endif // _XMPFRAME_
  435.