]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/frame.cpp
DJGPP compilation
[wxWidgets.git] / src / os2 / frame.cpp
index a3b3f82dd018d9bb034c6c744c1c6b50ae83cfdc..bc13037ef5a20b92c614c51ccbb5b44e116b276c 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        frame.cpp
 /////////////////////////////////////////////////////////////////////////////
 // Name:        frame.cpp
-// Purpose:     wxFrameOS2
+// Purpose:     wxFrame
 // Author:      David Webster
 // Modified by:
 // Created:     10/27/99
 // Author:      David Webster
 // Modified by:
 // Created:     10/27/99
 extern wxWindowList wxModelessWindows;
 extern wxList WXDLLEXPORT wxPendingDelete;
 extern wxChar wxFrameClassName[];
 extern wxWindowList wxModelessWindows;
 extern wxList WXDLLEXPORT wxPendingDelete;
 extern wxChar wxFrameClassName[];
+
+#if wxUSE_MENUS_NATIVE
 extern wxMenu *wxCurrentPopupMenu;
 extern wxMenu *wxCurrentPopupMenu;
+#endif
 
 
-extern void  wxAssociateWinWithHandle( HWND      hWnd
-                                      ,wxWindow* pWin
+extern void  wxAssociateWinWithHandle( HWND         hWnd
+                                      ,wxWindowOS2* pWin
                                      );
 
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 
                                      );
 
 // ----------------------------------------------------------------------------
 // event tables
 // ----------------------------------------------------------------------------
 
-BEGIN_EVENT_TABLE(wxFrameOS2, wxFrameBase)
-    EVT_ACTIVATE(wxFrameOS2::OnActivate)
-    EVT_SYS_COLOUR_CHANGED(wxFrameOS2::OnSysColourChanged)
+BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
+    EVT_ACTIVATE(wxFrame::OnActivate)
+    EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
 END_EVENT_TABLE()
 
 END_EVENT_TABLE()
 
-IMPLEMENT_DYNAMIC_CLASS(wxFrameOS2, wxWindow)
-
-#ifndef __WXUNIVERSAL__
-IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxFrameMSW)
-#endif
+IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
 
 // ============================================================================
 // implementation
 
 // ============================================================================
 // implementation
@@ -84,9 +83,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxFrameMSW)
 #if wxUSE_STATUSBAR
 
 #if wxUSE_NATIVE_STATUSBAR
 #if wxUSE_STATUSBAR
 
 #if wxUSE_NATIVE_STATUSBAR
-    bool wxFrameOS2::m_bUseNativeStatusBar = TRUE;
+    bool wxFrame::m_bUseNativeStatusBar = TRUE;
 #else
 #else
-    bool wxFrameOS2::m_bUseNativeStatusBar = FALSE;
+    bool wxFrame::m_bUseNativeStatusBar = FALSE;
 #endif
 
 #endif //wxUSE_STATUSBAR
 #endif
 
 #endif //wxUSE_STATUSBAR
@@ -95,7 +94,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxFrameMSW)
 // creation/destruction
 // ----------------------------------------------------------------------------
 
 // creation/destruction
 // ----------------------------------------------------------------------------
 
-void wxFrameOS2::Init()
+void wxFrame::Init()
 {
     m_bIconized = FALSE;
 
 {
     m_bIconized = FALSE;
 
@@ -109,6 +108,7 @@ void wxFrameOS2::Init()
     m_nFsStatusBarHeight = 0;
     m_nFsToolBarHeight   = 0;
     m_bFsIsMaximized     = FALSE;
     m_nFsStatusBarHeight = 0;
     m_nFsToolBarHeight   = 0;
     m_bFsIsMaximized     = FALSE;
+    m_bWasMinimized      = FALSE;
     m_bFsIsShowing       = FALSE;
     m_bIsShown           = FALSE;
     m_pWinLastFocused    = (wxWindow *)NULL;
     m_bFsIsShowing       = FALSE;
     m_bIsShown           = FALSE;
     m_pWinLastFocused    = (wxWindow *)NULL;
@@ -129,9 +129,9 @@ void wxFrameOS2::Init()
     memset(&m_vSwpVScroll, 0, sizeof(SWP));
     memset(&m_vSwpStatusBar, 0, sizeof(SWP));
     memset(&m_vSwpToolBar, 0, sizeof(SWP));
     memset(&m_vSwpVScroll, 0, sizeof(SWP));
     memset(&m_vSwpStatusBar, 0, sizeof(SWP));
     memset(&m_vSwpToolBar, 0, sizeof(SWP));
-} // end of wxFrameOS2::Init
+} // end of wxFrame::Init
 
 
-bool wxFrameOS2::Create(
+bool wxFrame::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
 , const wxString&                   rsTitle
   wxWindow*                         pParent
 , wxWindowID                        vId
 , const wxString&                   rsTitle
@@ -191,9 +191,9 @@ bool wxFrameOS2::Create(
         wxModelessWindows.Append(this);
     }
     return(bOk);
         wxModelessWindows.Append(this);
     }
     return(bOk);
