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