;$Id: db_axisprop.pro,v 1.9 2005/02/08 17:01:16 azuah Exp $
;###############################################################################
;
; NAME:
;   DB_AxisProp
;
; PURPOSE:
;   Widget dialog program (non-blocking) for editing text labels in a
;   plot.
;
; 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
;   Feb, 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_AxisProp_Cleanup
;
; PURPOSE:
;   Main cleanup routine called when the main widget is destroyed
;
; PARAMETERS:
;   tlb [in] - the widget id of the top-level-base that is being
;              killed.
;
pro DB_AxisProp_Cleanup, tlb

widget_control, tlb, get_uvalue=sPtr

ptr_free, sPtr

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



;===============================================================================
; DB_AxisProp_Event
;
; PURPOSE:
;   Event handler for events originating from the main UI
;
; PARAMETERS:
;   event [in] - the event structure to be handled
;
pro DB_AxisProp_Event, event
widget_control,event.top,get_uvalue = sPtr
uname = widget_info(event.id,/uname)
valid_numChar = [46,48,49,50,51,52,53,54,55,56,57]

switch uname of
    'TEXT': begin
        widget_control, event.id, get_value=value
        (*sPtr).axisText = strtrim(value,2)
        break
    end

    'FNAME': begin
        (*sPtr).axisFontName = event.str
        boldID = widget_info(event.top,find_by_uname='BOLD')
        italicID = widget_info(event.top,find_by_uname='ITALIC')
        case strmid(event.str,0,6) of
            'SYMBOL': begin
                widget_control, boldID, sensitive=0
                widget_control, italicID, sensitive=0
            end
            'HERSHE': begin
                widget_control, boldID, sensitive=0
                widget_control, italicID, sensitive=0
            end 
            else: begin
                widget_control, boldID, sensitive=1
                widget_control, italicID, sensitive=1
            end
        endcase
        break
    end

    'BOLD': begin
        (*sPtr).axisBold = 1 - (*sPtr).axisBold
        break
    end

    'ITALIC': begin
        (*sPtr).axisItalic = 1 - (*sPtr).axisItalic
        break
    end

    'COLOR': begin
        widget_control, event.id, get_uvalue=colors
        (*sPtr).axisColor = colors[*,event.index]
        break
    end

    'ZLOC': if (n_elements(index) eq 0) then index = 2
    'YLOC': if (n_elements(index) eq 0) then index = 1
    'XLOC': begin
        if (n_elements(index) eq 0) then index = 0
        widget_control, event.id, get_value=valueStr
        value = (strlen(strtrim(valueStr,2)) eq 0)? 0.0 : float(valueStr)
        if ((value lt 0.0) or (value gt 1.0)) then begin
            value =  (0.0 > value < 1.0)
            valueStr = strtrim(string(value,format='(F5.2)'))
            widget_control, event.id,set_value=valueStr
        endif
        (*sPtr).axisPosition[index] = value
        break
    end

    'SIZE': begin
        if (event.index eq -1) then begin ; add a new entry to the list
            widget_control, event.id, get_value=strArray, get_uvalue=fltArray
            index = insertValueInArray(fltArray, float(event.str))
            insertStringInStringArray, strArray, event.str, index
            widget_control, event.id, set_value=strArray,set_uvalue=fltArray,set_combobox_select=index
        endif
        (*sPtr).axisFontSize = float(event.str)
        break
    end

    'ALIGN': begin
        case strupcase(event.str) of 
            'LEFT': (*sPtr).axisAlignment = 0.0
            'CENTER': (*sPtr).axisAlignment = 0.5
            'RIGHT': (*sPtr).axisAlignment = 1.0
        endcase
        break
    end

    'USECUSTOM': begin
        (*sPtr).miscAttribs.useCustomFlag = 1 - (*sPtr).miscAttribs.useCustomFlag
        minID = widget_info(event.top,find_by_uname='MINIMUM')
        maxID = widget_info(event.top,find_by_uname='MAXIMUM')
        tintID = widget_info(event.top,find_by_uname='TICKINTERVAL')
        ;mulID = widget_info(event.top,find_by_uname='MULTIPLIER')
        ;ltypeID = widget_info(event.top,find_by_uname='LOGTYPE')
        widget_control, minID, sensitive = (*sPtr).miscAttribs.useCustomFlag
        widget_control, maxID, sensitive = (*sPtr).miscAttribs.useCustomFlag
        widget_control, tintID, sensitive = (*sPtr).miscAttribs.useCustomFlag
        ;widget_control, mulID, sensitive = (*sPtr).miscAttribs.useCustomFlag
        ;widget_control, ltypeID, sensitive = (*sPtr).miscAttribs.useCustomFlag and (*sPtr).axisPosFlag
        applyID = widget_info(event.top,find_by_uname='APPLY')
        widget_control, applyID, get_uvalue=applyIndex
        applyIndex = 1 - applyIndex
        applyOptions = ['Apply','Apply & Exit']
        widget_control, applyID, set_uvalue=applyIndex, set_value=applyOptions[applyIndex]
        print,'applyIndex = ',applyIndex
        break
    end

    'MINIMUM': begin
        aValidChar = 0
        if (event.type eq 0) then res = where(valid_numChar eq event.ch, aValidChar)
        if (not aValidChar) then break
        widget_control, event.id, get_value=value
        (*sPtr).miscAttribs.minimum = float(strtrim(value,2))
        break
    end

    'MAXIMUM': begin
        aValidChar = 0
        if (event.type eq 0) then res = where(valid_numChar eq event.ch, aValidChar)
        if (not aValidChar) then break
        widget_control, event.id, get_value=value
        (*sPtr).miscAttribs.maximum = float(strtrim(value,2))
        break
    end

    'TICKINTERVAL': begin
        aValidChar = 0
        if (event.type eq 0) then res = where(valid_numChar eq event.ch, aValidChar)
        if (not aValidChar) then break
        widget_control, event.id, get_value=value
        (*sPtr).miscAttribs.tickInterval = float(strtrim(value,2))
        break
    end

    'MULTIPLIER': begin
        aValidChar = 0
        if (event.type eq 0) then res = where(valid_numChar eq event.ch, aValidChar)
        if (not aValidChar) then break
        widget_control, event.id, get_value=value
        (*sPtr).miscAttribs.scalefactor = float(strtrim(value,2))
        break
    end

    'LOGTYPE': begin
        (*sPtr).miscAttribs.logFlag = event.index
        break
    end

    'DECPLACES': begin
        aValidChar = 0
        if (event.type eq 0) then res = where(valid_numChar eq event.ch, aValidChar)
        if (not aValidChar) then break
        widget_control, event.id, get_value=value
        (*sPtr).miscAttribs.decimalPlaces = fix(strtrim(value,2))
        break
    end

    'TICKDIR': begin
        (*sPtr).miscAttribs.tickDir = event.index
        break
    end

    'TICKLEN': begin
        (*sPtr).miscAttribs.tickLen = float(strtrim(event.str,2))
        break
    end

    'MINORCOUNT': begin
        (*sPtr).miscAttribs.minorTicks = fix(strtrim(event.str,2))
        break
    end

    'DEFAULT': begin
        if (!debug) then help,(*sPtr).miscAttribs,/struct
        ;; reset to default values
        (*sPtr).daveGrRef->resetMiscGrAttribs, index=(*sPtr).axisIndex

        ;; get the reset values
        case (*sPtr).axisIndex of
            0: void = (*sPtr).daveGrRef->get(xMiscAttribs=miscAttribs)
            1: void = (*sPtr).daveGrRef->get(yMiscAttribs=miscAttribs)
            2: void = (*sPtr).daveGrRef->get(zMiscAttribs=miscAttribs)
        endcase
        if (void ne 1) then begin
            if (!debug) then print, !error_state.msg
            return
        endif
        (*sPtr).miscAttribs = miscAttribs

        ;; update the dialog
        wID = widget_info(event.top,find_by_uname='USECUSTOM')
        widget_control, wid, set_button=miscattribs.useCustomFlag

        wID = widget_info(event.top,find_by_uname='MINIMUM')
        widget_control, wid, set_value=strtrim(string(miscattribs.minimum,format='(G11.5)'),2) $
                        ,sensitive = miscAttribs.useCustomFlag 

        wID = widget_info(event.top,find_by_uname='MAXIMUM')
        widget_control, wID, set_value=strtrim(string(miscattribs.maximum,format='(G11.5)'),2) $
                        ,sensitive = miscAttribs.useCustomFlag 

        wID = widget_info(event.top,find_by_uname='TICKINTERVAL')
        widget_control, wID, set_value=strtrim(string(miscattribs.tickinterval,format='(G11.5)'),2) $
                        ,sensitive = miscAttribs.useCustomFlag 

        wID = widget_info(event.top,find_by_uname='MULTIPLIER')
        widget_control, wID, set_value=strtrim(string(miscattribs.scalefactor,format='(G11.5)'),2)

        wID = widget_info(event.top,find_by_uname='LOGTYPE')
        widget_control, wID, set_combobox_select=miscAttribs.logFlag

        wID = widget_info(event.top,find_by_uname='DECPLACES')
        widget_control, wID, set_value=strtrim(string(miscattribs.decimalPlaces,format='(I3)'),2)

        wID = widget_info(event.top,find_by_uname='TICKDIR')
        widget_control, wID, set_combobox_select=miscAttribs.tickDir

        wID = widget_info(event.top,find_by_uname='TICKLEN')
        widget_control, wID, get_uvalue=options
        res = where(options eq miscAttribs.tickLen, count)
        if (count gt 0) then widget_control, wID, set_combobox_select=res[0]

        wID = widget_info(event.top,find_by_uname='MINORCOUNT')
        widget_control, wID, get_uvalue=options
        res = where(options eq miscAttribs.minorTicks, count)
        if (count gt 0) then widget_control, wID, set_combobox_select=res[0]

        if (!debug) then help,(*sPtr).miscAttribs,/struct

        break
    end


    'APPLY': begin
        font = (*sPtr).axisFontName
        if (strmid(font,0,6) ne 'SYMBOL') then begin
            if ((*sPtr).axisBold) then $
              font = font+'*'+'BOLD'
            if ((*sPtr).axisItalic) then $
              font = font+'*'+'ITALIC'
        endif

        if ((not obj_valid((*sPtr).atomRef)) or (not obj_valid((*sPtr).daveGrRef)) ) then begin
            widget_control,event.top,/destroy
            return
        endif
        

        ;; Apply changes

        ;;; modify axis title, font
        ((*sPtr).atomRef)->getProperty, title=axisLabelRef,range=curRange ; get axis label obj ref
        axisLabelRef->getProperty, font=fontRef ; get axis label font obj ref


        minorTicks = (*sPtr).miscAttribs.minorTicks
        logFlag = (curRange[0] ge 0.0)? (*sPtr).miscAttribs.logFlag : 0 ; range must be +ve for log
        fCode = getFormatCode(curRange[0],curRange[1],(*sPtr).miscAttribs.decimalPlaces)
        tickDir = (*sPtr).miscAttribs.tickDir


        ((*sPtr).atomRef)->setProperty, color=(*sPtr).axisColor $ ; update axis color
          ,minor=minorTicks $   ; update nos of minor ticks
          ,log=logFlag $        ; update axis scaling linear/log
          ,tickformat=fCode $   ; update format code
          ,tickDir=tickDir      ; update tick direction

        fontRef->setProperty, name=font, size=(*sPtr).axisFontSize ; change font properties
        axisLabelRef->setProperty, strings=(*sPtr).axisText ; change label text


        ;; Save changes

        ;;; axis label and font props
        case (*sPtr).AxisIndex of
            0: kw_val = {xLabel:(*sPtr).axisText,xColor:(*sPtr).axisColor,xFontVal:font $
                         ,xFontSize:(*sPtr).axisFontSize,xMiscAttribs:(*sPtr).miscAttribs} ; x-axis
            1: kw_val = {yLabel:(*sPtr).axisText,yColor:(*sPtr).axisColor,yFontVal:font $
                         ,yFontSize:(*sPtr).axisFontSize,yMiscAttribs:(*sPtr).miscAttribs} ; y-axis
            2: kw_val = {zLabel:(*sPtr).axisText,zColor:(*sPtr).axisColor,zFontVal:font $
                         ,zFontSize:(*sPtr).axisFontSize,zMiscAttribs:(*sPtr).miscAttribs} ; z-axis
        endcase        

        if (not ((*sPtr).daveGrRef)->set(_EXTRA=kw_val)) then return
        
        ;; if applying and exiting then kill dialog and reconstruct
        ;; the scene else simply update the scene
        widget_control, event.id, get_uvalue=finished
        if (finished) then begin
            ((*sPtr).widObjRef)->Renew
            ((*sPtr).widObjRef)->refresh 
            widget_control,event.top,/destroy
        endif else begin
            ((*sPtr).widObjRef)->noRenew
            ((*sPtr).widObjRef)->refresh 
        endelse

        break
    end

    'EXIT': begin
        widget_control,event.top,/destroy
        break
    end

    else:

