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