]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/frame.cpp
Return non-const pointer from wxDataViewRendererBase::GetView().
[wxWidgets.git] / src / os2 / frame.cpp
index 85f39c89caf162b6ab3eeaf1843cedea0832dd12..6f200c9ddeb134ba9377bc15ff4f0a750bd2c73f 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        frame.cpp
+// Name:        src/os2/frame.cpp
 // Purpose:     wxFrame
 // Author:      David Webster
 // Modified by:
@@ -13,7 +13,6 @@
 #include "wx/wxprec.h"
 
 #ifndef WX_PRECOMP
-    #include "wx/defs.h"
     #include "wx/object.h"
     #include "wx/dynarray.h"
     #include "wx/list.h"
@@ -22,7 +21,6 @@
     #include "wx/intl.h"
     #include "wx/log.h"
     #include "wx/event.h"
-    #include "wx/setup.h"
     #include "wx/frame.h"
     #include "wx/menu.h"
     #include "wx/app.h"
     #include "wx/settings.h"
     #include "wx/dcclient.h"
     #include "wx/mdi.h"
+    #include "wx/toolbar.h"
+    #include "wx/statusbr.h"
+    #include "wx/menuitem.h"
 #endif // WX_PRECOMP
 
 #include "wx/os2/private.h"
 
-#if wxUSE_STATUSBAR
-    #include "wx/statusbr.h"
-    #include "wx/generic/statusbr.h"
-#endif // wxUSE_STATUSBAR
-
-#if wxUSE_TOOLBAR
-    #include "wx/toolbar.h"
-#endif // wxUSE_TOOLBAR
-
-#include "wx/menuitem.h"
-#include "wx/log.h"
-
 // ----------------------------------------------------------------------------
 // globals
 // ----------------------------------------------------------------------------
 
-extern wxList WXDLLEXPORT wxPendingDelete;
-
 #if wxUSE_MENUS_NATIVE
 extern wxMenu *wxCurrentPopupMenu;
 #endif
 
-extern void  wxAssociateWinWithHandle( HWND         hWnd
-                                      ,wxWindowOS2* pWin
-                                     );
-
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
@@ -69,8 +52,6 @@ BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
 END_EVENT_TABLE()
 
-IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
-
 // ============================================================================
 // implementation
 // ============================================================================
@@ -144,7 +125,8 @@ bool wxFrame::Create( wxWindow*       pParent,
 
 wxFrame::~wxFrame()
 {
-    m_isBeingDeleted = true;
+    SendDestroyEvent();
+
     DeleteAllBars();
 } // end of wxFrame::~wxFrame
 
@@ -242,13 +224,8 @@ wxStatusBar* wxFrame::OnCreateStatusBar(
                         ,nHeight
                        );
 
-    ::WinSetParent( pStatusBar->GetHWND()
-                   ,m_hFrame
-                   ,FALSE
-                  );
-    ::WinSetOwner( pStatusBar->GetHWND()
-                  ,m_hFrame
-                 );
+    ::WinSetParent( pStatusBar->GetHWND(), m_hFrame, FALSE );
+    ::WinSetOwner( pStatusBar->GetHWND(), m_hFrame);
     //
     // to show statusbar
     //
@@ -302,7 +279,7 @@ void wxFrame::PositionStatusBar()
         {
             vError = ::WinGetLastError(vHabmain);
             sError = wxPMErrorToStr(vError);
-            wxLogError(_T("Error setting parent for StautsBar. Error: %s\n"), sError.c_str());
+            wxLogError(wxT("Error setting parent for StatusBar. Error: %s\n"), sError.c_str());
             return;
         }
     }
@@ -310,24 +287,15 @@ void wxFrame::PositionStatusBar()
 #endif // wxUSE_STATUSBAR
 
 #if wxUSE_TOOLBAR
-wxToolBar* wxFrame::OnCreateToolBar(
-  long                              lStyle
-, wxWindowID                        vId
-, const wxString&                   rsName
-)
+wxToolBar* wxFrame::OnCreateToolBar( long lStyle, wxWindowID vId, const wxString& rsName )
 {
     wxToolBar*                      pToolBar = wxFrameBase::OnCreateToolBar( lStyle
                                                                             ,vId
                                                                             ,rsName
                                                                            );
 
-    ::WinSetParent( pToolBar->GetHWND()
-                   ,m_hFrame
-                   ,FALSE
-                  );
-    ::WinSetOwner( pToolBar->GetHWND()
-                  ,m_hFrame
-                 );
+    ::WinSetParent( pToolBar->GetHWND(), m_hFrame, FALSE);
+    ::WinSetOwner( pToolBar->GetHWND(), m_hFrame);
     return pToolBar;
 } // end of WinGuiBase_CFrame::OnCreateToolBar
 #endif
