SourceForge has been redesigned. Learn more.

mpText::Plot is wrong

  • Anton41

    Anton41 - 2007-11-15

    After spending days trying to figure out why my mpText did not print correctly I found two things with mpText::Plot.

    First; x and y is switched, m_offsetx is used for calculating y position and vice versa.
    Second; It will only position the mpText correctly if the user scale is 1.0.

    void mpText::Plot(wxDC & dc, mpWindow & w)
        wxCoord tw=0, th=0;
        dc.GetTextExtent( GetName(), &tw, &th);
        double xscale, yscale;
        dc.GetUserScale(&xscale, &yscale);
        int left = -dc.LogicalToDeviceX(0)/xscale;
        int width = 2*left;//dc.LogicalToDeviceX(0) - left;
        if (width<0) width = -width; /// This is abs()
        int bottom = dc.LogicalToDeviceY(0)/yscale;
        int height = 2*bottom;// - -dc.LogicalToDeviceY(0);

        int xxx = (int)((((float)width/100.0) * m_offsetx) + left - (tw/2)); //This is correct
        int yyy =  (int)((((float)height/100.0) * m_offsety) - bottom);

        dc.DrawText( GetName(),
        yyy );

    • cdron77

      cdron77 - 2008-07-03

      The draw behaviour has been changed recently, so I figure out that mpText continued to use an old-fashioned drawing reference. Try the Subversion code, or just wait for the next release (I hope it'll come soon) to fix it.


Log in to post a comment.