Using Y_SCROLL_SIZE and COLUMN=8 on Mac widgets [message #86323] |
Sat, 26 October 2013 18:27  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
The following simple code works fine on a PC -- displaying 8 columns of data as requested. But on my Mac laptop it only shows a couple of columns.
***************
pro test
values = 's' + strtrim(indgen(200),2)
base = widget_base()
bgroup = cw_bgroup(base,values,column=8,y_scroll_size=600)
widget_control,base,/realize
****************
Now the IDL documentation does say that
"Use of the Y_SCROLL_SIZE keyword implies SCROLL. This means that scroll bars will be added in both the horizontal and vertical directions when Y_SCROLL_SIZE is specified. Because the default size of the scrolling viewport may differ between platforms, it is best to specify X_SCROLL_SIZE when specifying Y_SCROLL_SIZE."
And I can get a workaround by adding x_scroll_size = 300 for the Mac. The problem is that the necessary x_scroll_size depends on the length of the text being displayed (and the font size used). But on the PC, IDL automatically know what X size the widget should have to display 8 columns.
Any suggestions for kluge to make the above code work on a Mac? Thanks, --Wayne
P.S. I used cw_bgroup above to keep the code simple, but the problem also exists when using the Column and Y_scroll_size keywords with widget_base().
|
|
|
Re: Using Y_SCROLL_SIZE and COLUMN=8 on Mac widgets [message #86324 is a reply to message #86323] |
Sun, 27 October 2013 05:12  |
Heinz Stege
Messages: 189 Registered: January 2003
|
Senior Member |
|
|
On Sat, 26 Oct 2013 18:27:56 -0700 (PDT), wlandsman wrote:
> The following simple code works fine on a PC -- displaying 8 columns of data as requested. But on my Mac laptop it only shows a couple of columns.
>
> ***************
> pro test
>
> values = 's' + strtrim(indgen(200),2)
> base = widget_base()
> bgroup = cw_bgroup(base,values,column=8,y_scroll_size=600)
> widget_control,base,/realize
> ****************
>
> Now the IDL documentation does say that
>
> "Use of the Y_SCROLL_SIZE keyword implies SCROLL. This means that scroll bars will be added in both the horizontal and vertical directions when Y_SCROLL_SIZE is specified. Because the default size of the scrolling viewport may differ between platforms, it is best to specify X_SCROLL_SIZE when specifying Y_SCROLL_SIZE."
>
> And I can get a workaround by adding x_scroll_size = 300 for the Mac. The problem is that the necessary x_scroll_size depends on the length of the text being displayed (and the font size used). But on the PC, IDL automatically know what X size the widget should have to display 8 columns.
>
> Any suggestions for kluge to make the above code work on a Mac? Thanks, --Wayne
>
> P.S. I used cw_bgroup above to keep the code simple, but the problem also exists when using the Column and Y_scroll_size keywords with widget_base().
I don't think, that there is an easy solution. It may be the best, to
replace cw_bgroup by two loops.
However, if you need to use cw_bgroup, you may want to try the
following calculation subsequent to your code:
; Get the widget IDs of all buttons
button_wids=base
for i=0,3 do button_wids=widget_info(button_wids[0],/all_children)
; Get the width of the scroll bar
temp_wid=widget_text(base,xsize=1,ysize=1,/wrap,/scroll)
temp=(widget_info(temp_wid,/geom)).scr_xsize
widget_control,temp_wid,/destroy
temp_wid=widget_text(base,xsize=1,ysize=1,/wrap)
scroll_bar_xsize=round(temp-(widget_info(temp_wid,/geom)).sc r_xsize)
widget_control,temp_wid,/destroy
; Set the width of the button group widget
geo=widget_info(button_wids[0],/geom)
xmargin=geo.xoffset
geo=widget_info(button_wids[175],/geom)
widget_control,bgroup,xsize=geo.xoffset+geo.xsize+xmargin+sc roll_bar_xsize
I didn't test this on a Mac. It works on my Windows computer (after
mis-adjusting the xsize of cw_bgroup).
Please note, that you have to change the way of retrieving the button
IDs, when you use the label_left or label_top keyword in cw_bgroup.
Cheers, Heinz
|
|
|