]> git.saurik.com Git - wxWidgets.git/blame - src/motif/mdi.cpp
Removed a deprecated wxBitmap constructor, and some
[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
12#ifdef __GNUG__
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
JS
394 SetCanAddEventHandler(TRUE);
395 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
dfe1eee3
VZ
396
397 ChangeBackgroundColour();
398
621793f4 399 XtManageChild((Widget) m_mainWidget);
dfe1eee3 400
621793f4 401 SetTitle(title);
dfe1eee3 402
621793f4
JS
403 clientWindow->AddPage(this, title, TRUE);
404 clientWindow->Refresh();
dfe1eee3 405
621793f4
JS
406 // Positions the toolbar and status bar -- but we don't have any.
407 // PreResize();
dfe1eee3 408
621793f4
JS
409 wxModelessWindows.Append(this);
410 return TRUE;
4bb6408c
JS
411}
412
8704bf74 413
4bb6408c
JS
414wxMDIChildFrame::~wxMDIChildFrame()
415{
2e35f56f
JS
416 if (m_mainWidget)
417 XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask,FALSE,
418 wxUniversalRepaintProc, (XtPointer) this);
dfe1eee3 419
621793f4
JS
420 if (GetMDIParentFrame())
421 {
422 wxMDIParentFrame* parentFrame = GetMDIParentFrame();
dfe1eee3 423
621793f4
JS
424 if (parentFrame->GetActiveChild() == this)
425 parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
426 wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
dfe1eee3 427
621793f4 428 // Remove page if still there
fdfd5d49
MB
429 {
430 int i = clientWindow->FindPage(this);
431
432 if (i != -1)
433 {
434 clientWindow->RemovePage(i);
435 clientWindow->Refresh();
436 }
437 }
dfe1eee3 438
621793f4
JS
439 // Set the selection to the first remaining page
440 if (clientWindow->GetPageCount() > 0)
441 {
442 wxMDIChildFrame* child = (wxMDIChildFrame*) clientWindow->GetPage(0);
443 parentFrame->SetActiveChild(child);
444 parentFrame->SetChildMenuBar(child);
445 }
446 else
447 {
448 parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
449 parentFrame->SetChildMenuBar((wxMDIChildFrame*) NULL);
450 }
451 }
4bb6408c
JS
452}
453
621793f4 454#if 0
0d57be45
JS
455// Implementation: intercept and act upon raise and lower commands.
456void wxMDIChildFrame::OnRaise()
457{
458 wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
459 wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
460 parentFrame->SetActiveChild(this);
dfe1eee3 461
0d57be45
JS
462 if (oldActiveChild)
463 {
464 wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
465 event.SetEventObject( oldActiveChild );
466 oldActiveChild->GetEventHandler()->ProcessEvent(event);
467 }
dfe1eee3 468
0d57be45
JS
469 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
470 event.SetEventObject( this );
471 this->GetEventHandler()->ProcessEvent(event);
472}
473
474void wxMDIChildFrame::OnLower()
475{
476 wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
477 wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
dfe1eee3 478
0d57be45
JS
479 if (oldActiveChild == this)
480 {
481 wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
482 event.SetEventObject( oldActiveChild );
483 oldActiveChild->GetEventHandler()->ProcessEvent(event);
484 }
485 // TODO: unfortunately we don't now know which is the top-most child,
486 // so make the active child NULL.
487 parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
488}
621793f4 489#endif
0d57be45 490
4bb6408c
JS
491// Set the client size (i.e. leave the calculation of borders etc.
492// to wxWindows)
9a05fd8d 493void wxMDIChildFrame::DoSetClientSize(int width, int height)
4bb6408c 494{
bfc6fde4 495 wxWindow::DoSetClientSize(width, height);
8704bf74
JS
496}
497
449f38b5 498void wxMDIChildFrame::DoGetClientSize(int* width, int* height) const
8704bf74 499{
449f38b5 500 wxWindow::DoGetSize(width, height);
8704bf74
JS
501}
502
bfc6fde4 503void wxMDIChildFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags)
8704bf74 504{
bfc6fde4 505 wxWindow::DoSetSize(x, y, width, height, sizeFlags);
8704bf74
JS
506}
507
449f38b5 508void wxMDIChildFrame::DoGetSize(int* width, int* height) const
8704bf74 509{
449f38b5 510 wxWindow::DoGetSize(width, height);
4bb6408c
JS
511}
512
449f38b5 513void wxMDIChildFrame::DoGetPosition(int *x, int *y) const
4bb6408c 514{
449f38b5 515 wxWindow::DoGetPosition(x, y);
8704bf74
JS
516}
517
518bool wxMDIChildFrame::Show(bool show)
519{
798a4529 520 SetVisibleStatus( show );
621793f4 521 return wxWindow::Show(show);
4bb6408c
JS
522}
523
621793f4 524void wxMDIChildFrame::SetMenuBar(wxMenuBar *menuBar)
4bb6408c 525{
621793f4
JS
526 // Don't create the underlying menubar yet; need to recreate
527 // it every time the child is activated.
528 m_frameMenuBar = menuBar;
dfe1eee3 529
621793f4
JS
530 // We make the assumption that if you're setting the menubar,
531 // this is the currently active child.
532 GetMDIParentFrame()->SetChildMenuBar(this);
8704bf74
JS
533}
534
535// Set icon
536void wxMDIChildFrame::SetIcon(const wxIcon& icon)
537{
f618020a
MB
538 m_icons = wxIconBundle( icon );
539
540 if (icon.Ok())
4bb6408c 541 {
dfe1eee3 542 // Not appropriate since there are no icons in
2d120f83 543 // a tabbed window
4bb6408c 544 }
8704bf74
JS
545}
546
f618020a
MB
547void wxMDIChildFrame::SetIcons(const wxIconBundle& icons)
548{
549 m_icons = icons;
550}
551
8704bf74
JS
552void wxMDIChildFrame::SetTitle(const wxString& title)
553{
798a4529 554 wxTopLevelWindow::SetTitle( title );
7fe7d506 555 wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow();
fdfd5d49
MB
556
557 // Remove page if still there
558 {
559 int i = clientWindow->FindPage(this);
560
561 if (i != -1)
562 clientWindow->SetPageText(i, title);
563 }
4bb6408c
JS
564}
565
566// MDI operations
567void wxMDIChildFrame::Maximize()
568{
621793f4 569 // TODO
8704bf74
JS
570}
571
af111fc3 572void wxMDIChildFrame::Iconize(bool WXUNUSED(iconize))
8704bf74 573{
2d120f83 574 // TODO
8704bf74
JS
575}
576
577bool wxMDIChildFrame::IsIconized() const
578{
621793f4 579 return FALSE;
4bb6408c
JS
580}
581
6f63ec3f
JS
582// Is it maximized? Always maximized under Motif, using the
583// tabbed MDI implementation.
584bool wxMDIChildFrame::IsMaximized(void) const
585{
586 return TRUE;
587}
588
4bb6408c
JS
589void wxMDIChildFrame::Restore()
590{
621793f4 591 // TODO
4bb6408c
JS
592}
593
594void wxMDIChildFrame::Activate()
595{
621793f4
JS
596 // TODO
597}
598
599void wxMDIChildFrame::CaptureMouse()
600{
2d120f83 601 wxWindow::CaptureMouse();
621793f4
JS
602}
603
604void wxMDIChildFrame::ReleaseMouse()
605{
2d120f83 606 wxWindow::ReleaseMouse();
621793f4
JS
607}
608
609void wxMDIChildFrame::Raise()
610{
2d120f83 611 wxWindow::Raise();
621793f4
JS
612}
613
614void wxMDIChildFrame::Lower(void)
615{
2d120f83 616 wxWindow::Raise();
621793f4
JS
617}
618
619void wxMDIChildFrame::SetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), int WXUNUSED(maxH), int WXUNUSED(incW), int WXUNUSED(incH))
620{
4bb6408c
JS
621}
622
623// Client window
624
625wxMDIClientWindow::wxMDIClientWindow()
626{
627}
628
629wxMDIClientWindow::~wxMDIClientWindow()
630{
621793f4 631 // By the time this destructor is called, the child frames will have been
2d120f83 632 // deleted and removed from the notebook/client window.
8704bf74 633 DestroyChildren();
dfe1eee3 634
8704bf74 635 m_mainWidget = (WXWidget) 0;
4bb6408c
JS
636}
637
638bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
639{
af111fc3
JS
640 SetWindowStyleFlag(style);
641
2d120f83 642 // m_windowParent = parent;
a756f210 643 // m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
dfe1eee3 644
7fe7d506
JS
645 bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
646 if (success)
647 {
648 wxFont font(10, wxSWISS, wxNORMAL, wxNORMAL);
fdfd5d49 649 SetFont(font);
7fe7d506
JS
650 return TRUE;
651 }
652 else
2d120f83 653 return FALSE;
8704bf74
JS
654}
655
fdfd5d49
MB
656int wxMDIClientWindow::FindPage(const wxNotebookPage* page)
657{
658 for (int i = GetPageCount() - 1; i >= 0; --i)
659 {
660 if (GetPage(i) == page)
661 return i;
662 }
663
664 return -1;
665}
666
bfc6fde4 667void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
8704bf74 668{
bfc6fde4 669 wxWindow::DoSetSize(x, y, width, height, sizeFlags);
8704bf74 670}
4bb6408c 671
bfc6fde4 672void wxMDIClientWindow::DoSetClientSize(int width, int height)
8704bf74 673{
bfc6fde4 674 wxWindow::DoSetClientSize(width, height);
8704bf74
JS
675}
676
449f38b5 677void wxMDIClientWindow::DoGetClientSize(int *width, int *height) const
8704bf74 678{
449f38b5 679 wxWindow::DoGetClientSize(width, height);
8704bf74
JS
680}
681
449f38b5 682void wxMDIClientWindow::DoGetSize(int *width, int *height) const
8704bf74 683{
449f38b5 684 wxWindow::DoGetSize(width, height);
8704bf74
JS
685}
686
449f38b5 687void wxMDIClientWindow::DoGetPosition(int *x, int *y) const
8704bf74 688{
449f38b5 689 wxWindow::DoGetPosition(x, y);
4bb6408c
JS
690}
691
45f22d48 692void wxMDIClientWindow::OnScroll(wxScrollEvent& event)
4bb6408c 693{
45f22d48
JS
694 // Default(); // Default processing: OBSOLETE FUNCTION
695 event.Skip();
4bb6408c
JS
696}
697
621793f4
JS
698void wxMDIClientWindow::OnPageChanged(wxNotebookEvent& event)
699{
700 // Notify child that it has been activated
701 if (event.GetOldSelection() != -1)
702 {
703 wxMDIChildFrame* oldChild = (wxMDIChildFrame*) GetPage(event.GetOldSelection());
704 if (oldChild)
705 {
706 wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldChild->GetId());
707 event.SetEventObject( oldChild );
708 oldChild->GetEventHandler()->ProcessEvent(event);
709 }
710 }
7fe7d506 711 if (event.GetSelection() != -1)
621793f4 712 {
2d120f83
JS
713 wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
714 if (activeChild)
621793f4 715 {
2d120f83
JS
716 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
717 event.SetEventObject( activeChild );
718 activeChild->GetEventHandler()->ProcessEvent(event);
dfe1eee3 719
2d120f83
JS
720 if (activeChild->GetMDIParentFrame())
721 {
722 activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
723 activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
724 }
621793f4
JS
725 }
726 }
727 event.Skip();
728}