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