; $Id: db_disphist.pro,v 1.4 2005/02/08 17:01:16 azuah Exp $
;###############################################################################
;
; NAME:
;   DB_DispHist
;
; PURPOSE:
;   A small utility widget program to display a string array.
;   Used for displaying the treatment history for a dataset.
;
; CATEGORY:
;   Data Browser
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Mar, 2003
;
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used or if the code in this file is
;  included in another product.
;
;###############################################################################



;===============================================================================
; DB_DispHist_Event
;
; PURPOSE:
;   Main event handler for app.
;
; PARAMETERS:
;   event [in] - the event structure to be handled
;
pro db_DispHist_event,event

uname = widget_info(event.id,/uname)

case uname of
    'DISMISS': widget_control,event.top,/destroy
    else:
endcase

end
;-------------------------------------------------------------------------------



;===============================================================================
; DB_DispHist
;
; PURPOSE:
;   Entry point and dialog builder for application.
;
; PARAMETERS
;   history [in;req] - The string array to be displayed
;
; KEYWORDS:
;   group_leader [in] - the ID of the parent widget from which this
;                       dialog was launched.
;
pro db_DispHist, history, group_leader=grpl

; 
title = "DATABROWSER - Data Treatment Log"
if (n_elements(grpl) eq 0) then begin
    modal = 0
    tlb = widget_base(/col,title=title,/base_align_center)
endif else begin
    modal = 1
    tlb = widget_base(group_leader=grpl,modal=modal,/col,title=title,/base_align_center)
endelse

nlines = n_elements(history)
if (nlines le 0) then begin
    nlines = 1
    history = ['No treatment information available!']
endif


xmax = 120
ymax = 60
xsize = 0
ysize = nlines < ymax
xsize = max(strlen(history)) < xmax

scroll = 0
if ((xsize ge xmax) or (ysize ge ymax)) then scroll=1
void = widget_text(tlb,value=history,xsize=xsize,ysize=ysize,scroll=scroll,uname='TEXT')

dismTip = 'Close this dialog'
void = widget_button(tlb,value='Dismiss',uname='DISMISS',tooltip=dismTip)

widget_control,tlb,/realize

xmanager,'db_disphist',tlb,event_handler='db_disphist_event',no_block=modal

return
end
