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

Re: IDLgrLegend geometry

Mark Hadfield (m.hadfield@niwa.cri.nz) writes:
> 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)

Speaking of the RECOMPUTE_DIMENSIONS keyword, I realized
in the last object class I taught that my understanding
of what this keyword does was exactly the opposite of
what it *actually* does. (I discovered this when some
overzealous student actually typed the commands I said
to type and discovered that the program did the opposite
of what I said it would do. I *hate* students like this.)

This whole question suddenly rang some bells with me,
and I spent some time this evening going through the 
documentation very s-l-o-w-l-y, trying to understand

Text characters are sized according to a text "box",
whose width and height are given in the "data" units
of your arbitrary coordinate system. (See the
can do is tell you when to recompute the size of that
text box. For example, if you change the data range,
you will probably want to recompute your text box.

But, and here is the point I was confused about, if
you are just re-sizing the graphic there is no need
to recompute the text box, since the data range
doesn't change at all. In fact, in resizing windows
you explicitly do NOT want to recompute dimensions.

You can see this by downloading the Simple_Surface
program from my web page:


In this program, I have RECOMPUTE_DIMENSIONS set to
2. Notice when you resize the window that the text
sizes remain the same size. (I still doesn't understand
why this should be so, and I am looking for enlightenment
on this point.) But if you change all the RECOMPUTE_DIMENSIONS=2
to RECOMPUTE_DIMENSIONS=0 you will find that the text
is size proportionally to the axes, the data, etc. This
is the behaviour I want.

So, (sorry for the stream of consciousness here, it is
late and I am very tired), why, if I don't change the
data coordinate system at all, simply resize the window
and then recompute the text box dimensions, does the
text *always* stay the same size? Is it because a 14
point font is a particular size regardless of the size
of the output window? 

Mark!? Are you back from lunch yet? :-)



P.S. I think IDLgrLegend works correctly because the
author is calculating new text box sizes for each
draw. Thus, he *should* recompute the dimensions
before every draw. But this seems VERY low-level
to me. Is this really necessary?

David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155