; $Id: fans_resize.pro,v 1.3 2005/02/01 20:06:30 azuah Exp $
;###############################################################################
;
; NAME:
;   fans_resize
;
; PURPOSE:
;   Utility routines for FANS data reduction application defined in
;   the file fans_datreduc.pro. The routines in this file handle
;   resizing events for tlb.
;
; CATEGORY:
;   FANS Data Reduction
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Nov, 2002
;
; 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 of if the code in this file is
;  included in another product.
;
;###############################################################################



;===============================================================================
; fans_resize
;
; PURPOSE:
;   Event handler. Resize the tlb widget.
;
; PARAMETERS:
;   event [in] - event structure
;
pro fans_resize, event

if dave_set_focus(event) then return

widget_control, event.top, get_uvalue=sPtr

; new plot window width is maximum of the two r-values
(*sPtr).winWidth = (event.x - (*sPtr).restOfWidth) > (*sPtr).minXSize

; new plot window height is maximum of two r-values
(*sPtr).winHeight = (event.y - (*sPtr).restOfHeight) > (*sPtr).minYSize


; Delete and recreate pixmap window using new dimensions
wdelete, (*sPtr).winPix
window,/free,/pixmap,xsize=(*sPtr).winWidth,ysize=(*sPtr).winHeight
(*sPtr).winPix = !d.window
; Also resize visible window using new dimensions 
widget_control, (*sPtr).winVisID, xsize=(*sPtr).winWidth, ysize=(*sPtr).winHeight

widget_control, (*sPtr).tlbID, /realize

; Finally, update the display
widget_control, (*sPtr).sViewID, get_uvalue=sViewOn
widget_control, (*sPtr).bViewID, get_uvalue=bViewOn
widget_control, (*sPtr).fViewID, get_uvalue=fViewOn
widget_control, (*sPtr).oViewID, get_uvalue=oViewOn
case 1 of
    sViewOn: begin
        if ((*sPtr).sampCount lt 1) then return
        index = (*sPtr).sampIndex
        dataPtr = (*(*sPtr).sDataPtr)[index]
        updatePlotSlider, sPtr,'samp',dataPtr,err=err,emsg=emsg
    end

    bViewOn: begin
        if ((*sPtr).bkgdCount lt 1)  then return
        index = (*sPtr).bkgdIndex
        dataPtr = (*(*sPtr).bDataPtr)[index]
        updatePlotSlider, sPtr,'bkgd',dataPtr,err=err,emsg=emsg
    end

    fViewOn: begin
        if ((*sPtr).fastCount lt 1)  then return
        fans_plotData, sPtr,'fast',err=err,emsg=emsg ; can't view det cuts
    end 

    oViewOn: begin
        if ((*sPtr).sampCount lt 1)  then return
        fans_outpCalc, sPtr, err=err, emsg=emsg
        if (err ne 0) then begin
            printerror,err,emsg
            return
        endif
        fans_plotData, sPtr,'outp',err=err,emsg=emsg ; can't view det cuts
    end 

endcase


end
