]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
do nothing in ShowHidden() if the flag doesn't change (patch 1678963)
[wxWidgets.git] / src / msw / window.cpp
index 6d3b2b4bc66577b43be107537dd579c1ea5f327d..5ed982abb3737d74693238d00aad6efc1ca65490 100644 (file)
@@ -650,6 +650,47 @@ wxWindow *wxWindowBase::DoFindFocus()
 
 bool wxWindowMSW::Enable(bool enable)
 {
+    // we shouldn't really enable the window if our parent is currently
+    // disabled because under MSW this would indeed show the window in enabled
+    // state but it still wouldn't respond to the input (as its parent is
+    // disabled), so just update the internal m_childrenDisabled list in this
+    // case and our state will be really changed when the parent is enabled
+
+    // the logic above doesn't apply to top level windows, of course
+    wxWindowMSW * const parent = IsTopLevel() ? NULL : GetParent();
+    if ( parent && !parent->IsEnabled() && !IsEnabled() )
+    {
+        // it's a reference as we can create it below
+        wxWindowList *& disabledSiblings = parent->m_childrenDisabled;
+
+        bool rc = false;
+        if ( enable )
+        {
+            // shouldn't be disabled when the parent is reenabled
+            if ( disabledSiblings )
+            {
+                wxWindowList::compatibility_iterator
+                    i = disabledSiblings->Find(this);
+                if ( i )
+                {
+                    disabledSiblings->Erase(i);
+                    rc = true;
+                }
+            }
+            //else: nothing to do
+        }
+        else // !enable
+        {
+            // should disable this window when the parent is enabled
+            if ( !disabledSiblings )
+                disabledSiblings = new wxWindowList;
+
+            disabledSiblings->Append(this);
+        }
+
+        return rc;
+    }
+
     if ( !wxWindowBase::Enable(enable) )
         return false;
 
@@ -803,7 +844,30 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor)
     // don't "overwrite" busy cursor
     if ( m_cursor.Ok() && !wxIsBusy() )
     {
-        ::SetCursor(GetHcursorOf(m_cursor));
+        // normally we should change the cursor only if it's over this window
+        // but we should do it always if we capture the mouse currently
+        bool set = HasCapture();
+        if ( !set )
+        {
+            HWND hWnd = GetHwnd();
+
+            POINT point;
+#ifdef __WXWINCE__
+            ::GetCursorPosWinCE(&point);
+#else
+            ::GetCursorPos(&point);
+#endif
+
+            RECT rect = wxGetWindowRect(hWnd);
+
+            set = ::PtInRect(&rect, point) != 0;
+        }
+
+        if ( set )
+        {
+            ::SetCursor(GetHcursorOf(m_cursor));
+        }
+        //else: will be set later when the mouse enters this window
     }
 
     return true;
@@ -2155,10 +2219,13 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
             switch ( msg->wParam )
             {
                 case VK_TAB:
-                    if ( lDlgCode & DLGC_WANTTAB ) {
+                    if ( (lDlgCode & DLGC_WANTTAB) && !bCtrlDown )
+                    {
+                        // let the control have the TAB
                         bProcess = false;
                     }
-                    else {
+                    else // use it for navigation
+                    {
                         // Ctrl-Tab cycles thru notebook pages
                         bWindowChange = bCtrlDown;
                         bForward = !bShiftDown;
@@ -2838,12 +2905,12 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
 #endif // defined(WM_DRAWITEM)
 
         case WM_GETDLGCODE:
-            if ( !IsOfStandardClass() )
+            if ( !IsOfStandardClass() || HasFlag(wxWANTS_CHARS) )
             {
                 // we always want to get the char events
                 rc.result = DLGC_WANTCHARS;
 
-                if ( GetWindowStyleFlag() & wxWANTS_CHARS )
+                if ( HasFlag(wxWANTS_CHARS) )
                 {
                     // in fact, we want everything
                     rc.result |= DLGC_WANTARROWS |
@@ -5743,13 +5810,26 @@ WXWORD wxCharCodeWXToMSW(int wxk, bool *isVirtual)
     return vk;
 }
 
+#ifndef SM_SWAPBUTTON
+    #define SM_SWAPBUTTON 23
+#endif
+
 // small helper for wxGetKeyState() and wxGetMouseState()
 static inline bool wxIsKeyDown(WXWORD vk)
 {
+    switch (vk)
+    {
+        case VK_LBUTTON:
+            if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_RBUTTON;
+            break;
+        case VK_RBUTTON:
+            if (GetSystemMetrics(SM_SWAPBUTTON)) vk = VK_LBUTTON;
+            break;
+    }
     // the low order bit indicates whether the key was pressed since the last
     // call and the high order one indicates whether it is down right now and
     // we only want that one
-    return (::GetAsyncKeyState(vk) & (1<<15)) != 0;
+    return (GetAsyncKeyState(vk) & (1<<15)) != 0;
 }
 
 bool wxGetKeyState(wxKeyCode key)
@@ -5769,7 +5849,7 @@ bool wxGetKeyState(wxKeyCode key)
         // low order bit means LED is highlighted and high order one means the
         // key is down; for compatibility with the other ports return true if
         // either one is set
-        return ::GetKeyState(vk) != 0;
+        return GetKeyState(vk) != 0;
 
     }
     else // normal key