-} // end of wxFrameOS2::Create
+} // end of wxFrame::Create
 
 
-wxFrameOS2::~wxFrameOS2()
+wxFrame::~wxFrame()
 {
     m_isBeingDeleted = TRUE;
 
 {
     m_isBeingDeleted = TRUE;
 
@@ -235,12 +235,59 @@ wxFrameOS2::~wxFrameOS2()
                              );
         }
     }
                              );
         }
     }
-} // end of wxFrameOS2::~wxFrame
+} // end of wxFrame::~wxFrame
+
+//
+//  IF we have child controls in the Frame's client we need to alter
+//  the y position, because, OS/2 controls are positioned relative to
+//  wxWindows orgin (top left) not the OS/2 origin (bottom left)
+void wxFrame::AlterChildPos()
+{
+    //
+    // OS/2 is the only OS concerned about this
+    //
+    wxWindow*                               pChild = NULL;
+    wxControl*                              pCtrl = NULL;
+    RECTL                                   vRect;
+    SWP                                     vSwp;
+
+    ::WinQueryWindowRect(GetHwnd(), &vRect);
+    for (wxWindowList::Node* pNode = GetChildren().GetFirst();
+         pNode;
+         pNode = pNode->GetNext())
+    {
+        wxWindow*                   pChild = pNode->GetData();
+
+        ::WinQueryWindowPos(pChild->GetHWND(), &vSwp);
+        vSwp.y += (vRect.yTop - m_vSwpClient.cy);
+        if (pChild->IsKindOf(CLASSINFO(wxControl)))
+        {
+            pCtrl = wxDynamicCast(pChild, wxControl);
+            //
+            // Must deal with controls that have margins like ENTRYFIELD.  The SWP
+            // struct of such a control will have and origin offset from its intended
+            // position by the width of the margins.
+            //
+            vSwp.y -= pCtrl->GetYComp();
+            vSwp.x -= pCtrl->GetXComp();
+        }
+        ::WinSetWindowPos( pChild->GetHWND()
+                          ,HWND_TOP
+                          ,vSwp.x
+                          ,vSwp.y
+                          ,vSwp.cx
+                          ,vSwp.cy
+                          ,SWP_MOVE
+                         );
+        ::WinQueryWindowPos(pChild->GetHWND(), &vSwp);
+        pChild = NULL;
+    }
+} // end of wxFrame::AlterChildPos
 
 //
 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
 //
 
 //
 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
 //
-void wxFrameOS2::DoGetClientSize(
+void wxFrame::DoGetClientSize(
   int*                              pX
 , int*                              pY
 ) const
   int*                              pX
 , int*                              pY
 ) const
@@ -258,13 +305,13 @@ void wxFrameOS2::DoGetClientSize(
         *pX = vRect.xRight - vRect.xLeft;
     if (pY)
         *pY = vRect.yTop - vRect.yBottom;
         *pX = vRect.xRight - vRect.xLeft;
     if (pY)
         *pY = vRect.yTop - vRect.yBottom;
-} // end of wxFrameOS2::DoGetClientSize
+} // end of wxFrame::DoGetClientSize
 
 //
 // Set the client size (i.e. leave the calculation of borders etc.
 // to wxWindows)
 //
 
 //
 // Set the client size (i.e. leave the calculation of borders etc.
 // to wxWindows)
 //
-void wxFrameOS2::DoSetClientSize(
+void wxFrame::DoSetClientSize(
   int                               nWidth
 , int                               nHeight
 )
   int                               nWidth
 , int                               nHeight
 )
@@ -281,25 +328,23 @@ void wxFrameOS2::DoSetClientSize(
     // and the client area; add this to the new client size to move the
     // window.  Remember OS/2's backwards y coord system!
     //
     // and the client area; add this to the new client size to move the
     // window.  Remember OS/2's backwards y coord system!
     //
-    int                             nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
-    int                             nActualHeight = vRect2.yTop + vRect2.yTop - vRect.yTop + nHeight;
+    int                             nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight;
+    int                             nActualHeight = vRect2.yTop + vRect2.yTop - vRect.yTop;
 
 #if wxUSE_STATUSBAR
 
 #if wxUSE_STATUSBAR
-    if ( GetStatusBar() )
-    {
-        int                         nStatusX;
-        int                         nStatusY;
+    wxStatusBar*                    pStatusBar = GetStatusBar();
 
 
-        GetStatusBar()->GetClientSize( &nStatusX
-                                      ,&nStatusY
-                                     );
-        nActualHeight += nStatusY;
+    if (pStatusBar && pStatusBar->IsShown())
+    {
+        nActualHeight += pStatusBar->GetSize().y;
     }
     }
+
 #endif // wxUSE_STATUSBAR
 
     wxPoint                         vPoint(GetClientAreaOrigin());
 #endif // wxUSE_STATUSBAR
 
     wxPoint                         vPoint(GetClientAreaOrigin());
-    nActualWidth  += vPoint.y;
-    nActualHeight += vPoint.x;
+
+    nActualWidth  += vPoint.x;
+    nActualHeight += vPoint.y;
 
     POINTL                          vPointl;
 
 
     POINTL                          vPointl;
 
@@ -322,9 +367,9 @@ void wxFrameOS2::DoSetClientSize(
                                           );
     vEvent.SetEventObject(this);
     GetEventHandler()->ProcessEvent(vEvent);
                                           );
     vEvent.SetEventObject(this);
     GetEventHandler()->ProcessEvent(vEvent);
