]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: frame.cpp | |
0d53fc34 | 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 | |
51c1d535 DW |
16 | #include "wx/defs.h" |
17 | #include "wx/object.h" | |
18 | #include "wx/dynarray.h" | |
19 | #include "wx/list.h" | |
20 | #include "wx/hash.h" | |
21 | #include "wx/string.h" | |
22 | #include "wx/intl.h" | |
23 | #include "wx/log.h" | |
24 | #include "wx/event.h" | |
21802234 DW |
25 | #include "wx/setup.h" |
26 | #include "wx/frame.h" | |
27 | #include "wx/menu.h" | |
28 | #include "wx/app.h" | |
29 | #include "wx/utils.h" | |
30 | #include "wx/dialog.h" | |
31 | #include "wx/settings.h" | |
32 | #include "wx/dcclient.h" | |
2aa60728 | 33 | #include "wx/mdi.h" |
21802234 DW |
34 | #endif // WX_PRECOMP |
35 | ||
36 | #include "wx/os2/private.h" | |
f38374d0 DW |
37 | |
38 | #if wxUSE_STATUSBAR | |
39 | #include "wx/statusbr.h" | |
ea51d98d | 40 | #include "wx/generic/statusbr.h" |
f38374d0 DW |
41 | #endif // wxUSE_STATUSBAR |
42 | ||
43 | #if wxUSE_TOOLBAR | |
44 | #include "wx/toolbar.h" | |
45 | #endif // wxUSE_TOOLBAR | |
46 | ||
0e320a79 | 47 | #include "wx/menuitem.h" |
21802234 | 48 | #include "wx/log.h" |
0e320a79 | 49 | |
f38374d0 DW |
50 | // ---------------------------------------------------------------------------- |
51 | // globals | |
52 | // ---------------------------------------------------------------------------- | |
53 | ||
21802234 DW |
54 | extern wxWindowList wxModelessWindows; |
55 | extern wxList WXDLLEXPORT wxPendingDelete; | |
19193a2c KB |
56 | |
57 | #if wxUSE_MENUS_NATIVE | |
21802234 | 58 | extern wxMenu *wxCurrentPopupMenu; |
19193a2c | 59 | #endif |
0e320a79 | 60 | |
19193a2c KB |
61 | extern void wxAssociateWinWithHandle( HWND hWnd |
62 | ,wxWindowOS2* pWin | |
b7084589 | 63 | ); |
51c1d535 | 64 | |
f38374d0 DW |
65 | // ---------------------------------------------------------------------------- |
66 | // event tables | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
0d53fc34 VS |
69 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) |
70 | EVT_ACTIVATE(wxFrame::OnActivate) | |
71 | EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) | |
0e320a79 DW |
72 | END_EVENT_TABLE() |
73 | ||
8d7ddd02 | 74 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) |
0e320a79 | 75 | |
f38374d0 DW |
76 | // ============================================================================ |
77 | // implementation | |
78 | // ============================================================================ | |
0e320a79 | 79 | |
f38374d0 DW |
80 | // ---------------------------------------------------------------------------- |
81 | // static class members | |
82 | // ---------------------------------------------------------------------------- | |
7e99520b | 83 | #if wxUSE_STATUSBAR |
0e320a79 | 84 | |
f38374d0 | 85 | #if wxUSE_NATIVE_STATUSBAR |
0d53fc34 | 86 | bool wxFrame::m_bUseNativeStatusBar = TRUE; |
f38374d0 | 87 | #else |
0d53fc34 | 88 | bool wxFrame::m_bUseNativeStatusBar = FALSE; |
f38374d0 | 89 | #endif |
0e320a79 | 90 | |
7e99520b DW |
91 | #endif //wxUSE_STATUSBAR |
92 | ||
f38374d0 DW |
93 | // ---------------------------------------------------------------------------- |
94 | // creation/destruction | |
95 | // ---------------------------------------------------------------------------- | |
96 | ||
0d53fc34 | 97 | void wxFrame::Init() |
0e320a79 | 98 | { |
ea51d98d DW |
99 | m_nFsStatusBarFields = 0; |
100 | m_nFsStatusBarHeight = 0; | |
101 | m_nFsToolBarHeight = 0; | |
5d44b24e | 102 | m_hWndToolTip = 0L; |
0cf6acbf | 103 | m_bWasMinimized = FALSE; |
5d44b24e DW |
104 | m_pWinLastFocused = NULL; |
105 | ||
106 | ||
107 | m_frameMenuBar = NULL; | |
108 | m_frameToolBar = NULL; | |
109 | m_frameStatusBar = NULL; | |
40bd6154 | 110 | |
5d44b24e DW |
111 | m_hTitleBar = NULLHANDLE; |
112 | m_hHScroll = NULLHANDLE; | |
113 | m_hVScroll = NULLHANDLE; | |
51c1d535 | 114 | |
40bd6154 DW |
115 | // |
116 | // Initialize SWP's | |
117 | // | |
40bd6154 DW |
118 | memset(&m_vSwpTitleBar, 0, sizeof(SWP)); |
119 | memset(&m_vSwpMenuBar, 0, sizeof(SWP)); | |
120 | memset(&m_vSwpHScroll, 0, sizeof(SWP)); | |
121 | memset(&m_vSwpVScroll, 0, sizeof(SWP)); | |
122 | memset(&m_vSwpStatusBar, 0, sizeof(SWP)); | |
123 | memset(&m_vSwpToolBar, 0, sizeof(SWP)); | |
5d44b24e DW |
124 | m_bIconized = FALSE; |
125 | ||
0d53fc34 | 126 | } // end of wxFrame::Init |
ea51d98d | 127 | |
0d53fc34 | 128 | bool wxFrame::Create( |
ea51d98d DW |
129 | wxWindow* pParent |
130 | , wxWindowID vId | |
131 | , const wxString& rsTitle | |
132 | , const wxPoint& rPos | |
133 | , const wxSize& rSize | |
5d44b24e | 134 | , long lStyle |
ea51d98d DW |
135 | , const wxString& rsName |
136 | ) | |
f38374d0 | 137 | { |
5d44b24e DW |
138 | if (!wxTopLevelWindow::Create( pParent |
139 | ,vId | |
140 | ,rsTitle | |
141 | ,rPos | |
142 | ,rSize | |
143 | ,lStyle | |
144 | ,rsName | |
145 | )) | |
146 | return FALSE; | |
5d44b24e DW |
147 | wxModelessWindows.Append(this); |
148 | return TRUE; | |
0d53fc34 | 149 | } // end of wxFrame::Create |
0e320a79 | 150 | |
0d53fc34 | 151 | wxFrame::~wxFrame() |
0e320a79 | 152 | { |
ea51d98d | 153 | m_isBeingDeleted = TRUE; |
ea51d98d | 154 | DeleteAllBars(); |
0d53fc34 | 155 | } // end of wxFrame::~wxFrame |
0e320a79 | 156 | |
ea51d98d | 157 | // |
0e320a79 | 158 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. |
ea51d98d | 159 | // |
0d53fc34 | 160 | void wxFrame::DoGetClientSize( |
80d83cbc DW |
161 | int* pX |
162 | , int* pY | |
163 | ) const | |
0e320a79 | 164 | { |
5d44b24e DW |
165 | wxTopLevelWindow::DoGetClientSize( pX |
166 | ,pY | |
167 | ); | |
5fb9d2be DW |
168 | // |
169 | // No need to use statusbar code as in WIN32 as the FORMATFRAME | |
170 | // window procedure ensures PM knows about the new frame client | |
5d44b24e DW |
171 | // size internally. A ::WinQueryWindowRect (that is called in |
172 | // wxWindow's GetClient size from above) is all that is needed! | |
5fb9d2be | 173 | // |
0d53fc34 | 174 | } // end of wxFrame::DoGetClientSize |
0e320a79 | 175 | |
a885d89a | 176 | // |
0e320a79 DW |
177 | // Set the client size (i.e. leave the calculation of borders etc. |
178 | // to wxWindows) | |
80d83cbc | 179 | // |
0d53fc34 | 180 | void wxFrame::DoSetClientSize( |
80d83cbc DW |
181 | int nWidth |
182 | , int nHeight | |
183 | ) | |
0e320a79 | 184 | { |
5d44b24e | 185 | wxStatusBar* pStatusBar = GetStatusBar(); |
21802234 | 186 | |
80d83cbc | 187 | // |
5d44b24e DW |
188 | // Statusbars are not part of the OS/2 Client but parent frame |
189 | // so no statusbar consideration | |
80d83cbc | 190 | // |
5d44b24e DW |
191 | wxTopLevelWindow::DoSetClientSize( nWidth |
192 | ,nHeight | |
193 | ); | |
0d53fc34 | 194 | } // end of wxFrame::DoSetClientSize |
80d83cbc | 195 | |
f38374d0 | 196 | // ---------------------------------------------------------------------------- |
5d44b24e | 197 | // wxFrame: various geometry-related functions |
f38374d0 DW |
198 | // ---------------------------------------------------------------------------- |
199 | ||
5d44b24e | 200 | void wxFrame::Raise() |
0e320a79 | 201 | { |
5d44b24e DW |
202 | wxFrameBase::Raise(); |
203 | ::WinSetWindowPos( (HWND) GetParent()->GetHWND() | |
204 | ,HWND_TOP | |
205 | ,0 | |
206 | ,0 | |
207 | ,0 | |
208 | ,0 | |
209 | ,SWP_ZORDER | |
210 | ); | |
211 | } | |
21802234 | 212 | |
5d44b24e DW |
213 | // generate an artificial resize event |
214 | void wxFrame::SendSizeEvent() | |
0e320a79 | 215 | { |
5d44b24e | 216 | if (!m_bIconized) |
8330166c | 217 | { |
5d44b24e | 218 | RECTL vRect = wxGetWindowRect(GetHwnd()); |
8330166c | 219 | |
5d44b24e DW |
220 | (void)::WinPostMsg( m_hFrame |
221 | ,WM_SIZE | |
222 | ,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom) | |
223 | ,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom) | |
224 | ); | |
f38374d0 | 225 | } |
5d44b24e | 226 | } |
0e320a79 | 227 | |
21802234 | 228 | #if wxUSE_STATUSBAR |
0d53fc34 | 229 | wxStatusBar* wxFrame::OnCreateStatusBar( |
0fe536e3 | 230 | int nNumber |
a885d89a | 231 | , long lulStyle |
0fe536e3 DW |
232 | , wxWindowID vId |
233 | , const wxString& rName | |
234 | ) | |
0e320a79 | 235 | { |
0fe536e3 | 236 | wxStatusBar* pStatusBar = NULL; |
f6bcfd97 BP |
237 | SWP vSwp; |
238 | ERRORID vError; | |
239 | wxString sError; | |
0e320a79 | 240 | |
0fe536e3 | 241 | pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber |
a885d89a | 242 | ,lulStyle |
0fe536e3 DW |
243 | ,vId |
244 | ,rName | |
5b3ed311 DW |
245 | ); |
246 | ||
247 | if( !pStatusBar ) | |
f6bcfd97 | 248 | return NULL; |
f6bcfd97 | 249 | |
54ffa107 DW |
250 | wxClientDC vDC(pStatusBar); |
251 | int nY; | |
252 | ||
253 | // | |
254 | // Set the height according to the font and the border size | |
255 | // | |
256 | vDC.SetFont(pStatusBar->GetFont()); // Screws up the menues for some reason | |
257 | vDC.GetTextExtent( "X" | |
258 | ,NULL | |
259 | ,&nY | |
260 | ); | |
261 | ||
262 | int nHeight = ((11 * nY) / 10 + 2 * pStatusBar->GetBorderY()); | |
263 | ||
264 | pStatusBar->SetSize( -1 | |
265 | ,-1 | |
266 | ,-1 | |
267 | ,nHeight | |
268 | ); | |
269 | ||
51c1d535 DW |
270 | ::WinSetParent( pStatusBar->GetHWND() |
271 | ,m_hFrame | |
272 | ,FALSE | |
273 | ); | |
274 | ::WinSetOwner( pStatusBar->GetHWND() | |
275 | ,m_hFrame | |
276 | ); | |
7e99520b | 277 | // |
5b3ed311 | 278 | // to show statusbar |
f6bcfd97 | 279 | // |
51c1d535 DW |
280 | if(::WinIsWindowShowing(m_hFrame)) |
281 | ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0); | |
7e99520b | 282 | |
0fe536e3 | 283 | return pStatusBar; |
0d53fc34 | 284 | } // end of wxFrame::OnCreateStatusBar |
0e320a79 | 285 | |
0d53fc34 | 286 | void wxFrame::PositionStatusBar() |
0e320a79 | 287 | { |
f6bcfd97 BP |
288 | SWP vSwp; |
289 | ERRORID vError; | |
290 | wxString sError; | |
291 | ||
0fe536e3 DW |
292 | // |
293 | // Native status bar positions itself | |
294 | // | |
295 | if (m_frameStatusBar) | |
f38374d0 | 296 | { |
a885d89a | 297 | int nWidth; |
987da0d4 | 298 | int nY; |
a885d89a | 299 | int nStatbarWidth; |
0fe536e3 DW |
300 | int nStatbarHeight; |
301 | HWND hWndClient; | |
302 | RECTL vRect; | |
51c1d535 | 303 | RECTL vFRect; |
0fe536e3 | 304 | |
51c1d535 | 305 | ::WinQueryWindowRect(m_hFrame, &vRect); |
987da0d4 | 306 | nY = vRect.yTop; |
51c1d535 DW |
307 | ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2); |
308 | vFRect = vRect; | |
309 | ::WinCalcFrameRect(m_hFrame, &vRect, TRUE); | |
0fe536e3 | 310 | nWidth = vRect.xRight - vRect.xLeft; |
987da0d4 | 311 | nY = nY - (vRect.yBottom - vFRect.yBottom); |
a885d89a | 312 | |
0fe536e3 DW |
313 | m_frameStatusBar->GetSize( &nStatbarWidth |
314 | ,&nStatbarHeight | |
315 | ); | |
f38374d0 | 316 | |
987da0d4 | 317 | nY= nY - nStatbarHeight; |
0fe536e3 | 318 | // |
f38374d0 DW |
319 | // Since we wish the status bar to be directly under the client area, |
320 | // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. | |
0fe536e3 | 321 | // |
51c1d535 | 322 | m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft |
987da0d4 | 323 | ,nY |
0fe536e3 DW |
324 | ,nWidth |
325 | ,nStatbarHeight | |
326 | ); | |
f6bcfd97 BP |
327 | if (!::WinQueryWindowPos(m_frameStatusBar->GetHWND(), &vSwp)) |
328 | { | |
329 | vError = ::WinGetLastError(vHabmain); | |
330 | sError = wxPMErrorToStr(vError); | |
51c1d535 | 331 | wxLogError("Error setting parent for StautsBar. Error: %s\n", sError); |
f6bcfd97 BP |
332 | return; |
333 | } | |
f38374d0 | 334 | } |
0d53fc34 | 335 | } // end of wxFrame::PositionStatusBar |
21802234 | 336 | #endif // wxUSE_STATUSBAR |
0e320a79 | 337 | |
19193a2c | 338 | #if wxUSE_MENUS_NATIVE |
0d53fc34 | 339 | void wxFrame::DetachMenuBar() |
0e320a79 | 340 | { |
21802234 | 341 | if (m_frameMenuBar) |
0e320a79 | 342 | { |
29435d81 | 343 | m_frameMenuBar->Detach(); |
0e320a79 | 344 | m_frameMenuBar = NULL; |
21802234 | 345 | } |
0d53fc34 | 346 | } // end of wxFrame::DetachMenuBar |
21802234 | 347 | |
0d53fc34 | 348 | void wxFrame::SetMenuBar( |
a885d89a | 349 | wxMenuBar* pMenuBar |
0fe536e3 | 350 | ) |
21802234 | 351 | { |
c3cea748 DW |
352 | ERRORID vError; |
353 | wxString sError; | |
dae16775 DW |
354 | HWND hTitlebar = NULLHANDLE; |
355 | HWND hHScroll = NULLHANDLE; | |
356 | HWND hVScroll = NULLHANDLE; | |
357 | HWND hMenuBar = NULLHANDLE; | |
358 | SWP vSwp; | |
359 | SWP vSwpTitlebar; | |
360 | SWP vSwpVScroll; | |
361 | SWP vSwpHScroll; | |
362 | SWP vSwpMenu; | |
c3cea748 | 363 | |
0fe536e3 | 364 | if (!pMenuBar) |
21802234 DW |
365 | { |
366 | DetachMenuBar(); | |
29a99be3 | 367 | |
64e0c5c6 DW |
368 | // |
369 | // Actually remove the menu from the frame | |
370 | // | |
371 | m_hMenu = (WXHMENU)0; | |
372 | InternalSetMenuBar(); | |
29a99be3 | 373 | } |
64e0c5c6 | 374 | else // set new non NULL menu bar |
c3cea748 | 375 | { |
64e0c5c6 | 376 | m_frameMenuBar = NULL; |
c3cea748 | 377 | |
64e0c5c6 DW |
378 | // |
379 | // Can set a menubar several times. | |
380 | // TODO: how to prevent a memory leak if you have a currently-unattached | |
381 | // menubar? wxWindows assumes that the frame will delete the menu (otherwise | |
382 | // there are problems for MDI). | |
383 | // | |
384 | if (pMenuBar->GetHMenu()) | |
385 | { | |
386 | m_hMenu = pMenuBar->GetHMenu(); | |
387 | } | |
388 | else | |
389 | { | |
390 | pMenuBar->Detach(); | |
391 | m_hMenu = pMenuBar->Create(); | |
392 | if (!m_hMenu) | |
393 | return; | |
394 | } | |
395 | InternalSetMenuBar(); | |
396 | m_frameMenuBar = pMenuBar; | |
0367c1c0 | 397 | pMenuBar->Attach((wxFrame*)this); |
c3cea748 | 398 | } |
0d53fc34 | 399 | } // end of wxFrame::SetMenuBar |
0e320a79 | 400 | |
0d53fc34 | 401 | void wxFrame::AttachMenuBar( |
893758d5 DW |
402 | wxMenuBar* pMenubar |
403 | ) | |
404 | { | |
19193a2c KB |
405 | wxFrameBase::AttachMenuBar(pMenubar); |
406 | ||
893758d5 DW |
407 | m_frameMenuBar = pMenubar; |
408 | ||
409 | if (!pMenubar) | |
410 | { | |
411 | // | |
412 | // Actually remove the menu from the frame | |
413 | // | |
414 | m_hMenu = (WXHMENU)0; | |
415 | InternalSetMenuBar(); | |
416 | } | |
417 | else // Set new non NULL menu bar | |
418 | { | |
419 | // | |
420 | // Can set a menubar several times. | |
421 | // | |
422 | if (pMenubar->GetHMenu()) | |
423 | { | |
424 | m_hMenu = pMenubar->GetHMenu(); | |
425 | } | |
426 | else | |
427 | { | |
428 | if (pMenubar->IsAttached()) | |
429 | pMenubar->Detach(); | |
430 | ||
431 | m_hMenu = pMenubar->Create(); | |
432 | ||
433 | if (!m_hMenu) | |
434 | return; | |
435 | } | |
436 | InternalSetMenuBar(); | |
437 | } | |
0d53fc34 | 438 | } // end of wxFrame::AttachMenuBar |
893758d5 | 439 | |
0d53fc34 | 440 | void wxFrame::InternalSetMenuBar() |
0e320a79 | 441 | { |
64e0c5c6 DW |
442 | ERRORID vError; |
443 | wxString sError; | |
444 | // | |
445 | // Set the parent and owner of the menubar to be the frame | |
446 | // | |
51c1d535 | 447 | if (!::WinSetParent(m_hMenu, m_hFrame, FALSE)) |
64e0c5c6 DW |
448 | { |
449 | vError = ::WinGetLastError(vHabmain); | |
450 | sError = wxPMErrorToStr(vError); | |
451 | wxLogError("Error setting parent for submenu. Error: %s\n", sError); | |
452 | } | |
453 | ||
51c1d535 | 454 | if (!::WinSetOwner(m_hMenu, m_hFrame)) |
64e0c5c6 DW |
455 | { |
456 | vError = ::WinGetLastError(vHabmain); | |
457 | sError = wxPMErrorToStr(vError); | |
458 | wxLogError("Error setting parent for submenu. Error: %s\n", sError); | |
459 | } | |
b7084589 | 460 | ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); |
0d53fc34 | 461 | } // end of wxFrame::InternalSetMenuBar |
19193a2c | 462 | #endif // wxUSE_MENUS_NATIVE |
0e320a79 | 463 | |
a885d89a DW |
464 | // |
465 | // Responds to colour changes, and passes event on to children | |
466 | // | |
0d53fc34 | 467 | void wxFrame::OnSysColourChanged( |
a885d89a DW |
468 | wxSysColourChangedEvent& rEvent |
469 | ) | |
0e320a79 | 470 | { |
a756f210 | 471 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); |
0e320a79 DW |
472 | Refresh(); |
473 | ||
7e99520b | 474 | #if wxUSE_STATUSBAR |
a885d89a | 475 | if (m_frameStatusBar) |
0e320a79 | 476 | { |
a885d89a DW |
477 | wxSysColourChangedEvent vEvent2; |
478 | ||
479 | vEvent2.SetEventObject(m_frameStatusBar); | |
480 | m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2); | |
0e320a79 | 481 | } |
7e99520b | 482 | #endif //wxUSE_STATUSBAR |
0e320a79 | 483 | |
a885d89a | 484 | // |
0e320a79 | 485 | // Propagate the event to the non-top-level children |
a885d89a DW |
486 | // |
487 | wxWindow::OnSysColourChanged(rEvent); | |
0d53fc34 | 488 | } // end of wxFrame::OnSysColourChanged |
21802234 | 489 | |
542875a8 | 490 | // Pass TRUE to show full screen, FALSE to restore. |
0d53fc34 | 491 | bool wxFrame::ShowFullScreen( |
542875a8 DW |
492 | bool bShow |
493 | , long lStyle | |
494 | ) | |
495 | { | |
64e0c5c6 | 496 | if (bShow) |
542875a8 DW |
497 | { |
498 | if (IsFullScreen()) | |
499 | return FALSE; | |
500 | ||
64e0c5c6 DW |
501 | m_bFsIsShowing = TRUE; |
502 | m_lFsStyle = lStyle; | |
542875a8 | 503 | |
7e99520b | 504 | #if wxUSE_TOOLBAR |
19193a2c | 505 | wxToolBar* pTheToolBar = GetToolBar(); |
7e99520b DW |
506 | #endif //wxUSE_TOOLBAR |
507 | ||
508 | #if wxUSE_STATUSBAR | |
19193a2c | 509 | wxStatusBar* pTheStatusBar = GetStatusBar(); |
7e99520b | 510 | #endif //wxUSE_STATUSBAR |
542875a8 | 511 | |
64e0c5c6 | 512 | int nDummyWidth; |
542875a8 | 513 | |
7e99520b | 514 | #if wxUSE_TOOLBAR |
64e0c5c6 DW |
515 | if (pTheToolBar) |
516 | pTheToolBar->GetSize(&nDummyWidth, &m_nFsToolBarHeight); | |
7e99520b DW |
517 | #endif //wxUSE_TOOLBAR |
518 | ||
519 | #if wxUSE_STATUSBAR | |
64e0c5c6 DW |
520 | if (pTheStatusBar) |
521 | pTheStatusBar->GetSize(&nDummyWidth, &m_nFsStatusBarHeight); | |
7e99520b | 522 | #endif //wxUSE_STATUSBAR |
542875a8 | 523 | |
7e99520b | 524 | #if wxUSE_TOOLBAR |
64e0c5c6 DW |
525 | // |
526 | // Zap the toolbar, menubar, and statusbar | |
527 | // | |
528 | if ((lStyle & wxFULLSCREEN_NOTOOLBAR) && pTheToolBar) | |
542875a8 | 529 | { |
64e0c5c6 DW |
530 | pTheToolBar->SetSize(-1,0); |
531 | pTheToolBar->Show(FALSE); | |
542875a8 | 532 | } |
7e99520b | 533 | #endif //wxUSE_TOOLBAR |
542875a8 | 534 | |
64e0c5c6 DW |
535 | if (lStyle & wxFULLSCREEN_NOMENUBAR) |
536 | { | |
b7084589 DW |
537 | ::WinSetParent(m_hMenu, m_hFrame, FALSE); |
538 | ::WinSetOwner(m_hMenu, m_hFrame); | |
539 | ::WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); | |
64e0c5c6 | 540 | } |
542875a8 | 541 | |
7e99520b | 542 | #if wxUSE_STATUSBAR |
64e0c5c6 | 543 | // |
542875a8 | 544 | // Save the number of fields in the statusbar |
64e0c5c6 DW |
545 | // |
546 | if ((lStyle & wxFULLSCREEN_NOSTATUSBAR) && pTheStatusBar) | |
542875a8 | 547 | { |
64e0c5c6 | 548 | m_nFsStatusBarFields = pTheStatusBar->GetFieldsCount(); |
542875a8 | 549 | SetStatusBar((wxStatusBar*) NULL); |
64e0c5c6 | 550 | delete pTheStatusBar; |
542875a8 DW |
551 | } |
552 | else | |
64e0c5c6 | 553 | m_nFsStatusBarFields = 0; |
7e99520b | 554 | #endif //wxUSE_STATUSBAR |
542875a8 | 555 | |
64e0c5c6 DW |
556 | // |
557 | // Zap the frame borders | |
558 | // | |
542875a8 | 559 | |
64e0c5c6 DW |
560 | // |
561 | // Save the 'normal' window style | |
562 | // | |
b7084589 | 563 | m_lFsOldWindowStyle = ::WinQueryWindowULong(m_hFrame, QWL_STYLE); |
542875a8 | 564 | |
64e0c5c6 | 565 | // |
b7084589 | 566 | // Save the old position, width & height, maximize state |
64e0c5c6 DW |
567 | // |
568 | m_vFsOldSize = GetRect(); | |
569 | m_bFsIsMaximized = IsMaximized(); | |
542875a8 | 570 | |
64e0c5c6 | 571 | // |
b7084589 | 572 | // Decide which window style flags to turn off |
64e0c5c6 DW |
573 | // |
574 | LONG lNewStyle = m_lFsOldWindowStyle; | |
575 | LONG lOffFlags = 0; | |
542875a8 | 576 | |
64e0c5c6 DW |
577 | if (lStyle & wxFULLSCREEN_NOBORDER) |
578 | lOffFlags |= FCF_BORDER; | |
579 | if (lStyle & wxFULLSCREEN_NOCAPTION) | |
580 | lOffFlags |= (FCF_TASKLIST | FCF_SYSMENU); | |
542875a8 | 581 | |
64e0c5c6 | 582 | lNewStyle &= (~lOffFlags); |
542875a8 | 583 | |
64e0c5c6 DW |
584 | // |
585 | // Change our window style to be compatible with full-screen mode | |
586 | // | |
b7084589 | 587 | ::WinSetWindowULong((HWND)m_hFrame, QWL_STYLE, (ULONG)lNewStyle); |
542875a8 | 588 | |
64e0c5c6 DW |
589 | // |
590 | // Resize to the size of the desktop | |
591 | int nWidth; | |
592 | int nHeight; | |
542875a8 | 593 | |
64e0c5c6 | 594 | RECTL vRect; |
542875a8 | 595 | |
64e0c5c6 DW |
596 | ::WinQueryWindowRect(HWND_DESKTOP, &vRect); |
597 | nWidth = vRect.xRight - vRect.xLeft; | |
598 | // | |
599 | // Rmember OS/2 is backwards! | |
600 | // | |
601 | nHeight = vRect.yTop - vRect.yBottom; | |
542875a8 | 602 | |
64e0c5c6 DW |
603 | SetSize( nWidth |
604 | ,nHeight | |
605 | ); | |
542875a8 | 606 | |
64e0c5c6 DW |
607 | // |
608 | // Now flush the window style cache and actually go full-screen | |
609 | // | |
610 | ::WinSetWindowPos( (HWND) GetParent()->GetHWND() | |
611 | ,HWND_TOP | |
612 | ,0 | |
613 | ,0 | |
614 | ,nWidth | |
615 | ,nHeight | |
616 | ,SWP_SIZE | SWP_SHOW | |
617 | ); | |
618 | ||
619 | wxSizeEvent vEvent( wxSize( nWidth | |
620 | ,nHeight | |
621 | ) | |
622 | ,GetId() | |
623 | ); | |
542875a8 | 624 | |
64e0c5c6 | 625 | GetEventHandler()->ProcessEvent(vEvent); |
542875a8 DW |
626 | return TRUE; |
627 | } | |
628 | else | |
629 | { | |
630 | if (!IsFullScreen()) | |
631 | return FALSE; | |
632 | ||
64e0c5c6 | 633 | m_bFsIsShowing = FALSE; |
542875a8 | 634 | |
7e99520b | 635 | #if wxUSE_TOOLBAR |
64e0c5c6 | 636 | wxToolBar* pTheToolBar = GetToolBar(); |
542875a8 | 637 | |
64e0c5c6 DW |
638 | // |
639 | // Restore the toolbar, menubar, and statusbar | |
640 | // | |
641 | if (pTheToolBar && (m_lFsStyle & wxFULLSCREEN_NOTOOLBAR)) | |
542875a8 | 642 | { |
64e0c5c6 DW |
643 | pTheToolBar->SetSize(-1, m_nFsToolBarHeight); |
644 | pTheToolBar->Show(TRUE); | |
542875a8 | 645 | } |
7e99520b | 646 | #endif //wxUSE_TOOLBAR |
542875a8 | 647 | |
7e99520b | 648 | #if wxUSE_STATUSBAR |
64e0c5c6 | 649 | if ((m_lFsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_nFsStatusBarFields > 0)) |
542875a8 | 650 | { |
64e0c5c6 | 651 | CreateStatusBar(m_nFsStatusBarFields); |
5b3ed311 | 652 | // PositionStatusBar(); |
542875a8 | 653 | } |
7e99520b | 654 | #endif //wxUSE_STATUSBAR |
542875a8 | 655 | |
64e0c5c6 DW |
656 | if ((m_lFsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0)) |
657 | { | |
b7084589 DW |
658 | ::WinSetParent(m_hMenu, m_hFrame, FALSE); |
659 | ::WinSetOwner(m_hMenu, m_hFrame); | |
660 | ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0); | |
64e0c5c6 DW |
661 | } |
662 | Maximize(m_bFsIsMaximized); | |
663 | ||
b7084589 | 664 | ::WinSetWindowULong( m_hFrame |
64e0c5c6 DW |
665 | ,QWL_STYLE |
666 | ,(ULONG)m_lFsOldWindowStyle | |
667 | ); | |
668 | ::WinSetWindowPos( (HWND) GetParent()->GetHWND() | |
669 | ,HWND_TOP | |
670 | ,m_vFsOldSize.x | |
671 | ,m_vFsOldSize.y | |
672 | ,m_vFsOldSize.width | |
673 | ,m_vFsOldSize.height | |
674 | ,SWP_SIZE | SWP_SHOW | |
675 | ); | |
542875a8 DW |
676 | return TRUE; |
677 | } | |
0d53fc34 | 678 | } // end of wxFrame::ShowFullScreen |
542875a8 | 679 | |
a885d89a DW |
680 | // |
681 | // Frame window | |
682 | // | |
a885d89a | 683 | // |
0e320a79 DW |
684 | // Default activation behaviour - set the focus for the first child |
685 | // subwindow found. | |
a885d89a | 686 | // |
0d53fc34 | 687 | void wxFrame::OnActivate( |
a885d89a DW |
688 | wxActivateEvent& rEvent |
689 | ) | |
0e320a79 | 690 | { |
c4955899 | 691 | if ( rEvent.GetActive() ) |
0e320a79 | 692 | { |
c4955899 DW |
693 | // restore focus to the child which was last focused |
694 | wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd); | |
21802234 | 695 | |
c4955899 DW |
696 | wxWindow* pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent() |
697 | : NULL; | |
698 | if (!pParent) | |
699 | { | |
700 | pParent = this; | |
701 | } | |
21802234 | 702 | |
c4955899 DW |
703 | wxSetFocusToChild( pParent |
704 | ,&m_pWinLastFocused | |
705 | ); | |
706 | } | |
707 | else // deactivating | |
708 | { | |
709 | // | |
710 | // Remember the last focused child if it is our child | |
711 | // | |
712 | m_pWinLastFocused = FindFocus(); | |
713 | ||
714 | for (wxWindowList::Node* pNode = GetChildren().GetFirst(); | |
715 | pNode; | |
716 | pNode = pNode->GetNext()) | |
717 | { | |
718 | // FIXME all this is totally bogus - we need to do the same as wxPanel, | |
719 | // but how to do it without duplicating the code? | |
720 | ||
721 | // restore focus | |
722 | wxWindow* pChild = pNode->GetData(); | |
723 | ||
724 | if (!pChild->IsTopLevel() | |
21802234 | 725 | #if wxUSE_TOOLBAR |
c4955899 | 726 | && !wxDynamicCast(pChild, wxToolBar) |
21802234 DW |
727 | #endif // wxUSE_TOOLBAR |
728 | #if wxUSE_STATUSBAR | |
c4955899 | 729 | && !wxDynamicCast(pChild, wxStatusBar) |
21802234 | 730 | #endif // wxUSE_STATUSBAR |
c4955899 DW |
731 | ) |
732 | { | |
733 | pChild->SetFocus(); | |
734 | return; | |
735 | } | |
21802234 | 736 | } |
0e320a79 | 737 | } |
0d53fc34 | 738 | } // end of wxFrame::OnActivate |
0e320a79 | 739 | |
f38374d0 DW |
740 | // ---------------------------------------------------------------------------- |
741 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
742 | // from the client area, so the client area is what's really available for the | |
743 | // frame contents | |
744 | // ---------------------------------------------------------------------------- | |
0e320a79 DW |
745 | |
746 | // Checks if there is a toolbar, and returns the first free client position | |
0d53fc34 | 747 | wxPoint wxFrame::GetClientAreaOrigin() const |
0e320a79 | 748 | { |
a885d89a DW |
749 | wxPoint vPoint(0, 0); |
750 | ||
7e99520b | 751 | #if wxUSE_TOOLBAR |
0e320a79 DW |
752 | if (GetToolBar()) |
753 | { | |
a885d89a DW |
754 | int nWidth; |
755 | int nHeight; | |
756 | ||
757 | GetToolBar()->GetSize( &nWidth | |
758 | ,&nHeight | |
759 | ); | |
0e320a79 DW |
760 | |
761 | if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) | |
762 | { | |
a885d89a | 763 | vPoint.x += nWidth; |
0e320a79 DW |
764 | } |
765 | else | |
766 | { | |
a885d89a DW |
767 | // PM is backwards from windows |
768 | vPoint.y += nHeight; | |
0e320a79 DW |
769 | } |
770 | } | |
7e99520b | 771 | #endif //wxUSE_TOOLBAR |
a885d89a | 772 | return vPoint; |
0d53fc34 | 773 | } // end of wxFrame::GetClientAreaOrigin |
0e320a79 | 774 | |
f38374d0 DW |
775 | // ---------------------------------------------------------------------------- |
776 | // tool/status bar stuff | |
777 | // ---------------------------------------------------------------------------- | |
778 | ||
21802234 | 779 | #if wxUSE_TOOLBAR |
f38374d0 | 780 | |
0d53fc34 | 781 | wxToolBar* wxFrame::CreateToolBar( |
a885d89a DW |
782 | long lStyle |
783 | , wxWindowID vId | |
784 | , const wxString& rName | |
785 | ) | |
0e320a79 | 786 | { |
a885d89a DW |
787 | if (wxFrameBase::CreateToolBar( lStyle |
788 | ,vId | |
789 | ,rName | |
790 | )) | |
0e320a79 | 791 | { |
0e320a79 | 792 | PositionToolBar(); |
0e320a79 | 793 | } |
f38374d0 | 794 | return m_frameToolBar; |
0d53fc34 | 795 | } // end of wxFrame::CreateToolBar |
0e320a79 | 796 | |
0d53fc34 | 797 | void wxFrame::PositionToolBar() |
0e320a79 | 798 | { |
a885d89a DW |
799 | HWND hWndClient; |
800 | RECTL vRect; | |
801 | ||
40bd6154 | 802 | ::WinQueryWindowRect(GetHwnd(), &vRect); |
0e320a79 | 803 | |
f38374d0 | 804 | #if wxUSE_STATUSBAR |
a885d89a | 805 | if (GetStatusBar()) |
0e320a79 | 806 | { |
a885d89a DW |
807 | int nStatusX; |
808 | int nStatusY; | |
809 | ||
810 | GetStatusBar()->GetClientSize( &nStatusX | |
811 | ,&nStatusY | |
812 | ); | |
813 | // PM is backwards from windows | |
814 | vRect.yBottom += nStatusY; | |
0e320a79 | 815 | } |
f38374d0 | 816 | #endif // wxUSE_STATUSBAR |
0e320a79 | 817 | |
1c84ee88 | 818 | if ( m_frameToolBar ) |
0e320a79 | 819 | { |
a885d89a DW |
820 | int nToolbarWidth; |
821 | int nToolbarHeight; | |
822 | ||
1c84ee88 | 823 | m_frameToolBar->GetSize( &nToolbarWidth |
a885d89a DW |
824 | ,&nToolbarHeight |
825 | ); | |
0e320a79 | 826 | |
a885d89a | 827 | if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) |
0e320a79 | 828 | { |
a885d89a | 829 | nToolbarHeight = vRect.yBottom; |
0e320a79 DW |
830 | } |
831 | else | |
832 | { | |
a885d89a | 833 | nToolbarWidth = vRect.xRight; |
21802234 | 834 | } |
f38374d0 | 835 | |
a885d89a DW |
836 | // |
837 | // Use the 'real' PM position here | |
838 | // | |
839 | GetToolBar()->SetSize( 0 | |
840 | ,0 | |
841 | ,nToolbarWidth | |
842 | ,nToolbarHeight | |
843 | ,wxSIZE_NO_ADJUSTMENTS | |
844 | ); | |
21802234 | 845 | } |
0d53fc34 | 846 | } // end of wxFrame::PositionToolBar |
21802234 DW |
847 | #endif // wxUSE_TOOLBAR |
848 | ||
f38374d0 DW |
849 | // ---------------------------------------------------------------------------- |
850 | // frame state (iconized/maximized/...) | |
851 | // ---------------------------------------------------------------------------- | |
852 | ||
a885d89a | 853 | // |
21802234 DW |
854 | // propagate our state change to all child frames: this allows us to emulate X |
855 | // Windows behaviour where child frames float independently of the parent one | |
856 | // on the desktop, but are iconized/restored with it | |
a885d89a | 857 | // |
0d53fc34 | 858 | void wxFrame::IconizeChildFrames( |
a885d89a DW |
859 | bool bIconize |
860 | ) | |
21802234 | 861 | { |
a885d89a DW |
862 | for (wxWindowList::Node* pNode = GetChildren().GetFirst(); |
863 | pNode; | |
864 | pNode = pNode->GetNext() ) | |
21802234 | 865 | { |
a885d89a | 866 | wxWindow* pWin = pNode->GetData(); |
0cf6acbf | 867 | wxFrame* pFrame = wxDynamicCast(pWin, wxFrame); |
21802234 | 868 | |
0cf6acbf DW |
869 | if ( pFrame |
870 | #if wxUSE_MDI_ARCHITECTURE | |
871 | && !wxDynamicCast(pFrame, wxMDIChildFrame) | |
872 | #endif // wxUSE_MDI_ARCHITECTURE | |
873 | ) | |
21802234 | 874 | { |
0cf6acbf DW |
875 | // |
876 | // We don't want to restore the child frames which had been | |
877 | // iconized even before we were iconized, so save the child frame | |
878 | // status when iconizing the parent frame and check it when | |
879 | // restoring it. | |
880 | // | |
881 | if (bIconize) | |
882 | { | |
883 | pFrame->m_bWasMinimized = pFrame->IsIconized(); | |
884 | } | |
885 | ||
886 | // | |
887 | // This test works for both iconizing and restoring | |
888 | // | |
889 | if (!pFrame->m_bWasMinimized) | |
890 | pFrame->Iconize(bIconize); | |
0e320a79 DW |
891 | } |
892 | } | |
0d53fc34 | 893 | } // end of wxFrame::IconizeChildFrames |
0e320a79 | 894 | |
5d44b24e DW |
895 | WXHICON wxFrame::GetDefaultIcon() const |
896 | { | |
897 | return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON | |
898 | : wxDEFAULT_FRAME_ICON); | |
899 | } | |
21802234 DW |
900 | // =========================================================================== |
901 | // message processing | |
902 | // =========================================================================== | |
903 | ||
904 | // --------------------------------------------------------------------------- | |
905 | // preprocessing | |
906 | // --------------------------------------------------------------------------- | |
0d53fc34 | 907 | bool wxFrame::OS2TranslateMessage( |
a885d89a DW |
908 | WXMSG* pMsg |
909 | ) | |
21802234 | 910 | { |
a885d89a | 911 | // |
21802234 | 912 | // try the menu bar accels |
a885d89a DW |
913 | // |
914 | wxMenuBar* pMenuBar = GetMenuBar(); | |
915 | ||
19193a2c | 916 | if (!pMenuBar) |
21802234 DW |
917 | return FALSE; |
918 | ||
19193a2c | 919 | #if wxUSE_ACCEL && wxUSE_MENUS_NATIVE |
a885d89a | 920 | const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable(); |
e604d44b | 921 | return rAcceleratorTable.Translate(GetHWND(), pMsg); |
7e99520b DW |
922 | #else |
923 | return FALSE; | |
924 | #endif //wxUSE_ACCEL | |
0d53fc34 | 925 | } // end of wxFrame::OS2TranslateMessage |
21802234 DW |
926 | |
927 | // --------------------------------------------------------------------------- | |
928 | // our private (non virtual) message handlers | |
929 | // --------------------------------------------------------------------------- | |
0d53fc34 | 930 | bool wxFrame::HandlePaint() |
21802234 | 931 | { |
a885d89a DW |
932 | RECTL vRect; |
933 | ||
e604d44b | 934 | if (::WinQueryUpdateRect(GetHWND(), &vRect)) |
29435d81 | 935 | { |
a885d89a | 936 | if (m_bIconized) |
29435d81 | 937 | { |
a885d89a DW |
938 | // |
939 | // Icons in PM are the same as "pointers" | |
940 | // | |
941 | HPOINTER hIcon; | |
29435d81 | 942 | |
a885d89a | 943 | if (m_icon.Ok()) |
b7084589 | 944 | hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L); |
a885d89a DW |
945 | else |
946 | hIcon = (HPOINTER)m_hDefaultIcon; | |
947 | ||
948 | // | |
21802234 DW |
949 | // Hold a pointer to the dc so long as the OnPaint() message |
950 | // is being processed | |
a885d89a DW |
951 | // |
952 | RECTL vRect2; | |
64e0c5c6 | 953 | HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2); |
29435d81 | 954 | |
a885d89a | 955 | // |
29435d81 | 956 | // Erase background before painting or we get white background |
a885d89a DW |
957 | // |
958 | OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2); | |
29435d81 | 959 | |
a885d89a | 960 | if (hIcon) |
29435d81 | 961 | { |
a885d89a DW |
962 | HWND hWndClient; |
963 | RECTL vRect3; | |
21802234 | 964 | |
40bd6154 | 965 | ::WinQueryWindowRect(GetHwnd(), &vRect3); |
29435d81 | 966 | |
a885d89a DW |
967 | static const int nIconWidth = 32; |
968 | static const int nIconHeight = 32; | |
969 | int nIconX = (int)((vRect3.xRight - nIconWidth)/2); | |
970 | int nIconY = (int)((vRect3.yBottom + nIconHeight)/2); | |
29435d81 | 971 | |
a885d89a | 972 | ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL); |
29435d81 | 973 | } |
a885d89a | 974 | ::WinEndPaint(hPs); |
29435d81 DW |
975 | return TRUE; |
976 | } | |
977 | else | |
978 | { | |
8330166c DW |
979 | if (!wxWindow::HandlePaint()) |
980 | { | |
981 | HPS hPS; | |
982 | RECTL vRect; | |
983 | ||
984 | hPS = ::WinBeginPaint( GetHwnd() | |
985 | ,NULLHANDLE | |
986 | ,&vRect | |
987 | ); | |
988 | if(hPS) | |
989 | { | |
990 | ::GpiCreateLogColorTable( hPS | |
991 | ,0L | |
992 | ,LCOLF_CONSECRGB | |
993 | ,0L | |
994 | ,(LONG)wxTheColourDatabase->m_nSize | |
995 | ,(PLONG)wxTheColourDatabase->m_palTable | |
996 | ); | |
997 | ::GpiCreateLogColorTable( hPS | |
998 | ,0L | |
999 | ,LCOLF_RGB | |
1000 | ,0L | |
1001 | ,0L | |
1002 | ,NULL | |
1003 | ); | |
1004 | ||
1005 | ::WinFillRect( hPS | |
1006 | ,&vRect | |
1007 | ,GetBackgroundColour().GetPixel() | |
1008 | ); | |
1009 | ::WinEndPaint(hPS); | |
1010 | } | |
1011 | } | |
1012 | return TRUE; | |
29435d81 DW |
1013 | } |
1014 | } | |
1015 | else | |
1016 | { | |
1017 | // nothing to paint - processed | |
1018 | return TRUE; | |
1019 | } | |
29435d81 | 1020 | return FALSE; |
0d53fc34 | 1021 | } // end of wxFrame::HandlePaint |
21802234 | 1022 | |
0d53fc34 | 1023 | bool wxFrame::HandleSize( |
a885d89a DW |
1024 | int nX |
1025 | , int nY | |
1026 | , WXUINT nId | |
1027 | ) | |
21802234 | 1028 | { |
a885d89a | 1029 | bool bProcessed = FALSE; |
21802234 | 1030 | |
a885d89a | 1031 | switch (nId) |
21802234 | 1032 | { |
a885d89a DW |
1033 | case kSizeNormal: |
1034 | // | |
1035 | // Only do it it if we were iconized before, otherwise resizing the | |
21802234 DW |
1036 | // parent frame has a curious side effect of bringing it under it's |
1037 | // children | |
a885d89a | 1038 | if (!m_bIconized ) |
21802234 DW |
1039 | break; |
1040 | ||
a885d89a | 1041 | // |
21802234 | 1042 | // restore all child frames too |
a885d89a | 1043 | // |
21802234 | 1044 | IconizeChildFrames(FALSE); |
3febf684 | 1045 | (void)SendIconizeEvent(FALSE); |
21802234 | 1046 | |
a885d89a | 1047 | // |
21802234 | 1048 | // fall through |
a885d89a | 1049 | // |
21802234 | 1050 | |
a885d89a DW |
1051 | case kSizeMax: |
1052 | m_bIconized = FALSE; | |
21802234 DW |
1053 | break; |
1054 | ||
a885d89a DW |
1055 | case kSizeMin: |
1056 | // | |
1057 | // Iconize all child frames too | |
1058 | // | |
21802234 | 1059 | IconizeChildFrames(TRUE); |
3febf684 | 1060 | (void)SendIconizeEvent(); |
a885d89a | 1061 | m_bIconized = TRUE; |
21802234 DW |
1062 | break; |
1063 | } | |
f38374d0 | 1064 | |
a885d89a | 1065 | if (!m_bIconized) |
21802234 | 1066 | { |
a885d89a | 1067 | // |
29435d81 | 1068 | // forward WM_SIZE to status bar control |
a885d89a | 1069 | // |
f38374d0 DW |
1070 | #if wxUSE_NATIVE_STATUSBAR |
1071 | if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))) | |
1072 | { | |
a885d89a DW |
1073 | wxSizeEvent vEvent( wxSize( nX |
1074 | ,nY | |
1075 | ) | |
1076 | ,m_frameStatusBar->GetId() | |
1077 | ); | |
f38374d0 | 1078 | |
a885d89a DW |
1079 | vEvent.SetEventObject(m_frameStatusBar); |
1080 | m_frameStatusBar->OnSize(vEvent); | |
f38374d0 DW |
1081 | } |
1082 | #endif // wxUSE_NATIVE_STATUSBAR | |
1083 | ||
51c1d535 | 1084 | PositionStatusBar(); |
7e99520b | 1085 | #if wxUSE_TOOLBAR |
21802234 | 1086 | PositionToolBar(); |
7e99520b DW |
1087 | #endif // wxUSE_TOOLBAR |
1088 | ||
a885d89a DW |
1089 | wxSizeEvent vEvent( wxSize( nX |
1090 | ,nY | |
1091 | ) | |
1092 | ,m_windowId | |
1093 | ); | |
21802234 | 1094 | |
a885d89a DW |
1095 | vEvent.SetEventObject(this); |
1096 | bProcessed = GetEventHandler()->ProcessEvent(vEvent); | |
987da0d4 | 1097 | AlterChildPos(); |
21802234 | 1098 | } |
a885d89a | 1099 | return bProcessed; |
0d53fc34 | 1100 | } // end of wxFrame::HandleSize |
21802234 | 1101 | |
0d53fc34 | 1102 | bool wxFrame::HandleCommand( |
a885d89a DW |
1103 | WXWORD nId |
1104 | , WXWORD nCmd | |
1105 | , WXHWND hControl | |
1106 | ) | |
21802234 | 1107 | { |
a885d89a | 1108 | if (hControl) |
21802234 | 1109 | { |
a885d89a | 1110 | // |
21802234 | 1111 | // In case it's e.g. a toolbar. |
a885d89a DW |
1112 | // |
1113 | wxWindow* pWin = wxFindWinFromHandle(hControl); | |
1114 | ||
1115 | if (pWin) | |
1116 | return pWin->OS2Command( nCmd | |
1117 | ,nId | |
1118 | ); | |
21802234 DW |
1119 | } |
1120 | ||
a885d89a DW |
1121 | // |
1122 | // Handle here commands from menus and accelerators | |
1123 | // | |
5b3ed311 | 1124 | if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR) |
21802234 | 1125 | { |
19193a2c | 1126 | #if wxUSE_MENUS_NATIVE |
a885d89a | 1127 | if (wxCurrentPopupMenu) |
21802234 | 1128 | { |
a885d89a DW |
1129 | wxMenu* pPopupMenu = wxCurrentPopupMenu; |
1130 | ||
21802234 DW |
1131 | wxCurrentPopupMenu = NULL; |
1132 | ||
a885d89a DW |
1133 | return pPopupMenu->OS2Command( nCmd |
1134 | ,nId | |
1135 | ); | |
19193a2c | 1136 | return TRUE; |
21802234 | 1137 | } |
19193a2c | 1138 | #endif |
21802234 | 1139 | |
a885d89a | 1140 | if (ProcessCommand(nId)) |
21802234 DW |
1141 | { |
1142 | return TRUE; | |
1143 | } | |
1144 | } | |
21802234 | 1145 | return FALSE; |
0d53fc34 | 1146 | } // end of wxFrame::HandleCommand |
21802234 | 1147 | |
0d53fc34 | 1148 | bool wxFrame::HandleMenuSelect( |
a885d89a DW |
1149 | WXWORD nItem |
1150 | , WXWORD nFlags | |
1151 | , WXHMENU hMenu | |
1152 | ) | |
21802234 | 1153 | { |
e604d44b DW |
1154 | if( !nFlags ) |
1155 | { | |
1156 | MENUITEM mItem; | |
1157 | MRESULT rc; | |
1158 | ||
51c1d535 | 1159 | rc = ::WinSendMsg(hMenu, MM_QUERYITEM, MPFROM2SHORT(nItem, TRUE), (MPARAM)&mItem); |
e604d44b DW |
1160 | |
1161 | if(rc && !(mItem.afStyle & (MIS_SUBMENU | MIS_SEPARATOR))) | |
1162 | { | |
1163 | wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nItem); | |
1164 | ||
1165 | vEvent.SetEventObject(this); | |
1166 | GetEventHandler()->ProcessEvent(vEvent); // return value would be ignored by PM | |
1167 | } | |
1168 | } | |
1169 | return TRUE; | |
0d53fc34 | 1170 | } // end of wxFrame::HandleMenuSelect |
21802234 DW |
1171 | |
1172 | // --------------------------------------------------------------------------- | |
51c1d535 | 1173 | // Main Frame window proc |
21802234 | 1174 | // --------------------------------------------------------------------------- |
51c1d535 DW |
1175 | MRESULT EXPENTRY wxFrameMainWndProc( |
1176 | HWND hWnd | |
1177 | , ULONG ulMsg | |
1178 | , MPARAM wParam | |
1179 | , MPARAM lParam | |
1180 | ) | |
1181 | { | |
1182 | MRESULT rc = (MRESULT)0; | |
1183 | bool bProcessed = FALSE; | |
1184 | wxFrame* pWnd = NULL; | |
1185 | ||
1186 | pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd); | |
1187 | switch (ulMsg) | |
1188 | { | |
1189 | case WM_QUERYFRAMECTLCOUNT: | |
1190 | if(pWnd && pWnd->m_fnOldWndProc) | |
1191 | { | |
1192 | USHORT uItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam)); | |
1193 | ||
1194 | rc = MRFROMSHORT(uItemCount); | |
1195 | } | |
1196 | break; | |
1197 | ||
1198 | case WM_FORMATFRAME: | |
1199 | ///////////////////////////////////////////////////////////////////////////////// | |
1200 | // Applications that subclass frame controls may find that the frame is already | |
1201 | // subclassed the number of frame controls is variable. | |
1202 | // The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be | |
1203 | // subclassed by calling the previous window procedure and modifying its result. | |
1204 | //////////////////////////////////////////////////////////////////////////////// | |
1205 | { | |
1206 | int nItemCount; | |
1207 | int i; | |
1208 | PSWP pSWP = NULL; | |
1209 | SWP vSwpStb; | |
1210 | RECTL vRectl; | |
1211 | RECTL vRstb; | |
1212 | int nHeight=0; | |
1213 | ||
1214 | pSWP = (PSWP)PVOIDFROMMP(wParam); | |
1215 | nItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam)); | |
1216 | if(pWnd->m_frameStatusBar) | |
1217 | { | |
1218 | ::WinQueryWindowRect(pWnd->m_frameStatusBar->GetHWND(), &vRstb); | |
1219 | pWnd->m_frameStatusBar->GetSize(NULL, &nHeight); | |
1220 | ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl); | |
1221 | ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2); | |
1222 | vRstb = vRectl; | |
1223 | ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE); | |
1224 | ||
1225 | vSwpStb.x = vRectl.xLeft - vRstb.xLeft; | |
1226 | vSwpStb.y = vRectl.yBottom - vRstb.yBottom; | |
1227 | vSwpStb.cx = vRectl.xRight - vRectl.xLeft - 1; //?? -1 ?? | |
1228 | vSwpStb.cy = nHeight; | |
1229 | vSwpStb.fl = SWP_SIZE |SWP_MOVE | SWP_SHOW; | |
1230 | vSwpStb.hwnd = pWnd->m_frameStatusBar->GetHWND(); | |
1231 | vSwpStb.hwndInsertBehind = HWND_TOP; | |
1232 | } | |
1233 | ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl); | |
1234 | ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2); | |
1235 | ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE); | |
1236 | ::WinMapWindowPoints(HWND_DESKTOP, pWnd->m_hFrame, (PPOINTL)&vRectl, 2); | |
1237 | for(i = 0; i < nItemCount; i++) | |
1238 | { | |
1239 | if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd) | |
1240 | { | |
1241 | pSWP[i].x = vRectl.xLeft; | |
1242 | pSWP[i].y = vRectl.yBottom + nHeight; | |
1243 | pSWP[i].cx = vRectl.xRight - vRectl.xLeft; | |
1244 | pSWP[i].cy = vRectl.yTop - vRectl.yBottom - nHeight; | |
1245 | pSWP[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW; | |
1246 | pSWP[i].hwndInsertBehind = HWND_TOP; | |
1247 | } | |
1248 | } | |
1249 | bProcessed = TRUE; | |
1250 | rc = MRFROMSHORT(nItemCount); | |
1251 | } | |
1252 | break; | |
1253 | ||
1254 | default: | |
1255 | if(pWnd && pWnd->m_fnOldWndProc) | |
1256 | rc = pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam); | |
1257 | else | |
1258 | rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); | |
1259 | } | |
1260 | return rc; | |
1261 | } // end of wxFrameMainWndProc | |
1262 | ||
1263 | MRESULT EXPENTRY wxFrameWndProc( | |
1264 | HWND hWnd | |
1265 | , ULONG ulMsg | |
1266 | , MPARAM wParam | |
1267 | , MPARAM lParam | |
1268 | ) | |
1269 | { | |
1270 | // | |
1271 | // Trace all ulMsgs - useful for the debugging | |
1272 | // | |
1273 | HWND parentHwnd; | |
1274 | wxFrame* pWnd = NULL; | |
1275 | ||
1276 | parentHwnd = WinQueryWindow(hWnd,QW_PARENT); | |
1277 | pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd); | |
1278 | ||
1279 | // | |
1280 | // When we get the first message for the HWND we just created, we associate | |
1281 | // it with wxWindow stored in wxWndHook | |
1282 | // | |
51c1d535 DW |
1283 | |
1284 | MRESULT rc = (MRESULT)0; | |
1285 | bool bProcessed = FALSE; | |
1286 | ||
1287 | // | |
1288 | // Stop right here if we don't have a valid handle in our wxWindow object. | |
1289 | // | |
1290 | if (pWnd && !pWnd->GetHWND()) | |
1291 | { | |
1292 | pWnd->SetHWND((WXHWND) hWnd); | |
1293 | rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam ); | |
1294 | pWnd->SetHWND(0); | |
1295 | } | |
1296 | else | |
1297 | { | |
d08f23a7 DW |
1298 | if (pWnd) |
1299 | rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam); | |
1300 | else | |
1301 | rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam); | |
51c1d535 DW |
1302 | } |
1303 | return rc; | |
1304 | } // end of wxFrameWndProc | |
21802234 | 1305 | |
0d53fc34 | 1306 | MRESULT wxFrame::OS2WindowProc( |
a885d89a DW |
1307 | WXUINT uMessage |
1308 | , WXWPARAM wParam | |
1309 | , WXLPARAM lParam | |
1310 | ) | |
21802234 | 1311 | { |
a885d89a DW |
1312 | MRESULT mRc = 0L; |
1313 | bool bProcessed = FALSE; | |
21802234 | 1314 | |
a885d89a | 1315 | switch (uMessage) |
21802234 DW |
1316 | { |
1317 | case WM_CLOSE: | |
a885d89a DW |
1318 | // |
1319 | // If we can't close, tell the system that we processed the | |
21802234 | 1320 | // message - otherwise it would close us |
a885d89a DW |
1321 | // |
1322 | bProcessed = !Close(); | |
21802234 DW |
1323 | break; |
1324 | ||
d08f23a7 | 1325 | case WM_PAINT: |
8d854fa9 DW |
1326 | bProcessed = HandlePaint(); |
1327 | mRc = (MRESULT)FALSE; | |
1328 | break; | |
d08f23a7 | 1329 | |
8d854fa9 DW |
1330 | case WM_ERASEBACKGROUND: |
1331 | // | |
1332 | // Returning TRUE to requests PM to paint the window background | |
1333 | // in SYSCLR_WINDOW. We capture this here because the PS returned | |
1334 | // in Frames is the PS for the whole frame, which we can't really | |
1335 | // use at all. If you want to paint a different background, do it | |
1336 | // in an OnPaint using a wxPaintDC. | |
1337 | // | |
1338 | mRc = (MRESULT)(TRUE); | |
d08f23a7 DW |
1339 | break; |
1340 | ||
8d854fa9 | 1341 | case WM_COMMAND: |
21802234 | 1342 | { |
a885d89a DW |
1343 | WORD wId; |
1344 | WORD wCmd; | |
1345 | WXHWND hWnd; | |
1346 | ||
1347 | UnpackCommand( (WXWPARAM)wParam | |
d08f23a7 DW |
1348 | ,(WXLPARAM)lParam |
1349 | ,&wId | |
1350 | ,&hWnd | |
1351 | ,&wCmd | |
1352 | ); | |
5b3ed311 | 1353 | |
a885d89a DW |
1354 | bProcessed = HandleCommand( wId |
1355 | ,wCmd | |
1356 | ,(WXHWND)hWnd | |
1357 | ); | |
21802234 DW |
1358 | } |
1359 | break; | |
1360 | ||
1361 | case WM_MENUSELECT: | |
1362 | { | |
a885d89a DW |
1363 | WXWORD wItem; |
1364 | WXWORD wFlags; | |
1365 | WXHMENU hMenu; | |
1366 | ||
1367 | UnpackMenuSelect( wParam | |
1368 | ,lParam | |
1369 | ,&wItem | |
1370 | ,&wFlags | |
1371 | ,&hMenu | |
1372 | ); | |
1373 | bProcessed = HandleMenuSelect( wItem | |
1374 | ,wFlags | |
1375 | ,hMenu | |
1376 | ); | |
e604d44b | 1377 | mRc = (MRESULT)TRUE; |
21802234 DW |
1378 | } |
1379 | break; | |
1380 | ||
d08f23a7 DW |
1381 | case WM_SIZE: |
1382 | { | |
1383 | SHORT nScxold = SHORT1FROMMP(wParam); // Old horizontal size. | |
1384 | SHORT nScyold = SHORT2FROMMP(wParam); // Old vertical size. | |
1385 | SHORT nScxnew = SHORT1FROMMP(lParam); // New horizontal size. | |
1386 | SHORT nScynew = SHORT2FROMMP(lParam); // New vertical size. | |
1387 | ||
1388 | lParam = MRFROM2SHORT( nScxnew - 20 | |
1389 | ,nScynew - 30 | |
1390 | ); | |
1391 | } | |
1392 | bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam); | |
1393 | mRc = (MRESULT)FALSE; | |
21802234 DW |
1394 | break; |
1395 | ||
a885d89a | 1396 | case CM_QUERYDRAGIMAGE: |
21802234 | 1397 | { |
a885d89a DW |
1398 | HPOINTER hIcon; |
1399 | ||
1400 | if (m_icon.Ok()) | |
e604d44b | 1401 | hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L); |
a885d89a DW |
1402 | else |
1403 | hIcon = (HPOINTER)m_hDefaultIcon; | |
1404 | mRc = (MRESULT)hIcon; | |
1405 | bProcessed = mRc != 0; | |
21802234 DW |
1406 | } |
1407 | break; | |
21802234 | 1408 | } |
f38374d0 | 1409 | |
a885d89a DW |
1410 | if (!bProcessed ) |
1411 | mRc = wxWindow::OS2WindowProc( uMessage | |
1412 | ,wParam | |
1413 | ,lParam | |
1414 | ); | |
e604d44b | 1415 | return (MRESULT)mRc; |
0d53fc34 | 1416 | } // wxFrame::OS2WindowProc |
21802234 | 1417 | |
0d53fc34 | 1418 | void wxFrame::SetClient(WXHWND c_Hwnd) |
5b3ed311 | 1419 | { |
51c1d535 | 1420 | // Duh...nothing to do under OS/2 |
5b3ed311 DW |
1421 | } |
1422 | ||
0d53fc34 | 1423 | void wxFrame::SetClient( |
51c1d535 DW |
1424 | wxWindow* pWindow |
1425 | ) | |
5b3ed311 | 1426 | { |
51c1d535 DW |
1427 | wxWindow* pOldClient = this->GetClient(); |
1428 | bool bClientHasFocus = pOldClient && (pOldClient == wxWindow::FindFocus()); | |
5b3ed311 | 1429 | |
51c1d535 | 1430 | if(pOldClient == pWindow) // nothing to do |
5b3ed311 | 1431 | return; |
51c1d535 DW |
1432 | if(pWindow == NULL) // just need to remove old client |
1433 | { | |
1434 | if(pOldClient == NULL) // nothing to do | |
1435 | return; | |
5b3ed311 | 1436 | |
51c1d535 | 1437 | if(bClientHasFocus ) |
5b3ed311 DW |
1438 | this->SetFocus(); |
1439 | ||
51c1d535 DW |
1440 | pOldClient->Enable( FALSE ); |
1441 | pOldClient->Show( FALSE ); | |
1442 | ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId()); | |
5b3ed311 | 1443 | // to avoid OS/2 bug need to update frame |
b7084589 | 1444 | ::WinSendMsg((HWND)this->GetFrame(), WM_UPDATEFRAME, (MPARAM)~0, 0); |
5b3ed311 | 1445 | return; |
51c1d535 | 1446 | } |
5b3ed311 | 1447 | |
51c1d535 DW |
1448 | // |
1449 | // Else need to change client | |
1450 | // | |
1451 | if(bClientHasFocus) | |
5b3ed311 DW |
1452 | this->SetFocus(); |
1453 | ||
51c1d535 DW |
1454 | ::WinEnableWindowUpdate((HWND)GetHWND(), FALSE); |
1455 | if(pOldClient) | |
1456 | { | |
1457 | pOldClient->Enable(FALSE); | |
1458 | pOldClient->Show(FALSE); | |
1459 | ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId()); | |
1460 | } | |
1461 | pWindow->Reparent(this); | |
1462 | ::WinSetWindowUShort(pWindow->GetHWND(), QWS_ID, FID_CLIENT); | |
1463 | ::WinEnableWindowUpdate((HWND)GetHWND(), TRUE); | |
1464 | pWindow->Enable(); | |
1465 | pWindow->Show(); // ensure client is showing | |
1466 | if( this->IsShown() ) | |
1467 | { | |
1468 | this->Show(); | |
b7084589 | 1469 | ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0); |
51c1d535 | 1470 | } |
5b3ed311 DW |
1471 | } |
1472 | ||
0d53fc34 | 1473 | wxWindow* wxFrame::GetClient() |
5b3ed311 | 1474 | { |
b7084589 | 1475 | return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT)); |
5b3ed311 | 1476 | } |