X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 13 Dec 2007 08:54 AM by  anon
Passing info in a Multiple Widget Hierarchies Program
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
13 Dec 2007 08:54 AM
    Hi, I try to understand how to pass information hold in a state structure in a widget program that have multiple base widget. According to the help, a multiple widget hierarchies program has the following structure: b ase1 = WIDGET_BASE() base2 = WIDGET_BASE(GROUP_LEADER=base1) base3 = WIDGET_BASE(GROUP_LEADER=base1) simplified from the help content. Now, I'm not sure how to code this, I suppose that every base has it own state structure that contains the necessary information for his base. But some output (like VI_info) of base2 need to be pass to base1 and base3. So my program structure would be has follow: base1 = WIDGET_BASE() pstate1={Trans_VI_info} base2 = WIDGET_BASE(GROUP_LEADER=base1) pstate2={VI_info} base3 = WIDGET_BASE(GROUP_LEADER=base1) pstate3 So, I suppose that the best way to pass the VI_info to base1, would be to call the pstate1 within base2 and update (create/update a pointer) the Trans_VI_info field. My problem is that I don't know how to call pstate1 from base2 ? Maybe, one solution would be to use only 1 state structure hold by base1... but that would force me to recode all my modules ! Hope this is clear enought. Best Regards. Antoine C.

    Deleted User



    New Member


    Posts:
    New Member


    --
    13 Dec 2007 08:54 AM
    There are two typical ways to pass the state of a widget hierarchy to another widget hierarchy. The one we recommend most is passing it through a state structure, which is stored in the UVALUE of some critical widget in the widget hierarchy (almost always the top-level base). Thus, the group leader might keep a "placeholder" for "follower bases" in its initial state structure. As these followers are created, their widget ID's could be set within the leader's state structure. The followers, similarly, should pass the ID of the leader around in their own UVALUE state structures. Thus, a follower, on initialization, could have a call like: widget_control, wGroupLeader, GET_UVALUE=leaderStateStruct leaderStateStruct.wFollower1ID = follower1TLB widget_control, wGroupLeader, SET_UVALUE=leaderStateStruct ; Update ; ... follower1StateStruct = {leader:wGroupLeader, wDraw:wFollower1Draw, $ wBtnExit:wFollower1ExitButton, etc. ...} widget_control, follower1TLB, SET_UVALUE=follower1StateStruct This way, every top-level base has access to the info on the widget hierarchy of the other top-level bases. If 'follower1' wants to access 'follower2', then these three lines will get 'follower1' everything it needs: widget_control, follower1TLB, GET_UVALUE=follower1StateStruct widget_control, follower1StateStruct.leader, GET_UVALUE=leaderStateStruct widget_control, leaderStateStruct.wFollower2ID=follower2StateStruct The other option is to use IDL COMMON blocks. This approach is perilous, because it affects an entier IDL session, and there can be collisions caused by these global process variables that are hard to debug. However, they certainly may offer a low cost workaround to your existing application, if you cannot be modifying existing UVALUE state structures in the existing application. COMMON requires only that you add a single call to [preferably the beginning of] each of your PROcedures or FUNCTIONs that need access to the global variable. The line might look like this: COMMON MY_VERY_SPECIFIC_APP_GLOBALS, wGroupLeader, wFollower1TLB, $ wFollower2TLB and every routine that had that line would share the same variable references. Any of those routines could read it or modify it. James Jones ITT Technical Support
    You are not authorized to post a reply.