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