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