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 /////////////////////////////////////////////////////////////////////////////
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "mdi.h"
23 WXDLLEXPORT_DATA(extern const wxChar
*) wxFrameNameStr
;
24 WXDLLEXPORT_DATA(extern const wxChar
*) wxStatusLineNameStr
;
26 class WXDLLEXPORT wxMDIClientWindow
;
27 class WXDLLEXPORT wxMDIChildFrame
;
29 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
31 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
35 wxMDIParentFrame() { Init(); }
36 wxMDIParentFrame(wxWindow
*parent
,
38 const wxString
& title
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
41 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
, // Scrolling refers to client window
42 const wxString
& name
= wxFrameNameStr
)
45 Create(parent
, id
, title
, pos
, size
, style
, name
);
50 bool Create(wxWindow
*parent
,
52 const wxString
& title
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
55 long style
= wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
,
56 const wxString
& name
= wxFrameNameStr
);
58 // Mac OS activate event
59 virtual void MacActivate(long timestamp
, bool activating
);
61 // wxWidgets activate event
62 void OnActivate(wxActivateEvent
& event
);
63 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
65 void SetMenuBar(wxMenuBar
*menu_bar
);
67 // Get the active MDI child window (Windows only)
68 wxMDIChildFrame
*GetActiveChild() const ;
70 // Get the client window
71 inline wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; };
72 // Get rect to be used to center top-level children
73 virtual void GetRectForTopLevelChildren(int *x
, int *y
, int *w
, int *h
);
75 // Create the client window class (don't Create the window,
76 // just return a new class)
77 virtual wxMDIClientWindow
*OnCreateClient() ;
80 virtual void Cascade();
81 virtual void Tile(wxOrientation
WXUNUSED(orient
) = wxHORIZONTAL
);
82 virtual void ArrangeIcons();
83 virtual void ActivateNext();
84 virtual void ActivatePrevious();
86 virtual bool Show( bool show
= true );
88 // overridden base clas virtuals
89 virtual void AddChild(wxWindowBase
*child
);
90 virtual void RemoveChild(wxWindowBase
*child
);
93 // common part of all ctors
96 // returns true if this frame has some contents and so should be visible,
97 // false if it's used solely as container for its children
98 bool ShouldBeVisible() const;
101 // TODO maybe have this member
102 wxMDIClientWindow
*m_clientWindow
;
103 wxMDIChildFrame
*m_currentChild
;
104 wxMenu
*m_windowMenu
;
106 // true if MDI Frame is intercepting commands, not child
107 bool m_parentFrameActive
;
109 // true if the frame should be shown but is not because it is empty and
110 // useless otherwise than a container for its children
111 bool m_shouldBeShown
;
114 friend class WXDLLEXPORT wxMDIChildFrame
;
115 DECLARE_EVENT_TABLE()
118 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
120 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
124 inline wxMDIChildFrame(wxMDIParentFrame
*parent
,
126 const wxString
& title
,
127 const wxPoint
& pos
= wxDefaultPosition
,
128 const wxSize
& size
= wxDefaultSize
,
129 long style
= wxDEFAULT_FRAME_STYLE
,
130 const wxString
& name
= wxFrameNameStr
)
133 Create(parent
, id
, title
, pos
, size
, style
, name
);
138 bool Create(wxMDIParentFrame
*parent
,
140 const wxString
& title
,
141 const wxPoint
& pos
= wxDefaultPosition
,
142 const wxSize
& size
= wxDefaultSize
,
143 long style
= wxDEFAULT_FRAME_STYLE
,
144 const wxString
& name
= wxFrameNameStr
);
146 // Mac OS activate event
147 virtual void MacActivate(long timestamp
, bool activating
);
150 void SetMenuBar(wxMenuBar
*menu_bar
);
153 virtual void Maximize();
154 virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame
155 virtual void Restore();
156 virtual void Activate();
159 // common part of all ctors
163 /* The client window is a child of the parent MDI frame, and itself
164 * contains the child MDI frames.
165 * However, you create the MDI children as children of the MDI parent:
166 * only in the implementation does the client window become the parent
167 * of the children. Phew! So the children are sort of 'adopted'...
170 class WXDLLEXPORT wxMDIClientWindow
: public wxWindow
172 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
175 wxMDIClientWindow() ;
176 inline wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
178 CreateClient(parent
, style
);
181 ~wxMDIClientWindow();
183 // Note: this is virtual, to allow overridden behaviour.
184 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
186 // Gets the size available for subwindows after menu size, toolbar size
187 // and status bar size have been subtracted. If you want to manage your own
188 // toolbar(s), don't call SetToolBar.
189 void DoGetClientSize(int *width
, int *height
) const;
191 // Explicitly call default scroll behaviour
192 void OnScroll(wxScrollEvent
& event
);
196 DECLARE_EVENT_TABLE()