-} // end of wxFrameOS2::DoSetClientSize
+} // end of wxFrame::DoSetClientSize
 
 
-void wxFrameOS2::DoGetSize(
+void wxFrame::DoGetSize(
   int*                              pWidth
 , int*                              pHeight
 ) const
   int*                              pWidth
 , int*                              pHeight
 ) const
@@ -334,9 +379,9 @@ void wxFrameOS2::DoGetSize(
     ::WinQueryWindowRect(m_hFrame, &vRect);
     *pWidth = vRect.xRight - vRect.xLeft;
     *pHeight = vRect.yTop - vRect.yBottom;
     ::WinQueryWindowRect(m_hFrame, &vRect);
     *pWidth = vRect.xRight - vRect.xLeft;
     *pHeight = vRect.yTop - vRect.yBottom;
-} // end of wxFrameOS2::DoGetSize
+} // end of wxFrame::DoGetSize
 
 
-void wxFrameOS2::DoGetPosition(
+void wxFrame::DoGetPosition(
   int*                              pX
 , int*                              pY
 ) const
   int*                              pX
 , int*                              pY
 ) const
@@ -348,27 +393,37 @@ void wxFrameOS2::DoGetPosition(
 
     *pX = vRect.xRight - vRect.xLeft;
     *pY = vRect.yTop - vRect.yBottom;
 
     *pX = vRect.xRight - vRect.xLeft;
     *pY = vRect.yTop - vRect.yBottom;
-} // end of wxFrameOS2::DoGetPosition
+} // end of wxFrame::DoGetPosition
 
 // ----------------------------------------------------------------------------
 // variations around ::ShowWindow()
 // ----------------------------------------------------------------------------
 
 
 // ----------------------------------------------------------------------------
 // variations around ::ShowWindow()
 // ----------------------------------------------------------------------------
 
-void wxFrameOS2::DoShowWindow(
+void wxFrame::DoShowWindow(
   int                               bShowCmd
 )
 {
     ::WinShowWindow(m_hFrame, (BOOL)bShowCmd);
     m_bIconized = bShowCmd == SWP_MINIMIZE;
   int                               bShowCmd
 )
 {
     ::WinShowWindow(m_hFrame, (BOOL)bShowCmd);
     m_bIconized = bShowCmd == SWP_MINIMIZE;
-} // end of wxFrameOS2::DoShowWindow
+} // end of wxFrame::DoShowWindow
 
 
-bool wxFrameOS2::Show(
+bool wxFrame::Show(
   bool                              bShow
 )
 {
   bool                              bShow
 )
 {
+    int                             nShowCmd;
     SWP                             vSwp;
 
     SWP                             vSwp;
 
-    DoShowWindow((int)bShow);
+    if (bShow)
+    {
+        nShowCmd = SWP_SHOW;
+    }
+    else // hide
+    {
+        nShowCmd = SWP_HIDE;
+    }
+
+    DoShowWindow(nShowCmd);
 
     if (bShow)
     {
 
     if (bShow)
     {
@@ -376,6 +431,7 @@ bool wxFrameOS2::Show(
 
         ::WinQueryWindowPos(m_hFrame, &vSwp);
         m_bIconized = vSwp.fl & SWP_MINIMIZE;
 
         ::WinQueryWindowPos(m_hFrame, &vSwp);
         m_bIconized = vSwp.fl & SWP_MINIMIZE;
+        ::WinQueryWindowPos(m_hWnd, &m_vSwpClient);
         ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
         ::WinEnableWindow(m_hFrame, TRUE);
         vEvent.SetEventObject(this);
         ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
         ::WinEnableWindow(m_hFrame, TRUE);
         vEvent.SetEventObject(this);
@@ -405,27 +461,27 @@ bool wxFrameOS2::Show(
         }
     }
     return TRUE;
         }
     }
     return TRUE;
-} // end of wxFrameOS2::Show
+} // end of wxFrame::Show
 
 
-void wxFrameOS2::Iconize(
+void wxFrame::Iconize(
   bool                              bIconize
 )
 {
     DoShowWindow(bIconize ? SWP_MINIMIZE : SWP_RESTORE);
   bool                              bIconize
 )
 {
     DoShowWindow(bIconize ? SWP_MINIMIZE : SWP_RESTORE);
-} // end of wxFrameOS2::Iconize
+} // end of wxFrame::Iconize
 
 
-void wxFrameOS2::Maximize(
+void wxFrame::Maximize(
   bool                              bMaximize)
 {
     DoShowWindow(bMaximize ? SWP_MAXIMIZE : SWP_RESTORE);
   bool                              bMaximize)
 {
     DoShowWindow(bMaximize ? SWP_MAXIMIZE : SWP_RESTORE);
-} // end of wxFrameOS2::Maximize
+} // end of wxFrame::Maximize
 
 
-void wxFrameOS2::Restore()
+void wxFrame::Restore()
 {
     DoShowWindow(SWP_RESTORE);
 {
     DoShowWindow(SWP_RESTORE);
-} // end of wxFrameOS2::Restore
+} // end of wxFrame::Restore
 
 
-bool wxFrameOS2::IsIconized() const
+bool wxFrame::IsIconized() const
 {
     SWP                             vSwp;
 
 {
     SWP                             vSwp;
 
@@ -436,19 +492,19 @@ bool wxFrameOS2::IsIconized() const
     else
         ((wxFrame*)this)->m_bIconized = FALSE;
     return m_bIconized;
     else
         ((wxFrame*)this)->m_bIconized = FALSE;
     return m_bIconized;
-} // end of wxFrameOS2::IsIconized
+} // end of wxFrame::IsIconized
 
 // Is it maximized?
 
 // Is it maximized?
