; a=simpleexample() ; PRO SimpleExample_Event,ev Help,ev,/Struct END FUNCTION SimpleExample_ToolSelect_Event,ev Widget_Control,ev.top,Get_UValue=state,/No_Copy Widget_Control,ev.id,Get_UValue=uvalue IF uvalue[0] EQ 'CROSSHAIR' $ THEN state.oWindow->Set_Crosshairs,ev.select $ ; CROSSHAIR ELSE state.oWindow->SetCurrentTool,uvalue[0] ; SELECT|EDIT|ZOOM Widget_Control,ev.top,Set_UValue=state,/No_Copy END ;; This is the event handler for the print button. All it really ;; does is to call the DialogPrint method of the printer object. PRO SimpleExample_Print_Event, ev WIDGET_CONTROL, ev.id, GET_UVALUE=oPrint WIDGET_CONTROL, ev.top, GET_UVALUE=Window oWindow = Window.oWindow ;; comes back as a structure for some reason IF NOT (OBJ_VALID(oPrint) AND OBJ_VALID(oWindow)) THEN BEGIN PRINT,'WARNING: invalid GA_Printer and/or GA_Window objects.' PRINT,'No data will be printed.' HELP,oPrint,oWindow RETURN ENDIF ;; We pass to the DialogPrint method a string which is used to tell ;; the DialogPrint method the name of our Print callback procedure. ;; The UVALUE keyword is used here to indicate that our callback ;; takes a single argument. In other words, the DialogPrint method ;; makes this call: ;; IDL> SimpleExample_PrintCallback, oWindow oPrint->DialogPrint,'SimpleExample_PrintCallback', UVALUE=oWindow END ;; This is the print callback. ;; It turns out that it's really pretty easy to use the GA_Printer ;; object. All that's needed is a callback (like this one) that calls ;; the draw method of your GA_Window. PRO SimpleExample_PrintCallback, oWindow oWindow->Draw END FUNCTION SimpleExample,_Extra=extra forward_function cw_gawindow, color_index color_setup,/reverse wBase = Widget_Base(Title="Simple Example",/Column) ; Create a GA_Printer object oPrint = OBJ_NEW("GA_PRINTER",wBase,TITLE='GA_Printer Printing') ; Create the Select/Edit/Zoom/Crosshair buttons and the Status text wToolBase = Widget_Base(wBase,/Row,$ Event_Func='SimpleExample_ToolSelect_Event') wPrint = WIDGET_BUTTON(wToolBase,VALUE='Print',UVALUE=oPrint,$ EVENT_PRO='SimpleExample_Print_Event') wRadioBase = Widget_Base(wToolBase,/Row,/Exclusive) wSelectButton = Widget_Button(wRadioBase,Value='Select',UValue='SELECT') Widget_Control,wSelectButton,Set_Button=0 wEditButton = Widget_Button(wRadioBase,Value='Edit',UValue='EDIT') Widget_Control,wEditButton,Set_Button=0 wZoomButton = Widget_Button(wRadioBase,Value='Zoom',UValue='ZOOM') Widget_Control,wZoomButton,Set_Button=1 wCheckBase = Widget_Base(wToolBase,/NonExclusive) wCHButton = Widget_Button(wCheckBase,Value='CrossHair',UValue='CROSSHAIR') Widget_Control,wCHButton,Set_Button=1 wStatusText = Widget_Text(wToolBase,Value='',YSize=1,XSize=20) ; Create the GA_Plot_Window wGAWindow = CW_GAWindow(wBase,XSize=500,YSize=300,Color=Color_Index('Red'),_Extra=extra) Widget_Control,wGAWindow,Get_Value=oWindow ; Set the UVALUE of the base widget to the Window object for use in our ; printer callback. WIDGET_CONTROL, wBase, SET_UVALUE=oWindow ; Create the Ga_Plots and add them to the GA_Plot_Window xdata = (FindGen(100)-50)*2*!PI/100. oPlot1 = Obj_New("GA_PLOT",xdata,SIN(xdata),_Extra=extra) oPlot1->Set_Data_Property,YName='SIN',Color=Color_Index('Blue') oPlot2 = Obj_New("GA_PLOT",xdata,COS(xdata),_Extra=extra) oPlot2->Set_Data_Property,YName='COS' oPlot2->Set_Plot_Property,title='Second Title', xtitle='X axis' dumy = oPlot2->Add_Data(xdata,SIN(xdata),YName='SIN',Color=Color_Index(3)) oWindow->Add_Plot,oPlot1 oWindow->Add_Plot,oPlot2 ; Set up some properties of the GA_Plot_Window oWindow->SetCurrentTool,'ZOOM' oWindow->Set_Crosshairs,1 oWindow->Set_Status_Window,wStatusText ; Realize the widgets. Store GA_Plot_Window pointer in the uvalue of wBase. Widget_Control,wBase,/Realize,Set_UValue={oWindow:oWindow} XManager,'SimpleExample',wBase,/No_Block Return,oWindow END