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

Re: botton size ?

pei zeng (pei@prism-cs.com) writes:

> I have a dumb question: when I place 3 button with value 'Apply', 'OK' and
> 'Cancel', respectively, in one row, the buttons will have different size,
> and I can not find a way to make them have the exact same size. Can anybody
> help me?

When a button is created it has a "natural" size that depends
upon the text on the button. Buttons size themselves to fit
what is on them, normally. You can explicitly size buttons
with the Scr_XSize and Scr_YSize keywords, but this is not
always a good idea, since people prefer different fonts,
different font sizes, etc., and your button interface can
end up looking decidedly unprofessional.

Still...you sometimes want a neat, all-the-same-size
look. I know I do. :-)

So what I usually do is this:

   1. Create the buttons with their "natural" size.

   2. Before I realize the widget hierarchy, I find out
      the size of the largest button. The code will look
      something like this:

      big_size = 0
      FOR j=0,2 DO BEGIN
	  g = Widget_Info(buttonsID[j], Geometry)
         big_size = big_size > g.scr_xsize

   3. Make all the buttons the same big size. The code
      looks like this:

      FOR j=0,2 DO Widget_Control, buttonsID[j], Scr_XSize=big_size

This works with *most* widgets. For example, I find that you
can't resize droplist widgets this way on UNIX platforms 
(although the documentation gives no indication that it won't
work). On machines were it works all the time (I.e., Windows),
it works like a charm. :-)


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