-bool wxFrameOS2::IsMaximized() const
+bool wxFrame::IsMaximized() const
 {
     SWP                             vSwp;
     bool                            bIconic;
 
     ::WinQueryWindowPos(m_hFrame, &vSwp);
     return (vSwp.fl & SWP_MAXIMIZE);
 {
     SWP                             vSwp;
     bool                            bIconic;
 
     ::WinQueryWindowPos(m_hFrame, &vSwp);
     return (vSwp.fl & SWP_MAXIMIZE);
-} // end of wxFrameOS2::IsMaximized
+} // end of wxFrame::IsMaximized
 
 
-void wxFrameOS2::SetIcon(
+void wxFrame::SetIcon(
   const wxIcon&                     rIcon
 )
 {
   const wxIcon&                     rIcon
 )
 {
@@ -467,10 +523,10 @@ void wxFrameOS2::SetIcon(
                      ,(MPARAM)0
                     );
     }
                      ,(MPARAM)0
                     );
     }
-} // end of wxFrameOS2::SetIcon
+} // end of wxFrame::SetIcon
 
 #if wxUSE_STATUSBAR
 
 #if wxUSE_STATUSBAR
-wxStatusBar* wxFrameOS2::OnCreateStatusBar(
+wxStatusBar* wxFrame::OnCreateStatusBar(
   int                               nNumber
 , long                              lulStyle
 , wxWindowID                        vId
   int                               nNumber
 , long                              lulStyle
 , wxWindowID                        vId
@@ -505,9 +561,9 @@ wxStatusBar* wxFrameOS2::OnCreateStatusBar(
         ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
 
     return pStatusBar;
         ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
 
     return pStatusBar;
-} // end of wxFrameOS2::OnCreateStatusBar
+} // end of wxFrame::OnCreateStatusBar
 
 
-void wxFrameOS2::PositionStatusBar()
+void wxFrame::PositionStatusBar()
 {
     SWP                             vSwp;
     ERRORID                         vError;
 {
     SWP                             vSwp;
     ERRORID                         vError;
@@ -519,6 +575,7 @@ void wxFrameOS2::PositionStatusBar()
     if (m_frameStatusBar)
     {
         int                         nWidth;
     if (m_frameStatusBar)
     {
         int                         nWidth;
+        int                         nY;
         int                         nStatbarWidth;
         int                         nStatbarHeight;
         HWND                        hWndClient;
         int                         nStatbarWidth;
         int                         nStatbarHeight;
         HWND                        hWndClient;
@@ -526,21 +583,24 @@ void wxFrameOS2::PositionStatusBar()
         RECTL                       vFRect;
 
         ::WinQueryWindowRect(m_hFrame, &vRect);
         RECTL                       vFRect;
 
         ::WinQueryWindowRect(m_hFrame, &vRect);
+        nY = vRect.yTop;
         ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2);
         vFRect = vRect;
         ::WinCalcFrameRect(m_hFrame, &vRect, TRUE);
         nWidth = vRect.xRight - vRect.xLeft;
         ::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2);
         vFRect = vRect;
         ::WinCalcFrameRect(m_hFrame, &vRect, TRUE);
         nWidth = vRect.xRight - vRect.xLeft;
+        nY = nY - (vRect.yBottom - vFRect.yBottom);
 
         m_frameStatusBar->GetSize( &nStatbarWidth
                                   ,&nStatbarHeight
                                  );
 
 
         m_frameStatusBar->GetSize( &nStatbarWidth
                                   ,&nStatbarHeight
                                  );
 
+        nY= nY - nStatbarHeight;
         //
         // Since we wish the status bar to be directly under the client area,
         // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
         //
         m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft
         //
         // Since we wish the status bar to be directly under the client area,
         // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
         //
         m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft
-                                  ,vRect.yBottom - vFRect.yBottom
+                                  ,nY
                                   ,nWidth
                                   ,nStatbarHeight
                                  );
                                   ,nWidth
                                   ,nStatbarHeight
                                  );
@@ -552,19 +612,20 @@ void wxFrameOS2::PositionStatusBar()
             return;
         }
     }
             return;
         }
     }
-} // end of wxFrameOS2::PositionStatusBar
+} // end of wxFrame::PositionStatusBar
 #endif // wxUSE_STATUSBAR
 
 #endif // wxUSE_STATUSBAR
 
