More RTL work.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41206 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-09-13 22:20:10 +00:00
parent f4fe2f2052
commit 49e74855af
4 changed files with 66 additions and 42 deletions

View File

@@ -3137,12 +3137,24 @@ void wxListMainWindow::MoveToItem(size_t item)
Scroll( -1, (rect.y + rect.height - client_h + hLine) / hLine ); Scroll( -1, (rect.y + rect.height - client_h + hLine) / hLine );
} }
else // !report else // !report
{
if (GetLayoutDirection() == wxLayout_RightToLeft)
{
#if 0
wxPrintf( wxT("rect %d %d %d %d view_x %d\n"), rect.x, rect.y, rect.width, rect.height, view_x );
int virtual_width = GetVirtualSize().x;
view_x = virtual_width - view_x - client_w;
wxPrintf( wxT("virtual_width %d view_x = %d client_w = %d\n"), virtual_width, view_x, client_w );
#endif
}
else
{ {
if (rect.x-view_x < 5) if (rect.x-view_x < 5)
Scroll( (rect.x - 5) / SCROLL_UNIT_X, -1 ); Scroll( (rect.x - 5) / SCROLL_UNIT_X, -1 );
if (rect.x + rect.width - 5 > view_x + client_w) if (rect.x + rect.width - 5 > view_x + client_w)
Scroll( (rect.x + rect.width - client_w + SCROLL_UNIT_X) / SCROLL_UNIT_X, -1 ); Scroll( (rect.x + rect.width - client_w + SCROLL_UNIT_X) / SCROLL_UNIT_X, -1 );
} }
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -2242,11 +2242,6 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
if ( image != NO_IMAGE ) if ( image != NO_IMAGE )
{ {
#ifdef __WXGTK__
if (GetLayoutDirection() == wxLayout_RightToLeft)
dc.SetClippingRegion( item->GetX()+image_w-2, item->GetY(), image_w-2, total_h );
else
#endif
dc.SetClippingRegion( item->GetX(), item->GetY(), image_w-2, total_h ); dc.SetClippingRegion( item->GetX(), item->GetY(), image_w-2, total_h );
m_imageListNormal->Draw( image, dc, m_imageListNormal->Draw( image, dc,
item->GetX(), item->GetX(),
@@ -2392,6 +2387,7 @@ void wxGenericTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level
int yy = y_mid - image_h/2; int yy = y_mid - image_h/2;
wxDCClipper clip(dc, xx, yy, image_w, image_h); wxDCClipper clip(dc, xx, yy, image_w, image_h);
wxPrintf( wxT("hi\n") );
m_imageListButtons->Draw(image, dc, xx, yy, m_imageListButtons->Draw(image, dc, xx, yy,
wxIMAGELIST_DRAW_TRANSPARENT); wxIMAGELIST_DRAW_TRANSPARENT);
} }

View File

@@ -331,8 +331,24 @@ wxWindowDC::wxWindowDC( wxWindow *window )
m_signX = -1; m_signX = -1;
// origin in the upper right corner // origin in the upper right corner
wxScrolledWindow *sw = wxDynamicCast( m_owner, wxScrolledWindow );
if (sw) int scroll_lines = 0;
int scroll_step = 0;
// Are we using scrolling?
wxScrollHelper *sh = (wxScrollHelper*) m_owner->GetScrollHelper();
if (sh)
{
scroll_lines = sh->GetScrollLines(wxHORIZONTAL);
sh->GetScrollPixelsPerUnit( &scroll_step, NULL );
}
if (scroll_lines == 0)
{
int client_width = m_owner->GetClientSize().x;
m_deviceOriginX = client_width;
}
else
{ {
// We cannot use just the virtual size here, because // We cannot use just the virtual size here, because
// the virtual size may be less than the visible area // the virtual size may be less than the visible area
@@ -340,28 +356,13 @@ wxWindowDC::wxWindowDC( wxWindow *window )
// horizontal scroll step is 10 pixels and the virtual // horizontal scroll step is 10 pixels and the virtual
// area is 97 pixels, we should be able to see or scroll // area is 97 pixels, we should be able to see or scroll
// to 100 pixels, so the origin is at -100, not -97. // to 100 pixels, so the origin is at -100, not -97.
if (sw->GetScrollLines(wxHORIZONTAL) == 0) int client_width = sh->GetTargetWindow()->GetClientSize().x;
{ int virtual_size = m_owner->GetVirtualSize().x;
int client_width = m_owner->GetClientSize().x;
m_deviceOriginX = client_width;
}
else
{
int scroll_step = 0;
sw->GetScrollPixelsPerUnit( &scroll_step, NULL );
int client_width = m_owner->GetClientSize().x;
int virtual_size = sw->GetVirtualSize().x;
int steps = (virtual_size + scroll_step - 1) / scroll_step; int steps = (virtual_size + scroll_step - 1) / scroll_step;
int width = steps * scroll_step + (client_width % scroll_step); int width = steps * scroll_step + (client_width % scroll_step);
m_deviceOriginX = width; m_deviceOriginX = width;
} }
} }
else
{
int client_width = m_owner->GetClientSize().x;
m_deviceOriginX = client_width;
}
}
} }
wxWindowDC::~wxWindowDC() wxWindowDC::~wxWindowDC()
@@ -2151,6 +2152,11 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo
rect.width = XLOG2DEVREL(width); rect.width = XLOG2DEVREL(width);
rect.height = YLOG2DEVREL(height); rect.height = YLOG2DEVREL(height);
if (m_owner && m_owner->m_wxwindow && (m_owner->GetLayoutDirection() == wxLayout_RightToLeft))
{
rect.x -= rect.width;
}
if (!m_currentClippingRegion.IsNull()) if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( rect ); m_currentClippingRegion.Intersect( rect );
else else