endswitch

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



;===============================================================================
; DB_AxisProp
;
; PURPOSE:
;   Entry point and dialog builder for application.
;
; PARAMETERS
;   AxisIndex [in;req] - Axis type: 0=>x, 1=>y, 2=>z
;
;   atomRef [in|out;req] - The axis object reference to be edited.
;
;   daveGrRef [in;req] - The DaveGr object reference currently on
;                             display.
;
;   widObjRef [in;req] - The object reference of the display (view)
;                        from which the edit request originated from.
;
; KEYWORDS:
;   group_leader [in] - the ID of the parent widget from which this
;                       dialog was launched.
;
pro DB_AxisProp, AxisIndex,atomRef,daveGrRef,widObjRef,group_leader=glder

validGrObjects = ['DAVEGR1D','DAVEGR2D']
objClass = vartype(daveGrRef)
res = where(validGrObjects eq objClass, okay)
if (not okay) then return

if (not obj_valid(atomRef)) then return

if (not obj_valid(widObjRef)) then return
  
;res = where(objClass eq 'DAVEGR1D', is1D)

is1D = (objClass eq 'DAVEGR1D')? 1 : 0

if (is1D) then begin
    case AxisIndex of
        0: begin
            if (not daveGrRef->get(xColor=axisColor,xFontVal=axisFont,xFontSize=axisFontSize $
                                   ,xLabel=axisText,xLineSize=axisLineSize,xmin=amin,xmax=amax $
                                   ,xMiscAttribs=miscAttribs)) then return
            title = 'DATABROWSER - X-Axis Properties'
        end
        else: begin
            if (not daveGrRef->get(zColor=axisColor,zFontVal=axisFont,zFontSize=axisFontSize $
                                   ,zLabel=axisText,zLineSize=axisLineSize,zmin=amin,zmax=amax $
                                   ,zMiscAttribs=miscAttribs)) then return
            title = 'DATABROWSER - Y-Axis Properties'
            AxisIndex = 2 ; for 1D, zaxis ==  yaxis
        end
    endcase
