]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mdi.cpp | |
3 | // Purpose: MDI classes | |
75f11ad7 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
75f11ad7 | 6 | // Created: 10/10/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
75f11ad7 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
75f11ad7 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifndef WX_PRECOMP | |
16 | #include "wx/setup.h" | |
17 | #include "wx/frame.h" | |
18 | #include "wx/menu.h" | |
19 | #include "wx/app.h" | |
20 | #include "wx/utils.h" | |
21 | #include "wx/dialog.h" | |
22 | #include "wx/statusbr.h" | |
23 | #include "wx/settings.h" | |
24 | #include "wx/intl.h" | |
25 | #include "wx/log.h" | |
0e320a79 DW |
26 | #endif |
27 | ||
28 | #include "wx/mdi.h" | |
75f11ad7 DW |
29 | #include "wx/os2/private.h" |
30 | ||
31 | #include <string.h> | |
32 | ||
33 | // --------------------------------------------------------------------------- | |
34 | // global variables | |
35 | // --------------------------------------------------------------------------- | |
36 | ||
37 | extern wxWindowList wxModelessWindows; // from dialog.cpp | |
38 | extern wxMenu *wxCurrentPopupMenu; | |
39 | ||
40 | extern wxChar wxMDIFrameClassName[]; | |
41 | extern wxChar wxMDIChildFrameClassName[]; | |
42 | extern wxWindow *wxWndHook; // from window.cpp | |
43 | ||
44 | extern void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); | |
45 | ||
46 | static HWND invalidHandle = 0; | |
47 | ||
48 | // --------------------------------------------------------------------------- | |
49 | // constants | |
50 | // --------------------------------------------------------------------------- | |
51 | ||
52 | static const int IDM_WINDOWTILE = 4001; | |
53 | static const int IDM_WINDOWTILEHOR = 4001; | |
54 | static const int IDM_WINDOWCASCADE = 4002; | |
55 | static const int IDM_WINDOWICONS = 4003; | |
56 | static const int IDM_WINDOWNEXT = 4004; | |
57 | static const int IDM_WINDOWTILEVERT = 4005; | |
58 | ||
59 | // This range gives a maximum of 500 MDI children. Should be enough :-) | |
60 | static const int wxFIRST_MDI_CHILD = 4100; | |
61 | static const int wxLAST_MDI_CHILD = 4600; | |
0e320a79 | 62 | |
75f11ad7 DW |
63 | // Status border dimensions |
64 | static const int wxTHICK_LINE_BORDER = 3; | |
65 | static const int wxTHICK_LINE_WIDTH = 1; | |
66 | ||
67 | // --------------------------------------------------------------------------- | |
68 | // private functions | |
69 | // --------------------------------------------------------------------------- | |
70 | ||
71 | // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu | |
72 | // of the parent of win (which is supposed to be the MDI client window) | |
73 | static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow); | |
74 | ||
75 | // insert the window menu (subMenu) into menu just before "Help" submenu or at | |
76 | // the very end if not found | |
77 | static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu); | |
78 | ||
79 | // is this an id of an MDI child? | |
80 | inline bool IsMdiCommandId(int id) | |
81 | { | |
82 | return (id >= wxFIRST_MDI_CHILD) && (id <= wxLAST_MDI_CHILD); | |
83 | } | |
84 | ||
85 | static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam, | |
86 | WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact); | |
87 | ||
88 | // =========================================================================== | |
89 | // implementation | |
90 | // =========================================================================== | |
91 | ||
92 | // --------------------------------------------------------------------------- | |
93 | // wxWin macros | |
94 | // --------------------------------------------------------------------------- | |
0e320a79 | 95 | |
75f11ad7 DW |
96 | IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) |
97 | IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) | |
98 | IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) | |
0e320a79 DW |
99 | |
100 | BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) | |
75f11ad7 DW |
101 | EVT_SIZE(wxMDIParentFrame::OnSize) |
102 | EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) | |
0e320a79 DW |
103 | END_EVENT_TABLE() |
104 | ||
105 | BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow) | |
75f11ad7 | 106 | EVT_SCROLL(wxMDIClientWindow::OnScroll) |
0e320a79 DW |
107 | END_EVENT_TABLE() |
108 | ||
75f11ad7 DW |
109 | // =========================================================================== |
110 | // wxMDIParentFrame: the frame which contains the client window which manages | |
111 | // the children | |
112 | // =========================================================================== | |
0e320a79 DW |
113 | |
114 | wxMDIParentFrame::wxMDIParentFrame() | |
115 | { | |
75f11ad7 DW |
116 | m_clientWindow = NULL; |
117 | m_currentChild = NULL; | |
118 | m_windowMenu = 0; | |
119 | m_parentFrameActive = TRUE; | |
0e320a79 DW |
120 | } |
121 | ||
122 | bool wxMDIParentFrame::Create(wxWindow *parent, | |
75f11ad7 DW |
123 | wxWindowID id, |
124 | const wxString& title, | |
125 | const wxPoint& pos, | |
126 | const wxSize& size, | |
127 | long style, | |
128 | const wxString& name) | |
0e320a79 | 129 | { |
80d83cbc | 130 | m_hDefaultIcon = (WXHICON) (wxSTD_MDIPARENTFRAME_ICON ? wxSTD_MDIPARENTFRAME_ICON : wxDEFAULT_MDIPARENTFRAME_ICON); |
0e320a79 | 131 | |
75f11ad7 DW |
132 | m_clientWindow = NULL; |
133 | m_currentChild = NULL; | |
134 | m_windowMenu = 0; | |
135 | m_parentFrameActive = TRUE; | |
0e320a79 | 136 | |
75f11ad7 DW |
137 | if (!parent) |
138 | wxTopLevelWindows.Append(this); | |
0e320a79 | 139 | |
75f11ad7 DW |
140 | SetName(name); |
141 | m_windowStyle = style; | |
0e320a79 | 142 | |
75f11ad7 | 143 | if (parent) parent->AddChild(this); |
0e320a79 | 144 | |
75f11ad7 DW |
145 | if ( id > -1 ) |
146 | m_windowId = id; | |
147 | else | |
148 | m_windowId = (int)NewControlId(); | |
0e320a79 | 149 | |
75f11ad7 DW |
150 | int x = pos.x; |
151 | int y = pos.y; | |
152 | int width = size.x; | |
153 | int height = size.y; | |
154 | ||
155 | // TODO: m_windowMenu = (WXHMENU) ::LoadMenu(wxGetInstance(), wxT("wxWindowMenu")); | |
156 | /* | |
157 | DWORD msflags = WS_OVERLAPPED; | |
158 | if (style & wxMINIMIZE_BOX) | |
159 | msflags |= WS_MINIMIZEBOX; | |
160 | if (style & wxMAXIMIZE_BOX) | |
161 | msflags |= WS_MAXIMIZEBOX; | |
162 | if (style & wxTHICK_FRAME) | |
163 | msflags |= WS_THICKFRAME; | |
164 | if (style & wxSYSTEM_MENU) | |
165 | msflags |= WS_SYSMENU; | |
166 | if ((style & wxMINIMIZE) || (style & wxICONIZE)) | |
167 | msflags |= WS_MINIMIZE; | |
168 | if (style & wxMAXIMIZE) | |
169 | msflags |= WS_MAXIMIZE; | |
170 | if (style & wxCAPTION) | |
171 | msflags |= WS_CAPTION; | |
172 | ||
173 | if (style & wxCLIP_CHILDREN) | |
174 | msflags |= WS_CLIPCHILDREN; | |
175 | ||
176 | wxWindow::MSWCreate(m_windowId, parent, wxMDIFrameClassName, this, title, x, y, width, height, | |
177 | msflags); | |
178 | */ | |
179 | wxModelessWindows.Append(this); | |
180 | ||
181 | return TRUE; | |
0e320a79 DW |
182 | } |
183 | ||
184 | wxMDIParentFrame::~wxMDIParentFrame() | |
185 | { | |
75f11ad7 | 186 | DestroyChildren(); |
0e320a79 | 187 | |
75f11ad7 DW |
188 | // TODO: ::DestroyMenu((HMENU)m_windowMenu); |
189 | m_windowMenu = 0; | |
0e320a79 | 190 | |
75f11ad7 | 191 | if ( m_clientWindow ) |
0e320a79 | 192 | { |
75f11ad7 DW |
193 | if ( m_clientWindow->OS2GetOldWndProc() ) |
194 | m_clientWindow->UnsubclassWin(); | |
0e320a79 | 195 | |
75f11ad7 DW |
196 | m_clientWindow->SetHWND(0); |
197 | delete m_clientWindow; | |
198 | } | |
0e320a79 DW |
199 | } |
200 | ||
75f11ad7 | 201 | void wxMDIParentFrame::InternalSetMenuBar() |
0e320a79 | 202 | { |
75f11ad7 DW |
203 | // TODO: |
204 | /* | |
205 | HMENU subMenu = GetSubMenu((HMENU) m_windowMenu, 0); | |
0e320a79 | 206 | |
75f11ad7 DW |
207 | m_parentFrameActive = TRUE; |
208 | ||
209 | InsertWindowMenu(GetClientWindow(), m_hMenu, subMenu); | |
210 | */ | |
0e320a79 DW |
211 | } |
212 | ||
75f11ad7 | 213 | void wxMDIParentFrame::OnSize(wxSizeEvent& event) |
0e320a79 | 214 | { |
75f11ad7 DW |
215 | // TODO: |
216 | /* | |
217 | if ( GetClientWindow() ) | |
218 | { | |
219 | int width, height; | |
220 | GetClientSize(&width, &height); | |
221 | ||
222 | GetClientWindow()->SetSize(0, 0, width, height); | |
223 | } | |
224 | */ | |
0e320a79 DW |
225 | } |
226 | ||
227 | // Returns the active MDI child window | |
228 | wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const | |
229 | { | |
75f11ad7 DW |
230 | HWND hWnd = 0; // TODO: (HWND)::SendMessage(GetWinHwnd(GetClientWindow()), |
231 | // WM_MDIGETACTIVE, 0, 0L); | |
232 | if ( hWnd == 0 ) | |
233 | return NULL; | |
234 | else | |
235 | return (wxMDIChildFrame *)wxFindWinFromHandle((WXHWND) hWnd); | |
0e320a79 DW |
236 | } |
237 | ||
75f11ad7 DW |
238 | // Create the client window class (don't Create the window, just return a new |
239 | // class) | |
0e320a79 DW |
240 | wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() |
241 | { | |
75f11ad7 | 242 | return new wxMDIClientWindow; |
0e320a79 DW |
243 | } |
244 | ||
245 | // Responds to colour changes, and passes event on to children. | |
246 | void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) | |
247 | { | |
75f11ad7 DW |
248 | if ( m_clientWindow ) |
249 | { | |
250 | m_clientWindow->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); | |
251 | m_clientWindow->Refresh(); | |
252 | } | |
0e320a79 | 253 | |
75f11ad7 | 254 | event.Skip(); |
0e320a79 DW |
255 | } |
256 | ||
75f11ad7 | 257 | // --------------------------------------------------------------------------- |
0e320a79 | 258 | // MDI operations |
75f11ad7 DW |
259 | // --------------------------------------------------------------------------- |
260 | ||
0e320a79 DW |
261 | void wxMDIParentFrame::Cascade() |
262 | { | |
75f11ad7 | 263 | // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0); |
0e320a79 DW |
264 | } |
265 | ||
75f11ad7 | 266 | // TODO: add a direction argument (hor/vert) |
0e320a79 DW |
267 | void wxMDIParentFrame::Tile() |
268 | { | |
75f11ad7 | 269 | // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, MDITILE_HORIZONTAL, 0); |
0e320a79 DW |
270 | } |
271 | ||
272 | void wxMDIParentFrame::ArrangeIcons() | |
273 | { | |
75f11ad7 | 274 | // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIICONARRANGE, 0, 0); |
0e320a79 DW |
275 | } |
276 | ||
277 | void wxMDIParentFrame::ActivateNext() | |
278 | { | |
75f11ad7 | 279 | // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 0); |
0e320a79 DW |
280 | } |
281 | ||
282 | void wxMDIParentFrame::ActivatePrevious() | |
283 | { | |
75f11ad7 | 284 | // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 1); |
0e320a79 DW |
285 | } |
286 | ||
75f11ad7 DW |
287 | // --------------------------------------------------------------------------- |
288 | // the MDI parent frame window proc | |
289 | // --------------------------------------------------------------------------- | |
0e320a79 | 290 | |
a885d89a | 291 | MRESULT wxMDIParentFrame::OS2WindowProc(WXUINT message, |
75f11ad7 DW |
292 | WXWPARAM wParam, |
293 | WXLPARAM lParam) | |
0e320a79 | 294 | { |
75f11ad7 DW |
295 | MRESULT rc = 0; |
296 | bool processed = FALSE; | |
297 | ||
298 | // TODO: | |
299 | /* | |
300 | switch ( message ) | |
301 | { | |
302 | case WM_ACTIVATE: | |
303 | { | |
304 | WXWORD state, minimized; | |
305 | WXHWND hwnd; | |
306 | UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); | |
307 | ||
308 | processed = HandleActivate(state, minimized != 0, hwnd); | |
309 | } | |
310 | break; | |
311 | ||
312 | case WM_COMMAND: | |
313 | { | |
314 | WXWORD id, cmd; | |
315 | WXHWND hwnd; | |
316 | UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); | |
317 | ||
318 | (void)HandleCommand(id, cmd, hwnd); | |
319 | ||
320 | // even if the frame didn't process it, there is no need to try it | |
321 | // once again (i.e. call wxFrame::HandleCommand()) - we just dud it, | |
322 | // so pretend we processed the message anyhow | |
323 | processed = TRUE; | |
324 | } | |
325 | ||
326 | // always pass this message DefFrameProc(), otherwise MDI menu | |
327 | // commands (and sys commands - more surprizingly!) won't work | |
328 | MSWDefWindowProc(message, wParam, lParam); | |
329 | break; | |
330 | ||
331 | case WM_CREATE: | |
332 | m_clientWindow = OnCreateClient(); | |
333 | // Uses own style for client style | |
334 | if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) ) | |
335 | { | |
336 | wxLogMessage(_("Failed to create MDI parent frame.")); | |
337 | ||
338 | rc = -1; | |
339 | } | |
340 | ||
341 | processed = TRUE; | |
342 | break; | |
343 | ||
344 | case WM_ERASEBKGND: | |
345 | processed = TRUE; | |
346 | ||
347 | // we erase background ourselves | |
348 | rc = TRUE; | |
349 | break; | |
350 | ||
351 | case WM_MENUSELECT: | |
352 | { | |
353 | WXWORD item, flags; | |
354 | WXHMENU hmenu; | |
355 | UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); | |
356 | ||
357 | if ( m_parentFrameActive ) | |
358 | { | |
359 | processed = HandleMenuSelect(item, flags, hmenu); | |
360 | } | |
361 | else if (m_currentChild) | |
362 | { | |
363 | processed = m_currentChild-> | |
364 | HandleMenuSelect(item, flags, hmenu); | |
365 | } | |
366 | } | |
367 | break; | |
368 | ||
369 | case WM_SIZE: | |
370 | // as we don't (usually) resize the MDI client to exactly fit the | |
371 | // client area (we put it below the toolbar, above statusbar &c), | |
372 | // we should not pass this one to DefFrameProc | |
373 | break; | |
374 | } | |
375 | */ | |
376 | if ( !processed ) | |
80d83cbc | 377 | rc = wxFrame::OS2WindowProc(message, wParam, lParam); |
75f11ad7 DW |
378 | |
379 | return rc; | |
0e320a79 DW |
380 | } |
381 | ||
75f11ad7 | 382 | bool wxMDIParentFrame::HandleActivate(int state, bool minimized, WXHWND activate) |
0e320a79 | 383 | { |
75f11ad7 | 384 | bool processed = FALSE; |
0e320a79 | 385 | |
75f11ad7 DW |
386 | // TODO: |
387 | /* | |
388 | if ( wxWindow::HandleActivate(state, minimized, activate) ) | |
389 | { | |
390 | // already processed | |
391 | processed = TRUE; | |
392 | } | |
393 | ||
394 | // If this window is an MDI parent, we must also send an OnActivate message | |
395 | // to the current child. | |
396 | if ( (m_currentChild != NULL) && | |
397 | ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) ) | |
398 | { | |
399 | wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_currentChild->GetId()); | |
400 | event.SetEventObject( m_currentChild ); | |
401 | if ( m_currentChild->GetEventHandler()->ProcessEvent(event) ) | |
402 | processed = TRUE; | |
403 | } | |
404 | */ | |
405 | return processed; | |
406 | } | |
407 | ||
408 | bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) | |
409 | { | |
410 | // In case it's e.g. a toolbar. | |
411 | if ( hwnd ) | |
412 | { | |
413 | wxWindow *win = wxFindWinFromHandle(hwnd); | |
414 | if ( win ) | |
415 | return FALSE; // Need to get wxWindow for OS/2 up to date: win->OS2Command(cmd, id); | |
416 | } | |
417 | ||
418 | // is it one of standard MDI commands? | |
419 | WXWPARAM wParam = 0; | |
9dea36ef | 420 | int msg = 0; |
75f11ad7 DW |
421 | |
422 | // TODO: | |
423 | /* | |
424 | switch ( id ) | |
425 | { | |
426 | case IDM_WINDOWCASCADE: | |
427 | msg = WM_MDICASCADE; | |
428 | wParam = MDITILE_SKIPDISABLED; | |
429 | break; | |
430 | ||
431 | case IDM_WINDOWTILEHOR: | |
432 | wParam |= MDITILE_HORIZONTAL; | |
433 | // fall through | |
434 | ||
435 | case IDM_WINDOWTILEVERT: | |
436 | if ( !wParam ) | |
437 | wParam = MDITILE_VERTICAL; | |
438 | msg = WM_MDITILE; | |
439 | wParam |= MDITILE_SKIPDISABLED; | |
440 | break; | |
441 | ||
442 | case IDM_WINDOWICONS: | |
443 | msg = WM_MDIICONARRANGE; | |
444 | break; | |
445 | ||
446 | case IDM_WINDOWNEXT: | |
447 | msg = WM_MDINEXT; | |
448 | break; | |
449 | ||
450 | default: | |
451 | msg = 0; | |
452 | } | |
453 | */ | |
454 | if ( msg ) | |
455 | { | |
456 | // TODO: ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, 0); | |
457 | ||
458 | return TRUE; | |
459 | } | |
460 | ||
461 | // FIXME VZ: what does this test do?? | |
462 | if (id >= 0xF000) | |
463 | { | |
464 | return FALSE; // Get WndProc to call default proc | |
465 | } | |
466 | ||
467 | if ( IsMdiCommandId(id) ) | |
468 | { | |
469 | wxWindowList::Node* node = GetChildren().GetFirst(); | |
470 | while ( node ) | |
471 | { | |
472 | wxWindow* child = node->GetData(); | |
473 | if ( child->GetHWND() ) | |
474 | { | |
475 | long childId = wxGetWindowId(child->GetHWND()); | |
476 | if (childId == (long)id) | |
477 | { | |
478 | // TODO: ::SendMessage( GetWinHwnd(GetClientWindow()), | |
479 | // WM_MDIACTIVATE, | |
480 | // (WPARAM)child->GetHWND(), 0); | |
481 | return TRUE; | |
482 | } | |
483 | } | |
484 | node = node->GetNext(); | |
485 | } | |
486 | } | |
487 | else if ( m_parentFrameActive ) | |
488 | { | |
489 | return ProcessCommand(id); | |
490 | } | |
491 | else if ( m_currentChild ) | |
492 | { | |
493 | return m_currentChild->HandleCommand(id, cmd, hwnd); | |
494 | } | |
495 | else | |
496 | { | |
497 | // this shouldn't happen because it means that our messages are being | |
498 | // lost (they're not sent to the parent frame nor to the children) | |
499 | wxFAIL_MSG(wxT("MDI parent frame is not active, " | |
500 | "yet there is no active MDI child?")); | |
501 | } | |
502 | ||
503 | return FALSE; | |
504 | } | |
505 | ||
a885d89a | 506 | MRESULT wxMDIParentFrame::OS2DefWindowProc(WXUINT message, |
75f11ad7 DW |
507 | WXWPARAM wParam, |
508 | WXLPARAM lParam) | |
509 | { | |
510 | WXHWND clientWnd; | |
511 | if ( GetClientWindow() ) | |
512 | clientWnd = GetClientWindow()->GetHWND(); | |
0e320a79 | 513 | else |
75f11ad7 DW |
514 | clientWnd = 0; |
515 | ||
516 | // TODO: return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam); | |
517 | return((MRESULT)0); | |
518 | } | |
0e320a79 | 519 | |
75f11ad7 DW |
520 | bool wxMDIParentFrame::OS2TranslateMessage(WXMSG* msg) |
521 | { | |
522 | // TODO: | |
523 | /* | |
524 | if ( m_currentChild && m_currentChild->GetHWND() && | |
525 | m_currentChild->OS2TranslateMessage(msg) ) | |
526 | { | |
527 | return TRUE; | |
528 | } | |
0e320a79 | 529 | |
75f11ad7 DW |
530 | if ( m_acceleratorTable.Translate(this, msg) ) |
531 | { | |
532 | return TRUE; | |
533 | } | |
0e320a79 | 534 | |
75f11ad7 DW |
535 | if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN ) |
536 | { | |
537 | if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg)) | |
538 | return TRUE; | |
539 | } | |
540 | */ | |
0e320a79 DW |
541 | return FALSE; |
542 | } | |
543 | ||
75f11ad7 DW |
544 | // =========================================================================== |
545 | // wxMDIChildFrame | |
546 | // =========================================================================== | |
547 | ||
548 | wxMDIChildFrame::wxMDIChildFrame() | |
549 | { | |
550 | } | |
551 | ||
552 | bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, | |
553 | wxWindowID id, | |
554 | const wxString& title, | |
555 | const wxPoint& pos, | |
556 | const wxSize& size, | |
557 | long style, | |
558 | const wxString& name) | |
559 | { | |
80d83cbc DW |
560 | m_hDefaultIcon = (WXHICON)(wxSTD_MDICHILDFRAME_ICON ? wxSTD_MDICHILDFRAME_ICON |
561 | : wxDEFAULT_MDICHILDFRAME_ICON); | |
75f11ad7 DW |
562 | |
563 | SetName(name); | |
564 | ||
565 | if ( id > -1 ) | |
566 | m_windowId = id; | |
567 | else | |
568 | m_windowId = (int)NewControlId(); | |
569 | ||
570 | if ( parent ) | |
571 | { | |
572 | parent->AddChild(this); | |
573 | } | |
574 | ||
575 | wxWndHook = this; | |
576 | ||
577 | int x = pos.x; | |
578 | int y = pos.y; | |
579 | int width = size.x; | |
580 | int height = size.y; | |
581 | ||
582 | // TODO: | |
583 | /* | |
584 | MDICREATESTRUCT mcs; | |
585 | ||
586 | mcs.szClass = wxMDIChildFrameClassName; | |
587 | mcs.szTitle = title; | |
588 | mcs.hOwner = wxGetInstance(); | |
589 | if (x > -1) | |
590 | mcs.x = x; | |
591 | else | |
592 | mcs.x = CW_USEDEFAULT; | |
593 | ||
594 | if (y > -1) | |
595 | mcs.y = y; | |
596 | else | |
597 | mcs.y = CW_USEDEFAULT; | |
598 | ||
599 | if (width > -1) | |
600 | mcs.cx = width; | |
601 | else | |
602 | mcs.cx = CW_USEDEFAULT; | |
603 | ||
604 | if (height > -1) | |
605 | mcs.cy = height; | |
606 | else | |
607 | mcs.cy = CW_USEDEFAULT; | |
608 | ||
609 | DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN; | |
610 | if (style & wxMINIMIZE_BOX) | |
611 | msflags |= WS_MINIMIZEBOX; | |
612 | if (style & wxMAXIMIZE_BOX) | |
613 | msflags |= WS_MAXIMIZEBOX; | |
614 | if (style & wxTHICK_FRAME) | |
615 | msflags |= WS_THICKFRAME; | |
616 | if (style & wxSYSTEM_MENU) | |
617 | msflags |= WS_SYSMENU; | |
618 | if ((style & wxMINIMIZE) || (style & wxICONIZE)) | |
619 | msflags |= WS_MINIMIZE; | |
620 | if (style & wxMAXIMIZE) | |
621 | msflags |= WS_MAXIMIZE; | |
622 | if (style & wxCAPTION) | |
623 | msflags |= WS_CAPTION; | |
624 | ||
625 | mcs.style = msflags; | |
626 | ||
627 | mcs.lParam = 0; | |
628 | */ | |
629 | DWORD Return = 0; // SendMessage(GetWinHwnd(parent->GetClientWindow()), | |
630 | // WM_MDICREATE, 0, (LONG)(LPSTR)&mcs); | |
631 | m_hWnd = (WXHWND)Return; | |
632 | ||
633 | wxWndHook = NULL; | |
634 | wxAssociateWinWithHandle((HWND) GetHWND(), this); | |
635 | ||
636 | // VZ: what's this? an act of piracy? | |
637 | //SetWindowLong(GetHwnd(), 0, (long)this); | |
638 | ||
639 | wxModelessWindows.Append(this); | |
640 | return TRUE; | |
641 | } | |
642 | ||
0e320a79 DW |
643 | wxMDIChildFrame::~wxMDIChildFrame() |
644 | { | |
75f11ad7 | 645 | OS2DestroyWindow(); |
0e320a79 DW |
646 | } |
647 | ||
648 | // Set the client size (i.e. leave the calculation of borders etc. | |
649 | // to wxWindows) | |
75f11ad7 | 650 | void wxMDIChildFrame::DoSetClientSize(int width, int height) |
0e320a79 | 651 | { |
75f11ad7 DW |
652 | HWND hWnd = GetHwnd(); |
653 | ||
654 | // TODO: | |
655 | /* | |
656 | RECT rect; | |
657 | ::GetClientRect(hWnd, &rect); | |
658 | ||
659 | RECT rect2; | |
660 | GetWindowRect(hWnd, &rect2); | |
661 | ||
662 | // Find the difference between the entire window (title bar and all) | |
663 | // and the client area; add this to the new client size to move the | |
664 | // window | |
665 | int actual_width = rect2.right - rect2.left - rect.right + width; | |
666 | int actual_height = rect2.bottom - rect2.top - rect.bottom + height; | |
667 | ||
668 | if (GetStatusBar()) | |
669 | { | |
670 | int sx, sy; | |
671 | GetStatusBar()->GetSize(&sx, &sy); | |
672 | actual_height += sy; | |
673 | } | |
674 | ||
675 | POINT point; | |
676 | point.x = rect2.left; | |
677 | point.y = rect2.top; | |
678 | ||
679 | // If there's an MDI parent, must subtract the parent's top left corner | |
680 | // since MoveWindow moves relative to the parent | |
681 | wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent(); | |
682 | ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); | |
683 | ||
684 | MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE); | |
685 | ||
686 | wxSizeEvent event(wxSize(width, height), m_windowId); | |
687 | event.SetEventObject( this ); | |
688 | GetEventHandler()->ProcessEvent(event); | |
689 | */ | |
0e320a79 DW |
690 | } |
691 | ||
75f11ad7 | 692 | void wxMDIChildFrame::DoGetPosition(int *x, int *y) const |
0e320a79 | 693 | { |
75f11ad7 DW |
694 | // TODO: |
695 | /* | |
696 | RECT rect; | |
697 | GetWindowRect(GetHwnd(), &rect); | |
698 | POINT point; | |
699 | point.x = rect.left; | |
700 | point.y = rect.top; | |
701 | ||
702 | // Since we now have the absolute screen coords, | |
703 | // if there's a parent we must subtract its top left corner | |
704 | wxMDIParentFrame *mdiParent = (wxMDIParentFrame *)GetParent(); | |
705 | ::ScreenToClient((HWND) mdiParent->GetClientWindow()->GetHWND(), &point); | |
706 | ||
707 | *x = point.x; | |
708 | *y = point.y; | |
709 | */ | |
0e320a79 DW |
710 | } |
711 | ||
75f11ad7 | 712 | void wxMDIChildFrame::InternalSetMenuBar() |
0e320a79 | 713 | { |
75f11ad7 DW |
714 | // TODO: |
715 | /* | |
716 | ||
717 | wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); | |
718 | ||
719 | HMENU subMenu = GetSubMenu((HMENU)parent->GetWindowMenu(), 0); | |
720 | ||
721 | InsertWindowMenu(parent->GetClientWindow(), m_hMenu, subMenu); | |
722 | ||
723 | parent->m_parentFrameActive = FALSE; | |
724 | */ | |
0e320a79 DW |
725 | } |
726 | ||
75f11ad7 | 727 | // --------------------------------------------------------------------------- |
0e320a79 | 728 | // MDI operations |
75f11ad7 DW |
729 | // --------------------------------------------------------------------------- |
730 | ||
731 | void wxMDIChildFrame::Maximize(bool maximize) | |
0e320a79 | 732 | { |
75f11ad7 DW |
733 | wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); |
734 | // TODO: | |
735 | /* | |
736 | if ( parent && parent->GetClientWindow() ) | |
737 | { | |
738 | ::SendMessage(GetWinHwnd(parent->GetClientWindow()), | |
739 | maximize ? WM_MDIMAXIMIZE : WM_MDIRESTORE, | |
740 | (WPARAM)GetHwnd(), 0); | |
741 | } | |
742 | */ | |
0e320a79 DW |
743 | } |
744 | ||
745 | void wxMDIChildFrame::Restore() | |
746 | { | |
75f11ad7 DW |
747 | // TODO: |
748 | /* | |
749 | wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); | |
750 | if ( parent && parent->GetClientWindow() ) | |
751 | { | |
752 | ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE, | |
753 | (WPARAM) GetHwnd(), 0); | |
754 | } | |
755 | */ | |
0e320a79 DW |
756 | } |
757 | ||
758 | void wxMDIChildFrame::Activate() | |
75f11ad7 DW |
759 | { |
760 | // TODO: | |
761 | /* | |
762 | wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); | |
763 | if ( parent && parent->GetClientWindow() ) | |
764 | { | |
765 | ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE, | |
766 | (WPARAM) GetHwnd(), 0); | |
767 | } | |
768 | */ | |
769 | } | |
770 | ||
771 | // --------------------------------------------------------------------------- | |
772 | // MDI window proc and message handlers | |
773 | // --------------------------------------------------------------------------- | |
774 | ||
a885d89a | 775 | MRESULT wxMDIChildFrame::OS2WindowProc(WXUINT message, |
75f11ad7 DW |
776 | WXWPARAM wParam, |
777 | WXLPARAM lParam) | |
778 | { | |
779 | MRESULT rc = 0; | |
780 | bool processed = FALSE; | |
781 | ||
782 | // TODO: | |
783 | /* | |
784 | switch ( message ) | |
785 | { | |
786 | case WM_COMMAND: | |
787 | { | |
788 | WORD id, cmd; | |
789 | WXHWND hwnd; | |
790 | UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, | |
791 | &id, &hwnd, &cmd); | |
792 | ||
793 | processed = HandleCommand(id, cmd, (WXHWND)hwnd); | |
794 | } | |
795 | break; | |
796 | ||
797 | case WM_GETMINMAXINFO: | |
798 | // let the default window proc calculate the size of MDI children | |
799 | // frames because it is based on the size of the MDI client window, | |
800 | // not on the values specified in wxWindow m_min/max variables | |
801 | return MSWDefWindowProc(message, wParam, lParam); | |
802 | ||
803 | case WM_MDIACTIVATE: | |
804 | { | |
805 | WXWORD act; | |
806 | WXHWND hwndAct, hwndDeact; | |
807 | UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact); | |
808 | ||
809 | processed = HandleMDIActivate(act, hwndAct, hwndDeact); | |
810 | } | |
811 | // fall through | |
812 | ||
813 | case WM_MOVE: | |
814 | // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client | |
815 | // scrollbars if necessary | |
816 | ||
817 | // fall through | |
818 | ||
819 | case WM_SIZE: | |
820 | // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird | |
821 | // things happen | |
822 | MSWDefWindowProc(message, wParam, lParam); | |
823 | break; | |
824 | ||
825 | case WM_SYSCOMMAND: | |
826 | // DefMDIChildProc handles SC_{NEXT/PREV}WINDOW here, so pass it | |
827 | // the message (the base class version does not) | |
828 | return MSWDefWindowProc(message, wParam, lParam); | |
829 | ||
830 | case WM_WINDOWPOSCHANGING: | |
831 | processed = HandleWindowPosChanging((LPWINDOWPOS)lParam); | |
832 | break; | |
833 | } | |
834 | */ | |
835 | if ( !processed ) | |
80d83cbc | 836 | rc = wxFrame::OS2WindowProc(message, wParam, lParam); |
75f11ad7 DW |
837 | |
838 | return rc; | |
839 | } | |
840 | ||
841 | bool wxMDIChildFrame::HandleSize(int x, int y, WXUINT id) | |
842 | { | |
843 | HWND hwnd = GetHwnd(); | |
844 | ||
845 | if ( !hwnd || hwnd == invalidHandle ) | |
846 | { | |
847 | return FALSE; | |
848 | } | |
849 | ||
850 | // TODO: | |
851 | /* | |
852 | switch (id) | |
853 | { | |
854 | case SIZEFULLSCREEN: | |
855 | case SIZENORMAL: | |
856 | m_iconized = FALSE; | |
857 | break; | |
858 | ||
859 | case SIZEICONIC: | |
860 | m_iconized = TRUE; | |
861 | break; | |
862 | } | |
863 | ||
864 | if ( !m_iconized ) | |
865 | { | |
866 | // forward WM_SIZE to status bar control | |
867 | #if wxUSE_NATIVE_STATUSBAR | |
868 | if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))) | |
869 | { | |
870 | wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId()); | |
871 | event.SetEventObject( m_frameStatusBar ); | |
872 | ||
873 | ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event); | |
874 | } | |
875 | #endif // wxUSE_NATIVE_STATUSBAR | |
876 | ||
877 | PositionStatusBar(); | |
878 | PositionToolBar(); | |
879 | ||
880 | return wxWindow::HandleSize(x, y, id); | |
881 | } | |
882 | else | |
883 | { | |
884 | return FALSE; | |
885 | } | |
886 | */ | |
887 | return TRUE; | |
888 | } | |
889 | ||
890 | bool wxMDIChildFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) | |
891 | { | |
892 | // In case it's e.g. a toolbar. | |
893 | if ( hwnd ) | |
894 | { | |
895 | wxWindow *win = wxFindWinFromHandle(hwnd); | |
896 | // if (win) | |
897 | // Fix dependent stuff return win->OS2Command(cmd, id); | |
898 | } | |
899 | ||
900 | if (wxCurrentPopupMenu) | |
901 | { | |
902 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
903 | wxCurrentPopupMenu = NULL; | |
904 | // Fix dependent stuff if (popupMenu->OS2Command(cmd, id)) | |
905 | // return TRUE; | |
906 | } | |
907 | ||
476607a7 | 908 | if (GetMenuBar() && GetMenuBar()->FindItem(id)) |
75f11ad7 DW |
909 | { |
910 | ProcessCommand(id); | |
911 | return TRUE; | |
912 | } | |
913 | else | |
914 | return FALSE; | |
915 | ||
916 | return TRUE; | |
917 | } | |
918 | ||
919 | bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), | |
920 | WXHWND hwndAct, | |
921 | WXHWND hwndDeact) | |
922 | { | |
923 | wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); | |
924 | ||
925 | HMENU menuToSet = 0; | |
926 | ||
927 | bool activated; | |
928 | ||
929 | if ( m_hWnd == hwndAct ) | |
930 | { | |
931 | activated = TRUE; | |
932 | parent->m_currentChild = this; | |
933 | ||
934 | HMENU child_menu = (HMENU)GetWinMenu(); | |
935 | if ( child_menu ) | |
936 | { | |
937 | parent->m_parentFrameActive = FALSE; | |
938 | ||
939 | menuToSet = child_menu; | |
940 | } | |
941 | } | |
942 | else if ( m_hWnd == hwndDeact ) | |
943 | { | |
944 | wxASSERT_MSG( parent->m_currentChild == this, | |
945 | wxT("can't deactivate MDI child which wasn't active!") ); | |
946 | ||
947 | activated = FALSE; | |
948 | parent->m_currentChild = NULL; | |
949 | ||
950 | HMENU parent_menu = (HMENU)parent->GetWinMenu(); | |
951 | if ( parent_menu ) | |
952 | { | |
953 | parent->m_parentFrameActive = TRUE; | |
954 | ||
955 | menuToSet = parent_menu; | |
956 | } | |
957 | } | |
958 | else | |
959 | { | |
960 | // we have nothing to with it | |
961 | return FALSE; | |
962 | } | |
963 | ||
964 | if ( menuToSet ) | |
965 | { | |
966 | HMENU subMenu = 0; // TODO: GetSubMenu((HMENU) parent->GetWindowMenu(), 0); | |
967 | ||
968 | MDISetMenu(parent->GetClientWindow(), menuToSet, subMenu); | |
969 | } | |
970 | ||
971 | wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId); | |
972 | event.SetEventObject( this ); | |
973 | ||
974 | return GetEventHandler()->ProcessEvent(event); | |
975 | } | |
976 | ||
977 | bool wxMDIChildFrame::HandleWindowPosChanging(void *pos) | |
978 | { | |
979 | // WINDOWPOS *lpPos = (WINDOWPOS *)pos; | |
980 | return FALSE; | |
981 | } | |
982 | ||
983 | // --------------------------------------------------------------------------- | |
984 | // MDI specific message translation/preprocessing | |
985 | // --------------------------------------------------------------------------- | |
986 | ||
a885d89a | 987 | MRESULT wxMDIChildFrame::OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
0e320a79 DW |
988 | { |
989 | // TODO | |
75f11ad7 DW |
990 | /* |
991 | return DefMDIChildProc(GetHwnd(), | |
992 | (UINT)message, (WPARAM)wParam, (LPARAM)lParam); | |
993 | */ | |
994 | return (MRESULT)0; | |
0e320a79 DW |
995 | } |
996 | ||
75f11ad7 DW |
997 | bool wxMDIChildFrame::OS2TranslateMessage(WXMSG* msg) |
998 | { | |
999 | return m_acceleratorTable.Translate(GetParent(), msg); | |
1000 | } | |
0e320a79 | 1001 | |
75f11ad7 DW |
1002 | // --------------------------------------------------------------------------- |
1003 | // misc | |
1004 | // --------------------------------------------------------------------------- | |
1005 | ||
1006 | void wxMDIChildFrame::OS2DestroyWindow() | |
0e320a79 | 1007 | { |
75f11ad7 DW |
1008 | // get wxWindow up to date OS2DetachWindowMenu(); |
1009 | invalidHandle = GetHwnd(); | |
1010 | ||
1011 | wxMDIParentFrame *parent = (wxMDIParentFrame *)GetParent(); | |
1012 | ||
1013 | // Must make sure this handle is invalidated (set to NULL) since all sorts | |
1014 | // of things could happen after the child client is destroyed, but before | |
1015 | // the wxFrame is destroyed. | |
1016 | ||
1017 | HWND oldHandle = (HWND)GetHWND(); | |
1018 | // TODO: SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY, | |
1019 | // (WPARAM)oldHandle, 0); | |
1020 | invalidHandle = 0; | |
1021 | ||
1022 | if (m_hMenu) | |
1023 | { | |
1024 | // TODO: ::DestroyMenu((HMENU) m_hMenu); | |
1025 | m_hMenu = 0; | |
1026 | } | |
1027 | m_hWnd = 0; | |
0e320a79 DW |
1028 | } |
1029 | ||
75f11ad7 DW |
1030 | // Change the client window's extended style so we don't get a client edge |
1031 | // style when a child is maximised (a double border looks silly.) | |
1032 | bool wxMDIChildFrame::ResetWindowStyle(void *vrect) | |
0e320a79 | 1033 | { |
75f11ad7 | 1034 | return FALSE; |
0e320a79 DW |
1035 | } |
1036 | ||
75f11ad7 DW |
1037 | // =========================================================================== |
1038 | // wxMDIClientWindow: the window of predefined (by Windows) class which | |
1039 | // contains the child frames | |
1040 | // =========================================================================== | |
1041 | ||
0e320a79 DW |
1042 | bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) |
1043 | { | |
0e320a79 DW |
1044 | m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); |
1045 | ||
75f11ad7 DW |
1046 | // TODO: |
1047 | /* | |
1048 | CLIENTCREATESTRUCT ccs; | |
1049 | m_windowStyle = style; | |
1050 | m_parent = parent; | |
1051 | ||
1052 | ccs.hWindowMenu = (HMENU)parent->GetWindowMenu(); | |
1053 | ccs.idFirstChild = wxFIRST_MDI_CHILD; | |
1054 | ||
1055 | DWORD msStyle = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN; | |
1056 | if ( style & wxHSCROLL ) | |
1057 | msStyle |= WS_HSCROLL; | |
1058 | if ( style & wxVSCROLL ) | |
1059 | msStyle |= WS_VSCROLL; | |
1060 | ||
1061 | #if defined(__WIN95__) | |
1062 | DWORD exStyle = WS_EX_CLIENTEDGE; | |
1063 | #else | |
1064 | DWORD exStyle = 0; | |
1065 | #endif | |
1066 | ||
1067 | wxWndHook = this; | |
1068 | m_hWnd = (WXHWND)::CreateWindowEx | |
1069 | ( | |
1070 | exStyle, | |
1071 | wxT("MDICLIENT"), | |
1072 | NULL, | |
1073 | msStyle, | |
1074 | 0, 0, 0, 0, | |
1075 | GetWinHwnd(parent), | |
1076 | NULL, | |
1077 | wxGetInstance(), | |
1078 | (LPSTR)(LPCLIENTCREATESTRUCT)&ccs); | |
1079 | if ( !m_hWnd ) | |
1080 | { | |
1081 | wxLogLastError("CreateWindowEx(MDI client)"); | |
1082 | ||
1083 | return FALSE; | |
1084 | } | |
1085 | ||
1086 | SubclassWin(m_hWnd); | |
1087 | wxWndHook = NULL; | |
1088 | */ | |
1089 | return TRUE; | |
0e320a79 DW |
1090 | } |
1091 | ||
1092 | // Explicitly call default scroll behaviour | |
1093 | void wxMDIClientWindow::OnScroll(wxScrollEvent& event) | |
1094 | { | |
75f11ad7 DW |
1095 | // Note: for client windows, the scroll position is not set in |
1096 | // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what | |
1097 | // scroll position we're at. | |
1098 | // This makes it hard to paint patterns or bitmaps in the background, | |
1099 | // and have the client area scrollable as well. | |
1100 | ||
1101 | if ( event.GetOrientation() == wxHORIZONTAL ) | |
1102 | m_scrollX = event.GetPosition(); // Always returns zero! | |
1103 | else | |
1104 | m_scrollY = event.GetPosition(); // Always returns zero! | |
1105 | ||
1106 | event.Skip(); | |
1107 | } | |
1108 | ||
1109 | // --------------------------------------------------------------------------- | |
1110 | // non member functions | |
1111 | // --------------------------------------------------------------------------- | |
1112 | ||
1113 | static void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow) | |
1114 | { | |
1115 | // TODO: | |
1116 | /* | |
1117 | ::SendMessage(GetWinHwnd(win), WM_MDISETMENU, | |
1118 | (WPARAM)hmenuFrame, (LPARAM)hmenuWindow); | |
1119 | // update menu bar of the parent window | |
1120 | wxWindow *parent = win->GetParent(); | |
1121 | wxCHECK_RET( parent, wxT("MDI client without parent frame? weird...") ); | |
1122 | ||
1123 | ::DrawMenuBar(GetWinHwnd(parent)); | |
1124 | */ | |
1125 | } | |
1126 | ||
1127 | static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu) | |
1128 | { | |
1129 | /* | |
1130 | // Try to insert Window menu in front of Help, otherwise append it. | |
1131 | HMENU hmenu = (HMENU)menu; | |
1132 | int N = GetMenuItemCount(hmenu); | |
1133 | bool success = FALSE; | |
1134 | for ( int i = 0; i < N; i++ ) | |
1135 | { | |
1136 | wxChar buf[256]; | |
1137 | int chars = GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION); | |
1138 | if ( chars == 0 ) | |
1139 | { | |
1140 | wxLogLastError(wxT("GetMenuString")); | |
1141 | ||
1142 | continue; | |
1143 | } | |
1144 | ||
1145 | if ( wxStripMenuCodes(wxString(buf)).IsSameAs(wxT("Help")) ) | |
1146 | { | |
1147 | success = TRUE; | |
1148 | ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING, | |
1149 | (UINT)subMenu, wxT("&Window")); | |
1150 | break; | |
1151 | } | |
1152 | } | |
1153 | ||
1154 | if ( !success ) | |
1155 | { | |
1156 | ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, wxT("&Window")); | |
1157 | } | |
1158 | MDISetMenu(win, hmenu, subMenu); | |
1159 | */ | |
1160 | } | |
1161 | ||
1162 | static void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam, | |
1163 | WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact) | |
1164 | { | |
1165 | *activate = TRUE; | |
1166 | *hwndAct = (WXHWND)lParam; | |
1167 | *hwndDeact = (WXHWND)wParam; | |
0e320a79 DW |
1168 | } |
1169 |