FUNCTION cwq_winsel,on_base, QLDS, $ uvalue=uvalue, no_copy=no_copy, $ initial=initial, $ ;; In/Out title=title default,uvalue,'CWQ_WINSEL' ;* default,no_copy,0 ;* For setting uvalue of this Compound widget default,initial,-1 ; Default: Take the first available default,title,'' ;; ;; Once more: Check variable types ;; keyword = 0 scalar = 0 real = typ(/rea) natural = typ(/nat) strng = typ(/str) lng = typ(/lon) Nwin = N_ELEMENTS(qlds.detdesc(*)) ; Widgety things no_copy = KEYWORD_SET(no_copy) parcheck,initial,keyword,natural,scalar,'INITIAL',MINVAL=-1,MAXVAL=nwin-1 parcheck,title,keyword,strng,scalar,'TITLE' ;; ;; What do we have? ;; names = qlds.detdesc(*).label ;; ;; Which windows are valid ;; valid = qlds.detdesc(*).ixstop(0) GE 0 validix = WHERE(valid,nvalid) IF nvalid EQ 0 THEN BEGIN MESSAGE,"No selectable windows found" END menu = REPLICATE({PSELECT_S, btext:'', mtext:'', uvalue:'', flags:0}, $ Nwin) wlim = gt_wlimits(qlds,/wave,band=band,/quiet) aa = STRING(194B) ;Angstrom FOR i = 0,Nwin-1 DO BEGIN menu(i).btext = names(i) menu(i).uvalue = trim(i) text = " (Band "+trim(band(i))+")"+ $ " ["+trim(wlim(0,i))+aa+", "+ trim(wlim(1,i))+aa+"]" menu(i).mtext = names(i) + text END IF since_version('4.0') THEN sp = 1 ELSE sp = 0 base = WIDGET_BASE(on_base, xpad = sp,ypad = sp,space = sp,$ uvalue=uvalue,no_copy=no_copy, $ event_func='cwq_winsel_event', $ pro_set_value='cwq_winsel_setv') ;; ;; Bases for internal use: ;; storage = WIDGET_BASE(base,space=0,xpad=0,ypad=0) IF initial EQ -1 THEN BEGIN initial = validix(0) END ELSE BEGIN WHILE NOT valid(initial) DO initial = (initial + 1) MOD Nwin END PSEL_ID = CW_PSELECT(storage,title,menu,initial=initial) ;; Desensitize the nonvalid choices nonvalix = WHERE(valid - 1b,count) ;; Not valid FOR i = 0,count-1 DO BEGIN WIDGET_CONTROL,PSEL_ID,set_value = {insensitive:[trim(nonvalix(i))]} END ;; External values ;; These can be set by the user "on the fly" ext = $ { $ ;; cwq_winsel_disp,$ UPDATE : 0 $ } ;; Internal values ;; These are fixed for the lifetime of the compound widget. int = $ { $ ;; cwq_winsel_int,$ ql_no : QLDS.QL_NO, $ PSEL_ID: PSEL_ID,$ current : initial} info = $ { $ ;;cwq_winsel_info,$ ext : ext,$ int: int} WIDGET_CONTROL,storage,set_uvalue=info,/no_copy RETURN,base END