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