]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
Also set GTK text direction to m_wxwindow.
[wxWidgets.git] / src / msw / window.cpp
index 4522e1bfc2dc94c007136baa84d31be8be9e5778..bd227b7ed35ab07fe7f42e7a1a19512c9a2903d6 100644 (file)
@@ -28,6 +28,8 @@
 
 #ifndef WX_PRECOMP
     #include "wx/msw/wrapwin.h"
+    #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
+    #include "wx/msw/missing.h"
     #include "wx/accel.h"
     #include "wx/menu.h"
     #include "wx/dc.h"
@@ -48,6 +50,7 @@
     #include "wx/log.h"
     #include "wx/textctrl.h"
     #include "wx/menuitem.h"
+    #include "wx/module.h"
 #endif
 
 #if wxUSE_OWNER_DRAWN && !defined(__WXUNIVERSAL__)
@@ -55,7 +58,6 @@
 #endif
 
 #include "wx/evtloop.h"
-#include "wx/module.h"
 #include "wx/power.h"
 #include "wx/sysopt.h"
 
     #include <windowsx.h>
 #endif
 
-// include <commctrl.h> "properly"
-#include "wx/msw/wrapcctl.h"
-
-#ifndef __WXWINCE__
+#if !defined __WXWINCE__ && !defined NEED_PBT_H
     #include <pbt.h>
 #endif
 
-#include "wx/msw/missing.h"
-
 #if defined(__WXWINCE__)
     #include "wx/msw/wince/missing.h"
 #ifdef __POCKETPC__
@@ -1018,6 +1015,67 @@ bool wxWindowMSW::ScrollPages(int pages)
                             down ? pages : -pages);
 }
 
+// ----------------------------------------------------------------------------
+// RTL support
+// ----------------------------------------------------------------------------
+
+void wxWindowMSW::SetLayoutDirection(wxLayoutDirection dir)
+{
+#ifdef __WXWINCE__
+    wxUnusedVar(dir);
+#else
+    const HWND hwnd = GetHwnd();
+    wxCHECK_RET( hwnd, _T("layout direction must be set after window creation") );
+
+    LONG styleOld = ::GetWindowLong(hwnd, GWL_EXSTYLE);
+
+    LONG styleNew = styleOld;
+    switch ( dir )
+    {
+        case wxLayout_LeftToRight:
+            styleNew &= ~WS_EX_LAYOUTRTL;
+            break;
+
+        case wxLayout_RightToLeft:
+            styleNew |= WS_EX_LAYOUTRTL;
+            break;
+
+        default:
+            wxFAIL_MSG(_T("unsupported layout direction"));
+            break;
+    }
+
+    if ( styleNew != styleOld )
+    {
+        ::SetWindowLong(hwnd, GWL_EXSTYLE, styleNew);
+    }
+#endif
+}
+
+wxLayoutDirection wxWindowMSW::GetLayoutDirection() const
+{
+#ifdef __WXWINCE__
+    return wxLayout_Default;
+#else
+    const HWND hwnd = GetHwnd();
+    wxCHECK_MSG( hwnd, wxLayout_Default, _T("invalid window") );
+
+    return ::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL
+                ? wxLayout_RightToLeft
+                : wxLayout_LeftToRight;
+#endif
+}
+
+wxCoord
+wxWindowMSW::AdjustForLayoutDirection(wxCoord x,
+                                      wxCoord WXUNUSED(width),
+                                      wxCoord WXUNUSED(widthTotal)) const
+{
+    // Win32 mirrors the coordinates of RTL windows automatically, so don't
+    // redo it ourselves
+    return x;
+}
+
 // ---------------------------------------------------------------------------
 // subclassing
 // ---------------------------------------------------------------------------