endif else begin
    case AxisIndex of
        0: begin
            if (not daveGrRef->get(xColor=axisColor,xFontVal=axisFont,xFontSize=axisFontSize $
                                   ,xLabel=axisText,xLineSize=axisLineSize,xmin=amin,xmax=amax $
                                   ,xMiscAttribs=miscAttribs)) then return
            title = 'DATABROWSER - X-Axis Properties'
        end
        1: begin
            if (not daveGrRef->get(yColor=axisColor,yFontVal=axisFont,yFontSize=axisFontSize $
                                   ,yLabel=axisText,yLineSize=axisLineSize,ymin=amin,ymax=amax $
                                   ,yMiscAttribs=miscAttribs)) then return
            title = 'DATABROWSER - Y-Axis Properties'        
        end
        2: begin
            if (not daveGrRef->get(zColor=axisColor,zFontVal=axisFont,zFontSize=axisFontSize $
                                   ,zLabel=axisText,zLineSize=axisLineSize,zmin=amin,zmax=amax $
                                   ,zMiscAttribs=miscAttribs)) then return
            title = 'DATABROWSER - Z-Axis Properties'
        end
    endcase
endelse

axisBold = 0b
axisItalic = 0b
axisFontName = 'HELVETICA'
if (strlen(axisFont) gt 0) then begin
    toks = strsplit(axisFont,'*',/extract)
    axisFontName = toks[0]
    if (n_elements(toks) gt 1) then begin
        case toks[1] of
            'BOLD': axisBold = 1b
            'ITALIC': axisItalic = 1b
        endcase
    endif
    if (n_elements(toks) gt 2) then begin
        case toks[2] of
            'BOLD': axisBold = 1b
            'ITALIC': axisItalic = 1b
        endcase
    endif