@@ -435,14 +403,14 @@ void wxFrame::InternalSetMenuBar()
     {
         vError = ::WinGetLastError(vHabmain);
         sError = wxPMErrorToStr(vError);
-        wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError.c_str());
+        wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str());
     }
 
     if (!::WinSetOwner(m_hMenu, m_hFrame))
     {
         vError = ::WinGetLastError(vHabmain);
         sError = wxPMErrorToStr(vError);
-        wxLogError(_T("Error setting parent for submenu. Error: %s\n"), sError.c_str());
+        wxLogError(wxT("Error setting parent for submenu. Error: %s\n"), sError.c_str());
     }
     ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
 } // end of wxFrame::InternalSetMenuBar
@@ -464,7 +432,7 @@ void wxFrame::OnSysColourChanged(
         wxSysColourChangedEvent     vEvent2;
 
         vEvent2.SetEventObject(m_frameStatusBar);
-        m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2);
+        m_frameStatusBar->HandleWindowEvent(vEvent2);
     }
 #endif //wxUSE_STATUSBAR
 
@@ -530,7 +498,7 @@ bool wxFrame::ShowFullScreen( bool bShow, long lStyle )
         if ((lStyle & wxFULLSCREEN_NOSTATUSBAR) && pTheStatusBar)
         {
             m_nFsStatusBarFields = pTheStatusBar->GetFieldsCount();
-            SetStatusBar((wxStatusBar*) NULL);
+            SetStatusBar(NULL);
             delete pTheStatusBar;
         }
         else
@@ -580,7 +548,7 @@ bool wxFrame::ShowFullScreen( bool bShow, long lStyle )
         ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
         nWidth = vRect.xRight - vRect.xLeft;
         //
-        // Rmember OS/2 is backwards!
+        // Remember OS/2 is backwards!
         //
         nHeight = vRect.yTop - vRect.yBottom;
 
@@ -601,7 +569,7 @@ bool wxFrame::ShowFullScreen( bool bShow, long lStyle )
         wxSize sz( nWidth, nHeight );
         wxSizeEvent vEvent( sz, GetId() );
 
-        GetEventHandler()->ProcessEvent(vEvent);
+        HandleWindowEvent(vEvent);
         return true;
     }
     else
@@ -726,7 +694,7 @@ void wxFrame::PositionToolBar()
                       ,&vTHeight
                      );
 
-    if (pToolBar->GetWindowStyleFlag() & wxTB_HORIZONTAL)
+    if (pToolBar->GetWindowStyleFlag() & wxTB_TOP)
     {
         vWidth = (wxCoord)(vRect.xRight - vRect.xLeft);
         pToolBar->SetSize( vRect.xLeft - vFRect.xLeft
@@ -735,6 +703,38 @@ void wxFrame::PositionToolBar()
                           ,vTHeight
                          );
     }
+    else if (pToolBar->GetWindowStyleFlag() & wxTB_BOTTOM)
+    {
+        wxCoord                     vSwidth = 0;
+        wxCoord                     vSheight = 0;
+
+        if (m_frameStatusBar)
+            m_frameStatusBar->GetSize( &vSwidth
+                                      ,&vSheight
+                                     );
+        vWidth = (wxCoord)(vRect.xRight - vRect.xLeft);
+        pToolBar->SetSize( vRect.xLeft - vFRect.xLeft
+                          ,vFRect.yTop - vRect.yBottom - vTHeight - vSheight
+                          ,vWidth
+                          ,vTHeight
+                         );
+    }
+    else if (pToolBar->GetWindowStyleFlag() & wxTB_LEFT)
+    {
+        wxCoord                     vSwidth = 0;
+        wxCoord                     vSheight = 0;
+
+        if (m_frameStatusBar)
+            m_frameStatusBar->GetSize( &vSwidth
+                                      ,&vSheight
+                                     );
+        vHeight = (wxCoord)(vRect.yTop - vRect.yBottom);
+        pToolBar->SetSize( vRect.xLeft - vRect.xLeft
+                          ,vPos.y
+                          ,vTWidth
+                          ,vHeight - vSheight
+                         );
+    }
     else
     {
         wxCoord                     vSwidth = 0;
@@ -745,7 +745,7 @@ void wxFrame::PositionToolBar()
                                       ,&vSheight
                                      );
         vHeight = (wxCoord)(vRect.yTop - vRect.yBottom);
