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