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