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