;+ ;NAME: ;thm_ui_history ;PURPOSE: ; A widget to display the string array for the history of programs ; called, given the thm_gui state structure ;INPUT: ;state structure, with a tag that is a pointer to a string array ;OUTPUT: ;The history array can be written to a file called ;'thm_gui_history.pro', which in principle, should be callable ;from IDL ;HISTORY: ;5-oct-2006, jmm, jimm@ssl.berkeley.edu ; ;$LastChangedBy: kenb-mac $ ;$LastChangedDate: 2007-01-26 15:52:34 -0800 (Fri, 26 Jan 2007) $ ;$LastChangedRevision: 241 $ ;$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/trunk/idl/themis/common/thm_ui_history.pro $ ; ;- Pro thm_ui_history_event, event ;Put a catch here to insure that the state remains defined err_xxx = 0 catch, err_xxx If(err_xxx Ne 0) Then Begin catch, /cancel message, /info, 'Error' help, /last_message, output = err_msg For j = 0, n_elements(err_msg)-1 Do print, err_msg[j] If(is_struct(state)) Then Begin widget_control, event.top, set_uval = state, /no_copy Endif Return Endif ; what happened? widget_control, event.id, get_uval = uval Case uval Of 'EXIT': widget_control, event.top, /destroy 'SAVE': Begin widget_control, event.top, get_uval = state, /no_copy If(is_string(state.history[0])) Then Begin If(strcompress(strupcase(state.history[0]), /remove_all) Ne 'NONE') $ Then Begin n = n_elements(state.history) ofile = 'thm_gui_history_'+time2file(!stime)+'.pro' openw, unit, ofile, /get_lun For j = 0, n-1 Do printf, unit, state.history[j] printf, unit, 'End' free_lun, unit message, /info, 'History saved in file: '+ofile Endif Else message, /info, 'No History to save' Endif Else message, /info, 'No History to save' widget_control, event.top, set_uval = state, /no_copy End Endcase Return End Pro thm_ui_history, state_in history = 'None' If(ptr_valid(state_in.history)) Then history = *state_in.history ;here is the display widget,not editable histid = widget_base(/col, title = 'Thm_gui History', tlb_frame_attr = 1) histdisplay = widget_text(histid, uval = 'HIST_DISPLAY', val = history, $ xsize = 80, ysize = 10, /scroll, frame = 5) ;a widget for buttons buttons = widget_base(histid, /row, /align_center, frame = 5) ;save button save_button = widget_base(buttons, /col, /align_center) savebut = widget_button(save_button, val = ' Save ', uval = 'SAVE', $ /align_center) ; exit button exit_button = widget_base(buttons, /col, /align_center) exitbut = widget_button(exit_button, val = ' Exit ', uval = 'EXIT', $ /align_center) state = {histid:histid, $ histdisplay:histdisplay, $ buttons:buttons, $ savebut:savebut, $ exitbut:exitbut, $ history:history} widget_control, histid, set_uval = state, /no_copy widget_control, histid, /realize xmanager, 'thm_ui_history', histid, /no_block Return End