On 2015-02-27 22:12-0000 Phil Rosenberg wrote:

Hi Alan

Yes I believe this is doable in wxWidgets. I'm sure I remember
coding it up when I added newline support so I think the code is
already in the driver if you look. I guess I never realised this
needed plumbing into the core code.

Should be a very easy fix if you know how to feed the sizes back in.

I have put in that necessary plumbing (see attached patch) but it
isn't working correctly (produces strange looking results for example
26).

Note, for git format-patch I used the --ignore-all-space option so
that the patch does not reflect the local styling changes I made, but
does give the essence of most of the changes you should need to get
the example 26 legend size to be correct.

I hope some minor correction is all that is needed to make this patch
work, but I cannot figure out what that correction is (probably
because I am not that familiar with the wxwidgets device code) so I
hope you can figure out that correction instead.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
From ff7f505975d6c0137d81d2aefe7f1b76b17e37b8 Mon Sep 17 00:00:00 2001
From: "Alan W. Irwin" <air...@users.sourceforge.net>
Date: Fri, 27 Feb 2015 15:59:51 -0800
Subject: [PATCH] wxwidgets device: install plumbing for
 has/get_string_length.

This should be almost there, but produces incorrect rendering results for
example 26 so obviously needs more work from someone who knows
more about the wxwidgets device driver than I do.
---
 drivers/wxwidgets_dev.cpp |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/wxwidgets_dev.cpp b/drivers/wxwidgets_dev.cpp
index b850f4e..45febac 100644
--- a/drivers/wxwidgets_dev.cpp
+++ b/drivers/wxwidgets_dev.cpp
@@ -194,6 +194,7 @@ wxPLDevice::wxPLDevice( PLStream *pls, char * mfo, PLINT text, PLINT hrshsym )
     {
         pls->dev_text          = 1; // want to draw text
         pls->dev_unicode       = 1; // want unicode
+        pls->has_string_length = 1; // Driver supports string length calculations
         if ( hrshsym )
             pls->dev_hrshsym = 1;
     }
@@ -769,7 +770,8 @@ void wxPLDevice::ProcessString( PLStream* pls, EscText* args )
     bool      lineFeed       = false;
     bool      carriageReturn = false;
     wxCoord   paraHeight     = 0;
-    // Get the curent font
+    wxCoord   max_textWidth  = 0;
+    // Get the current font
     m_fontScale = 1.0;
     m_yOffset   = 0.0;
     plgfci( &m_fci );
@@ -799,6 +801,12 @@ void wxPLDevice::ProcessString( PLStream* pls, EscText* args )
         m_posY = args->y / m_yScale;
         DrawText( lineStart, lineLen, false );
 
+        if ( pls->get_string_length )
+        {
+            max_textWidth = m_textWidth > max_textWidth ? m_textWidth : max_textWidth;
+        }
+        else
+        {
             if ( lineFeed && m_superscriptHeight > m_textHeight )
                 paraHeight += m_superscriptHeight - m_textHeight;
 
@@ -862,13 +870,18 @@ void wxPLDevice::ProcessString( PLStream* pls, EscText* args )
                 m_posY = (PLINT) ( args->y / m_yScale - ( args->just * m_textWidth ) * sin_rot + ( 0.5 * m_textHeight - paraHeight * m_lineSpacing ) * cos_rot );
                 DrawText( lineStart, lineLen, true );
             }
-
+        }
 
         lineStart += lineLen;
         if ( carriageReturn )
             lineStart++;
         lineLen = 0;
     }
+
+    if ( pls->get_string_length )
+    {
+        pls->string_length = (PLFLT) max_textWidth * 25.4 / 72.0;
+    }
 }
 
 //--------------------------------------------------------------------------
-- 
1.7.10.4

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to