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