endif

axisPosFlag = (amin gt 0.0 and amax gt 0.0)? 1b : 0b ; is axis positive
axisCustom = miscAttribs.useCustomFlag
axisMin = miscAttribs.minimum
axisMax = miscAttribs.maximum
axisTickInt = miscAttribs.tickInterval
mplier = miscAttribs.scalefactor
axisLogType = miscAttribs.logFlag
axisPrecision = miscAttribs.decimalPlaces
axisTickDir = miscAttribs.tickDir
axisTickLen = miscAttribs.tickLen
axisMinorNos = miscAttribs.minorTicks

if n_elements(glder) eq 0 then begin
    group_leader = 0L
    modal = 0
    tlb = widget_base(/col,title=title)
endif else begin
    modal = 1
    tlb = widget_base(group_leader=glder,/col,title=title);,modal=modal)
endelse

; Split the dialog base into
; - one tab base
; - one control base
tabBase = widget_tab(tlb)
ansBase = widget_base(tlb,/row,/align_center)

; Create three tab widgets
tab1 = widget_base(tabBase,title='Label Text',/col)
tab2 = widget_base(tabBase,title='Range',/col)
tab3 = widget_base(tabBase,title='Format',/col)

dropSize = 150
labSize = 70
lab2Size = 150
textSize = 50
locSize = 17
gap0 = 10
gap1 = dropSize + labSize + gap0
gap2 = gap1 + labSize
; Create control bases for first tab
cb1 = widget_base(tab1,/row,/align_center)
cb2 = widget_base(tab1,/row)
cb21 = widget_base(cb2,/row)
cb22 = widget_base(cb2,/row,/align_left)
cb3 = widget_base(tab1,/row)
cb31 = widget_base(cb3,/row)
cb32 = widget_base(cb3,/row,/align_left)
cb33 = widget_base(cb3,/row,xoffset=gap1)
cb34 = widget_base(cb3,/row,/align_right,xoffset=gap2,/nonexclusive)
cb4 = widget_base(tab1,/row)
cb41 = widget_base(cb4,/row)
cb42 = widget_base(cb4,/row,/align_left)
cb43 = widget_base(cb4,/row,xoffset=gap1)
cb44 = widget_base(cb4,/row,/align_right,xoffset=gap2,/nonexclusive)
cb5 = widget_base(tab1,/row)
cb51 = widget_base(cb5,/row)
cb52 = widget_base(cb5,/row,/align_left)
; Create control bases for second tab
cb6 = widget_base(tab2,/row,/align_center,/nonexclusive)
cb7 = widget_base(tab2,/row)
cb71 = widget_base(cb7,/row)
cb72 = widget_base(cb7,/row,/align_left)
cb8 = widget_base(tab2,/row)
cb81 = widget_base(cb8,/row)
cb82 = widget_base(cb8,/row,/align_left)
cb9 = widget_base(tab2,/row)
cb91 = widget_base(cb9,/row)
cb92 = widget_base(cb9,/row,/align_left)
cb93 = widget_base(cb9,/row)
cb10 = widget_base(tab2,/row)
cb101 = widget_base(cb10,/row)
cb102 = widget_base(cb10,/row,/align_left)
cb11 = widget_base(tab2,/row)
cb111 = widget_base(cb11,/row)
cb112 = widget_base(cb11,/row,/align_left)
; Create control bases for third tab
cb300 = widget_base(tab3,/row,/align_center)
cb301 = widget_base(tab3,/row,/align_left)
cb3011 = widget_base(cb301,/row,/align_left)
cb3012 = widget_base(cb301,/row,/align_left)
cb302 = widget_base(tab3,/row,/align_left)
cb3021 = widget_base(cb302,/row,/align_left)
cb3022 = widget_base(cb302,/row,/align_left)
cb303 = widget_base(tab3,/row,/align_left)
cb3031 = widget_base(cb303,/row,/align_left)
cb3032 = widget_base(cb303,/row,/align_left)
cb304 = widget_base(tab3,/row,/align_left)
cb3041 = widget_base(cb304,/row,/align_left)
cb3042 = widget_base(cb304,/row,/align_left)

