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