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

Home » Public Forums » archive » widget_base alignment question
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
widget_base alignment question [message #42639] Wed, 16 February 2005 19:50 Go to next message
mperrin+news is currently offline  mperrin+news
Messages: 81
Registered: May 2001
Member
I'd like to create a resizable widget app which looks
kind of like this:

+-----------------------------------------------+
| LEFT_ALIGNED_LABEL RIGHT_ALIGNED_LABEL |
| |
| draw widget |
| some other stuff... |
+-----------------------------------------------+

but I can't figure out if this is possible in IDL. The
top-level base has COLUMN set, and then into that I
first place a widget_base with ROW set. But I can't
figure out how to make this base span the entire width
of my larger, resizable TLB. Is there a trick here, some
keyword I've been missing?

It actually doesn't even have to be really right aligned,
so long as it's spaced over to the right. Currently I am
getting

+-----------------------------------------------+
| LEFT_ALIGNED_LABEL RIGHT_ALIGNED_LABEL |
| |
| draw widget |
| some other stuff... |
+-----------------------------------------------+

and when I resize the window it just adds whitespace to the right
of both labels, rather than padding between or around both.

Having read through the IDL documentation on widget_base, and
skimmed through all the widget stuff in Dave Fanning's most excellent
book, I'm still stuck on this one. This is easy in GTK! Why is it so
hard (or at least obscure) in IDL?!

- Marshall
Re: widget_base alignment question [message #42718 is a reply to message #42639] Mon, 21 February 2005 16:45 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JD Smith writes:

> Your test program behaves differently, but just as poorly. I found out
> that at least one of the problems is entirely unrelated to the draw
> widget: grid layouts under X don't like to be resized in the least. You
> can show it like this:
>
> top=widget_base(/COLUMN)
> b=widget_base(top,/GRID_LAYOUT,COLUMN=2,/FRAME)
> l=widget_label(b,value='ALIGN_LEFT',/ALIGN_LEFT,/FRAME)
> l=widget_label(b,value='ALIGN_RIGHT',/ALIGN_RIGHT,/FRAME)
> widget_control, b,/realize
>
> Looks fine, nicely centered and aligned. Now try:
>
> widget_control, b,xsize=200
>
> The rightmost box shifts inside of its frame to cut off the last
> letter. Why?

Windows doesn't cut the letter off, but it does jam
the button frame up against the base frame in a way that
doesn't happen to the frames on the left. It looks ugly,
but, ... well, what else is new? Something is not right,
clearly.

> I'm not asking for a herculean alignment effort, merely
> to increase the size of the label base. And heaven forfend that I
> give the grid base an xsize to begin with (though SCR_XSIZE seems to
> work initially, but not on subsequent sizings). I think RSI needs to
> chain an intern to a desk this Spring and have her go through all
> possible combinations of widget alignment on all platforms, and take
> careful note of all the inconsistencies. Volunteers?

Oh, Lord. Would this be a *paid* internship? I've got a couple
of young men at home who are looking for a job this summer. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: widget_base alignment question [message #42719 is a reply to message #42639] Mon, 21 February 2005 16:15 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 21 Feb 2005 14:35:09 -0700, David Fanning wrote:

> JD Smith writes:
>
>> Useful layout trick. Does this work for everyone? Why does Linux
>> suffer here?
>
> Suffer!? You don't even want to know! I made the mistake
> of making my Catalyst test application available. It is
> a nightmare. Private discussions lead me to conclude even
> RSI is not immune to the problems caused by differences
> in graphical user interface implementations.
>
>> Unless I realize the widgets first, and set the xsize
>> after, the labels are piled up on each other (see
>> turtle.as.arizona.edu/idl/test_pre.png and
>> turtle.as.arizona.edu/idl/test_fix.png). But even that doesn't really
>> fix it, cutting off part of the "t" in "right".
>
> I think this might be because your draw widget is probably
> slightly bigger than you think it is. In Windows, anyway,
> there is a 3 pixel "border" around the canvas of a draw
> widget, and this has to be accounted for if things are to
> align themselves. I offer my test program as an example that
> ran OK in Windows.
>
> ;*********************************************************** **********
> Pro TEST_EVENT, event
> Widget_control, event.top, Get_UValue=info
>
> Print, event.x, event.y
> Widget_Control, info.labelbase, XSIZe=event.x-6
> Widget_Control, info.draw, XSIZe=event.x
> END
>
> PRO TEST
> tlb = Widget_base(column=1, /TLB_SIze_Events)
> base = widget_base(tlb, Row=1)
> labelbase = Widget_Base(base, Column=2, /Grid, xsize=194)
> button = Widget_Label(labelbase, Value='Align Left', align_left=1)
> button = Widget_Label(labelbase, Value='Align Right', align_right=1)
> draw = widget_Draw(tlb, xsize=200, ysize=100)
> Widget_Control, tlb, /Realize, Set_UValue={labelbase:labelbase,
> draw:draw}
> Xmanager, 'test', tlb, /No_Block
> END
> ;*********************************************************** **********
>
>> Then when it gets resized, and a TLB_SIZE_EVENTS comes in, it is clearly
>> lying about the "frame-free" size of the usable window area, and the
>> widgets are resized to overfill the window (see
>> turtle.as.arizona.edu/idl/test_post.png). Does anyone at RSI actually go
>> through the layout on all of their systems to see what works?
>
> I presume you are asking a rhetorical question here. :-)

I presume you know the answer to that ;).

Your test program behaves differently, but just as poorly. I found out
that at least one of the problems is entirely unrelated to the draw
widget: grid layouts under X don't like to be resized in the least. You
can show it like this:

top=widget_base(/COLUMN)
b=widget_base(top,/GRID_LAYOUT,COLUMN=2,/FRAME)
l=widget_label(b,value='ALIGN_LEFT',/ALIGN_LEFT,/FRAME)
l=widget_label(b,value='ALIGN_RIGHT',/ALIGN_RIGHT,/FRAME)
widget_control, b,/realize

Looks fine, nicely centered and aligned. Now try:

widget_control, b,xsize=200

The rightmost box shifts inside of its frame to cut off the last
letter. Why? I'm not asking for a herculean alignment effort, merely
to increase the size of the label base. And heaven forfend that I
give the grid base an xsize to begin with (though SCR_XSIZE seems to
work initially, but not on subsequent sizings). I think RSI needs to
chain an intern to a desk this Spring and have her go through all
possible combinations of widget alignment on all platforms, and take
careful note of all the inconsistencies. Volunteers?

JD
Re: widget_base alignment question [message #42723 is a reply to message #42639] Mon, 21 February 2005 13:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JD Smith writes:

> Useful layout trick. Does this work for everyone? Why does Linux
> suffer here?

Suffer!? You don't even want to know! I made the mistake
of making my Catalyst test application available. It is
a nightmare. Private discussions lead me to conclude even
RSI is not immune to the problems caused by differences
in graphical user interface implementations.

> Unless I realize the widgets first, and set the xsize
> after, the labels are piled up on each other (see
> turtle.as.arizona.edu/idl/test_pre.png and
> turtle.as.arizona.edu/idl/test_fix.png). But even that doesn't really
> fix it, cutting off part of the "t" in "right".

I think this might be because your draw widget is probably
slightly bigger than you think it is. In Windows, anyway,
there is a 3 pixel "border" around the canvas of a draw
widget, and this has to be accounted for if things are to
align themselves. I offer my test program as an example that
ran OK in Windows.

;*********************************************************** **********
Pro TEST_EVENT, event
Widget_control, event.top, Get_UValue=info

Print, event.x, event.y
Widget_Control, info.labelbase, XSIZe=event.x-6
Widget_Control, info.draw, XSIZe=event.x
END

PRO TEST
tlb = Widget_base(column=1, /TLB_SIze_Events)
base = widget_base(tlb, Row=1)
labelbase = Widget_Base(base, Column=2, /Grid, xsize=194)
button = Widget_Label(labelbase, Value='Align Left', align_left=1)
button = Widget_Label(labelbase, Value='Align Right', align_right=1)
draw = widget_Draw(tlb, xsize=200, ysize=100)
Widget_Control, tlb, /Realize, Set_UValue={labelbase:labelbase,
draw:draw}
Xmanager, 'test', tlb, /No_Block
END
;*********************************************************** **********

> Then when it gets resized, and a TLB_SIZE_EVENTS comes in, it is clearly
> lying about the "frame-free" size of the usable window area, and the
> widgets are resized to overfill the window (see
> turtle.as.arizona.edu/idl/test_post.png). Does anyone at RSI actually go
> through the layout on all of their systems to see what works?

I presume you are asking a rhetorical question here. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: how to rerun subroutine only?
Next Topic: Re: Weird MIN behavior

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

Current Time: Sat Oct 11 05:18:45 PDT 2025

Total time taken to generate the page: 1.76320 seconds