]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/dcclient.cpp
don't include generic/statusbr.h directly
[wxWidgets.git] / src / gtk / dcclient.cpp
index 7c724b05ae07f3add04d2a7d985e2367a820b788..d99ad46033181ef4dc6a15caea8c365301822284 100644 (file)
 #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,44 @@ 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
+        wxScrolledWindow *sw = wxDynamicCast( m_owner, wxScrolledWindow );
+        if (sw)
+        {
+            // 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.
+            if (sw->GetScrollLines(wxHORIZONTAL) == 0)
+            {
+                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 width = steps * scroll_step + (client_width % scroll_step);
+                m_deviceOriginX = width;
+            }
+        }
+        else
+        {
+            int client_width = m_owner->GetClientSize().x;
+            m_deviceOriginX = client_width;
+        }
+    }
 }
 
 wxWindowDC::~wxWindowDC()
@@ -1038,7 +1078,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 +1209,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 +1493,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 +1513,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 +1716,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));
 }
 
@@ -2196,6 +2246,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);