home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / BCPPOWL1.ZIP / OWLINC.ZIP / MDI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-28  |  6.7 KB  |  194 lines

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