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