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