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) )
}
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 );
}
}
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 );
}
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;
}
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;
}
{
// 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;
}
}
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))
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,
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;
}
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;
}
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;
}
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();
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
// Clip to paint region in wxClientDC
m_clipPaintRegion = true;
- wxRegion maybe_rtl_region = m_updateRegion;
-
#if 0
if (GetLayoutDirection() == wxLayout_RightToLeft)
{
}
else
{
- m_updateRegion = maybe_rtl_region;
-
wxWindowDC dc( (wxWindow*)this );
dc.SetClippingRegion( m_updateRegion );
GetEventHandler()->ProcessEvent(erase_event);
}
- m_updateRegion = maybe_rtl_region;
-
wxNcPaintEvent nc_paint_event( GetId() );
nc_paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( nc_paint_event );
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])
{
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
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;
}