PRO Helper_Tracking_Events, event ; IF this is a PROGRAM event rather than a TRACKING event, ; send the event structure to HELPER_EVENTS and RETURN. eventName = Tag_Names(event, /Structure_Name) IF eventName NE 'WIDGET_TRACKING' THEN BEGIN ; This is a Helper program event. Send it to the ; Helper_Events event handler. Helper_Events, event RETURN ENDIF ; Get the info structure out of the TLB. Widget_Control, event.top, Get_UValue=info ; If entering a widget, put message in HELP window. ; If exiting, put generic help text in HELP window. IF event.enter EQ 1 THEN BEGIN ; Which widget caused the event? Branch and put the ; appropriate text in the on-line help window. CASE event.id OF info.shadeID: Widget_Control, info.helpTextID, $ Set_Value='This button produces a SHADED SURFACE plot.' info.contourID:Widget_Control, info.helpTextID, $ Set_Value='This button produces a CONTOUR plot.' info.surfaceID:Widget_Control, info.helpTextID, $ Set_Value='This button produces a SURFACE plot.' info.drawID:Widget_Control, info.helpTextID, $ Set_Value='The program data is displayed here.' info.quitterID:Widget_Control, info.helpTextID, $ Set_Value='This button EXITS the program.' ENDCASE ENDIF ELSE BEGIN ; Put a generic message in the help window. Widget_Control, info.helpTextID, $ Set_Value='Move your cursor over a widget to get ' + $ 'an explanation of its purpose.' ENDELSE END ; of HELPER_TRACKING_EVENTS *********************************** PRO Help_Dismiss_Event, event ; The help program has been dismissed. Restore normal program ; functionality, resensitive "Program Help" button, and destroy ; the HELP window. Widget_Control, event.top, Get_UValue=info ; Turn tracking off and send events to HELPER_EVENTS. Widget_Control, info.shadeID, Tracking=0, Event_Pro='Helper_Events' Widget_Control, info.contourID, Tracking=0, Event_Pro='Helper_Events' Widget_Control, info.surfaceID, Tracking=0, Event_Pro='Helper_Events' Widget_Control, info.drawID, Tracking=0, Event_Pro='Helper_Events' Widget_Control, info.quitterID, Tracking=0, Event_Pro='Helper_Events' ; Resensitize the "Program Help" button. Widget_Control, info.helperID, Sensitive=1 ; Destroy the HELP window. Widget_Control, event.top, /Destroy END ; of HELP_DISMISS_EVENT ************************************************* PRO Help_Button_Event, event ; Get the info structure out of the TLB. Widget_Control, event.top, Get_UValue=info, /No_Copy ; Create a help window under the current program window. Widget_Control, event.top, TLB_Get_Offset=tlbOffsets Widget_Control, event.top, TLB_Get_Size=tlbSizes xoffset = tlbOffsets(0) yoffset = tlbOffsets(1) + tlbSizes(1) + 40 helptlb = Widget_Base(Column=1, Title='On-Line Help Window', $ XOffset=xoffset, YOffset=yoffset, TLB_Frame_Attr=8, $ Group=event.top) helpTextID = Widget_Text(helptlb, Wrap=1, $ Scr_XSize=tlbSizes(0), Scr_YSize=75, $ Value='Move your cursor over a widget to get ' + $ 'an explanation of its purpose.') dismissID = Widget_Button(helptlb, Value='Dismiss Help Window', $ Event_Pro='Help_Dismiss_Event') info.helpTextID = helpTextID Widget_Control, helptlb, /Realize, Set_UValue=info ; Desensitize the "Program Help" button. Widget_Control, info.helperID, Sensitive=0 ; Turn tracking on for all program widgets and change the ; event handler to HELPER_TRACKING_EVENTS. Widget_Control, info.shadeID, Tracking=1, $ Event_Pro='Helper_Tracking_Events' Widget_Control, info.contourID, Tracking=1, $ Event_Pro='Helper_Tracking_Events' Widget_Control, info.surfaceID, Tracking=1, $ Event_Pro='Helper_Tracking_Events' Widget_Control, info.drawID, Tracking=1, $ Event_Pro='Helper_Tracking_Events' Widget_Control, info.quitterID, Tracking=1, $ Event_Pro='Helper_Tracking_Events' ; Put the info structure back in the TLB. Widget_Control, event.top, Set_UValue=info, /No_Copy END ; of HELP_BUTTON_EVENT ************************************************* PRO Helper_Events, event ; Get the info structure out of the TLB. Widget_Control, event.top, Get_UValue=info, /No_Copy ; Make the draw widget the current window. WSet, info.wid ; Which button caused the event? Widget_Control, event.id, Get_Value=buttonValue ; Branch based on button value CASE buttonValue OF 'Shaded Surface': Shade_Surf, info.data 'Contour Plot': Contour, info.data 'Surface Plot': Surface, info.data 'Quit': Widget_Control, event.top, /Destroy ENDCASE ; Put the info structure back in the TLB. IF Widget_Info(event.top, /Valid_ID) THEN $ Widget_Control, event.top, Set_UValue=info, /No_Copy END ; of HELPER_EVENTS **************************************************** PRO Helper ; Create a top-level base that is a column base. tlb = Widget_Base(Column=2, Title = 'On-Line Help Example') ; Two children. buttonbase = Widget_Base(tlb, Column=1, Frame=1) drawbase = Widget_Base(tlb, Row=1) ; Create five buttons that will perform the actions. shadeID = Widget_Button(buttonbase, Value='Shaded Surface') contourID = Widget_Button(buttonbase, Value='Contour Plot') surfaceID = Widget_Button(buttonbase, Value='Surface Plot') helperID = Widget_Button(buttonbase, Value='Program Help', $ Event_Pro='Help_Button_Event') quitterID = Widget_Button(buttonbase, Value='Quit') ; Create a draw widget to display the data drawID = Widget_Draw(drawbase, XSize=250, YSize=250) ; Realize the top-level base Widget_Control, tlb, /Realize ; Get the value of the draw widget, which is its window index ; number. Make this the current graphics window. Widget_Control, drawID, Get_Value=wid WSet, wid ; Create some data to display in the window. MakePeak creates ; a 41 by 41 data array. data = MakePeak(41) ; Put an initial display in the window. Shade_Surf, data ; Create an info structure with data for the program. info = { $ data:data, $ ; The data for the program. wid:wid, $ ; The window index of the draw widget. shadeID:shadeID, $ ; The ID of the SHADE SURFACE button. contourID:contourID, $ ; The ID of the CONTOUR button. surfaceID:surfaceID, $ ; The ID of the SURFACE button. quitterID:quitterID, $ ; The ID of the QUIT button. helperID:helperID, $ ; The ID of the PROGRAM HELP button. drawID:drawID, $ ; The ID of the draw widget. helptextID:-1L} ; The ID of the HELP WINDOW text widget. ; Store the info structure in the TLB. Widget_Control, tlb, Set_UValue=info, /No_Copy ; Register the program and set up the event loop. XManager, 'helper', tlb, Event_Handler='Helper_Events' END ;*******************************************************************