]> git.saurik.com Git - wxWidgets.git/commitdiff
Catching up
authorDavid Webster <Dave.Webster@bhmi.com>
Mon, 17 Jun 2002 22:08:57 +0000 (22:08 +0000)
committerDavid Webster <Dave.Webster@bhmi.com>
Mon, 17 Jun 2002 22:08:57 +0000 (22:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

12 files changed:
include/wx/os2/frame.h
include/wx/os2/popupwin.h
include/wx/os2/radiobox.h
include/wx/os2/toplevel.h
include/wx/os2/window.h
src/os2/font.cpp
src/os2/fontutil.cpp
src/os2/frame.cpp
src/os2/popupwin.cpp
src/os2/thread.cpp
src/os2/toplevel.cpp
src/os2/window.cpp

index 88cac74d0fa8c712f37764bc2e629ac5b9f9cded..d05f166f99502d65a51684ab73a5dba9180c4cf0 100644 (file)
@@ -62,7 +62,6 @@ public:
     virtual void Raise(void);
 
     // event handlers
-    void OnActivate(wxActivateEvent& rEvent);
     void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
 
     // Toolbar
@@ -122,12 +121,6 @@ public:
     void   SetToolTipCtrl(WXHWND hHwndTT) { m_hWndToolTip = hHwndTT; }
 #endif // tooltips
 
-    //
-    // Called by wxWindow whenever it gets focus
-    //
-    void SetLastFocus(wxWindow* pWin) { m_pWinLastFocused = pWin; }
-    wxWindow *GetLastFocus(void) const { return m_pWinLastFocused; }
-
     void      SetClient(WXHWND    c_Hwnd);
     void      SetClient(wxWindow* c_Window);
     wxWindow *GetClient();
@@ -188,7 +181,6 @@ protected:
     bool                            m_bFsIsShowing;
     bool                            m_bWasMinimized;
     bool                            m_bIsShown;
-    wxWindow*                       m_pWinLastFocused;
 
 private:
 #if wxUSE_TOOLTIPS
index 9341ecdd5c5cb0ec75d800601125ab73ac144dfe..72ddbab4d789b4b542c612a594c886f5f31efedd 100644 (file)
@@ -21,7 +21,10 @@ class WXDLLEXPORT wxPopupWindow : public wxPopupWindowBase
 public:
     wxPopupWindow() { }
 
-    wxPopupWindow(wxWindow* pParent) { (void)Create(pParent); }
+    wxPopupWindow( wxWindow* pParent
+                  ,int       nFlags
+                 )
+    { (void)Create(pParent, nFlags); }
 
     bool Create( wxWindow* pParent
                 ,int       nFlags = wxBORDER_NONE
@@ -30,19 +33,8 @@ public:
     // Implementation only from now on
     // -------------------------------
     //
-
-    //
-    // Override Show() to prevent wxPopupWindow from being activated
-    //
-    virtual bool Show(bool show = TRUE);
-
-    //
-    // Find a shown popup window with the given window as parent, return NULL
-    // if none
-    //
-    static wxPopupWindow *FindPopupFor(wxWindow* pWin);
-
 protected:
+
     virtual void DoGetPosition( int* pnX
                                ,int* pny
                               ) const;
@@ -50,6 +42,11 @@ protected:
     virtual WXDWORD OS2GetStyle( long     lFlags
                                 ,WXDWORD* dwExstyle
                                ) const;
+    //
+    // Get the HWND to be used as parent of this window with CreateWindow()
+    //
+    virtual WXHWND OS2GetParent(void) const;
+
     //
     // The list of all currently shown popup windows used by FindPopupFor()
     //
index 2e0f9af62f6ec1013e04b0e15ea214934ac1ab4c..8b1e97a9c0beffb3b25a433ee675eaa5a1526031 100644 (file)
@@ -70,7 +70,7 @@ public:
 
     void             Command(wxCommandEvent& rEvent);
     bool             ContainsHWND(WXHWND hWnd) const;
-    bool             Enable(bool bEnable);
+    virtual bool     Enable(bool bEnable = TRUE);
     void             Enable( int  nItem
                             ,bool bEnable
                            );
@@ -87,7 +87,7 @@ public:
                                 ,WXWORD wId
                                );
     void             SendNotificationEvent(void);
-    void             Show( int  nItem
+    virtual void     Show( int  nItem
                           ,bool bShow =  TRUE
                          ) ;
     bool             Show(bool bShow);
index d0e1a3e469062106085f11bbcde7e55b3df14e9f..b45053a8622c38c4b5e787b5bb4d56b4eb3e3a27 100644 (file)
@@ -86,6 +86,11 @@ public:
     // --------------------------
     //
            PSWP         GetSwpClient(void) { return &m_vSwpClient; }
+
+           void         OnActivate(wxActivateEvent& rEvent);
+
+           void         SetLastFocus(wxWindow *pWin) { m_pWinLastFocused = pWin; }
+           wxWindow*    GetLastFocus(void) const { return m_pWinLastFocused; }
 protected:
     //
     // Common part of all ctors
@@ -157,11 +162,15 @@ protected:
     bool                            m_bFsIsMaximized;
     bool                            m_bFsIsShowing;
 
+    wxWindow*                       m_pWinLastFocused;
+
     WXHWND                          m_hFrame;
     SWP                             m_vSwp;
     SWP                             m_vSwpClient;
     static bool                     m_sbInitialized;
     static wxWindow*                m_spHiddenParent;
+
+    DECLARE_EVENT_TABLE()
 }; // end of CLASS wxTopLevelWindowOS2
 
 //
index 12e1debc20c57d996e9f3d93689111c8bc270185..3d1e43bf7da77be2a102fc15badacfadf5bdd62e 100644 (file)
@@ -237,6 +237,10 @@ public:
 
     WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
     void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
+    //
+    // Return TRUE if the window is of a standard (i.e. not wxWindows') class
+    //
+    bool IsOfStandardClass(void) const { return m_fnOldWndProc != NULL; }
 
     wxWindow* FindItem(long lId) const;
     wxWindow* FindItemByHWND( WXHWND hWnd
@@ -503,7 +507,6 @@ protected:
     bool                            m_bUseCtl3D:1; // Using CTL3D for this control
     bool                            m_bBackgroundTransparent:1;
     bool                            m_bMouseInWindow:1;
-    bool                            m_bDoubleClickAllowed:1;
     bool                            m_bLastKeydownProcessed:1;
     bool                            m_bWinCaptured:1;
     WXDWORD                         m_dwExStyle;
index d35787fca95f920ab59ce7ede7bfc63cd9f2c990..747b3232f775cc9da96c47c406907eafc54272d5 100644 (file)
@@ -1117,5 +1117,5 @@ void wxFont::SetPS(
     M_FONTDATA->SetPS(hPS);
 
     RealizeResource();
-} // end of wxFont::SetUnderlined
+} // end of wxFont::SetPS
 
index 805b4eeb9e716b6ed6efac35cfd1481ec5ff79e0..bb4490f96c889aa31ed7c016c59184d992d52bc8 100644 (file)
@@ -323,27 +323,12 @@ void wxFillLogFont(
                  ,(int)lNumFonts
                 );
 
-    wxString                        sVals;
-
-    //
-    // For debugging, delete later
-    //
-    for (int i = 0; i < lNumFonts; i++)
-    {
-         sVals << "Face: " << pFM[i].szFacename
-               << "Family: " << pFM[i].szFamilyname
-               << " PointSize: " << pFM[i].lEmHeight
-               << " Height: " << pFM[i].lXHeight
-               ;
-         sVals = "";
-    }
-
     //
     // Initialize FATTR and FACENAMEDESC
     //
     pFattrs->usRecordLength = sizeof(FATTRS);
     pFattrs->fsFontUse = FATTR_FONTUSE_OUTLINE |       // only outline fonts allowed
-                          FATTR_FONTUSE_TRANSFORMABLE;  // may be transformed
+                         FATTR_FONTUSE_TRANSFORMABLE;  // may be transformed
     pFattrs->fsType = 0;
     pFattrs->lMaxBaselineExt = pFattrs->lAveCharWidth = 0;
     pFattrs->idRegistry = 0;
@@ -639,110 +624,12 @@ wxFont wxCreateFontFromLogFont(
 , PFACENAMEDESC                     pFaceName
 )
 {
-    //
-    // Extract family from facename
-    //
-    int                             nFontFamily;
-
-    if (strcmp(pLogFont->szFacename, "Times New Roman") == 0)
-        nFontFamily = wxROMAN;
-    else if (strcmp(pLogFont->szFacename, "WarpSans") == 0)
-        nFontFamily = wxSWISS;
-    else if (strcmp(pLogFont->szFacename, "Script") == 0)
-        nFontFamily = wxSCRIPT;
-    else if (strcmp(pLogFont->szFacename, "Courier New") == 0)
-        nFontFamily = wxMODERN;
-    else
-        nFontFamily = wxSWISS;
-
-    //
-    // Weight and Style
-    //
-    int                             nFontWeight = wxNORMAL;
-
-    switch (pFaceName->usWeightClass)
-    {
-        case FWEIGHT_LIGHT:
-            nFontWeight = wxLIGHT;
-            break;
-
-        default:
-        case FWEIGHT_NORMAL:
-            nFontWeight = wxNORMAL;
-            break;
-
-        case FWEIGHT_BOLD:
-            nFontWeight = wxBOLD;
-            break;
-    }
-
-    int                             nFontStyle;
-
-    if(pLogFont->fsSelection & FATTR_SEL_ITALIC)
-        nFontStyle = wxITALIC;
-    else
-        nFontStyle = wxNORMAL;
-
-    bool                            bFontUnderline = (pLogFont->fsSelection & FATTR_SEL_UNDERSCORE);
-    wxString                        sFontFace = pLogFont->szFacename;
-    int                             nFontPoints = pFM->lEmHeight;
-    wxFontEncoding                  vFontEncoding;
-
-    switch (pLogFont->usCodePage)
-    {
-        default:
-            wxFAIL_MSG(wxT("unsupported charset"));
-            // fall through
-
-        case 850:
-            vFontEncoding = wxFONTENCODING_CP1252;
-            break;
-
-        case 1250:
-            vFontEncoding = wxFONTENCODING_CP1250;
-            break;
-
-        case 921:
-            vFontEncoding = wxFONTENCODING_CP1257;
-            break;
-
-        case 866:
-            vFontEncoding = wxFONTENCODING_CP1251;
-            break;
-
-        case 864:
-            vFontEncoding = wxFONTENCODING_CP1256;
-            break;
-
-        case 869:
-            vFontEncoding = wxFONTENCODING_CP1253;
-            break;
-
-        case 862:
-            vFontEncoding = wxFONTENCODING_CP1255;
-            break;
-
-        case 857:
-            vFontEncoding = wxFONTENCODING_CP1254;
-            break;
-
-        case 874:
-            vFontEncoding = wxFONTENCODING_CP437;
-            break;
-
-        case 437:
-            vFontEncoding = wxFONTENCODING_CP437;
-            break;
-    }
+    wxNativeFontInfo                vInfo;
 
-    return wxFont( nFontPoints
-                  ,nFontFamily
-                  ,nFontStyle
-                  ,nFontWeight
-                  ,bFontUnderline
-                  ,sFontFace
-                  ,vFontEncoding
-                 );
+    vInfo.fa = *pLogFont;
+    vInfo.fm = *pFM;
+    vInfo.fn = *pFaceName;
+    return wxFont(vInfo);
 } // end of wxCreateFontFromLogFont
 
 int wxGpiStrcmp(
index a49e174364b813a60f40112cd6e8501c36a94f78..4c345bcea7f4924706e3f91e96b1a8de24b82455 100644 (file)
@@ -67,7 +67,6 @@ extern void  wxAssociateWinWithHandle( HWND         hWnd
 // ----------------------------------------------------------------------------
 
 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
-    EVT_ACTIVATE(wxFrame::OnActivate)
     EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
 END_EVENT_TABLE()
 
@@ -101,7 +100,6 @@ void wxFrame::Init()
     m_nFsToolBarHeight   = 0;
     m_hWndToolTip        = 0L;
     m_bWasMinimized      = FALSE;
-    m_pWinLastFocused    = NULL;
 
 
     m_frameMenuBar   = NULL;
@@ -658,70 +656,13 @@ bool wxFrame::ShowFullScreen(
                           ,m_vFsOldSize.height
                           ,SWP_SIZE | SWP_SHOW
                          );
-        return TRUE;
     }
+    return wxFrameBase::ShowFullScreen(bShow, lStyle);
 } // end of wxFrame::ShowFullScreen
 
 //
 // Frame window
 //
-//
-// Default activation behaviour - set the focus for the first child
-// subwindow found.
-//
-void wxFrame::OnActivate(
-  wxActivateEvent&                  rEvent
-)
-{
-    if ( rEvent.GetActive() )
-    {
-        // restore focus to the child which was last focused
-        wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
-
-        wxWindow*                           pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
-                                            : NULL;
-        if (!pParent)
-        {
-            pParent = this;
-        }
-
-        wxSetFocusToChild( pParent
-                          ,&m_pWinLastFocused
-                         );
-    }
-    else // deactivating
-    {
-        //
-        // Remember the last focused child if it is our child
-        //
-        m_pWinLastFocused = FindFocus();
-
-        for (wxWindowList::Node* pNode = GetChildren().GetFirst();
-             pNode;
-             pNode = pNode->GetNext())
-        {
-            // FIXME all this is totally bogus - we need to do the same as wxPanel,
-            //       but how to do it without duplicating the code?
-
-            // restore focus
-            wxWindow*                   pChild = pNode->GetData();
-
-            if (!pChild->IsTopLevel()
-#if wxUSE_TOOLBAR
-                 && !wxDynamicCast(pChild, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
-                 && !wxDynamicCast(pChild, wxStatusBar)
-#endif // wxUSE_STATUSBAR
-               )
-            {
-                pChild->SetFocus();
-                return;
-            }
-        }
-    }
-} // end of wxFrame::OnActivate
-
 // ----------------------------------------------------------------------------
 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
 // from the client area, so the client area is what's really available for the
index 4c0ca2757ac9410fc93d9104ff4c630a3e53bb07..7ffb1164f8324ef0d1296036a1ec90e96ca04b31 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "wx/popupwin.h"
 
-wxWindowList wxPopupWindow::m_svShownPopups;
+IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
 
 // ============================================================================
 // implementation
@@ -64,6 +64,14 @@ void wxPopupWindow::DoGetPosition(
     GetParent()->ClientToScreen(pnX, pnY);
 } // end of wxPopupWindow::DoGetPosition
 
+WXHWND wxPopupWindow::OS2GetParent() const
+{
+    // we must be a child of the desktop to be able to extend beyond the parent
+    // window client area (like the comboboxes drop downs do)
+    //
+    return (WXHWND)HWND_DESKTOP;
+} // end of wxPopupWindow::OS2GetParent
+
 WXDWORD wxPopupWindow::OS2GetStyle(
   long                              lFlags
 , WXDWORD*                          dwExstyle
@@ -76,73 +84,4 @@ WXDWORD wxPopupWindow::OS2GetStyle(
     return dwStyle;
 } // end of wxPopupWindow::OS2GetStyle
 
-bool wxPopupWindow::Show(
-  bool                              bShow
-)
-{
-    SWP                             vSwp;
-    //
-    // Skip wxWindow::Show() which calls wxBringWindowToTop(): this results in
-    // activating the popup window and stealing the atcivation from our parent
-    // which means that the parent frame becomes deactivated when opening a
-    // combobox, for example -- definitely not what we want
-    //
-    if (!wxWindowBase::Show(bShow))
-        return FALSE;
-
-    if (bShow)
-    {
-        m_svShownPopups.Append(this);
-    }
-    else // remove from the shown list
-    {
-        m_svShownPopups.DeleteObject(this);
-    }
-    ::WinQueryWindowPos(GetHwnd(), &vSwp);
-
-    if (bShow)
-    {
-        ::WinSetWindowPos( GetHwnd()
-                          ,HWND_TOP
-                          ,vSwp.x
-                          ,vSwp.y
-                          ,vSwp.cx
-                          ,vSwp.cy
-                          ,SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER
-                         );
-    }
-    else
-    {
-        ::WinSetWindowPos( GetHwnd()
-                          ,HWND_BOTTOM
-                          ,vSwp.x
-                          ,vSwp.y
-                          ,vSwp.cx
-                          ,vSwp.cy
-                          ,SWP_HIDE | SWP_ZORDER
-                         );
-    }
-    return TRUE;
-} // end of wxPopupWindow::Show
-
-/* static */
-wxPopupWindow* wxPopupWindow::FindPopupFor(
-  wxWindow*                         pWinParent
-)
-{
-    //
-    // Find a popup with the given parent in the linked list of all shown
-    // popups
-    //
-    for ( wxWindowList::Node *node = m_svShownPopups.GetFirst();
-          node;
-          node = node->GetNext() )
-    {
-        wxWindow*                   pWin = node->GetData();
-
-        if (pWin->GetParent() == pWinParent )
-            return (wxPopupWindow *)pWin;
-    }
-    return NULL;
-} // end of wxPopupWindow::FindPopupFor
 
index af2e0f7304c9a4911b38d0e7ad7a46a69f4b2501..db6ba0651071baa64bc0a29d827766b890518262 100644 (file)
@@ -85,7 +85,9 @@ public:
     HMTX                            m_vMutex;
 };
 
-wxMutex::wxMutex()
+wxMutex::wxMutex(
+  wxMutexType                       eMutexType
+)
 {
     APIRET                          ulrc;
 
@@ -95,13 +97,10 @@ wxMutex::wxMutex()
     {
         wxLogSysError(_("Can not create mutex."));
     }
-    m_locked = 0;
 }
 
 wxMutex::~wxMutex()
 {
-    if (m_locked > 0)
-        wxLogDebug(wxT("Warning: freeing a locked mutex (%d locks)."), m_locked);
     ::DosCloseMutexSem(m_internal->m_vMutex);
     m_internal->m_vMutex = NULL;
 }
@@ -131,7 +130,6 @@ wxMutexError wxMutex::Lock()
         default:
             wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock"));
     }
-    m_locked++;
     return wxMUTEX_NO_ERROR;
 }
 
