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