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