]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: frame.cpp | |
3 | // Purpose: wxFrame | |
f0a56ab0 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
29435d81 | 6 | // Created: 10/27/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
f0a56ab0 | 8 | // Copyright: (c) David Webster |
0e320a79 DW |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
21802234 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/settings.h" | |
23 | #include "wx/dcclient.h" | |
24 | #endif // WX_PRECOMP | |
25 | ||
26 | #include "wx/os2/private.h" | |
f38374d0 DW |
27 | |
28 | #if wxUSE_STATUSBAR | |
29 | #include "wx/statusbr.h" | |
ea51d98d | 30 | #include "wx/generic/statusbr.h" |
f38374d0 DW |
31 | #endif // wxUSE_STATUSBAR |
32 | ||
33 | #if wxUSE_TOOLBAR | |
34 | #include "wx/toolbar.h" | |
35 | #endif // wxUSE_TOOLBAR | |
36 | ||
0e320a79 | 37 | #include "wx/menuitem.h" |
21802234 | 38 | #include "wx/log.h" |
0e320a79 | 39 | |
f38374d0 DW |
40 | // ---------------------------------------------------------------------------- |
41 | // globals | |
42 | // ---------------------------------------------------------------------------- | |
43 | ||
21802234 DW |
44 | extern wxWindowList wxModelessWindows; |
45 | extern wxList WXDLLEXPORT wxPendingDelete; | |
46 | extern wxChar wxFrameClassName[]; | |
47 | extern wxMenu *wxCurrentPopupMenu; | |
0e320a79 | 48 | |
f38374d0 DW |
49 | // ---------------------------------------------------------------------------- |
50 | // event tables | |
51 | // ---------------------------------------------------------------------------- | |
52 | ||
f38374d0 DW |
53 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
54 | EVT_ACTIVATE(wxFrame::OnActivate) | |
55 | EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) | |
0e320a79 DW |
56 | END_EVENT_TABLE() |
57 | ||
58 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) | |
0e320a79 | 59 | |
f38374d0 DW |
60 | // ============================================================================ |
61 | // implementation | |
62 | // ============================================================================ | |
0e320a79 | 63 | |
f38374d0 DW |
64 | // ---------------------------------------------------------------------------- |
65 | // static class members | |
66 | // ---------------------------------------------------------------------------- | |
0e320a79 | 67 | |
f38374d0 | 68 | #if wxUSE_NATIVE_STATUSBAR |
a885d89a | 69 | bool wxFrame::m_bUseNativeStatusBar = TRUE; |
f38374d0 | 70 | #else |
a885d89a | 71 | bool wxFrame::m_bUseNativeStatusBar = FALSE; |
f38374d0 | 72 | #endif |
0e320a79 | 73 | |
f38374d0 DW |
74 | // ---------------------------------------------------------------------------- |
75 | // creation/destruction | |
76 | // ---------------------------------------------------------------------------- | |
77 | ||
78 | void wxFrame::Init() | |
0e320a79 | 79 | { |
80d83cbc | 80 | m_bIconized = FALSE; |
f38374d0 | 81 | |
21802234 | 82 | #if wxUSE_TOOLTIPS |
a885d89a | 83 | m_hWndToolTip = 0; |
21802234 | 84 | #endif |
ea51d98d DW |
85 | // Data to save/restore when calling ShowFullScreen |
86 | m_lFsStyle = 0L; | |
87 | m_lFsOldWindowStyle = 0L; | |
88 | m_nFsStatusBarFields = 0; | |
89 | m_nFsStatusBarHeight = 0; | |
90 | m_nFsToolBarHeight = 0; | |
91 | m_bFsIsMaximized = FALSE; | |
92 | m_bFsIsShowing = FALSE; | |
93 | } // end of wxFrame::Init | |
94 | ||
95 | bool wxFrame::Create( | |
96 | wxWindow* pParent | |
97 | , wxWindowID vId | |
98 | , const wxString& rsTitle | |
99 | , const wxPoint& rPos | |
100 | , const wxSize& rSize | |
a885d89a | 101 | , long lulStyle |
ea51d98d DW |
102 | , const wxString& rsName |
103 | ) | |
f38374d0 | 104 | { |
ea51d98d DW |
105 | int nX = rPos.x; |
106 | int nY = rPos.y; | |
107 | int nWidth = rSize.x; | |
108 | int nHeight = rSize.y; | |
ea51d98d DW |
109 | |
110 | SetName(rsName); | |
a885d89a | 111 | m_windowStyle = lulStyle; |
ea51d98d DW |
112 | m_frameMenuBar = NULL; |
113 | m_frameToolBar = NULL; | |
114 | m_frameStatusBar = NULL; | |
115 | ||
116 | SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); | |
117 | ||
118 | if (vId > -1 ) | |
119 | m_windowId = vId; | |
120 | else | |
121 | m_windowId = (int)NewControlId(); | |
122 | ||
80d83cbc | 123 | if (pParent) |
ea51d98d DW |
124 | pParent->AddChild(this); |
125 | ||
126 | m_bIconized = FALSE; | |
127 | ||
128 | // | |
129 | // We pass NULL as parent to MSWCreate because frames with parents behave | |
80d83cbc | 130 | // very strangely under Win95 shell. |
ea51d98d | 131 | // Alteration by JACS: keep normal Windows behaviour (float on top of parent) |
a885d89a | 132 | // with this ulStyle. |
ea51d98d DW |
133 | // |
134 | if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0) | |
135 | pParent = NULL; | |
136 | ||
137 | if (!pParent) | |
138 | wxTopLevelWindows.Append(this); | |
139 | ||
140 | OS2Create( m_windowId | |
141 | ,pParent | |
142 | ,wxFrameClassName | |
143 | ,this | |
144 | ,rsTitle | |
145 | ,nX | |
146 | ,nY | |
147 | ,nWidth | |
148 | ,nHeight | |
a885d89a | 149 | ,lulStyle |
ea51d98d DW |
150 | ); |
151 | ||
152 | wxModelessWindows.Append(this); | |
153 | return TRUE; | |
154 | } // end of wxFrame::Create | |
0e320a79 DW |
155 | |
156 | wxFrame::~wxFrame() | |
157 | { | |
ea51d98d DW |
158 | m_isBeingDeleted = TRUE; |
159 | wxTopLevelWindows.DeleteObject(this); | |
0e320a79 | 160 | |
ea51d98d | 161 | DeleteAllBars(); |
29435d81 | 162 | |
ea51d98d DW |
163 | if (wxTheApp && (wxTopLevelWindows.Number() == 0)) |
164 | { | |
165 | wxTheApp->SetTopWindow(NULL); | |
0e320a79 | 166 | |
ea51d98d DW |
167 | if (wxTheApp->GetExitOnFrameDelete()) |
168 | { | |
80d83cbc | 169 | ::WinPostMsg(GetHwnd(), WM_QUIT, 0, 0); |
ea51d98d DW |
170 | } |
171 | } | |
172 | wxModelessWindows.DeleteObject(this); | |
173 | ||
174 | // | |
175 | // For some reason, wxWindows can activate another task altogether | |
176 | // when a frame is destroyed after a modal dialog has been invoked. | |
177 | // Try to bring the parent to the top. | |
178 | // | |
179 | // MT:Only do this if this frame is currently the active window, else weird | |
180 | // things start to happen. | |
181 | // | |
182 | if (wxGetActiveWindow() == this) | |
0e320a79 | 183 | { |
ea51d98d DW |
184 | if (GetParent() && GetParent()->GetHWND()) |
185 | { | |
ea51d98d DW |
186 | ::WinSetWindowPos( (HWND) GetParent()->GetHWND() |
187 | ,HWND_TOP | |
80d83cbc DW |
188 | ,0 |
189 | ,0 | |
190 | ,0 | |
191 | ,0 | |
192 | ,SWP_ZORDER | |
ea51d98d DW |
193 | ); |
194 | } | |
0e320a79 | 195 | } |
ea51d98d | 196 | } // end of wxFrame::~wxFrame |
0e320a79 | 197 | |
ea51d98d | 198 | // |
0e320a79 | 199 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. |
ea51d98d | 200 | // |
80d83cbc DW |
201 | void wxFrame::DoGetClientSize( |
202 | int* pX | |
203 | , int* pY | |
204 | ) const | |
0e320a79 | 205 | { |
80d83cbc | 206 | // |
a885d89a | 207 | // OS/2 PM's coordinates go from bottom-left not |
80d83cbc DW |
208 | // top-left thus the += instead of the -= |
209 | // | |
210 | RECTL vRect; | |
211 | HWND hWndClient; | |
212 | ||
213 | // | |
214 | // PM has no GetClientRect that inherantly knows about the client window | |
215 | // We have to explicitly go fetch it! | |
216 | // | |
a885d89a | 217 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); |
80d83cbc | 218 | ::WinQueryWindowRect(hWndClient, &vRect); |
21802234 | 219 | |
f38374d0 | 220 | #if wxUSE_STATUSBAR |
80d83cbc DW |
221 | if ( GetStatusBar() ) |
222 | { | |
a885d89a | 223 | int nStatusX; |
80d83cbc DW |
224 | int nStatusY; |
225 | ||
226 | GetStatusBar()->GetClientSize( &nStatusX | |
227 | ,&nStatusY | |
228 | ); | |
229 | vRect.yBottom += nStatusY; | |
230 | } | |
f38374d0 | 231 | #endif // wxUSE_STATUSBAR |
21802234 | 232 | |
80d83cbc | 233 | wxPoint vPoint(GetClientAreaOrigin()); |
a885d89a DW |
234 | |
235 | vRect.yBottom += vPoint.y; | |
236 | vRect.xRight -= vPoint.x; | |
21802234 | 237 | |
80d83cbc DW |
238 | if (pX) |
239 | *pX = vRect.xRight; | |
240 | if (pY) | |
241 | *pY = vRect.yBottom; | |
242 | } // end of wxFrame::DoGetClientSize | |
0e320a79 | 243 | |
a885d89a | 244 | // |
0e320a79 DW |
245 | // Set the client size (i.e. leave the calculation of borders etc. |
246 | // to wxWindows) | |
80d83cbc DW |
247 | // |
248 | void wxFrame::DoSetClientSize( | |
249 | int nWidth | |
250 | , int nHeight | |
251 | ) | |
0e320a79 | 252 | { |
80d83cbc DW |
253 | HWND hWnd = GetHwnd(); |
254 | HWND hWndClient; | |
255 | RECTL vRect; | |
a7ef993c | 256 | RECTL vRect2; |
0e320a79 | 257 | |
a885d89a | 258 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); |
80d83cbc | 259 | ::WinQueryWindowRect(hWndClient, &vRect); |
21802234 | 260 | |
80d83cbc | 261 | ::WinQueryWindowRect(hWnd, &vRect2); |
21802234 | 262 | |
80d83cbc DW |
263 | // |
264 | // Find the difference between the entire window (title bar and all) | |
265 | // and the client area; add this to the new client size to move the | |
266 | // window. Remember OS/2's backwards y coord system! | |
267 | // | |
268 | int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth; | |
269 | int nActualHeight = vRect2.yTop + vRect2.yTop - vRect.yTop + nHeight; | |
29435d81 | 270 | |
f38374d0 | 271 | #if wxUSE_STATUSBAR |
80d83cbc DW |
272 | if ( GetStatusBar() ) |
273 | { | |
274 | int nStatusX; | |
275 | int nStatusY; | |
276 | ||
277 | GetStatusBar()->GetClientSize( &nStatusX | |
278 | ,&nStatusY | |
279 | ); | |
280 | nActualHeight += nStatusY; | |
281 | } | |
f38374d0 | 282 | #endif // wxUSE_STATUSBAR |
29435d81 | 283 | |
80d83cbc DW |
284 | wxPoint vPoint(GetClientAreaOrigin()); |
285 | nActualWidth += vPoint.y; | |
286 | nActualHeight += vPoint.x; | |
287 | ||
288 | POINTL vPointl; | |
289 | ||
290 | vPointl.x = vRect2.xLeft; | |
291 | vPoint.y = vRect2.yTop; | |
292 | ||
293 | ::WinSetWindowPos( hWnd | |
294 | ,HWND_TOP | |
295 | ,vPointl.x | |
296 | ,vPointl.y | |
297 | ,nActualWidth | |
298 | ,nActualHeight | |
299 | ,SWP_MOVE | SWP_SIZE | SWP_SHOW | |
300 | ); | |
301 | ||
302 | wxSizeEvent vEvent( wxSize( nWidth | |
303 | ,nHeight | |
304 | ) | |
305 | ,m_windowId | |
306 | ); | |
307 | vEvent.SetEventObject(this); | |
308 | GetEventHandler()->ProcessEvent(vEvent); | |
309 | } // end of wxFrame::DoSetClientSize | |
310 | ||
311 | void wxFrame::DoGetSize( | |
312 | int* pWidth | |
313 | , int* pHeight | |
314 | ) const | |
315 | { | |
316 | RECTL vRect; | |
21802234 | 317 | |
80d83cbc DW |
318 | ::WinQueryWindowRect(GetHwnd(), &vRect); |
319 | *pWidth = vRect.xRight - vRect.xLeft; | |
320 | *pHeight = vRect.yTop - vRect.yBottom; | |
321 | } // end of wxFrame::DoGetSize | |
21802234 | 322 | |
80d83cbc DW |
323 | void wxFrame::DoGetPosition( |
324 | int* pX | |
325 | , int* pY | |
326 | ) const | |
327 | { | |
328 | RECTL vRect; | |
a885d89a | 329 | POINTL vPoint; |
29435d81 | 330 | |
80d83cbc DW |
331 | ::WinQueryWindowRect(GetHwnd(), &vRect); |
332 | vPoint.x = vRect.xLeft; | |
0e320a79 | 333 | |
80d83cbc DW |
334 | // |
335 | // OS/2 is backwards [WIN32 it is vRect.yTop] | |
336 | // | |
337 | vPoint.y = vRect.yBottom; | |
0e320a79 | 338 | |
80d83cbc DW |
339 | *pX = vPoint.x; |
340 | *pY = vPoint.y; | |
341 | } // end of wxFrame::DoGetPosition | |
0e320a79 | 342 | |
f38374d0 DW |
343 | // ---------------------------------------------------------------------------- |
344 | // variations around ::ShowWindow() | |
345 | // ---------------------------------------------------------------------------- | |
346 | ||
80d83cbc DW |
347 | void wxFrame::DoShowWindow( |
348 | int nShowCmd | |
349 | ) | |
0e320a79 | 350 | { |
80d83cbc DW |
351 | ::WinShowWindow(GetHwnd(), nShowCmd); |
352 | m_bIconized = nShowCmd == SWP_MINIMIZE; | |
353 | } // end of wxFrame::DoShowWindow | |
21802234 | 354 | |
80d83cbc DW |
355 | bool wxFrame::Show( |
356 | bool bShow | |
357 | ) | |
0e320a79 | 358 | { |
a885d89a | 359 | DoShowWindow(bShow ? SWP_SHOW : SWP_HIDE); |
21802234 | 360 | |
80d83cbc | 361 | if (bShow) |
f38374d0 | 362 | { |
80d83cbc DW |
363 | wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId); |
364 | ||
365 | ::WinSetWindowPos( (HWND) GetHWND() | |
366 | ,HWND_TOP | |
367 | ,0 | |
368 | ,0 | |
369 | ,0 | |
370 | ,0 | |
371 | ,SWP_ZORDER | |
372 | ); | |
373 | vEvent.SetEventObject(this); | |
374 | GetEventHandler()->ProcessEvent(vEvent); | |
f38374d0 DW |
375 | } |
376 | else | |
377 | { | |
80d83cbc | 378 | // |
f38374d0 | 379 | // Try to highlight the correct window (the parent) |
80d83cbc DW |
380 | // |
381 | if (GetParent()) | |
f38374d0 | 382 | { |
80d83cbc DW |
383 | HWND hWndParent = GetHwndOf(GetParent()); |
384 | ||
f38374d0 | 385 | if (hWndParent) |
80d83cbc DW |
386 | ::WinSetWindowPos( hWndParent |
387 | ,HWND_TOP | |
388 | ,0 | |
389 | ,0 | |
390 | ,0 | |
391 | ,0 | |
392 | ,SWP_ZORDER | |
393 | ); | |
f38374d0 DW |
394 | } |
395 | } | |
f38374d0 | 396 | return TRUE; |
80d83cbc | 397 | } // end of wxFrame::Show |
f38374d0 | 398 | |
80d83cbc DW |
399 | void wxFrame::Iconize( |
400 | bool bIconize | |
401 | ) | |
f38374d0 | 402 | { |
80d83cbc DW |
403 | DoShowWindow(bIconize ? SWP_MINIMIZE : SWP_RESTORE); |
404 | } // end of wxFrame::Iconize | |
0e320a79 | 405 | |
80d83cbc DW |
406 | void wxFrame::Maximize( |
407 | bool bMaximize) | |
0e320a79 | 408 | { |
80d83cbc DW |
409 | DoShowWindow(bMaximize ? SWP_MAXIMIZE : SWP_RESTORE); |
410 | } // end of wxFrame::Maximize | |
f38374d0 DW |
411 | |
412 | void wxFrame::Restore() | |
413 | { | |
80d83cbc DW |
414 | DoShowWindow(SWP_RESTORE); |
415 | } // end of wxFrame::Restore | |
0e320a79 DW |
416 | |
417 | bool wxFrame::IsIconized() const | |
418 | { | |
80d83cbc DW |
419 | SWP vSwp; |
420 | bool bIconic; | |
421 | ||
a885d89a DW |
422 | ::WinQueryWindowPos(GetHwnd(), &vSwp); |
423 | ||
80d83cbc DW |
424 | if (vSwp.fl & SWP_MINIMIZE) |
425 | ((wxFrame*)this)->m_bIconized = TRUE; | |
426 | else | |
427 | ((wxFrame*)this)->m_bIconized = FALSE; | |
428 | return m_bIconized; | |
429 | } // end of wxFrame::IsIconized | |
0e320a79 | 430 | |
21802234 DW |
431 | // Is it maximized? |
432 | bool wxFrame::IsMaximized() const | |
0e320a79 | 433 | { |
80d83cbc DW |
434 | SWP vSwp; |
435 | bool bIconic; | |
436 | ||
a885d89a | 437 | ::WinQueryWindowPos(GetHwnd(), &vSwp); |
80d83cbc DW |
438 | return (vSwp.fl & SWP_MAXIMIZE); |
439 | } // end of wxFrame::IsMaximized | |
0e320a79 | 440 | |
0fe536e3 DW |
441 | void wxFrame::SetIcon( |
442 | const wxIcon& rIcon | |
443 | ) | |
0e320a79 | 444 | { |
0fe536e3 | 445 | wxFrameBase::SetIcon(rIcon); |
f38374d0 | 446 | |
0fe536e3 | 447 | if (m_icon.Ok()) |
f38374d0 | 448 | { |
a885d89a DW |
449 | WinSendMsg( GetHwnd() |
450 | ,WM_SETICON | |
451 | ,(MPARAM)((HICON)m_icon.GetHICON()) | |
452 | ,NULL | |
453 | ); | |
f38374d0 | 454 | } |
0fe536e3 | 455 | } // end of wxFrame::SetIcon |
0e320a79 | 456 | |
21802234 | 457 | #if wxUSE_STATUSBAR |
0fe536e3 DW |
458 | wxStatusBar* wxFrame::OnCreateStatusBar( |
459 | int nNumber | |
a885d89a | 460 | , long lulStyle |
0fe536e3 DW |
461 | , wxWindowID vId |
462 | , const wxString& rName | |
463 | ) | |
0e320a79 | 464 | { |
0fe536e3 | 465 | wxStatusBar* pStatusBar = NULL; |
0e320a79 | 466 | |
0fe536e3 | 467 | pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber |
a885d89a | 468 | ,lulStyle |
0fe536e3 DW |
469 | ,vId |
470 | ,rName | |
471 | ); | |
472 | return pStatusBar; | |
473 | } // end of wxFrame::OnCreateStatusBar | |
0e320a79 DW |
474 | |
475 | void wxFrame::PositionStatusBar() | |
476 | { | |
0fe536e3 DW |
477 | // |
478 | // Native status bar positions itself | |
479 | // | |
480 | if (m_frameStatusBar) | |
f38374d0 | 481 | { |
a885d89a | 482 | int nWidth; |
0fe536e3 | 483 | int nHeight; |
a885d89a | 484 | int nStatbarWidth; |
0fe536e3 DW |
485 | int nStatbarHeight; |
486 | HWND hWndClient; | |
487 | RECTL vRect; | |
488 | ||
a885d89a | 489 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); |
0fe536e3 DW |
490 | ::WinQueryWindowRect(hWndClient, &vRect); |
491 | nWidth = vRect.xRight - vRect.xLeft; | |
a885d89a DW |
492 | nHeight = vRect.yTop - vRect.yBottom; |
493 | ||
0fe536e3 DW |
494 | m_frameStatusBar->GetSize( &nStatbarWidth |
495 | ,&nStatbarHeight | |
496 | ); | |
f38374d0 | 497 | |
0fe536e3 | 498 | // |
f38374d0 DW |
499 | // Since we wish the status bar to be directly under the client area, |
500 | // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. | |
0fe536e3 DW |
501 | // |
502 | m_frameStatusBar->SetSize( 0 | |
503 | ,nHeight | |
504 | ,nWidth | |
505 | ,nStatbarHeight | |
506 | ); | |
f38374d0 | 507 | } |
0fe536e3 | 508 | } // end of wxFrame::PositionStatusBar |
21802234 | 509 | #endif // wxUSE_STATUSBAR |
0e320a79 | 510 | |
21802234 | 511 | void wxFrame::DetachMenuBar() |
0e320a79 | 512 | { |
21802234 | 513 | if (m_frameMenuBar) |
0e320a79 | 514 | { |
29435d81 | 515 | m_frameMenuBar->Detach(); |
0e320a79 | 516 | m_frameMenuBar = NULL; |
21802234 | 517 | } |
0fe536e3 | 518 | } // end of wxFrame::DetachMenuBar |
21802234 | 519 | |
0fe536e3 | 520 | void wxFrame::SetMenuBar( |
a885d89a | 521 | wxMenuBar* pMenuBar |
0fe536e3 | 522 | ) |
21802234 | 523 | { |
0fe536e3 | 524 | if (!pMenuBar) |
21802234 DW |
525 | { |
526 | DetachMenuBar(); | |
0e320a79 DW |
527 | return; |
528 | } | |
c3d43472 | 529 | |
29a99be3 | 530 | m_frameMenuBar = NULL; |
0e320a79 | 531 | |
29a99be3 DW |
532 | // Can set a menubar several times. |
533 | // TODO: how to prevent a memory leak if you have a currently-unattached | |
534 | // menubar? wxWindows assumes that the frame will delete the menu (otherwise | |
535 | // there are problems for MDI). | |
536 | if (pMenuBar->GetHMenu()) | |
0fe536e3 | 537 | { |
29a99be3 | 538 | m_hMenu = pMenuBar->GetHMenu(); |
0fe536e3 | 539 | } |
29a99be3 DW |
540 | else |
541 | { | |
542 | pMenuBar->Detach(); | |
21802234 | 543 | |
29a99be3 DW |
544 | m_hMenu = pMenuBar->Create(); |
545 | ||
546 | if (!m_hMenu) | |
547 | return; | |
548 | } | |
21802234 DW |
549 | |
550 | InternalSetMenuBar(); | |
551 | ||
a885d89a DW |
552 | m_frameMenuBar = pMenuBar; |
553 | pMenuBar->Attach(this); | |
0fe536e3 | 554 | } // end of wxFrame::SetMenuBar |
0e320a79 | 555 | |
21802234 | 556 | void wxFrame::InternalSetMenuBar() |
0e320a79 | 557 | { |
a885d89a | 558 | |
0fe536e3 DW |
559 | ::WinPostMsg( GetHwnd() |
560 | ,WM_UPDATEFRAME | |
a885d89a | 561 | ,(MPARAM)FCF_MENU |
0fe536e3 DW |
562 | ,NULL |
563 | ); | |
564 | } // end of wxFrame::InternalSetMenuBar | |
0e320a79 | 565 | |
a885d89a DW |
566 | // |
567 | // Responds to colour changes, and passes event on to children | |
568 | // | |
569 | void wxFrame::OnSysColourChanged( | |
570 | wxSysColourChangedEvent& rEvent | |
571 | ) | |
0e320a79 DW |
572 | { |
573 | SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); | |
574 | Refresh(); | |
575 | ||
a885d89a | 576 | if (m_frameStatusBar) |
0e320a79 | 577 | { |
a885d89a DW |
578 | wxSysColourChangedEvent vEvent2; |
579 | ||
580 | vEvent2.SetEventObject(m_frameStatusBar); | |
581 | m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2); | |
0e320a79 DW |
582 | } |
583 | ||
a885d89a | 584 | // |
0e320a79 | 585 | // Propagate the event to the non-top-level children |
a885d89a DW |
586 | // |
587 | wxWindow::OnSysColourChanged(rEvent); | |
588 | } // end of wxFrame::OnSysColourChanged | |
21802234 | 589 | |
542875a8 DW |
590 | // Pass TRUE to show full screen, FALSE to restore. |
591 | bool wxFrame::ShowFullScreen( | |
592 | bool bShow | |
593 | , long lStyle | |
594 | ) | |
595 | { | |
596 | /* | |
597 | // TODO | |
598 | if (show) | |
599 | { | |
600 | if (IsFullScreen()) | |
601 | return FALSE; | |
602 | ||
603 | m_fsIsShowing = TRUE; | |
604 | m_fsStyle = style; | |
605 | ||
606 | wxToolBar *theToolBar = GetToolBar(); | |
607 | wxStatusBar *theStatusBar = GetStatusBar(); | |
608 | ||
609 | int dummyWidth; | |
610 | ||
611 | if (theToolBar) | |
612 | theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight); | |
613 | if (theStatusBar) | |
614 | theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight); | |
615 | ||
616 | // zap the toolbar, menubar, and statusbar | |
617 | ||
618 | if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar) | |
619 | { | |
620 | theToolBar->SetSize(-1,0); | |
621 | theToolBar->Show(FALSE); | |
622 | } | |
623 | ||
624 | if (style & wxFULLSCREEN_NOMENUBAR) | |
625 | SetMenu((HWND)GetHWND(), (HMENU) NULL); | |
626 | ||
627 | // Save the number of fields in the statusbar | |
628 | if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar) | |
629 | { | |
630 | m_fsStatusBarFields = theStatusBar->GetFieldsCount(); | |
631 | SetStatusBar((wxStatusBar*) NULL); | |
632 | delete theStatusBar; | |
633 | } | |
634 | else | |
635 | m_fsStatusBarFields = 0; | |
636 | ||
637 | // zap the frame borders | |
638 | ||
639 | // save the 'normal' window style | |
640 | m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE); | |
641 | ||
642 | // save the old position, width & height, maximize state | |
643 | m_fsOldSize = GetRect(); | |
644 | m_fsIsMaximized = IsMaximized(); | |
645 | ||
646 | // decide which window style flags to turn off | |
647 | LONG newStyle = m_fsOldWindowStyle; | |
648 | LONG offFlags = 0; | |
649 | ||
650 | if (style & wxFULLSCREEN_NOBORDER) | |
651 | offFlags |= WS_BORDER; | |
652 | if (style & wxFULLSCREEN_NOCAPTION) | |
653 | offFlags |= (WS_CAPTION | WS_SYSMENU); | |
654 | ||
655 | newStyle &= (~offFlags); | |
656 | ||
657 | // change our window style to be compatible with full-screen mode | |
658 | SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle); | |
659 | ||
660 | // resize to the size of the desktop | |
661 | int width, height; | |
662 | ||
663 | RECT rect; | |
664 | ::GetWindowRect(GetDesktopWindow(), &rect); | |
665 | width = rect.right - rect.left; | |
666 | height = rect.bottom - rect.top; | |
667 | ||
668 | SetSize(width, height); | |
669 | ||
670 | // now flush the window style cache and actually go full-screen | |
671 | SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); | |
672 | ||
673 | wxSizeEvent event(wxSize(width, height), GetId()); | |
674 | GetEventHandler()->ProcessEvent(event); | |
675 | ||
676 | return TRUE; | |
677 | } | |
678 | else | |
679 | { | |
680 | if (!IsFullScreen()) | |
681 | return FALSE; | |
682 | ||
683 | m_fsIsShowing = FALSE; | |
684 | ||
685 | wxToolBar *theToolBar = GetToolBar(); | |
686 | ||
687 | // restore the toolbar, menubar, and statusbar | |
688 | if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR)) | |
689 | { | |
690 | theToolBar->SetSize(-1, m_fsToolBarHeight); | |
691 | theToolBar->Show(TRUE); | |
692 | } | |
693 | ||
694 | if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0)) | |
695 | { | |
696 | CreateStatusBar(m_fsStatusBarFields); | |
697 | PositionStatusBar(); | |
698 | } | |
699 | ||
700 | if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0)) | |
701 | SetMenu((HWND)GetHWND(), (HMENU)m_hMenu); | |
702 | ||
703 | Maximize(m_fsIsMaximized); | |
704 | SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle); | |
705 | SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y, | |
706 | m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED); | |
707 | ||
708 | return TRUE; | |
709 | } | |
710 | */ | |
711 | return TRUE; | |
712 | } // end of wxFrame::ShowFullScreen | |
713 | ||
a885d89a DW |
714 | // |
715 | // Frame window | |
716 | // | |
717 | bool wxFrame::OS2Create( | |
718 | int nId | |
719 | , wxWindow* pParent | |
720 | , const wxChar* zWclass | |
721 | , wxWindow* pWxWin | |
722 | , const wxChar* zTitle | |
723 | , int nX | |
724 | , int nY | |
725 | , int nWidth | |
726 | , int nHeight | |
727 | , long ulStyle | |
728 | ) | |
21802234 | 729 | { |
914589c2 DW |
730 | ULONG ulPmFlags = 0L; |
731 | ULONG ulExtraFlags = 0L; | |
732 | ULONG ulTempFlags = FCF_STANDARD; | |
a885d89a DW |
733 | |
734 | m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); | |
735 | ||
914589c2 DW |
736 | if (ulStyle == wxDEFAULT_FRAME_STYLE) |
737 | ulPmFlags = FCF_STANDARD; | |
a885d89a | 738 | else |
a885d89a | 739 | { |
914589c2 DW |
740 | if ((ulStyle & wxCAPTION) == wxCAPTION) |
741 | ulPmFlags = FCF_TASKLIST; | |
742 | else | |
743 | ulPmFlags = FCF_NOMOVEWITHOWNER; | |
744 | ||
745 | if (ulStyle & wxMINIMIZE_BOX) | |
746 | ulPmFlags |= FCF_MINBUTTON; | |
747 | if (ulStyle & wxMAXIMIZE_BOX) | |
748 | ulPmFlags |= FCF_MAXBUTTON; | |
749 | if (ulStyle & wxTHICK_FRAME) | |
750 | ulPmFlags |= FCF_DLGBORDER; | |
751 | if (ulStyle & wxSYSTEM_MENU) | |
752 | ulPmFlags |= FCF_SYSMENU; | |
753 | if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE)) | |
754 | ulPmFlags |= WS_MINIMIZED; | |
755 | if (ulStyle & wxMAXIMIZE) | |
756 | ulPmFlags |= WS_MAXIMIZED; | |
757 | if (ulStyle & wxCAPTION) | |
758 | ulPmFlags |= FCF_TASKLIST; | |
759 | if (ulStyle & wxCLIP_CHILDREN) | |
760 | { | |
761 | // Invalid for frame windows under PM | |
762 | } | |
a885d89a | 763 | |
914589c2 DW |
764 | // |
765 | // Keep this in wxFrame because it saves recoding this function | |
766 | // in wxTinyFrame | |
767 | // | |
21802234 | 768 | #if wxUSE_ITSY_BITSY |
914589c2 DW |
769 | if (ulStyle & wxTINY_CAPTION_VERT) |
770 | ulExtraFlags |= kVertCaption; | |
771 | if (ulStyle & wxTINY_CAPTION_HORIZ) | |
772 | ulExtraFlags |= kHorzCaption; | |
21802234 | 773 | #else |
914589c2 DW |
774 | if (ulStyle & wxTINY_CAPTION_VERT) |
775 | ulPmFlags |= FCF_TASKLIST; | |
776 | if (ulStyle & wxTINY_CAPTION_HORIZ) | |
777 | ulPmFlags |= FCF_TASKLIST; | |
21802234 | 778 | #endif |
914589c2 DW |
779 | if ((ulStyle & wxTHICK_FRAME) == 0) |
780 | ulPmFlags |= FCF_BORDER; | |
781 | if (ulStyle & wxFRAME_TOOL_WINDOW) | |
782 | ulExtraFlags = kFrameToolWindow; | |
21802234 | 783 | |
914589c2 DW |
784 | if (ulStyle & wxSTAY_ON_TOP) |
785 | ulPmFlags |= FCF_SYSMODAL; | |
786 | } | |
a885d89a DW |
787 | // |
788 | // Clear the visible flag, we always call show | |
789 | // | |
790 | ulPmFlags &= (unsigned long)~WS_VISIBLE; | |
791 | m_bIconized = FALSE; | |
792 | if ( !wxWindow::OS2Create( nId | |
793 | ,pParent | |
794 | ,zWclass | |
795 | ,pWxWin | |
796 | ,zTitle | |
797 | ,nX | |
798 | ,nY | |
799 | ,nWidth | |
800 | ,nHeight | |
801 | ,ulPmFlags | |
802 | ,NULL | |
803 | ,ulExtraFlags)) | |
804 | { | |
805 | return FALSE; | |
806 | } | |
807 | return TRUE; | |
808 | } // end of wxFrame::OS2Create | |
0e320a79 | 809 | |
a885d89a | 810 | // |
0e320a79 DW |
811 | // Default activation behaviour - set the focus for the first child |
812 | // subwindow found. | |
a885d89a DW |
813 | // |
814 | void wxFrame::OnActivate( | |
815 | wxActivateEvent& rEvent | |
816 | ) | |
0e320a79 | 817 | { |
a885d89a DW |
818 | for (wxWindowList::Node* pNode = GetChildren().GetFirst(); |
819 | pNode; | |
820 | pNode = pNode->GetNext()) | |
0e320a79 | 821 | { |
21802234 DW |
822 | // FIXME all this is totally bogus - we need to do the same as wxPanel, |
823 | // but how to do it without duplicating the code? | |
824 | ||
825 | // restore focus | |
a885d89a | 826 | wxWindow* pChild = pNode->GetData(); |
21802234 | 827 | |
a885d89a | 828 | if (!pChild->IsTopLevel() |
21802234 | 829 | #if wxUSE_TOOLBAR |
a885d89a | 830 | && !wxDynamicCast(pChild, wxToolBar) |
21802234 DW |
831 | #endif // wxUSE_TOOLBAR |
832 | #if wxUSE_STATUSBAR | |
a885d89a | 833 | && !wxDynamicCast(pChild, wxStatusBar) |
21802234 DW |
834 | #endif // wxUSE_STATUSBAR |
835 | ) | |
836 | { | |
a885d89a | 837 | pChild->SetFocus(); |
21802234 DW |
838 | return; |
839 | } | |
0e320a79 | 840 | } |
a885d89a | 841 | } // end of wxFrame::OnActivate |
0e320a79 | 842 | |
f38374d0 DW |
843 | // ---------------------------------------------------------------------------- |
844 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
845 | // from the client area, so the client area is what's really available for the | |
846 | // frame contents | |
847 | // ---------------------------------------------------------------------------- | |
0e320a79 DW |
848 | |
849 | // Checks if there is a toolbar, and returns the first free client position | |
850 | wxPoint wxFrame::GetClientAreaOrigin() const | |
851 | { | |
a885d89a DW |
852 | wxPoint vPoint(0, 0); |
853 | ||
0e320a79 DW |
854 | if (GetToolBar()) |
855 | { | |
a885d89a DW |
856 | int nWidth; |
857 | int nHeight; | |
858 | ||
859 | GetToolBar()->GetSize( &nWidth | |
860 | ,&nHeight | |
861 | ); | |
0e320a79 DW |
862 | |
863 | if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) | |
864 | { | |
a885d89a | 865 | vPoint.x += nWidth; |
0e320a79 DW |
866 | } |
867 | else | |
868 | { | |
a885d89a DW |
869 | // PM is backwards from windows |
870 | vPoint.y += nHeight; | |
0e320a79 DW |
871 | } |
872 | } | |
a885d89a DW |
873 | return vPoint; |
874 | } // end of wxFrame::GetClientAreaOrigin | |
0e320a79 | 875 | |
f38374d0 DW |
876 | // ---------------------------------------------------------------------------- |
877 | // tool/status bar stuff | |
878 | // ---------------------------------------------------------------------------- | |
879 | ||
21802234 | 880 | #if wxUSE_TOOLBAR |
f38374d0 | 881 | |
a885d89a DW |
882 | wxToolBar* wxFrame::CreateToolBar( |
883 | long lStyle | |
884 | , wxWindowID vId | |
885 | , const wxString& rName | |
886 | ) | |
0e320a79 | 887 | { |
a885d89a DW |
888 | if (wxFrameBase::CreateToolBar( lStyle |
889 | ,vId | |
890 | ,rName | |
891 | )) | |
0e320a79 | 892 | { |
0e320a79 | 893 | PositionToolBar(); |
0e320a79 | 894 | } |
f38374d0 | 895 | return m_frameToolBar; |
a885d89a | 896 | } // end of wxFrame::CreateToolBar |
0e320a79 DW |
897 | |
898 | void wxFrame::PositionToolBar() | |
899 | { | |
a885d89a DW |
900 | HWND hWndClient; |
901 | RECTL vRect; | |
902 | ||
903 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); | |
904 | ::WinQueryWindowRect(hWndClient, &vRect); | |
0e320a79 | 905 | |
f38374d0 | 906 | #if wxUSE_STATUSBAR |
a885d89a | 907 | if (GetStatusBar()) |
0e320a79 | 908 | { |
a885d89a DW |
909 | int nStatusX; |
910 | int nStatusY; | |
911 | ||
912 | GetStatusBar()->GetClientSize( &nStatusX | |
913 | ,&nStatusY | |
914 | ); | |
915 | // PM is backwards from windows | |
916 | vRect.yBottom += nStatusY; | |
0e320a79 | 917 | } |
f38374d0 | 918 | #endif // wxUSE_STATUSBAR |
0e320a79 | 919 | |
f38374d0 | 920 | if ( GetToolBar() ) |
0e320a79 | 921 | { |
a885d89a DW |
922 | int nToolbarWidth; |
923 | int nToolbarHeight; | |
924 | ||
925 | GetToolBar()->GetSize( &nToolbarWidth | |
926 | ,&nToolbarHeight | |
927 | ); | |
0e320a79 | 928 | |
a885d89a | 929 | if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) |
0e320a79 | 930 | { |
a885d89a | 931 | nToolbarHeight = vRect.yBottom; |
0e320a79 DW |
932 | } |
933 | else | |
934 | { | |
a885d89a | 935 | nToolbarWidth = vRect.xRight; |
21802234 | 936 | } |
f38374d0 | 937 | |
a885d89a DW |
938 | // |
939 | // Use the 'real' PM position here | |
940 | // | |
941 | GetToolBar()->SetSize( 0 | |
942 | ,0 | |
943 | ,nToolbarWidth | |
944 | ,nToolbarHeight | |
945 | ,wxSIZE_NO_ADJUSTMENTS | |
946 | ); | |
21802234 | 947 | } |
a885d89a | 948 | } // end of wxFrame::PositionToolBar |
21802234 DW |
949 | #endif // wxUSE_TOOLBAR |
950 | ||
f38374d0 DW |
951 | // ---------------------------------------------------------------------------- |
952 | // frame state (iconized/maximized/...) | |
953 | // ---------------------------------------------------------------------------- | |
954 | ||
a885d89a | 955 | // |
21802234 DW |
956 | // propagate our state change to all child frames: this allows us to emulate X |
957 | // Windows behaviour where child frames float independently of the parent one | |
958 | // on the desktop, but are iconized/restored with it | |
a885d89a DW |
959 | // |
960 | void wxFrame::IconizeChildFrames( | |
961 | bool bIconize | |
962 | ) | |
21802234 | 963 | { |
a885d89a DW |
964 | for (wxWindowList::Node* pNode = GetChildren().GetFirst(); |
965 | pNode; | |
966 | pNode = pNode->GetNext() ) | |
21802234 | 967 | { |
a885d89a | 968 | wxWindow* pWin = pNode->GetData(); |
21802234 | 969 | |
a885d89a | 970 | if (pWin->IsKindOf(CLASSINFO(wxFrame)) ) |
21802234 | 971 | { |
a885d89a | 972 | ((wxFrame *)pWin)->Iconize(bIconize); |
0e320a79 DW |
973 | } |
974 | } | |
a885d89a | 975 | } // end of wxFrame::IconizeChildFrames |
0e320a79 | 976 | |
21802234 DW |
977 | // =========================================================================== |
978 | // message processing | |
979 | // =========================================================================== | |
980 | ||
981 | // --------------------------------------------------------------------------- | |
982 | // preprocessing | |
983 | // --------------------------------------------------------------------------- | |
a885d89a DW |
984 | bool wxFrame::OS2TranslateMessage( |
985 | WXMSG* pMsg | |
986 | ) | |
21802234 | 987 | { |
a885d89a | 988 | if (wxWindow::OS2TranslateMessage(pMsg)) |
29435d81 | 989 | return TRUE; |
a885d89a | 990 | // |
21802234 | 991 | // try the menu bar accels |
a885d89a DW |
992 | // |
993 | wxMenuBar* pMenuBar = GetMenuBar(); | |
994 | ||
995 | if (!pMenuBar ) | |
21802234 DW |
996 | return FALSE; |
997 | ||
a885d89a DW |
998 | const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable(); |
999 | return rAcceleratorTable.Translate(this, pMsg); | |
1000 | } // end of wxFrame::OS2TranslateMessage | |
21802234 DW |
1001 | |
1002 | // --------------------------------------------------------------------------- | |
1003 | // our private (non virtual) message handlers | |
1004 | // --------------------------------------------------------------------------- | |
21802234 DW |
1005 | bool wxFrame::HandlePaint() |
1006 | { | |
a885d89a DW |
1007 | RECTL vRect; |
1008 | ||
1009 | if (::WinQueryUpdateRect(GetHwnd(), &vRect)) | |
29435d81 | 1010 | { |
a885d89a | 1011 | if (m_bIconized) |
29435d81 | 1012 | { |
a885d89a DW |
1013 | // |
1014 | // Icons in PM are the same as "pointers" | |
1015 | // | |
1016 | HPOINTER hIcon; | |
29435d81 | 1017 | |
a885d89a DW |
1018 | if (m_icon.Ok()) |
1019 | hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L); | |
1020 | else | |
1021 | hIcon = (HPOINTER)m_hDefaultIcon; | |
1022 | ||
1023 | // | |
21802234 DW |
1024 | // Hold a pointer to the dc so long as the OnPaint() message |
1025 | // is being processed | |
a885d89a DW |
1026 | // |
1027 | RECTL vRect2; | |
1028 | HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2); | |
29435d81 | 1029 | |
a885d89a | 1030 | // |
29435d81 | 1031 | // Erase background before painting or we get white background |
a885d89a DW |
1032 | // |
1033 | OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2); | |
29435d81 | 1034 | |
a885d89a | 1035 | if (hIcon) |
29435d81 | 1036 | { |
a885d89a DW |
1037 | HWND hWndClient; |
1038 | RECTL vRect3; | |
21802234 | 1039 | |
a885d89a DW |
1040 | hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); |
1041 | ::WinQueryWindowRect(hWndClient, &vRect3); | |
29435d81 | 1042 | |
a885d89a DW |
1043 | static const int nIconWidth = 32; |
1044 | static const int nIconHeight = 32; | |
1045 | int nIconX = (int)((vRect3.xRight - nIconWidth)/2); | |
1046 | int nIconY = (int)((vRect3.yBottom + nIconHeight)/2); | |
29435d81 | 1047 | |
a885d89a | 1048 | ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL); |
29435d81 | 1049 | } |
a885d89a | 1050 | ::WinEndPaint(hPs); |
29435d81 DW |
1051 | return TRUE; |
1052 | } | |
1053 | else | |
1054 | { | |
1055 | return wxWindow::HandlePaint(); | |
1056 | } | |
1057 | } | |
1058 | else | |
1059 | { | |
1060 | // nothing to paint - processed | |
1061 | return TRUE; | |
1062 | } | |
29435d81 | 1063 | return FALSE; |
a885d89a | 1064 | } // end of wxFrame::HandlePaint |
21802234 | 1065 | |
a885d89a DW |
1066 | bool wxFrame::HandleSize( |
1067 | int nX | |
1068 | , int nY | |
1069 | , WXUINT nId | |
1070 | ) | |
21802234 | 1071 | { |
a885d89a | 1072 | bool bProcessed = FALSE; |
21802234 | 1073 | |
a885d89a | 1074 | switch (nId) |
21802234 | 1075 | { |
a885d89a DW |
1076 | case kSizeNormal: |
1077 | // | |
1078 | // Only do it it if we were iconized before, otherwise resizing the | |
21802234 DW |
1079 | // parent frame has a curious side effect of bringing it under it's |
1080 | // children | |
a885d89a | 1081 | if (!m_bIconized ) |
21802234 DW |
1082 | break; |
1083 | ||
a885d89a | 1084 | // |
21802234 | 1085 | // restore all child frames too |
a885d89a | 1086 | // |
21802234 DW |
1087 | IconizeChildFrames(FALSE); |
1088 | ||
a885d89a | 1089 | // |
21802234 | 1090 | // fall through |
a885d89a | 1091 | // |
21802234 | 1092 | |
a885d89a DW |
1093 | case kSizeMax: |
1094 | m_bIconized = FALSE; | |
21802234 DW |
1095 | break; |
1096 | ||
a885d89a DW |
1097 | case kSizeMin: |
1098 | // | |
1099 | // Iconize all child frames too | |
1100 | // | |
21802234 | 1101 | IconizeChildFrames(TRUE); |
a885d89a | 1102 | m_bIconized = TRUE; |
21802234 DW |
1103 | break; |
1104 | } | |
f38374d0 | 1105 | |
a885d89a | 1106 | if (!m_bIconized) |
21802234 | 1107 | { |
a885d89a | 1108 | // |
29435d81 | 1109 | // forward WM_SIZE to status bar control |
a885d89a | 1110 | // |
f38374d0 DW |
1111 | #if wxUSE_NATIVE_STATUSBAR |
1112 | if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))) | |
1113 | { | |
a885d89a DW |
1114 | wxSizeEvent vEvent( wxSize( nX |
1115 | ,nY | |
1116 | ) | |
1117 | ,m_frameStatusBar->GetId() | |
1118 | ); | |
f38374d0 | 1119 | |
a885d89a DW |
1120 | vEvent.SetEventObject(m_frameStatusBar); |
1121 | m_frameStatusBar->OnSize(vEvent); | |
f38374d0 DW |
1122 | } |
1123 | #endif // wxUSE_NATIVE_STATUSBAR | |
1124 | ||
21802234 DW |
1125 | PositionStatusBar(); |
1126 | PositionToolBar(); | |
a885d89a DW |
1127 | wxSizeEvent vEvent( wxSize( nX |
1128 | ,nY | |
1129 | ) | |
1130 | ,m_windowId | |
1131 | ); | |
21802234 | 1132 | |
a885d89a DW |
1133 | vEvent.SetEventObject(this); |
1134 | bProcessed = GetEventHandler()->ProcessEvent(vEvent); | |
21802234 | 1135 | } |
a885d89a DW |
1136 | return bProcessed; |
1137 | } // end of wxFrame::HandleSize | |
21802234 | 1138 | |
a885d89a DW |
1139 | bool wxFrame::HandleCommand( |
1140 | WXWORD nId | |
1141 | , WXWORD nCmd | |
1142 | , WXHWND hControl | |
1143 | ) | |
21802234 | 1144 | { |
a885d89a | 1145 | if (hControl) |
21802234 | 1146 | { |
a885d89a | 1147 | // |
21802234 | 1148 | // In case it's e.g. a toolbar. |
a885d89a DW |
1149 | // |
1150 | wxWindow* pWin = wxFindWinFromHandle(hControl); | |
1151 | ||
1152 | if (pWin) | |
1153 | return pWin->OS2Command( nCmd | |
1154 | ,nId | |
1155 | ); | |
21802234 DW |
1156 | } |
1157 | ||
a885d89a DW |
1158 | // |
1159 | // Handle here commands from menus and accelerators | |
1160 | // | |
1161 | if (nCmd == 0 || nCmd == 1) | |
21802234 | 1162 | { |
a885d89a | 1163 | if (wxCurrentPopupMenu) |
21802234 | 1164 | { |
a885d89a DW |
1165 | wxMenu* pPopupMenu = wxCurrentPopupMenu; |
1166 | ||
21802234 DW |
1167 | wxCurrentPopupMenu = NULL; |
1168 | ||
a885d89a DW |
1169 | return pPopupMenu->OS2Command( nCmd |
1170 | ,nId | |
1171 | ); | |
21802234 DW |
1172 | } |
1173 | ||
a885d89a | 1174 | if (ProcessCommand(nId)) |
21802234 DW |
1175 | { |
1176 | return TRUE; | |
1177 | } | |
1178 | } | |
21802234 | 1179 | return FALSE; |
a885d89a | 1180 | } // end of wxFrame::HandleCommand |
21802234 | 1181 | |
a885d89a DW |
1182 | bool wxFrame::HandleMenuSelect( |
1183 | WXWORD nItem | |
1184 | , WXWORD nFlags | |
1185 | , WXHMENU hMenu | |
1186 | ) | |
21802234 | 1187 | { |
a885d89a DW |
1188 | int nMenuItem; |
1189 | ||
1190 | if (nFlags == 0xFFFF && hMenu == 0) | |
21802234 | 1191 | { |
a885d89a DW |
1192 | // |
1193 | // Menu was removed from screen | |
1194 | // | |
1195 | nMenuItem = -1; | |
21802234 | 1196 | } |
a885d89a | 1197 | else if (!(nFlags & MIS_SUBMENU) && !(nFlags & MIS_SEPARATOR)) |
21802234 | 1198 | { |
a885d89a | 1199 | nMenuItem = nItem; |
21802234 | 1200 | } |
21802234 DW |
1201 | else |
1202 | { | |
a885d89a DW |
1203 | // |
1204 | // Don't give hints for separators (doesn't make sense) nor for the | |
21802234 | 1205 | // items opening popup menus (they don't have them anyhow) |
a885d89a | 1206 | // |
21802234 DW |
1207 | return FALSE; |
1208 | } | |
a885d89a | 1209 | wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nMenuItem); |
21802234 | 1210 | |
a885d89a DW |
1211 | vEvent.SetEventObject(this); |
1212 | return GetEventHandler()->ProcessEvent(vEvent); | |
1213 | } // end of wxFrame::HandleMenuSelect | |
21802234 DW |
1214 | |
1215 | // --------------------------------------------------------------------------- | |
1216 | // the window proc for wxFrame | |
1217 | // --------------------------------------------------------------------------- | |
1218 | ||
a885d89a DW |
1219 | MRESULT wxFrame::OS2WindowProc( |
1220 | WXUINT uMessage | |
1221 | , WXWPARAM wParam | |
1222 | , WXLPARAM lParam | |
1223 | ) | |
21802234 | 1224 | { |
a885d89a DW |
1225 | MRESULT mRc = 0L; |
1226 | bool bProcessed = FALSE; | |
21802234 | 1227 | |
a885d89a | 1228 | switch (uMessage) |
21802234 DW |
1229 | { |
1230 | case WM_CLOSE: | |
a885d89a DW |
1231 | // |
1232 | // If we can't close, tell the system that we processed the | |
21802234 | 1233 | // message - otherwise it would close us |
a885d89a DW |
1234 | // |
1235 | bProcessed = !Close(); | |
21802234 DW |
1236 | break; |
1237 | ||
1238 | case WM_COMMAND: | |
1239 | { | |
a885d89a DW |
1240 | WORD wId; |
1241 | WORD wCmd; | |
1242 | WXHWND hWnd; | |
1243 | ||
1244 | UnpackCommand( (WXWPARAM)wParam | |
1245 | ,(WXLPARAM)lParam | |
1246 | ,&wId | |
1247 | ,&hWnd | |
1248 | ,&wCmd | |
1249 | ); | |
1250 | bProcessed = HandleCommand( wId | |
1251 | ,wCmd | |
1252 | ,(WXHWND)hWnd | |
1253 | ); | |
21802234 DW |
1254 | } |
1255 | break; | |
1256 | ||
1257 | case WM_MENUSELECT: | |
1258 | { | |
a885d89a DW |
1259 | WXWORD wItem; |
1260 | WXWORD wFlags; | |
1261 | WXHMENU hMenu; | |
1262 | ||
1263 | UnpackMenuSelect( wParam | |
1264 | ,lParam | |
1265 | ,&wItem | |
1266 | ,&wFlags | |
1267 | ,&hMenu | |
1268 | ); | |
1269 | bProcessed = HandleMenuSelect( wItem | |
1270 | ,wFlags | |
1271 | ,hMenu | |
1272 | ); | |
21802234 DW |
1273 | } |
1274 | break; | |
1275 | ||
1276 | case WM_PAINT: | |
a885d89a | 1277 | bProcessed = HandlePaint(); |
21802234 DW |
1278 | break; |
1279 | ||
a885d89a | 1280 | case CM_QUERYDRAGIMAGE: |
21802234 | 1281 | { |
a885d89a DW |
1282 | HPOINTER hIcon; |
1283 | ||
1284 | if (m_icon.Ok()) | |
1285 | hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L); | |
1286 | else | |
1287 | hIcon = (HPOINTER)m_hDefaultIcon; | |
1288 | mRc = (MRESULT)hIcon; | |
1289 | bProcessed = mRc != 0; | |
21802234 DW |
1290 | } |
1291 | break; | |
1292 | ||
1293 | case WM_SIZE: | |
a885d89a | 1294 | bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam); |
21802234 DW |
1295 | break; |
1296 | } | |
f38374d0 | 1297 | |
a885d89a DW |
1298 | if (!bProcessed ) |
1299 | mRc = wxWindow::OS2WindowProc( uMessage | |
1300 | ,wParam | |
1301 | ,lParam | |
1302 | ); | |
f38374d0 | 1303 | return (MRESULT)0; |
a885d89a | 1304 | } // wxFrame::OS2WindowProc |
21802234 | 1305 |