]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented window coord mirroring for RTL. This
authorRobert Roebling <robert@roebling.de>
Sun, 10 Sep 2006 19:39:22 +0000 (19:39 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 10 Sep 2006 19:39:22 +0000 (19:39 +0000)
    is only implemented for *setting* the coordinates
    which is enough for wxSizers and 99% or other
    dialogs to work.
  Also reversed the meaning of wxStaticText alignment
    in RTL mode. It is possible that later versions
    of GTK actually do that themselves. (?)

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

include/wx/gtk/win_gtk.h
src/gtk/stattext.cpp
src/gtk/toplevel.cpp
src/gtk/win_gtk.c
src/gtk/window.cpp

index b873dffa5df6f7e55b4071b656ba44b4e31b530b..34e665a4104af1920413b8d372f113500fbf58ef 100644 (file)
@@ -50,11 +50,10 @@ struct _GtkPizza
     GList *children;
     GtkMyShadowType shadow_type;
 
-    guint m_width;
-    guint m_height;
-
     guint m_xoffset;
     guint m_yoffset;
+    
+    gint  m_width;
 
     GdkWindow *bin_window;
 
@@ -77,10 +76,6 @@ GtkWidget* gtk_pizza_new             (void);
 
 /* accessors */
 
-WXDLLIMPEXP_CORE
-gint       gtk_pizza_get_width       (GtkPizza          *pizza); 
-WXDLLIMPEXP_CORE
-gint       gtk_pizza_get_height      (GtkPizza          *pizza); 
 WXDLLIMPEXP_CORE
 gint       gtk_pizza_get_xoffset     (GtkPizza          *pizza); 
 WXDLLIMPEXP_CORE
index c8ab59de09391649e8177ccb541f4c105844a3d8..8d2c1e01b42f31ed49675a3ed9896fb14f5693af 100644 (file)
@@ -72,6 +72,15 @@ bool wxStaticText::Create(wxWindow *parent,
       justify = GTK_JUSTIFY_RIGHT;
     else // wxALIGN_LEFT is 0
       justify = GTK_JUSTIFY_LEFT;
+      
+    if (GetLayoutDirection() == wxLayout_RightToLeft)
+    {  
+         if (justify == GTK_JUSTIFY_RIGHT)
+            justify = GTK_JUSTIFY_LEFT;
+         if (justify == GTK_JUSTIFY_LEFT)
+            justify = GTK_JUSTIFY_RIGHT;
+    }
+    
     gtk_label_set_justify(GTK_LABEL(m_widget), justify);
 
     // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
index 614a4dce0af589ef047dc9a46706445c01da08e1..33ef92100e65caacc22ca1fcc194efee4c346fc3 100644 (file)
@@ -237,8 +237,13 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
                                 (int)alloc->height );
 */
 
+        // Tell the wxWindow class about the new size
         win->m_width = alloc->width;
         win->m_height = alloc->height;
+        
+        if (win->m_mainWidget)
+            GTK_PIZZA(win->m_mainWidget)->m_width = win->m_width;
+        
         win->GtkUpdateSize();
     }
 }
@@ -559,6 +564,8 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
     GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
     gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
 
+    GTK_PIZZA(m_mainWidget)->m_width = m_width;
+        
     if (m_miniEdge == 0) // wxMiniFrame has its own version.
     {
        // For m_mainWidget themes
@@ -852,6 +859,9 @@ void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int si
     }
     if (width != -1) m_width = width;
     if (height != -1) m_height = height;
