#include "wx/dcmemory.h"
#include "wx/math.h" // for floating-point functions
#include "wx/image.h"
+ #include "wx/module.h"
#endif
-#include "wx/module.h"
#include "wx/fontutil.h"
+#include "wx/scrolwin.h"
#include "wx/gtk/win_gtk.h"
#include "wx/gtk/private.h"
standard (as e.g. wxStatusBar) */
m_owner = window;
+
+ if (m_owner && m_owner->m_wxwindow && (m_owner->GetLayoutDirection() == wxLayout_RightToLeft))
+ {
+ // 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;
+ }
+ }
}
wxWindowDC::~wxWindowDC()
int w = bitmap.GetWidth();
int h = bitmap.GetHeight();
-
+
+ if (m_owner && m_owner->GetLayoutDirection() == wxLayout_RightToLeft)
+ xx -= w;
+
CalcBoundingBox( x, y );
CalcBoundingBox( x + w, y + h );
}
// Draw layout.
- gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
+ if (m_owner && m_owner->GetLayoutDirection() == wxLayout_RightToLeft)
+ gdk_draw_layout( m_window, m_textGC, x-w, y, m_layout );
+ else
+ gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
// reset unscaled size
pango_font_description_set_size( m_fontdesc, oldSize );
gdk_draw_rectangle(m_window, m_textGC, TRUE, x, y, w, h);
gdk_gc_set_foreground(m_textGC, m_textForegroundColour.GetColor());
}
+
// Draw layout.
- gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
+ if (m_owner && m_owner->GetLayoutDirection() == wxLayout_RightToLeft)
+ gdk_draw_layout( m_window, m_textGC, x-w, y, m_layout );
+ else
+ gdk_draw_layout( m_window, m_textGC, x, y, m_layout );
}
if (underlined)
wxCoord wxWindowDC::GetCharHeight() const
{
- PangoFontMetrics *metrics = pango_context_get_metrics (m_context, m_fontdesc, NULL);
+ PangoFontMetrics *metrics = pango_context_get_metrics (m_context, m_fontdesc, pango_context_get_language(m_context));
return PANGO_PIXELS (pango_font_metrics_get_descent (metrics) + pango_font_metrics_get_ascent (metrics));
}
rect.width = XLOG2DEVREL(width);
rect.height = YLOG2DEVREL(height);
+ if (m_owner && m_owner->m_wxwindow && (m_owner->GetLayoutDirection() == wxLayout_RightToLeft))
+ {
+ rect.x -= rect.width;
+ }
+
if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( rect );
else
m_bgGC = (GdkGC*) NULL;
}
+void wxWindowDC::SetDeviceOrigin( wxCoord x, wxCoord y )
+{
+ m_deviceOriginX = x;
+ m_deviceOriginY = y;
+
+ ComputeScaleAndOrigin();
+}
+
+void wxWindowDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
+{
+ m_signX = (xLeftRight ? 1 : -1);
+ m_signY = (yBottomUp ? -1 : 1);
+
+ if (m_owner && m_owner->m_wxwindow && (m_owner->GetLayoutDirection() == wxLayout_RightToLeft))
+ m_signX = -m_signX;
+
+ ComputeScaleAndOrigin();
+}
+
void wxWindowDC::ComputeScaleAndOrigin()
{
const wxRealPoint origScale(m_scaleX, m_scaleY);