-void wxFrameOS2::DetachMenuBar()
+#if wxUSE_MENUS_NATIVE
+void wxFrame::DetachMenuBar()
 {
     if (m_frameMenuBar)
     {
         m_frameMenuBar->Detach();
         m_frameMenuBar = NULL;
     }
 {
     if (m_frameMenuBar)
     {
         m_frameMenuBar->Detach();
         m_frameMenuBar = NULL;
     }
-} // end of wxFrameOS2::DetachMenuBar
+} // end of wxFrame::DetachMenuBar
 
 
-void wxFrameOS2::SetMenuBar(
+void wxFrame::SetMenuBar(
   wxMenuBar*                        pMenuBar
 )
 {
   wxMenuBar*                        pMenuBar
 )
 {
@@ -615,9 +676,48 @@ void wxFrameOS2::SetMenuBar(
         m_frameMenuBar = pMenuBar;
         pMenuBar->Attach((wxFrame*)this);
     }
         m_frameMenuBar = pMenuBar;
         pMenuBar->Attach((wxFrame*)this);
     }
-} // end of wxFrameOS2::SetMenuBar
+} // end of wxFrame::SetMenuBar
 
 
-void wxFrameOS2::InternalSetMenuBar()
+void wxFrame::AttachMenuBar(
+  wxMenuBar*                        pMenubar
+)
+{
+    wxFrameBase::AttachMenuBar(pMenubar);
+
+    m_frameMenuBar = pMenubar;
+
+    if (!pMenubar)
+    {
+        //
+        // Actually remove the menu from the frame
+        //
+        m_hMenu = (WXHMENU)0;
+        InternalSetMenuBar();
+    }
+    else // Set new non NULL menu bar
+    {
+        //
+        // Can set a menubar several times.
+        //
+        if (pMenubar->GetHMenu())
+        {
+            m_hMenu = pMenubar->GetHMenu();
+        }
+        else
+        {
+            if (pMenubar->IsAttached())
+                pMenubar->Detach();
+
+            m_hMenu = pMenubar->Create();
+
+            if (!m_hMenu)
+                return;
+        }
+        InternalSetMenuBar();
+    }
+} // end of wxFrame::AttachMenuBar
+
+void wxFrame::InternalSetMenuBar()
 {
     ERRORID                         vError;
     wxString                        sError;
 {
     ERRORID                         vError;
     wxString                        sError;
@@ -638,12 +738,13 @@ void wxFrameOS2::InternalSetMenuBar()
         wxLogError("Error setting parent for submenu. Error: %s\n", sError);
     }
     ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
         wxLogError("Error setting parent for submenu. Error: %s\n", sError);
     }
     ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
-} // end of wxFrameOS2::InternalSetMenuBar
+} // end of wxFrame::InternalSetMenuBar
+#endif // wxUSE_MENUS_NATIVE
 
 //
 // Responds to colour changes, and passes event on to children
 //
 
 //
 // Responds to colour changes, and passes event on to children
 //
-void wxFrameOS2::OnSysColourChanged(
+void wxFrame::OnSysColourChanged(
   wxSysColourChangedEvent&          rEvent
 )
 {
   wxSysColourChangedEvent&          rEvent
 )
 {
@@ -664,10 +765,10 @@ void wxFrameOS2::OnSysColourChanged(
     // Propagate the event to the non-top-level children
     //
     wxWindow::OnSysColourChanged(rEvent);
     // Propagate the event to the non-top-level children
     //
     wxWindow::OnSysColourChanged(rEvent);
-} // end of wxFrameOS2::OnSysColourChanged
+} // end of wxFrame::OnSysColourChanged
 
 // Pass TRUE to show full screen, FALSE to restore.
 
 // Pass TRUE to show full screen, FALSE to restore.
-bool wxFrameOS2::ShowFullScreen(
+bool wxFrame::ShowFullScreen(
   bool                              bShow
 , long                              lStyle
 )
   bool                              bShow
 , long                              lStyle
 )
@@ -681,11 +782,11 @@ bool wxFrameOS2::ShowFullScreen(
         m_lFsStyle = lStyle;
 
 #if wxUSE_TOOLBAR
         m_lFsStyle = lStyle;
 
 #if wxUSE_TOOLBAR
-           wxToolBar*                  pTheToolBar = GetToolBar();
+        wxToolBar*                  pTheToolBar = GetToolBar();
 #endif //wxUSE_TOOLBAR
 
 #if wxUSE_STATUSBAR
 #endif //wxUSE_TOOLBAR
 
 #if wxUSE_STATUSBAR
-           wxStatusBar*                pTheStatusBar = GetStatusBar();
+        wxStatusBar*                pTheStatusBar = GetStatusBar();
 #endif //wxUSE_STATUSBAR
 
         int                         nDummyWidth;
 #endif //wxUSE_STATUSBAR
 
         int                         nDummyWidth;
@@ -854,12 +955,12 @@ bool wxFrameOS2::ShowFullScreen(
                          );
         return TRUE;
     }
                          );
         return TRUE;
     }
-} // end of wxFrameOS2::ShowFullScreen
+} // end of wxFrame::ShowFullScreen
 
 //
 // Frame window
 //
 
 //
 // Frame window
 //
