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;
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);
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.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.