]>
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 | ||
31 | #include "mdi/lib/XsMDICanvas.h" | |
32 | #include "mdi/lib/XsMotifWindow.h" | |
33 | ||
34 | #include "wx/motif/private.h" | |
35 | ||
4bb6408c JS |
36 | extern wxList wxModelessWindows; |
37 | ||
8704bf74 JS |
38 | // Implemented in frame.cpp |
39 | extern void wxFrameFocusProc(Widget workArea, XtPointer clientData, | |
40 | XmAnyCallbackStruct *cbs); | |
41 | ||
4bb6408c JS |
42 | #if !USE_SHARED_LIBRARY |
43 | IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) | |
44 | IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) | |
45 | IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) | |
46 | ||
47 | BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) | |
48 | EVT_SIZE(wxMDIParentFrame::OnSize) | |
49 | EVT_ACTIVATE(wxMDIParentFrame::OnActivate) | |
50 | EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) | |
51 | END_EVENT_TABLE() | |
52 | ||
53 | BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow) | |
54 | EVT_SCROLL(wxMDIClientWindow::OnScroll) | |
55 | END_EVENT_TABLE() | |
56 | ||
57 | #endif | |
58 | ||
8704bf74 JS |
59 | /* |
60 | static void _doNothingCallback (Widget, XtPointer, XtPointer) | |
61 | { | |
62 | } | |
63 | */ | |
64 | ||
65 | // wxXsMDIWindow represents the MDI child frame, as far as the MDI | |
66 | // package is concerned. | |
67 | // TODO: override raise, so we can tell which is the 'active' | |
68 | // (raised) window. We can also use it to send wxActivateEvents, | |
69 | // and switching menubars when we make the child frame menubar | |
70 | // appear on the parent frame. | |
71 | ||
72 | // Note: see XsMotifWindow.C, _XsMotifMenu::_processItem for | |
73 | // where user menu selections are processed. | |
74 | // When Close is selected, _win->close() is called. | |
75 | ||
76 | class wxXsMDIWindow: public XsMotifWindow | |
77 | { | |
78 | public: | |
79 | wxMDIChildFrame* m_childFrame; | |
80 | ||
81 | wxXsMDIWindow(const char* name, wxMDIChildFrame* frame): XsMotifWindow(name) | |
82 | { | |
83 | m_childFrame = frame; | |
84 | } | |
85 | virtual void setSize(Dimension w, Dimension h) | |
86 | { | |
87 | XsMotifWindow::setSize(w, h); | |
88 | ||
89 | // Generate wxSizeEvent here, I think. Maybe also restore, maximize | |
90 | // Probably don't need to generate size event here since work area | |
0d57be45 | 91 | // is used (???) |
8704bf74 JS |
92 | wxSizeEvent event(wxSize(w, h), m_childFrame->GetId()); |
93 | event.SetEventObject(m_childFrame); | |
94 | m_childFrame->ProcessEvent(event); | |
95 | } | |
96 | virtual void close() | |
97 | { | |
98 | XsMotifWindow::close(); | |
99 | m_childFrame->Close(); | |
100 | } | |
0d57be45 JS |
101 | virtual void raise() |
102 | { | |
103 | XsMotifWindow::raise(); | |
104 | m_childFrame->OnRaise(); | |
105 | } | |
106 | virtual void lower() | |
107 | { | |
108 | XsMotifWindow::lower(); | |
109 | m_childFrame->OnLower(); | |
110 | } | |
8704bf74 JS |
111 | virtual void _buildClientArea(Widget parent) |
112 | { | |
113 | m_childFrame->BuildClientArea((WXWidget) parent); | |
114 | ||
115 | // Code from MDI sample | |
116 | #if 0 | |
117 | assert (parent != 0); | |
118 | ||
119 | Widget pulldown; | |
120 | Widget cascade; | |
121 | Widget button; | |
122 | ||
123 | // Create a main window with some dummy menus | |
124 | ||
125 | Widget mainW = XtVaCreateWidget ("mainWin", xmMainWindowWidgetClass, parent, | |
126 | XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, | |
127 | XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, | |
128 | NULL); | |
129 | ||
130 | // Create a menubar | |
131 | ||
132 | Widget menuBar = XmCreateMenuBar (mainW, "menuBar", NULL, 0); | |
133 | ||
134 | // Create the "file" menu | |
135 | ||
136 | pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0); | |
137 | cascade = XtVaCreateManagedWidget ("fileMenu", xmCascadeButtonGadgetClass, | |
138 | menuBar, XmNsubMenuId, pulldown, NULL); | |
139 | ||
140 | button = XtVaCreateManagedWidget ("openMenuItem", xmPushButtonGadgetClass, | |
141 | pulldown, NULL); | |
142 | XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this); | |
143 | ||
144 | button = XtVaCreateManagedWidget ("newMenuItem", xmPushButtonGadgetClass, | |
145 | pulldown, NULL); | |
146 | // XtAddCallback (button, XmNactivateCallback, _newWindowCallback, (XtPointer)this); | |
147 | ||
148 | // Create the "edit" menu | |
149 | ||
150 | pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0); | |
151 | cascade = XtVaCreateManagedWidget ("editMenu", xmCascadeButtonGadgetClass, | |
152 | menuBar, XmNsubMenuId, pulldown, NULL); | |
153 | ||
154 | button = XtVaCreateManagedWidget ("cutMenuItem", xmPushButtonGadgetClass, | |
155 | pulldown, NULL); | |
156 | XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this); | |
157 | ||
158 | button = XtVaCreateManagedWidget ("copyMenuItem", xmPushButtonGadgetClass, | |
159 | pulldown, NULL); | |
160 | XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this); | |
161 | ||
162 | button = XtVaCreateManagedWidget ("pasteMenuItem", xmPushButtonGadgetClass, | |
163 | pulldown, NULL); | |
164 | XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this); | |
165 | ||
166 | // Create the help menu | |
167 | ||
168 | pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0); | |
169 | cascade = XtVaCreateManagedWidget ("helpMenu", xmCascadeButtonGadgetClass, | |
170 | menuBar, XmNsubMenuId, pulldown, NULL); | |
171 | ||
172 | button = XtVaCreateManagedWidget ("aboutMenuItem", xmPushButtonGadgetClass, | |
173 | pulldown, NULL); | |
174 | XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this); | |
175 | ||
176 | XtVaSetValues (menuBar, XmNmenuHelpWidget, cascade, NULL); | |
177 | ||
178 | // Manage the menubar | |
179 | ||
180 | XtManageChild (menuBar); | |
181 | ||
182 | // Create the work area | |
183 | ||
184 | const int nargs = 8; | |
185 | Arg args[nargs]; | |
186 | int n; | |
187 | ||
188 | n = 0; | |
189 | XtSetArg (args[n], XmNscrollingPolicy, XmAUTOMATIC); n++; | |
190 | XtSetArg (args[n], XmNhighlightThickness, (Dimension)0); n++; | |
191 | XtSetArg (args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; | |
192 | XtSetArg (args[n], XmNeditable, True); n++; | |
193 | XtSetArg (args[n], XmNwordWrap, False); n++; | |
194 | XtSetArg (args[n], XmNcursorPositionVisible, True); n++; | |
195 | XtSetArg (args[n], XmNverifyBell, True); n++; | |
196 | ||
197 | assert (n <= nargs); | |
198 | ||
199 | Widget scrolledText = XmCreateScrolledText (mainW, "scrolledText", args, n); | |
200 | XtManageChild (scrolledText); | |
201 | ||
202 | // Set the main window area | |
203 | ||
204 | XtVaSetValues (mainW, XmNmenuBar, menuBar, XmNworkWindow, | |
205 | XtParent (scrolledText), NULL); | |
206 | ||
207 | XtManageChild (mainW); | |
208 | #endif | |
209 | } | |
210 | void Show() { show(); } | |
211 | }; | |
212 | ||
4bb6408c JS |
213 | // Parent frame |
214 | ||
215 | wxMDIParentFrame::wxMDIParentFrame() | |
216 | { | |
0d57be45 JS |
217 | m_clientWindow = (wxMDIClientWindow*) NULL; |
218 | m_activeChild = (wxMDIChildFrame*) NULL; | |
4bb6408c JS |
219 | } |
220 | ||
221 | bool wxMDIParentFrame::Create(wxWindow *parent, | |
222 | wxWindowID id, | |
223 | const wxString& title, | |
224 | const wxPoint& pos, | |
225 | const wxSize& size, | |
226 | long style, | |
227 | const wxString& name) | |
228 | { | |
0d57be45 JS |
229 | m_clientWindow = (wxMDIClientWindow*) NULL; |
230 | m_activeChild = (wxMDIChildFrame*) NULL; | |
4bb6408c | 231 | |
8704bf74 JS |
232 | bool success = wxFrame::Create(parent, id, title, pos, size, style, name); |
233 | if (success) | |
234 | { | |
235 | // TODO: app cannot override OnCreateClient since | |
236 | // wxMDIParentFrame::OnCreateClient will still be called | |
237 | // (we're in the constructor). How to resolve? | |
238 | ||
239 | m_clientWindow = OnCreateClient(); | |
240 | // Uses own style for client style | |
241 | m_clientWindow->CreateClient(this, GetWindowStyleFlag()); | |
242 | return TRUE; | |
243 | } | |
4bb6408c | 244 | else |
8704bf74 | 245 | return FALSE; |
4bb6408c JS |
246 | } |
247 | ||
248 | wxMDIParentFrame::~wxMDIParentFrame() | |
249 | { | |
8704bf74 JS |
250 | DestroyChildren(); |
251 | delete m_clientWindow; | |
4bb6408c JS |
252 | } |
253 | ||
254 | // Get size *available for subwindows* i.e. excluding menu bar. | |
255 | void wxMDIParentFrame::GetClientSize(int *x, int *y) const | |
256 | { | |
8704bf74 | 257 | wxFrame::GetClientSize(x, y); |
4bb6408c JS |
258 | } |
259 | ||
260 | void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) | |
261 | { | |
8704bf74 | 262 | wxFrame::SetMenuBar(menu_bar); |
4bb6408c JS |
263 | } |
264 | ||
265 | void wxMDIParentFrame::OnSize(wxSizeEvent& event) | |
266 | { | |
47d67540 | 267 | #if wxUSE_CONSTRAINTS |
4bb6408c JS |
268 | if (GetAutoLayout()) |
269 | Layout(); | |
270 | #endif | |
271 | int x = 0; | |
272 | int y = 0; | |
273 | int width, height; | |
274 | GetClientSize(&width, &height); | |
275 | ||
276 | if ( GetClientWindow() ) | |
277 | GetClientWindow()->SetSize(x, y, width, height); | |
278 | } | |
279 | ||
280 | void wxMDIParentFrame::OnActivate(wxActivateEvent& event) | |
281 | { | |
282 | // Do nothing | |
283 | } | |
284 | ||
285 | // Returns the active MDI child window | |
286 | wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const | |
287 | { | |
0d57be45 | 288 | return m_activeChild; |
4bb6408c JS |
289 | } |
290 | ||
291 | // Create the client window class (don't Create the window, | |
292 | // just return a new class) | |
293 | wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() | |
294 | { | |
295 | return new wxMDIClientWindow ; | |
296 | } | |
297 | ||
298 | // Responds to colour changes, and passes event on to children. | |
299 | void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) | |
300 | { | |
301 | // TODO | |
302 | ||
303 | // Propagate the event to the non-top-level children | |
304 | wxFrame::OnSysColourChanged(event); | |
305 | } | |
306 | ||
307 | // MDI operations | |
308 | void wxMDIParentFrame::Cascade() | |
309 | { | |
310 | // TODO | |
311 | } | |
312 | ||
313 | void wxMDIParentFrame::Tile() | |
314 | { | |
315 | // TODO | |
316 | } | |
317 | ||
318 | void wxMDIParentFrame::ArrangeIcons() | |
319 | { | |
320 | // TODO | |
321 | } | |
322 | ||
323 | void wxMDIParentFrame::ActivateNext() | |
324 | { | |
325 | // TODO | |
326 | } | |
327 | ||
328 | void wxMDIParentFrame::ActivatePrevious() | |
329 | { | |
330 | // TODO | |
331 | } | |
332 | ||
333 | // Child frame | |
334 | ||
335 | wxMDIChildFrame::wxMDIChildFrame() | |
336 | { | |
337 | } | |
338 | ||
339 | bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, | |
340 | wxWindowID id, | |
341 | const wxString& title, | |
342 | const wxPoint& pos, | |
343 | const wxSize& size, | |
344 | long style, | |
345 | const wxString& name) | |
346 | { | |
347 | SetName(name); | |
348 | ||
349 | if ( id > -1 ) | |
350 | m_windowId = id; | |
351 | else | |
352 | m_windowId = (int)NewControlId(); | |
353 | ||
354 | if (parent) parent->AddChild(this); | |
355 | ||
8704bf74 JS |
356 | int x = pos.x; int y = pos.y; |
357 | int width = size.x; 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 | |
8704bf74 JS |
362 | |
363 | wxMDIClientWindow* clientWindow = parent->GetClientWindow(); | |
364 | if (!clientWindow) | |
365 | return FALSE; | |
366 | ||
0d57be45 JS |
367 | // We're deactivating the old child |
368 | wxMDIChildFrame* oldActiveChild = parent->GetActiveChild(); | |
369 | if (oldActiveChild) | |
370 | { | |
371 | wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); | |
372 | event.SetEventObject( oldActiveChild ); | |
373 | oldActiveChild->GetEventHandler()->ProcessEvent(event); | |
374 | } | |
375 | ||
8704bf74 JS |
376 | m_mdiWindow = new wxXsMDIWindow("mdiChildWindow", this); |
377 | clientWindow->GetMDICanvas()->add(m_mdiWindow); | |
0d57be45 JS |
378 | |
379 | // This is the currently active child | |
380 | parent->SetActiveChild((wxMDIChildFrame*) this); | |
381 | ||
8704bf74 | 382 | m_mdiWindow->Show(); |
0d57be45 | 383 | |
8704bf74 JS |
384 | #if 0 |
385 | m_mainWidget = (WXWidget) (Widget) (*m_mdiWindow); | |
386 | ||
387 | m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window", | |
388 | xmMainWindowWidgetClass, (Widget) m_mainWidget, | |
389 | XmNresizePolicy, XmRESIZE_NONE, | |
390 | NULL); | |
391 | ||
392 | m_workArea = (WXWidget) XtVaCreateWidget("form", | |
393 | xmFormWidgetClass, (Widget) m_frameWidget, | |
394 | XmNresizePolicy, XmRESIZE_NONE, | |
395 | NULL); | |
396 | ||
397 | m_clientArea = (WXWidget) XtVaCreateWidget("client", | |
398 | xmBulletinBoardWidgetClass, (Widget) m_workArea, | |
399 | XmNmarginWidth, 0, | |
400 | XmNmarginHeight, 0, | |
401 | XmNrightAttachment, XmATTACH_FORM, | |
402 | XmNleftAttachment, XmATTACH_FORM, | |
403 | XmNtopAttachment, XmATTACH_FORM, | |
404 | XmNbottomAttachment, XmATTACH_FORM, | |
405 | // XmNresizePolicy, XmRESIZE_ANY, | |
406 | NULL); | |
407 | ||
408 | XtVaSetValues((Widget) m_frameWidget, | |
409 | XmNworkWindow, (Widget) m_workArea, | |
410 | NULL); | |
411 | ||
412 | XtManageChild((Widget) m_clientArea); | |
413 | XtManageChild((Widget) m_workArea); | |
414 | ||
415 | wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ; | |
416 | ||
417 | wxAddWindowToTable((Widget) m_workArea, this); | |
418 | ||
419 | XtTranslations ptr ; | |
420 | ||
421 | XtOverrideTranslations((Widget) m_workArea, | |
422 | ptr = XtParseTranslationTable("<Configure>: resize()")); | |
423 | ||
424 | XtFree((char *)ptr); | |
425 | ||
426 | XtAddCallback((Widget) m_workArea, XmNfocusCallback, | |
427 | (XtCallbackProc)wxFrameFocusProc, (XtPointer)this); | |
428 | ||
429 | if (x > -1) | |
430 | XtVaSetValues((Widget) m_mainWidget, XmNx, x, NULL); | |
431 | if (y > -1) | |
432 | XtVaSetValues((Widget) m_mainWidget, XmNy, y, NULL); | |
433 | if (width > -1) | |
434 | XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL); | |
435 | if (height > -1) | |
436 | XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL); | |
437 | #endif | |
438 | ||
439 | SetTitle(title); | |
440 | ||
441 | PreResize(); | |
442 | ||
0d57be45 | 443 | m_mdiWindow->setSize(width, height); |
4bb6408c JS |
444 | |
445 | wxModelessWindows.Append(this); | |
8704bf74 JS |
446 | return TRUE; |
447 | } | |
448 | ||
449 | void wxMDIChildFrame::BuildClientArea(WXWidget parent) | |
450 | { | |
451 | m_mainWidget = parent; | |
452 | ||
453 | m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window", | |
454 | xmMainWindowWidgetClass, (Widget) m_mainWidget, | |
455 | XmNresizePolicy, XmRESIZE_NONE, | |
456 | XmNtopAttachment, XmATTACH_FORM, | |
457 | XmNbottomAttachment, XmATTACH_FORM, | |
458 | XmNleftAttachment, XmATTACH_FORM, | |
459 | XmNrightAttachment, XmATTACH_FORM, | |
460 | NULL); | |
461 | ||
462 | m_workArea = (WXWidget) XtVaCreateWidget("form", | |
463 | xmFormWidgetClass, (Widget) m_frameWidget, | |
464 | XmNresizePolicy, XmRESIZE_NONE, | |
465 | NULL); | |
466 | ||
467 | m_clientArea = (WXWidget) XtVaCreateWidget("client", | |
468 | xmBulletinBoardWidgetClass, (Widget) m_workArea, | |
469 | XmNmarginWidth, 0, | |
470 | XmNmarginHeight, 0, | |
471 | XmNrightAttachment, XmATTACH_FORM, | |
472 | XmNleftAttachment, XmATTACH_FORM, | |
473 | XmNtopAttachment, XmATTACH_FORM, | |
474 | XmNbottomAttachment, XmATTACH_FORM, | |
475 | // XmNresizePolicy, XmRESIZE_ANY, | |
476 | NULL); | |
477 | ||
478 | XtVaSetValues((Widget) m_frameWidget, | |
479 | XmNworkWindow, (Widget) m_workArea, | |
480 | NULL); | |
481 | ||
482 | XtManageChild((Widget) m_clientArea); | |
483 | XtManageChild((Widget) m_workArea); | |
484 | ||
485 | wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ; | |
486 | ||
487 | wxAddWindowToTable((Widget) m_workArea, this); | |
488 | ||
489 | XtTranslations ptr ; | |
490 | ||
491 | XtOverrideTranslations((Widget) m_workArea, | |
492 | ptr = XtParseTranslationTable("<Configure>: resize()")); | |
493 | ||
494 | XtFree((char *)ptr); | |
495 | ||
496 | XtAddCallback((Widget) m_workArea, XmNfocusCallback, | |
497 | (XtCallbackProc)wxFrameFocusProc, (XtPointer)this); | |
498 | ||
499 | /* | |
500 | int x = pos.x; int y = pos.y; | |
501 | int width = size.x; int height = size.y; | |
502 | ||
503 | if (x > -1) | |
504 | XtVaSetValues((Widget) m_mainWidget, XmNx, x, NULL); | |
505 | if (y > -1) | |
506 | XtVaSetValues((Widget) m_mainWidget, XmNy, y, NULL); | |
507 | if (width > -1) | |
508 | XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL); | |
509 | if (height > -1) | |
510 | XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL); | |
511 | */ | |
512 | ||
513 | XtManageChild((Widget) m_frameWidget); | |
4bb6408c JS |
514 | } |
515 | ||
8704bf74 | 516 | |
4bb6408c JS |
517 | wxMDIChildFrame::~wxMDIChildFrame() |
518 | { | |
0d57be45 JS |
519 | wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; |
520 | if (parentFrame->GetActiveChild() == this) | |
521 | parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); | |
522 | ||
523 | wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow(); | |
8704bf74 JS |
524 | clientWindow->GetMDICanvas()->remove(m_mdiWindow); |
525 | m_mainWidget = (WXWidget) 0; | |
4bb6408c JS |
526 | } |
527 | ||
0d57be45 JS |
528 | // Implementation: intercept and act upon raise and lower commands. |
529 | void wxMDIChildFrame::OnRaise() | |
530 | { | |
531 | wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; | |
532 | wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); | |
533 | parentFrame->SetActiveChild(this); | |
534 | ||
535 | if (oldActiveChild) | |
536 | { | |
537 | wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); | |
538 | event.SetEventObject( oldActiveChild ); | |
539 | oldActiveChild->GetEventHandler()->ProcessEvent(event); | |
540 | } | |
541 | ||
542 | wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId()); | |
543 | event.SetEventObject( this ); | |
544 | this->GetEventHandler()->ProcessEvent(event); | |
545 | } | |
546 | ||
547 | void wxMDIChildFrame::OnLower() | |
548 | { | |
549 | wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; | |
550 | wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); | |
551 | ||
552 | if (oldActiveChild == this) | |
553 | { | |
554 | wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); | |
555 | event.SetEventObject( oldActiveChild ); | |
556 | oldActiveChild->GetEventHandler()->ProcessEvent(event); | |
557 | } | |
558 | // TODO: unfortunately we don't now know which is the top-most child, | |
559 | // so make the active child NULL. | |
560 | parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); | |
561 | } | |
562 | ||
4bb6408c JS |
563 | // Set the client size (i.e. leave the calculation of borders etc. |
564 | // to wxWindows) | |
565 | void wxMDIChildFrame::SetClientSize(int width, int height) | |
566 | { | |
8704bf74 JS |
567 | wxFrame::SetClientSize(width, height); |
568 | } | |
569 | ||
570 | void wxMDIChildFrame::GetClientSize(int* width, int* height) const | |
571 | { | |
572 | wxFrame::GetClientSize(width, height); | |
573 | } | |
574 | ||
575 | void wxMDIChildFrame::SetSize(int x, int y, int width, int height, int sizeFlags) | |
576 | { | |
577 | wxWindow::SetSize(x, y, width, height, sizeFlags); | |
578 | } | |
579 | ||
580 | void wxMDIChildFrame::GetSize(int* width, int* height) const | |
581 | { | |
582 | wxWindow::GetSize(width, height); | |
4bb6408c JS |
583 | } |
584 | ||
585 | void wxMDIChildFrame::GetPosition(int *x, int *y) const | |
586 | { | |
8704bf74 JS |
587 | wxWindow::GetPosition(x, y); |
588 | } | |
589 | ||
590 | bool wxMDIChildFrame::Show(bool show) | |
591 | { | |
592 | m_visibleStatus = show; /* show-&-hide fix */ | |
593 | return TRUE; | |
4bb6408c JS |
594 | } |
595 | ||
596 | void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) | |
597 | { | |
598 | // TODO | |
8704bf74 JS |
599 | // Currently, the menu appears on the child frame. |
600 | // It should eventually be recreated on the main frame | |
601 | // whenever the child is activated. | |
602 | wxFrame::SetMenuBar(menu_bar); | |
603 | } | |
604 | ||
605 | // Set icon | |
606 | void wxMDIChildFrame::SetIcon(const wxIcon& icon) | |
607 | { | |
608 | m_icon = icon; | |
609 | if (m_icon.Ok()) | |
4bb6408c | 610 | { |
8704bf74 JS |
611 | /* TODO: doesn't work yet (crashes in XCopyArea) |
612 | Pixmap pixmap = (Pixmap) m_icon.GetPixmap(); | |
613 | m_mdiWindow->setPixmap(pixmap); | |
614 | */ | |
4bb6408c | 615 | } |
8704bf74 JS |
616 | } |
617 | ||
618 | void wxMDIChildFrame::SetTitle(const wxString& title) | |
619 | { | |
620 | m_title = title; | |
621 | m_mdiWindow->setTitle(title); | |
622 | m_mdiWindow->setIconName(title); | |
4bb6408c JS |
623 | } |
624 | ||
625 | // MDI operations | |
626 | void wxMDIChildFrame::Maximize() | |
627 | { | |
8704bf74 JS |
628 | m_mdiWindow->maximize(); |
629 | } | |
630 | ||
631 | void wxMDIChildFrame::Iconize(bool iconize) | |
632 | { | |
633 | if (iconize) | |
634 | m_mdiWindow->minimize(); | |
635 | else | |
636 | m_mdiWindow->restore(); | |
637 | } | |
638 | ||
639 | bool wxMDIChildFrame::IsIconized() const | |
640 | { | |
641 | return m_mdiWindow->minimized(); | |
4bb6408c JS |
642 | } |
643 | ||
644 | void wxMDIChildFrame::Restore() | |
645 | { | |
8704bf74 | 646 | m_mdiWindow->restore(); |
4bb6408c JS |
647 | } |
648 | ||
649 | void wxMDIChildFrame::Activate() | |
650 | { | |
8704bf74 | 651 | m_mdiWindow->raise(); |
4bb6408c JS |
652 | } |
653 | ||
654 | // Client window | |
655 | ||
656 | wxMDIClientWindow::wxMDIClientWindow() | |
657 | { | |
8704bf74 JS |
658 | m_mdiCanvas = NULL; |
659 | m_topWidget = (WXWidget) 0; | |
4bb6408c JS |
660 | } |
661 | ||
662 | wxMDIClientWindow::~wxMDIClientWindow() | |
663 | { | |
8704bf74 JS |
664 | DestroyChildren(); |
665 | delete m_mdiCanvas; | |
666 | ||
667 | m_mainWidget = (WXWidget) 0; | |
668 | m_topWidget = (WXWidget) 0; | |
4bb6408c JS |
669 | } |
670 | ||
671 | bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) | |
672 | { | |
8704bf74 | 673 | m_windowParent = parent; |
4bb6408c | 674 | m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); |
8704bf74 JS |
675 | m_mdiCanvas = new XsMDICanvas("mdiClientWindow", (Widget) parent->GetClientWidget()); |
676 | m_mainWidget = (WXWidget) m_mdiCanvas->GetDrawingArea(); | |
677 | // m_topWidget = (WXWidget) m_mdiCanvas->GetBase(); | |
678 | m_topWidget = (WXWidget) (Widget) (*m_mdiCanvas); | |
679 | ||
680 | m_mdiCanvas->show(); | |
681 | ||
682 | return TRUE; | |
683 | } | |
684 | ||
685 | void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags) | |
686 | { | |
687 | wxWindow::SetSize(x, y, width, height, sizeFlags); | |
688 | } | |
4bb6408c | 689 | |
8704bf74 JS |
690 | void wxMDIClientWindow::SetClientSize(int width, int height) |
691 | { | |
692 | wxWindow::SetClientSize(width, height); | |
693 | } | |
694 | ||
695 | void wxMDIClientWindow::GetClientSize(int *width, int *height) const | |
696 | { | |
697 | wxWindow::GetClientSize(width, height); | |
698 | } | |
699 | ||
700 | void wxMDIClientWindow::GetSize(int *width, int *height) const | |
701 | { | |
702 | wxWindow::GetSize(width, height); | |
703 | } | |
704 | ||
705 | void wxMDIClientWindow::GetPosition(int *x, int *y) const | |
706 | { | |
707 | wxWindow::GetPosition(x, y); | |
4bb6408c JS |
708 | } |
709 | ||
710 | // Explicitly call default scroll behaviour | |
711 | void wxMDIClientWindow::OnScroll(wxScrollEvent& event) | |
712 | { | |
713 | Default(); // Default processing | |
714 | } | |
715 |