-bool wxFrameOS2::OS2Create(
+bool wxFrame::OS2Create(
   int                               nId
 , wxWindow*                         pParent
 , const wxChar*                     zWclass
   int                               nId
 , wxWindow*                         pParent
 , const wxChar*                     zWclass
@@ -1016,6 +1117,17 @@ bool wxFrameOS2::OS2Create(
     // Now size everything.  If adding a menu the client will need to be resized.
     //
 
     // Now size everything.  If adding a menu the client will need to be resized.
     //
 
+    if (pParent)
+    {
+        nY = pParent->GetSize().y - (nY + nHeight);
+    }
+    else
+    {
+        RECTL                   vRect;
+
+        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+        nY = vRect.yTop - (nY + nHeight);
+    }
     if (!::WinSetWindowPos( m_hFrame
                            ,HWND_TOP
                            ,nX
     if (!::WinSetWindowPos( m_hFrame
                            ,HWND_TOP
                            ,nX
@@ -1030,31 +1142,14 @@ bool wxFrameOS2::OS2Create(
         wxLogError("Error sizing frame. Error: %s\n", sError);
         return FALSE;
     }
         wxLogError("Error sizing frame. Error: %s\n", sError);
         return FALSE;
     }
-    //
-    // We may have to be smarter here when variable sized toolbars are added!
-    //
-    if (!::WinSetWindowPos( m_hWnd
-                           ,HWND_TOP
-                           ,nX // + 20
-                           ,nY // + 20
-                           ,nWidth // - 60
-                           ,nHeight // - 60
-                           ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
-                          ))
-    {
-        vError = ::WinGetLastError(vHabmain);
-        sError = wxPMErrorToStr(vError);
-        wxLogError("Error sizing client. Error: %s\n", sError);
-        return FALSE;
-    }
     return TRUE;
     return TRUE;
-} // end of wxFrameOS2::OS2Create
+} // end of wxFrame::OS2Create
 
 //
 // Default activation behaviour - set the focus for the first child
 // subwindow found.
 //
 
 //
 // Default activation behaviour - set the focus for the first child
 // subwindow found.
 //
-void wxFrameOS2::OnActivate(
+void wxFrame::OnActivate(
   wxActivateEvent&                  rEvent
 )
 {
   wxActivateEvent&                  rEvent
 )
 {
@@ -1105,7 +1200,7 @@ void wxFrameOS2::OnActivate(
             }
         }
     }
             }
         }
     }
-} // end of wxFrameOS2::OnActivate
+} // end of wxFrame::OnActivate
 
 // ----------------------------------------------------------------------------
 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
 
 // ----------------------------------------------------------------------------
 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
@@ -1114,7 +1209,7 @@ void wxFrameOS2::OnActivate(
 // ----------------------------------------------------------------------------
 
 // Checks if there is a toolbar, and returns the first free client position
 // ----------------------------------------------------------------------------
 
 // Checks if there is a toolbar, and returns the first free client position
-wxPoint wxFrameOS2::GetClientAreaOrigin() const
+wxPoint wxFrame::GetClientAreaOrigin() const
 {
     wxPoint                         vPoint(0, 0);
 
 {
     wxPoint                         vPoint(0, 0);
 
@@ -1140,7 +1235,7 @@ wxPoint wxFrameOS2::GetClientAreaOrigin() const
     }
 #endif //wxUSE_TOOLBAR
     return vPoint;
     }
 #endif //wxUSE_TOOLBAR
     return vPoint;
-} // end of wxFrameOS2::GetClientAreaOrigin
+} // end of wxFrame::GetClientAreaOrigin
 
 // ----------------------------------------------------------------------------
 // tool/status bar stuff
 
 // ----------------------------------------------------------------------------
 // tool/status bar stuff
@@ -1148,7 +1243,7 @@ wxPoint wxFrameOS2::GetClientAreaOrigin() const
 
 #if wxUSE_TOOLBAR
 
 
 #if wxUSE_TOOLBAR
 
-wxToolBar* wxFrameOS2::CreateToolBar(
+wxToolBar* wxFrame::CreateToolBar(
   long                              lStyle
 , wxWindowID                        vId
 , const wxString&                   rName
   long                              lStyle
 , wxWindowID                        vId
 , const wxString&                   rName
@@ -1162,9 +1257,9 @@ wxToolBar* wxFrameOS2::CreateToolBar(
         PositionToolBar();
     }
     return m_frameToolBar;
         PositionToolBar();
     }
     return m_frameToolBar;
-} // end of wxFrameOS2::CreateToolBar
+} // end of wxFrame::CreateToolBar
 
 
-void wxFrameOS2::PositionToolBar()
+void wxFrame::PositionToolBar()
 {
     HWND                            hWndClient;
     RECTL                           vRect;
 {
     HWND                            hWndClient;
     RECTL                           vRect;
@@ -1213,7 +1308,7 @@ void wxFrameOS2::PositionToolBar()
                               ,wxSIZE_NO_ADJUSTMENTS
                              );
     }
                               ,wxSIZE_NO_ADJUSTMENTS
                              );
     }
