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