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;
// 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;
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;
#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 |
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)
// 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