X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/280831d5dddee274a37618fdfd15a166ef4df1fb..26af4dbd0a733de7df04c50acde5b4747f7fff24:/src/gtk/dcclient.cpp diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 7c724b05ae..7d8b303bc6 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -17,14 +17,16 @@ #include "wx/dcclient.h" #ifndef WX_PRECOMP + #include "wx/window.h" #include "wx/log.h" #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" @@ -322,6 +324,45 @@ wxWindowDC::wxWindowDC( wxWindow *window ) 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() @@ -1038,7 +1079,10 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, 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 ); @@ -1166,8 +1210,8 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, if (!m_window) return false; // transform the source DC coords to the device ones - xsrc = source->XLOG2DEV(xsrc); - ysrc = source->YLOG2DEV(ysrc); + xsrc = source->LogicalToDeviceX(xsrc); + ysrc = source->LogicalToDeviceY(ysrc); wxClientDC *srcDC = (wxClientDC*)source; wxMemoryDC *memDC = (wxMemoryDC*)source; @@ -1450,7 +1494,10 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) } // 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 ); @@ -1467,8 +1514,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) 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) @@ -1666,7 +1717,7 @@ wxCoord wxWindowDC::GetCharWidth() const 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)); } @@ -2101,6 +2152,11 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo 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 @@ -2196,6 +2252,25 @@ void wxWindowDC::Destroy() 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);