Next round of RTL fixes. This change greatly simplifes
the code and makes most #ifdefs redundant. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41255 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1701,24 +1701,23 @@ void wxListHeaderWindow::AdjustDC(wxDC& dc)
|
||||
int view_start;
|
||||
m_owner->GetViewStart( &view_start, NULL );
|
||||
|
||||
if (GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
{
|
||||
// FIXME: we need a better way for RTL scrolling..
|
||||
int scroll_lines = m_owner->GetScrollLines( wxHORIZONTAL );
|
||||
if (scroll_lines)
|
||||
{
|
||||
int client_size = m_owner->GetClientSize().x;
|
||||
view_start = scroll_lines - (client_size / xpix) - view_start;
|
||||
view_start = -view_start;
|
||||
}
|
||||
}
|
||||
|
||||
int org_x = 0;
|
||||
int org_y = 0;
|
||||
dc.GetDeviceOrigin( &org_x, &org_y );
|
||||
|
||||
// account for the horz scrollbar offset
|
||||
dc.SetDeviceOrigin( org_x - (view_start * xpix), org_y );
|
||||
#ifdef __WXGTK__
|
||||
if (GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
{
|
||||
// Maybe we just have to check for m_signX
|
||||
// in the DC, but I leave the #ifdef __WXGTK__
|
||||
// for now
|
||||
dc.SetDeviceOrigin( org_x + (view_start * xpix), org_y );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
dc.SetDeviceOrigin( org_x - (view_start * xpix), org_y );
|
||||
}
|
||||
|
||||
void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
@@ -3155,22 +3154,10 @@ void wxListMainWindow::MoveToItem(size_t item)
|
||||
}
|
||||
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)
|
||||
Scroll( (rect.x - 5) / SCROLL_UNIT_X, -1 );
|
||||
if (rect.x + rect.width - 5 > view_x + client_w)
|
||||
Scroll( (rect.x + rect.width - client_w + SCROLL_UNIT_X) / SCROLL_UNIT_X, -1 );
|
||||
}
|
||||
if (rect.x-view_x < 5)
|
||||
Scroll( (rect.x - 5) / SCROLL_UNIT_X, -1 );
|
||||
if (rect.x + rect.width - 5 > view_x + client_w)
|
||||
Scroll( (rect.x + rect.width - client_w + SCROLL_UNIT_X) / SCROLL_UNIT_X, -1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -815,8 +815,17 @@ void wxScrollHelper::AdjustScrollbars()
|
||||
void wxScrollHelper::DoPrepareDC(wxDC& dc)
|
||||
{
|
||||
wxPoint pt = dc.GetDeviceOrigin();
|
||||
dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine,
|
||||
pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
|
||||
#ifdef __WXGTK__
|
||||
// It may actually be correct to always query
|
||||
// the m_sign from the DC here, but I leve the
|
||||
// #ifdef GTK for now.
|
||||
if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
dc.SetDeviceOrigin( pt.x + m_xScrollPosition * m_xScrollPixelsPerLine,
|
||||
pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
|
||||
else
|
||||
#endif
|
||||
dc.SetDeviceOrigin( pt.x - m_xScrollPosition * m_xScrollPixelsPerLine,
|
||||
pt.y - m_yScrollPosition * m_yScrollPixelsPerLine );
|
||||
dc.SetUserScale( m_scaleX, m_scaleY );
|
||||
}
|
||||
|
||||
@@ -949,33 +958,7 @@ void wxScrollHelper::GetViewStart (int *x, int *y) const
|
||||
void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const
|
||||
{
|
||||
if ( xx )
|
||||
{
|
||||
if ((m_xScrollLines == 0) || (m_xScrollPixelsPerLine == 0))
|
||||
{
|
||||
// nothing to do
|
||||
*xx = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
GetTargetSize(&w, &h);
|
||||
|
||||
// Calculate page size i.e. number of scroll units you get on the
|
||||
// current client window
|
||||
int noPagePositions = w/m_xScrollPixelsPerLine;
|
||||
if (noPagePositions < 1) noPagePositions = 1;
|
||||
*xx = x - ((m_xScrollLines - noPagePositions - m_xScrollPosition) * m_xScrollPixelsPerLine);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
*xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
*xx = x - m_xScrollPosition * m_xScrollPixelsPerLine;
|
||||
if ( yy )
|
||||
*yy = y - m_yScrollPosition * m_yScrollPixelsPerLine;
|
||||
}
|
||||
@@ -983,33 +966,7 @@ void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) cons
|
||||
void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
|
||||
{
|
||||
if ( xx )
|
||||
{
|
||||
if ((m_xScrollLines == 0) || (m_xScrollPixelsPerLine == 0))
|
||||
{
|
||||
// nothing to do
|
||||
*xx = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
if (m_win->GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
GetTargetSize(&w, &h);
|
||||
|
||||
// Calculate page size i.e. number of scroll units you get on the
|
||||
// current client window
|
||||
int noPagePositions = w/m_xScrollPixelsPerLine;
|
||||
if (noPagePositions < 1) noPagePositions = 1;
|
||||
*xx = x + ((m_xScrollLines - noPagePositions - m_xScrollPosition) * m_xScrollPixelsPerLine);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
*xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
*xx = x + m_xScrollPosition * m_xScrollPixelsPerLine;
|
||||
if ( yy )
|
||||
*yy = y + m_yScrollPosition * m_yScrollPixelsPerLine;
|
||||
}
|
||||
|
@@ -329,39 +329,9 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
||||
{
|
||||
// reverse sense
|
||||
m_signX = -1;
|
||||
|
||||
|
||||
// origin in the upper right corner
|
||||
|
||||
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
|
||||
// the virtual size may be less than the visible area
|
||||
// due to rounding errors of the scroll steps. If the
|
||||
// horizontal scroll step is 10 pixels and the virtual
|
||||
// area is 97 pixels, we should be able to see or scroll
|
||||
// to 100 pixels, so the origin is at -100, not -97.
|
||||
int client_width = sh->GetTargetWindow()->GetClientSize().x;
|
||||
int virtual_size = m_owner->GetVirtualSize().x;
|
||||
int steps = (virtual_size + scroll_step - 1) / scroll_step;
|
||||
int width = steps * scroll_step + (client_width % scroll_step);
|
||||
m_deviceOriginX = width;
|
||||
}
|
||||
m_deviceOriginX = m_owner->GetClientSize().x;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -338,14 +338,6 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win )
|
||||
if (!win->m_hasVMT)
|
||||
return;
|
||||
|
||||
int dw = 0;
|
||||
int dh = 0;
|
||||
|
||||
if (win->m_hasScrolling)
|
||||
{
|
||||
GetScrollbarWidth(widget, dw, dh);
|
||||
}
|
||||
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
if (GTK_WIDGET_NO_WINDOW (widget))
|
||||
@@ -354,6 +346,27 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win )
|
||||
dy += widget->allocation.y;
|
||||
}
|
||||
|
||||
int x = dx;
|
||||
int y = dy;
|
||||
|
||||
int dw = 0;
|
||||
int dh = 0;
|
||||
if (win->m_hasScrolling)
|
||||
{
|
||||
GetScrollbarWidth(widget, dw, dh);
|
||||
|
||||
if (win->GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
{
|
||||
// This is actually wrong for old GTK+ version
|
||||
// which do not display the scrollbar on the
|
||||
// left side in RTL
|
||||
x += dw;
|
||||
}
|
||||
}
|
||||
|
||||
int w = widget->allocation.width-dw;
|
||||
int h = widget->allocation.height-dh;
|
||||
|
||||
if (win->HasFlag(wxRAISED_BORDER))
|
||||
{
|
||||
gtk_paint_shadow (widget->style,
|
||||
@@ -361,8 +374,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win )
|
||||
GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_OUT,
|
||||
NULL, NULL, NULL, // FIXME: No clipping?
|
||||
dx, dy,
|
||||
widget->allocation.width-dw, widget->allocation.height-dh );
|
||||
x, y, w, h );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,8 +385,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win )
|
||||
GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_IN,
|
||||
NULL, NULL, NULL, // FIXME: No clipping?
|
||||
dx, dy,
|
||||
widget->allocation.width-dw, widget->allocation.height-dh );
|
||||
x, y, w, h );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -383,9 +394,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win )
|
||||
GdkGC *gc;
|
||||
gc = gdk_gc_new( widget->window );
|
||||
gdk_gc_set_foreground( gc, &widget->style->black );
|
||||
gdk_draw_rectangle( widget->window, gc, FALSE,
|
||||
dx, dy,
|
||||
widget->allocation.width-dw-1, widget->allocation.height-dh-1 );
|
||||
gdk_draw_rectangle( widget->window, gc, FALSE, x, y, w-1, h-1 );
|
||||
g_object_unref (gc);
|
||||
return;
|
||||
}
|
||||
@@ -2460,6 +2469,8 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
||||
|
||||
m_scrollBar[ScrollDir_Horz] = GTK_RANGE(scrolledWindow->hscrollbar);
|
||||
m_scrollBar[ScrollDir_Vert] = GTK_RANGE(scrolledWindow->vscrollbar);
|
||||
if (GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
gtk_range_set_inverted( m_scrollBar[ScrollDir_Horz], TRUE );
|
||||
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
|
||||
@@ -3764,6 +3775,7 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect )
|
||||
gdk_rect.height = rect->height;
|
||||
if (GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
gdk_rect.x = GetClientSize().x - gdk_rect.x - gdk_rect.width;
|
||||
|
||||
p = &gdk_rect;
|
||||
}
|
||||
else // invalidate everything
|
||||
@@ -3829,8 +3841,6 @@ void wxWindowGTK::GtkSendPaintEvents()
|
||||
// Clip to paint region in wxClientDC
|
||||
m_clipPaintRegion = true;
|
||||
|
||||
wxRegion maybe_rtl_region = m_updateRegion;
|
||||
|
||||
#if 0
|
||||
if (GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
{
|
||||
@@ -3893,8 +3903,6 @@ void wxWindowGTK::GtkSendPaintEvents()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_updateRegion = maybe_rtl_region;
|
||||
|
||||
wxWindowDC dc( (wxWindow*)this );
|
||||
dc.SetClippingRegion( m_updateRegion );
|
||||
|
||||
@@ -3904,8 +3912,6 @@ void wxWindowGTK::GtkSendPaintEvents()
|
||||
GetEventHandler()->ProcessEvent(erase_event);
|
||||
}
|
||||
|
||||
m_updateRegion = maybe_rtl_region;
|
||||
|
||||
wxNcPaintEvent nc_paint_event( GetId() );
|
||||
nc_paint_event.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( nc_paint_event );
|
||||
@@ -4290,8 +4296,8 @@ void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
|
||||
pos = max;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
m_scrollPos[dir] =
|
||||
adj->value = pos;
|
||||
m_scrollPos[dir] = adj->value = pos;
|
||||
|
||||
// If a "value_changed" signal emission is not already in progress
|
||||
if (!m_blockValueChanged[dir])
|
||||
{
|
||||
@@ -4344,7 +4350,9 @@ wxEventType wxWindowGTK::GetScrollEventType(GtkRange* range)
|
||||
|
||||
const int barIndex = range == m_scrollBar[1];
|
||||
GtkAdjustment* adj = range->adjustment;
|
||||
|
||||
const int value = int(adj->value + 0.5);
|
||||
|
||||
// save previous position
|
||||
const double oldPos = m_scrollPos[barIndex];
|
||||
// update current position
|
||||
@@ -4390,7 +4398,10 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
|
||||
|
||||
m_clipPaintRegion = true;
|
||||
|
||||
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy );
|
||||
if (GetLayoutDirection() == wxLayout_RightToLeft)
|
||||
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), dx, -dy );
|
||||
else
|
||||
gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy );
|
||||
|
||||
m_clipPaintRegion = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user