-} // end of wxFrameOS2::PositionToolBar
+} // end of wxFrame::PositionToolBar
 #endif // wxUSE_TOOLBAR
 
 // ----------------------------------------------------------------------------
 #endif // wxUSE_TOOLBAR
 
 // ----------------------------------------------------------------------------
@@ -1225,7 +1320,7 @@ void wxFrameOS2::PositionToolBar()
 // Windows behaviour where child frames float independently of the parent one
 // on the desktop, but are iconized/restored with it
 //
 // Windows behaviour where child frames float independently of the parent one
 // on the desktop, but are iconized/restored with it
 //
-void wxFrameOS2::IconizeChildFrames(
+void wxFrame::IconizeChildFrames(
   bool                              bIconize
 )
 {
   bool                              bIconize
 )
 {
@@ -1234,13 +1329,33 @@ void wxFrameOS2::IconizeChildFrames(
          pNode = pNode->GetNext() )
     {
         wxWindow*                   pWin = pNode->GetData();
          pNode = pNode->GetNext() )
     {
         wxWindow*                   pWin = pNode->GetData();
+        wxFrame*                    pFrame = wxDynamicCast(pWin, wxFrame);
 
 
-        if (pWin->IsKindOf(CLASSINFO(wxFrame)) )
+        if ( pFrame
+#if wxUSE_MDI_ARCHITECTURE
+                && !wxDynamicCast(pFrame, wxMDIChildFrame)
+#endif // wxUSE_MDI_ARCHITECTURE
+           )
         {
         {
-            ((wxFrame *)pWin)->Iconize(bIconize);
+            //
+            // We don't want to restore the child frames which had been
+            // iconized even before we were iconized, so save the child frame
+            // status when iconizing the parent frame and check it when
+            // restoring it.
+            //
+            if (bIconize)
+            {
+                pFrame->m_bWasMinimized = pFrame->IsIconized();
+            }
+
+            //
+            // This test works for both iconizing and restoring
+            //
+            if (!pFrame->m_bWasMinimized)
+                pFrame->Iconize(bIconize);
         }
     }
         }
     }
-} // end of wxFrameOS2::IconizeChildFrames
+} // end of wxFrame::IconizeChildFrames
 
 // ===========================================================================
 // message processing
 
 // ===========================================================================
 // message processing
@@ -1249,7 +1364,7 @@ void wxFrameOS2::IconizeChildFrames(
 // ---------------------------------------------------------------------------
 // preprocessing
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 // preprocessing
 // ---------------------------------------------------------------------------
-bool wxFrameOS2::OS2TranslateMessage(
+bool wxFrame::OS2TranslateMessage(
   WXMSG*                            pMsg
 )
 {
   WXMSG*                            pMsg
 )
 {
@@ -1258,21 +1373,21 @@ bool wxFrameOS2::OS2TranslateMessage(
     //
     wxMenuBar*                      pMenuBar = GetMenuBar();
 
     //
     wxMenuBar*                      pMenuBar = GetMenuBar();
 
-    if (!pMenuBar )
+    if (!pMenuBar)
         return FALSE;
 
         return FALSE;
 
-#if wxUSE_ACCEL
+#if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
     const wxAcceleratorTable&       rAcceleratorTable = pMenuBar->GetAccelTable();
     return rAcceleratorTable.Translate(GetHWND(), pMsg);
 #else
     return FALSE;
 #endif //wxUSE_ACCEL
     const wxAcceleratorTable&       rAcceleratorTable = pMenuBar->GetAccelTable();
     return rAcceleratorTable.Translate(GetHWND(), pMsg);
 #else
     return FALSE;
 #endif //wxUSE_ACCEL
-} // end of wxFrameOS2::OS2TranslateMessage
+} // end of wxFrame::OS2TranslateMessage
 
 // ---------------------------------------------------------------------------
 // our private (non virtual) message handlers
 // ---------------------------------------------------------------------------
 
 // ---------------------------------------------------------------------------
 // our private (non virtual) message handlers
 // ---------------------------------------------------------------------------
-bool wxFrameOS2::HandlePaint()
+bool wxFrame::HandlePaint()
 {
     RECTL                           vRect;
 
 {
     RECTL                           vRect;
 
@@ -1321,7 +1436,40 @@ bool wxFrameOS2::HandlePaint()
         }
         else
         {
         }
         else
         {
-            return(wxWindow::HandlePaint());
+            if (!wxWindow::HandlePaint())
+            {
+                HPS                     hPS;
+                RECTL                   vRect;
+
+                hPS = ::WinBeginPaint( GetHwnd()
+                                      ,NULLHANDLE
+                                      ,&vRect
+                                     );
+                if(hPS)
+                {
+                    ::GpiCreateLogColorTable( hPS
+                                             ,0L
+                                             ,LCOLF_CONSECRGB
+                                             ,0L
+                                             ,(LONG)wxTheColourDatabase->m_nSize
+                                             ,(PLONG)wxTheColourDatabase->m_palTable
+                                            );
+                    ::GpiCreateLogColorTable( hPS
+                                             ,0L
+                                             ,LCOLF_RGB
+                                             ,0L
+                                             ,0L
+                                             ,NULL
+                                            );
+
+                    ::WinFillRect( hPS
+                                  ,&vRect
+                                  ,GetBackgroundColour().GetPixel()
+                                 );
+                   ::WinEndPaint(hPS);
+                }
+            }
+            return TRUE;
         }
     }
     else
         }
     }
     else
