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 WXDLLEXPORT_DATA(extern const wxChar
) wxFrameNameStr
[];
20 WXDLLEXPORT_DATA(extern const wxChar
) wxStatusLineNameStr
[];
22 class WXDLLEXPORT wxMDIClientWindow
;
23 class WXDLLEXPORT wxMDIChildFrame
;
25 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
27 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
31 wxMDIParentFrame() { Init(); }
32 wxMDIParentFrame(wxWindow
*parent
,
34 const wxString
& title
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
37 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
, // Scrolling refers to client window
38 const wxString
& name
= wxFrameNameStr
)
41 Create(parent
, id
, title
, pos
, size
, style
, name
);
46 bool Create(wxWindow
*parent
,
48 const wxString
& title
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
51 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
52 const wxString
& name
= wxFrameNameStr
);
54 // Mac OS activate event
55 virtual void MacActivate(long timestamp
, bool activating
);
57 // wxWidgets activate event
58 void OnActivate(wxActivateEvent
& event
);
59 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
61 void SetMenuBar(wxMenuBar
*menu_bar
);
63 // Get the active MDI child window (Windows only)
64 wxMDIChildFrame
*GetActiveChild() const ;
66 // Get the client window
67 inline wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; };
68 // Get rect to be used to center top-level children
69 virtual void GetRectForTopLevelChildren(int *x
, int *y
, int *w
, int *h
);
71 // Create the client window class (don't Create the window,
72 // just return a new class)
73 virtual wxMDIClientWindow
*OnCreateClient() ;
76 virtual void Cascade();
77 virtual void Tile(wxOrientation
WXUNUSED(orient
) = wxHORIZONTAL
);
78 virtual void ArrangeIcons();
79 virtual void ActivateNext();
80 virtual void ActivatePrevious();
82 virtual bool Show( bool show
= true );
84 // overridden base clas virtuals
85 virtual void AddChild(wxWindowBase
*child
);
86 virtual void RemoveChild(wxWindowBase
*child
);
89 // common part of all ctors
92 // returns true if this frame has some contents and so should be visible,
93 // false if it's used solely as container for its children
94 bool ShouldBeVisible() const;
97 // TODO maybe have this member
98 wxMDIClientWindow
*m_clientWindow
;
99 wxMDIChildFrame
*m_currentChild
;
100 wxMenu
*m_windowMenu
;
102 // true if MDI Frame is intercepting commands, not child
103 bool m_parentFrameActive
;
105 // true if the frame should be shown but is not because it is empty and
106 // useless otherwise than a container for its children
107 bool m_shouldBeShown
;
110 friend class WXDLLEXPORT wxMDIChildFrame
;
111 DECLARE_EVENT_TABLE()
114 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
116 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
120 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
122 const wxString
& title
,
123 const wxPoint
& pos
= wxDefaultPosition
,
124 const wxSize
& size
= wxDefaultSize
,
125 long style
= wxDEFAULT_FRAME_STYLE
,
126 const wxString
& name
= wxFrameNameStr
)
129 Create(parent
, id
, title
, pos
, size
, style
, name
);
134 bool Create(wxMDIParentFrame
*parent
,
136 const wxString
& title
,
137 const wxPoint
& pos
= wxDefaultPosition
,
138 const wxSize
& size
= wxDefaultSize
,
139 long style
= wxDEFAULT_FRAME_STYLE
,
140 const wxString
& name
= wxFrameNameStr
);
142 // Mac OS activate event
143 virtual void MacActivate(long timestamp
, bool activating
);
146 void SetMenuBar(wxMenuBar
*menu_bar
);
149 virtual void Maximize();
150 virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame
151 virtual void Restore();
152 virtual void Activate();
155 // common part of all ctors
159 /* The client window is a child of the parent MDI frame, and itself
160 * contains the child MDI frames.
161 * However, you create the MDI children as children of the MDI parent:
162 * only in the implementation does the client window become the parent
163 * of the children. Phew! So the children are sort of 'adopted'...
166 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
168 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
171 wxMDIClientWindow() ;
172 inline wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
174 CreateClient(parent
, style
);
177 ~wxMDIClientWindow();
179 // Note: this is virtual, to allow overridden behaviour.
180 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
182 // Gets the size available for subwindows after menu size, toolbar size
183 // and status bar size have been subtracted. If you want to manage your own
184 // toolbar(s), don't call SetToolBar.
185 void DoGetClientSize(int *width
, int *height
) const;
187 // Explicitly call default scroll behaviour
188 void OnScroll(wxScrollEvent
& event
);
192 DECLARE_EVENT_TABLE()