[114] | 1 | ; PRO testwid_event, event |
---|
| 2 | ; ; |
---|
| 3 | ; compile_opt idl2, strictarrsubs |
---|
| 4 | ; ; |
---|
| 5 | ; widget_control, event.id, get_uvalue=uval |
---|
| 6 | ; if n_elements(uval) EQ 0 then return |
---|
| 7 | ; case uval of |
---|
| 8 | ; 'done':widget_control, event.top, /destroy |
---|
| 9 | ; 'get':BEGIN |
---|
| 10 | ; id = widget_info(event.top,find_by_uname = 'discret') |
---|
| 11 | ; widget_control, id, get_value = value1 |
---|
| 12 | ; help, value1 |
---|
| 13 | ; print, 'value1', value1 |
---|
| 14 | ; id = widget_info(event.top,find_by_uname = 'continus') |
---|
| 15 | ; widget_control, id, get_value = value2 |
---|
| 16 | ; help, value2 |
---|
| 17 | ; print, 'value2', value2 |
---|
| 18 | ; END |
---|
| 19 | ; ELSE: |
---|
| 20 | ; endcase |
---|
| 21 | ; return |
---|
| 22 | ; end |
---|
| 23 | ; PRO testwid, _extra = ex |
---|
| 24 | ; ; |
---|
| 25 | ; compile_opt idl2, strictarrsubs |
---|
| 26 | ; ; |
---|
| 27 | ; base=widget_base(/COLUMN) |
---|
| 28 | ; nothing = widget_label(base, value = 'beginning of the test') |
---|
| 29 | ; ; |
---|
| 30 | ; nothing = cw_selectinterval(base, 10+indgen(5), _extra = ex, uname = 'discret', uvalue = 'discret') |
---|
| 31 | ; print, nothing |
---|
| 32 | ; nothing = cw_selectinterval(base, indgen(20), _extra = ex, uname = 'continus', uvalue = 'continus') |
---|
| 33 | ; print, nothing |
---|
| 34 | ; ; |
---|
| 35 | ; nothing = widget_button(base, value = 'get', uvalue = 'get') |
---|
| 36 | ; nothing = widget_button(base, value = 'done', uvalue = 'done') |
---|
| 37 | ; widget_control, base, /REALIZE |
---|
| 38 | ; xmanager,'testwid', base, /no_block |
---|
| 39 | ; return |
---|
| 40 | ; end |
---|
[231] | 41 | ; |
---|
[157] | 42 | ;+ |
---|
[231] | 43 | ; @file_comments |
---|
| 44 | ; |
---|
[157] | 45 | ; @categories |
---|
| 46 | ; Compound widget |
---|
[231] | 47 | ; |
---|
[157] | 48 | ; @param ID |
---|
[231] | 49 | ; |
---|
[157] | 50 | ; @returns |
---|
[231] | 51 | ; |
---|
[157] | 52 | ; @restrictions |
---|
[231] | 53 | ; |
---|
[157] | 54 | ; @examples |
---|
| 55 | ; |
---|
| 56 | ; @history |
---|
| 57 | ; |
---|
| 58 | ; @version |
---|
| 59 | ; $Id$ |
---|
[325] | 60 | ; |
---|
| 61 | ; @todo |
---|
| 62 | ; seb |
---|
| 63 | ; |
---|
[157] | 64 | ;- |
---|
[53] | 65 | function cw_selectinterval_get_value, id |
---|
[114] | 66 | ; |
---|
| 67 | compile_opt idl2, strictarrsubs |
---|
| 68 | ; |
---|
[53] | 69 | bgroupid=widget_info(id, find_by_uname = 'bgroup') |
---|
| 70 | ; the widget is a set of button |
---|
| 71 | if bgroupid ne 0 then begin |
---|
| 72 | widget_control, bgroupid, get_value = selected |
---|
| 73 | widget_control, bgroupid, get_uvalue = vecteur |
---|
| 74 | vecteur = vecteur.vecteur |
---|
| 75 | endif else begin |
---|
| 76 | ; the widget is 2 sliders |
---|
| 77 | Minid = Widget_Info(Id, Find_by_uname = 'min') |
---|
| 78 | widget_control, minid, get_value = minval |
---|
| 79 | minval = minval.value |
---|
| 80 | maxid = widget_info(id, find_by_uname = 'max') |
---|
| 81 | widget_control, maxid, get_value = maxval |
---|
| 82 | maxval = maxval.value |
---|
| 83 | widget_control, minid, get_uvalue = vecteur |
---|
| 84 | vecteur = vecteur.vecteur |
---|
| 85 | selected = where(vecteur ge minval and vecteur le maxval) |
---|
| 86 | ENDELSE |
---|
| 87 | if selected[0] eq -1 then return, -1 else return, vecteur[selected] |
---|
| 88 | END |
---|
[231] | 89 | ; |
---|
[157] | 90 | ;+ |
---|
[231] | 91 | ; @file_comments |
---|
| 92 | ; |
---|
[157] | 93 | ; @categories |
---|
| 94 | ; Compound widget |
---|
[231] | 95 | ; |
---|
[157] | 96 | ; @param EVENT |
---|
[231] | 97 | ; |
---|
[157] | 98 | ; @returns |
---|
[231] | 99 | ; |
---|
[157] | 100 | ; @restrictions |
---|
[231] | 101 | ; |
---|
[157] | 102 | ; @examples |
---|
[114] | 103 | ; |
---|
[157] | 104 | ; @history |
---|
| 105 | ; |
---|
| 106 | ; @version |
---|
| 107 | ; $Id$ |
---|
[325] | 108 | ; |
---|
[157] | 109 | ;- |
---|
[325] | 110 | function cw_selectinterval_event, event |
---|
[231] | 111 | ; |
---|
[114] | 112 | compile_opt idl2, strictarrsubs |
---|
| 113 | ; |
---|
[53] | 114 | widget_control, event.id, get_uvalue=uval |
---|
| 115 | case uval.name of |
---|
| 116 | 'min':begin ; change the value if the minimum for the slider called max |
---|
| 117 | maxid=widget_info(event.handler, find_by_uname = 'max') |
---|
| 118 | widget_control, maxid, set_value={SLIDER_MIN:event.value+1} |
---|
| 119 | end |
---|
| 120 | 'max':begin ; change the value if the maximum for the slider called min |
---|
| 121 | minid=widget_info(event.handler, find_by_uname = 'min') |
---|
| 122 | widget_control, minid, set_value={SLIDER_MAX:event.value-1} |
---|
| 123 | end |
---|
| 124 | 'bgroup': |
---|
| 125 | endcase |
---|
| 126 | return, {ID:event.handler, TOP:event.top, HANDLER:0L} |
---|
| 127 | END |
---|
[231] | 128 | ; |
---|
[157] | 129 | ;+ |
---|
[231] | 130 | ; @file_comments |
---|
| 131 | ; |
---|
[157] | 132 | ; @categories |
---|
[231] | 133 | ; Compound widget |
---|
| 134 | ; |
---|
| 135 | ; @param PARENT |
---|
[157] | 136 | ; The widget ID of the parent widget. |
---|
[231] | 137 | ; |
---|
[163] | 138 | ; @param VECTEUR {type=vector} |
---|
[231] | 139 | ; A vector whose the first element must be the smallest one and the last |
---|
[157] | 140 | ; must be the biggest one. |
---|
[231] | 141 | ; |
---|
[157] | 142 | ; @keyword _EXTRA |
---|
[231] | 143 | ; Used to pass keywords |
---|
| 144 | ; |
---|
[157] | 145 | ; @returns |
---|
[231] | 146 | ; |
---|
[157] | 147 | ; @restrictions |
---|
[231] | 148 | ; |
---|
[157] | 149 | ; @examples |
---|
| 150 | ; |
---|
| 151 | ; @history |
---|
| 152 | ; |
---|
| 153 | ; @version |
---|
| 154 | ; $Id$ |
---|
[325] | 155 | ; |
---|
[157] | 156 | ;- |
---|
[232] | 157 | FUNCTION cw_selectinterval, parent, vecteur, _EXTRA = ex |
---|
[114] | 158 | ; |
---|
| 159 | compile_opt idl2, strictarrsubs |
---|
| 160 | ; |
---|
[53] | 161 | |
---|
| 162 | base = widget_base(parent $ |
---|
| 163 | , EVENT_FUNC = 'cw_selectinterval_event' $ |
---|
| 164 | , FUNC_GET_VALUE='cw_selectinterval_get_value' $ |
---|
| 165 | , PRO_SET_VALUE='cw_selectinterval_set_value' $ |
---|
| 166 | , /ROW, _extra = ex) |
---|
| 167 | if n_elements(vecteur) le 10 then begin |
---|
| 168 | nothing = CW_BGROUP(base, strtrim(vecteur,1),/nonexclusive,/row, uvalue = {name:'bgroup', vecteur:vecteur}, uname='bgroup') |
---|
| 169 | buttvalue=bytarr(n_elements(nothing)) |
---|
| 170 | buttvalue[0]=1 |
---|
| 171 | widget_control, nothing, set_value=buttvalue |
---|
| 172 | endif else begin |
---|
| 173 | min=min(floor(vecteur)) |
---|
| 174 | max=max(ceil(vecteur)) |
---|
| 175 | nothing=cw_slider_pm(base, value = min, min=min, max=max-1, uvalue = {name:'min', vecteur:vecteur}, uname='min') |
---|
| 176 | nothing=cw_slider_pm(base, value = max, min=min+1, max=max, uvalue = {name:'max'}, uname='max') |
---|
| 177 | endelse |
---|
| 178 | return, base |
---|
| 179 | end |
---|