Implemented window coord mirroring for RTL. This

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
This commit is contained in:
Robert Roebling
2006-09-10 19:39:22 +00:00
parent 1d203ed837
commit 6959763942
5 changed files with 60 additions and 30 deletions

View File

@@ -50,11 +50,10 @@ struct _GtkPizza
GList *children; GList *children;
GtkMyShadowType shadow_type; GtkMyShadowType shadow_type;
guint m_width;
guint m_height;
guint m_xoffset; guint m_xoffset;
guint m_yoffset; guint m_yoffset;
gint m_width;
GdkWindow *bin_window; GdkWindow *bin_window;
@@ -77,10 +76,6 @@ GtkWidget* gtk_pizza_new (void);
/* accessors */ /* accessors */
WXDLLIMPEXP_CORE
gint gtk_pizza_get_width (GtkPizza *pizza);
WXDLLIMPEXP_CORE
gint gtk_pizza_get_height (GtkPizza *pizza);
WXDLLIMPEXP_CORE WXDLLIMPEXP_CORE
gint gtk_pizza_get_xoffset (GtkPizza *pizza); gint gtk_pizza_get_xoffset (GtkPizza *pizza);
WXDLLIMPEXP_CORE WXDLLIMPEXP_CORE

View File

@@ -72,6 +72,15 @@ bool wxStaticText::Create(wxWindow *parent,
justify = GTK_JUSTIFY_RIGHT; justify = GTK_JUSTIFY_RIGHT;
else // wxALIGN_LEFT is 0 else // wxALIGN_LEFT is 0
justify = GTK_JUSTIFY_LEFT; 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_label_set_justify(GTK_LABEL(m_widget), justify);
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2

View File

@@ -237,8 +237,13 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
(int)alloc->height ); (int)alloc->height );
*/ */
// Tell the wxWindow class about the new size
win->m_width = alloc->width; win->m_width = alloc->width;
win->m_height = alloc->height; win->m_height = alloc->height;
if (win->m_mainWidget)
GTK_PIZZA(win->m_mainWidget)->m_width = win->m_width;
win->GtkUpdateSize(); win->GtkUpdateSize();
} }
} }
@@ -559,6 +564,8 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); 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. if (m_miniEdge == 0) // wxMiniFrame has its own version.
{ {
// For m_mainWidget themes // 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 (width != -1) m_width = width;
if (height != -1) m_height = height; 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) if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
@@ -1024,6 +1034,7 @@ void wxTopLevelWindowGTK::GtkOnSize()
if (client_h < 0) if (client_h < 0)
client_h = 0; client_h = 0;
// Let the parent perform the resize
gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
m_wxwindow, m_wxwindow,
client_x, client_y, client_w, client_h ); client_x, client_y, client_w, client_h );

View File

@@ -189,13 +189,12 @@ gtk_pizza_init (GtkPizza *pizza)
pizza->children = NULL; pizza->children = NULL;
pizza->m_width = 20;
pizza->m_height = 20;
pizza->bin_window = NULL; pizza->bin_window = NULL;
pizza->m_xoffset = 0; pizza->m_xoffset = 0;
pizza->m_yoffset = 0; pizza->m_yoffset = 0;
pizza->m_width = -1;
pizza->external_expose = FALSE; pizza->external_expose = FALSE;
} }
@@ -210,22 +209,6 @@ gtk_pizza_new ()
return GTK_WIDGET (pizza); 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) gint gtk_pizza_get_xoffset (GtkPizza *pizza)
{ {
g_return_val_if_fail ( (pizza != NULL), -1 ); 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 (GTK_IS_PIZZA (pizza));
g_return_if_fail (widget != NULL); 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 = g_new (GtkPizzaChild, 1);
child_info->widget = widget; child_info->widget = widget;
@@ -319,6 +308,9 @@ gtk_pizza_put (GtkPizza *pizza,
child_info->width = width; child_info->width = width;
child_info->height = height; child_info->height = height;
if (GTK_IS_PIZZA(widget))
GTK_PIZZA(widget)->m_width = width;
pizza->children = g_list_append (pizza->children, child_info); pizza->children = g_list_append (pizza->children, child_info);
if (GTK_WIDGET_REALIZED (pizza)) if (GTK_WIDGET_REALIZED (pizza))
@@ -362,15 +354,25 @@ gtk_pizza_set_size (GtkPizza *pizza,
if (child->widget == widget) 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->y == y) &&
(child->width == width) && (child->width == width) &&
(child->height == height)) return; (child->height == height)) return;
child->x = x; child->x = new_x;
child->y = y; child->y = y;
child->width = width; child->width = width;
child->height = height; child->height = height;
if (GTK_IS_PIZZA(widget))
GTK_PIZZA(widget)->m_width = width;
gtk_widget_set_size_request (widget, width, height); gtk_widget_set_size_request (widget, width, height);

View File

@@ -2115,7 +2115,7 @@ gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win )
static static
void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
GtkAllocation *WXUNUSED(alloc), GtkAllocation *alloc,
wxWindow *win ) wxWindow *win )
{ {
if (g_isIdle) 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)) if ((client_width == win->m_oldClientWidth) && (client_height == win->m_oldClientHeight))
return; return;
GTK_PIZZA(win->m_wxwindow)->m_width = alloc->width;
win->m_oldClientWidth = client_width; win->m_oldClientWidth = client_width;
win->m_oldClientHeight = client_height; win->m_oldClientHeight = client_height;
@@ -2732,7 +2734,9 @@ bool wxWindowGTK::Destroy()
void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) 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 ); 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 ) 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); GTKSetLayout(m_widget, dir);
if (m_wxwindow) 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) void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move)