Fix setting layout direction for wxComboBox in wxMSW.

The EDIT control used by the native combobox is different from normal EDIT
controls and has to be handled specially.

We also need to explicitly forward WS_EX_LAYOUTRTL to the dropdown window as
it doesn't inherit it from the combobox itself automatically.

See #11583.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-21 01:41:17 +00:00
parent da41c5d9bb
commit e5755015e7
4 changed files with 68 additions and 34 deletions

View File

@@ -126,6 +126,8 @@ public:
virtual bool SetHint(const wxString& hint);
#endif // wxUSE_UXTHEME
virtual void SetLayoutDirection(wxLayoutDirection dir) wxOVERRIDE;
protected:
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip(wxToolTip *tip);

View File

@@ -1013,29 +1013,28 @@ inline long wxSetWindowExStyle(const wxWindowMSW *win, long style)
return ::SetWindowLong(GetHwndOf(win), GWL_EXSTYLE, style);
}
// Update layout direction flag for an EDIT control.
//
// Returns true if anything changed or false if the direction flag was already
// set to the desired direction (which can't be wxLayout_Default).
inline bool wxUpdateEditLayoutDirection(WXHWND hWnd, wxLayoutDirection dir)
// Common helper of wxUpdate{,Edit}LayoutDirection() below: sets or clears the
// given flag(s) depending on wxLayoutDirection and returns true if the flags
// really changed.
inline bool
wxUpdateExStyleForLayoutDirection(WXHWND hWnd,
wxLayoutDirection dir,
LONG_PTR flagsForRTL)
{
wxCHECK_MSG( hWnd, false,
wxS("Can't set layout direction for invalid window") );
static const LONG_PTR
EDIT_RTL_EX_FLAGS = WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR;
const LONG_PTR styleOld = ::GetWindowLongPtr(hWnd, GWL_EXSTYLE);
LONG_PTR styleNew = styleOld;
switch ( dir )
{
case wxLayout_LeftToRight:
styleNew &= ~EDIT_RTL_EX_FLAGS;
styleNew &= ~flagsForRTL;
break;
case wxLayout_RightToLeft:
styleNew |= EDIT_RTL_EX_FLAGS;
styleNew |= flagsForRTL;
break;
case wxLayout_Default:
@@ -1050,6 +1049,28 @@ inline bool wxUpdateEditLayoutDirection(WXHWND hWnd, wxLayoutDirection dir)
return true;
}
// Update layout direction flag for a generic window.
//
// See below for the special version that must be used with EDIT controls.
//
// Returns true if the layout direction did change.
inline bool wxUpdateLayoutDirection(WXHWND hWnd, wxLayoutDirection dir)
{
return wxUpdateExStyleForLayoutDirection(hWnd, dir, WS_EX_LAYOUTRTL);
}
// Update layout direction flag for an EDIT control.
//
// Returns true if anything changed or false if the direction flag was already
// set to the desired direction (which can't be wxLayout_Default).
inline bool wxUpdateEditLayoutDirection(WXHWND hWnd, wxLayoutDirection dir)
{
return wxUpdateExStyleForLayoutDirection(hWnd, dir,
WS_EX_RIGHT |
WS_EX_RTLREADING |
WS_EX_LEFTSCROLLBAR);
}
// Companion of the above function checking if an EDIT control uses RTL.
inline wxLayoutDirection wxGetEditLayoutDirection(WXHWND hWnd)
{