]> git.saurik.com Git - wxWidgets.git/blame - src/motif/mdi.cpp
error msg when there are no files in wxFindFirst() removed
[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,
2d120f83 37 XmAnyCallbackStruct *cbs);
8704bf74 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)
2d120f83
JS
47EVT_SIZE(wxMDIParentFrame::OnSize)
48EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
49EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
4bb6408c
JS
50END_EVENT_TABLE()
51
621793f4 52BEGIN_EVENT_TABLE(wxMDIClientWindow, wxNotebook)
2d120f83
JS
53EVT_SCROLL(wxMDIClientWindow::OnScroll)
54EVT_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,
2d120f83
JS
69 wxWindowID id,
70 const wxString& title,
71 const wxPoint& pos,
72 const wxSize& size,
73 long style,
74 const wxString& name)
4bb6408c 75{
0d57be45
JS
76 m_clientWindow = (wxMDIClientWindow*) NULL;
77 m_activeChild = (wxMDIChildFrame*) NULL;
621793f4 78 m_activeMenuBar = (wxMenuBar*) NULL;
2d120f83 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?
2d120f83 86
8704bf74 87 m_clientWindow = OnCreateClient();
2d120f83 88
621793f4
JS
89 // Uses own style for client style
90 m_clientWindow->CreateClient(this, GetWindowStyleFlag());
2d120f83 91
621793f4
JS
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);
2d120f83 105
8704bf74 106 DestroyChildren();
2d120f83 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 120 m_frameMenuBar = menu_bar;
2d120f83 121
621793f4 122 SetChildMenuBar((wxMDIChildFrame*) NULL);
4bb6408c
JS
123}
124
125void wxMDIParentFrame::OnSize(wxSizeEvent& event)
126{
47d67540 127#if wxUSE_CONSTRAINTS
4bb6408c 128 if (GetAutoLayout())
2d120f83 129 Layout();
4bb6408c
JS
130#endif
131 int x = 0;
132 int y = 0;
133 int width, height;
134 GetClientSize(&width, &height);
2d120f83 135
4bb6408c
JS
136 if ( GetClientWindow() )
137 GetClientWindow()->SetSize(x, y, width, height);
138}
139
140void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
141{
2d120f83 142 // Do nothing
4bb6408c
JS
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{
2d120f83 155 return new wxMDIClientWindow ;
4bb6408c
JS
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;
2d120f83 162
621793f4
JS
163 if (child == (wxMDIChildFrame*) NULL) // No child: use parent frame
164 {
165 if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
166 {
2d120f83
JS
167 // if (m_activeMenuBar)
168 // m_activeMenuBar->DestroyMenuBar();
169
621793f4
JS
170 m_activeMenuBar = GetMenuBar();
171 m_activeMenuBar->CreateMenuBar(this);
2d120f83 172 /*
621793f4 173 if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
2d120f83
JS
174 XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
175 */
621793f4 176 if (oldMenuBar && oldMenuBar->GetMainWidget())
2d120f83
JS
177 XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
178
621793f4
JS
179 }
180 }
181 else if (child->GetMenuBar() == (wxMenuBar*) NULL) // No child menu bar: use parent frame
182 {
183 if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
184 {
2d120f83
JS
185 // if (m_activeMenuBar)
186 // m_activeMenuBar->DestroyMenuBar();
621793f4
JS
187 m_activeMenuBar = GetMenuBar();
188 m_activeMenuBar->CreateMenuBar(this);
2d120f83 189 /*
621793f4 190 if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
2d120f83
JS
191 XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
192 */
621793f4 193 if (oldMenuBar && oldMenuBar->GetMainWidget())
2d120f83 194 XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
621793f4
JS
195 }
196 }
197 else // The child has a menubar
198 {
199 if (child->GetMenuBar() != m_activeMenuBar)
200 {
2d120f83
JS
201 // if (m_activeMenuBar)
202 // m_activeMenuBar->DestroyMenuBar();
203
621793f4
JS
204 m_activeMenuBar = child->GetMenuBar();
205 m_activeMenuBar->CreateMenuBar(this);
2d120f83 206 /*
621793f4 207 if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
2d120f83
JS
208 XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
209 */
621793f4 210 if (oldMenuBar && oldMenuBar->GetMainWidget())
2d120f83 211 XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
621793f4
JS
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;
2d120f83 223
621793f4
JS
224 inEvent = event.GetEventType();
225
226 bool res = FALSE;
227 if (m_activeChild && event.IsKindOf(CLASSINFO(wxCommandEvent)))
228 {
2d120f83 229 res = m_activeChild->GetEventHandler()->ProcessEvent(event);
621793f4 230 }
2d120f83 231
621793f4 232 if (!res)
2d120f83
JS
233 res = GetEventHandler()->wxEvtHandler::ProcessEvent(event);
234
621793f4 235 inEvent = wxEVT_NULL;
2d120f83 236
621793f4
JS
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
2d120f83 244
4bb6408c
JS
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,
2d120f83
JS
283 wxWindowID id,
284 const wxString& title,
285 const wxPoint& pos,
286 const wxSize& size,
287 long style,
288 const wxString& name)
4bb6408c
JS
289{
290 SetName(name);
2d120f83 291
621793f4
JS
292 m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
293 m_foregroundColour = *wxBLACK;
294 m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
2d120f83 295
4bb6408c
JS
296 if ( id > -1 )
297 m_windowId = id;
298 else
299 m_windowId = (int)NewControlId();
2d120f83 300
621793f4 301 wxMDIClientWindow* clientWindow = parent->GetClientWindow();
2d120f83 302
621793f4 303 wxASSERT_MSG( (clientWindow != (wxWindow*) NULL), "Missing MDI client window.");
2d120f83 304
621793f4 305 if (clientWindow) clientWindow->AddChild(this);
2d120f83 306
621793f4 307 SetMDIParentFrame(parent);
2d120f83 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
2d120f83 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 }
2d120f83 324
0d57be45
JS
325 // This is the currently active child
326 parent->SetActiveChild((wxMDIChildFrame*) this);
2d120f83 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.
2d120f83 330
621793f4 331 m_mainWidget = (WXWidget) XtVaCreateWidget("client",
2d120f83
JS
332 xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(),
333 XmNmarginWidth, 0,
334 XmNmarginHeight, 0,
335 /*
336 XmNrightAttachment, XmATTACH_FORM,
337 XmNleftAttachment, XmATTACH_FORM,
338 XmNtopAttachment, XmATTACH_FORM,
339 XmNbottomAttachment, XmATTACH_FORM,
340 */
341 XmNresizePolicy, XmRESIZE_NONE,
342 NULL);
0492c5a0 343
2e35f56f
JS
344 XtAddEventHandler((Widget) m_mainWidget, ExposureMask,FALSE,
345 wxUniversalRepaintProc, (XtPointer) this);
346
621793f4
JS
347 SetCanAddEventHandler(TRUE);
348 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
2d120f83
JS
349
350 ChangeBackgroundColour();
351
621793f4 352 XtManageChild((Widget) m_mainWidget);
2d120f83 353
621793f4 354 SetTitle(title);
2d120f83 355
621793f4
JS
356 clientWindow->AddPage(this, title, TRUE);
357 clientWindow->Refresh();
2d120f83 358
621793f4
JS
359 // Positions the toolbar and status bar -- but we don't have any.
360 // PreResize();
2d120f83 361
621793f4
JS
362 wxModelessWindows.Append(this);
363 return TRUE;
4bb6408c
JS
364}
365
8704bf74 366
4bb6408c
JS
367wxMDIChildFrame::~wxMDIChildFrame()
368{
2e35f56f
JS
369 if (m_mainWidget)
370 XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask,FALSE,
371 wxUniversalRepaintProc, (XtPointer) this);
372
621793f4
JS
373 if (GetMDIParentFrame())
374 {
375 wxMDIParentFrame* parentFrame = GetMDIParentFrame();
2d120f83 376
621793f4
JS
377 if (parentFrame->GetActiveChild() == this)
378 parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
379 wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
2d120f83 380
621793f4
JS
381 // Remove page if still there
382 if (clientWindow->RemovePage(this))
2d120f83
JS
383 clientWindow->Refresh();
384
621793f4
JS
385 // Set the selection to the first remaining page
386 if (clientWindow->GetPageCount() > 0)
387 {
388 wxMDIChildFrame* child = (wxMDIChildFrame*) clientWindow->GetPage(0);
389 parentFrame->SetActiveChild(child);
390 parentFrame->SetChildMenuBar(child);
391 }
392 else
393 {
394 parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
395 parentFrame->SetChildMenuBar((wxMDIChildFrame*) NULL);
396 }
397 }
4bb6408c
JS
398}
399
621793f4 400#if 0
0d57be45
JS
401// Implementation: intercept and act upon raise and lower commands.
402void wxMDIChildFrame::OnRaise()
403{
404 wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
405 wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
406 parentFrame->SetActiveChild(this);
2d120f83 407
0d57be45
JS
408 if (oldActiveChild)
409 {
410 wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
411 event.SetEventObject( oldActiveChild );
412 oldActiveChild->GetEventHandler()->ProcessEvent(event);
413 }
2d120f83 414
0d57be45
JS
415 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
416 event.SetEventObject( this );
417 this->GetEventHandler()->ProcessEvent(event);
418}
419
420void wxMDIChildFrame::OnLower()
421{
422 wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
423 wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
2d120f83 424
0d57be45
JS
425 if (oldActiveChild == this)
426 {
427 wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
428 event.SetEventObject( oldActiveChild );
429 oldActiveChild->GetEventHandler()->ProcessEvent(event);
430 }
431 // TODO: unfortunately we don't now know which is the top-most child,
432 // so make the active child NULL.
433 parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
434}
621793f4 435#endif
0d57be45 436
4bb6408c
JS
437// Set the client size (i.e. leave the calculation of borders etc.
438// to wxWindows)
439void wxMDIChildFrame::SetClientSize(int width, int height)
440{
2d120f83 441 wxWindow::SetClientSize(width, height);
8704bf74
JS
442}
443
444void wxMDIChildFrame::GetClientSize(int* width, int* height) const
445{
621793f4 446 wxWindow::GetSize(width, height);
8704bf74
JS
447}
448
449void wxMDIChildFrame::SetSize(int x, int y, int width, int height, int sizeFlags)
450{
2d120f83 451 wxWindow::SetSize(x, y, width, height, sizeFlags);
8704bf74
JS
452}
453
454void wxMDIChildFrame::GetSize(int* width, int* height) const
455{
456 wxWindow::GetSize(width, height);
4bb6408c
JS
457}
458
459void wxMDIChildFrame::GetPosition(int *x, int *y) const
460{
8704bf74
JS
461 wxWindow::GetPosition(x, y);
462}
463
464bool wxMDIChildFrame::Show(bool show)
465{
466 m_visibleStatus = show; /* show-&-hide fix */
621793f4 467 return wxWindow::Show(show);
4bb6408c
JS
468}
469
621793f4 470void wxMDIChildFrame::SetMenuBar(wxMenuBar *menuBar)
4bb6408c 471{
621793f4
JS
472 // Don't create the underlying menubar yet; need to recreate
473 // it every time the child is activated.
474 m_frameMenuBar = menuBar;
2d120f83 475
621793f4
JS
476 // We make the assumption that if you're setting the menubar,
477 // this is the currently active child.
478 GetMDIParentFrame()->SetChildMenuBar(this);
8704bf74
JS
479}
480
481// Set icon
482void wxMDIChildFrame::SetIcon(const wxIcon& icon)
483{
484 m_icon = icon;
485 if (m_icon.Ok())
4bb6408c 486 {
2d120f83
JS
487 // Not appropriate since there are no icons in
488 // a tabbed window
4bb6408c 489 }
8704bf74
JS
490}
491
492void wxMDIChildFrame::SetTitle(const wxString& title)
493{
494 m_title = title;
7fe7d506
JS
495 wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow();
496 int pageNo = clientWindow->FindPagePosition(this);
497 if (pageNo > -1)
498 clientWindow->SetPageText(pageNo, title);
4bb6408c
JS
499}
500
501// MDI operations
502void wxMDIChildFrame::Maximize()
503{
621793f4 504 // TODO
8704bf74
JS
505}
506
507void wxMDIChildFrame::Iconize(bool iconize)
508{
2d120f83 509 // TODO
8704bf74
JS
510}
511
512bool wxMDIChildFrame::IsIconized() const
513{
621793f4 514 return FALSE;
4bb6408c
JS
515}
516
6f63ec3f
JS
517// Is it maximized? Always maximized under Motif, using the
518// tabbed MDI implementation.
519bool wxMDIChildFrame::IsMaximized(void) const
520{
521 return TRUE;
522}
523
4bb6408c
JS
524void wxMDIChildFrame::Restore()
525{
621793f4 526 // TODO
4bb6408c
JS
527}
528
529void wxMDIChildFrame::Activate()
530{
621793f4
JS
531 // TODO
532}
533
534void wxMDIChildFrame::CaptureMouse()
535{
2d120f83 536 wxWindow::CaptureMouse();
621793f4
JS
537}
538
539void wxMDIChildFrame::ReleaseMouse()
540{
2d120f83 541 wxWindow::ReleaseMouse();
621793f4
JS
542}
543
544void wxMDIChildFrame::Raise()
545{
2d120f83 546 wxWindow::Raise();
621793f4
JS
547}
548
549void wxMDIChildFrame::Lower(void)
550{
2d120f83 551 wxWindow::Raise();
621793f4
JS
552}
553
554void wxMDIChildFrame::SetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), int WXUNUSED(maxH), int WXUNUSED(incW), int WXUNUSED(incH))
555{
4bb6408c
JS
556}
557
558// Client window
559
560wxMDIClientWindow::wxMDIClientWindow()
561{
562}
563
564wxMDIClientWindow::~wxMDIClientWindow()
565{
621793f4 566 // By the time this destructor is called, the child frames will have been
2d120f83 567 // deleted and removed from the notebook/client window.
8704bf74 568 DestroyChildren();
2d120f83 569
8704bf74 570 m_mainWidget = (WXWidget) 0;
4bb6408c
JS
571}
572
573bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
574{
2d120f83 575 // m_windowParent = parent;
621793f4 576 // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
2d120f83 577
7fe7d506
JS
578 bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
579 if (success)
580 {
581 wxFont font(10, wxSWISS, wxNORMAL, wxNORMAL);
582 wxFont selFont(10, wxSWISS, wxNORMAL, wxBOLD);
583 GetTabView()->SetTabFont(font);
584 GetTabView()->SetSelectedTabFont(selFont);
585 GetTabView()->SetTabSize(120, 18);
586 GetTabView()->SetTabSelectionHeight(20);
587 return TRUE;
588 }
589 else
2d120f83 590 return FALSE;
8704bf74
JS
591}
592
593void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
594{
595 wxWindow::SetSize(x, y, width, height, sizeFlags);
596}
4bb6408c 597
8704bf74
JS
598void wxMDIClientWindow::SetClientSize(int width, int height)
599{
600 wxWindow::SetClientSize(width, height);
601}
602
603void wxMDIClientWindow::GetClientSize(int *width, int *height) const
604{
605 wxWindow::GetClientSize(width, height);
606}
607
608void wxMDIClientWindow::GetSize(int *width, int *height) const
609{
610 wxWindow::GetSize(width, height);
611}
612
613void wxMDIClientWindow::GetPosition(int *x, int *y) const
614{
615 wxWindow::GetPosition(x, y);
4bb6408c
JS
616}
617
618// Explicitly call default scroll behaviour
619void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
620{
621 Default(); // Default processing
622}
623
621793f4
JS
624void wxMDIClientWindow::OnPageChanged(wxNotebookEvent& event)
625{
626 // Notify child that it has been activated
627 if (event.GetOldSelection() != -1)
628 {
629 wxMDIChildFrame* oldChild = (wxMDIChildFrame*) GetPage(event.GetOldSelection());
630 if (oldChild)
631 {
632 wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldChild->GetId());
633 event.SetEventObject( oldChild );
634 oldChild->GetEventHandler()->ProcessEvent(event);
635 }
636 }
7fe7d506 637 if (event.GetSelection() != -1)
621793f4 638 {
2d120f83
JS
639 wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
640 if (activeChild)
621793f4 641 {
2d120f83
JS
642 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
643 event.SetEventObject( activeChild );
644 activeChild->GetEventHandler()->ProcessEvent(event);
645
646 if (activeChild->GetMDIParentFrame())
647 {
648 activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
649 activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
650 }
621793f4
JS
651 }
652 }
653 event.Skip();
654}