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