]> git.saurik.com Git - wxWidgets.git/blame - src/os2/frame.cpp
signed/unsigned comparison warning (and probably even error) fixed
[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
d697657f
DW
321#if wxUSE_TOOLBAR
322wxToolBar* wxFrame::OnCreateToolBar(
323 long lStyle
324, wxWindowID vId
325, const wxString& rsName
326)
327{
328 wxToolBar* pToolBar = wxFrameBase::OnCreateToolBar( lStyle
329 ,vId
330 ,rsName
331 );
332
333 ::WinSetParent( pToolBar->GetHWND()
334 ,m_hFrame
335 ,FALSE
336 );
337 ::WinSetOwner( pToolBar->GetHWND()
338 ,m_hFrame
339 );
340 return pToolBar;
341} // end of WinGuiBase_CFrame::OnCreateToolBar
342#endif
343
19193a2c 344#if wxUSE_MENUS_NATIVE
0d53fc34 345void wxFrame::DetachMenuBar()
0e320a79 346{
21802234 347 if (m_frameMenuBar)
0e320a79 348 {
29435d81 349 m_frameMenuBar->Detach();
0e320a79 350 m_frameMenuBar = NULL;
21802234 351 }
0d53fc34 352} // end of wxFrame::DetachMenuBar
21802234 353
0d53fc34 354void wxFrame::SetMenuBar(
a885d89a 355 wxMenuBar* pMenuBar
0fe536e3 356)
21802234 357{
c3cea748
DW
358 ERRORID vError;
359 wxString sError;
dae16775
DW
360 HWND hTitlebar = NULLHANDLE;
361 HWND hHScroll = NULLHANDLE;
362 HWND hVScroll = NULLHANDLE;
363 HWND hMenuBar = NULLHANDLE;
364 SWP vSwp;
365 SWP vSwpTitlebar;
366 SWP vSwpVScroll;
367 SWP vSwpHScroll;
368 SWP vSwpMenu;
c3cea748 369
0fe536e3 370 if (!pMenuBar)
21802234
DW
371 {
372 DetachMenuBar();
29a99be3 373
64e0c5c6
DW
374 //
375 // Actually remove the menu from the frame
376 //
377 m_hMenu = (WXHMENU)0;
378 InternalSetMenuBar();
29a99be3 379 }
64e0c5c6 380 else // set new non NULL menu bar
c3cea748 381 {
64e0c5c6 382 m_frameMenuBar = NULL;
c3cea748 383
64e0c5c6
DW
384 //
385 // Can set a menubar several times.
386 // TODO: how to prevent a memory leak if you have a currently-unattached
387 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
388 // there are problems for MDI).
389 //
390 if (pMenuBar->GetHMenu())
391 {
392 m_hMenu = pMenuBar->GetHMenu();
393 }
394 else
395 {
396 pMenuBar->Detach();
397 m_hMenu = pMenuBar->Create();
398 if (!m_hMenu)
399 return;
400 }
401 InternalSetMenuBar();
402 m_frameMenuBar = pMenuBar;
0367c1c0 403 pMenuBar->Attach((wxFrame*)this);
c3cea748 404 }
0d53fc34 405} // end of wxFrame::SetMenuBar
0e320a79 406
0d53fc34 407void wxFrame::AttachMenuBar(
893758d5
DW
408 wxMenuBar* pMenubar
409)
410{
19193a2c
KB
411 wxFrameBase::AttachMenuBar(pMenubar);
412
893758d5
DW
413 m_frameMenuBar = pMenubar;
414
415 if (!pMenubar)
416 {
417 //
418 // Actually remove the menu from the frame
419 //
420 m_hMenu = (WXHMENU)0;
421 InternalSetMenuBar();
422 }
423 else // Set new non NULL menu bar
424 {
425 //
426 // Can set a menubar several times.
427 //
428 if (pMenubar->GetHMenu())
429 {
430 m_hMenu = pMenubar->GetHMenu();
431 }
432 else
433 {
434 if (pMenubar->IsAttached())
435 pMenubar->Detach();
436
437 m_hMenu = pMenubar->Create();
438
439 if (!m_hMenu)
440 return;
441 }
442 InternalSetMenuBar();
443 }
0d53fc34 444} // end of wxFrame::AttachMenuBar
893758d5 445
0d53fc34 446void wxFrame::InternalSetMenuBar()
0e320a79 447{
64e0c5c6
DW
448 ERRORID vError;
449 wxString sError;
450 //
451 // Set the parent and owner of the menubar to be the frame
452 //
51c1d535 453 if (!::WinSetParent(m_hMenu, m_hFrame, FALSE))
64e0c5c6
DW
454 {
455 vError = ::WinGetLastError(vHabmain);
456 sError = wxPMErrorToStr(vError);
457 wxLogError("Error setting parent for submenu. Error: %s\n", sError);
458 }
459
51c1d535 460 if (!::WinSetOwner(m_hMenu, m_hFrame))
64e0c5c6
DW
461 {
462 vError = ::WinGetLastError(vHabmain);
463 sError = wxPMErrorToStr(vError);
464 wxLogError("Error setting parent for submenu. Error: %s\n", sError);
465 }
b7084589 466 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
0d53fc34 467} // end of wxFrame::InternalSetMenuBar
19193a2c 468#endif // wxUSE_MENUS_NATIVE
0e320a79 469
a885d89a
DW
470//
471// Responds to colour changes, and passes event on to children
472//
0d53fc34 473void wxFrame::OnSysColourChanged(
a885d89a
DW
474 wxSysColourChangedEvent& rEvent
475)
0e320a79 476{
a756f210 477 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
0e320a79
DW
478 Refresh();
479
7e99520b 480#if wxUSE_STATUSBAR
a885d89a 481 if (m_frameStatusBar)
0e320a79 482 {
a885d89a
DW
483 wxSysColourChangedEvent vEvent2;
484
485 vEvent2.SetEventObject(m_frameStatusBar);
486 m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2);
0e320a79 487 }
7e99520b 488#endif //wxUSE_STATUSBAR
0e320a79 489
a885d89a 490 //
0e320a79 491 // Propagate the event to the non-top-level children
a885d89a
DW
492 //
493 wxWindow::OnSysColourChanged(rEvent);
0d53fc34 494} // end of wxFrame::OnSysColourChanged
21802234 495
542875a8 496// Pass TRUE to show full screen, FALSE to restore.
0d53fc34 497bool wxFrame::ShowFullScreen(
542875a8
DW
498 bool bShow
499, long lStyle
500)
501{
64e0c5c6 502 if (bShow)
542875a8
DW
503 {
504 if (IsFullScreen())
505 return FALSE;
506
64e0c5c6
DW
507 m_bFsIsShowing = TRUE;
508 m_lFsStyle = lStyle;
542875a8 509
7e99520b 510#if wxUSE_TOOLBAR
19193a2c 511 wxToolBar* pTheToolBar = GetToolBar();
7e99520b
DW
512#endif //wxUSE_TOOLBAR
513
514#if wxUSE_STATUSBAR
19193a2c 515 wxStatusBar* pTheStatusBar = GetStatusBar();
7e99520b 516#endif //wxUSE_STATUSBAR
542875a8 517
64e0c5c6 518 int nDummyWidth;
542875a8 519
7e99520b 520#if wxUSE_TOOLBAR
64e0c5c6
DW
521 if (pTheToolBar)
522 pTheToolBar->GetSize(&nDummyWidth, &m_nFsToolBarHeight);
7e99520b
DW
523#endif //wxUSE_TOOLBAR
524
525#if wxUSE_STATUSBAR
64e0c5c6
DW
526 if (pTheStatusBar)
527 pTheStatusBar->GetSize(&nDummyWidth, &m_nFsStatusBarHeight);
7e99520b 528#endif //wxUSE_STATUSBAR
542875a8 529
7e99520b 530#if wxUSE_TOOLBAR
64e0c5c6
DW
531 //
532 // Zap the toolbar, menubar, and statusbar
533 //
534 if ((lStyle & wxFULLSCREEN_NOTOOLBAR) && pTheToolBar)
542875a8 535 {
64e0c5c6
DW
536 pTheToolBar->SetSize(-1,0);
537 pTheToolBar->Show(FALSE);
542875a8 538 }
7e99520b 539#endif //wxUSE_TOOLBAR
542875a8 540
64e0c5c6
DW
541 if (lStyle & wxFULLSCREEN_NOMENUBAR)
542 {
b7084589
DW
543 ::WinSetParent(m_hMenu, m_hFrame, FALSE);
544 ::WinSetOwner(m_hMenu, m_hFrame);
545 ::WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
64e0c5c6 546 }
542875a8 547
7e99520b 548#if wxUSE_STATUSBAR
64e0c5c6 549 //
542875a8 550 // Save the number of fields in the statusbar
64e0c5c6
DW
551 //
552 if ((lStyle & wxFULLSCREEN_NOSTATUSBAR) && pTheStatusBar)
542875a8 553 {
64e0c5c6 554 m_nFsStatusBarFields = pTheStatusBar->GetFieldsCount();
542875a8 555 SetStatusBar((wxStatusBar*) NULL);
64e0c5c6 556 delete pTheStatusBar;
542875a8
DW
557 }
558 else
64e0c5c6 559 m_nFsStatusBarFields = 0;
7e99520b 560#endif //wxUSE_STATUSBAR
542875a8 561
64e0c5c6
DW
562 //
563 // Zap the frame borders
564 //
542875a8 565
64e0c5c6
DW
566 //
567 // Save the 'normal' window style
568 //
b7084589 569 m_lFsOldWindowStyle = ::WinQueryWindowULong(m_hFrame, QWL_STYLE);
542875a8 570
64e0c5c6 571 //
b7084589 572 // Save the old position, width & height, maximize state
64e0c5c6
DW
573 //
574 m_vFsOldSize = GetRect();
575 m_bFsIsMaximized = IsMaximized();
542875a8 576
64e0c5c6 577 //
b7084589 578 // Decide which window style flags to turn off
64e0c5c6
DW
579 //
580 LONG lNewStyle = m_lFsOldWindowStyle;
581 LONG lOffFlags = 0;
542875a8 582
64e0c5c6
DW
583 if (lStyle & wxFULLSCREEN_NOBORDER)
584 lOffFlags |= FCF_BORDER;
585 if (lStyle & wxFULLSCREEN_NOCAPTION)
586 lOffFlags |= (FCF_TASKLIST | FCF_SYSMENU);
542875a8 587
64e0c5c6 588 lNewStyle &= (~lOffFlags);
542875a8 589
64e0c5c6
DW
590 //
591 // Change our window style to be compatible with full-screen mode
592 //
b7084589 593 ::WinSetWindowULong((HWND)m_hFrame, QWL_STYLE, (ULONG)lNewStyle);
542875a8 594
64e0c5c6
DW
595 //
596 // Resize to the size of the desktop
597 int nWidth;
598 int nHeight;
542875a8 599
64e0c5c6 600 RECTL vRect;
542875a8 601
64e0c5c6
DW
602 ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
603 nWidth = vRect.xRight - vRect.xLeft;
604 //
605 // Rmember OS/2 is backwards!
606 //
607 nHeight = vRect.yTop - vRect.yBottom;
542875a8 608
64e0c5c6
DW
609 SetSize( nWidth
610 ,nHeight
611 );
542875a8 612
64e0c5c6
DW
613 //
614 // Now flush the window style cache and actually go full-screen
615 //
616 ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
617 ,HWND_TOP
618 ,0
619 ,0
620 ,nWidth
621 ,nHeight
622 ,SWP_SIZE | SWP_SHOW
623 );
624
625 wxSizeEvent vEvent( wxSize( nWidth
626 ,nHeight
627 )
628 ,GetId()
629 );
542875a8 630
64e0c5c6 631 GetEventHandler()->ProcessEvent(vEvent);
542875a8
DW
632 return TRUE;
633 }
634 else
635 {
636 if (!IsFullScreen())
637 return FALSE;
638
64e0c5c6 639 m_bFsIsShowing = FALSE;
542875a8 640
7e99520b 641#if wxUSE_TOOLBAR
64e0c5c6 642 wxToolBar* pTheToolBar = GetToolBar();
542875a8 643
64e0c5c6
DW
644 //
645 // Restore the toolbar, menubar, and statusbar
646 //
647 if (pTheToolBar && (m_lFsStyle & wxFULLSCREEN_NOTOOLBAR))
542875a8 648 {
64e0c5c6
DW
649 pTheToolBar->SetSize(-1, m_nFsToolBarHeight);
650 pTheToolBar->Show(TRUE);
542875a8 651 }
7e99520b 652#endif //wxUSE_TOOLBAR
542875a8 653
7e99520b 654#if wxUSE_STATUSBAR
64e0c5c6 655 if ((m_lFsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_nFsStatusBarFields > 0))
542875a8 656 {
64e0c5c6 657 CreateStatusBar(m_nFsStatusBarFields);
5b3ed311 658// PositionStatusBar();
542875a8 659 }
7e99520b 660#endif //wxUSE_STATUSBAR
542875a8 661
64e0c5c6
DW
662 if ((m_lFsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
663 {
b7084589
DW
664 ::WinSetParent(m_hMenu, m_hFrame, FALSE);
665 ::WinSetOwner(m_hMenu, m_hFrame);
666 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
64e0c5c6
DW
667 }
668 Maximize(m_bFsIsMaximized);
669
b7084589 670 ::WinSetWindowULong( m_hFrame
64e0c5c6
DW
671 ,QWL_STYLE
672 ,(ULONG)m_lFsOldWindowStyle
673 );
674 ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
675 ,HWND_TOP
676 ,m_vFsOldSize.x
677 ,m_vFsOldSize.y
678 ,m_vFsOldSize.width
679 ,m_vFsOldSize.height
680 ,SWP_SIZE | SWP_SHOW
681 );
542875a8 682 }
47df2b8c 683 return wxFrameBase::ShowFullScreen(bShow, lStyle);
0d53fc34 684} // end of wxFrame::ShowFullScreen
542875a8 685
a885d89a
DW
686//
687// Frame window
688//
f38374d0
DW
689// ----------------------------------------------------------------------------
690// wxFrame size management: we exclude the areas taken by menu/status/toolbars
691// from the client area, so the client area is what's really available for the
692// frame contents
693// ----------------------------------------------------------------------------
0e320a79
DW
694
695// Checks if there is a toolbar, and returns the first free client position
0d53fc34 696wxPoint wxFrame::GetClientAreaOrigin() const
0e320a79 697{
2590f154 698 wxPoint vPoint = wxTopLevelWindow::GetClientAreaOrigin();
a885d89a 699
2590f154
DW
700 //
701 // In OS/2 the toolbar and statusbar are frame extensions so there is no
702 // adjustment. The client is supposedly resized for a toolbar in OS/2
703 // as it is for the status bar.
704 //
a885d89a 705 return vPoint;
0d53fc34 706} // end of wxFrame::GetClientAreaOrigin
0e320a79 707
f38374d0
DW
708// ----------------------------------------------------------------------------
709// tool/status bar stuff
710// ----------------------------------------------------------------------------
711
21802234 712#if wxUSE_TOOLBAR
f38374d0 713
0d53fc34 714wxToolBar* wxFrame::CreateToolBar(
a885d89a
DW
715 long lStyle
716, wxWindowID vId
717, const wxString& rName
718)
0e320a79 719{
a885d89a
DW
720 if (wxFrameBase::CreateToolBar( lStyle
721 ,vId
722 ,rName
723 ))
0e320a79 724 {
0e320a79 725 PositionToolBar();
0e320a79 726 }
f38374d0 727 return m_frameToolBar;
0d53fc34 728} // end of wxFrame::CreateToolBar
0e320a79 729
0d53fc34 730void wxFrame::PositionToolBar()
0e320a79 731{
d697657f
DW
732 wxToolBar* pToolBar = GetToolBar();
733 wxCoord vWidth;
734 wxCoord vHeight;
735 wxCoord vTWidth;
736 wxCoord vTHeight;
737
738 if (!pToolBar)
739 return;
740
a885d89a
DW
741 HWND hWndClient;
742 RECTL vRect;
d697657f
DW
743 RECTL vFRect;
744 SWP vSwp;
745 wxPoint vPos;
a885d89a 746
d697657f
DW
747 ::WinQueryWindowRect(m_hFrame, &vRect);
748 vPos.y = (wxCoord)vRect.yTop;
749 ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2);
750 vFRect = vRect;
751 ::WinCalcFrameRect(m_hFrame, &vRect, TRUE);
0e320a79 752
d697657f
DW
753 vPos.y = (wxCoord)(vFRect.yTop - vRect.yTop);
754 pToolBar->GetSize( &vTWidth
755 ,&vTHeight
756 );
a885d89a 757
d697657f
DW
758 if (pToolBar->GetWindowStyleFlag() & wxTB_HORIZONTAL)
759 {
760 vWidth = (wxCoord)(vRect.xRight - vRect.xLeft);
761 pToolBar->SetSize( vRect.xLeft - vFRect.xLeft
762 ,vPos.y
763 ,vWidth
764 ,vTHeight
765 );
0e320a79 766 }
d697657f 767 else
0e320a79 768 {
d697657f
DW
769 wxCoord vSwidth = 0;
770 wxCoord vSheight = 0;
0e320a79 771
d697657f
DW
772 if (m_frameStatusBar)
773 m_frameStatusBar->GetSize( &vSwidth
774 ,&vSheight
775 );
776 vHeight = (wxCoord)(vRect.yTop - vRect.yBottom);
777 pToolBar->SetSize( vRect.xLeft - vFRect.xLeft
778 ,vPos.y
779 ,vTWidth
780 ,vHeight - vSheight
781 );
21802234 782 }
d697657f
DW
783 if( ::WinIsWindowShowing(m_hFrame) )
784 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
0d53fc34 785} // end of wxFrame::PositionToolBar
21802234
DW
786#endif // wxUSE_TOOLBAR
787
f38374d0
DW
788// ----------------------------------------------------------------------------
789// frame state (iconized/maximized/...)
790// ----------------------------------------------------------------------------
791
a885d89a 792//
21802234
DW
793// propagate our state change to all child frames: this allows us to emulate X
794// Windows behaviour where child frames float independently of the parent one
795// on the desktop, but are iconized/restored with it
a885d89a 796//
0d53fc34 797void wxFrame::IconizeChildFrames(
a885d89a
DW
798 bool bIconize
799)
21802234 800{
a885d89a
DW
801 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
802 pNode;
803 pNode = pNode->GetNext() )
21802234 804 {
a885d89a 805 wxWindow* pWin = pNode->GetData();
0cf6acbf 806 wxFrame* pFrame = wxDynamicCast(pWin, wxFrame);
21802234 807
0cf6acbf
DW
808 if ( pFrame
809#if wxUSE_MDI_ARCHITECTURE
810 && !wxDynamicCast(pFrame, wxMDIChildFrame)
811#endif // wxUSE_MDI_ARCHITECTURE
812 )
21802234 813 {
0cf6acbf
DW
814 //
815 // We don't want to restore the child frames which had been
816 // iconized even before we were iconized, so save the child frame
817 // status when iconizing the parent frame and check it when
818 // restoring it.
819 //
820 if (bIconize)
821 {
822 pFrame->m_bWasMinimized = pFrame->IsIconized();
823 }
824
825 //
826 // This test works for both iconizing and restoring
827 //
828 if (!pFrame->m_bWasMinimized)
829 pFrame->Iconize(bIconize);
0e320a79
DW
830 }
831 }
0d53fc34 832} // end of wxFrame::IconizeChildFrames
0e320a79 833
5d44b24e
DW
834WXHICON wxFrame::GetDefaultIcon() const
835{
836 return (WXHICON)(wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON
837 : wxDEFAULT_FRAME_ICON);
838}
21802234
DW
839// ===========================================================================
840// message processing
841// ===========================================================================
842
843// ---------------------------------------------------------------------------
844// preprocessing
845// ---------------------------------------------------------------------------
0d53fc34 846bool wxFrame::OS2TranslateMessage(
a885d89a
DW
847 WXMSG* pMsg
848)
21802234 849{
a885d89a 850 //
21802234 851 // try the menu bar accels
a885d89a
DW
852 //
853 wxMenuBar* pMenuBar = GetMenuBar();
854
19193a2c 855 if (!pMenuBar)
21802234
DW
856 return FALSE;
857
19193a2c 858#if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
a885d89a 859 const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
e604d44b 860 return rAcceleratorTable.Translate(GetHWND(), pMsg);
7e99520b
DW
861#else
862 return FALSE;
863#endif //wxUSE_ACCEL
0d53fc34 864} // end of wxFrame::OS2TranslateMessage
21802234
DW
865
866// ---------------------------------------------------------------------------
867// our private (non virtual) message handlers
868// ---------------------------------------------------------------------------
0d53fc34 869bool wxFrame::HandlePaint()
21802234 870{
a885d89a
DW
871 RECTL vRect;
872
e604d44b 873 if (::WinQueryUpdateRect(GetHWND(), &vRect))
29435d81 874 {
a885d89a 875 if (m_bIconized)
29435d81 876 {
a885d89a
DW
877 //
878 // Icons in PM are the same as "pointers"
879 //
3437f881 880 const wxIcon& vIcon = GetIcon();
a885d89a 881 HPOINTER hIcon;
29435d81 882
3437f881 883 if (vIcon.Ok())
b7084589 884 hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
a885d89a
DW
885 else
886 hIcon = (HPOINTER)m_hDefaultIcon;
887
888 //
21802234
DW
889 // Hold a pointer to the dc so long as the OnPaint() message
890 // is being processed
a885d89a
DW
891 //
892 RECTL vRect2;
64e0c5c6 893 HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2);
29435d81 894
a885d89a 895 //
29435d81 896 // Erase background before painting or we get white background
a885d89a
DW
897 //
898 OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2);
29435d81 899
a885d89a 900 if (hIcon)
29435d81 901 {
a885d89a
DW
902 HWND hWndClient;
903 RECTL vRect3;
21802234 904
40bd6154 905 ::WinQueryWindowRect(GetHwnd(), &vRect3);
29435d81 906
a885d89a
DW
907 static const int nIconWidth = 32;
908 static const int nIconHeight = 32;
909 int nIconX = (int)((vRect3.xRight - nIconWidth)/2);
910 int nIconY = (int)((vRect3.yBottom + nIconHeight)/2);
29435d81 911
a885d89a 912 ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL);
29435d81 913 }
a885d89a 914 ::WinEndPaint(hPs);
29435d81
DW
915 return TRUE;
916 }
917 else
918 {
8330166c
DW
919 if (!wxWindow::HandlePaint())
920 {
921 HPS hPS;
922 RECTL vRect;
923
924 hPS = ::WinBeginPaint( GetHwnd()
925 ,NULLHANDLE
926 ,&vRect
927 );
928 if(hPS)
929 {
930 ::GpiCreateLogColorTable( hPS
931 ,0L
932 ,LCOLF_CONSECRGB
933 ,0L
934 ,(LONG)wxTheColourDatabase->m_nSize
935 ,(PLONG)wxTheColourDatabase->m_palTable
936 );
937 ::GpiCreateLogColorTable( hPS
938 ,0L
939 ,LCOLF_RGB
940 ,0L
941 ,0L
942 ,NULL
943 );
944
945 ::WinFillRect( hPS
946 ,&vRect
947 ,GetBackgroundColour().GetPixel()
948 );
949 ::WinEndPaint(hPS);
950 }
951 }
952 return TRUE;
29435d81
DW
953 }
954 }
955 else
956 {
957 // nothing to paint - processed
958 return TRUE;
959 }
29435d81 960 return FALSE;
0d53fc34 961} // end of wxFrame::HandlePaint
21802234 962
0d53fc34 963bool wxFrame::HandleSize(
a885d89a
DW
964 int nX
965, int nY
966, WXUINT nId
967)
21802234 968{
a885d89a 969 bool bProcessed = FALSE;
21802234 970
a885d89a 971 switch (nId)
21802234 972 {
a885d89a
DW
973 case kSizeNormal:
974 //
975 // Only do it it if we were iconized before, otherwise resizing the
21802234
DW
976 // parent frame has a curious side effect of bringing it under it's
977 // children
a885d89a 978 if (!m_bIconized )
21802234
DW
979 break;
980
a885d89a 981 //
21802234 982 // restore all child frames too
a885d89a 983 //
21802234 984 IconizeChildFrames(FALSE);
3febf684 985 (void)SendIconizeEvent(FALSE);
21802234 986
a885d89a 987 //
21802234 988 // fall through
a885d89a 989 //
21802234 990
a885d89a
DW
991 case kSizeMax:
992 m_bIconized = FALSE;
21802234
DW
993 break;
994
a885d89a
DW
995 case kSizeMin:
996 //
997 // Iconize all child frames too
998 //
21802234 999 IconizeChildFrames(TRUE);
3febf684 1000 (void)SendIconizeEvent();
a885d89a 1001 m_bIconized = TRUE;
21802234
DW
1002 break;
1003 }
f38374d0 1004
a885d89a 1005 if (!m_bIconized)
21802234 1006 {
a885d89a 1007 //
29435d81 1008 // forward WM_SIZE to status bar control
a885d89a 1009 //
f38374d0
DW
1010#if wxUSE_NATIVE_STATUSBAR
1011 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
1012 {
a885d89a
DW
1013 wxSizeEvent vEvent( wxSize( nX
1014 ,nY
1015 )
1016 ,m_frameStatusBar->GetId()
1017 );
f38374d0 1018
a885d89a
DW
1019 vEvent.SetEventObject(m_frameStatusBar);
1020 m_frameStatusBar->OnSize(vEvent);
f38374d0
DW
1021 }
1022#endif // wxUSE_NATIVE_STATUSBAR
1023
51c1d535 1024 PositionStatusBar();
7e99520b 1025#if wxUSE_TOOLBAR
21802234 1026 PositionToolBar();
7e99520b
DW
1027#endif // wxUSE_TOOLBAR
1028
598d8cac
DW
1029 bProcessed = wxWindow::HandleSize( nX
1030 ,nY
1031 ,nId
1032 );
21802234 1033 }
a885d89a 1034 return bProcessed;
0d53fc34 1035} // end of wxFrame::HandleSize
21802234 1036
0d53fc34 1037bool wxFrame::HandleCommand(
a885d89a
DW
1038 WXWORD nId
1039, WXWORD nCmd
1040, WXHWND hControl
1041)
21802234 1042{
a885d89a 1043 if (hControl)
21802234 1044 {
a885d89a 1045 //
21802234 1046 // In case it's e.g. a toolbar.
a885d89a
DW
1047 //
1048 wxWindow* pWin = wxFindWinFromHandle(hControl);
1049
1050 if (pWin)
1051 return pWin->OS2Command( nCmd
1052 ,nId
1053 );
21802234
DW
1054 }
1055
a885d89a
DW
1056 //
1057 // Handle here commands from menus and accelerators
1058 //
5b3ed311 1059 if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR)
21802234 1060 {
19193a2c 1061#if wxUSE_MENUS_NATIVE
a885d89a 1062 if (wxCurrentPopupMenu)
21802234 1063 {
a885d89a
DW
1064 wxMenu* pPopupMenu = wxCurrentPopupMenu;
1065
21802234
DW
1066 wxCurrentPopupMenu = NULL;
1067
a885d89a
DW
1068 return pPopupMenu->OS2Command( nCmd
1069 ,nId
1070 );
19193a2c 1071 return TRUE;
21802234 1072 }
19193a2c 1073#endif
21802234 1074
a885d89a 1075 if (ProcessCommand(nId))
21802234
DW
1076 {
1077 return TRUE;
1078 }
1079 }
21802234 1080 return FALSE;
0d53fc34 1081} // end of wxFrame::HandleCommand
21802234 1082
0d53fc34 1083bool wxFrame::HandleMenuSelect(
a885d89a
DW
1084 WXWORD nItem
1085, WXWORD nFlags
1086, WXHMENU hMenu
1087)
21802234 1088{
e604d44b
DW
1089 if( !nFlags )
1090 {
1091 MENUITEM mItem;
1092 MRESULT rc;
1093
51c1d535 1094 rc = ::WinSendMsg(hMenu, MM_QUERYITEM, MPFROM2SHORT(nItem, TRUE), (MPARAM)&mItem);
e604d44b
DW
1095
1096 if(rc && !(mItem.afStyle & (MIS_SUBMENU | MIS_SEPARATOR)))
1097 {
1098 wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nItem);
1099
1100 vEvent.SetEventObject(this);
1101 GetEventHandler()->ProcessEvent(vEvent); // return value would be ignored by PM
1102 }
16ff355b
DW
1103 else
1104 {
1105 DoGiveHelp(wxEmptyString, FALSE);
1106 return FALSE;
1107 }
e604d44b
DW
1108 }
1109 return TRUE;
0d53fc34 1110} // end of wxFrame::HandleMenuSelect
21802234
DW
1111
1112// ---------------------------------------------------------------------------
51c1d535 1113// Main Frame window proc
21802234 1114// ---------------------------------------------------------------------------
51c1d535
DW
1115MRESULT EXPENTRY wxFrameMainWndProc(
1116 HWND hWnd
1117, ULONG ulMsg
1118, MPARAM wParam
1119, MPARAM lParam
1120)
1121{
1122 MRESULT rc = (MRESULT)0;
1123 bool bProcessed = FALSE;
1124 wxFrame* pWnd = NULL;
1125
1126 pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);
1127 switch (ulMsg)
1128 {
1129 case WM_QUERYFRAMECTLCOUNT:
1130 if(pWnd && pWnd->m_fnOldWndProc)
1131 {
1132 USHORT uItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));
1133
1134 rc = MRFROMSHORT(uItemCount);
1135 }
1136 break;
1137
1138 case WM_FORMATFRAME:
1139/////////////////////////////////////////////////////////////////////////////////
1140// Applications that subclass frame controls may find that the frame is already
1141// subclassed the number of frame controls is variable.
1142// The WM_FORMATFRAME and WM_QUERYFRAMECTLCOUNT messages must always be
1143// subclassed by calling the previous window procedure and modifying its result.
1144////////////////////////////////////////////////////////////////////////////////
1145 {
1146 int nItemCount;
1147 int i;
1148 PSWP pSWP = NULL;
51c1d535
DW
1149 RECTL vRectl;
1150 RECTL vRstb;
d697657f
DW
1151 RECTL vRtlb;
1152 int nHeight = 0;
1153 int nHeight2 = 0;
1154 int nWidth = 0;
51c1d535
DW
1155
1156 pSWP = (PSWP)PVOIDFROMMP(wParam);
1157 nItemCount = SHORT1FROMMR(pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam));
1158 if(pWnd->m_frameStatusBar)
1159 {
1160 ::WinQueryWindowRect(pWnd->m_frameStatusBar->GetHWND(), &vRstb);
1161 pWnd->m_frameStatusBar->GetSize(NULL, &nHeight);
d697657f
DW
1162 }
1163 if(pWnd->m_frameToolBar)
1164 {
1165 ::WinQueryWindowRect(pWnd->m_frameToolBar->GetHWND(), &vRtlb);
1166 pWnd->m_frameToolBar->GetSize(&nWidth, &nHeight2);
51c1d535
DW
1167 }
1168 ::WinQueryWindowRect(pWnd->m_hFrame, &vRectl);
1169 ::WinMapWindowPoints(pWnd->m_hFrame, HWND_DESKTOP, (PPOINTL)&vRectl, 2);
1170 ::WinCalcFrameRect(pWnd->m_hFrame, &vRectl, TRUE);
1171 ::WinMapWindowPoints(HWND_DESKTOP, pWnd->m_hFrame, (PPOINTL)&vRectl, 2);
1172 for(i = 0; i < nItemCount; i++)
1173 {
1174 if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd)
1175 {
d697657f
DW
1176 if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_HORIZONTAL)
1177 {
1178 pSWP[i].x = vRectl.xLeft;
1179 pSWP[i].y = vRectl.yBottom + nHeight;
1180 pSWP[i].cx = vRectl.xRight - vRectl.xLeft;
1181 pSWP[i].cy = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
1182 }
1183 else
1184 {
97d74dd2 1185 pSWP[i].x = vRectl.xLeft + nWidth;
d697657f
DW
1186 pSWP[i].y = vRectl.yBottom + nHeight;
1187 pSWP[i].cx = vRectl.xRight - (vRectl.xLeft + nWidth);
1188 pSWP[i].cy = vRectl.yTop - vRectl.yBottom - nHeight;
1189 }
51c1d535
DW
1190 pSWP[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
1191 pSWP[i].hwndInsertBehind = HWND_TOP;
1192 }
1193 }
1194 bProcessed = TRUE;
1195 rc = MRFROMSHORT(nItemCount);
1196 }
1197 break;
1198
1199 default:
1200 if(pWnd && pWnd->m_fnOldWndProc)
1201 rc = pWnd->m_fnOldWndProc(hWnd, ulMsg, wParam, lParam);
1202 else
1203 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
1204 }
1205 return rc;
1206} // end of wxFrameMainWndProc
1207
1208MRESULT EXPENTRY wxFrameWndProc(
1209 HWND hWnd
1210, ULONG ulMsg
1211, MPARAM wParam
1212, MPARAM lParam
1213)
1214{
1215 //
1216 // Trace all ulMsgs - useful for the debugging
1217 //
1218 HWND parentHwnd;
1219 wxFrame* pWnd = NULL;
1220
1221 parentHwnd = WinQueryWindow(hWnd,QW_PARENT);
1222 pWnd = (wxFrame*) wxFindWinFromHandle((WXHWND) hWnd);
1223
1224 //
1225 // When we get the first message for the HWND we just created, we associate
1226 // it with wxWindow stored in wxWndHook
1227 //
51c1d535
DW
1228
1229 MRESULT rc = (MRESULT)0;
1230 bool bProcessed = FALSE;
1231
1232 //
1233 // Stop right here if we don't have a valid handle in our wxWindow object.
1234 //
1235 if (pWnd && !pWnd->GetHWND())
1236 {
1237 pWnd->SetHWND((WXHWND) hWnd);
1238 rc = pWnd->OS2DefWindowProc(ulMsg, wParam, lParam );
1239 pWnd->SetHWND(0);
1240 }
1241 else
1242 {
d08f23a7
DW
1243 if (pWnd)
1244 rc = pWnd->OS2WindowProc(ulMsg, wParam, lParam);
1245 else
1246 rc = ::WinDefWindowProc(hWnd, ulMsg, wParam, lParam);
51c1d535
DW
1247 }
1248 return rc;
1249} // end of wxFrameWndProc
21802234 1250
0d53fc34 1251MRESULT wxFrame::OS2WindowProc(
a885d89a
DW
1252 WXUINT uMessage
1253, WXWPARAM wParam
1254, WXLPARAM lParam
1255)
21802234 1256{
a885d89a
DW
1257 MRESULT mRc = 0L;
1258 bool bProcessed = FALSE;
21802234 1259
a885d89a 1260 switch (uMessage)
21802234
DW
1261 {
1262 case WM_CLOSE:
a885d89a
DW
1263 //
1264 // If we can't close, tell the system that we processed the
21802234 1265 // message - otherwise it would close us
a885d89a
DW
1266 //
1267 bProcessed = !Close();
21802234
DW
1268 break;
1269
d08f23a7 1270 case WM_PAINT:
8d854fa9
DW
1271 bProcessed = HandlePaint();
1272 mRc = (MRESULT)FALSE;
1273 break;
d08f23a7 1274
8d854fa9
DW
1275 case WM_ERASEBACKGROUND:
1276 //
1277 // Returning TRUE to requests PM to paint the window background
1278 // in SYSCLR_WINDOW. We capture this here because the PS returned
1279 // in Frames is the PS for the whole frame, which we can't really
1280 // use at all. If you want to paint a different background, do it
1281 // in an OnPaint using a wxPaintDC.
1282 //
1283 mRc = (MRESULT)(TRUE);
d08f23a7
DW
1284 break;
1285
8d854fa9 1286 case WM_COMMAND:
21802234 1287 {
a885d89a
DW
1288 WORD wId;
1289 WORD wCmd;
1290 WXHWND hWnd;
1291
1292 UnpackCommand( (WXWPARAM)wParam
d08f23a7
DW
1293 ,(WXLPARAM)lParam
1294 ,&wId
1295 ,&hWnd
1296 ,&wCmd
1297 );
5b3ed311 1298
a885d89a
DW
1299 bProcessed = HandleCommand( wId
1300 ,wCmd
1301 ,(WXHWND)hWnd
1302 );
21802234
DW
1303 }
1304 break;
1305
1306 case WM_MENUSELECT:
1307 {
a885d89a
DW
1308 WXWORD wItem;
1309 WXWORD wFlags;
1310 WXHMENU hMenu;
1311
1312 UnpackMenuSelect( wParam
1313 ,lParam
1314 ,&wItem
1315 ,&wFlags
1316 ,&hMenu
1317 );
1318 bProcessed = HandleMenuSelect( wItem
1319 ,wFlags
1320 ,hMenu
1321 );
e604d44b 1322 mRc = (MRESULT)TRUE;
21802234
DW
1323 }
1324 break;
1325
d08f23a7
DW
1326 case WM_SIZE:
1327 {
1328 SHORT nScxold = SHORT1FROMMP(wParam); // Old horizontal size.
1329 SHORT nScyold = SHORT2FROMMP(wParam); // Old vertical size.
1330 SHORT nScxnew = SHORT1FROMMP(lParam); // New horizontal size.
1331 SHORT nScynew = SHORT2FROMMP(lParam); // New vertical size.
1332
1333 lParam = MRFROM2SHORT( nScxnew - 20
1334 ,nScynew - 30
1335 );
1336 }
1337 bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
1338 mRc = (MRESULT)FALSE;
21802234
DW
1339 break;
1340
a885d89a 1341 case CM_QUERYDRAGIMAGE:
21802234 1342 {
3437f881 1343 const wxIcon& vIcon = GetIcon();
a885d89a
DW
1344 HPOINTER hIcon;
1345
3437f881 1346 if (vIcon.Ok())
e604d44b 1347 hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L);
a885d89a
DW
1348 else
1349 hIcon = (HPOINTER)m_hDefaultIcon;
1350 mRc = (MRESULT)hIcon;
1351 bProcessed = mRc != 0;
21802234
DW
1352 }
1353 break;
21802234 1354 }
f38374d0 1355
a885d89a
DW
1356 if (!bProcessed )
1357 mRc = wxWindow::OS2WindowProc( uMessage
1358 ,wParam
1359 ,lParam
1360 );
e604d44b 1361 return (MRESULT)mRc;
0d53fc34 1362} // wxFrame::OS2WindowProc
21802234 1363
0d53fc34 1364void wxFrame::SetClient(WXHWND c_Hwnd)
5b3ed311 1365{
51c1d535 1366 // Duh...nothing to do under OS/2
5b3ed311
DW
1367}
1368
0d53fc34 1369void wxFrame::SetClient(
51c1d535
DW
1370 wxWindow* pWindow
1371)
5b3ed311 1372{
51c1d535
DW
1373 wxWindow* pOldClient = this->GetClient();
1374 bool bClientHasFocus = pOldClient && (pOldClient == wxWindow::FindFocus());
5b3ed311 1375
51c1d535 1376 if(pOldClient == pWindow) // nothing to do
5b3ed311 1377 return;
51c1d535
DW
1378 if(pWindow == NULL) // just need to remove old client
1379 {
1380 if(pOldClient == NULL) // nothing to do
1381 return;
5b3ed311 1382
51c1d535 1383 if(bClientHasFocus )
5b3ed311
DW
1384 this->SetFocus();
1385
51c1d535
DW
1386 pOldClient->Enable( FALSE );
1387 pOldClient->Show( FALSE );
1388 ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId());
5b3ed311 1389 // to avoid OS/2 bug need to update frame
b7084589 1390 ::WinSendMsg((HWND)this->GetFrame(), WM_UPDATEFRAME, (MPARAM)~0, 0);
5b3ed311 1391 return;
51c1d535 1392 }
5b3ed311 1393
51c1d535
DW
1394 //
1395 // Else need to change client
1396 //
1397 if(bClientHasFocus)
5b3ed311
DW
1398 this->SetFocus();
1399
51c1d535
DW
1400 ::WinEnableWindowUpdate((HWND)GetHWND(), FALSE);
1401 if(pOldClient)
1402 {
1403 pOldClient->Enable(FALSE);
1404 pOldClient->Show(FALSE);
1405 ::WinSetWindowUShort(pOldClient->GetHWND(), QWS_ID, (USHORT)pOldClient->GetId());
1406 }
1407 pWindow->Reparent(this);
1408 ::WinSetWindowUShort(pWindow->GetHWND(), QWS_ID, FID_CLIENT);
1409 ::WinEnableWindowUpdate((HWND)GetHWND(), TRUE);
1410 pWindow->Enable();
1411 pWindow->Show(); // ensure client is showing
1412 if( this->IsShown() )
1413 {
1414 this->Show();
b7084589 1415 ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
51c1d535 1416 }
5b3ed311
DW
1417}
1418
0d53fc34 1419wxWindow* wxFrame::GetClient()
5b3ed311 1420{
b7084589 1421 return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
5b3ed311 1422}
cfcebdb1
DW
1423
1424void wxFrame::SendSizeEvent()
1425{
1426 if (!m_bIconized)
1427 {
1428 RECTL vRect = wxGetWindowRect(GetHwnd());
1429
1430 ::WinPostMsg( GetHwnd()
1431 ,WM_SIZE
1432 ,MPFROM2SHORT( vRect.xRight - vRect.xLeft
1433 ,vRect.xRight - vRect.xLeft
1434 )
1435 ,MPFROM2SHORT( vRect.yTop - vRect.yBottom
1436 ,vRect.yTop - vRect.yBottom
1437 )
1438 );
1439 }
1440}
1441