-        pToolBar->SetSize( vRect.xLeft - vFRect.xLeft
+        pToolBar->SetSize( vRect.xRight - vFRect.xLeft - vTWidth
                           ,vPos.y
                           ,vTWidth
                           ,vHeight - vSheight
@@ -852,7 +852,7 @@ bool wxFrame::HandlePaint()
             const wxIcon&           vIcon = GetIcon();
             HPOINTER                hIcon;
 
-            if (vIcon.Ok())
+            if (vIcon.IsOk())
                 hIcon = (HPOINTER)::WinSendMsg(m_hFrame, WM_QUERYICON, 0L, 0L);
             else
                 hIcon = (HPOINTER)m_hDefaultIcon;
@@ -875,17 +875,12 @@ bool wxFrame::HandlePaint()
 
                 ::WinQueryWindowRect(GetHwnd(), &vRect3);
 
-#if !(defined(__WATCOMC__) && __WATCOMC__ < 1240 )
-// Open Watcom 1.3 had incomplete headers
-// that's reported and should be fixed for OW 1.4
-
                 static const int    nIconWidth = 32;
                 static const int    nIconHeight = 32;
                 int                 nIconX = (int)((vRect3.xRight - nIconWidth)/2);
                 int                 nIconY = (int)((vRect3.yBottom + nIconHeight)/2);
 
                 ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL);
-#endif
             }
             ::WinEndPaint(hPs);
         }
@@ -1055,11 +1050,11 @@ bool wxFrame::HandleMenuSelect( WXWORD nItem,
             wxMenuEvent                     vEvent(wxEVT_MENU_HIGHLIGHT, nItem);
 
             vEvent.SetEventObject(this);
-            GetEventHandler()->ProcessEvent(vEvent); // return value would be ignored by PM
+            HandleWindowEvent(vEvent); // return value would be ignored by PM
         }
         else
         {
-            DoGiveHelp(wxEmptyString, false);
+            DoGiveHelp(wxEmptyString, true);
             return false;
         }
     }
@@ -1128,20 +1123,34 @@ MRESULT EXPENTRY wxFrameMainWndProc( HWND   hWnd,
                 {
                     if(pWnd->m_hWnd && pSWP[i].hwnd == pWnd->m_hWnd)
                     {
-                        if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_HORIZONTAL)
+                        if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_TOP)
                         {
                             pSWP[i].x    = vRectl.xLeft;
                             pSWP[i].y    = vRectl.yBottom + nHeight;
                             pSWP[i].cx   = vRectl.xRight - vRectl.xLeft;
                             pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
                         }
-                        else
+                        else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_BOTTOM)
+                        {
+                            pSWP[i].x    = vRectl.xLeft;
+                            pSWP[i].y    = vRectl.yBottom + nHeight + nHeight2;
+                            pSWP[i].cx   = vRectl.xRight - vRectl.xLeft;
+                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - (nHeight + nHeight2);
+                         }
+                        else if (pWnd->m_frameToolBar && pWnd->m_frameToolBar->GetWindowStyleFlag() & wxTB_LEFT)
                         {
                             pSWP[i].x    = vRectl.xLeft + nWidth;
                             pSWP[i].y    = vRectl.yBottom + nHeight;
                             pSWP[i].cx   = vRectl.xRight - (vRectl.xLeft + nWidth);
                             pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - nHeight;
                         }
+                        else
+                        {
+                            pSWP[i].x    = vRectl.xLeft;
+                            pSWP[i].y    = vRectl.yBottom + nHeight;
+                            pSWP[i].cx   = vRectl.xRight - (vRectl.xLeft + nWidth);
+                            pSWP[i].cy   = vRectl.yTop - vRectl.yBottom - nHeight;
+                        }
                         pSWP[i].fl   = SWP_SIZE | SWP_MOVE | SWP_SHOW;
                         pSWP[i].hwndInsertBehind = HWND_TOP;
                     }
@@ -1293,7 +1302,7 @@ MRESULT wxFrame::OS2WindowProc( WXUINT uMessage,
                 const wxIcon&           vIcon = GetIcon();
                 HPOINTER                hIcon;
 
-                if (vIcon.Ok())
+                if (vIcon.IsOk())
                     hIcon = (HPOINTER)::WinSendMsg(GetHWND(), WM_QUERYICON, 0L, 0L);
                 else
                     hIcon = (HPOINTER)m_hDefaultIcon;
@@ -1369,20 +1378,3 @@ wxWindow* wxFrame::GetClient()
     return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
 }
 
-void wxFrame::SendSizeEvent()
-{
-    if (!m_bIconized)
-    {
-        RECTL                       vRect = wxGetWindowRect(GetHwnd());
-
-        ::WinPostMsg( GetHwnd()
-                     ,WM_SIZE
-                     ,MPFROM2SHORT( vRect.xRight - vRect.xLeft
-                                   ,vRect.xRight - vRect.xLeft
-                                  )
-                     ,MPFROM2SHORT( vRect.yTop - vRect.yBottom
-                                   ,vRect.yTop - vRect.yBottom
-                                  )
-                    );
-    }
-}