]> git.saurik.com Git - wxWidgets.git/blame - src/os2/frame.cpp
Ups, mismatch between header and source wrt InterruptWait()
[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
DW
345 HWND hClient;
346
347 hClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
348 ::WinShowWindow(GetHwnd(), (BOOL)bShowCmd);
349 ::WinShowWindow(hClient, (BOOL)bShowCmd);
80d83cbc 350} // end of wxFrame::DoShowWindow
21802234 351
80d83cbc
DW
352bool wxFrame::Show(
353 bool bShow
354)
0e320a79 355{
426d5745
DW
356 SWP vSwp;
357
358 DoShowWindow((int)bShow);
21802234 359
80d83cbc 360 if (bShow)
f38374d0 361 {
80d83cbc
DW
362 wxActivateEvent vEvent(wxEVT_ACTIVATE, TRUE, m_windowId);
363
426d5745
DW
364 ::WinQueryWindowPos(GetHwnd(), &vSwp);
365 m_bIconized = vSwp & SWP_MINIMIZE;
80d83cbc
DW
366 ::WinSetWindowPos( (HWND) GetHWND()
367 ,HWND_TOP
426d5745
DW
368 ,vSwp.x
369 ,vSwp.y
370 ,vSwp.cx
371 ,vSwp.cy
372 ,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE
80d83cbc
DW
373 );
374 vEvent.SetEventObject(this);
375 GetEventHandler()->ProcessEvent(vEvent);
f38374d0
DW
376 }
377 else
378 {
80d83cbc 379 //
f38374d0 380 // Try to highlight the correct window (the parent)
80d83cbc
DW
381 //
382 if (GetParent())
f38374d0 383 {
80d83cbc
DW
384 HWND hWndParent = GetHwndOf(GetParent());
385
426d5745
DW
386 ::WinQueryWindowPos(hWndParent, &vSwp);
387 m_bIconized = vSwp & SWP_MINIMIZE;
f38374d0 388 if (hWndParent)
80d83cbc
DW
389 ::WinSetWindowPos( hWndParent
390 ,HWND_TOP
426d5745
DW
391 ,vSwp.x
392 ,vSwp.y
393 ,vSwp.cx
394 ,vSwp.cy
395 ,SWP_ZORDER | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE
80d83cbc 396 );
f38374d0
DW
397 }
398 }
f38374d0 399 return TRUE;
80d83cbc 400} // end of wxFrame::Show
f38374d0 401
80d83cbc
DW
402void wxFrame::Iconize(
403 bool bIconize
404)
f38374d0 405{
80d83cbc
DW
406 DoShowWindow(bIconize ? SWP_MINIMIZE : SWP_RESTORE);
407} // end of wxFrame::Iconize
0e320a79 408
80d83cbc
DW
409void wxFrame::Maximize(
410 bool bMaximize)
0e320a79 411{
80d83cbc
DW
412 DoShowWindow(bMaximize ? SWP_MAXIMIZE : SWP_RESTORE);
413} // end of wxFrame::Maximize
f38374d0
DW
414
415void wxFrame::Restore()
416{
80d83cbc
DW
417 DoShowWindow(SWP_RESTORE);
418} // end of wxFrame::Restore
0e320a79
DW
419
420bool wxFrame::IsIconized() const
421{
80d83cbc
DW
422 SWP vSwp;
423 bool bIconic;
424
a885d89a
DW
425 ::WinQueryWindowPos(GetHwnd(), &vSwp);
426
80d83cbc
DW
427 if (vSwp.fl & SWP_MINIMIZE)
428 ((wxFrame*)this)->m_bIconized = TRUE;
429 else
430 ((wxFrame*)this)->m_bIconized = FALSE;
431 return m_bIconized;
432} // end of wxFrame::IsIconized
0e320a79 433
21802234
DW
434// Is it maximized?
435bool wxFrame::IsMaximized() const
0e320a79 436{
80d83cbc
DW
437 SWP vSwp;
438 bool bIconic;
439
a885d89a 440 ::WinQueryWindowPos(GetHwnd(), &vSwp);
80d83cbc
DW
441 return (vSwp.fl & SWP_MAXIMIZE);
442} // end of wxFrame::IsMaximized
0e320a79 443
0fe536e3
DW
444void wxFrame::SetIcon(
445 const wxIcon& rIcon
446)
0e320a79 447{
0fe536e3 448 wxFrameBase::SetIcon(rIcon);
f38374d0 449
426d5745 450 if ((m_icon.GetHICON()) != NULLHANDLE)
f38374d0 451 {
f23208ca
DW
452 ::WinSendMsg( GetHwnd()
453 ,WM_SETICON
426d5745 454 ,(MPARAM)((HPOINTER)m_icon.GetHICON())
f23208ca
DW
455 ,NULL
456 );
457 ::WinSendMsg( GetHwnd()
458 ,WM_UPDATEFRAME
459 ,(MPARAM)FCF_ICON
460 ,(MPARAM)0
461 );
f38374d0 462 }
0fe536e3 463} // end of wxFrame::SetIcon
0e320a79 464
21802234 465#if wxUSE_STATUSBAR
0fe536e3
DW
466wxStatusBar* wxFrame::OnCreateStatusBar(
467 int nNumber
a885d89a 468, long lulStyle
0fe536e3
DW
469, wxWindowID vId
470, const wxString& rName
471)
0e320a79 472{
0fe536e3 473 wxStatusBar* pStatusBar = NULL;
0e320a79 474
0fe536e3 475 pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber
a885d89a 476 ,lulStyle
0fe536e3
DW
477 ,vId
478 ,rName
479 );
480 return pStatusBar;
481} // end of wxFrame::OnCreateStatusBar
0e320a79
DW
482
483void wxFrame::PositionStatusBar()
484{
0fe536e3
DW
485 //
486 // Native status bar positions itself
487 //
488 if (m_frameStatusBar)
f38374d0 489 {
a885d89a 490 int nWidth;
0fe536e3 491 int nHeight;
a885d89a 492 int nStatbarWidth;
0fe536e3
DW
493 int nStatbarHeight;
494 HWND hWndClient;
495 RECTL vRect;
496
a885d89a 497 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
0fe536e3
DW
498 ::WinQueryWindowRect(hWndClient, &vRect);
499 nWidth = vRect.xRight - vRect.xLeft;
a885d89a
DW
500 nHeight = vRect.yTop - vRect.yBottom;
501
0fe536e3
DW
502 m_frameStatusBar->GetSize( &nStatbarWidth
503 ,&nStatbarHeight
504 );
f38374d0 505
0fe536e3 506 //
f38374d0
DW
507 // Since we wish the status bar to be directly under the client area,
508 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
0fe536e3
DW
509 //
510 m_frameStatusBar->SetSize( 0
511 ,nHeight
512 ,nWidth
513 ,nStatbarHeight
514 );
f38374d0 515 }
0fe536e3 516} // end of wxFrame::PositionStatusBar
21802234 517#endif // wxUSE_STATUSBAR
0e320a79 518
21802234 519void wxFrame::DetachMenuBar()
0e320a79 520{
21802234 521 if (m_frameMenuBar)
0e320a79 522 {
29435d81 523 m_frameMenuBar->Detach();
0e320a79 524 m_frameMenuBar = NULL;
21802234 525 }
0fe536e3 526} // end of wxFrame::DetachMenuBar
21802234 527
0fe536e3 528void wxFrame::SetMenuBar(
a885d89a 529 wxMenuBar* pMenuBar
0fe536e3 530)
21802234 531{
0fe536e3 532 if (!pMenuBar)
21802234
DW
533 {
534 DetachMenuBar();
0e320a79
DW
535 return;
536 }
c3d43472 537
29a99be3 538 m_frameMenuBar = NULL;
0e320a79 539
29a99be3
DW
540 // Can set a menubar several times.
541 // TODO: how to prevent a memory leak if you have a currently-unattached
542 // menubar? wxWindows assumes that the frame will delete the menu (otherwise
543 // there are problems for MDI).
544 if (pMenuBar->GetHMenu())
0fe536e3 545 {
29a99be3 546 m_hMenu = pMenuBar->GetHMenu();
0fe536e3 547 }
29a99be3
DW
548 else
549 {
550 pMenuBar->Detach();
21802234 551
29a99be3
DW
552 m_hMenu = pMenuBar->Create();
553
554 if (!m_hMenu)
555 return;
556 }
21802234
DW
557
558 InternalSetMenuBar();
559
a885d89a
DW
560 m_frameMenuBar = pMenuBar;
561 pMenuBar->Attach(this);
0fe536e3 562} // end of wxFrame::SetMenuBar
0e320a79 563
21802234 564void wxFrame::InternalSetMenuBar()
0e320a79 565{
f23208ca 566 WinSendMsg((HWND)GetHwnd(), WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
0fe536e3 567} // end of wxFrame::InternalSetMenuBar
0e320a79 568
a885d89a
DW
569//
570// Responds to colour changes, and passes event on to children
571//
572void wxFrame::OnSysColourChanged(
573 wxSysColourChangedEvent& rEvent
574)
0e320a79
DW
575{
576 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
577 Refresh();
578
a885d89a 579 if (m_frameStatusBar)
0e320a79 580 {
a885d89a
DW
581 wxSysColourChangedEvent vEvent2;
582
583 vEvent2.SetEventObject(m_frameStatusBar);
584 m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2);
0e320a79
DW
585 }
586
a885d89a 587 //
0e320a79 588 // Propagate the event to the non-top-level children
a885d89a
DW
589 //
590 wxWindow::OnSysColourChanged(rEvent);
591} // end of wxFrame::OnSysColourChanged
21802234 592
542875a8
DW
593// Pass TRUE to show full screen, FALSE to restore.
594bool wxFrame::ShowFullScreen(
595 bool bShow
596, long lStyle
597)
598{
599 /*
600 // TODO
601 if (show)
602 {
603 if (IsFullScreen())
604 return FALSE;
605
606 m_fsIsShowing = TRUE;
607 m_fsStyle = style;
608
609 wxToolBar *theToolBar = GetToolBar();
610 wxStatusBar *theStatusBar = GetStatusBar();
611
612 int dummyWidth;
613
614 if (theToolBar)
615 theToolBar->GetSize(&dummyWidth, &m_fsToolBarHeight);
616 if (theStatusBar)
617 theStatusBar->GetSize(&dummyWidth, &m_fsStatusBarHeight);
618
619 // zap the toolbar, menubar, and statusbar
620
621 if ((style & wxFULLSCREEN_NOTOOLBAR) && theToolBar)
622 {
623 theToolBar->SetSize(-1,0);
624 theToolBar->Show(FALSE);
625 }
626
627 if (style & wxFULLSCREEN_NOMENUBAR)
628 SetMenu((HWND)GetHWND(), (HMENU) NULL);
629
630 // Save the number of fields in the statusbar
631 if ((style & wxFULLSCREEN_NOSTATUSBAR) && theStatusBar)
632 {
633 m_fsStatusBarFields = theStatusBar->GetFieldsCount();
634 SetStatusBar((wxStatusBar*) NULL);
635 delete theStatusBar;
636 }
637 else
638 m_fsStatusBarFields = 0;
639
640 // zap the frame borders
641
642 // save the 'normal' window style
643 m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE);
644
645 // save the old position, width & height, maximize state
646 m_fsOldSize = GetRect();
647 m_fsIsMaximized = IsMaximized();
648
649 // decide which window style flags to turn off
650 LONG newStyle = m_fsOldWindowStyle;
651 LONG offFlags = 0;
652
653 if (style & wxFULLSCREEN_NOBORDER)
654 offFlags |= WS_BORDER;
655 if (style & wxFULLSCREEN_NOCAPTION)
656 offFlags |= (WS_CAPTION | WS_SYSMENU);
657
658 newStyle &= (~offFlags);
659
660 // change our window style to be compatible with full-screen mode
661 SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle);
662
663 // resize to the size of the desktop
664 int width, height;
665
666 RECT rect;
667 ::GetWindowRect(GetDesktopWindow(), &rect);
668 width = rect.right - rect.left;
669 height = rect.bottom - rect.top;
670
671 SetSize(width, height);
672
673 // now flush the window style cache and actually go full-screen
674 SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED);
675
676 wxSizeEvent event(wxSize(width, height), GetId());
677 GetEventHandler()->ProcessEvent(event);
678
679 return TRUE;
680 }
681 else
682 {
683 if (!IsFullScreen())
684 return FALSE;
685
686 m_fsIsShowing = FALSE;
687
688 wxToolBar *theToolBar = GetToolBar();
689
690 // restore the toolbar, menubar, and statusbar
691 if (theToolBar && (m_fsStyle & wxFULLSCREEN_NOTOOLBAR))
692 {
693 theToolBar->SetSize(-1, m_fsToolBarHeight);
694 theToolBar->Show(TRUE);
695 }
696
697 if ((m_fsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_fsStatusBarFields > 0))
698 {
699 CreateStatusBar(m_fsStatusBarFields);
700 PositionStatusBar();
701 }
702
703 if ((m_fsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
704 SetMenu((HWND)GetHWND(), (HMENU)m_hMenu);
705
706 Maximize(m_fsIsMaximized);
707 SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle);
708 SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
709 m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
710
711 return TRUE;
712 }
713*/
714 return TRUE;
715} // end of wxFrame::ShowFullScreen
716
a885d89a
DW
717//
718// Frame window
719//
720bool wxFrame::OS2Create(
721 int nId
722, wxWindow* pParent
723, const wxChar* zWclass
724, wxWindow* pWxWin
725, const wxChar* zTitle
726, int nX
727, int nY
728, int nWidth
729, int nHeight
730, long ulStyle
731)
21802234 732{
f23208ca
DW
733 ULONG ulCreateFlags = 0L;
734 ULONG ulStyleFlags = 0L;
914589c2 735 ULONG ulExtraFlags = 0L;
f23208ca
DW
736 FRAMECDATA vFrameCtlData;
737 HWND hParent = NULLHANDLE;
738 HWND hClient = NULLHANDLE;
739 HWND hTitlebar = NULLHANDLE;
740 HWND hHScroll = NULLHANDLE;
741 HWND hVScroll = NULLHANDLE;
742 SWP vSwp;
743 SWP vSwpTitlebar;
744 SWP vSwpVScroll;
745 SWP vSwpHScroll;
a885d89a
DW
746
747 m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
f23208ca
DW
748 memset(&vSwp, '\0', sizeof(SWP));
749 memset(&vSwpTitlebar, '\0', sizeof(SWP));
750 memset(&vSwpVScroll, '\0', sizeof(SWP));
751 memset(&vSwpHScroll, '\0', sizeof(SWP));
752 if (pParent)
753 hParent = GetWinHwnd(pParent);
754 else
755 hParent = HWND_DESKTOP;
a885d89a 756
914589c2 757 if (ulStyle == wxDEFAULT_FRAME_STYLE)
f23208ca
DW
758 ulCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU |
759 FCF_MINMAX | FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_TASKLIST;
a885d89a 760 else
a885d89a 761 {
914589c2 762 if ((ulStyle & wxCAPTION) == wxCAPTION)
f23208ca 763 ulCreateFlags = FCF_TASKLIST;
914589c2 764 else
f23208ca 765 ulCreateFlags = FCF_NOMOVEWITHOWNER;
914589c2
DW
766
767 if (ulStyle & wxMINIMIZE_BOX)
f23208ca 768 ulCreateFlags |= FCF_MINBUTTON;
914589c2 769 if (ulStyle & wxMAXIMIZE_BOX)
f23208ca 770 ulCreateFlags |= FCF_MAXBUTTON;
914589c2 771 if (ulStyle & wxTHICK_FRAME)
f23208ca 772 ulCreateFlags |= FCF_DLGBORDER;
914589c2 773 if (ulStyle & wxSYSTEM_MENU)
f23208ca 774 ulCreateFlags |= FCF_SYSMENU;
914589c2 775 if (ulStyle & wxCAPTION)
f23208ca 776 ulCreateFlags |= FCF_TASKLIST;
914589c2
DW
777 if (ulStyle & wxCLIP_CHILDREN)
778 {
779 // Invalid for frame windows under PM
780 }
a885d89a 781
914589c2 782 if (ulStyle & wxTINY_CAPTION_VERT)
f23208ca 783 ulCreateFlags |= FCF_TASKLIST;
914589c2 784 if (ulStyle & wxTINY_CAPTION_HORIZ)
f23208ca
DW
785 ulCreateFlags |= FCF_TASKLIST;
786
914589c2 787 if ((ulStyle & wxTHICK_FRAME) == 0)
f23208ca 788 ulCreateFlags |= FCF_BORDER;
914589c2
DW
789 if (ulStyle & wxFRAME_TOOL_WINDOW)
790 ulExtraFlags = kFrameToolWindow;
21802234 791
914589c2 792 if (ulStyle & wxSTAY_ON_TOP)
f23208ca 793 ulCreateFlags |= FCF_SYSMODAL;
914589c2 794 }
f23208ca
DW
795 if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE))
796 ulStyleFlags |= WS_MINIMIZED;
797 if (ulStyle & wxMAXIMIZE)
798 ulStyleFlags |= WS_MAXIMIZED;
799
a885d89a
DW
800 //
801 // Clear the visible flag, we always call show
802 //
f23208ca 803 ulStyleFlags &= (unsigned long)~WS_VISIBLE;
a885d89a 804 m_bIconized = FALSE;
f23208ca
DW
805
806 //
807 // Set the frame control block
808 //
809 vFrameCtlData.cb = sizeof(vFrameCtlData);
810 vFrameCtlData.flCreateFlags = ulCreateFlags;
811 vFrameCtlData.hmodResources = 0L;
812 vFrameCtlData.idResources = 0;
813
814 //
815 // Create the frame window
816 //
817 if (!wxWindow::OS2Create( hParent
818 ,WC_FRAME
819 ,zTitle
820 ,ulStyleFlags
821 ,(long)nX
822 ,(long)nY
823 ,(long)nWidth
824 ,(long)nHeight
825 ,NULLHANDLE
826 ,HWND_TOP
827 ,(long)nId
828 ,(void*)&vFrameCtlData
829 ,NULL
830 ))
a885d89a
DW
831 {
832 return FALSE;
833 }
f23208ca
DW
834
835 //
836 // Create the client window. We must call the API from here rather than
837 // the static base class create because we need a separate handle
838 //
839 if ((hClient = ::WinCreateWindow( GetHwnd() // Frame is parent
840 ,zWclass // Custom client class
841 ,NULL // Window title
842 ,0 // No styles
843 ,0, 0, 0, 0 // Window position
844 ,NULLHANDLE // Owner
845 ,HWND_TOP // Sibling
846 ,FID_CLIENT // standard client ID
847 ,NULL // Creation data
848 ,NULL // Window Pres Params
849 )) == 0L)
850 {
851 return FALSE;
852 }
853
854 //
855 // Now size everything. If adding a menu the client will need to be resized.
856 //
857 if (!::WinSetWindowPos( GetHwnd()
858 ,HWND_TOP
859 ,nX
860 ,nY
861 ,nWidth
862 ,nHeight
863 ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
864 ))
865 return FALSE;
866
867 WinQueryWindowPos(GetHwnd(), &vSwp);
868
869 if (ulCreateFlags & FCF_TITLEBAR)
870 {
871 hTitlebar = WinWindowFromID(GetHwnd(), FID_TITLEBAR);
872 WinQueryWindowPos(hTitlebar, &vSwpTitlebar);
873 }
874 if (ulCreateFlags & FCF_HORZSCROLL)
875 {
876 hHScroll = WinWindowFromID(GetHwnd(), FID_HORZSCROLL);
877 WinQueryWindowPos(hHScroll, &vSwpHScroll);
878 }
879 if (ulCreateFlags & FCF_VERTSCROLL)
880 {
881 hVScroll = WinWindowFromID(GetHwnd(), FID_VERTSCROLL);
882 WinQueryWindowPos(hVScroll, &vSwpVScroll);
883 }
884 if (!::WinSetWindowPos( hClient
885 ,HWND_TOP
886 ,SV_CXSIZEBORDER
887 ,(SV_CYSIZEBORDER - 1) + vSwpHScroll.cy
888 ,vSwp.cx - ((SV_CXSIZEBORDER * 2) + vSwpVScroll.cx)
889 ,vSwp.cy - ((SV_CYSIZEBORDER * 2) + 1 + vSwpTitlebar.cy + vSwpHScroll.cy)
890 ,SWP_SIZE | SWP_MOVE
891 ))
892 return FALSE;
a885d89a
DW
893 return TRUE;
894} // end of wxFrame::OS2Create
0e320a79 895
a885d89a 896//
0e320a79
DW
897// Default activation behaviour - set the focus for the first child
898// subwindow found.
a885d89a
DW
899//
900void wxFrame::OnActivate(
901 wxActivateEvent& rEvent
902)
0e320a79 903{
a885d89a
DW
904 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
905 pNode;
906 pNode = pNode->GetNext())
0e320a79 907 {
21802234
DW
908 // FIXME all this is totally bogus - we need to do the same as wxPanel,
909 // but how to do it without duplicating the code?
910
911 // restore focus
a885d89a 912 wxWindow* pChild = pNode->GetData();
21802234 913
a885d89a 914 if (!pChild->IsTopLevel()
21802234 915#if wxUSE_TOOLBAR
a885d89a 916 && !wxDynamicCast(pChild, wxToolBar)
21802234
DW
917#endif // wxUSE_TOOLBAR
918#if wxUSE_STATUSBAR
a885d89a 919 && !wxDynamicCast(pChild, wxStatusBar)
21802234
DW
920#endif // wxUSE_STATUSBAR
921 )
922 {
a885d89a 923 pChild->SetFocus();
21802234
DW
924 return;
925 }
0e320a79 926 }
a885d89a 927} // end of wxFrame::OnActivate
0e320a79 928
f38374d0
DW
929// ----------------------------------------------------------------------------
930// wxFrame size management: we exclude the areas taken by menu/status/toolbars
931// from the client area, so the client area is what's really available for the
932// frame contents
933// ----------------------------------------------------------------------------
0e320a79
DW
934
935// Checks if there is a toolbar, and returns the first free client position
936wxPoint wxFrame::GetClientAreaOrigin() const
937{
a885d89a
DW
938 wxPoint vPoint(0, 0);
939
0e320a79
DW
940 if (GetToolBar())
941 {
a885d89a
DW
942 int nWidth;
943 int nHeight;
944
945 GetToolBar()->GetSize( &nWidth
946 ,&nHeight
947 );
0e320a79
DW
948
949 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
950 {
a885d89a 951 vPoint.x += nWidth;
0e320a79
DW
952 }
953 else
954 {
a885d89a
DW
955 // PM is backwards from windows
956 vPoint.y += nHeight;
0e320a79
DW
957 }
958 }
a885d89a
DW
959 return vPoint;
960} // end of wxFrame::GetClientAreaOrigin
0e320a79 961
f38374d0
DW
962// ----------------------------------------------------------------------------
963// tool/status bar stuff
964// ----------------------------------------------------------------------------
965
21802234 966#if wxUSE_TOOLBAR
f38374d0 967
a885d89a
DW
968wxToolBar* wxFrame::CreateToolBar(
969 long lStyle
970, wxWindowID vId
971, const wxString& rName
972)
0e320a79 973{
a885d89a
DW
974 if (wxFrameBase::CreateToolBar( lStyle
975 ,vId
976 ,rName
977 ))
0e320a79 978 {
0e320a79 979 PositionToolBar();
0e320a79 980 }
f38374d0 981 return m_frameToolBar;
a885d89a 982} // end of wxFrame::CreateToolBar
0e320a79
DW
983
984void wxFrame::PositionToolBar()
985{
a885d89a
DW
986 HWND hWndClient;
987 RECTL vRect;
988
989 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
990 ::WinQueryWindowRect(hWndClient, &vRect);
0e320a79 991
f38374d0 992#if wxUSE_STATUSBAR
a885d89a 993 if (GetStatusBar())
0e320a79 994 {
a885d89a
DW
995 int nStatusX;
996 int nStatusY;
997
998 GetStatusBar()->GetClientSize( &nStatusX
999 ,&nStatusY
1000 );
1001 // PM is backwards from windows
1002 vRect.yBottom += nStatusY;
0e320a79 1003 }
f38374d0 1004#endif // wxUSE_STATUSBAR
0e320a79 1005
f38374d0 1006 if ( GetToolBar() )
0e320a79 1007 {
a885d89a
DW
1008 int nToolbarWidth;
1009 int nToolbarHeight;
1010
1011 GetToolBar()->GetSize( &nToolbarWidth
1012 ,&nToolbarHeight
1013 );
0e320a79 1014
a885d89a 1015 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
0e320a79 1016 {
a885d89a 1017 nToolbarHeight = vRect.yBottom;
0e320a79
DW
1018 }
1019 else
1020 {
a885d89a 1021 nToolbarWidth = vRect.xRight;
21802234 1022 }
f38374d0 1023
a885d89a
DW
1024 //
1025 // Use the 'real' PM position here
1026 //
1027 GetToolBar()->SetSize( 0
1028 ,0
1029 ,nToolbarWidth
1030 ,nToolbarHeight
1031 ,wxSIZE_NO_ADJUSTMENTS
1032 );
21802234 1033 }
a885d89a 1034} // end of wxFrame::PositionToolBar
21802234
DW
1035#endif // wxUSE_TOOLBAR
1036
f38374d0
DW
1037// ----------------------------------------------------------------------------
1038// frame state (iconized/maximized/...)
1039// ----------------------------------------------------------------------------
1040
a885d89a 1041//
21802234
DW
1042// propagate our state change to all child frames: this allows us to emulate X
1043// Windows behaviour where child frames float independently of the parent one
1044// on the desktop, but are iconized/restored with it
a885d89a
DW
1045//
1046void wxFrame::IconizeChildFrames(
1047 bool bIconize
1048)
21802234 1049{
a885d89a
DW
1050 for (wxWindowList::Node* pNode = GetChildren().GetFirst();
1051 pNode;
1052 pNode = pNode->GetNext() )
21802234 1053 {
a885d89a 1054 wxWindow* pWin = pNode->GetData();
21802234 1055
a885d89a 1056 if (pWin->IsKindOf(CLASSINFO(wxFrame)) )
21802234 1057 {
a885d89a 1058 ((wxFrame *)pWin)->Iconize(bIconize);
0e320a79
DW
1059 }
1060 }
a885d89a 1061} // end of wxFrame::IconizeChildFrames
0e320a79 1062
21802234
DW
1063// ===========================================================================
1064// message processing
1065// ===========================================================================
1066
1067// ---------------------------------------------------------------------------
1068// preprocessing
1069// ---------------------------------------------------------------------------
a885d89a
DW
1070bool wxFrame::OS2TranslateMessage(
1071 WXMSG* pMsg
1072)
21802234 1073{
a885d89a 1074 if (wxWindow::OS2TranslateMessage(pMsg))
29435d81 1075 return TRUE;
a885d89a 1076 //
21802234 1077 // try the menu bar accels
a885d89a
DW
1078 //
1079 wxMenuBar* pMenuBar = GetMenuBar();
1080
1081 if (!pMenuBar )
21802234
DW
1082 return FALSE;
1083
a885d89a
DW
1084 const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
1085 return rAcceleratorTable.Translate(this, pMsg);
1086} // end of wxFrame::OS2TranslateMessage
21802234
DW
1087
1088// ---------------------------------------------------------------------------
1089// our private (non virtual) message handlers
1090// ---------------------------------------------------------------------------
21802234
DW
1091bool wxFrame::HandlePaint()
1092{
a885d89a
DW
1093 RECTL vRect;
1094
1095 if (::WinQueryUpdateRect(GetHwnd(), &vRect))
29435d81 1096 {
a885d89a 1097 if (m_bIconized)
29435d81 1098 {
a885d89a
DW
1099 //
1100 // Icons in PM are the same as "pointers"
1101 //
1102 HPOINTER hIcon;
29435d81 1103
a885d89a
DW
1104 if (m_icon.Ok())
1105 hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L);
1106 else
1107 hIcon = (HPOINTER)m_hDefaultIcon;
1108
1109 //
21802234
DW
1110 // Hold a pointer to the dc so long as the OnPaint() message
1111 // is being processed
a885d89a
DW
1112 //
1113 RECTL vRect2;
1114 HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2);
29435d81 1115
a885d89a 1116 //
29435d81 1117 // Erase background before painting or we get white background
a885d89a
DW
1118 //
1119 OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2);
29435d81 1120
a885d89a 1121 if (hIcon)
29435d81 1122 {
a885d89a
DW
1123 HWND hWndClient;
1124 RECTL vRect3;
21802234 1125
a885d89a
DW
1126 hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
1127 ::WinQueryWindowRect(hWndClient, &vRect3);
29435d81 1128
a885d89a
DW
1129 static const int nIconWidth = 32;
1130 static const int nIconHeight = 32;
1131 int nIconX = (int)((vRect3.xRight - nIconWidth)/2);
1132 int nIconY = (int)((vRect3.yBottom + nIconHeight)/2);
29435d81 1133
a885d89a 1134 ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL);
29435d81 1135 }
a885d89a 1136 ::WinEndPaint(hPs);
29435d81
DW
1137 return TRUE;
1138 }
1139 else
1140 {
1141 return wxWindow::HandlePaint();
1142 }
1143 }
1144 else
1145 {
1146 // nothing to paint - processed
1147 return TRUE;
1148 }
29435d81 1149 return FALSE;
a885d89a 1150} // end of wxFrame::HandlePaint
21802234 1151
a885d89a
DW
1152bool wxFrame::HandleSize(
1153 int nX
1154, int nY
1155, WXUINT nId
1156)
21802234 1157{
a885d89a 1158 bool bProcessed = FALSE;
21802234 1159
a885d89a 1160 switch (nId)
21802234 1161 {
a885d89a
DW
1162 case kSizeNormal:
1163 //
1164 // Only do it it if we were iconized before, otherwise resizing the
21802234
DW
1165 // parent frame has a curious side effect of bringing it under it's
1166 // children
a885d89a 1167 if (!m_bIconized )
21802234
DW
1168 break;
1169
a885d89a 1170 //
21802234 1171 // restore all child frames too
a885d89a 1172 //
21802234
DW
1173 IconizeChildFrames(FALSE);
1174
a885d89a 1175 //
21802234 1176 // fall through
a885d89a 1177 //
21802234 1178
a885d89a
DW
1179 case kSizeMax:
1180 m_bIconized = FALSE;
21802234
DW
1181 break;
1182
a885d89a
DW
1183 case kSizeMin:
1184 //
1185 // Iconize all child frames too
1186 //
21802234 1187 IconizeChildFrames(TRUE);
a885d89a 1188 m_bIconized = TRUE;
21802234
DW
1189 break;
1190 }
f38374d0 1191
a885d89a 1192 if (!m_bIconized)
21802234 1193 {
a885d89a 1194 //
29435d81 1195 // forward WM_SIZE to status bar control
a885d89a 1196 //
f38374d0
DW
1197#if wxUSE_NATIVE_STATUSBAR
1198 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
1199 {
a885d89a
DW
1200 wxSizeEvent vEvent( wxSize( nX
1201 ,nY
1202 )
1203 ,m_frameStatusBar->GetId()
1204 );
f38374d0 1205
a885d89a
DW
1206 vEvent.SetEventObject(m_frameStatusBar);
1207 m_frameStatusBar->OnSize(vEvent);
f38374d0
DW
1208 }
1209#endif // wxUSE_NATIVE_STATUSBAR
1210
21802234
DW
1211 PositionStatusBar();
1212 PositionToolBar();
a885d89a
DW
1213 wxSizeEvent vEvent( wxSize( nX
1214 ,nY
1215 )
1216 ,m_windowId
1217 );
21802234 1218
a885d89a
DW
1219 vEvent.SetEventObject(this);
1220 bProcessed = GetEventHandler()->ProcessEvent(vEvent);
21802234 1221 }
a885d89a
DW
1222 return bProcessed;
1223} // end of wxFrame::HandleSize
21802234 1224
a885d89a
DW
1225bool wxFrame::HandleCommand(
1226 WXWORD nId
1227, WXWORD nCmd
1228, WXHWND hControl
1229)
21802234 1230{
a885d89a 1231 if (hControl)
21802234 1232 {
a885d89a 1233 //
21802234 1234 // In case it's e.g. a toolbar.
a885d89a
DW
1235 //
1236 wxWindow* pWin = wxFindWinFromHandle(hControl);
1237
1238 if (pWin)
1239 return pWin->OS2Command( nCmd
1240 ,nId
1241 );
21802234
DW
1242 }
1243
a885d89a
DW
1244 //
1245 // Handle here commands from menus and accelerators
1246 //
1247 if (nCmd == 0 || nCmd == 1)
21802234 1248 {
a885d89a 1249 if (wxCurrentPopupMenu)
21802234 1250 {
a885d89a
DW
1251 wxMenu* pPopupMenu = wxCurrentPopupMenu;
1252
21802234
DW
1253 wxCurrentPopupMenu = NULL;
1254
a885d89a
DW
1255 return pPopupMenu->OS2Command( nCmd
1256 ,nId
1257 );
21802234
DW
1258 }
1259
a885d89a 1260 if (ProcessCommand(nId))
21802234
DW
1261 {
1262 return TRUE;
1263 }
1264 }
21802234 1265 return FALSE;
a885d89a 1266} // end of wxFrame::HandleCommand
21802234 1267
a885d89a
DW
1268bool wxFrame::HandleMenuSelect(
1269 WXWORD nItem
1270, WXWORD nFlags
1271, WXHMENU hMenu
1272)
21802234 1273{
a885d89a
DW
1274 int nMenuItem;
1275
1276 if (nFlags == 0xFFFF && hMenu == 0)
21802234 1277 {
a885d89a
DW
1278 //
1279 // Menu was removed from screen
1280 //
1281 nMenuItem = -1;
21802234 1282 }
a885d89a 1283 else if (!(nFlags & MIS_SUBMENU) && !(nFlags & MIS_SEPARATOR))
21802234 1284 {
a885d89a 1285 nMenuItem = nItem;
21802234 1286 }
21802234
DW
1287 else
1288 {
a885d89a
DW
1289 //
1290 // Don't give hints for separators (doesn't make sense) nor for the
21802234 1291 // items opening popup menus (they don't have them anyhow)
a885d89a 1292 //
21802234
DW
1293 return FALSE;
1294 }
a885d89a 1295 wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nMenuItem);
21802234 1296
a885d89a
DW
1297 vEvent.SetEventObject(this);
1298 return GetEventHandler()->ProcessEvent(vEvent);
1299} // end of wxFrame::HandleMenuSelect
21802234
DW
1300
1301// ---------------------------------------------------------------------------
1302// the window proc for wxFrame
1303// ---------------------------------------------------------------------------
1304
a885d89a
DW
1305MRESULT wxFrame::OS2WindowProc(
1306 WXUINT uMessage
1307, WXWPARAM wParam
1308, WXLPARAM lParam
1309)
21802234 1310{
a885d89a
DW
1311 MRESULT mRc = 0L;
1312 bool bProcessed = FALSE;
21802234 1313
a885d89a 1314 switch (uMessage)
21802234
DW
1315 {
1316 case WM_CLOSE:
a885d89a
DW
1317 //
1318 // If we can't close, tell the system that we processed the
21802234 1319 // message - otherwise it would close us
a885d89a
DW
1320 //
1321 bProcessed = !Close();
21802234
DW
1322 break;
1323
1324 case WM_COMMAND:
1325 {
a885d89a
DW
1326 WORD wId;
1327 WORD wCmd;
1328 WXHWND hWnd;
1329
1330 UnpackCommand( (WXWPARAM)wParam
1331 ,(WXLPARAM)lParam
1332 ,&wId
1333 ,&hWnd
1334 ,&wCmd
1335 );
1336 bProcessed = HandleCommand( wId
1337 ,wCmd
1338 ,(WXHWND)hWnd
1339 );
21802234
DW
1340 }
1341 break;
1342
1343 case WM_MENUSELECT:
1344 {
a885d89a
DW
1345 WXWORD wItem;
1346 WXWORD wFlags;
1347 WXHMENU hMenu;
1348
1349 UnpackMenuSelect( wParam
1350 ,lParam
1351 ,&wItem
1352 ,&wFlags
1353 ,&hMenu
1354 );
1355 bProcessed = HandleMenuSelect( wItem
1356 ,wFlags
1357 ,hMenu
1358 );
21802234
DW
1359 }
1360 break;
1361
1362 case WM_PAINT:
a885d89a 1363 bProcessed = HandlePaint();
21802234
DW
1364 break;
1365
a885d89a 1366 case CM_QUERYDRAGIMAGE:
21802234 1367 {
a885d89a
DW
1368 HPOINTER hIcon;
1369
1370 if (m_icon.Ok())
1371 hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L);
1372 else
1373 hIcon = (HPOINTER)m_hDefaultIcon;
1374 mRc = (MRESULT)hIcon;
1375 bProcessed = mRc != 0;
21802234
DW
1376 }
1377 break;
1378
1379 case WM_SIZE:
a885d89a 1380 bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam);
21802234
DW
1381 break;
1382 }
f38374d0 1383
a885d89a
DW
1384 if (!bProcessed )
1385 mRc = wxWindow::OS2WindowProc( uMessage
1386 ,wParam
1387 ,lParam
1388 );
f38374d0 1389 return (MRESULT)0;
a885d89a 1390} // wxFrame::OS2WindowProc
21802234 1391