From: Robert Roebling <robert@roebling.de>
Date: Mon, 18 Sep 2006 14:29:16 +0000 (+0000)
Subject:   More RTL work. Now transform m_updateRegion and
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/bcb614b328a884ce6754d7a84bde03922b1da24f?ds=sidebyside

  More RTL work. Now transform m_updateRegion and
   do nothing special in IsExposed() since some
   code may use m_updateRegion directly. Keep
   untransformed version around for use with
   GTK clipping in the DC.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h
index c009ff693a..f1857ba42d 100644
--- a/include/wx/gtk/window.h
+++ b/include/wx/gtk/window.h
@@ -307,6 +307,7 @@ public:
     bool                 m_hasFocus:1;          // true if == FindFocus()
     bool                 m_isScrolling:1;       // dragging scrollbar thumb?
     bool                 m_clipPaintRegion:1;   // true after ScrollWindow()
+    wxRegion             m_nativeUpdateRegion;  // not transformed for RTL
     bool                 m_dirtyTabOrder:1;     // tab order changed, GTK focus
                                                 // chain needs update
     bool                 m_needsStyleChange:1;  // May not be able to change
diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp
index 5fcffb809e..1c007dd1ca 100644
--- a/src/generic/grid.cpp
+++ b/src/generic/grid.cpp
@@ -6826,6 +6826,14 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
 
     if ( !parent->GetEventHandler()->ProcessEvent( keyEvt ) )
     {
+        if (GetLayoutDirection() == wxLayout_RightToLeft)
+        {
+            if (event.GetKeyCode() == WXK_RIGHT)
+                event.m_keyCode = WXK_LEFT;
+            else if (event.GetKeyCode() == WXK_LEFT)
+                event.m_keyCode = WXK_RIGHT;
+        }
+    
         // try local handlers
         switch ( event.GetKeyCode() )
         {
@@ -7506,6 +7514,12 @@ void wxGrid::DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr )
         rect.width -= penWidth - 1;
         rect.height -= penWidth - 1;
 
+#ifdef __WXGTK__
+        // FIXME: why is the rect drawn off-by-one?
+        if ((penWidth == 2) && (GetLayoutDirection() == wxLayout_RightToLeft))
+            rect.x -= 1;
+#endif
+
         // Now draw the rectangle
         // use the cellHighlightColour if the cell is inside a selection, this
         // will ensure the cell is always visible.
diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp
index 71c58be3d2..4c47974d55 100644
--- a/src/gtk/dcclient.cpp
+++ b/src/gtk/dcclient.cpp
@@ -2332,7 +2332,7 @@ wxPaintDC::wxPaintDC( wxWindow *win )
         return;
 
     wxSize sz = win->GetSize();
-    m_paintClippingRegion = win->GetUpdateRegion();
+    m_paintClippingRegion = win->m_nativeUpdateRegion;
     wxLimitRegionToSize(m_paintClippingRegion, sz);
 
     GdkRegion *region = m_paintClippingRegion.GetRegion();
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
index 616ac2f836..a83c1c551e 100644
--- a/src/gtk/window.cpp
+++ b/src/gtk/window.cpp
@@ -3824,9 +3824,11 @@ bool wxWindowGTK::DoIsExposed( int x, int y ) const
 
 bool wxWindowGTK::DoIsExposed( int x, int y, int w, int h ) const
 {
+#if 0
     if (GetLayoutDirection() == wxLayout_RightToLeft)
         return m_updateRegion.Contains(x-w, y, w, h) != wxOutRegion;
     else
+#endif
         return m_updateRegion.Contains(x, y, w, h) != wxOutRegion;
 }
 
@@ -3841,16 +3843,18 @@ void wxWindowGTK::GtkSendPaintEvents()
     // Clip to paint region in wxClientDC
     m_clipPaintRegion = true;
 
-#if 0
+    m_nativeUpdateRegion = m_updateRegion;
+
     if (GetLayoutDirection() == wxLayout_RightToLeft)
     {
-        maybe_rtl_region.Clear();
+        // Transform m_updateRegion under RTL
+        m_updateRegion.Clear();
         
         gint width;
         gdk_window_get_geometry( GTK_PIZZA(m_wxwindow)->bin_window,
                                  NULL, NULL, &width, NULL, NULL );
         
-        wxRegionIterator upd( m_updateRegion );
+        wxRegionIterator upd( m_nativeUpdateRegion );
         while (upd)
         {
             wxRect rect;
@@ -3860,12 +3864,11 @@ void wxWindowGTK::GtkSendPaintEvents()
             rect.height = upd.GetHeight();
             
             rect.x = width - rect.x - rect.width;
-            maybe_rtl_region.Union( rect );
+            m_updateRegion.Union( rect );
             
             ++upd;
         }
     }
-#endif
     
     // widget to draw on
     GtkPizza *pizza = GTK_PIZZA (m_wxwindow);
@@ -3879,7 +3882,7 @@ void wxWindowGTK::GtkSendPaintEvents()
 
         if (GTK_WIDGET_MAPPED(parent->m_widget))
         {
-            wxRegionIterator upd( m_updateRegion );
+            wxRegionIterator upd( m_nativeUpdateRegion );
             while (upd)
             {
                 GdkRectangle rect;
@@ -3923,6 +3926,7 @@ void wxWindowGTK::GtkSendPaintEvents()
     m_clipPaintRegion = false;
 
     m_updateRegion.Clear();
+    m_nativeUpdateRegion.Clear();
 }
 
 void wxWindowGTK::SetDoubleBuffered( bool on )