View File

@@ -2137,7 +2137,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
alloc->height ); alloc->height );
#endif #endif
GTK_PIZZA(win->m_wxwindow)->m_width = alloc->width; GTK_PIZZA(win->m_wxwindow)->m_width = win->GetClientSize().x;
win->m_oldClientWidth = client_width; win->m_oldClientWidth = client_width;
win->m_oldClientHeight = client_height; win->m_oldClientHeight = client_height;
@@ -2753,10 +2753,6 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") ); wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") );
/*
printf( "DoSetSize: name %s, x,y,w,h: %d,%d,%d,%d \n", GetName().c_str(), x,y,width,height );
*/
if (m_resizing) return; /* I don't like recursions */ if (m_resizing) return; /* I don't like recursions */
m_resizing = true; m_resizing = true;
@@ -3107,7 +3103,15 @@ void wxWindowGTK::DoClientToScreen( int *x, int *y ) const
} }
} }
if (x) *x += org_x;
if (x)
{
if (GetLayoutDirection() == wxLayout_RightToLeft)
*x = (GetClientSize().x - *x) + org_x;
else
*x += org_x;
}
if (y) *y += org_y; if (y) *y += org_y;
} }
@@ -3136,7 +3140,13 @@ void wxWindowGTK::DoScreenToClient( int *x, int *y ) const
} }
} }
if (x) *x -= org_x; if (x)
{
if (GetLayoutDirection() == wxLayout_RightToLeft)
*x = (GetClientSize().x - *x) - org_x;
else
*x -= org_x;
}
if (y) *y -= org_y; if (y) *y -= org_y;
} }
@@ -3752,6 +3762,8 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
gdk_rect.y = rect->y; gdk_rect.y = rect->y;
gdk_rect.width = rect->width; gdk_rect.width = rect->width;
gdk_rect.height = rect->height; gdk_rect.height = rect->height;
if (GetLayoutDirection() == wxLayout_RightToLeft)
gdk_rect.x = GetClientSize().x - gdk_rect.x - gdk_rect.width;
p = &gdk_rect; p = &gdk_rect;
} }
else // invalidate everything else // invalidate everything
@@ -3759,8 +3771,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
p = NULL; p = NULL;
} }
p = NULL;
gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE ); gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE );
} }
} }