home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ibmodf.zip / CNTNRPRT.ZIP / CNTNRPRT.H < prev    next >
C/C++ Source or Header  |  1994-11-25  |  16KB  |  387 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /* COPYRIGHT:                                                                 */
  4. /* ----------                                                                 */
  5. /* Copyright (C) International Business Machines Corp., 1994.                 */
  6. /* Copyright:(C) Apple Computer, Inc., 1994                                   */
  7. /*                                                                            */  
  8. /* DISCLAIMER OF WARRANTIES:                                                  */
  9. /* -------------------------                                                  */
  10. /* The following [enclosed] code is sample code created by IBM                */
  11. /* Corporation.  This sample code is not part of any standard IBM product     */
  12. /* and is provided to you solely for the purpose of assisting you in the      */
  13. /* development of your applications.  The code is provided "AS IS",           */
  14. /* without warranty of any kind.  IBM shall not be liable for any damages     */
  15. /* arising out of your use of the sample code, even if they have been         */
  16. /* advised of the possibility of such damages.                                */
  17. /*                                                                            */
  18. /******************************************************************************/
  19. /*
  20.    File:    CntnrPrt.h
  21.  
  22.    Contains:   definition for class ContainerPart
  23.  
  24.    Written by: Joshua Susser
  25.  
  26.    Change History (most recent first):
  27.  
  28. */
  29.  
  30. #ifndef _CNTNRPRT_
  31. #define _CNTNRPRT_
  32.  
  33. #if 1
  34.    extern "C" {
  35.       class ODMenuBar;
  36.       void EXPENTRY AddMenuResourceLast( Environment *ev, HMODULE hmodDLL, long resid, ODMenuBar *menubar, ODMenuID menuid);
  37.    }
  38. #else   
  39.    #ifndef _PLFMTYPE_
  40.       #include "PlfmType.h"
  41.    #endif
  42.    
  43.    #ifndef _IBP_
  44.       #include "ibp.h"
  45.    #endif
  46.    
  47.    // define constants for type names of part classes
  48.    #ifndef _PARTTYPE_
  49.       #include "PartType.h"
  50.    #endif                   
  51.    
  52.    #ifndef __MENUS__
  53.       #include <Menus.h>
  54.    #endif
  55.    
  56.    #define APPLEINCL_QuickDraw
  57.    #ifndef APPLEINCLUDED
  58.       #include <Apple.h>
  59.    #endif
  60.    
  61.    #ifndef __DRAWDEF__
  62.       #include "DrawDef.h"
  63.    #endif
  64.                    
  65.    #ifndef _CNTNRRES_
  66.    #include "cntnrres.h"
  67.    #endif
  68.    
  69.    //==============================================================================
  70.    // Classes defined in this interface
  71.    //==============================================================================
  72.    
  73.    class ContainerPart;
  74.    class ContainerPartEmbeddedFramesIterator;
  75.    
  76.    //==============================================================================
  77.    // Classes used by this interface
  78.    //==============================================================================
  79.    
  80.    class OrderedCollection;
  81.    class OrderedCollectionIterator;
  82.    class XMPEmbeddedFramesIterator;
  83.    class XMPFacet;
  84.    class XMPFrame;
  85.    class XMPMenuBar;
  86.    class XMPFocusSet;
  87.    class XMPSemanticInterface;
  88.    class ContainerPartPropAccessor;
  89.    class XMPDragItemIterator;
  90.    class XMPWindow;
  91.    class XMPSession;
  92.    
  93.       //--------------------------------------------------------------------------
  94.       // Class Types
  95.       //--------------------------------------------------------------------------
  96.    
  97.       struct Proxy {
  98.          XMPRgnHandle region;
  99.          XMPFrame* frame;
  100.          XMPTransform* transform;
  101.          // XMPBoolean isSelected;
  102.    
  103.          Proxy(XMPRgnHandle r, XMPFrame* f, XMPTransform* t)
  104.             {region = r; frame = f; transform = t; /* isSelected = kXMPFalse; */ }
  105.       };
  106.    
  107.    //==============================================================================
  108.    // Types
  109.    //==============================================================================
  110.    
  111.       typedef RGB RGBColor;
  112.    
  113.       class PartInfoRec
  114.       {
  115.       public:
  116.          PartInfoRec() { fIsActive = kXMPFalse; fNeedsActivating = kXMPFalse; }
  117.          virtual ~PartInfoRec() { }
  118.          RGBColor bgColor;
  119.          RgnHandle   bgClipRegion;
  120.          XMPBoolean  fIsActive;  // Does this frame have its focus set?
  121.          XMPBoolean  fNeedsActivating; // should this be activated when its window is activated?
  122.       };
  123.    
  124.    //==============================================================================
  125.    // ContainerPart
  126.    //==============================================================================
  127.    
  128.    extern "C" {
  129.       XMPPart* EXPENTRY CreatePart(void);
  130.    }
  131.    
  132.    class ContainerPart : public ImplBasePart
  133.    {
  134.       //--------------------------------------------------------------------------
  135.       // Class Friends
  136.       //--------------------------------------------------------------------------
  137.    
  138.       friend class XMPDraft;
  139.       friend class ContainerPartEmbeddedFramesIterator;
  140.       friend class ContainerPartPropAccessor;
  141.    
  142.    public:
  143.    
  144.       // -Extension-
  145.       XMPMethod XMPBoolean    HasExtension(XMPType extensionName);
  146.       XMPMethod XMPExtension* GetExtension(XMPType extensionName);
  147.    
  148.       // -Drag&Drop-
  149.       XMPMethod void FulfillPromise(XMPStorageUnitView *promiseSUView);
  150.       XMPMethod void DropCompleted(XMPPart* destPart, XMPDropResult dropResult);
  151.       XMPMethod MRESULT DragEnter(XMPDragItemIterator* dragInfo, XMPFacet* facet, XMPPoint where);  //dwf
  152.       XMPMethod MRESULT DragWithin(XMPDragItemIterator* dragInfo, XMPFacet* facet, XMPPoint where);   //dwf
  153.       XMPMethod void DragLeave(XMPFacet* facet, XMPPoint where);
  154.       XMPMethod XMPDropResult Drop(XMPDragItemIterator* dropInfo, XMPFacet* facet, XMPPoint where);
  155.    
  156.       // -Embedding-
  157.       XMPMethod XMPStorageUnit* GetContainingPartProperties(XMPFrame* displayFrame);
  158.       XMPMethod XMPEmbeddedFramesIterator* CreateEmbeddedFramesIterator();
  159.       XMPMethod XMPSLong CountEmbeddedFrames();
  160.    
  161.       // -Frame-
  162.       XMPMethod void AddDisplayFrame(XMPFrame* frame);
  163.       XMPMethod void AttachSourceFrame(XMPFrame* frame, XMPFrame* sourceFrame);
  164.       XMPMethod void RemoveDisplayFrame(XMPFrame* frame);
  165.       XMPMethod void CloseDisplayFrame(XMPFrame* frame);
  166.       XMPMethod void FrameShapeChanged(XMPFrame* frame);
  167.       XMPMethod void ViewTypeChanged(XMPFrame* frame);
  168.       XMPMethod void PresentationChanged(XMPFrame* frame);
  169.       XMPMethod void WritePartInfo(XMPPtr partInfo, XMPStorageUnitView* storageUnitView);
  170.       XMPMethod XMPPtr ReadPartInfo(XMPFrame* frame, XMPStorageUnitView* storageUnitView);
  171.       XMPMethod XMPID Open(XMPFrame* frame); //Override
  172.       XMPMethod XMPFrame* CreateEmbeddedFrame(XMPFrame* containingFrame,
  173.                                     XMPShape* frameShape,
  174.                                     XMPTransform* externalTransform,
  175.                                     XMPPart* embedPart,
  176.                                     XMPTypeToken viewType,
  177.                                     XMPTypeToken presentation,
  178.                                     XMPID frameGroupID,
  179.                                     XMPBoolean isOverlaid);
  180.       XMPMethod void RemoveEmbeddedFrame(XMPFrame* embeddedFrame);
  181.       XMPMethod XMPShape* RequestFrameShape(XMPFrame* embeddedFrame, XMPShape* frameShape);
  182.       XMPMethod void UsedShapeChanged(XMPFrame* embeddedFrame);
  183.    
  184.       // -Facet-
  185.       XMPMethod void FacetAdded(XMPFacet* facet);
  186.       XMPMethod void FacetRemoved(XMPFacet* facet);
  187.       XMPMethod void ClipShapeChanged(XMPFacet* facet);
  188.       XMPMethod void ExternalTransformChanged(XMPFacet* facet);
  189.    
  190.       // -Imaging-
  191.       XMPMethod void Draw(XMPFacet* facet, XMPShape* invalidShape);
  192.    
  193.       // -Memory Management-
  194.       XMPMethod XMPSize Purge(XMPSize size);
  195.    
  196.       // -Part Activation-
  197.       XMPMethod void CommitRelinquishFocus(XMPTypeToken focus,
  198.                                    XMPFrame* ownerFrame,
  199.                                    XMPFrame* proposedFrame);
  200.       XMPMethod void FocusAcquired(XMPTypeToken focus, XMPFrame* ownerFrame);
  201.       XMPMethod void FocusLost(XMPTypeToken focus, XMPFrame* ownerFrame);
  202.    
  203.       // -Storage-
  204.       XMPMethod void Externalize();
  205.       XMPMethod void CloneInto(XMPDraftKey key, XMPStorageUnit* storageUnit, XMPStorageUnit* initiatingFrameSU);
  206.    
  207.       // -UI Events-
  208.       XMPMethod XMPBoolean HandleEvent(XMPEventData event, XMPFrame* frame, XMPFacet* facet);
  209.       XMPMethod void AdjustMenus(XMPFrame* frame);
  210.    
  211.       // -Undo-
  212.       XMPVMethod void UndoAction(XMPActionData actionState);
  213.       XMPVMethod void RedoAction(XMPActionData actionState);
  214.       XMPVMethod void DisposeActionState(XMPActionData actionState,
  215.                                  XMPDoneState doneState);
  216.    
  217.          //PRIVATE BY CONVENTION -- needed by ContainerPart's object accessors
  218.       XMPMethod XMPSemanticInterface* GetSemanticInterface(){return fSemtIntf;}
  219.       XMPMethod void SetNewBounds( XMPFrame* frame, Rect* r ) ;
  220.       XMPMethod Proxy* ProxyForFrame(XMPFrame* frame);
  221.       XMPMethod void UpdateProxyRegion(Proxy* proxy);
  222.       XMPMethod void CreateProxySelectionBorder(Proxy* p);
  223.       XMPMethod void InvalidateSelection(XMPFrame* frame);
  224.       XMPMethod void ClipEmbeddedFrames(XMPFrame* frame);
  225.    
  226.    protected:
  227.    
  228.       friend XMPPart* EXPENTRY CreatePart(void);
  229.       // -constructor/destructor-
  230.       ContainerPart();
  231.       virtual ~ContainerPart();
  232.    
  233.       // JYS: submenu stuff
  234.       static HWND hwndArrangeSubMenu;
  235.       static HWND hwndEmbedSubMenu;
  236.       static HWND hwndColorSubMenu;
  237.       static HWND hwndFrameSubMenu;
  238.       static ULONG ulRefCnt;
  239.       //JYS: end of submenu
  240.    
  241.       XMPMethod void InitPart(XMPStorageUnit* storageUnit);
  242.       XMPMethod void InitPartFromStorage(XMPStorageUnit* storageUnit);
  243.       XMPNVMethod void CommonInitContainerPart();
  244.       XMPMethod void LoadIcons();
  245.    
  246.       XMPMethod void Release();
  247.    
  248.       // -Embedding-
  249.       XMPMethod OrderedCollection* GetEmbeddedFrames();
  250.       XMPMethod Proxy* ProxyForFrameID(XMPID frameID);
  251.    
  252.       // -Imaging-
  253.       XMPMethod void HighlightSelection(XMPFacet* facet);
  254.       XMPMethod void HighlightProxyBorder(Proxy* p, XMPFacet *facet);
  255.       XMPMethod void HighlightContentObject(Proxy* p, XMPFacet* facet);
  256.       XMPMethod void ClipEmbeddedFacets(XMPFacet* facet);
  257.    
  258.       XMPMethod void EmptySelection();
  259.    
  260.       // -UI Events-
  261.       XMPMethod XMPBoolean HandleMouseDown(XMPFacet* facet,
  262.                                   XMPPoint where,
  263.                                   XMPEventData event);
  264.       XMPMethod XMPBoolean HandleMouseMove(XMPFacet* facet,
  265.                                   XMPPoint where,
  266.                                   XMPEventData event);
  267.       XMPMethod XMPBoolean HandleMouseDownDrag(XMPFacet* facet, Proxy* selection, XMPEventData event);
  268.       XMPMethod XMPBoolean HandleMouseDownEdgeResize(XMPFacet* facet, Proxy* selection, Point mouse);
  269.       XMPMethod XMPBoolean HandleMouseDownCornerResize(XMPFacet* facet, Proxy* selection, Point mouse);
  270.       XMPMethod XMPBoolean HandleMouseDownInEmbeddedFrame(XMPFacet* container,
  271.                                              XMPFacet* facet,
  272.                                              XMPPoint where,
  273.                                              XMPEventData event);
  274.       XMPMethod XMPBoolean HandleKeyDown(XMPFrame* focusFrame, XMPEventData event);
  275.       XMPMethod XMPBoolean HandleMenuEvent(XMPFrame* focusFrame, XMPEventData event);
  276.    
  277.       // -Menu Commands-
  278.       XMPMethod XMPBoolean DoCut(XMPFrame* frame);
  279.       XMPMethod XMPBoolean DoCopy(XMPFrame* frame);
  280.       XMPMethod XMPBoolean DoPaste(XMPFrame* frame);
  281.       XMPMethod XMPBoolean DoPasteLink(XMPFrame* frame);
  282.       XMPMethod XMPBoolean DoClear(XMPFrame* frame);
  283.       XMPMethod XMPBoolean DoSelectAll(XMPFrame* frame);
  284.    
  285.       // -utilities-
  286.       XMPMethod void ActivateFrame(XMPFrame* frame);
  287.       XMPMethod void DeActivateFrame(XMPFrame* frame);
  288.       XMPMethod void ActivatingWindow(XMPFrame* frame);
  289.       XMPMethod void DeActivatingWindow(XMPFrame* frame);
  290.       XMPMethod void InstallMenus(XMPFrame* aFrame);
  291.       XMPMethod void RemoveMenus(XMPFrame* aFrame);
  292.       XMPMethod void SetBGColor(XMPFrame* aFrame, XMPCommandID whichColor);
  293.       XMPMethod void UserSetBGColor(XMPFrame* frame, RGBColor whichColor);
  294.       XMPMethod void SetBGColor(XMPFrame* aFrame, RGBColor whichColor);
  295.       XMPMethod void Embed(long item, XMPFrame* frame, XMPPart** newPart=kXMPNULL);
  296.       XMPMethod void SetGrafPortOrigin(XMPFacet* facet);
  297.       XMPMethod void InvalEmbedFrameAfterResize(XMPFacet* facet, Proxy* selection,
  298.                                       XMPShape* oldShape, XMPShape* newShape,
  299.                                       Point transOffset);
  300.       XMPMethod Rect* GetSelectionRectLocal(Proxy* selection);
  301.    
  302.       XMPMethod   void CreatePalette();
  303.       XMPMethod void DestroyPalette();
  304.       XMPMethod   void ShowPalette();
  305.       XMPMethod void HidePalette();
  306.       XMPMethod void GetBGColor(XMPUShort whichColor, RGBColor* newColor);
  307.       XMPMethod XMPWindow* CreateWindow(XMPFrame* sourceFrame);
  308.    
  309.       XMPMethod XMPBoolean MoveToFront(XMPFrame* frame);
  310.       XMPMethod XMPBoolean MoveToBack(XMPFrame* frame);
  311.       XMPMethod XMPBoolean MoveForward(XMPFrame* frame);
  312.       XMPMethod XMPBoolean MoveBackward(XMPFrame* frame);
  313.    
  314.    private:
  315.       int ExtractMenuPartStrings( char * fullstring , char * * dllstring , int * dllstringlength , char * * descripstring );
  316.    
  317.       OrderedCollection*   fDisplayFrames;
  318.       OrderedCollection*   fEmbeddedFrames;
  319.       XMPID          fWindowID;        // ID of View As Window window
  320.    
  321.       XMPULong       fFrameGroupIDCounter;
  322.       Point          fDragStart;
  323.    
  324.       RGBColor        fDefaultColor; // Initial background color of all display frames
  325.       OrderedCollection*   fContents;
  326.       OrderedCollection*   fSelection;
  327.    
  328.       RgnHandle         fSelectRgn;
  329.       RgnHandle         fCornerHandleRgn;
  330.       RgnHandle         fEdgeHandleRgn;
  331.    
  332.       MenuHandle        fEmbedMenu;
  333.       MenuHandle        fColorMenu;
  334.       MenuHandle        fFrameMenu;
  335.    
  336.       XMPIcon           fLargeIcons;
  337.       XMPIcon           fSmallIcons;
  338.    
  339.       XMPMenuBar*       fMenuBar;
  340.       XMPFocusSet*      fFocusSet;
  341.       XMPTypeToken      fSelectionFocus;
  342.       XMPTypeToken      fMenuFocus;
  343.       XMPTypeToken      fKeyFocus;
  344.    
  345.       XMPSemanticInterface*   fSemtIntf;
  346.    
  347.       XMPWindow*        fPalette;
  348.       XMPBoolean        fPaletteUp;
  349.       XMPBoolean        fPaletteWasShown;
  350.    
  351.       XMPSession*       fSession;
  352.    
  353.       HPS               hpsMem;
  354.       HDC               hdcMem;
  355.    
  356.       POINTL            mouseStart;   //dwf
  357.    };
  358.    
  359.    
  360.    //==============================================================================
  361.    // ContainerPartEmbeddedFramesIterator
  362.    //==============================================================================
  363.    
  364.    class ContainerPartEmbeddedFramesIterator : public XMPEmbeddedFramesIterator
  365.    {
  366.       friend class ContainerPart;
  367.    
  368.    public:
  369.    
  370.       XMPMethod XMPFrame* First();
  371.       XMPMethod XMPFrame* Next();
  372.       XMPMethod XMPBoolean IsNotComplete();
  373.    
  374.    protected:
  375.    
  376.       ContainerPartEmbeddedFramesIterator(XMPPart* part);
  377.       virtual ~ContainerPartEmbeddedFramesIterator();
  378.    
  379.    private:
  380.    
  381.       OrderedCollectionIterator* fOCIter;
  382.    };
  383. #endif
  384.  
  385.  
  386. #endif // _CNTNRPRT_
  387.