@@ -1330,9 +1478,9 @@ bool wxFrameOS2::HandlePaint()
         return TRUE;
     }
     return FALSE;
         return TRUE;
     }
     return FALSE;
-} // end of wxFrameOS2::HandlePaint
+} // end of wxFrame::HandlePaint
 
 
-bool wxFrameOS2::HandleSize(
+bool wxFrame::HandleSize(
   int                               nX
 , int                               nY
 , WXUINT                            nId
   int                               nX
 , int                               nY
 , WXUINT                            nId
@@ -1406,11 +1554,12 @@ bool wxFrameOS2::HandleSize(
 
         vEvent.SetEventObject(this);
         bProcessed = GetEventHandler()->ProcessEvent(vEvent);
 
         vEvent.SetEventObject(this);
         bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+        AlterChildPos();
     }
     return bProcessed;
     }
     return bProcessed;
-} // end of wxFrameOS2::HandleSize
+} // end of wxFrame::HandleSize
 
 
-bool wxFrameOS2::HandleCommand(
+bool wxFrame::HandleCommand(
   WXWORD                            nId
 , WXWORD                            nCmd
 , WXHWND                            hControl
   WXWORD                            nId
 , WXWORD                            nCmd
 , WXHWND                            hControl
@@ -1434,6 +1583,7 @@ bool wxFrameOS2::HandleCommand(
     //
     if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR)
     {
     //
     if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR)
     {
+#if wxUSE_MENUS_NATIVE
         if (wxCurrentPopupMenu)
         {
             wxMenu*                 pPopupMenu = wxCurrentPopupMenu;
         if (wxCurrentPopupMenu)
         {
             wxMenu*                 pPopupMenu = wxCurrentPopupMenu;
@@ -1443,7 +1593,9 @@ bool wxFrameOS2::HandleCommand(
             return pPopupMenu->OS2Command( nCmd
                                           ,nId
                                          );
             return pPopupMenu->OS2Command( nCmd
                                           ,nId
                                          );
+            return TRUE;
         }
         }
+#endif
 
         if (ProcessCommand(nId))
         {
 
         if (ProcessCommand(nId))
         {
@@ -1451,9 +1603,9 @@ bool wxFrameOS2::HandleCommand(
         }
     }
     return FALSE;
         }
     }
     return FALSE;
-} // end of wxFrameOS2::HandleCommand
+} // end of wxFrame::HandleCommand
 
 
-bool wxFrameOS2::HandleMenuSelect(
+bool wxFrame::HandleMenuSelect(
   WXWORD                            nItem
 , WXWORD                            nFlags
 , WXHMENU                           hMenu
   WXWORD                            nItem
 , WXWORD                            nFlags
 , WXHMENU                           hMenu
@@ -1475,7 +1627,7 @@ bool wxFrameOS2::HandleMenuSelect(
         }
     }
     return TRUE;
         }
     }
     return TRUE;
-} // end of wxFrameOS2::HandleMenuSelect
+} // end of wxFrame::HandleMenuSelect
 
 // ---------------------------------------------------------------------------
 // Main Frame window proc
 
 // ---------------------------------------------------------------------------
 // Main Frame window proc
@@ -1611,7 +1763,7 @@ MRESULT EXPENTRY wxFrameWndProc(
     return rc;
 } // end of wxFrameWndProc
 
     return rc;
 } // end of wxFrameWndProc
 
-MRESULT wxFrameOS2::OS2WindowProc(
+MRESULT wxFrame::OS2WindowProc(
   WXUINT                            uMessage
 , WXWPARAM                          wParam
 , WXLPARAM                          lParam
   WXUINT                            uMessage
 , WXWPARAM                          wParam
 , WXLPARAM                          lParam
@@ -1721,14 +1873,14 @@ MRESULT wxFrameOS2::OS2WindowProc(
                                       ,lParam
                                      );
     return (MRESULT)mRc;
                                       ,lParam
                                      );
     return (MRESULT)mRc;
-} // wxFrameOS2::OS2WindowProc
+} // wxFrame::OS2WindowProc
 
 
-void wxFrameOS2::SetClient(WXHWND c_Hwnd)
+void wxFrame::SetClient(WXHWND c_Hwnd)
 {
    // Duh...nothing to do under OS/2
 }
 
 {
    // Duh...nothing to do under OS/2
 }
 
-void wxFrameOS2::SetClient(
+void wxFrame::SetClient(
   wxWindow*                         pWindow
 )
 {
   wxWindow*                         pWindow
 )
 {
@@ -1778,7 +1930,7 @@ void wxFrameOS2::SetClient(
     }
 }
 
     }
 }
 
-wxWindow* wxFrameOS2::GetClient()
+wxWindow* wxFrame::GetClient()
 {
     return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
 }
 {
     return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
 }