Roger Binns wrote:
I have implemented a way of "sizing" some HTML and it mostly
works, but I was wondering if anyone has a better way.My goal is given a chunk of HTML, work out the area it
occupies. I need this for two reasons. One was for
a custom grid cell renderer, where I need to respond
to the best size method, and the second is where I
want the equivalent a text widget that sizes itself
correctly. I typically use it in about boxes and
as the top widget in a dialog box with instructions.The way I solved the problem was brute force. I start
with a really wide area and measure how high the resulting HTML is. I then keep narrowing the
area until the height increases which indicates
that the area got narrow enough to wrap a line.An alternate idea I had was to render to a bitmap/memorydc,
but I couldn't find an efficient way of working out
the area modified.
Try dc.MaxX() and dc.MaxY() (or dc.GetBoundingBox()) They should tell you how much of the dc has been touched by any drawing commands that have been done so far.
I am also not too convinced that
rendering to a memorydc results in the exact same pixels
as rendering to a real dc
It does. (Or is supposed to anyway.)
ยทยทยท
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!