; First Tab
;-------------------------------------------------
void = widget_label(cb1,value='(To commit changes, use Apply button below!)')

; Text edit widget
void = widget_label(cb21,value='Text:',xsize=labSize,/align_right)
textID = widget_text(cb22,/editable,/all_events,value=axisText,xsize=textSize,uname='TEXT')

; Font Color
void = widget_label(cb31,value='Color:',xsize=labSize,/align_right)
colorNames = ['Aqua','Black','Blue','Fuchsia','Gray','Green','Lime','Maroon', $
              'Navy','Olive','Purple','Red','Silver','Teal','White','Yellow']
colorIndices = [[0,255,255],[0,0,0],[0,0,255],[255,0,255],$
                [128,128,128],[0,128,0],[0,255,0],[128,0,0], $
                [0,0,128],[128,128,0],[128,0,128],[255,0,0], $
                [192,192,192],[0,128,128],[255,255,255],[255,255,0]]
fcolorID = widget_combobox(cb32,value=colorNames,uname='COLOR',uvalue=colorIndices,xsize=dropSize)
if (n_elements(axisColor) gt 0) then begin
    for i=0,(size(colorIndices))[2]-1 do begin
        void = where(colorIndices[*,i] eq axisColor, count)
        if (count eq 3) then begin
            widget_control, fcolorID, set_combobox_select=i
            break
        endif
    endfor
