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