+    
+    if (m_mainWidget)
+        GTK_PIZZA(m_mainWidget)->m_width = m_width;
 
 /*
     if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
@@ -1024,6 +1034,7 @@ void wxTopLevelWindowGTK::GtkOnSize()
         if (client_h < 0)
             client_h = 0;
 
+        // Let the parent perform the resize
         gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                               m_wxwindow,
                               client_x, client_y, client_w, client_h );
index 8d31fb8675251dd21dc4498cf9ca344ad264d191..6e473cfa673eb94ea9234fdd3bc7268e0ddbdcb8 100644 (file)
@@ -189,13 +189,12 @@ gtk_pizza_init (GtkPizza *pizza)
 
     pizza->children = NULL;
 
-    pizza->m_width = 20;
-    pizza->m_height = 20;
-
     pizza->bin_window = NULL;
 
     pizza->m_xoffset = 0;
     pizza->m_yoffset = 0;
+    
+    pizza->m_width = -1;
 
     pizza->external_expose = FALSE;
 }
@@ -210,22 +209,6 @@ gtk_pizza_new ()
     return GTK_WIDGET (pizza);
 }
 
-gint       gtk_pizza_get_width       (GtkPizza          *pizza)
-{
-    g_return_val_if_fail ( (pizza != NULL), -1 );
-    g_return_val_if_fail ( (GTK_IS_PIZZA (pizza)), -1 );
-
-    return pizza->m_width;
-}
-
-gint       gtk_pizza_get_height      (GtkPizza          *pizza)
-{
-    g_return_val_if_fail ( (pizza != NULL), -1 );
-    g_return_val_if_fail ( (GTK_IS_PIZZA (pizza)), -1 );
-
-    return pizza->m_height;
-}
-
 gint       gtk_pizza_get_xoffset     (GtkPizza          *pizza)
 {
     g_return_val_if_fail ( (pizza != NULL), -1 );
@@ -311,6 +294,12 @@ gtk_pizza_put (GtkPizza   *pizza,
     g_return_if_fail (GTK_IS_PIZZA (pizza));
     g_return_if_fail (widget != NULL);
 
+    if (gtk_widget_get_direction( GTK_WIDGET(pizza) ) == GTK_TEXT_DIR_RTL)
+    {
+        // reverse horizontal placement
+        x = pizza->m_width - x - width;
+    }
+
     child_info = g_new (GtkPizzaChild, 1);
 
     child_info->widget = widget;
@@ -319,6 +308,9 @@ gtk_pizza_put (GtkPizza   *pizza,
     child_info->width = width;
     child_info->height = height;
 
+    if (GTK_IS_PIZZA(widget))
+        GTK_PIZZA(widget)->m_width = width;
+                
     pizza->children = g_list_append (pizza->children, child_info);
 
     if (GTK_WIDGET_REALIZED (pizza))
@@ -362,15 +354,25 @@ gtk_pizza_set_size (GtkPizza   *pizza,
 
         if (child->widget == widget)
         {
-            if ((child->x == x) &&
+            gint new_x = x;
+            if (gtk_widget_get_direction( GTK_WIDGET(pizza) ) == GTK_TEXT_DIR_RTL)
+            {
+                // reverse horizontal placement
+                new_x = pizza->m_width - new_x - width;
+            }
+
+            if ((child->x == new_x) &&
                 (child->y == y) &&
                 (child->width == width) &&
                 (child->height == height)) return;
 
-            child->x = x;
+            child->x = new_x;
             child->y = y;
             child->width = width;
             child->height = height;
+            
+            if (GTK_IS_PIZZA(widget))
+                GTK_PIZZA(widget)->m_width = width;
 
             gtk_widget_set_size_request (widget, width, height);
 
index 1fe968ef99831b107e4483618bb75d5183338644..375ad6d806124638ac0efd32aa1a66996e2c2e86 100644 (file)
@@ -2115,7 +2115,7 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
 
 static
 void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
-                               GtkAllocation *WXUNUSED(alloc),
+                               GtkAllocation *alloc,
                                wxWindow *win )
 {
     if (g_isIdle)
@@ -2127,6 +2127,8 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
     if ((client_width == win->m_oldClientWidth) && (client_height == win->m_oldClientHeight))
         return;
 
+    GTK_PIZZA(win->m_wxwindow)->m_width = alloc->width;
+
     win->m_oldClientWidth = client_width;
     win->m_oldClientHeight = client_height;
 
@@ -2732,7 +2734,9 @@ bool wxWindowGTK::Destroy()
 
 void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height)
 {
+    // inform the parent to perform the move
     gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), m_widget, x, y, width, height );
+    
 }
 
 void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
@@ -3479,7 +3483,16 @@ void wxWindowGTK::SetLayoutDirection(wxLayoutDirection dir)
     GTKSetLayout(m_widget, dir);
     
     if (m_wxwindow)
-        GTKSetLayout(m_widget, dir);
+        GTKSetLayout(m_wxwindow, dir);
+}
+
+wxCoord
+wxWindowGTK::AdjustForLayoutDirection(wxCoord x,
+                                      wxCoord WXUNUSED(width),
+                                      wxCoord WXUNUSED(widthTotal)) const
+{
+    // We now mirrors the coordinates of RTL windows in GtkPizza
+    return x;
 }
 
 void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)