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