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
|