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