home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 3.ddi / OWLINC.ZIP / MDI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  6.8 KB  |  203 lines

  1. // ObjectWindows - (C) Copyright 1992 by Borland International
  2.  
  3. #ifndef __MDI_H
  4. #define __MDI_H
  5.  
  6. #ifndef __APPLICAT_H
  7. #include <applicat.h>
  8. #endif
  9.  
  10. #pragma option -Vo-
  11. #if     defined(__BCOPT__) && !defined(_ALLOW_po)
  12. #pragma option -po-
  13. #endif
  14.  
  15. _CLASSDEF(TMDIFrame)
  16. _CLASSDEF(TMDIClient)
  17.  
  18. /* --------------------------------------------------------
  19.   TMDIClient object
  20.   -------------------------------------------------------- */
  21.  
  22. class _EXPORT TMDIClient : public TWindow
  23. {
  24. public:
  25.     LPCLIENTCREATESTRUCT ClientAttr;
  26.  
  27.     TMDIClient(PTMDIFrame AParent, PTModule AModule = NULL);
  28.     TMDIClient(PTMDIFrame AParent, HWND AnHWindow, PTModule AModule = NULL);
  29.     virtual ~TMDIClient();
  30.  
  31.     /* Arranges iconized MDI child windows. */
  32.     virtual void ArrangeIcons()
  33.     { SendMessage(HWindow, WM_MDIICONARRANGE, 0, 0); }
  34.  
  35.     /* Cascades the MDI child windows. */
  36.     virtual void CascadeChildren()
  37.     { SendMessage(HWindow, WM_MDICASCADE, 0, 0); }
  38.  
  39.     /* Tiles the MDI child windows. */
  40.     virtual void TileChildren()
  41.     { SendMessage(HWindow, WM_MDITILE, 0, 0); }
  42.  
  43.     static PTStreamable build();
  44.  
  45. protected:
  46.     virtual LPSTR GetClassName()
  47.         { return "MDICLIENT"; }
  48.  
  49.     /* Override TWindow::WMPaint and instead call DefWndProc */
  50.     virtual void WMPaint(RTMessage Msg) = [WM_FIRST + WM_PAINT]
  51.         { DefWndProc(Msg); }
  52.  
  53.     /* Override TWindow::WMMDIActivate, instead just call DefWndProc. */
  54.     virtual void WMMDIActivate(RTMessage Msg) =
  55.                  [WM_FIRST + WM_MDIACTIVATE]
  56.         { DefWndProc(Msg); }
  57.  
  58.     TMDIClient(StreamableInit) : TWindow(streamableInit) {}
  59.     virtual void write (Ropstream os);
  60.     virtual Pvoid read (Ripstream is);
  61.  
  62. private:
  63.     virtual const Pchar streamableName() const
  64.         { return "TMDIClient"; }
  65. };
  66.  
  67. inline Ripstream operator >> ( Ripstream is, RTMDIClient cl )
  68.     { return is >> (RTStreamable)cl; }
  69. inline Ripstream operator >> ( Ripstream is, RPTMDIClient cl )
  70.     { return is >> (RPvoid)cl; }
  71.  
  72. inline Ropstream operator << ( Ropstream os, RTMDIClient cl )
  73.     { return os << (RTStreamable)cl; }
  74. inline Ropstream operator << ( Ropstream os, PTMDIClient cl )
  75.     { return os << (PTStreamable)cl; }
  76.  
  77. /* --------------------------------------------------------
  78.   TMDIFrame object
  79.   -------------------------------------------------------- */
  80.  
  81. class _EXPORT TMDIFrame : public TWindow
  82. {
  83. public:
  84.     PTMDIClient ClientWnd;     // MDI client window
  85.     int ChildMenuPos;          // menu position for child menu
  86.     PTWindow ActiveChild;
  87.  
  88.     TMDIFrame(LPSTR ATitle, LPSTR MenuName, PTModule AModule = NULL);
  89.     TMDIFrame(LPSTR ATitle, int MenuId, PTModule AModule = NULL);
  90.     TMDIFrame(HWND AnHWindow, HWND ClientHWnd, PTModule AModule = NULL);
  91.     virtual ~TMDIFrame();
  92.  
  93.     /* Constructs the TMDIFrame's MDI client window. */
  94.     virtual void InitClientWindow()
  95.         { ClientWnd = new TMDIClient(this); }
  96.  
  97.     /* Returns a pointer to the TMDIFrame's MDI client window. */
  98.     virtual PTMDIClient GetClient()
  99.         { return ClientWnd; }
  100.  
  101.     /* Constructs a new MDI child window object.  By default,
  102.       constructs an instance of TWindow as an MDI child window object.
  103.       Will almost always be redefined by descendants to construct an
  104.       instance of a user-defined TWindow descendant as an MDI child
  105.       window object. */
  106.     virtual PTWindowsObject InitChild()
  107.         { return new TWindow(this, ""); }
  108.  
  109.     virtual PTWindowsObject CreateChild();
  110.  
  111.     /* Tiles the MDI child windows by calling the TileChildren method
  112.       of the MDI client window object. */
  113.     virtual void TileChildren()
  114.         { ClientWnd->TileChildren(); }
  115.  
  116.     /* Cascades the MDI child windows by calling the CascadeChildren
  117.       method of the MDI client window object. */
  118.     virtual void CascadeChildren()
  119.         { ClientWnd->CascadeChildren(); }
  120.  
  121.     /* Arranges iconized MDI child windows by calling the
  122.       ArrangeIcons method of the MDI client window object. */
  123.     virtual void ArrangeIcons()
  124.         { ClientWnd->ArrangeIcons(); }
  125.  
  126.     virtual BOOL CloseChildren();
  127.     static PTStreamable build();
  128.  
  129. protected:
  130.     virtual void GetWindowClass(WNDCLASS _FAR & AWndClass);
  131.     virtual LPSTR GetClassName()
  132.         { return "OWLMDIFrame31"; }
  133.     virtual void SetupWindow();
  134.  
  135.     /* Since an MDI child doesn't get MDIACTIVATE messages when the
  136.        frame gets (de)activated, call its ActivationResponse here. */
  137.     virtual void WMActivate(RTMessage Msg)
  138.         { TWindow::WMActivate(Msg);
  139.           if ( ActiveChild )
  140.             ActiveChild->ActivationResponse(
  141.                    Msg.WParam, IsIconic(ActiveChild->HWindow)); }
  142.  
  143.     /* Responds to an incoming "CreateChild" command (with a
  144.       CM_CREATECHILD command identifier) by calling CreateChild to
  145.       construct and create a new MDI child. */
  146.     virtual void CMCreateChild(RTMessage) =
  147.                  [CM_FIRST + CM_CREATECHILD]
  148.         { CreateChild(); }
  149.  
  150.     /* Responds to an incoming "Tile" command (with a CM_TILECHILDREN
  151.       command identifier) by calling TileChildren to tile the MDI
  152.       child windows. */
  153.     virtual void CMTileChildren(RTMessage) =
  154.                  [CM_FIRST + CM_TILECHILDREN]
  155.         { TileChildren(); }
  156.  
  157.     /* Responds to an incoming "Cascade" command (with a
  158.       CM_CASCADECHILDREN command identifier) by calling
  159.       CascadeChildren to cascade the MDI  child windows. */
  160.     virtual void CMCascadeChildren(RTMessage) =
  161.                  [CM_FIRST + CM_CASCADECHILDREN]
  162.         { CascadeChildren(); }
  163.  
  164.     /* Responds to an incoming "Arrange" command (with a
  165.       CM_ARRANGEICONS command identifier) by calling ArrangeIcons
  166.       to arrange the icons of the MDI child windows. */
  167.     virtual void CMArrangeIcons(RTMessage) =
  168.                  [CM_FIRST + CM_ARRANGEICONS]
  169.         { ArrangeIcons(); }
  170.  
  171.     /* Responds to an incoming "CloseAll" command (with a
  172.       CM_CLOSECHILDREN command identifier) by calling CloseChildren
  173.       to close the MDI child windows. */
  174.     virtual void CMCloseChildren(RTMessage) =
  175.                  [CM_FIRST + CM_CLOSECHILDREN]
  176.         { CloseChildren(); }
  177.  
  178.     TMDIFrame(StreamableInit) : TWindow(streamableInit) {};
  179.     virtual void write (Ropstream os);
  180.     virtual Pvoid read (Ripstream is);
  181.  
  182. private:
  183.     virtual const Pchar streamableName() const
  184.         { return "TMDIFrame"; }
  185. };
  186.  
  187. inline Ripstream operator >> ( Ripstream is, RTMDIFrame cl )
  188.     { return is >> (RTStreamable)cl; }
  189. inline Ripstream operator >> ( Ripstream is, RPTMDIFrame cl )
  190.     { return is >> (RPvoid)cl; }
  191.  
  192. inline Ropstream operator << ( Ropstream os, RTMDIFrame cl )
  193.     { return os << (RTStreamable)cl; }
  194. inline Ropstream operator << ( Ropstream os, PTMDIFrame cl )
  195.     { return os << (PTStreamable)cl; }
  196.  
  197. #pragma option -Vo.
  198. #if     defined(__BCOPT__) && !defined(_ALLOW_po)
  199. #pragma option -po.
  200. #endif
  201.  
  202. #endif
  203.