X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 21 Nov 2005 04:08 AM by  anon
Layering widgets?
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
21 Nov 2005 04:08 AM
    Hi, I have created a widget application that has a widget_tree structure. The tree includes three different types of nodes. Each node type generates a unique event. I want to show a different compound widget on the right depending on which type of node is selected. I am currently mapping and unmapping them but this doesn't do quite what I want. My problem is that the nodes, even when unmapped still cannot occupy space on the screen. I want the widgets to replace each other, at the moment they appear and dissapear but are positioned next to each other rather than on top of each other. Is there a way to 'layer' widgets in such a way that I can show widgets one at a time occupying the same space? Thanks a lot Graeme

    Deleted User



    New Member


    Posts:
    New Member


    --
    21 Nov 2005 04:08 AM
    I suspect that you have not studied the WIDGET_TAB widgets that were added to IDL just a few versions ago. The example below combines the example that you can access through Online Help for WIDGET_TREE (follow the 'Using Tree Widgerts' link) with the example from WIDGET_TAB's Help page (follow the 'Using Tab Widgets' link). Let me know, if this does not demonstrate what you are looking for. ; Single event handler for TREE_AND_TAB_PAGES_EX PRO tree_and_tab_pages_ex_event, event widget_control, event.top, GET_UVALUE=info case event.id of ; Note: The first 3 WIDGET_TREE events are all followed by WIDGET_TAB events. info.wL1: widget_control, info.wTab, SET_TAB_CURRENT=0 info.wL2: widget_control, info.wTab, SET_TAB_CURRENT=1 info.wL3: widget_control, info.wTab, SET_TAB_CURRENT=2 else: print, 'Detected ' + tag_names(event, /STRUCTURE_NAME) + $ ' event from widget #' + strtrim(event.id, 2) endcase END ; Widget creation code PRO tree_and_tab_pages_ex tlb = widget_base(/ROW, TITLE='Tree-controlled Tab Pages') wTree = widget_tree(tlb) wRoot = widget_tree(wTree, VALUE='Root', /FOLDER, /EXPANDED) wLeaf1 = widget_tree(wRoot, VALUE='Tab Page 1') wLeaf2 = widget_tree(wRoot, VALUE='Tab Page 2') wLeaf3 = widget_tree(wRoot, VALUE='Tab Page 3') wTab = widget_tab(tlb) ; Create the first tab base, containing a label and two ; button groups. wT1 = widget_base(wTab, TITLE='TAB 1', /COLUMN) wLabel = widget_label(wT1, VALUE='Choose values') wBgroup1 = cw_bgroup(wT1, ['one', 'two', 'three'], $ /ROW, /NONEXCLUSIVE, /RETURN_NAME) wBgroup2 = cw_bgroup(wT1, ['red', 'green', 'blue'], $ /ROW, /EXCLUSIVE, /RETURN_NAME) ; Create the second tab base, containing a label and ; a slider. wT2 = widget_base(wTab, TITLE='TAB 2', /COLUMN) wLabel = widget_label(wT2, VALUE='Move the Slider') wSlider = widget_slider(wT2) ; Create the third tab base, containing a label and ; a text-entry field. wT3 = widget_base(wTab, TITLE='TAB 3', /COLUMN) wLabel = widget_label(wT3, VALUE='Enter some text') wText= widget_text(wT3, /EDITABLE, /ALL_EVENTS) widget_control, tlb, /REALIZE info = {wL1:wLeaf1, wL2:wLeaf2, wL3:wLeaf3, wTab:wTab, wBG1:wBgroup1, $ wBG2:wBgroup2, wSlider:wSlider, wText:wText} widget_control, tlb, SET_UVALUE=info XMANAGER, 'tree_and_tab_pages_ex', tlb END James Jones

    Deleted User



    New Member


    Posts:
    New Member


    --
    21 Nov 2005 04:08 AM
    Graeme, I think the following code might do what you are interested in. The key is that the base that contains the overlapping layers does not specify either /row nor /column. When a particular layer is to be shown it is mapped and the other layers are unmapped (via widget_control's map keyword). Note that only bases can be mapped and unmapped. Good luck, Doug pro tree_example_event, e end pro show_layer, layers, x for i = 0, 2 do begin widget_control, layers[i], map = ( i eq x ? 1 : 0 ) endfor end pro tree_event, e widget_control, e.top, get_uvalue = layers widget_control, e.id, get_uvalue = x show_layer, layers, x end function create_layer, parent, i layerBase = widget_base( parent, /column ) label = widget_label( layerBase, $ value = 'Layer ' + i ) button = widget_button( layerBase, $ xsize = 100, ysize = 100, $ value = 'Button ' + i ) return, layerBase end pro tree_example ; create the top level base topBase = widget_base( /row ) ; create a tree root = widget_tree( topBase, event_pro = 'tree_event' ) node1 = widget_tree( root, value = 'Node 1', uvalue = 0 ) node2 = widget_tree( root, value = 'Node 2', uvalue = 1 ) node3 = widget_tree( root, value = 'Node 3', uvalue = 2 ) ; create three overlapping layers containerBase = widget_base( topBase ) layers = lonarr( 3 ) layers[0] = create_layer( containerBase, '1' ) layers[1] = create_layer( containerBase, '2' ) layers[2] = create_layer( containerBase, '3' ) ; store the layers in the top level base's uvalue widget_control, topBase, set_uvalue = layers ; realize it all widget_control, topBase, /realize xmanager, 'tree_example', topBase, /no_block end
    You are not authorized to post a reply.