Pro GraphWin_Event, event ; This is the main event handler for GRAPHWIN. ; The top-level base contains a pointer to the data. Get the pointer. Widget_Control, event.top, Get_UValue=ptr ; Put the data into a local variable named "data". (If you don't ; use the SET keyword with Handle_Value, you GET the data.) Handle_Value, ptr, data ; Which button caused the event? Widget_Control, event.id, Get_Value=buttonValue ; Branch based on button value CASE buttonValue OF 'Shaded Surface': Shade_Surf, data 'Contour Plot': Contour, data 'Surface Plot': Surface, data 'Quit': Widget_Control, event.top, /Destroy ENDCASE END ;******************************************************************* Pro GraphWin ; This program displays some data in a variety of formats. ; Create a top-level base that is a column base. tlb = Widget_Base(Column=1, Title = 'Resizing Example') ; To facilitate button layout, create some button sub-bases. buttonbase = Widget_Base(tlb, Row=1, Frame=1) buttonleft = Widget_Base(buttonbase, Column=1) buttonright = Widget_Base(buttonbase, Column=1) ; Create four buttons that will perform the actions. shader = Widget_Button(buttonleft, Value='Shaded Surface') contourer = Widget_Button(buttonleft, Value='Contour Plot') surfer = Widget_Button(buttonright, Value='Surface Plot') quiter = Widget_Button(buttonright, Value='Quit') ; Create a draw widget to display the data graphicsbase = Widget_Base(tlb, Row=1) draw = Widget_Draw(graphicsbase, XSize=300, YSize=300) ; 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, draw, 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 ; The data will be stored in a pointer location. Create ; the pointer and fill it with the data. ptr = Handle_Create(Value=data, /No_Copy) ; Store the pointer in the user value of the top-level base. Widget_Control, tlb, Set_UValue=ptr ; Register the program and set up the event loop. XManager, 'GraphWin', tlb, Event_Handler='GraphWin_Event' END ;*******************************************************************