]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mdi.cpp | |
3 | // Purpose: MDI classes | |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
e40298d5 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "mdi.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/mdi.h" | |
17 | #include "wx/menu.h" | |
18 | #include "wx/settings.h" | |
19 | ||
76a5e5d2 SC |
20 | #include "wx/mac/private.h" |
21 | ||
fe08e597 | 22 | extern wxWindowList wxModelessWindows; |
e9576ca5 | 23 | |
2f1ae414 | 24 | #if !USE_SHARED_LIBRARY |
e9576ca5 SC |
25 | IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) |
26 | IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) | |
27 | IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) | |
28 | ||
29 | BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) | |
e9576ca5 SC |
30 | EVT_ACTIVATE(wxMDIParentFrame::OnActivate) |
31 | EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) | |
32 | END_EVENT_TABLE() | |
33 | ||
34 | BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow) | |
35 | EVT_SCROLL(wxMDIClientWindow::OnScroll) | |
36 | END_EVENT_TABLE() | |
37 | ||
2f1ae414 | 38 | #endif |
e9576ca5 | 39 | |
0a67a93b SC |
40 | static const int IDM_WINDOWTILE = 4001; |
41 | static const int IDM_WINDOWTILEHOR = 4001; | |
42 | static const int IDM_WINDOWCASCADE = 4002; | |
43 | static const int IDM_WINDOWICONS = 4003; | |
44 | static const int IDM_WINDOWNEXT = 4004; | |
45 | static const int IDM_WINDOWTILEVERT = 4005; | |
4f3b37fd | 46 | static const int IDM_WINDOWPREV = 4006; |
0a67a93b SC |
47 | |
48 | // This range gives a maximum of 500 MDI children. Should be enough :-) | |
49 | static const int wxFIRST_MDI_CHILD = 4100; | |
50 | static const int wxLAST_MDI_CHILD = 4600; | |
51 | ||
52 | // Status border dimensions | |
53 | static const int wxTHICK_LINE_BORDER = 3; | |
54 | ||
e9576ca5 SC |
55 | // Parent frame |
56 | ||
57 | wxMDIParentFrame::wxMDIParentFrame() | |
58 | { | |
0a67a93b SC |
59 | m_clientWindow = NULL; |
60 | m_currentChild = NULL; | |
61 | m_windowMenu = (wxMenu*) NULL; | |
62 | m_parentFrameActive = TRUE; | |
e9576ca5 SC |
63 | } |
64 | ||
65 | bool wxMDIParentFrame::Create(wxWindow *parent, | |
66 | wxWindowID id, | |
67 | const wxString& title, | |
68 | const wxPoint& pos, | |
69 | const wxSize& size, | |
70 | long style, | |
71 | const wxString& name) | |
72 | { | |
e40298d5 JS |
73 | m_clientWindow = NULL; |
74 | m_currentChild = NULL; | |
75 | ||
76 | // this style can be used to prevent a window from having the standard MDI | |
77 | // "Window" menu | |
78 | if ( style & wxFRAME_NO_WINDOW_MENU ) | |
79 | { | |
80 | m_windowMenu = (wxMenu *)NULL; | |
81 | style -= wxFRAME_NO_WINDOW_MENU ; | |
82 | } | |
83 | else // normal case: we have the window menu, so construct it | |
84 | { | |
85 | m_windowMenu = new wxMenu; | |
0a67a93b | 86 | |
e40298d5 JS |
87 | m_windowMenu->Append(IDM_WINDOWCASCADE, wxT("&Cascade")); |
88 | m_windowMenu->Append(IDM_WINDOWTILEHOR, wxT("Tile &Horizontally")); | |
89 | m_windowMenu->Append(IDM_WINDOWTILEVERT, wxT("Tile &Vertically")); | |
90 | m_windowMenu->AppendSeparator(); | |
91 | m_windowMenu->Append(IDM_WINDOWICONS, wxT("&Arrange Icons")); | |
92 | m_windowMenu->Append(IDM_WINDOWNEXT, wxT("&Next")); | |
93 | } | |
94 | ||
95 | wxFrame::Create( parent , id , title , wxPoint( 2000 , 2000 ) , size , style , name ) ; | |
96 | m_parentFrameActive = TRUE; | |
97 | ||
98 | OnCreateClient(); | |
99 | ||
e9576ca5 SC |
100 | return TRUE; |
101 | } | |
102 | ||
103 | wxMDIParentFrame::~wxMDIParentFrame() | |
104 | { | |
0a67a93b SC |
105 | DestroyChildren(); |
106 | // already delete by DestroyChildren() | |
107 | m_frameToolBar = NULL; | |
108 | m_frameStatusBar = NULL; | |
109 | m_clientWindow = NULL ; | |
e40298d5 | 110 | |
0a67a93b SC |
111 | if (m_windowMenu) |
112 | { | |
113 | delete m_windowMenu; | |
114 | m_windowMenu = (wxMenu*) NULL; | |
115 | } | |
e40298d5 | 116 | |
0a67a93b SC |
117 | if ( m_clientWindow ) |
118 | { | |
119 | delete m_clientWindow; | |
120 | m_clientWindow = NULL ; | |
121 | } | |
e9576ca5 SC |
122 | } |
123 | ||
0a67a93b | 124 | |
e9576ca5 SC |
125 | void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) |
126 | { | |
e40298d5 | 127 | wxFrame::SetMenuBar( menu_bar ) ; |
e9576ca5 SC |
128 | } |
129 | ||
e9576ca5 SC |
130 | void wxMDIParentFrame::OnActivate(wxActivateEvent& event) |
131 | { | |
e40298d5 JS |
132 | if ( m_currentChild && event.GetActive() ) |
133 | { | |
134 | wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); | |
135 | event.SetEventObject( m_currentChild ); | |
136 | m_currentChild->GetEventHandler()->ProcessEvent(event) ; | |
137 | } | |
138 | else if ( event.GetActive() ) | |
139 | { | |
140 | if ( m_frameMenuBar != NULL ) | |
141 | { | |
142 | m_frameMenuBar->MacInstallMenuBar() ; | |
143 | } | |
144 | ||
145 | } | |
e9576ca5 SC |
146 | } |
147 | ||
148 | // Returns the active MDI child window | |
149 | wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const | |
150 | { | |
e40298d5 | 151 | return m_currentChild ; |
e9576ca5 SC |
152 | } |
153 | ||
154 | // Create the client window class (don't Create the window, | |
155 | // just return a new class) | |
156 | wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() | |
157 | { | |
0a67a93b SC |
158 | m_clientWindow = new wxMDIClientWindow( this ); |
159 | return m_clientWindow; | |
e9576ca5 SC |
160 | } |
161 | ||
162 | // Responds to colour changes, and passes event on to children. | |
163 | void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) | |
164 | { | |
165 | // TODO | |
e40298d5 | 166 | |
e9576ca5 SC |
167 | // Propagate the event to the non-top-level children |
168 | wxFrame::OnSysColourChanged(event); | |
169 | } | |
170 | ||
171 | // MDI operations | |
172 | void wxMDIParentFrame::Cascade() | |
173 | { | |
174 | // TODO | |
175 | } | |
176 | ||
177 | void wxMDIParentFrame::Tile() | |
178 | { | |
179 | // TODO | |
180 | } | |
181 | ||
182 | void wxMDIParentFrame::ArrangeIcons() | |
183 | { | |
184 | // TODO | |
185 | } | |
186 | ||
187 | void wxMDIParentFrame::ActivateNext() | |
188 | { | |
189 | // TODO | |
190 | } | |
191 | ||
192 | void wxMDIParentFrame::ActivatePrevious() | |
193 | { | |
194 | // TODO | |
195 | } | |
196 | ||
197 | // Child frame | |
198 | ||
199 | wxMDIChildFrame::wxMDIChildFrame() | |
0a67a93b SC |
200 | { |
201 | Init() ; | |
202 | } | |
203 | void wxMDIChildFrame::Init() | |
e9576ca5 SC |
204 | { |
205 | } | |
206 | ||
207 | bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, | |
e40298d5 JS |
208 | wxWindowID id, |
209 | const wxString& title, | |
210 | const wxPoint& pos, | |
211 | const wxSize& size, | |
212 | long style, | |
213 | const wxString& name) | |
e9576ca5 SC |
214 | { |
215 | SetName(name); | |
e40298d5 | 216 | |
e9576ca5 SC |
217 | if ( id > -1 ) |
218 | m_windowId = id; | |
219 | else | |
220 | m_windowId = (int)NewControlId(); | |
e40298d5 | 221 | |
e9576ca5 | 222 | if (parent) parent->AddChild(this); |
e40298d5 JS |
223 | |
224 | MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; | |
225 | ||
226 | m_macWindowBackgroundTheme = kThemeBrushDocumentWindowBackground ; | |
227 | SetThemeWindowBackground( (WindowRef) m_macWindow , m_macWindowBackgroundTheme , false ) ; | |
228 | ||
e9576ca5 SC |
229 | wxModelessWindows.Append(this); |
230 | return FALSE; | |
231 | } | |
232 | ||
233 | wxMDIChildFrame::~wxMDIChildFrame() | |
234 | { | |
0a67a93b SC |
235 | DestroyChildren(); |
236 | // already delete by DestroyChildren() | |
237 | m_frameToolBar = NULL; | |
238 | m_frameStatusBar = NULL; | |
e9576ca5 SC |
239 | } |
240 | ||
241 | void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) | |
242 | { | |
e40298d5 | 243 | return wxFrame::SetMenuBar( menu_bar ) ; |
e9576ca5 SC |
244 | } |
245 | ||
246 | // MDI operations | |
247 | void wxMDIChildFrame::Maximize() | |
248 | { | |
0a67a93b | 249 | wxFrame::Maximize() ; |
e9576ca5 SC |
250 | } |
251 | ||
252 | void wxMDIChildFrame::Restore() | |
253 | { | |
0a67a93b | 254 | wxFrame::Restore() ; |
e9576ca5 SC |
255 | } |
256 | ||
257 | void wxMDIChildFrame::Activate() | |
258 | { | |
e9576ca5 SC |
259 | } |
260 | ||
0a67a93b SC |
261 | //----------------------------------------------------------------------------- |
262 | // wxMDIClientWindow | |
263 | //----------------------------------------------------------------------------- | |
e9576ca5 SC |
264 | |
265 | wxMDIClientWindow::wxMDIClientWindow() | |
266 | { | |
267 | } | |
268 | ||
269 | wxMDIClientWindow::~wxMDIClientWindow() | |
270 | { | |
0a67a93b | 271 | DestroyChildren(); |
e9576ca5 SC |
272 | } |
273 | ||
274 | bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) | |
275 | { | |
e40298d5 | 276 | |
0a67a93b | 277 | m_windowId = (int)NewControlId(); |
e40298d5 | 278 | |
0a67a93b SC |
279 | if ( parent ) |
280 | { | |
e40298d5 | 281 | parent->AddChild(this); |
0a67a93b | 282 | } |
a756f210 | 283 | m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); |
e40298d5 | 284 | |
0a67a93b SC |
285 | wxModelessWindows.Append(this); |
286 | return TRUE; | |
e9576ca5 SC |
287 | } |
288 | ||
be7a1013 DE |
289 | // Get size *available for subwindows* i.e. excluding menu bar. |
290 | void wxMDIClientWindow::DoGetClientSize(int *x, int *y) const | |
291 | { | |
292 | wxDisplaySize( x , y ) ; | |
293 | } | |
294 | ||
e9576ca5 SC |
295 | // Explicitly call default scroll behaviour |
296 | void wxMDIClientWindow::OnScroll(wxScrollEvent& event) | |
297 | { | |
e9576ca5 SC |
298 | } |
299 |