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