endif

; Font modifiers - bold, italics
void = widget_label(cb33,value='Bold:',xsize=labSize,/align_right)
mod1ID = widget_button(cb34,uname='BOLD',value=' ')
widget_control, mod1ID, set_button=axisBold
void = widget_label(cb43,value='Italic:',xsize=labSize,/align_right)
mod2ID = widget_button(cb44,uname='ITALIC',value=' ')
widget_control, mod2ID, set_button=axisItalic
str = strmid(axisFontName,0,6)
if ((str eq 'SYMBOL') or (str eq 'HERSHE')) then begin
    widget_control, mod1ID, sensitive=0
    widget_control, mod2ID, sensitive=0
endif



; Fontname droplist
void = widget_label(cb41,value='Font:',xsize=labSize,/align_right)
fonts = ['HELVETICA','COURIER','TIMES','SYMBOL','HERSHEY']
fnameID = widget_combobox(cb42,value=fonts,uname='FNAME',xsize=dropSize)
;if (strlen(axisFontName) gt 0) then begin
index = where(fonts eq axisFontName)
widget_control, fnameID, set_combobox_select=index
;endif

; Font Size
void = widget_label(cb51,value='Fontsize:',xsize=labSize,/align_right)
sizes = [8,10,12,14,16,18,20,22,24,26,28,30]
fSizes = ['8','10','12','14','16','18','20','22','24','26','28','30']
fsizeID = widget_combobox(cb52,/editable,value=fSizes,uname='SIZE',uvalue=sizes,xsize=dropSize)
;if (n_elements(labFontSize) gt 0) then begin
    res = where(sizes ge axisFontSize, count)
    if (count gt 0) then widget_control, fsizeID, set_combobox_select=res[0]
;endif


; Second Tab
;-------------------------------------------------
dropSize = 150
labSize = 90
lab2Size = 150
textSize = 30
locSize = 17

void = widget_button(cb6,uname='USECUSTOM',value='Use custom range settings')
widget_control, void, set_button=axisCustom
;void = widget_label(cb6,value='(To commit changes, use Apply button below!)',/align_center)

; minimum field
void = widget_label(cb71,value='Minimum:',xsize=labSize,/align_right)
value = strtrim(string(axisMin,format='(G11.5)'),2)
void = widget_text(cb72,/editable,/all_events,value=value,xsize=textSize,uname='MINIMUM')
widget_control, void, sensitive=axisCustom
; maximum field
void = widget_label(cb81,value='Maximum:',xsize=labSize,/align_right)
value = strtrim(string(axisMax,format='(G11.5)'),2)
void = widget_text(cb82,/editable,/all_events,value=value,xsize=textSize,uname='MAXIMUM')
widget_control, void, sensitive=axisCustom
; interval field
void = widget_label(cb91,value='Tick interval:',xsize=labSize,/align_right)
value = strtrim(string(axisTickInt,format='(G11.5)'),2)
void = widget_text(cb92,/editable,/all_events,value=value,xsize=textSize,uname='TICKINTERVAL')
widget_control, void, sensitive=axisCustom
; multiplier field
void = widget_label(cb101,value='Multiply by:',xsize=labSize,/align_right)
value = strtrim(string(mplier,format='(G11.5)'),2)
void = widget_text(cb102,/editable,/all_events,value=value,xsize=textSize,uname='MULTIPLIER',sensitive=0)
; log/linear field
void = widget_label(cb111,value='Type:',xsize=labSize,/align_right)
options = ['Linear','Log10']
ltypeID = widget_combobox(cb112,value=options,uname='LOGTYPE',xsize=dropSize,sensitive=0)
widget_control, ltypeID, set_combobox_select=axisLogType

