]> git.saurik.com Git - wxWidgets.git/blame - src/os2/frame.cpp
fixed crash in OnChar() after m_key_current was deleted
[wxWidgets.git] / src / os2 / frame.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: frame.cpp
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
16 #include "wx/setup.h"
17 #include "wx/frame.h"
18 #include "wx/menu.h"
19 #include "wx/app.h"
20 #include "wx/utils.h"
21 #include "wx/dialog.h"
22 #include "wx/settings.h"
23 #include "wx/dcclient.h"
24#endif // WX_PRECOMP
25
26#include "wx/os2/private.h"
f38374d0
DW
27
28#if wxUSE_STATUSBAR
29 #include "wx/statusbr.h"
ea51d98d 30 #include "wx/generic/statusbr.h"
f38374d0
DW
31#endif // wxUSE_STATUSBAR
32
33#if wxUSE_TOOLBAR
34 #include "wx/toolbar.h"
35#endif // wxUSE_TOOLBAR
36
0e320a79 37#include "wx/menuitem.h"
21802234 38#include "wx/log.h"
0e320a79 39
f38374d0
DW
40// ----------------------------------------------------------------------------
41// globals
42// ----------------------------------------------------------------------------
43
21802234
DW
44extern wxWindowList wxModelessWindows;
45extern wxList WXDLLEXPORT wxPendingDelete;
46extern wxChar wxFrameClassName[];
47extern wxMenu *wxCurrentPopupMenu;
0e320a79 48
f38374d0
DW
49// ----------------------------------------------------------------------------
50// event tables
51// ----------------------------------------------------------------------------
52
f38374d0
DW
53BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
54 EVT_ACTIVATE(wxFrame::OnActivate)
55 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
0e320a79
DW
56END_EVENT_TABLE()
57
58IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
0e320a79 59
f38374d0
DW
60// ============================================================================
61// implementation
62// ============================================================================
0e320a79 63
f38374d0
DW
64// ----------------------------------------------------------------------------
65// static class members
66// ----------------------------------------------------------------------------
0e320a79 67
f38374d0 68#if wxUSE_NATIVE_STATUSBAR
a885d89a 69 bool wxFrame::m_bUseNativeStatusBar = TRUE;
f38374d0 70#else
a885d89a 71 bool wxFrame::m_bUseNativeStatusBar = FALSE;
f38374d0 72#endif
0e320a79 73
f38374d0
DW
74// ----------------------------------------------------------------------------
75// creation/destruction
76// ----------------------------------------------------------------------------
77
78void wxFrame::Init()
0e320a79 79{
80d83cbc 80 m_bIconized = FALSE;
f38374d0 81
21802234 82#if wxUSE_TOOLTIPS
a885d89a 83 m_hWndToolTip = 0;
21802234 84#endif
ea51d98d
DW
85 // Data to save/restore when calling ShowFullScreen
86 m_lFsStyle = 0L;
87 m_lFsOldWindowStyle = 0L;
88 m_nFsStatusBarFields = 0;
89 m_nFsStatusBarHeight = 0;
90 m_nFsToolBarHeight = 0;
91 m_bFsIsMaximized = FALSE;
92 m_bFsIsShowing = FALSE;
93} // end of wxFrame::Init
94
95bool wxFrame::Create(
96 wxWindow* pParent
97, wxWindowID vId
98, const wxString& rsTitle
99, const wxPoint& rPos
100, const wxSize& rSize
a885d89a 101, long lulStyle
ea51d98d
DW
102, const wxString& rsName
103)
f38374d0 104{
ea51d98d
DW
105 int nX = rPos.x;
106 int nY = rPos.y;
107 int nWidth = rSize.x;
108 int nHeight = rSize.y;
ea51d98d
DW
109
110 SetName(rsName);
a885d89a 111 m_windowStyle = lulStyle;
ea51d98d
DW
112 m_frameMenuBar = NULL;
113 m_frameToolBar = NULL;
114 m_frameStatusBar = NULL;
115
116 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
117
118 if (vId > -1 )
119 m_windowId = vId;
120 else
121 m_windowId = (int)NewControlId();
122
80d83cbc 123 if (pParent)
ea51d98d
DW
124 pParent->AddChild(this);
125
126 m_bIconized = FALSE;
127
ea51d98d
DW
128 if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0)
129 pParent = NULL;
130
131 if (!pParent)
132 wxTopLevelWindows.Append(this);
133
134 OS2Create( m_windowId
135 ,pParent
136 ,wxFrameClassName
137 ,this
138 ,rsTitle
139 ,nX
140 ,nY
141 ,nWidth
142 ,nHeight
a885d89a 143 ,lulStyle
ea51d98d
DW
144 );
145
146 wxModelessWindows.Append(this);
147 return TRUE;
148} // end of wxFrame::Create
0e320a79
DW
149
150wxFrame::~wxFrame()
151{
ea51d98d
DW
152 m_isBeingDeleted = TRUE;
153 wxTopLevelWindows.DeleteObject(this);
0e320a79 154
ea51d98d 155 DeleteAllBars();
29435d81 156
ea51d98d
DW
157 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
158 {
159 wxTheApp->SetTopWindow(NULL);
0e320a79 160
ea51d98d
DW
161 if (wxTheApp->GetExitOnFrameDelete())
162 {
80d83cbc 163 ::WinPostMsg(GetHwnd(), WM_QUIT, 0, 0);
ea51d98d
DW
164 }
165 }
166 wxModelessWindows.DeleteObject(this);
167
168 //
169 // For some reason, wxWindows can activate another task altogether
170 // when a frame is destroyed after a modal dialog has been invoked.
171 // Try to bring the parent to the top.
172 //
173 // MT:Only do this if this frame is currently the active window, else weird
174 // things start to happen.
175 //
176 if (wxGetActiveWindow() == this)
0e320a79 177 {
ea51d98d
DW
178 if (GetParent() && GetParent()->GetHWND())
179 {
ea51d98d
DW
180 ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
181 ,HWND_TOP
80d83cbc
DW
182 ,0
183 ,0
184 ,0
185 ,0
186 ,SWP_ZORDER
ea51d98d
DW
187 );
188 }
0e320a79 189 }
ea51d98d 190} // end of wxFrame::~wxFrame
0e320a79 191
ea51d98d 192//
0e320a79 193// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
ea51d98d 194//
80d83cbc
DW
195void wxFrame::DoGetClientSize(
196 int* pX
197, int* pY
198) const
0e320a79 199{
80d83cbc 200 //
a885d89a 201 // OS/2 PM's coordinates go from bottom-left not
80d83cbc
DW
202 // top-left thus the += instead of the -=
203 //
204 RECTL vRect;
205 HWND hWndClient;
206
207 //
208 // PM has no GetClientRect that inherantly knows about the client window
209 // We have to explicitly go fetch it!
210 //
a885d89a 211 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
80d83cbc 212 ::WinQueryWindowRect(hWndClient, &vRect);
21802234 213
f38374d0 214#if wxUSE_STATUSBAR
80d83cbc
DW
215 if ( GetStatusBar() )
216 {
a885d89a 217 int nStatusX;
80d83cbc
DW
218 int nStatusY;
219
220 GetStatusBar()->GetClientSize( &nStatusX
221 ,&nStatusY
222 );
223 vRect.yBottom += nStatusY;
224 }
f38374d0 225#endif // wxUSE_STATUSBAR
21802234 226
80d83cbc 227 wxPoint vPoint(GetClientAreaOrigin());
a885d89a
DW
228
229 vRect.yBottom += vPoint.y;
230 vRect.xRight -= vPoint.x;
21802234 231
80d83cbc
DW
232 if (pX)
233 *pX = vRect.xRight;
234 if (pY)
235 *pY = vRect.yBottom;
236} // end of wxFrame::DoGetClientSize
0e320a79 237
a885d89a 238//
0e320a79
DW
239// Set the client size (i.e. leave the calculation of borders etc.
240// to wxWindows)
80d83cbc
DW
241//
242void wxFrame::DoSetClientSize(
243 int nWidth
244, int nHeight
245)
0e320a79 246{
80d83cbc
DW
247 HWND hWnd = GetHwnd();
248 HWND hWndClient;
249 RECTL vRect;
a7ef993c 250 RECTL vRect2;
0e320a79 251
a885d89a 252 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
80d83cbc 253 ::WinQueryWindowRect(hWndClient, &vRect);
21802234 254
80d83cbc 255 ::WinQueryWindowRect(hWnd, &vRect2);
21802234 256
80d83cbc
DW
257 //
258 // Find the difference between the entire window (title bar and all)
259 // and the client area; add this to the new client size to move the
260 // window. Remember OS/2's backwards y coord system!
261 //
262 int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
263 int nActualHeight = vRect2.yTop + vRect2.yTop - vRect.yTop + nHeight;
29435d81 264
f38374d0 265#if wxUSE_STATUSBAR
80d83cbc
DW
266 if ( GetStatusBar() )
267 {
268 int nStatusX;
269 int nStatusY;
270
271 GetStatusBar()->GetClientSize( &nStatusX
272 ,&nStatusY
273 );
274 nActualHeight += nStatusY;
275 }
f38374d0 276#endif // wxUSE_STATUSBAR
29435d81 277
80d83cbc
DW
278 wxPoint vPoint(GetClientAreaOrigin());
279 nActualWidth += vPoint.y;
280 nActualHeight += vPoint.x;
281
282 POINTL vPointl;
283
284 vPointl.x = vRect2.xLeft;
285 vPoint.y = vRect2.yTop;
286
287 ::WinSetWindowPos( hWnd
288 ,HWND_TOP
289 ,vPointl.x
290 ,vPointl.y
291 ,nActualWidth
292 ,nActualHeight
293 ,SWP_MOVE | SWP_SIZE | SWP_SHOW
294 );
295
296 wxSizeEvent vEvent( wxSize( nWidth
297 ,nHeight
298 )
299 ,m_windowId
300 );
301 vEvent.SetEventObject(this);
302 GetEventHandler()->ProcessEvent(vEvent);
303} // end of wxFrame::DoSetClientSize
304
305void wxFrame::DoGetSize(
306 int* pWidth
307, int* pHeight
308) const
309{
310 RECTL vRect;
21802234 311
80d83cbc
DW
312 ::WinQueryWindowRect(GetHwnd(), &vRect);
313 *pWidth = vRect.xRight - vRect.xLeft;
314 *pHeight = vRect.yTop - vRect.yBottom;
315} // end of wxFrame::DoGetSize
21802234 316
80d83cbc
DW
317void wxFrame::DoGetPosition(
318 int* pX
319, int* pY
320) const
321{
322 RECTL vRect;
a885d89a 323 POINTL vPoint;
29435d81 324
80d83cbc
DW
325 ::WinQueryWindowRect(GetHwnd(), &vRect);
326 vPoint.x = vRect.xLeft;
0e320a79 327
80d83cbc
DW
328 //
329 // OS/2 is backwards [WIN32 it is vRect.yTop]
330 //
331 vPoint.y = vRect.yBottom;
0e320a79 332
80d83cbc
DW
333 *pX = vPoint.x;
334 *pY = vPoint.y;
335} // end of wxFrame::DoGetPosition
0e320a79 336
f38374d0
DW
337// ----------------------------------------------------------------------------
338// variations around ::ShowWindow()
339// ----------------------------------------------------------------------------
340
80d83cbc 341void wxFrame::DoShowWindow(
426d5745 342 int bShowCmd
80d83cbc 343)
0e320a79 344{
426d5745 345 HWND hClient;
a0606634
DW
346 HWND hTitlebar = NULLHANDLE;
347 HWND hHScroll = NULLHANDLE;
348 HWND hVScroll = NULLHANDLE;
349 HWND hMenuBar = NULLHANDLE;
350 SWP vSwp;
351 SWP vSwpTitlebar;
352 SWP vSwpVScroll;
353 SWP vSwpHScroll;
354 SWP vSwpMenu;
426d5745 355
7bed7a50
DW
356 //
357 // Send anything to initialize the frame
358 //
a0606634
DW
359 WinQueryWindowPos(GetHwnd(), &vSwp);
360 hClient = WinWindowFromID(GetHwnd(), FID_CLIENT);
361 hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
362 WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
363 hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL);
364 WinQueryWindowPos(hHScroll, &vSwpHScroll);
365 hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL);
366 WinQueryWindowPos(hVScroll, &vSwpVScroll);
367 hMenuBar = WinWindowFromID(GetHwnd(), FID_MENU);
368 WinQueryWindowPos(hMenuBar, &vSwpMenu);
369 WinSetWindowPos( hClient
370 ,HWND_TOP
371 ,SV_CXSIZEBORDER
372 ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy
373 ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx)
374 ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpMenu.cy + vSwpHScroll.cy)
375 ,SWP_SIZE | SWP_MOVE
376 );
426d5745
DW
377 ::WinShowWindow(GetHwnd(), (BOOL)bShowCmd);
378 ::WinShowWindow(hClient, (BOOL)bShowCmd);
80d83cbc 379} // end of wxFrame::DoShowWindow
21802234 380
80d83cbc
DW
381bool wxFrame::Show(
382 bool bShow
383)
0e320a79 384{
426d5745
DW
385 SWP vSwp;
386
387 DoShowWindow((int)bShow);
21802234 388
80d83cbc 389 if (bShow)
f38374d0 390 {
80d83cbc
DW
391 wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId);
392
426d5745 393 ::WinQueryWindowPos(GetHwnd(), &vSwp);
d8530167 394 m_bIconized = vSwp.fl & SWP_MINIMIZE;
a0606634 395 ::WinEnableWindow(GetHwnd(), TRUE);
80d83cbc
DW
396 vEvent.SetEventObject(this);
397 GetEventHandler()->ProcessEvent(vEvent);
f38374d0
DW
398 }
399 else
400 {
80d83cbc 401 //
f38374d0 402 // Try to highlight the correct window (the parent)
80d83cbc
DW
403 //
404 if (GetParent())
f38374d0 405 {
80d83cbc
DW
406 HWND hWndParent = GetHwndOf(GetParent());
407
426d5745 408 ::WinQueryWindowPos(hWndParent, &vSwp);
d8530167 409 m_bIconized = vSwp.fl & SWP_MINIMIZE;
f38374d0 410 if (hWndParent)
80d83cbc
DW
411 ::WinSetWindowPos( hWndParent
412 ,HWND_TOP
426d5745
DW
413 ,vSwp.x
414 ,vSwp.y
415 ,vSwp.cx
416 ,vSwp.cy
417 ,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE
80d83cbc 418 );
a0606634 419 ::WinEnableWindow(hWndParent, TRUE);
f38374d0
DW
420 }
421 }
f38374d0 422 return TRUE;
80d83cbc 423} // end of wxFrame::Show
f38374d0 424
80d83cbc
DW
425void wxFrame::Iconize(
426 bool bIconize
427)
f38374d0 428{
80d83cbc
DW
429 DoShowWindow(bIconize ? SWP_MINIMIZE : SWP_RESTORE);
430} // end of wxFrame::Iconize
0e320a79 431
80d83cbc
DW
432void wxFrame::Maximize(
433 bool bMaximize)
0e320a79 434{
80d83cbc
DW
435 DoShowWindow(bMaximize ? SWP_MAXIMIZE : SWP_RESTORE);
436} // end of wxFrame::Maximize
f38374d0
DW
437
438void wxFrame::Restore()
439{
80d83cbc
DW
440 DoShowWindow(SWP_RESTORE);
441} // end of wxFrame::Restore
0e320a79
DW
442
443bool wxFrame::IsIconized() const
444{
80d83cbc
DW
445 SWP vSwp;
446 bool bIconic;
447
a885d89a
DW
448 ::WinQueryWindowPos(GetHwnd(), &vSwp);
449
80d83cbc
DW
450 if (vSwp.fl & SWP_MINIMIZE)
451 ((wxFrame*)this)->m_bIconized = TRUE;
452 else
453 ((wxFrame*)this)->m_bIconized = FALSE;
454 return m_bIconized;
455} // end of wxFrame::IsIconized
0e320a79 456
21802234
DW
457// Is it maximized?
458bool wxFrame::IsMaximized() const
0e320a79 459{
80d83cbc
DW
460 SWP vSwp;
461 bool bIconic;
462
a885d89a 463 ::WinQueryWindowPos(GetHwnd(), &vSwp);
80d83cbc
DW
464 return (vSwp.fl & SWP_MAXIMIZE);
465} // end of wxFrame::IsMaximized
0e320a79 466
0fe536e3
DW
467void wxFrame::SetIcon(
468 const wxIcon& rIcon
469)
0e320a79 470{
0fe536e3 471 wxFrameBase::SetIcon(rIcon);
f38374d0 472
426d5745 473 if ((m_icon.GetHICON()) != NULLHANDLE)
f38374d0 474 {
f23208ca
DW
475 ::WinSendMsg( GetHwnd()
476 ,WM_SETICON
426d5745 477 ,(MPARAM)((HPOINTER)m_icon.GetHICON())
f23208ca
DW
478 ,NULL
479 );
480 ::WinSendMsg( GetHwnd()
481 ,WM_UPDATEFRAME
482 ,(MPARAM)FCF_ICON
483 ,(MPARAM)0
484 );
f38374d0 485 }
0fe536e3 486} // end of wxFrame::SetIcon
0e320a79 487
21802234 488#if wxUSE_STATUSBAR
0fe536e3
DW
489wxStatusBar* wxFrame::OnCreateStatusBar(
490 int nNumber
a885d89a 491, long lulStyle
0fe536e3
DW
492, wxWindowID vId
493, const wxString& rName
494)
0e320a79 495{
0fe536e3 496 wxStatusBar* pStatusBar = NULL;
0e320a79 497
0fe536e3 498 pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber
a885d89a 499 ,lulStyle
0fe536e3
DW
500 ,vId
501 ,rName
502 );
503 return pStatusBar;
504} // end of wxFrame::OnCreateStatusBar
0e320a79
DW
505
506void wxFrame::PositionStatusBar()
507{
0fe536e3
DW
508 //
509 // Native status bar positions itself
510 //
511 if (m_frameStatusBar)
f38374d0 512 {
a885d89a 513 int nWidth;
0fe536e3 514 int nHeight;
a885d89a 515 int nStatbarWidth;
0fe536e3
DW
516 int nStatbarHeight;
517 HWND hWndClient;
518 RECTL vRect;
519
a885d89a 520 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
0fe536e3
DW
521 ::WinQueryWindowRect(hWndClient, &vRect);
522 nWidth = vRect.xRight - vRect.xLeft;
a885d89a
DW
523 nHeight = vRect.yTop - vRect.yBottom;
524
0fe536e3
DW
525 m_frameStatusBar->GetSize( &nStatbarWidth
526 ,&nStatbarHeight
527 );
f38374d0 528
0fe536e3 529 //
f38374d0
DW
530 // Since we wish the status bar to be directly under the client area,
531 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
0fe536e3
DW
532 //
533 m_frameStatusBar->SetSize( 0
534 ,nHeight
535 ,nWidth
536 ,nStatbarHeight
537 );
f38374d0 538 }
0fe536e3 539} // end of wxFrame::PositionStatusBar
21802234 540#endif // wxUSE_STATUSBAR
0e320a79 541
21802234 542void wxFrame::DetachMenuBar()
0e320a79 543{
21802234 544 if (m_frameMenuBar)
0e320a79 545 {
29435d81 546 m_frameMenuBar->Detach();
0e320a79 547 m_frameMenuBar = NULL;
21802234 548 }
0fe536e3 549} // end of wxFrame::DetachMenuBar
21802234 550
0fe536e3 551void wxFrame::SetMenuBar(
a885d89a 552 wxMenuBar* pMenuBar
0fe536e3 553)
21802234 554{
0fe536e3 555 if (!pMenuBar)
21802234
DW
556 {
557 DetachMenuBar();
0e320a79
DW
558 return;
559 }
c3d43472 560
29a99be3 561 m_frameMenuBar = NULL;
0e320a79 562
29a99be3
DW
563 // Can set a menubar several times.
564 // TODO: how to prevent a memory leak if you have a currently-unattached
565 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
566 // there are problems for MDI).
567 if (pMenuBar->GetHMenu())
0fe536e3 568 {
29a99be3 569 m_hMenu = pMenuBar->GetHMenu();
0fe536e3 570 }
29a99be3
DW
571 else
572 {
573 pMenuBar->Detach();
21802234 574
29a99be3
DW
575 m_hMenu = pMenuBar->Create();
576
577 if (!m_hMenu)
578 return;
579 }
21802234
DW
580
581 InternalSetMenuBar();
582
a885d89a
DW
583 m_frameMenuBar = pMenuBar;
584 pMenuBar->Attach(this);
0fe536e3 585} // end of wxFrame::SetMenuBar
0e320a79 586
21802234 587void wxFrame::InternalSetMenuBar()
0e320a79 588{
f23208ca 589 WinSendMsg((HWND)GetHwnd(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
0fe536e3 590} // end of wxFrame::InternalSetMenuBar
0e320a79 591
a885d89a
DW
592//
593// Responds to colour changes, and passes event on to children
594//
595void wxFrame::OnSysColourChanged(
596 wxSysColourChangedEvent& rEvent
597)
0e320a79
DW
598{
599 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
600 Refresh();
601
a885d89a 602 if (m_frameStatusBar)
0e320a79 603 {
a885d89a
DW
604 wxSysColourChangedEvent vEvent2;
605
606 vEvent2.SetEventObject(m_frameStatusBar);
607 m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2);
0e320a79
DW
608 }
609
a885d89a 610 //
0e320a79 611 // Propagate the event to the non-top-level children
a885d89a
DW
612 //
613 wxWindow::OnSysColourChanged(rEvent);
614} // end of wxFrame::OnSysColourChanged
21802234 615
542875a8
DW
616// Pass TRUE to show full screen, FALSE to restore.
617bool wxFrame::ShowFullScreen(
618 bool bShow
619, long lStyle
620)
621{
622 /*
623 // TODO
624 if (show)
625 {
626 if (IsFullScreen())
627 return FALSE;
628
629 m_fsIsShowing = TRUE;
630 m_fsStyle = style;
631
632 wxToolBar *theToolBar = GetToolBar();
633 wxStatusBar *theStatusBar = GetStatusBar();
634
635 int dummyWidth;
636
637 if (theToolBar)
638 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
639 if (theStatusBar)
640 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
641
642 // zap the toolbar, menubar, and statusbar
643
644 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
645 {
646 theToolBar->SetSize(-1,0);
647 theToolBar->Show(FALSE);
648 }
649
650 if (style & wxFULLSCREEN_NOMENUBAR)
651 SetMenu((HWND)GetHWND(), (HMENU) NULL);
652
653 // Save the number of fields in the statusbar
654 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
655 {
656 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
657 SetStatusBar((wxStatusBar*) NULL);
658 delete theStatusBar;
659 }
660 else
661 m_fsStatusBarFields = 0;
662
663 // zap the frame borders
664
665 // save the 'normal' window style
666 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
667
668 // save the old position, width & height, maximize state
669 m_fsOldSize = GetRect();
670 m_fsIsMaximized = IsMaximized();
671
672 // decide which window style flags to turn off
673 LONG newStyle = m_fsOldWindowStyle;
674 LONG offFlags = 0;
675
676 if (style & wxFULLSCREEN_NOBORDER)
677 offFlags |= WS_BORDER;
678 if (style & wxFULLSCREEN_NOCAPTION)
679 offFlags |= (WS_CAPTION | WS_SYSMENU);
680
681 newStyle &= (~offFlags);
682
683 // change our window style to be compatible with full-screen mode
684 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
685
686 // resize to the size of the desktop
687 int width, height;
688
689 RECT rect;
690 ::GetWindowRect(GetDesktopWindow(), &rect);
691 width = rect.right - rect.left;
692 height = rect.bottom - rect.top;
693
694 SetSize(width, height);
695
696 // now flush the window style cache and actually go full-screen
697 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
698
699 wxSizeEvent event(wxSize(width, height), GetId());
700 GetEventHandler()->ProcessEvent(event);
701
702 return TRUE;
703 }
704 else
705 {
706 if (!IsFullScreen())
707 return FALSE;
708
709 m_fsIsShowing = FALSE;
710
711 wxToolBar *theToolBar = GetToolBar();
712
713 // restore the toolbar, menubar, and statusbar
714 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
715 {
716 theToolBar->SetSize(-1, m_fsToolBarHeight);
717 theToolBar->Show(TRUE);
718 }
719
720 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
721 {
722 CreateStatusBar(m_fsStatusBarFields);
723 PositionStatusBar();
724 }
725
726 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
727 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
728
729 Maximize(m_fsIsMaximized);
730 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
731 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
732 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
733
734 return TRUE;
735 }
736*/
737 return TRUE;
738} // end of wxFrame::ShowFullScreen
739
a885d89a
DW
740//
741// Frame window
742//
743bool wxFrame::OS2Create(
744 int nId
745, wxWindow* pParent
746, const wxChar* zWclass
747, wxWindow* pWxWin
748, const wxChar* zTitle
749, int nX
750, int nY
751, int nWidth
752, int nHeight
753, long ulStyle
754)
21802234 755{
f23208ca
DW
756 ULONG ulCreateFlags = 0L;
757 ULONG ulStyleFlags = 0L;
914589c2 758 ULONG ulExtraFlags = 0L;
f23208ca
DW
759 FRAMECDATA vFrameCtlData;
760 HWND hParent = NULLHANDLE;
761 HWND hClient = NULLHANDLE;
762 HWND hTitlebar = NULLHANDLE;
763 HWND hHScroll = NULLHANDLE;
764 HWND hVScroll = NULLHANDLE;
a0606634
DW
765 HWND hMenuBar = NULLHANDLE;
766 HWND hMenu1 = NULLHANDLE;
767 HWND hMenu2 = NULLHANDLE;
768 HWND hFrame = NULLHANDLE;
f23208ca
DW
769 SWP vSwp;
770 SWP vSwpTitlebar;
771 SWP vSwpVScroll;
772 SWP vSwpHScroll;
a0606634
DW
773 SWP vSwpMenu;
774 RGB2 vRgb;
a885d89a
DW
775
776 m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
f23208ca
DW
777 memset(&vSwp, '\0', sizeof(SWP));
778 memset(&vSwpTitlebar, '\0', sizeof(SWP));
779 memset(&vSwpVScroll, '\0', sizeof(SWP));
780 memset(&vSwpHScroll, '\0', sizeof(SWP));
a0606634 781
f23208ca
DW
782 if (pParent)
783 hParent = GetWinHwnd(pParent);
784 else
785 hParent = HWND_DESKTOP;
a885d89a 786
914589c2 787 if (ulStyle == wxDEFAULT_FRAME_STYLE)
f23208ca
DW
788 ulCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU |
789 FCF_MINMAX | FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_TASKLIST;
a885d89a 790 else
a885d89a 791 {
914589c2 792 if ((ulStyle & wxCAPTION) == wxCAPTION)
f23208ca 793 ulCreateFlags = FCF_TASKLIST;
914589c2 794 else
f23208ca 795 ulCreateFlags = FCF_NOMOVEWITHOWNER;
914589c2
DW
796
797 if (ulStyle & wxMINIMIZE_BOX)
f23208ca 798 ulCreateFlags |= FCF_MINBUTTON;
914589c2 799 if (ulStyle & wxMAXIMIZE_BOX)
f23208ca 800 ulCreateFlags |= FCF_MAXBUTTON;
914589c2 801 if (ulStyle & wxTHICK_FRAME)
f23208ca 802 ulCreateFlags |= FCF_DLGBORDER;
914589c2 803 if (ulStyle & wxSYSTEM_MENU)
f23208ca 804 ulCreateFlags |= FCF_SYSMENU;
914589c2 805 if (ulStyle & wxCAPTION)
f23208ca 806 ulCreateFlags |= FCF_TASKLIST;
914589c2
DW
807 if (ulStyle & wxCLIP_CHILDREN)
808 {
809 // Invalid for frame windows under PM
810 }
a885d89a 811
914589c2 812 if (ulStyle & wxTINY_CAPTION_VERT)
f23208ca 813 ulCreateFlags |= FCF_TASKLIST;
914589c2 814 if (ulStyle & wxTINY_CAPTION_HORIZ)
f23208ca
DW
815 ulCreateFlags |= FCF_TASKLIST;
816
914589c2 817 if ((ulStyle & wxTHICK_FRAME) == 0)
f23208ca 818 ulCreateFlags |= FCF_BORDER;
914589c2
DW
819 if (ulStyle & wxFRAME_TOOL_WINDOW)
820 ulExtraFlags = kFrameToolWindow;
21802234 821
914589c2 822 if (ulStyle & wxSTAY_ON_TOP)
f23208ca 823 ulCreateFlags |= FCF_SYSMODAL;
914589c2 824 }
f23208ca
DW
825 if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE))
826 ulStyleFlags |= WS_MINIMIZED;
827 if (ulStyle & wxMAXIMIZE)
828 ulStyleFlags |= WS_MAXIMIZED;
829
a885d89a
DW
830 //
831 // Clear the visible flag, we always call show
832 //
f23208ca 833 ulStyleFlags &= (unsigned long)~WS_VISIBLE;
a885d89a 834 m_bIconized = FALSE;
f23208ca
DW
835
836 //
837 // Set the frame control block
838 //
839 vFrameCtlData.cb = sizeof(vFrameCtlData);
840 vFrameCtlData.flCreateFlags = ulCreateFlags;
841 vFrameCtlData.hmodResources = 0L;
842 vFrameCtlData.idResources = 0;
843
844 //
845 // Create the frame window
846 //
847 if (!wxWindow::OS2Create( hParent
848 ,WC_FRAME
849 ,zTitle
850 ,ulStyleFlags
851 ,(long)nX
852 ,(long)nY
853 ,(long)nWidth
854 ,(long)nHeight
855 ,NULLHANDLE
856 ,HWND_TOP
857 ,(long)nId
858 ,(void*)&vFrameCtlData
859 ,NULL
860 ))
a885d89a
DW
861 {
862 return FALSE;
863 }
f23208ca
DW
864
865 //
866 // Create the client window. We must call the API from here rather than
867 // the static base class create because we need a separate handle
868 //
a0606634
DW
869 if ((hClient = ::WinCreateWindow( hFrame // Frame is parent
870 ,wxFrameClassName
f23208ca
DW
871 ,NULL // Window title
872 ,0 // No styles
873 ,0, 0, 0, 0 // Window position
874 ,NULLHANDLE // Owner
875 ,HWND_TOP // Sibling
876 ,FID_CLIENT // standard client ID
877 ,NULL // Creation data
878 ,NULL // Window Pres Params
879 )) == 0L)
880 {
881 return FALSE;
882 }
3d407eda
DW
883 //
884 // Send anything to initialize the frame
885 //
a0606634 886 ::WinSendMsg( hFrame
3d407eda
DW
887 ,WM_UPDATEFRAME
888 ,(MPARAM)FCF_TASKLIST
889 ,(MPARAM)0
890 );
f23208ca
DW
891
892 //
893 // Now size everything. If adding a menu the client will need to be resized.
894 //
a0606634 895 if (!::WinSetWindowPos( hFrame
f23208ca
DW
896 ,HWND_TOP
897 ,nX
898 ,nY
899 ,nWidth
900 ,nHeight
901 ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
902 ))
903 return FALSE;
904
a0606634 905 WinQueryWindowPos(hFrame, &vSwp);
f23208ca 906
a0606634
DW
907 //
908 // Set the client window's background, otherwise it is transparent!
909 //
910 wxColour vColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
911
912 vRgb.bRed = (BYTE)vColour.Red();
913 vRgb.bGreen = (BYTE)vColour.Green();
914 vRgb.bBlue = (BYTE)vColour.Blue();
915 WinSetPresParam( hClient
916 ,PP_BACKGROUNDCOLOR
917 ,(ULONG)sizeof(RGB2)
918 ,(PVOID)&vRgb
919 );
f23208ca
DW
920 if (ulCreateFlags & FCF_TITLEBAR)
921 {
a0606634 922 hTitlebar = WinWindowFromID(hFrame, FID_TITLEBAR);
f23208ca
DW
923 WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
924 }
925 if (ulCreateFlags & FCF_HORZSCROLL)
926 {
a0606634 927 hHScroll = WinWindowFromID(hFrame, FID_HORZSCROLL);
f23208ca
DW
928 WinQueryWindowPos(hHScroll, &vSwpHScroll);
929 }
930 if (ulCreateFlags & FCF_VERTSCROLL)
931 {
a0606634 932 hVScroll = WinWindowFromID(hFrame, FID_VERTSCROLL);
f23208ca
DW
933 WinQueryWindowPos(hVScroll, &vSwpVScroll);
934 }
935 if (!::WinSetWindowPos( hClient
936 ,HWND_TOP
937 ,SV_CXSIZEBORDER
938 ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy
939 ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx)
940 ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpHScroll.cy)
941 ,SWP_SIZE | SWP_MOVE
942 ))
943 return FALSE;
7bed7a50 944 WinQueryWindowPos(hClient, &vSwp);
a0606634 945 ::WinShowWindow(hClient, TRUE);
a885d89a
DW
946 return TRUE;
947} // end of wxFrame::OS2Create
0e320a79 948
a885d89a 949//
0e320a79
DW
950// Default activation behaviour - set the focus for the first child
951// subwindow found.
a885d89a
DW
952//
953void wxFrame::OnActivate(
954 wxActivateEvent& rEvent
955)
0e320a79 956{
a885d89a
DW
957 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
958 pNode;
959 pNode = pNode->GetNext())
0e320a79 960 {
21802234
DW
961 // FIXME all this is totally bogus - we need to do the same as wxPanel,
962 // but how to do it without duplicating the code?
963
964 // restore focus
a885d89a 965 wxWindow* pChild = pNode->GetData();
21802234 966
a885d89a 967 if (!pChild->IsTopLevel()
21802234 968#if wxUSE_TOOLBAR
a885d89a 969 && !wxDynamicCast(pChild, wxToolBar)
21802234
DW
970#endif // wxUSE_TOOLBAR
971#if wxUSE_STATUSBAR
a885d89a 972 && !wxDynamicCast(pChild, wxStatusBar)
21802234
DW
973#endif // wxUSE_STATUSBAR
974 )
975 {
a885d89a 976 pChild->SetFocus();
21802234
DW
977 return;
978 }
0e320a79 979 }
a885d89a 980} // end of wxFrame::OnActivate
0e320a79 981
f38374d0
DW
982// ----------------------------------------------------------------------------
983// wxFrame size management: we exclude the areas taken by menu/status/toolbars
984// from the client area, so the client area is what's really available for the
985// frame contents
986// ----------------------------------------------------------------------------
0e320a79
DW
987
988// Checks if there is a toolbar, and returns the first free client position
989wxPoint wxFrame::GetClientAreaOrigin() const
990{
a885d89a
DW
991 wxPoint vPoint(0, 0);
992
0e320a79
DW
993 if (GetToolBar())
994 {
a885d89a
DW
995 int nWidth;
996 int nHeight;
997
998 GetToolBar()->GetSize( &nWidth
999 ,&nHeight
1000 );
0e320a79
DW
1001
1002 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
1003 {
a885d89a 1004 vPoint.x += nWidth;
0e320a79
DW
1005 }
1006 else
1007 {
a885d89a
DW
1008 // PM is backwards from windows
1009 vPoint.y += nHeight;
0e320a79
DW
1010 }
1011 }
a885d89a
DW
1012 return vPoint;
1013} // end of wxFrame::GetClientAreaOrigin
0e320a79 1014
f38374d0
DW
1015// ----------------------------------------------------------------------------
1016// tool/status bar stuff
1017// ----------------------------------------------------------------------------
1018
21802234 1019#if wxUSE_TOOLBAR
f38374d0 1020
a885d89a
DW
1021wxToolBar* wxFrame::CreateToolBar(
1022 long lStyle
1023, wxWindowID vId
1024, const wxString& rName
1025)
0e320a79 1026{
a885d89a
DW
1027 if (wxFrameBase::CreateToolBar( lStyle
1028 ,vId
1029 ,rName
1030 ))
0e320a79 1031 {
0e320a79 1032 PositionToolBar();
0e320a79 1033 }
f38374d0 1034 return m_frameToolBar;
a885d89a 1035} // end of wxFrame::CreateToolBar
0e320a79
DW
1036
1037void wxFrame::PositionToolBar()
1038{
a885d89a
DW
1039 HWND hWndClient;
1040 RECTL vRect;
1041
1042 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1043 ::WinQueryWindowRect(hWndClient, &vRect);
0e320a79 1044
f38374d0 1045#if wxUSE_STATUSBAR
a885d89a 1046 if (GetStatusBar())
0e320a79 1047 {
a885d89a
DW
1048 int nStatusX;
1049 int nStatusY;
1050
1051 GetStatusBar()->GetClientSize( &nStatusX
1052 ,&nStatusY
1053 );
1054 // PM is backwards from windows
1055 vRect.yBottom += nStatusY;
0e320a79 1056 }
f38374d0 1057#endif // wxUSE_STATUSBAR
0e320a79 1058
f38374d0 1059 if ( GetToolBar() )
0e320a79 1060 {
a885d89a
DW
1061 int nToolbarWidth;
1062 int nToolbarHeight;
1063
1064 GetToolBar()->GetSize( &nToolbarWidth
1065 ,&nToolbarHeight
1066 );
0e320a79 1067
a885d89a 1068 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
0e320a79 1069 {
a885d89a 1070 nToolbarHeight = vRect.yBottom;
0e320a79
DW
1071 }
1072 else
1073 {
a885d89a 1074 nToolbarWidth = vRect.xRight;
21802234 1075 }
f38374d0 1076
a885d89a
DW
1077 //
1078 // Use the 'real' PM position here
1079 //
1080 GetToolBar()->SetSize( 0
1081 ,0
1082 ,nToolbarWidth
1083 ,nToolbarHeight
1084 ,wxSIZE_NO_ADJUSTMENTS
1085 );
21802234 1086 }
a885d89a 1087} // end of wxFrame::PositionToolBar
21802234
DW
1088#endif // wxUSE_TOOLBAR
1089
f38374d0
DW
1090// ----------------------------------------------------------------------------
1091// frame state (iconized/maximized/...)
1092// ----------------------------------------------------------------------------
1093
a885d89a 1094//
21802234
DW
1095// propagate our state change to all child frames: this allows us to emulate X
1096// Windows behaviour where child frames float independently of the parent one
1097// on the desktop, but are iconized/restored with it
a885d89a
DW
1098//
1099void wxFrame::IconizeChildFrames(
1100 bool bIconize
1101)
21802234 1102{
a885d89a
DW
1103 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
1104 pNode;
1105 pNode = pNode->GetNext() )
21802234 1106 {
a885d89a 1107 wxWindow* pWin = pNode->GetData();
21802234 1108
a885d89a 1109 if (pWin->IsKindOf(CLASSINFO(wxFrame)) )
21802234 1110 {
a885d89a 1111 ((wxFrame *)pWin)->Iconize(bIconize);
0e320a79
DW
1112 }
1113 }
a885d89a 1114} // end of wxFrame::IconizeChildFrames
0e320a79 1115
21802234
DW
1116// ===========================================================================
1117// message processing
1118// ===========================================================================
1119
1120// ---------------------------------------------------------------------------
1121// preprocessing
1122// ---------------------------------------------------------------------------
a885d89a
DW
1123bool wxFrame::OS2TranslateMessage(
1124 WXMSG* pMsg
1125)
21802234 1126{
a885d89a 1127 if (wxWindow::OS2TranslateMessage(pMsg))
29435d81 1128 return TRUE;
a885d89a 1129 //
21802234 1130 // try the menu bar accels
a885d89a
DW
1131 //
1132 wxMenuBar* pMenuBar = GetMenuBar();
1133
1134 if (!pMenuBar )
21802234
DW
1135 return FALSE;
1136
a885d89a
DW
1137 const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
1138 return rAcceleratorTable.Translate(this, pMsg);
1139} // end of wxFrame::OS2TranslateMessage
21802234
DW
1140
1141// ---------------------------------------------------------------------------
1142// our private (non virtual) message handlers
1143// ---------------------------------------------------------------------------
21802234
DW
1144bool wxFrame::HandlePaint()
1145{
a885d89a
DW
1146 RECTL vRect;
1147
1148 if (::WinQueryUpdateRect(GetHwnd(), &vRect))
29435d81 1149 {
a885d89a 1150 if (m_bIconized)
29435d81 1151 {
a885d89a
DW
1152 //
1153 // Icons in PM are the same as "pointers"
1154 //
1155 HPOINTER hIcon;
29435d81 1156
a885d89a
DW
1157 if (m_icon.Ok())
1158 hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L);
1159 else
1160 hIcon = (HPOINTER)m_hDefaultIcon;
1161
1162 //
21802234
DW
1163 // Hold a pointer to the dc so long as the OnPaint() message
1164 // is being processed
a885d89a
DW
1165 //
1166 RECTL vRect2;
1167 HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2);
29435d81 1168
a885d89a 1169 //
29435d81 1170 // Erase background before painting or we get white background
a885d89a
DW
1171 //
1172 OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2);
29435d81 1173
a885d89a 1174 if (hIcon)
29435d81 1175 {
a885d89a
DW
1176 HWND hWndClient;
1177 RECTL vRect3;
21802234 1178
a885d89a
DW
1179 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1180 ::WinQueryWindowRect(hWndClient, &vRect3);
29435d81 1181
a885d89a
DW
1182 static const int nIconWidth = 32;
1183 static const int nIconHeight = 32;
1184 int nIconX = (int)((vRect3.xRight - nIconWidth)/2);
1185 int nIconY = (int)((vRect3.yBottom + nIconHeight)/2);
29435d81 1186
a885d89a 1187 ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL);
29435d81 1188 }
a885d89a 1189 ::WinEndPaint(hPs);
29435d81
DW
1190 return TRUE;
1191 }
1192 else
1193 {
1194 return wxWindow::HandlePaint();
1195 }
1196 }
1197 else
1198 {
1199 // nothing to paint - processed
1200 return TRUE;
1201 }
29435d81 1202 return FALSE;
a885d89a 1203} // end of wxFrame::HandlePaint
21802234 1204
a885d89a
DW
1205bool wxFrame::HandleSize(
1206 int nX
1207, int nY
1208, WXUINT nId
1209)
21802234 1210{
a885d89a 1211 bool bProcessed = FALSE;
21802234 1212
a885d89a 1213 switch (nId)
21802234 1214 {
a885d89a
DW
1215 case kSizeNormal:
1216 //
1217 // Only do it it if we were iconized before, otherwise resizing the
21802234
DW
1218 // parent frame has a curious side effect of bringing it under it's
1219 // children
a885d89a 1220 if (!m_bIconized )
21802234
DW
1221 break;
1222
a885d89a 1223 //
21802234 1224 // restore all child frames too
a885d89a 1225 //
21802234
DW
1226 IconizeChildFrames(FALSE);
1227
a885d89a 1228 //
21802234 1229 // fall through
a885d89a 1230 //
21802234 1231
a885d89a
DW
1232 case kSizeMax:
1233 m_bIconized = FALSE;
21802234
DW
1234 break;
1235
a885d89a
DW
1236 case kSizeMin:
1237 //
1238 // Iconize all child frames too
1239 //
21802234 1240 IconizeChildFrames(TRUE);
a885d89a 1241 m_bIconized = TRUE;
21802234
DW
1242 break;
1243 }
f38374d0 1244
a885d89a 1245 if (!m_bIconized)
21802234 1246 {
a885d89a 1247 //
29435d81 1248 // forward WM_SIZE to status bar control
a885d89a 1249 //
f38374d0
DW
1250#if wxUSE_NATIVE_STATUSBAR
1251 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
1252 {
a885d89a
DW
1253 wxSizeEvent vEvent( wxSize( nX
1254 ,nY
1255 )
1256 ,m_frameStatusBar->GetId()
1257 );
f38374d0 1258
a885d89a
DW
1259 vEvent.SetEventObject(m_frameStatusBar);
1260 m_frameStatusBar->OnSize(vEvent);
f38374d0
DW
1261 }
1262#endif // wxUSE_NATIVE_STATUSBAR
1263
21802234
DW
1264 PositionStatusBar();
1265 PositionToolBar();
a885d89a
DW
1266 wxSizeEvent vEvent( wxSize( nX
1267 ,nY
1268 )
1269 ,m_windowId
1270 );
21802234 1271
a885d89a
DW
1272 vEvent.SetEventObject(this);
1273 bProcessed = GetEventHandler()->ProcessEvent(vEvent);
21802234 1274 }
a885d89a
DW
1275 return bProcessed;
1276} // end of wxFrame::HandleSize
21802234 1277
a885d89a
DW
1278bool wxFrame::HandleCommand(
1279 WXWORD nId
1280, WXWORD nCmd
1281, WXHWND hControl
1282)
21802234 1283{
a885d89a 1284 if (hControl)
21802234 1285 {
a885d89a 1286 //
21802234 1287 // In case it's e.g. a toolbar.
a885d89a
DW
1288 //
1289 wxWindow* pWin = wxFindWinFromHandle(hControl);
1290
1291 if (pWin)
1292 return pWin->OS2Command( nCmd
1293 ,nId
1294 );
21802234
DW
1295 }
1296
a885d89a
DW
1297 //
1298 // Handle here commands from menus and accelerators
1299 //
1300 if (nCmd == 0 || nCmd == 1)
21802234 1301 {
a885d89a 1302 if (wxCurrentPopupMenu)
21802234 1303 {
a885d89a
DW
1304 wxMenu* pPopupMenu = wxCurrentPopupMenu;
1305
21802234
DW
1306 wxCurrentPopupMenu = NULL;
1307
a885d89a
DW
1308 return pPopupMenu->OS2Command( nCmd
1309 ,nId
1310 );
21802234
DW
1311 }
1312
a885d89a 1313 if (ProcessCommand(nId))
21802234
DW
1314 {
1315 return TRUE;
1316 }
1317 }
21802234 1318 return FALSE;
a885d89a 1319} // end of wxFrame::HandleCommand
21802234 1320
a885d89a
DW
1321bool wxFrame::HandleMenuSelect(
1322 WXWORD nItem
1323, WXWORD nFlags
1324, WXHMENU hMenu
1325)
21802234 1326{
a885d89a
DW
1327 int nMenuItem;
1328
1329 if (nFlags == 0xFFFF && hMenu == 0)
21802234 1330 {
a885d89a
DW
1331 //
1332 // Menu was removed from screen
1333 //
1334 nMenuItem = -1;
21802234 1335 }
a885d89a 1336 else if (!(nFlags & MIS_SUBMENU) && !(nFlags & MIS_SEPARATOR))
21802234 1337 {
a885d89a 1338 nMenuItem = nItem;
21802234 1339 }
21802234
DW
1340 else
1341 {
a885d89a
DW
1342 //
1343 // Don't give hints for separators (doesn't make sense) nor for the
21802234 1344 // items opening popup menus (they don't have them anyhow)
a885d89a 1345 //
21802234
DW
1346 return FALSE;
1347 }
a885d89a 1348 wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nMenuItem);
21802234 1349
a885d89a
DW
1350 vEvent.SetEventObject(this);
1351 return GetEventHandler()->ProcessEvent(vEvent);
1352} // end of wxFrame::HandleMenuSelect
21802234
DW
1353
1354// ---------------------------------------------------------------------------
1355// the window proc for wxFrame
1356// ---------------------------------------------------------------------------
1357
a885d89a
DW
1358MRESULT wxFrame::OS2WindowProc(
1359 WXUINT uMessage
1360, WXWPARAM wParam
1361, WXLPARAM lParam
1362)
21802234 1363{
a885d89a
DW
1364 MRESULT mRc = 0L;
1365 bool bProcessed = FALSE;
21802234 1366
a885d89a 1367 switch (uMessage)
21802234
DW
1368 {
1369 case WM_CLOSE:
a885d89a
DW
1370 //
1371 // If we can't close, tell the system that we processed the
21802234 1372 // message - otherwise it would close us
a885d89a
DW
1373 //
1374 bProcessed = !Close();
21802234
DW
1375 break;
1376
1377 case WM_COMMAND:
1378 {
a885d89a
DW
1379 WORD wId;
1380 WORD wCmd;
1381 WXHWND hWnd;
1382
1383 UnpackCommand( (WXWPARAM)wParam
1384 ,(WXLPARAM)lParam
1385 ,&wId
1386 ,&hWnd
1387 ,&wCmd
1388 );
1389 bProcessed = HandleCommand( wId
1390 ,wCmd
1391 ,(WXHWND)hWnd
1392 );
21802234
DW
1393 }
1394 break;
1395
1396 case WM_MENUSELECT:
1397 {
a885d89a
DW
1398 WXWORD wItem;
1399 WXWORD wFlags;
1400 WXHMENU hMenu;
1401
1402 UnpackMenuSelect( wParam
1403 ,lParam
1404 ,&wItem
1405 ,&wFlags
1406 ,&hMenu
1407 );
1408 bProcessed = HandleMenuSelect( wItem
1409 ,wFlags
1410 ,hMenu
1411 );
21802234
DW
1412 }
1413 break;
1414
1415 case WM_PAINT:
a885d89a 1416 bProcessed = HandlePaint();
21802234
DW
1417 break;
1418
a885d89a 1419 case CM_QUERYDRAGIMAGE:
21802234 1420 {
a885d89a
DW
1421 HPOINTER hIcon;
1422
1423 if (m_icon.Ok())
1424 hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L);
1425 else
1426 hIcon = (HPOINTER)m_hDefaultIcon;
1427 mRc = (MRESULT)hIcon;
1428 bProcessed = mRc != 0;
21802234
DW
1429 }
1430 break;
1431
1432 case WM_SIZE:
a885d89a 1433 bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
21802234
DW
1434 break;
1435 }
f38374d0 1436
a885d89a
DW
1437 if (!bProcessed )
1438 mRc = wxWindow::OS2WindowProc( uMessage
1439 ,wParam
1440 ,lParam
1441 );
f38374d0 1442 return (MRESULT)0;
a885d89a 1443} // wxFrame::OS2WindowProc
21802234 1444