]>
Commit | Line | Data |
---|---|---|
8cf73271 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mdi.h | |
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 | |
7 | // Modified by: | |
8 | // Created: 1998-01-01 | |
9 | // RCS-ID: $Id$ | |
10 | // Copyright: (c) Stefan Csomor | |
65571936 | 11 | // Licence: wxWindows licence |
8cf73271 SC |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | ||
14 | #ifndef _WX_MDI_H_ | |
15 | #define _WX_MDI_H_ | |
16 | ||
8cf73271 SC |
17 | #include "wx/frame.h" |
18 | ||
64034845 | 19 | WXDLLEXPORT_DATA(extern const char) wxStatusLineNameStr[]; |
8cf73271 | 20 | |
b5dbe15d VS |
21 | class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow; |
22 | class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; | |
8cf73271 SC |
23 | |
24 | class WXDLLEXPORT wxMDIParentFrame: public wxFrame | |
25 | { | |
26 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) | |
27 | ||
28 | public: | |
29 | ||
a57ac1c4 VZ |
30 | wxMDIParentFrame() { Init(); } |
31 | wxMDIParentFrame(wxWindow *parent, | |
32 | wxWindowID id, | |
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) | |
8cf73271 | 38 | { |
a57ac1c4 | 39 | Init(); |
8cf73271 SC |
40 | Create(parent, id, title, pos, size, style, name); |
41 | } | |
42 | ||
d3c7fc99 | 43 | virtual ~wxMDIParentFrame(); |
8cf73271 SC |
44 | |
45 | bool Create(wxWindow *parent, | |
46 | wxWindowID id, | |
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); | |
52 | ||
53 | // Mac OS activate event | |
54 | virtual void MacActivate(long timestamp, bool activating); | |
55 | ||
77ffb593 | 56 | // wxWidgets activate event |
8cf73271 SC |
57 | void OnActivate(wxActivateEvent& event); |
58 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
59 | ||
60 | void SetMenuBar(wxMenuBar *menu_bar); | |
61 | ||
62 | // Get the active MDI child window (Windows only) | |
63 | wxMDIChildFrame *GetActiveChild() const ; | |
64 | ||
65 | // Get the client window | |
66 | inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; | |
0bba37f5 DE |
67 | // Get rect to be used to center top-level children |
68 | virtual void GetRectForTopLevelChildren(int *x, int *y, int *w, int *h); | |
8cf73271 SC |
69 | |
70 | // Create the client window class (don't Create the window, | |
71 | // just return a new class) | |
72 | virtual wxMDIClientWindow *OnCreateClient() ; | |
73 | ||
74 | // MDI operations | |
75 | virtual void Cascade(); | |
0d97c090 | 76 | virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL); |
8cf73271 SC |
77 | virtual void ArrangeIcons(); |
78 | virtual void ActivateNext(); | |
79 | virtual void ActivatePrevious(); | |
80 | ||
29e92efb VZ |
81 | virtual bool Show( bool show = true ); |
82 | ||
a57ac1c4 VZ |
83 | // overridden base clas virtuals |
84 | virtual void AddChild(wxWindowBase *child); | |
85 | virtual void RemoveChild(wxWindowBase *child); | |
86 | ||
8cf73271 | 87 | protected: |
a57ac1c4 VZ |
88 | // common part of all ctors |
89 | void Init(); | |
90 | ||
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; | |
8cf73271 | 94 | |
8cf73271 | 95 | |
a57ac1c4 VZ |
96 | // TODO maybe have this member |
97 | wxMDIClientWindow *m_clientWindow; | |
98 | wxMDIChildFrame *m_currentChild; | |
99 | wxMenu *m_windowMenu; | |
100 | ||
101 | // true if MDI Frame is intercepting commands, not child | |
8cf73271 SC |
102 | bool m_parentFrameActive; |
103 | ||
a57ac1c4 VZ |
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; | |
107 | ||
8cf73271 | 108 | private: |
b5dbe15d | 109 | friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame; |
a57ac1c4 | 110 | DECLARE_EVENT_TABLE() |
8cf73271 SC |
111 | }; |
112 | ||
113 | class WXDLLEXPORT wxMDIChildFrame: public wxFrame | |
114 | { | |
115 | DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) | |
116 | public: | |
117 | ||
118 | wxMDIChildFrame(); | |
119 | inline wxMDIChildFrame(wxMDIParentFrame *parent, | |
120 | wxWindowID id, | |
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) | |
126 | { | |
127 | Init() ; | |
128 | Create(parent, id, title, pos, size, style, name); | |
129 | } | |
130 | ||
d3c7fc99 | 131 | virtual ~wxMDIChildFrame(); |
8cf73271 SC |
132 | |
133 | bool Create(wxMDIParentFrame *parent, | |
134 | wxWindowID id, | |
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); | |
140 | ||
141 | // Mac OS activate event | |
142 | virtual void MacActivate(long timestamp, bool activating); | |
143 | ||
144 | // Set menu bar | |
145 | void SetMenuBar(wxMenuBar *menu_bar); | |
146 | ||
147 | // MDI operations | |
148 | virtual void Maximize(); | |
149 | virtual void Maximize( bool ){ Maximize() ; } // this one is inherited from wxFrame | |
150 | virtual void Restore(); | |
151 | virtual void Activate(); | |
152 | protected: | |
153 | ||
154 | // common part of all ctors | |
155 | void Init(); | |
156 | }; | |
157 | ||
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'... | |
163 | */ | |
164 | ||
165 | class WXDLLEXPORT wxMDIClientWindow: public wxWindow | |
166 | { | |
167 | DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) | |
168 | public: | |
169 | ||
170 | wxMDIClientWindow() ; | |
171 | inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) | |
172 | { | |
173 | CreateClient(parent, style); | |
174 | } | |
175 | ||
d3c7fc99 | 176 | virtual ~wxMDIClientWindow(); |
8cf73271 SC |
177 | |
178 | // Note: this is virtual, to allow overridden behaviour. | |
179 | virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); | |
180 | ||
8cf73271 SC |
181 | // Explicitly call default scroll behaviour |
182 | void OnScroll(wxScrollEvent& event); | |
183 | ||
184 | protected: | |
6f02a879 VZ |
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; | |
8cf73271 SC |
189 | |
190 | DECLARE_EVENT_TABLE() | |
191 | }; | |
192 | ||
193 | #endif | |
194 | // _WX_MDI_H_ |