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