; $Id: w_psopt.pro,v 1.0 1997/05/23 mgs $ ;+ ; NAME: ; w_psopt ; PURPOSE: ; creates a dialog to set various postscript options ; ; CATEGORY: ; Modal widgets. ; ; CALLING SEQUENCE: ; widget = w_psopt(parent) ; ; INPUTS: ; PARENT - The ID of the parent widget. ; ; KEYWORD PARAMETERS: ; UVALUE - Supplies the user value for the widget. ; VALUE - Supplies the initial entries of the list (structure) ; TITLE - Supplies the title of the dialog ; ORIENTATION - set portrait (1) or landscape (0) ; ENCAPS - produce encapsulated postscript file ; TIMESTAMP - put time label on bottom of plot ; FILENAME - choose filename for ps file ; ; OUTPUTS: ; The ID of the created widget is returned. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; ; PROCEDURE: ; ; MODIFICATION HISTORY: ;- ;----------------------------------------------------------------------------- FUNCTION psopt_event, event parent=event.handler ; the event usually must be passed further up ! ; and the next higher event handler must destroy the window ; (cannot be destroyed here, because we need the info !) passevent = 0 ; Retrieve the structure from the child that contains the sub ids. stash = WIDGET_INFO(parent, /CHILD) WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY if(event.id eq state.bID) then begin ; button pressed (OK or Cancel) widget_control,state.boriID,get_value=bstate orient = bstate(0) widget_control,state.bepsID,get_value=bstate eps = bstate(0) timestamp = bstate(1) widget_control,state.nameID,get_value=filename info = { orient:orient, eps:eps, timestamp:timestamp, filename:filename } value = 1-event.value ; OK=1, Cancel=0 passevent = 1 endif ; Restore the state structure WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY if(passevent) then $ return, { ID:parent, TOP:event.top, HANDLER:0L, VALUE:value , $ INFO:info } $ else return,0 END ;----------------------------------------------------------------------------- FUNCTION w_psopt, TITLE=title, UVALUE=uval, ORIENTATION=orientation, $ ENCAPS=encaps, TIMESTAMP=timestamp, FILENAME=filename ON_ERROR, 2 ;return to caller ; Defaults for keywords IF NOT (KEYWORD_SET(uval)) THEN uval = 0 if (not keyword_set(orientation)) then orientation = 0 if (not keyword_set(encaps)) then encaps = 0 if (not keyword_set(timestamp)) then timestamp = 0 if (not keyword_set(filename)) then filename = 'insight' if (not keyword_set(title)) then title = ' ' base = WIDGET_BASE(TITLE=title, UVALUE = uval, $ frame = 3, /column, $ EVENT_FUNC = "psopt_event" ) subbase = widget_base(base, /column, /frame) bori = cw_bgroup(subbase,/column, /exclusive, $ ['landscape', 'portrait'], set_value=orientation) beps = cw_bgroup(subbase,/column, /nonexclusive, $ ['encapsulated (EPS)', 'Time stamp'],set_value=[ encaps,timestamp ]) namef = cw_field(subbase,title='Filename :',value=filename,xsize=40) buttons = cw_bgroup(base,/row,['OK','Cancel']) state = { bID:buttons, nameID:namef, boriID:bori, bepsID:beps } ; Save out the initial state structure into the first childs UVALUE. WIDGET_CONTROL, WIDGET_INFO(base, /CHILD), SET_UVALUE=state, /NO_COPY RETURN, base END