comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » GUI size on different screens
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
GUI size on different screens [message #51512] Thu, 23 November 2006 10:37 Go to next message
lory is currently offline  lory
Messages: 6
Registered: November 2006
Junior Member
Hi,
I developed a software in IDL with a large number of GUIs. The screen
resolution of my PC is 1600x1200 and the GUIs are correctly sized for
this kind of screen. I did not use explicit sizing of the widgets,
since I need to use both linux and windows systems. Now, I installed my
software on a laptop with a 1024x768 pixels screen and ... the software
is totally useless since the GUIs are too large and go off the screen !
Is there any simple solution to this problem? There is any way to
resize characters, buttons and so on accordingly with the screen size?
Please, I don't want to rewrite all the code to fit the 1024x768 pixels
! It's a lot of code !

thanks

lory
Re: GUI size on different screens [message #51576 is a reply to message #51512] Mon, 27 November 2006 14:43 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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?

I'm not sure there is a "correct" or "right" way to write
these programs. But there are certainly some ways that are
better than others. You seem to be discovering some of these. :-)

> When I started this project, I tried not using explicit sizing of
> widgets because I realized that this can be a problem when the software
> must be used under different OS and I want that my software could run
> under both Windows and Linux (and something else ...). Very soon I
> realized that it is not possible to write an IDL program really working
> at the same way under different OS.

Well, it's not as easy as the IDL marketing materials might
lead you to believe, certainly. But with some precautions,
I think IDL does a fairly decent job. And, to be fair, it IS
a hard job!

> 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!!)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: GUI size on different screens [message #51579 is a reply to message #51512] Mon, 27 November 2006 14:07 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mike writes:

> One more suggestion that I haven't seen yet: when I really want to save
> a few pixels, I set xpad=0 and ypad=0 in my calls to widget creation
> functions. This packs them tighter, especially when I'm using many
> nested widget_base's.

Yes, I've gotten so used to doing this I forget to even
mention it. I first noticed this "base decoration" problem
on Windows XP, when it seemed all my widgets suddenly got
5-10% bigger than they used to be. :-(

Incidentally, Andrew Cool's little WindowSize kludge
seems to subtract this "decoration" size from the window
size it reports, whereas the GetPrimaryScreenSize function
Dick Jackson alerted us to does not. The result is that
if you make a "normal" window with the "Cool" size, the
window is what you expect, whereas if you make one with
the "Jackson" size, the window slips down behind the
task bar by about 6 pixels. Not a big deal, but another
thing to keep in mind.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: GUI size on different screens [message #51662 is a reply to message #51512] Thu, 30 November 2006 16:07 Go to previous message
Harvey Rarback is currently offline  Harvey Rarback
Messages: 24
Registered: September 1998
Junior Member
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.1fd7eedbd3e10bde989e01@news.frii.com...
> Harvey Rarback writes:
>
>> 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.
>
> Harvey, where in the world have you been!? I can't believe
> it takes resizeable fonts to draw you out of the shadows. :-)
>
> By all means, let's see that GET_FONTS function. That's
> the one we are ALL missing!
>
> I'd be delighted to host this if it is something that
> can be made available on my web page. I think we are
> now only one or two tools away from cracking this nut.
> (Although Dick and Andrew are still discussing a two
> pixel discrepancy in screen size that none of us can
> account for. Andrew calls them poxels, and I think he
> may be right.)

This is so trivial that I am almost embarrassed to display the code here,
but you asked for it. Its origin is lost in the mists of time, but I
believe Mark Rivers was responsible for this. We didn't document back then
;-)

function get_fonts, font_size=font_size
compile_opt idl2

if n_elements( font_size ) eq 0 then font_size = 2
fonts = {application_fonts, $
default: get_font_name( /helvetica, size=font_size ), $
menu: get_font_name( /bold, size=font_size ), $
big_menu: get_font_name( /bold, size=font_size+1 ), $
label: get_font_name( /bold, /italic, size=font_size ), $
big_label: get_font_name( /bold, /italic, size=font_size+1 ), $
button: get_font_name( size=font_size ), $
big_button: get_font_name( size=font_size+1 ), $
text: get_font_name( size=font_size ), $
big_text: get_font_name( size=font_size+1 ), $
message: get_font_name( size=font_size-1 ), $
symbol: get_font_name( /symbol, size=font_size ), $
big_symbol: get_font_name( /symbol, size=font_size+1 ) $
}

return, fonts
end


function get_font_name, $
helvetica=helvetica, times=times, courier=courier, symbol=symbol, $
tiny=tiny, small=small, medium=medium, large=large, huge=huge, $
giant=giant, $
size=size, $
bold=bold, italic=italic, $
dpi75=dpi75, dpi100=dpi100

; Returns the name of the font with the specified characteristics

if (!version.os_family eq 'Windows') then begin
font = ''
if keyword_set(helvetica) then font = font + 'Helvetica' else $
if keyword_set(times) then font = font + 'Times' else $
if keyword_set(courier) then font = font + 'Courier New' else $
if keyword_set(symbol) then font = font + 'Symbol' else $
font = font + 'MS San Serif'
if keyword_set(bold) then font = font + '*Bold'
if keyword_set(italic) then font = font + '*Italic'
if keyword_set(tiny) then size=0
if keyword_set(small) then size=1
if keyword_set(medium) then size=2
if keyword_set(large) then size=3
if keyword_set(huge) then size=4
if (n_elements(size) eq 0) then size=2
; font_size_strings = ['12', '14', '16', '18', '20']
font_size_strings = ['8', '12', '16', '20', '24']
size = (size > 0) < (n_elements(font_size_strings) - 1)
font = font + '*' + font_size_strings( size )
return, font
endif else if (!version.os_family eq 'Mac') then begin
font='Helvetica'
return, font
endif else begin ; Assume Motif
font = '-adobe-'
if keyword_set(helvetica) then font = font + 'helvetica-' else $
if keyword_set(times) then font = font + 'times-' else $
if keyword_set(courier) then font = font + 'courier-' else $
if keyword_set(symbol) then font = font + 'symbol-' else $
font = font + 'helvetica-'

if keyword_set(bold) then font = font + 'bold-' else font = font +
'medium-'
if keyword_set(italic) then font = font + 'o-' else font = font + 'r-'
font = font + 'normal--*-'
if keyword_set(tiny) then size=0
if keyword_set(small) then size=1
if keyword_set(medium) then size=2
if keyword_set(large) then size=3
if keyword_set(huge) then size=4
if keyword_set(giant) then size=5
if (n_elements(size) eq 0) then size=2
font_size_strings = ['80-', '100-', '120-', '140-', '180-', '240-']
size = (size > 0) < (n_elements(font_size_strings) - 1)
font = font + font_size_strings(size)

if keyword_set(dpi100) then font = font + '100-100-' else $
if keyword_set(dpi75) then font = font + '75-75-' else $
font = font + '*-*-'
if keyword_set(symbol) then font = font + '*-*-*-*' else $
font = font + '*-*-iso8859-1'
return, font
endelse

end
Re: GUI size on different screens [message #51664 is a reply to message #51512] Wed, 29 November 2006 18:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Harvey Rarback writes:

> 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.

Harvey, where in the world have you been!? I can't believe
it takes resizeable fonts to draw you out of the shadows. :-)

By all means, let's see that GET_FONTS function. That's
the one we are ALL missing!

I'd be delighted to host this if it is something that
can be made available on my web page. I think we are
now only one or two tools away from cracking this nut.
(Although Dick and Andrew are still discussing a two
pixel discrepancy in screen size that none of us can
account for. Andrew calls them poxels, and I think he
may be right.)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: GUI size on different screens [message #51665 is a reply to message #51576] Wed, 29 November 2006 18:00 Go to previous message
Harvey Rarback is currently offline  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
Re: GUI size on different screens [message #51671 is a reply to message #51512] Wed, 29 November 2006 12:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rick Towler writes:

> This thread awakens a long suppressed annoyance with IDL and its lack of
> a default window/widget re-sizing event handler. Would it not be
> possible to say specify that a tlb be resizable, *not* specify a resize
> event handler, and have IDL automagically scale all of the widgets
> proportionally?
>
> I'm sure a number of people are hitting reply right now to propose cases
> where this behavior wouldn't be desirable. And they'd be right. And
> they could write their own resize event handler. But there are a lot of
> cases where this re-sizing behavior is quite acceptable. In Lory's
> case, a few lines of code could resize the entire gui, instead of having
> to rework much of the gui creation code.

This was one of our ambitious goals for the Catalyst Library
when Dave Burridge and I first wrote it. I'll bet Dave told
me 30 times that he "had the problem solved", only to have
his spirits crushed when I could come up with a counter-example
in less than five minutes. (Of course, we weren't working
with some of Dick Jackson's nifty tools then, either.)

Some days I became convinced that IDL was substituting
random numbers for widget geometry, but this was corrected,
more or less, by adjusting the dosage of my medication.

I'm just saying, it was one frustrating time in my life.

I'd like to see it happen, too. But I am *definitely* not
going to be counting on it. :-(

Cheers,

David

P.S. I even got (I think) this to work for a *single* widget,
a status bar. I was so excited I was going to write an article
about it, but I notice the article is not on my web page. I'm
trying to remember why not. Probably because I *still* had to
use a fudge factor that I couldn't explain away.

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: GUI size on different screens [message #51674 is a reply to message #51512] Wed, 29 November 2006 09:18 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
This thread awakens a long suppressed annoyance with IDL and its lack of
a default window/widget re-sizing event handler. Would it not be
possible to say specify that a tlb be resizable, *not* specify a resize
event handler, and have IDL automagically scale all of the widgets
proportionally?

I'm sure a number of people are hitting reply right now to propose cases
where this behavior wouldn't be desirable. And they'd be right. And
they could write their own resize event handler. But there are a lot of
cases where this re-sizing behavior is quite acceptable. In Lory's
case, a few lines of code could resize the entire gui, instead of having
to rework much of the gui creation code.

-Rick



lory wrote:
> Hi,
> I developed a software in IDL with a large number of GUIs. The screen
> resolution of my PC is 1600x1200 and the GUIs are correctly sized for
> this kind of screen. I did not use explicit sizing of the widgets,
> since I need to use both linux and windows systems. Now, I installed my
> software on a laptop with a 1024x768 pixels screen and ... the software
> is totally useless since the GUIs are too large and go off the screen !
> Is there any simple solution to this problem? There is any way to
> resize characters, buttons and so on accordingly with the screen size?
> Please, I don't want to rewrite all the code to fit the 1024x768 pixels
> ! It's a lot of code !
>
> thanks
>
> lory
>
Re: GUI size on different screens [message #51684 is a reply to message #51512] Tue, 28 November 2006 11:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
lory writes:

> How do you get the geometry of the widget? (I checked the help without
> success ..., sorry if it is a stupid question)

geometry = Widget_Info(widgetID, /Geometry)
help, geometry, /Structure

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: GUI size on different screens [message #51687 is a reply to message #51576] Tue, 28 November 2006 11:34 Go to previous message
lory is currently offline  lory
Messages: 6
Registered: November 2006
Junior Member
>
> To do size tinkering, I often get the geometry of a widget after
> it has been created and filled, but before it is realized.

How do you get the geometry of the widget? (I checked the help without
success ..., sorry if it is a stupid question)

> 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.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: objects, crashes, and negative memory oh my
Next Topic: IDLgrPlot Axis scaling bug?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:23:10 PDT 2025

Total time taken to generate the page: 0.00530 seconds