1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     MDI (Multiple Document Interface) classes. 
   4 //              This doesn't have to be implemented just like Windows, 
   5 //              it could be a tabbed design as in wxGTK. 
   6 // Author:      Stefan Csomor 
  10 // Copyright:   (c) Stefan Csomor 
  11 // Licence:     wxWindows licence 
  12 ///////////////////////////////////////////////////////////////////////////// 
  19 WXDLLIMPEXP_DATA_CORE(extern const char) wxStatusLineNameStr
[]; 
  21 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
; 
  22 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
; 
  24 class WXDLLIMPEXP_CORE wxMDIParentFrame
: public wxFrame
 
  26   DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
) 
  30   wxMDIParentFrame() { Init(); } 
  31   wxMDIParentFrame(wxWindow 
*parent
, 
  33                    const wxString
& title
, 
  34                    const wxPoint
& pos 
= wxDefaultPosition
, 
  35                    const wxSize
& size 
= wxDefaultSize
, 
  36                    long style 
= wxDEFAULT_FRAME_STYLE 
| wxVSCROLL 
| wxHSCROLL
,  // Scrolling refers to client window 
  37                    const wxString
& name 
= wxFrameNameStr
) 
  40       Create(parent
, id
, title
, pos
, size
, style
, name
); 
  43   virtual ~wxMDIParentFrame(); 
  45   bool Create(wxWindow 
*parent
, 
  47            const wxString
& title
, 
  48            const wxPoint
& pos 
= wxDefaultPosition
, 
  49            const wxSize
& size 
= wxDefaultSize
, 
  50            long style 
= wxDEFAULT_FRAME_STYLE 
| wxVSCROLL 
| wxHSCROLL
, 
  51            const wxString
& name 
= wxFrameNameStr
); 
  53   // Mac OS activate event 
  54   virtual void MacActivate(long timestamp
, bool activating
); 
  56   // wxWidgets activate event 
  57   void OnActivate(wxActivateEvent
& event
); 
  58   void OnSysColourChanged(wxSysColourChangedEvent
& event
); 
  60   void SetMenuBar(wxMenuBar 
*menu_bar
); 
  62   // Get the active MDI child window (Windows only) 
  63   wxMDIChildFrame 
*GetActiveChild() const ; 
  65   // Get the client window 
  66   inline wxMDIClientWindow 
*GetClientWindow() const { return m_clientWindow
; }; 
  67   // Get rect to be used to center top-level children 
  68   virtual void GetRectForTopLevelChildren(int *x
, int *y
, int *w
, int *h
); 
  70   // Create the client window class (don't Create the window, 
  71   // just return a new class) 
  72   virtual wxMDIClientWindow 
*OnCreateClient() ; 
  75   virtual void Cascade(); 
  76   virtual void Tile(wxOrientation 
WXUNUSED(orient
) = wxHORIZONTAL
); 
  77   virtual void ArrangeIcons(); 
  78   virtual void ActivateNext(); 
  79   virtual void ActivatePrevious(); 
  81   virtual bool Show( bool show 
= true ); 
  83   // overridden base clas virtuals 
  84   virtual void AddChild(wxWindowBase 
*child
); 
  85   virtual void RemoveChild(wxWindowBase 
*child
); 
  88     // common part of all ctors 
  91     // returns true if this frame has some contents and so should be visible, 
  92     // false if it's used solely as container for its children 
  93     bool ShouldBeVisible() const; 
  96     // TODO maybe have this member 
  97     wxMDIClientWindow 
*m_clientWindow
; 
  98     wxMDIChildFrame 
*m_currentChild
; 
 101     // true if MDI Frame is intercepting commands, not child 
 102     bool m_parentFrameActive
; 
 104     // true if the frame should be shown but is not because it is empty and 
 105     // useless otherwise than a container for its children 
 106     bool m_shouldBeShown
; 
 109     friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
; 
 110     DECLARE_EVENT_TABLE() 
 113 class WXDLLIMPEXP_CORE wxMDIChildFrame
: public wxFrame
 
 115 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
) 
 119   inline wxMDIChildFrame(wxMDIParentFrame 
*parent
, 
 121            const wxString
& title
, 
 122            const wxPoint
& pos 
= wxDefaultPosition
, 
 123            const wxSize
& size 
= wxDefaultSize
, 
 124            long style 
= wxDEFAULT_FRAME_STYLE
, 
 125            const wxString
& name 
= wxFrameNameStr
) 
 128       Create(parent
, id
, title
, pos
, size
, style
, name
); 
 131   virtual ~wxMDIChildFrame(); 
 133   bool Create(wxMDIParentFrame 
*parent
, 
 135            const wxString
& title
, 
 136            const wxPoint
& pos 
= wxDefaultPosition
, 
 137            const wxSize
& size 
= wxDefaultSize
, 
 138            long style 
= wxDEFAULT_FRAME_STYLE
, 
 139            const wxString
& name 
= wxFrameNameStr
); 
 141   // Mac OS activate event 
 142   virtual void MacActivate(long timestamp
, bool activating
); 
 145   void SetMenuBar(wxMenuBar 
*menu_bar
); 
 148   virtual void Maximize(); 
 149   virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame 
 150   virtual void Restore(); 
 151   virtual void Activate(); 
 154     // common part of all ctors 
 158 /* The client window is a child of the parent MDI frame, and itself 
 159  * contains the child MDI frames. 
 160  * However, you create the MDI children as children of the MDI parent: 
 161  * only in the implementation does the client window become the parent 
 162  * of the children. Phew! So the children are sort of 'adopted'... 
 165 class WXDLLIMPEXP_CORE wxMDIClientWindow
: public wxWindow
 
 167   DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
) 
 170   wxMDIClientWindow() ; 
 171   inline wxMDIClientWindow(wxMDIParentFrame 
*parent
, long style 
= 0) 
 173       CreateClient(parent
, style
); 
 176   virtual ~wxMDIClientWindow(); 
 178   // Note: this is virtual, to allow overridden behaviour. 
 179   virtual bool CreateClient(wxMDIParentFrame 
*parent
, long style 
= wxVSCROLL 
| wxHSCROLL
); 
 181   // Explicitly call default scroll behaviour 
 182   void OnScroll(wxScrollEvent
& event
); 
 185     // Gets the size available for subwindows after menu size, toolbar size 
 186     // and status bar size have been subtracted. If you want to manage your own 
 187     // toolbar(s), don't call SetToolBar. 
 188     void DoGetClientSize(int *width
, int *height
) const; 
 190 DECLARE_EVENT_TABLE()