; Third Tab
;-------------------------------------------------
dropSize = 150
labSize = 130
textSize = 30
locSize = 17

void = widget_label(cb300,value='(To commit changes, use Apply button below!)',/align_center)



; custom settings button
;void = widget_label(cb311,value='Use Custom Settings:',/align_right)
;mod1ID = widget_button(cb312,uname='CUSTOM',value=' ')

; scientific
;void = widget_label(cb321,value='Notation:',/align_right)
;mod1ID = widget_button(cb322,uname='SCIENTIFIC',value=' ')

; field width field
void = widget_label(cb3011,value='Decimal places:',xsize=labSize,/align_right)
value = strtrim(string(axisPrecision,format='(I6)'),2)
void = widget_text(cb3012,/editable,/all_events,value=value,xsize=textSize,uname='DECPLACES')
; Tick direction field
void = widget_label(cb3021,value='Tick direction:',xsize=labSize,/align_right)
options = ['Inwards','Outwards']
tdirID = widget_combobox(cb3022,value=options,uname='TICKDIR',xsize=dropSize)
widget_control, tdirID, set_combobox_select=axisTickDir
; (major) Tick length field
void = widget_label(cb3031,value='Tick length (%axis):',xsize=labSize,/align_right)
noptions= [1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0]
options = ['1.0','1.5','2.0','2.5','3.0','3.5','4.0','4.5','5.0']
tlenID = widget_combobox(cb3032,value=options,uvalue=noptions,uname='TICKLEN',xsize=dropSize)
if (n_elements(axisTickLen) gt 0) then begin
    res = where(noptions eq axisTickLen, count)
    if (count gt 0) then widget_control, tlenID, set_combobox_select=res[0]
endif

; Nos of minor ticks field
void = widget_label(cb3041,value='Nos minor ticks:',xsize=labSize,/align_right)
noptions = [1,2,3,4,5,6,7,8,9,10]
options = ['1','2','3','4','5','6','7','8','9','10']
nminorID = widget_combobox(cb3042,value=options,uvalue=noptions,uname='MINORCOUNT',xsize=dropSize)
if (n_elements(axisMinorNos) gt 0) then begin
    res = where(noptions eq fix(axisMinorNos), count)
    if (count gt 0) then widget_control, nminorID, set_combobox_select=res[0]
endif

; Action buttons
applTip = 'Save and apply changes made then update plot'
dismTip = 'Close this dialog, discarding all un-applied chages'
dfltTip = 'Revert all attributes to their default values'
applyOptions = ['   Apply    ','Apply + Exit']
void = widget_button(ansBase,value=applyOptions[axisCustom],uname='APPLY' $
                     ,uvalue=axisCustom,tooltip=applTip)
void = widget_button(ansBase,value='Dismiss',uname='EXIT',tooltip=dismTip)
void = widget_button(ansBase,value='Set Defaults',uname='DEFAULT',tooltip=dfltTip)

; tlb uvalue
sPtr = ptr_new({AxisIndex:AxisIndex, $
                atomRef:atomRef, $
                davegrRef:daveGrRef, $
                widObjRef:widObjRef, $
                miscAttribs:miscAttribs, $
                axisText:axisText, $
                axisColor:axisColor, $
                axisFontName:axisFontName, $
                axisFontSize:axisFontSize, $
                axisBold:axisBold, $
                axisItalic:axisItalic, $
                axisPosFlag:axisPosFlag $
                })

;----------------------------------------------------------------------------
; realize widgets
widget_control, tlb,/realize, set_uvalue=sPtr


registerName = 'db_axisprop'
xmanager,registerName,tlb,/no_block,event_handler='db_axisprop_event',cleanup='db_axisprop_cleanup'


end
