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