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