]> git.saurik.com Git - wxWidgets.git/commitdiff
handlers added using AddHandler() last must have the highest priority (patch 1522807)
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 25 Jul 2006 00:33:14 +0000 (00:33 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 25 Jul 2006 00:33:14 +0000 (00:33 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43590 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/gtk/dcclient.h
src/gtk/dcclient.cpp

index 0239bc5cddb2da14f666296dcf055c17690c5318..de91b5c126025c948a3090d16945e7586bca3755 100644 (file)
@@ -69,6 +69,7 @@ protected:
                                 wxCoord *descent = (wxCoord *) NULL,
                                 wxCoord *externalLeading = (wxCoord *) NULL,
                                 wxFont *theFont = (wxFont *) NULL) const;
+    virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
     virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
     virtual void DoSetClippingRegionAsRegion( const wxRegion &region );
 
index 15b718f7a546e7872a7f7d802c6593b7cf1a159d..6022888051ce8cfa903778129f635f3db8589b76 100644 (file)
@@ -1775,6 +1775,51 @@ void wxWindowDC::DoGetTextExtent(const wxString &string,
         pango_layout_set_font_description( m_layout, m_fontdesc );
 }
 
+
+bool wxWindowDC::DoGetPartialTextExtents(const wxString& text,
+                                         wxArrayInt& widths) const
+{
+    const size_t len = text.length();
+    widths.Empty();
+    widths.Add(0, len);
+
+    if (text.empty())
+        return true;
+
+    // Set layout's text
+    const wxCharBuffer dataUTF8 = wxGTK_CONV_FONT(text, m_font);
+    if ( !dataUTF8 )
+    {
+        // hardly ideal, but what else can we do if conversion failed?
+        wxLogLastError(wxT("DoGetPartialTextExtents"));
+        return false;
+    }
+
+    pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
+    
+    // Calculate the position of each character based on the widths of
+    // the previous characters
+
+    // Code borrowed from Scintilla's PlatGTK
+    PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
+    PangoRectangle pos;
+    pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+    size_t i = 0;
+    while (pango_layout_iter_next_cluster(iter))
+    {
+        pango_layout_iter_get_cluster_extents(iter, NULL, &pos);
+        int position = PANGO_PIXELS(pos.x);
+        size_t curIndex = pango_layout_iter_get_index(iter);
+        widths[i++] = position;
+    }
+    while (i < len)
+        widths[i++] = PANGO_PIXELS(pos.x + pos.width);
+    pango_layout_iter_free(iter);
+
+    return true;
+}
+
+
 wxCoord wxWindowDC::GetCharWidth() const
 {
     pango_layout_set_text( m_layout, "H", 1 );