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