FUNCTION CW_DATE_GET_VAL, id ;# recover the state of this compound widget stash = WIDGET_INFO( id, /CHILD ) WIDGET_CONTROL, stash, GET_UVALUE = state, /NO_COPY ;# get the year, month, and day value WIDGET_CONTROL, state.id1, GET_VALUE = yy WIDGET_CONTROL, state.id2, GET_VALUE = mm WIDGET_CONTROL, state.id3, GET_VALUE = dd date = FIX( [ yy, mm, dd ] ) ;# restore the state WIDGET_CONTROL, stash, SET_UVALUE = state, /NO_COPY RETURN, date END PRO CW_DATE_EVENT, ev COMMON TOP, wid, date, data parent = ev.handler ;# check OK and Cancel events WIDGET_CONTROL, ev.id, GET_VALUE = value CASE value OF 'OK': BEGIN WIDGET_CONTROL, parent, GET_VALUE = date WIDGET_CONTROL, ev.top, /DESTROY END 'Cancel': BEGIN date = 0 WIDGET_CONTROL, ev.top, /DESTROY END ENDCASE RETURN END FUNCTION CW_DATE, parent ;# get today's date today = BIN_DATE( SYSTIME( 0 ) ) ;# create top level base base = WIDGET_BASE( EVENT_PRO = 'CW_DATE_EVENT', /MODAL, $ FUNC_GET_VALUE = 'CW_DATE_GET_VAL', GROUP_LEADER = parent, COLUMN = 1,$ TITLE='SELECT DATE' ) ;# state information passed to the first child state = { ID1: 0L, ID2: 0L, ID3: 0L } ;# create text fields for year, month, and day and set default to today base2=WIDGET_BASE(base,ROW=1,/ALIGN_CENTER) state.id1 = CW_FIELD( base2, TITLE = 'Year:', VALUE = today( 0 ), XSIZE = 6 ) state.id2 = CW_FIELD( base2, TITLE = 'Month:', VALUE = today( 1 ), XSIZE = 4 ) state.id3 = CW_FIELD( base2, TITLE = 'Day:', VALUE = today( 2 ), XSIZE = 4 ) ;# stash the state WIDGET_CONTROL, WIDGET_INFO( base, /CHILD ), SET_UVALUE = state, /NO_COPY ;# create OK and Cancel buttons base3=WIDGET_BASE(base,ROW=1,/ALIGN_CENTER) b1 = WIDGET_BUTTON( base3, /ALIGN_CENTER, VALUE = 'OK', XSIZE = 80 ) b2 = WIDGET_BUTTON( base3, /ALIGN_CENTER, VALUE = 'Cancel', XSIZE = 80 ) ;# realize the widget hierarchy WIDGET_CONTROL, base, /REALIZE XMANAGER, 'CW_DATE', base RETURN, base END