PDA

View Full Version : Set the size of the WwInit top shell



green12
09-22-2009, 11:12 AM
When i hide or show item in my gui the main gui window will not change its size with the new displayed widgets, leaving it very distorted looking. Are there ways to change the gui window size or have in adjust for newly shown widgets?

Thanks!

acg
11-10-2009, 04:28 PM
After experimenting with this for a while I am afraid that the answer to your question is no.

The window manager seems to reserve the space when the widgets are created initially
and I have not found a way to rearrange just the widgets that are shown.

bads19
11-12-2009, 01:32 PM
Scenario 1:

If you have all the widgets created at the first time and attched to the main window one after another. Then, you do a hide and show on them. The widgets might more from one place to another if all the edges of attachment are not declared upfront. Alternatively you can make them sensitive / nonsensitive.

Scenario 2:

If you are creating widgets with conditional display one behind another. Then you can use layouts and hide and show the layouts. The widgets can be attached to the suitable layouts.

Here is an example ofr the second scenario.


PRO HideShowCB, wid, which
COMMON wids, layout1, layout2

name = WwGetValue(wid)

CASE name OF
'Layout 1' : BEGIN
st = WwSetValue(layout1, /SHOW)
st = WwSetValue(layout2, /HIDE)
END
'Layout 2' : BEGIN
st = WwSetValue(layout1, /HIDE)
st = WwSetValue(layout2, /SHOW)
END
ELSE:
ENDCASE

END

PRO hide_and_show
@wtxlib
COMMON wids, layout1, layout2

title = 'HIDE AND SHOW EXAMPLE'

top = WwInit( title, 'Hide and Show', layout, /FORM, POSITION=[200,200])

items = { , callback: 'HideShowCB' $
, name : 'Layout 1', button : 'Layout 1' $
, name : 'Layout 2', button : 'Layout 2' $
, current: 1}
option = WwOptionMenu(layout, '', items, /TOP, /LEFT, /RIGHT, MENUS=menus)
st = WtSet(option, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

layout_1 = WwLayout( layout, TOP=option, /LEFT, /RIGHT, /BOTTOM, /FORM)
st = WtSet(layout_1, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

layout_2 = WwLayout( layout, TOP=option, /LEFT, /RIGHT, /BOTTOM, /FORM)
st = WtSet(layout_2, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})
;
; Layout 2
;
label1 = WwText(layout_1, /LABEL, TEXT='LAYOUT 1 - LABEL 1', /TOP, /LEFT)
st = WtSet(label1, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

text1 = WwText(layout_1, '', COLS=40, /TOP, LEFT=label1, /RIGHT)
st = WtSet(text1, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

label2 = WwText(layout_1, /LABEL, TEXT='LAYOUT 1 - LABEL 2', TOP=text1, /LEFT)
st = WtSet(label2, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

text2 = WwText(layout_1, '', COLS=40, TOP=text1, LEFT=label2, /RIGHT)
st = WtSet(text2, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})
;
; Layout 2
;
label3 = WwText(layout_2, /LABEL, TEXT='LAYOUT 2 - LABEL 1', /TOP, /LEFT)
st = WtSet(label3, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

text3 = WwText(layout_2, '', COLS=40, /TOP, LEFT=label3, /RIGHT)
st = WtSet(text3, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

label4 = WwText(layout_2, /LABEL, TEXT='LAYOUT 2 - LABEL 2', TOP=text3, /LEFT)
st = WtSet(label4, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

text4 = WwText(layout_2, '', COLS=40, TOP=text3, LEFT=label4, /RIGHT)
st = WtSet(text4, {, topOffset:5, bottomOffset:5, leftOffset:5, rightOffset:5})

st = WwSetValue(layout_1, /SHOW)
st = WwSetValue(layout_2, /HIDE)
;
; Save the layout wids
;
layout1 = layout_1
layout2 = layout_2

status = WwSetValue(top, /Display)
WwLoop, /Noblock

END