[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IDLgrLegend geometry

"David Fanning" <davidf@dfanning.com> wrote in message
> George Constantinides (gconstantinides@mhl.nsw.gov.au) writes:
> > I was resizing an IDLgrWindow object and noticed that objects such as
> > IDLgrAxis, IDLgrPlot,IDLgrText resized correctly to fit the new
> > dimensions, but IDLgrLegend did not.
> > [...]
> Humm. It's pretty clear that the author of IDLgrLegend
> was *trying* to solve this problem in the ComputeDimensions
> method. Have you tried using this when you resize or change
> to another destination device? It looks to me like this
> would solve all your problems, although I confess I've
> never used IDLgrLegend.

>From my reading of the IDLgrLegend code in version 5.4, ComputeDimensions is
called every time the legend is re-drawn, so there should be no need to call
it manually. ComputeDimensions recalculates the dimensions of the legend's
atoms based on the character size of the legend text, and since the text
objects are created with RECOMPUTE_DIMENSIONS = 2, the legend should be
resized every time it is drawn.

In fact on my system legends do get resized as the size of the destination
device changes! I wonder why they don't on yours, George. What version are
you using? Do you have a line that looks like this in the CreateGlyphs
method in idlgrlegend__define.pro?

      (*self.pTexts)[index] = OBJ_NEW('IDLgrText', $
                                      FONT = self.oFont, $
                                      COLOR = (*self.pText_Color), $
                                      STRINGS = (*self.pItem_Name)[index],$
                                      RECOMPUTE_DIMENSIONS = 2)

If you want to debug this you could put a break in ComputeDimensions and see
what's happening. (Warning: you may be surprised how often a model's Draw
method is called.)

Mark Hadfield
m.hadfield@niwa.cri.nz  http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research