@@ -143,7 +141,6 @@ wxMutexError wxMutex::TryLock()
     if (ulrc == ERROR_TIMEOUT || ulrc == ERROR_TOO_MANY_SEM_REQUESTS)
         return wxMUTEX_BUSY;
 
-    m_locked++;
     return wxMUTEX_NO_ERROR;
 }
 
@@ -151,9 +148,6 @@ wxMutexError wxMutex::Unlock()
 {
     APIRET                          ulrc;
 
-    if (m_locked > 0)
-        m_locked--;
-
     ulrc = ::DosReleaseMutexSem(m_internal->m_vMutex);
     if (ulrc != 0)
     {
@@ -180,7 +174,7 @@ public:
         m_nWaiters = 0;
     }
 
-    inline bool Wait(
+    inline APIRET Wait(
       unsigned long                 ulTimeout
     )
     {
@@ -189,7 +183,7 @@ public:
         m_nWaiters++;
         ulrc = ::DosWaitEventSem(m_vEvent, ulTimeout);
         m_nWaiters--;
-        return (ulrc != ERROR_TIMEOUT);
+        return (ulrc);
     }
 
     inline ~wxConditionInternal ()
@@ -234,34 +228,80 @@ wxCondition::~wxCondition()
     m_internal = NULL;
 }
 
-void wxCondition::Wait()
+wxCondError wxCondition::Wait()
 {
-    (void)m_internal->Wait(SEM_INDEFINITE_WAIT);
+    APIRET                          rc = m_internal->Wait(SEM_INDEFINITE_WAIT);
+
+    switch(rc)
+    {
+        case NO_ERROR:
+            return wxCOND_NO_ERROR;
+        case ERROR_INVALID_HANDLE:
+            return wxCOND_INVALID;
+        case ERROR_TIMEOUT:
+            return wxCOND_TIMEOUT;
+        default:
+            return wxCOND_MISC_ERROR;
+    }
 }
 
-bool wxCondition::Wait(
+wxCondError wxCondition::WaitTimeout(
   unsigned long                     lMilliSec
 )
 {
-    return m_internal->Wait(lMilliSec);
+    APIRET                          rc = m_internal->Wait(lMilliSec);
+
+    switch(rc)
+    {
+        case NO_ERROR:
+            return wxCOND_NO_ERROR;
+        case ERROR_INVALID_HANDLE:
+            return wxCOND_INVALID;
+        case ERROR_TIMEOUT:
+            return wxCOND_TIMEOUT;
+        default:
+            return wxCOND_MISC_ERROR;
+    }
 }
 
-void wxCondition::Signal()
+wxCondError wxCondition::Signal()
 {
-    ::DosPostEventSem(m_internal->m_vEvent);
+    APIRET                          rc = ::DosPostEventSem(m_internal->m_vEvent);
+
+    switch(rc)
+    {
+        case NO_ERROR:
+            return wxCOND_NO_ERROR;
+        case ERROR_INVALID_HANDLE:
+            return wxCOND_INVALID;
+        default:
+            return wxCOND_MISC_ERROR;
+    }
 }
 
-void wxCondition::Broadcast()
+wxCondError wxCondition::Broadcast()
 {
     int                             i;
+    APIRET                          rc = NO_ERROR;
 
     for (i = 0; i < m_internal->m_nWaiters; i++)
     {
-        if (::DosPostEventSem(m_internal->m_vEvent) != 0)
+        if ((rc = ::DosPostEventSem(m_internal->m_vEvent)) != NO_ERROR)
         {
             wxLogSysError(_("Couldn't change the state of event object."));
+            break;
         }
     }
+
+    switch(rc)
+    {
+        case NO_ERROR:
+            return wxCOND_NO_ERROR;
+        case ERROR_INVALID_HANDLE:
+            return wxCOND_INVALID;
+        default:
+            return wxCOND_MISC_ERROR;
+    }
 }
 
 // ----------------------------------------------------------------------------
index 4e74fa9343af89846361d405d6a6dc50fd9cbfc4..0b4219617a2a15cd0fa42103df1b24e4e5d41d65 100644 (file)
@@ -59,6 +59,14 @@ extern void          wxAssociateWinWithHandle( HWND         hWnd
 bool                 wxTopLevelWindowOS2::m_sbInitialized = FALSE;
 wxWindow*            wxTopLevelWindowOS2::m_spHiddenParent = NULL;
 
+// ============================================================================
+// wxTopLevelWindowOS2 implementation
+// ============================================================================
+
+BEGIN_EVENT_TABLE(wxTopLevelWindowOS2, wxTopLevelWindowBase)
+    EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate)
+END_EVENT_TABLE()
+
 // ============================================================================
 // wxTopLevelWindowMSW implementation
 // ============================================================================
@@ -70,21 +78,20 @@ MRESULT EXPENTRY wxDlgProc( HWND WXUNUSED(hWnd)
                            ,MPARAM WXUNUSED(lParam)
                           )
 {
-    if (uMessage == WM_INITDLG)
-    {
-        //
-        // For this message, returning TRUE tells system to set focus to the
-        // first control in the dialog box.
-        //
-        return (MRESULT)TRUE;
-    }
-    else
+    switch(uMessage)
     {
-        //
-        // For all the other ones, FALSE means that we didn't process the
-        // message
-        //
-        return (MRESULT)FALSE;
+        case WM_INITDLG:
+            //
+            // For this message, returning TRUE tells system to set focus to
+            // the first control in the dialog box, but as we set the focus
+            // ourselves, we return FALSE from here as well, so fall through
+            //
+        default:
+            //
+            // For all the other ones, FALSE means that we didn't process the
+            // message
+            //
+            return (MRESULT)FALSE;
     }
 } // end of wxDlgProc
 
@@ -111,8 +118,65 @@ void wxTopLevelWindowOS2::Init()
     m_hFrame    = NULLHANDLE;
     memset(&m_vSwp, 0, sizeof(SWP));
     memset(&m_vSwpClient, 0, sizeof(SWP));
+    m_pWinLastFocused = (wxWindow *)NULL;
 } // end of wxTopLevelWindowIOS2::Init
 
+void wxTopLevelWindowOS2::OnActivate(
+  wxActivateEvent&                  rEvent
+)
+{
+    if (rEvent.GetActive())
+    {
+        //
+        // Restore focus to the child which was last focused
+        //
+        wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), m_hWnd);
+
+        wxWindow*                   pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
+                                                                : NULL;
+        if (!pParent)
+        {
+            pParent = this;
+        }
+
+        wxSetFocusToChild( pParent
+                          ,&m_pWinLastFocused
+                         );
+    }
+    else // deactivating
+    {
+        //
+        // Remember the last focused child if it is our child
+        //
+        m_pWinLastFocused = FindFocus();
+
+        //
+        // So we NULL it out if it's a child from some other frame
+        //
+        wxWindow*                   pWin = m_pWinLastFocused;
+
+        while (pWin)
+        {
+            if (pWin->IsTopLevel())
+            {
+                if (pWin != this)
+                {
+                    m_pWinLastFocused = NULL;
+                }
+                break;
+            }
+            pWin = pWin->GetParent();
+        }
+
+        wxLogTrace(_T("focus"),
+                   _T("wxTLW %08x deactivated, last focused: %08x."),
+                   m_hWnd,
+                   m_pWinLastFocused ? GetHwndOf(m_pWinLastFocused)
+                                     : NULL);
+        rEvent.Skip();
+    }
+} // end of wxTopLevelWindowOS2::OnActivate
+
 WXDWORD wxTopLevelWindowOS2::OS2GetStyle(
   long                              lStyle
 , WXDWORD*                          pdwExflags
index 12a47e3f5de06b07ad8be0acc2253fcdbb80c057..318aeb93ec81c2d78744afee426767fe36f1a8b7 100644 (file)
@@ -293,11 +293,10 @@ void wxWindowOS2::Init()
     //
     // PM specific
     //
-    m_bDoubleClickAllowed = 0;
     m_bWinCaptured = FALSE;
 
     m_isBeingDeleted        = FALSE;
-    m_fnOldWndProc          = 0;
+    m_fnOldWndProc          = NULL;
     m_bUseCtl3D             = FALSE;
     m_bMouseInWindow        = FALSE;
     m_bLastKeydownProcessed = FALSE;
@@ -342,12 +341,12 @@ wxWindowOS2::~wxWindowOS2()
 
     for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
     {
-        wxFrame*                    pFrame = wxDynamicCast(pWin, wxFrame);
+        wxTopLevelWindow*           pFrame = wxDynamicCast(pWin, wxTopLevelWindow);
 
         if (pFrame)
         {
             if (pFrame->GetLastFocus() == this)
-                pFrame->SetLastFocus((wxWindow*)NULL);
+                pFrame->SetLastFocus(NULL);
         }
     }
 
@@ -2732,10 +2731,13 @@ MRESULT wxWindowOS2::OS2WindowProc(
             break;
 
         case WM_QUERYDLGCODE:
-            if ( m_lDlgCode )
+            if (!IsOfStandardClass())
             {
-                mResult = (MRESULT)m_lDlgCode;
-                bProcessed = TRUE;
+                if ( m_lDlgCode )
+                {
+                    mResult = (MRESULT)m_lDlgCode;
+                    bProcessed = TRUE;
+                }
             }
             //
             //else: get the dlg code from the DefWindowProc()