| Re: GUI size on different screens [message #51665 is a reply to message #51576] |
Wed, 29 November 2006 18:00   |
Harvey Rarback
Messages: 24 Registered: September 1998
|
Junior Member |
|
|
Folks,
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.1fd5180abec66622989de8@news.frii.com...
> Lory writes:
>
>> Ok, I see that it is not the "correct" way... but how should I do to
>> develop programs in the "right" way with the goal that they could be
>> used under PC with different configuration?
[snip]
>> I undestand that if I wrote the software optimizing it, for example,
>> for 1024x768, it would run even with resolution higher than that, but
>> it would not exploit the capabilities of high resolution screen
>> ...Instead, I would like a software optimized for 1600x1200, but usable
>> with 1024x768, 1280x1024 etc. Scroll bars are a good suggestion, but is
>> there a way to know if the widget need a scroll bar? is there a way to
>> put a scroll bar only if the natural size of the widget is greater of
>> the screen size?
>
> I don't know how this works in UNIX, but on Windows I can set
> a scroll X and Y size on my TLB for the screen resolution (I
> use Get_Screen_Size() jiggered, of course, by appropriate fudge
> factors to account for the task bar, window decorations and the like).
> If the final widget application is less than that size, no scroll bars
> appear. If it is larger, then I get scroll bars.
>
>> For example: I have GUIs that in high resolution take more or less 2/3
>> of the screen but in low resolution go off the screen. I want put a
>> scoll bar in the second case, but I don't want resize the GUIs in the
>> first case and I don't want check by hand every screen configuration to
>> decide if a scroll bar is required or not. I could do that in automatic
>> if I know the GUI size before realizing it, by comparing its natural
>> size with the screen size, but I don't know if it is possible.
>
> To do size tinkering, I often get the geometry of a widget after
> it has been created and filled, but before it is realized. Using
> the geometry values, I can size other widgets, etc. Then, when the
> widgets get realized, they are all the correct size, as if by magic.
>
> (You don't know the meaning of "frustration" until you have tried
> to size a status bar widget to the exact dimensions of the widgets
> in the window along with it. After careful accounting of every XPAD,
> YPAD, SPACE, etc., etc., there is still a fudge factor of 6--or
> is it 4?--that never gets canceled out in the arithmetic. It drives
> you absolutely MAD!!)
And now for the totally anal:
I like to create resizable windows with resizable fonts so that the initial
TLBs fit on
the screen, but can be resized to suit the user's preference. This scheme
works as
follows.
- Function get_fonts( font_size ) returns a structure of font names having
elements
like "default", "label", "big_menu", etc. These font names are OS-dependent
and are
used in all widget fonts. The font_size parameter is used to collect fonts
that
look good together.
- A target size and offset for the TLB is calculated based on the screen
size.
- The TLB is created (but not realized) by trying the font_sizes starting
from
the largest. The layout of the child widgets avoids using absolute sizes
whenever
possible. The widest widget sets the scale for the other widgets sizes,
PADs,
SPACEs, etc. As David acknowledges, this part of the widget design can be
frustrating,
but is an analist's delight. If the dimensions of the TLB are less than the
target dimensions,
the widget is realized. Otherwise, it is destroyed, the font_size is
decreased and the widget
creation routine is tried again.
- The resize event handler uses the X and Y event fields to set the new
target size and
calls the same widget creation routine before destroying the old TLB.
If any fellow analists are interested, I can supply more details. You know
the code is good:
it's been running for the last decade on VMS IDL 5.3!
--Harvey
----
Harvey Rarback phone: (650)926-3963
Stanford Linear Accelerator Center
2575 Sand Hill Road
Menlo Park, CA 94025
rarback@slac.stanford.edu http://ssrl.slac.stanford.edu/~rarback
"Always tell the truth, that way you don't have to keep track."
Pogo
|
|
|
|