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

  1. /*
  2.     File:        Facet.h
  3.  
  4.     Contains:    Definition of class XMPAbsFacet
  5.  
  6.     Written by:    Joshua Susser
  7.  
  8.     Copyright:    ⌐ 1993 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <11>     2/16/94    JA        Stop including Point.h.
  13.         <10>      2/3/94    JA        Tiger Team Makeover!
  14.          <9>     1/24/94    SS        Checkin for Joshua (see below)
  15.          <8+>     1/13/94    JBS        active border displays fActiveShape
  16.                                        added offscreen canvas support
  17.          <8>    12/21/93    JBS        removed Initialize()
  18.          <7>    12/15/93    JBS        add fActiveShape & fWindow, plus accessors
  19.          <6>     12/3/93    Té        return XMPFacet* from CreateEmebeddedFacet
  20.          <5>    11/19/93    PH        Add virtual keyword and fix for ASLM
  21.          <4>    11/18/93    JBS        remove fWindow, add mouse tracking
  22.          <3>    11/16/93    JBS        add child drawing and moving methods
  23.          <2>    11/16/93    JBS        add fIsSelected and fHighlight
  24.          <1>    11/12/93    JBS        first checked in
  25. */
  26.  
  27. #ifndef _FACET_
  28. #define _FACET_
  29.  
  30. #ifndef _XMPTYPES_
  31. #include "XMPTypes.h"
  32. #endif
  33.  
  34. #ifndef _XMPOBJ_
  35. #include "XMPObj.h"
  36. #endif
  37.  
  38. //=====================================================================================
  39. // Theory of Operation
  40. //=====================================================================================
  41.  
  42. /*
  43.     Facets hold the ephemeral information associated with the display of
  44.     a particular Frame.
  45. */
  46.  
  47. //==============================================================================
  48. // Types
  49. //==============================================================================
  50.  
  51. typedef enum {
  52.     kXMPNoHighlight = 0,
  53.     kXMPFullHighlight,
  54.     kXMPDimHighlight
  55. } XMPHighlight;
  56.  
  57. //=====================================================================================
  58. // Classes defined in this interface
  59. //=====================================================================================
  60.  
  61. class XMPAbsFacet;
  62. class XMPFacetIterator;
  63.  
  64. //=====================================================================================
  65. // Classes used by this interface
  66. //=====================================================================================
  67.  
  68. class XMPFacet;
  69. class FacetNode;
  70. class List;
  71. class NodeTraverser;
  72. class XMPCanvas;
  73. class XMPDragItemIterator;
  74. class XMPFrame;
  75. class XMPObject;
  76. class XMPShape;
  77. class XMPTransform;
  78. class XMPWindow;
  79.  
  80. //=====================================================================================
  81. // XMPAbsFacet
  82. //=====================================================================================
  83.  
  84. class XMPAbsFacet : public XMPObject
  85. {
  86.     friend class XMPFacetIterator;
  87.  
  88. public:
  89.     
  90.     //---------------------------------
  91.     // constructor
  92.  
  93.     XMPAbsFacet() {}
  94.             
  95.     XMPVMethod ~XMPAbsFacet() {}
  96.     
  97.     XMPVMethod XMPSize Purge(XMPSize size)
  98.         = 0;
  99.     
  100.     //---------------------------------
  101.     // frames
  102.  
  103.     XMPVMethod XMPFrame* GetFrame()
  104.         = 0;
  105.  
  106.     XMPVMethod XMPFacet* CreateEmbeddedFacet(XMPFrame* frame,
  107.                             XMPShape* clipShape, XMPTransform* externalTransform,
  108.                             XMPFacet* siblingFacet, XMPFramePosition position)
  109.         = 0;
  110.         // Add a frame to my list of visible facets, creating a new Facet for it
  111.                 
  112.     XMPVMethod void RemoveFacet(XMPFacet* facet)
  113.         = 0;
  114.         // Remove a facet which is no longer visible. 
  115.  
  116.     XMPVMethod void MoveBefore(XMPFacet* child, XMPFacet* sibling)
  117.         = 0;
  118.         // Move child facet to be in front of sibling.
  119.         // If sibling is NULL, move child to front of all children.
  120.  
  121.     XMPVMethod void MoveBehind(XMPFacet* child, XMPFacet* sibling)
  122.         = 0;
  123.         // Move child facet to be in back of sibling.
  124.         // If sibling is NULL, move child to back of all children.
  125.  
  126.     XMPVMethod XMPFacet* GetContainingFacet()
  127.         = 0;
  128.     
  129.     XMPVMethod XMPFacetIterator* CreateFacetIterator(XMPTraversalType traversalType, 
  130.                                                      XMPSiblingOrder siblingOrder)
  131.         = 0;
  132.  
  133.     //---------------------------------
  134.     // clip shape
  135.     
  136.     XMPVMethod XMPShape* GetClipShape()
  137.         = 0;
  138.  
  139.     XMPVMethod void ChangeClipShape(XMPShape* clipShape)
  140.         = 0;
  141.         // set the value of my clip shape and notify my part
  142.  
  143.     XMPVMethod XMPShape* GetAggregateClipShape()
  144.         = 0;
  145.         // returns clipShape clipped to all containing
  146.         // frames' clipShapes on facet's canvas
  147.  
  148.     XMPVMethod XMPShape* GetWindowAggregateClipShape()
  149.         = 0;
  150.         // returns clipShape clipped to all containing
  151.         // frames' clipShapes in facet's window
  152.  
  153.     XMPVMethod void InvalidateAggregateClipShape()
  154.         = 0;
  155.  
  156.     //---------------------------------
  157.     // active shape
  158.     
  159.     XMPVMethod XMPShape* GetActiveShape()
  160.         = 0;
  161.  
  162.     XMPVMethod void ChangeActiveShape(XMPShape* activeShape)
  163.         = 0;
  164.         // set the value of my active shape
  165.  
  166.     //---------------------------------
  167.     // transformations:
  168.  
  169.     XMPVMethod XMPTransform* GetExternalTransform()
  170.         = 0;
  171.  
  172.     XMPVMethod void ChangeExternalTransform(XMPTransform* transform)
  173.         = 0;
  174.         // if current fExternalTransform differs from new transform, then
  175.         // invalidate the cached external and internal aggregate transforms
  176.         // and also for all contained frames.
  177.  
  178.     XMPVMethod void InternalTransformChanged()
  179.         = 0;
  180.         // notify me that my frame's internalTransform changed
  181.         // I need to invalidate my content transforms, and
  182.         // my children's transforms as well
  183.  
  184.     XMPVMethod XMPTransform* GetFrameTransform()
  185.         = 0;
  186.  
  187.     XMPVMethod XMPTransform* GetContentTransform()
  188.         = 0;
  189.  
  190.     XMPVMethod XMPTransform* GetWindowFrameTransform()
  191.         = 0;
  192.  
  193.     XMPVMethod XMPTransform* GetWindowContentTransform()
  194.         = 0;
  195.  
  196.     XMPVMethod void InvalidateAggregateTransforms()
  197.         = 0;
  198.  
  199.     //---------------------------------
  200.     // canvas
  201.  
  202.     XMPVMethod XMPBoolean HasCanvas()
  203.         = 0;
  204.         // return whether this facet has its own canvas
  205.         // (as opposed to using its parent's)
  206.  
  207.     XMPVMethod XMPCanvas* GetCanvas()
  208.         = 0;
  209.         // return my canvas.  if fCanvas is NULL, return my parent's canvas.
  210.  
  211.     XMPVMethod void SetCanvas(XMPCanvas* canvas)
  212.         = 0;
  213.  
  214.     //---------------------------------
  215.     // window
  216.  
  217.     XMPVMethod XMPWindow* GetWindow()
  218.         = 0;
  219.         // return my window - if NULL, inherit from containing facet
  220.  
  221.     XMPVMethod void SetWindow(XMPWindow* window)
  222.         = 0;
  223.         // only root facets should have a window
  224.  
  225.     //---------------------------------
  226.     // PartInfo
  227.  
  228.     XMPVMethod XMPInfoType GetPartInfo()
  229.         = 0;
  230.  
  231.     XMPVMethod void SetPartInfo(XMPInfoType partInfo)
  232.         = 0;
  233.  
  234.     //---------------------------------
  235.     // drag&drop
  236.  
  237.     XMPVMethod void DragEnter(XMPPoint point, XMPDragItemIterator* dragInfo)
  238.         = 0;
  239.         // point in window coordinates
  240.  
  241.     XMPVMethod void DragWithin(XMPPoint point, XMPDragItemIterator* dragInfo)
  242.         = 0;
  243.         // point in window coordinates
  244.  
  245.     XMPVMethod void DragLeave(XMPPoint point)
  246.         = 0;
  247.         // point in window coordinates
  248.  
  249.     XMPVMethod XMPDropResult Drop(XMPPoint point, XMPDragItemIterator* dropInfo)
  250.         = 0;
  251.         // point in window coordinates
  252.  
  253.     //---------------------------------
  254.     // drawing
  255.  
  256.     XMPVMethod void Update(XMPShape* invalidShape)
  257.         = 0;
  258.         // draw any of (me + children) intersecting invalidShape
  259.  
  260.     XMPVMethod void Invalidate(XMPShape* invalidShape)
  261.         = 0;
  262.         // tell underlying graphics system to invalidate the area in invalidShape.
  263.         // invalidShape is in my frame's coordinate system
  264.  
  265.     XMPVMethod void Validate(XMPShape* validShape)
  266.         = 0;
  267.         // tell underlying graphics system to validate the area in validShape.
  268.         // validShape is in my frame's coordinate system
  269.  
  270.     XMPVMethod void Draw(XMPShape* invalidShape)
  271.         = 0;
  272.         // Asks my frame's part to draw its contents within my clipShape
  273.         // clipped to the transformed invalidShape on my frame's canvas
  274.  
  275.     XMPVMethod void DrawChildren(XMPShape* invalidShape)
  276.         = 0;
  277.         // Draw all of my child facets which need updating, and all of their
  278.         // children too.
  279.  
  280.     XMPVMethod void DrawChildrenAlways(XMPShape* invalidShape)
  281.         = 0;
  282.         // Force drawing of all of my child facets, and all of their children too.
  283.  
  284.     XMPVMethod void DrawnIn(XMPShape* shape)
  285.         = 0;
  286.         // mark shape as having been drawn in, but not in response to
  287.         // an update event.  notify owner of canvas to update parent
  288.         // canvas with altered contents
  289.  
  290.     XMPVMethod void InvalidateActiveBorder()
  291.         = 0;
  292.  
  293.     XMPVMethod void DrawActiveBorder()
  294.         = 0;
  295.  
  296.     //---------------------------------
  297.     // mouse tracking and hit detection:
  298.  
  299.     XMPVMethod void MouseEnter(XMPPoint where)
  300.         = 0;
  301.         // Called when the mouse is moved over a facet (mouse button up)
  302.         // Transform point to facet coords and pass to part
  303.  
  304.     XMPVMethod void MouseWithin(XMPPoint where)
  305.         = 0;
  306.         // Called when the mouse is moved within a facet (mouse button up)
  307.         // Transform point to facet coords and pass to part
  308.             
  309.     XMPVMethod void MouseLeave()
  310.         = 0;
  311.         // Called when the mouse is moved out of a facet (mouse button up)
  312.  
  313.     XMPVMethod XMPBoolean ContainsPoint(XMPPoint point)
  314.         = 0;
  315.         // within activeShape ^ clipShape
  316.         // point in window coordinate space
  317.  
  318.     XMPVMethod XMPBoolean ActiveBorderContainsPoint(XMPPoint point)
  319.         = 0;
  320.         // within active border shape
  321.         // point in window coordinate space
  322.  
  323.     //---------------------------------
  324.     // selection and highlighting:
  325.  
  326.     XMPVMethod XMPBoolean IsSelected()
  327.         = 0;
  328.         // return selection state
  329.  
  330.     XMPVMethod void SetSelected(XMPBoolean isSelected)
  331.         = 0;
  332.         // set selection state
  333.  
  334.     XMPVMethod XMPHighlight    GetHighlight()
  335.         = 0;
  336.         // return highlight state
  337.     
  338.     XMPVMethod void ChangeHighlight(XMPHighlight highlight)
  339.         = 0;
  340.         // Change the highlight state of this facet.
  341.  
  342.  
  343. protected:
  344.  
  345.     XMPVMethod FacetNode* GetNode()
  346.         = 0;
  347.  
  348.     XMPVMethod XMPBoolean NeedsUpdate()
  349.         = 0;
  350.  
  351.     XMPVMethod void SetNeedsUpdate(XMPBoolean needsUpdate)
  352.         = 0;
  353. };
  354.  
  355.  
  356. //=====================================================================================
  357. // XMPFacetIterator
  358. //=====================================================================================
  359.  
  360. #define kXMPFacetIteratorID "appl:xmpfacetiterator$class,1.0.0"
  361.  
  362. class XMPFacetIterator
  363. {
  364.  
  365. public:
  366.  
  367.     XMPFacetIterator(XMPFacet* facet,
  368.                      XMPTraversalType traversalType, 
  369.                      XMPSiblingOrder siblingOrder);
  370.  
  371.     virtual ~XMPFacetIterator();
  372.     
  373.     XMPMethod XMPFacet* First();
  374.     
  375.         // Returns the first visible facet in traversal order.
  376.     
  377.     XMPMethod XMPFacet* Next();
  378.     
  379.         // Returns the next visible facet in traversal order.
  380.         // Step transparently into nested Canvases.
  381.     
  382.     XMPMethod void SkipChildren();
  383.     
  384.         // advance past all the children of the current facet.
  385.         // only has an effect for kXMPTopDown traversalType.
  386.  
  387.     XMPMethod XMPBoolean IsNotComplete();
  388.     
  389.         // Returns TRUE as long as there are more facets
  390.  
  391. private:
  392.  
  393.     XMPFacet*            fFacet;
  394.      XMPTraversalType    fTraversalType;
  395.      XMPSiblingOrder        fSiblingOrder;
  396.     NodeTraverser*        fNodeTraverser;
  397. };
  398.  
  399. #if PLATFORM_MACINTOSH
  400. #ifndef _FACETM_
  401. #include "FacetM.h"
  402. #endif
  403. #endif
  404.  
  405. #endif // _FACET_
  406.