]>
Commit | Line | Data |
---|---|---|
4bb6408c | 1 | ///////////////////////////////////////////////////////////////////////////// |
3b3dc801 | 2 | // Name: src/motif/mdi.cpp |
4bb6408c JS |
3 | // Purpose: MDI classes |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
65571936 | 9 | // Licence: wxWindows licence |
4bb6408c JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
1248b41f MB |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
4bb6408c | 15 | #include "wx/mdi.h" |
3b3dc801 WS |
16 | |
17 | #ifndef WX_PRECOMP | |
18 | #include "wx/menu.h" | |
923d28da | 19 | #include "wx/icon.h" |
9eddec69 | 20 | #include "wx/settings.h" |
3b3dc801 WS |
21 | #endif |
22 | ||
338dd992 JJ |
23 | #ifdef __VMS__ |
24 | #pragma message disable nosimpint | |
25 | #endif | |
8704bf74 JS |
26 | #include <Xm/Xm.h> |
27 | #include <Xm/BulletinB.h> | |
28 | #include <Xm/Form.h> | |
29 | #include <Xm/MainW.h> | |
30 | #include <Xm/RowColumn.h> | |
31 | #include <Xm/CascadeBG.h> | |
32 | #include <Xm/Text.h> | |
33 | #include <Xm/PushBG.h> | |
34 | #include <Xm/AtomMgr.h> | |
35 | #include <Xm/Protocols.h> | |
338dd992 JJ |
36 | #ifdef __VMS__ |
37 | #pragma message enable nosimpint | |
38 | #endif | |
8704bf74 | 39 | |
8704bf74 JS |
40 | #include "wx/motif/private.h" |
41 | ||
4bb6408c JS |
42 | extern wxList wxModelessWindows; |
43 | ||
8704bf74 | 44 | // Implemented in frame.cpp |
dfe1eee3 | 45 | extern void wxFrameFocusProc(Widget workArea, XtPointer clientData, |
2d120f83 | 46 | XmAnyCallbackStruct *cbs); |
8704bf74 | 47 | |
621793f4 JS |
48 | #define wxID_NOTEBOOK_CLIENT_AREA wxID_HIGHEST + 100 |
49 | ||
4bb6408c JS |
50 | IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) |
51 | IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) | |
621793f4 | 52 | IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxNotebook) |
4bb6408c JS |
53 | |
54 | BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) | |
25b1fc05 VZ |
55 | EVT_SIZE(wxMDIParentFrame::OnSize) |
56 | EVT_ACTIVATE(wxMDIParentFrame::OnActivate) | |
57 | EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) | |
449f38b5 | 58 | EVT_MENU_HIGHLIGHT_ALL(wxMDIParentFrame::OnMenuHighlight) |
4bb6408c JS |
59 | END_EVENT_TABLE() |
60 | ||
621793f4 | 61 | BEGIN_EVENT_TABLE(wxMDIClientWindow, wxNotebook) |
25b1fc05 VZ |
62 | EVT_SCROLL(wxMDIClientWindow::OnScroll) |
63 | EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged) | |
4bb6408c JS |
64 | END_EVENT_TABLE() |
65 | ||
4bb6408c JS |
66 | |
67 | // Parent frame | |
68 | ||
69 | wxMDIParentFrame::wxMDIParentFrame() | |
70 | { | |
0d57be45 JS |
71 | m_clientWindow = (wxMDIClientWindow*) NULL; |
72 | m_activeChild = (wxMDIChildFrame*) NULL; | |
621793f4 | 73 | m_activeMenuBar = (wxMenuBar*) NULL; |
4bb6408c JS |
74 | } |
75 | ||
76 | bool wxMDIParentFrame::Create(wxWindow *parent, | |
2d120f83 JS |
77 | wxWindowID id, |
78 | const wxString& title, | |
79 | const wxPoint& pos, | |
80 | const wxSize& size, | |
81 | long style, | |
82 | const wxString& name) | |
4bb6408c | 83 | { |
0d57be45 JS |
84 | m_clientWindow = (wxMDIClientWindow*) NULL; |
85 | m_activeChild = (wxMDIChildFrame*) NULL; | |
621793f4 | 86 | m_activeMenuBar = (wxMenuBar*) NULL; |
dfe1eee3 | 87 | |
8704bf74 JS |
88 | bool success = wxFrame::Create(parent, id, title, pos, size, style, name); |
89 | if (success) | |
90 | { | |
91 | // TODO: app cannot override OnCreateClient since | |
92 | // wxMDIParentFrame::OnCreateClient will still be called | |
93 | // (we're in the constructor). How to resolve? | |
dfe1eee3 | 94 | |
8704bf74 | 95 | m_clientWindow = OnCreateClient(); |
dfe1eee3 | 96 | |
621793f4 JS |
97 | // Uses own style for client style |
98 | m_clientWindow->CreateClient(this, GetWindowStyleFlag()); | |
dfe1eee3 | 99 | |
621793f4 JS |
100 | int w, h; |
101 | GetClientSize(& w, & h); | |
102 | m_clientWindow->SetSize(0, 0, w, h); | |
96be256b | 103 | return true; |
8704bf74 | 104 | } |
4bb6408c | 105 | else |
96be256b | 106 | return false; |
4bb6408c JS |
107 | } |
108 | ||
109 | wxMDIParentFrame::~wxMDIParentFrame() | |
110 | { | |
621793f4 JS |
111 | // Make sure we delete the client window last of all |
112 | RemoveChild(m_clientWindow); | |
dfe1eee3 | 113 | |
8704bf74 | 114 | DestroyChildren(); |
dfe1eee3 | 115 | |
8704bf74 | 116 | delete m_clientWindow; |
621793f4 | 117 | m_clientWindow = NULL; |
4bb6408c JS |
118 | } |
119 | ||
4bb6408c JS |
120 | void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) |
121 | { | |
621793f4 | 122 | m_frameMenuBar = menu_bar; |
dfe1eee3 | 123 | |
621793f4 | 124 | SetChildMenuBar((wxMDIChildFrame*) NULL); |
4bb6408c JS |
125 | } |
126 | ||
af111fc3 | 127 | void wxMDIParentFrame::OnSize(wxSizeEvent& WXUNUSED(event)) |
4bb6408c | 128 | { |
47d67540 | 129 | #if wxUSE_CONSTRAINTS |
4bb6408c | 130 | if (GetAutoLayout()) |
2d120f83 | 131 | Layout(); |
4bb6408c JS |
132 | #endif |
133 | int x = 0; | |
134 | int y = 0; | |
135 | int width, height; | |
136 | GetClientSize(&width, &height); | |
dfe1eee3 | 137 | |
4bb6408c JS |
138 | if ( GetClientWindow() ) |
139 | GetClientWindow()->SetSize(x, y, width, height); | |
140 | } | |
141 | ||
449f38b5 | 142 | void wxMDIParentFrame::DoGetClientSize(int *width, int *height) const |
25b1fc05 | 143 | { |
449f38b5 | 144 | wxFrame::DoGetClientSize(width, height); |
25b1fc05 VZ |
145 | } |
146 | ||
af111fc3 | 147 | void wxMDIParentFrame::OnActivate(wxActivateEvent& WXUNUSED(event)) |
4bb6408c | 148 | { |
2d120f83 | 149 | // Do nothing |
4bb6408c JS |
150 | } |
151 | ||
152 | // Returns the active MDI child window | |
153 | wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const | |
154 | { | |
0d57be45 | 155 | return m_activeChild; |
4bb6408c JS |
156 | } |
157 | ||
158 | // Create the client window class (don't Create the window, | |
159 | // just return a new class) | |
160 | wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() | |
161 | { | |
2d120f83 | 162 | return new wxMDIClientWindow ; |
4bb6408c JS |
163 | } |
164 | ||
621793f4 JS |
165 | // Set the child's menu into the parent frame |
166 | void wxMDIParentFrame::SetChildMenuBar(wxMDIChildFrame* child) | |
167 | { | |
168 | wxMenuBar* oldMenuBar = m_activeMenuBar; | |
dfe1eee3 | 169 | |
621793f4 JS |
170 | if (child == (wxMDIChildFrame*) NULL) // No child: use parent frame |
171 | { | |
172 | if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar)) | |
173 | { | |
2d120f83 JS |
174 | // if (m_activeMenuBar) |
175 | // m_activeMenuBar->DestroyMenuBar(); | |
dfe1eee3 | 176 | |
621793f4 JS |
177 | m_activeMenuBar = GetMenuBar(); |
178 | m_activeMenuBar->CreateMenuBar(this); | |
2d120f83 | 179 | /* |
621793f4 | 180 | if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget())) |
2d120f83 JS |
181 | XtUnmanageChild((Widget) oldMenuBar->GetMainWidget()); |
182 | */ | |
621793f4 | 183 | if (oldMenuBar && oldMenuBar->GetMainWidget()) |
2d120f83 | 184 | XtUnmapWidget((Widget) oldMenuBar->GetMainWidget()); |
dfe1eee3 | 185 | |
621793f4 JS |
186 | } |
187 | } | |
188 | else if (child->GetMenuBar() == (wxMenuBar*) NULL) // No child menu bar: use parent frame | |
189 | { | |
190 | if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar)) | |
191 | { | |
2d120f83 JS |
192 | // if (m_activeMenuBar) |
193 | // m_activeMenuBar->DestroyMenuBar(); | |
621793f4 JS |
194 | m_activeMenuBar = GetMenuBar(); |
195 | m_activeMenuBar->CreateMenuBar(this); | |
2d120f83 | 196 | /* |
621793f4 | 197 | if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget())) |
2d120f83 JS |
198 | XtUnmanageChild((Widget) oldMenuBar->GetMainWidget()); |
199 | */ | |
621793f4 | 200 | if (oldMenuBar && oldMenuBar->GetMainWidget()) |
2d120f83 | 201 | XtUnmapWidget((Widget) oldMenuBar->GetMainWidget()); |
621793f4 JS |
202 | } |
203 | } | |
204 | else // The child has a menubar | |
205 | { | |
206 | if (child->GetMenuBar() != m_activeMenuBar) | |
207 | { | |
2d120f83 JS |
208 | // if (m_activeMenuBar) |
209 | // m_activeMenuBar->DestroyMenuBar(); | |
dfe1eee3 | 210 | |
621793f4 JS |
211 | m_activeMenuBar = child->GetMenuBar(); |
212 | m_activeMenuBar->CreateMenuBar(this); | |
2d120f83 | 213 | /* |
621793f4 | 214 | if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget())) |
2d120f83 JS |
215 | XtUnmanageChild((Widget) oldMenuBar->GetMainWidget()); |
216 | */ | |
621793f4 | 217 | if (oldMenuBar && oldMenuBar->GetMainWidget()) |
2d120f83 | 218 | XtUnmapWidget((Widget) oldMenuBar->GetMainWidget()); |
621793f4 JS |
219 | } |
220 | } | |
221 | } | |
222 | ||
223 | // Redirect events to active child first | |
224 | bool wxMDIParentFrame::ProcessEvent(wxEvent& event) | |
225 | { | |
226 | // Stops the same event being processed repeatedly | |
227 | static wxEventType inEvent = wxEVT_NULL; | |
228 | if (inEvent == event.GetEventType()) | |
96be256b | 229 | return false; |
dfe1eee3 | 230 | |
621793f4 | 231 | inEvent = event.GetEventType(); |
dfe1eee3 | 232 | |
96be256b | 233 | bool res = false; |
621793f4 JS |
234 | if (m_activeChild && event.IsKindOf(CLASSINFO(wxCommandEvent))) |
235 | { | |
937013e0 | 236 | res = m_activeChild->HandleWindowEvent(event); |
621793f4 | 237 | } |
dfe1eee3 | 238 | |
621793f4 | 239 | if (!res) |
2d120f83 | 240 | res = GetEventHandler()->wxEvtHandler::ProcessEvent(event); |
dfe1eee3 | 241 | |
621793f4 | 242 | inEvent = wxEVT_NULL; |
dfe1eee3 | 243 | |
621793f4 JS |
244 | return res; |
245 | } | |
246 | ||
25b1fc05 VZ |
247 | void wxMDIParentFrame::DoSetSize(int x, int y, |
248 | int width, int height, | |
249 | int sizeFlags) | |
250 | { | |
b23386b2 | 251 | wxWindow::DoSetSize(x, y, width, height, sizeFlags); |
25b1fc05 VZ |
252 | } |
253 | ||
254 | void wxMDIParentFrame::DoSetClientSize(int width, int height) | |
255 | { | |
b23386b2 | 256 | wxWindow::DoSetClientSize(width, height); |
25b1fc05 VZ |
257 | } |
258 | ||
4bb6408c JS |
259 | // Responds to colour changes, and passes event on to children. |
260 | void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) | |
261 | { | |
262 | // TODO | |
dfe1eee3 | 263 | |
4bb6408c JS |
264 | // Propagate the event to the non-top-level children |
265 | wxFrame::OnSysColourChanged(event); | |
266 | } | |
267 | ||
268 | // MDI operations | |
269 | void wxMDIParentFrame::Cascade() | |
270 | { | |
271 | // TODO | |
272 | } | |
273 | ||
0d97c090 | 274 | void wxMDIParentFrame::Tile(wxOrientation WXUNUSED(orient)) |
4bb6408c JS |
275 | { |
276 | // TODO | |
277 | } | |
278 | ||
279 | void wxMDIParentFrame::ArrangeIcons() | |
280 | { | |
281 | // TODO | |
282 | } | |
283 | ||
284 | void wxMDIParentFrame::ActivateNext() | |
285 | { | |
286 | // TODO | |
287 | } | |
288 | ||
289 | void wxMDIParentFrame::ActivatePrevious() | |
290 | { | |
291 | // TODO | |
292 | } | |
293 | ||
449f38b5 JS |
294 | // Default menu selection behaviour - display a help string |
295 | void wxMDIParentFrame::OnMenuHighlight(wxMenuEvent& event) | |
296 | { | |
297 | if (GetStatusBar()) | |
298 | { | |
299 | if (event.GetMenuId() == -1) | |
3b3dc801 | 300 | SetStatusText(wxEmptyString); |
449f38b5 JS |
301 | else |
302 | { | |
303 | wxMenuBar *menuBar = (wxMenuBar*) NULL; | |
304 | if (GetActiveChild()) | |
305 | menuBar = GetActiveChild()->GetMenuBar(); | |
306 | else | |
307 | menuBar = GetMenuBar(); | |
308 | if (menuBar) | |
309 | { | |
310 | wxString helpString(menuBar->GetHelpString(event.GetMenuId())); | |
3b3dc801 | 311 | if (!helpString.empty()) |
449f38b5 JS |
312 | SetStatusText(helpString); |
313 | } | |
314 | } | |
315 | } | |
316 | } | |
317 | ||
4bb6408c JS |
318 | // Child frame |
319 | ||
320 | wxMDIChildFrame::wxMDIChildFrame() | |
321 | { | |
621793f4 | 322 | m_mdiParentFrame = (wxMDIParentFrame*) NULL; |
4bb6408c JS |
323 | } |
324 | ||
325 | bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, | |
2d120f83 JS |
326 | wxWindowID id, |
327 | const wxString& title, | |
328 | const wxPoint& pos, | |
329 | const wxSize& size, | |
330 | long style, | |
331 | const wxString& name) | |
4bb6408c JS |
332 | { |
333 | SetName(name); | |
af111fc3 | 334 | SetWindowStyleFlag(style); |
dfe1eee3 | 335 | |
4bb6408c JS |
336 | if ( id > -1 ) |
337 | m_windowId = id; | |
338 | else | |
339 | m_windowId = (int)NewControlId(); | |
dfe1eee3 | 340 | |
621793f4 | 341 | wxMDIClientWindow* clientWindow = parent->GetClientWindow(); |
dfe1eee3 | 342 | |
cbaa866f | 343 | wxCHECK_MSG( clientWindow, false, "Missing MDI client window." ); |
dfe1eee3 | 344 | |
cbaa866f | 345 | clientWindow->AddChild(this); |
dfe1eee3 | 346 | |
621793f4 | 347 | SetMDIParentFrame(parent); |
105fbe1f | 348 | PreCreation(); |
dfe1eee3 VZ |
349 | |
350 | int width = size.x; | |
351 | int height = size.y; | |
0d57be45 JS |
352 | if (width == -1) |
353 | width = 200; // TODO: give reasonable default | |
354 | if (height == -1) | |
355 | height = 200; // TODO: give reasonable default | |
dfe1eee3 | 356 | |
0d57be45 JS |
357 | // We're deactivating the old child |
358 | wxMDIChildFrame* oldActiveChild = parent->GetActiveChild(); | |
359 | if (oldActiveChild) | |
360 | { | |
96be256b | 361 | wxActivateEvent event(wxEVT_ACTIVATE, false, oldActiveChild->GetId()); |
0d57be45 | 362 | event.SetEventObject( oldActiveChild ); |
937013e0 | 363 | oldActiveChild->HandleWindowEvent(event); |
0d57be45 | 364 | } |
dfe1eee3 | 365 | |
0d57be45 JS |
366 | // This is the currently active child |
367 | parent->SetActiveChild((wxMDIChildFrame*) this); | |
dfe1eee3 | 368 | |
621793f4 JS |
369 | // This time we'll try a bog-standard bulletin board for |
370 | // the 'frame'. A main window doesn't seem to work. | |
dfe1eee3 | 371 | |
621793f4 | 372 | m_mainWidget = (WXWidget) XtVaCreateWidget("client", |
2d120f83 JS |
373 | xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(), |
374 | XmNmarginWidth, 0, | |
375 | XmNmarginHeight, 0, | |
376 | /* | |
377 | XmNrightAttachment, XmATTACH_FORM, | |
378 | XmNleftAttachment, XmATTACH_FORM, | |
379 | XmNtopAttachment, XmATTACH_FORM, | |
380 | XmNbottomAttachment, XmATTACH_FORM, | |
381 | */ | |
382 | XmNresizePolicy, XmRESIZE_NONE, | |
383 | NULL); | |
0492c5a0 | 384 | |
96be256b | 385 | XtAddEventHandler((Widget) m_mainWidget, ExposureMask,False, |
2e35f56f | 386 | wxUniversalRepaintProc, (XtPointer) this); |
dfe1eee3 | 387 | |
105fbe1f | 388 | PostCreation(); |
621793f4 | 389 | AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); |
dfe1eee3 | 390 | |
621793f4 | 391 | XtManageChild((Widget) m_mainWidget); |
dfe1eee3 | 392 | |
621793f4 | 393 | SetTitle(title); |
dfe1eee3 | 394 | |
96be256b | 395 | clientWindow->AddPage(this, title, true); |
621793f4 | 396 | clientWindow->Refresh(); |
dfe1eee3 | 397 | |
621793f4 JS |
398 | // Positions the toolbar and status bar -- but we don't have any. |
399 | // PreResize(); | |
dfe1eee3 | 400 | |
621793f4 | 401 | wxModelessWindows.Append(this); |
96be256b | 402 | return true; |
4bb6408c JS |
403 | } |
404 | ||
8704bf74 | 405 | |
4bb6408c JS |
406 | wxMDIChildFrame::~wxMDIChildFrame() |
407 | { | |
2e35f56f | 408 | if (m_mainWidget) |
96be256b | 409 | XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask,False, |
2e35f56f | 410 | wxUniversalRepaintProc, (XtPointer) this); |
dfe1eee3 | 411 | |
621793f4 JS |
412 | if (GetMDIParentFrame()) |
413 | { | |
414 | wxMDIParentFrame* parentFrame = GetMDIParentFrame(); | |
dfe1eee3 | 415 | |
621793f4 JS |
416 | if (parentFrame->GetActiveChild() == this) |
417 | parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); | |
418 | wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow(); | |
dfe1eee3 | 419 | |
621793f4 | 420 | // Remove page if still there |
fdfd5d49 MB |
421 | { |
422 | int i = clientWindow->FindPage(this); | |
423 | ||
424 | if (i != -1) | |
425 | { | |
426 | clientWindow->RemovePage(i); | |
427 | clientWindow->Refresh(); | |
428 | } | |
429 | } | |
dfe1eee3 | 430 | |
621793f4 JS |
431 | // Set the selection to the first remaining page |
432 | if (clientWindow->GetPageCount() > 0) | |
433 | { | |
434 | wxMDIChildFrame* child = (wxMDIChildFrame*) clientWindow->GetPage(0); | |
435 | parentFrame->SetActiveChild(child); | |
436 | parentFrame->SetChildMenuBar(child); | |
437 | } | |
438 | else | |
439 | { | |
440 | parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); | |
441 | parentFrame->SetChildMenuBar((wxMDIChildFrame*) NULL); | |
442 | } | |
443 | } | |
4bb6408c JS |
444 | } |
445 | ||
621793f4 | 446 | #if 0 |
0d57be45 JS |
447 | // Implementation: intercept and act upon raise and lower commands. |
448 | void wxMDIChildFrame::OnRaise() | |
449 | { | |
450 | wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; | |
451 | wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); | |
452 | parentFrame->SetActiveChild(this); | |
dfe1eee3 | 453 | |
0d57be45 JS |
454 | if (oldActiveChild) |
455 | { | |
96be256b | 456 | wxActivateEvent event(wxEVT_ACTIVATE, false, oldActiveChild->GetId()); |
0d57be45 | 457 | event.SetEventObject( oldActiveChild ); |
937013e0 | 458 | oldActiveChild->HandleWindowEvent(event); |
0d57be45 | 459 | } |
dfe1eee3 | 460 | |
96be256b | 461 | wxActivateEvent event(wxEVT_ACTIVATE, true, this->GetId()); |
0d57be45 | 462 | event.SetEventObject( this ); |
937013e0 | 463 | this->HandleWindowEvent(event); |
0d57be45 JS |
464 | } |
465 | ||
466 | void wxMDIChildFrame::OnLower() | |
467 | { | |
468 | wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; | |
469 | wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); | |
dfe1eee3 | 470 | |
0d57be45 JS |
471 | if (oldActiveChild == this) |
472 | { | |
96be256b | 473 | wxActivateEvent event(wxEVT_ACTIVATE, false, oldActiveChild->GetId()); |
0d57be45 | 474 | event.SetEventObject( oldActiveChild ); |
937013e0 | 475 | oldActiveChild->HandleWindowEvent(event); |
0d57be45 JS |
476 | } |
477 | // TODO: unfortunately we don't now know which is the top-most child, | |
478 | // so make the active child NULL. | |
479 | parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); | |
480 | } | |
621793f4 | 481 | #endif |
0d57be45 | 482 | |
4bb6408c | 483 | // Set the client size (i.e. leave the calculation of borders etc. |
77ffb593 | 484 | // to wxWidgets) |
9a05fd8d | 485 | void wxMDIChildFrame::DoSetClientSize(int width, int height) |
4bb6408c | 486 | { |
bfc6fde4 | 487 | wxWindow::DoSetClientSize(width, height); |
8704bf74 JS |
488 | } |
489 | ||
449f38b5 | 490 | void wxMDIChildFrame::DoGetClientSize(int* width, int* height) const |
8704bf74 | 491 | { |
449f38b5 | 492 | wxWindow::DoGetSize(width, height); |
8704bf74 JS |
493 | } |
494 | ||
bfc6fde4 | 495 | void wxMDIChildFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
8704bf74 | 496 | { |
bfc6fde4 | 497 | wxWindow::DoSetSize(x, y, width, height, sizeFlags); |
8704bf74 JS |
498 | } |
499 | ||
449f38b5 | 500 | void wxMDIChildFrame::DoGetSize(int* width, int* height) const |
8704bf74 | 501 | { |
449f38b5 | 502 | wxWindow::DoGetSize(width, height); |
4bb6408c JS |
503 | } |
504 | ||
449f38b5 | 505 | void wxMDIChildFrame::DoGetPosition(int *x, int *y) const |
4bb6408c | 506 | { |
449f38b5 | 507 | wxWindow::DoGetPosition(x, y); |
8704bf74 JS |
508 | } |
509 | ||
510 | bool wxMDIChildFrame::Show(bool show) | |
511 | { | |
798a4529 | 512 | SetVisibleStatus( show ); |
621793f4 | 513 | return wxWindow::Show(show); |
4bb6408c JS |
514 | } |
515 | ||
621793f4 | 516 | void wxMDIChildFrame::SetMenuBar(wxMenuBar *menuBar) |
4bb6408c | 517 | { |
621793f4 JS |
518 | // Don't create the underlying menubar yet; need to recreate |
519 | // it every time the child is activated. | |
520 | m_frameMenuBar = menuBar; | |
dfe1eee3 | 521 | |
621793f4 JS |
522 | // We make the assumption that if you're setting the menubar, |
523 | // this is the currently active child. | |
524 | GetMDIParentFrame()->SetChildMenuBar(this); | |
8704bf74 JS |
525 | } |
526 | ||
527 | // Set icon | |
528 | void wxMDIChildFrame::SetIcon(const wxIcon& icon) | |
529 | { | |
f618020a MB |
530 | m_icons = wxIconBundle( icon ); |
531 | ||
532 | if (icon.Ok()) | |
4bb6408c | 533 | { |
dfe1eee3 | 534 | // Not appropriate since there are no icons in |
2d120f83 | 535 | // a tabbed window |
4bb6408c | 536 | } |
8704bf74 JS |
537 | } |
538 | ||
f618020a MB |
539 | void wxMDIChildFrame::SetIcons(const wxIconBundle& icons) |
540 | { | |
541 | m_icons = icons; | |
542 | } | |
543 | ||
8704bf74 JS |
544 | void wxMDIChildFrame::SetTitle(const wxString& title) |
545 | { | |
798a4529 | 546 | wxTopLevelWindow::SetTitle( title ); |
7fe7d506 | 547 | wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow(); |
fdfd5d49 MB |
548 | |
549 | // Remove page if still there | |
550 | { | |
551 | int i = clientWindow->FindPage(this); | |
552 | ||
553 | if (i != -1) | |
554 | clientWindow->SetPageText(i, title); | |
555 | } | |
4bb6408c JS |
556 | } |
557 | ||
558 | // MDI operations | |
559 | void wxMDIChildFrame::Maximize() | |
560 | { | |
621793f4 | 561 | // TODO |
8704bf74 JS |
562 | } |
563 | ||
af111fc3 | 564 | void wxMDIChildFrame::Iconize(bool WXUNUSED(iconize)) |
8704bf74 | 565 | { |
2d120f83 | 566 | // TODO |
8704bf74 JS |
567 | } |
568 | ||
569 | bool wxMDIChildFrame::IsIconized() const | |
570 | { | |
96be256b | 571 | return false; |
4bb6408c JS |
572 | } |
573 | ||
6f63ec3f JS |
574 | // Is it maximized? Always maximized under Motif, using the |
575 | // tabbed MDI implementation. | |
576 | bool wxMDIChildFrame::IsMaximized(void) const | |
577 | { | |
96be256b | 578 | return true; |
6f63ec3f JS |
579 | } |
580 | ||
4bb6408c JS |
581 | void wxMDIChildFrame::Restore() |
582 | { | |
621793f4 | 583 | // TODO |
4bb6408c JS |
584 | } |
585 | ||
586 | void wxMDIChildFrame::Activate() | |
587 | { | |
621793f4 JS |
588 | // TODO |
589 | } | |
590 | ||
591 | void wxMDIChildFrame::CaptureMouse() | |
592 | { | |
2d120f83 | 593 | wxWindow::CaptureMouse(); |
621793f4 JS |
594 | } |
595 | ||
596 | void wxMDIChildFrame::ReleaseMouse() | |
597 | { | |
2d120f83 | 598 | wxWindow::ReleaseMouse(); |
621793f4 JS |
599 | } |
600 | ||
601 | void wxMDIChildFrame::Raise() | |
602 | { | |
2d120f83 | 603 | wxWindow::Raise(); |
621793f4 JS |
604 | } |
605 | ||
606 | void wxMDIChildFrame::Lower(void) | |
607 | { | |
2d120f83 | 608 | wxWindow::Raise(); |
621793f4 JS |
609 | } |
610 | ||
024f89f9 | 611 | void wxMDIChildFrame::DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), int WXUNUSED(maxH), int WXUNUSED(incW), int WXUNUSED(incH)) |
621793f4 | 612 | { |
4bb6408c JS |
613 | } |
614 | ||
615 | // Client window | |
616 | ||
617 | wxMDIClientWindow::wxMDIClientWindow() | |
618 | { | |
619 | } | |
620 | ||
621 | wxMDIClientWindow::~wxMDIClientWindow() | |
622 | { | |
621793f4 | 623 | // By the time this destructor is called, the child frames will have been |
2d120f83 | 624 | // deleted and removed from the notebook/client window. |
8704bf74 | 625 | DestroyChildren(); |
dfe1eee3 | 626 | |
8704bf74 | 627 | m_mainWidget = (WXWidget) 0; |
4bb6408c JS |
628 | } |
629 | ||
630 | bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) | |
631 | { | |
af111fc3 JS |
632 | SetWindowStyleFlag(style); |
633 | ||
7fe7d506 JS |
634 | bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0); |
635 | if (success) | |
636 | { | |
96be256b | 637 | return true; |
7fe7d506 JS |
638 | } |
639 | else | |
96be256b | 640 | return false; |
8704bf74 JS |
641 | } |
642 | ||
fdfd5d49 MB |
643 | int wxMDIClientWindow::FindPage(const wxNotebookPage* page) |
644 | { | |
645 | for (int i = GetPageCount() - 1; i >= 0; --i) | |
646 | { | |
647 | if (GetPage(i) == page) | |
648 | return i; | |
649 | } | |
650 | ||
651 | return -1; | |
652 | } | |
653 | ||
bfc6fde4 | 654 | void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
8704bf74 | 655 | { |
bfc6fde4 | 656 | wxWindow::DoSetSize(x, y, width, height, sizeFlags); |
8704bf74 | 657 | } |
4bb6408c | 658 | |
bfc6fde4 | 659 | void wxMDIClientWindow::DoSetClientSize(int width, int height) |
8704bf74 | 660 | { |
bfc6fde4 | 661 | wxWindow::DoSetClientSize(width, height); |
8704bf74 JS |
662 | } |
663 | ||
449f38b5 | 664 | void wxMDIClientWindow::DoGetClientSize(int *width, int *height) const |
8704bf74 | 665 | { |
449f38b5 | 666 | wxWindow::DoGetClientSize(width, height); |
8704bf74 JS |
667 | } |
668 | ||
449f38b5 | 669 | void wxMDIClientWindow::DoGetSize(int *width, int *height) const |
8704bf74 | 670 | { |
449f38b5 | 671 | wxWindow::DoGetSize(width, height); |
8704bf74 JS |
672 | } |
673 | ||
449f38b5 | 674 | void wxMDIClientWindow::DoGetPosition(int *x, int *y) const |
8704bf74 | 675 | { |
449f38b5 | 676 | wxWindow::DoGetPosition(x, y); |
4bb6408c JS |
677 | } |
678 | ||
45f22d48 | 679 | void wxMDIClientWindow::OnScroll(wxScrollEvent& event) |
4bb6408c | 680 | { |
45f22d48 JS |
681 | // Default(); // Default processing: OBSOLETE FUNCTION |
682 | event.Skip(); | |
4bb6408c JS |
683 | } |
684 | ||
621793f4 JS |
685 | void wxMDIClientWindow::OnPageChanged(wxNotebookEvent& event) |
686 | { | |
687 | // Notify child that it has been activated | |
688 | if (event.GetOldSelection() != -1) | |
689 | { | |
690 | wxMDIChildFrame* oldChild = (wxMDIChildFrame*) GetPage(event.GetOldSelection()); | |
691 | if (oldChild) | |
692 | { | |
96be256b | 693 | wxActivateEvent event(wxEVT_ACTIVATE, false, oldChild->GetId()); |
621793f4 | 694 | event.SetEventObject( oldChild ); |
937013e0 | 695 | oldChild->HandleWindowEvent(event); |
621793f4 JS |
696 | } |
697 | } | |
7fe7d506 | 698 | if (event.GetSelection() != -1) |
621793f4 | 699 | { |
2d120f83 JS |
700 | wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection()); |
701 | if (activeChild) | |
621793f4 | 702 | { |
96be256b | 703 | wxActivateEvent event(wxEVT_ACTIVATE, true, activeChild->GetId()); |
2d120f83 | 704 | event.SetEventObject( activeChild ); |
937013e0 | 705 | activeChild->HandleWindowEvent(event); |
dfe1eee3 | 706 | |
2d120f83 JS |
707 | if (activeChild->GetMDIParentFrame()) |
708 | { | |
709 | activeChild->GetMDIParentFrame()->SetActiveChild(activeChild); | |
710 | activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild); | |
711 | } | |
621793f4 JS |
712 | } |
713 | } | |
714 | event.Skip(); | |
715 | } |