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