;------------------------------------------------------------- ;+ ; NAME: ; XDATE ; PURPOSE: ; Widget based date selection tool. ; CATEGORY: ; CALLING SEQUENCE: ; xdate ; INPUTS: ; KEYWORD PARAMETERS: ; Keywords: ; TITLE=tt Widget title (def="Select date"). ; YLIST=ylist Allowed list of years. ; Default is +/- 5 years from default year. ; MLIST=mlist Allowed list of months. ; Default is all months. ; YDEF=ydef Default year. ; MDEF=mdef Default month. ; DDEF=ddef Default day. ; Defaults are current. If negative lock selection. ; YOUT=yout Returned year. ; MOUT=mout Returned month. ; DOUT=dout Returned day. ; These are null strings for CANCEL. ; OUTPUTS: ; COMMON BLOCKS: ; NOTES: ; MODIFICATION HISTORY: ; R. Sterner, 10 Nov, 1993 ; ; Copyright (C) 1993, Johns Hopkins University/Applied Physics Laboratory ; This software may be used, copied, or redistributed as long as it is not ; sold and this copyright notice is reproduced on each copy made. This ; routine is provided as is without any express or implied warranties ; whatsoever. Other limitations apply as described in the file disclaimer.txt. ;- ;------------------------------------------------------------- pro xdate_event, ev widget_control, ev.id, get_uval=uval name = strupcase(strmid(uval,0,1)) val = strmid(uval,1,99) widget_control, ev.top, get_uval=d if name eq 'D' then return if name eq 'O' then begin widget_control, d.id_y, get_val=ytxt widget_control, d.id_m, get_val=mtxt mtxt = getwrd(mtxt) widget_control, d.id_d, get_val=dtxt widget_control, d.res, set_uval=ytxt+' '+mtxt+' '+strtrim(dtxt,2) widget_control, ev.top, /dest return endif if name eq 'C' then begin widget_control, ev.top, /dest widget_control, d.res, set_uval=' ' return endif if name eq 'Y' then begin widget_control, d.id_y, set_val=val endif if name eq 'M' then begin widget_control, d.id_m, set_val=val endif ;------ Update day slider --------- widget_control, d.id_y, get_val=ytxt widget_control, d.id_m, get_val=mtxt widget_control, d.id_d, get_val=dtxt mmax = monthdays(ytxt+0,mtxt+0) widget_control, /dest, d.id_d id = widget_slider(d.b_day, xsize=200, min=1, max=mmax, uval='DAY') widget_control, id, set_val=(dtxt+0)0,2)+' '+mname(abs(mdef)<12>0) id_m = widget_label(id,val=mtxt) if mdef lt 0 then widget_control, b0, sens=0 ; Lock. ;------- Day --------- mmax = monthdays(abs(ydef), abs(mdef)) b_day = widget_base(top,/row) b0 = widget_label(b_day,val='Day') id_d = widget_slider(b_day, xsize=200, min=1, max=mmax, uval='DAY') widget_control, id_d, set_val=abs(ddef)1 if ddef lt 0 then widget_control, id_d, sens=0 ; Lock. ;------ Package and store needed info ------------ res = widget_base() data = {id_y:id_y, id_m:id_m, id_d:id_d, b_day:b_day, res:res} widget_control, top, set_uval=data ;------ realize widget ----------- widget_control, top, /real ;------ Event loop --------------- xmanager, 'xdate', top ;------ Get result --------------- widget_control, res, get_uval=out yout = getwrd(out,0) mout = getwrd('',1) dout = getwrd('',2) return end