[157] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[157] | 3 | ; @file_comments |
---|
| 4 | ; |
---|
| 5 | ; @categories |
---|
| 6 | ; Compound widget |
---|
| 7 | ; |
---|
| 8 | ; @param VALUE |
---|
| 9 | ; It is the default tick mark value (a floating-point number). |
---|
| 10 | ; |
---|
| 11 | ; @returns |
---|
[226] | 12 | ; |
---|
[157] | 13 | ; @uses |
---|
[226] | 14 | ; |
---|
[157] | 15 | ; @restrictions |
---|
[226] | 16 | ; |
---|
[157] | 17 | ; @examples |
---|
[226] | 18 | ; |
---|
[157] | 19 | ; @history |
---|
[226] | 20 | ; |
---|
| 21 | ; @version |
---|
[157] | 22 | ; $Id$ |
---|
[325] | 23 | ; |
---|
[157] | 24 | ;- |
---|
[69] | 25 | FUNCTION decvalue, value |
---|
[114] | 26 | ; |
---|
| 27 | compile_opt idl2, strictarrsubs |
---|
| 28 | ; |
---|
[69] | 29 | a = float(value[0]) |
---|
| 30 | return, strtrim(string(floor(a) + 0.1*indgen(10), format = '(f15.1)'), 2) |
---|
| 31 | end |
---|
[231] | 32 | ; |
---|
[157] | 33 | ;+ |
---|
[231] | 34 | ; |
---|
[157] | 35 | ; @file_comments |
---|
| 36 | ; |
---|
| 37 | ; @categories |
---|
| 38 | ; Compound widget |
---|
| 39 | ; |
---|
| 40 | ; @param VALUE |
---|
| 41 | ; It is the default tick mark value (a floating-point number). |
---|
| 42 | ; |
---|
| 43 | ; @returns |
---|
[226] | 44 | ; |
---|
[157] | 45 | ; @uses |
---|
[226] | 46 | ; |
---|
[157] | 47 | ; @restrictions |
---|
[226] | 48 | ; |
---|
[157] | 49 | ; @examples |
---|
[226] | 50 | ; |
---|
[157] | 51 | ; @history |
---|
[226] | 52 | ; |
---|
| 53 | ; @version |
---|
[157] | 54 | ; $Id$ |
---|
[325] | 55 | ; |
---|
[157] | 56 | ;- |
---|
[69] | 57 | FUNCTION decind, value |
---|
[114] | 58 | ; |
---|
| 59 | compile_opt idl2, strictarrsubs |
---|
| 60 | ; |
---|
[69] | 61 | a = float(value[0]) |
---|
| 62 | return, round(10*(a - floor(a))) ; !! computation accuracy |
---|
| 63 | end |
---|
[231] | 64 | ; |
---|
[157] | 65 | ;+ |
---|
[231] | 66 | ; |
---|
[157] | 67 | ; @file_comments |
---|
| 68 | ; |
---|
| 69 | ; @categories |
---|
| 70 | ; Compound widget |
---|
[226] | 71 | ; |
---|
[157] | 72 | ; @param ID |
---|
| 73 | ; |
---|
| 74 | ; @param VALUE |
---|
| 75 | ; It is the default tick mark value (a floating-point number). |
---|
| 76 | ; |
---|
| 77 | ; @returns |
---|
[226] | 78 | ; |
---|
[157] | 79 | ; @uses |
---|
[226] | 80 | ; |
---|
[157] | 81 | ; @restrictions |
---|
[226] | 82 | ; |
---|
[157] | 83 | ; @examples |
---|
[226] | 84 | ; |
---|
[157] | 85 | ; @history |
---|
[226] | 86 | ; |
---|
| 87 | ; @version |
---|
[157] | 88 | ; $Id$ |
---|
[325] | 89 | ; |
---|
[157] | 90 | ;- |
---|
[2] | 91 | PRO cw_slider_pm_set_value, id, value |
---|
[114] | 92 | ; |
---|
| 93 | compile_opt idl2, strictarrsubs |
---|
| 94 | ; |
---|
[69] | 95 | sbid = widget_info(id, find_by_uname = 'SliderBar') |
---|
| 96 | dcid = widget_info(id, find_by_uname = 'decimal') |
---|
| 97 | minmax = widget_info(sbid, /SLIDER_MIN_MAX) |
---|
| 98 | if size(value, /type) eq 8 then BEGIN ; this is a structure |
---|
| 99 | tagnames = tag_names(value) |
---|
| 100 | for tag = 0, n_tags(value)-1 do begin |
---|
| 101 | case strtrim(strlowcase(tagnames[tag]), 2) of |
---|
| 102 | 'slider_min':BEGIN |
---|
[226] | 103 | ; IF float(value.slider_min[0]) LT minmax[1] THEN BEGIN |
---|
[69] | 104 | minmax[0] = value.slider_min[0] |
---|
| 105 | widget_control, sbid, set_slider_min = floor(float(value.slider_min[0])) |
---|
| 106 | valuedc = float(widget_info(dcid, /combobox_gettext)) |
---|
| 107 | IF valuedc LT value.slider_min THEN BEGIN |
---|
| 108 | widget_control, sbid, set_value = floor(float(value.slider_min[0])) |
---|
| 109 | widget_control, dcid, set_value = decvalue(value.slider_min) |
---|
| 110 | widget_control, dcid, set_combobox_select = decind(value.slider_min) |
---|
[226] | 111 | ENDIF |
---|
| 112 | ; ENDIF |
---|
[69] | 113 | end |
---|
| 114 | 'slider_max':BEGIN |
---|
[226] | 115 | ; IF float(value.slider_max[0]) GT minmax[0] THEN BEGIN |
---|
[69] | 116 | minmax[1] = value.slider_max[0] |
---|
| 117 | widget_control, sbid, set_slider_max = ceil(float(value.slider_max[0])) |
---|
| 118 | valuedc = float(widget_info(dcid, /combobox_gettext)) |
---|
| 119 | IF valuedc GT value.slider_max THEN BEGIN |
---|
| 120 | widget_control, sbid, set_value = ceil(float(value.slider_max[0])) |
---|
| 121 | widget_control, dcid, set_value = decvalue(value.slider_max) |
---|
| 122 | widget_control, dcid, set_combobox_select = decind(value.slider_max) |
---|
[226] | 123 | ENDIF |
---|
| 124 | ; ENDIF |
---|
[69] | 125 | end |
---|
| 126 | 'value':IF float(value.value[0]) GE minmax[0] $ |
---|
| 127 | AND float(value.value[0]) LE minmax[1] THEN value2 = float(value.value[0]) |
---|
| 128 | ELSE:ras = report('wrong tag name in argument "value" of cw_slider_pm_set_value') |
---|
| 129 | endcase |
---|
| 130 | endfor |
---|
[226] | 131 | ENDIF ELSE BEGIN |
---|
[69] | 132 | IF float(value[0]) GE minmax[0] $ |
---|
| 133 | AND float(value[0]) LE minmax[1] THEN value2 = float(value[0]) |
---|
| 134 | ENDELSE |
---|
[226] | 135 | IF n_elements(value2) NE 0 THEN BEGIN |
---|
[69] | 136 | widget_control, sbid, set_value = fix(value2) |
---|
| 137 | widget_control, dcid, set_value = decvalue(value2) |
---|
| 138 | widget_control, dcid, set_combobox_select = decind(value2) |
---|
[226] | 139 | ENDIF |
---|
[69] | 140 | return |
---|
[2] | 141 | end |
---|
[231] | 142 | ; |
---|
[157] | 143 | ;+ |
---|
[231] | 144 | ; |
---|
[157] | 145 | ; @file_comments |
---|
| 146 | ; |
---|
| 147 | ; |
---|
| 148 | ; @categories |
---|
[226] | 149 | ; Compound widget |
---|
| 150 | ; |
---|
[157] | 151 | ; @param ID |
---|
| 152 | ; |
---|
[226] | 153 | ; @returns |
---|
[157] | 154 | ; |
---|
| 155 | ; @uses |
---|
[226] | 156 | ; |
---|
[157] | 157 | ; @restrictions |
---|
[226] | 158 | ; |
---|
[157] | 159 | ; @examples |
---|
[226] | 160 | ; |
---|
[157] | 161 | ; @history |
---|
[226] | 162 | ; |
---|
| 163 | ; @version |
---|
[157] | 164 | ; $Id$ |
---|
[325] | 165 | ; |
---|
[157] | 166 | ;- |
---|
[2] | 167 | FUNCTION cw_slider_pm_get_value, id |
---|
[114] | 168 | ; |
---|
| 169 | compile_opt idl2, strictarrsubs |
---|
| 170 | ; |
---|
[69] | 171 | sbid = widget_info(id, find_by_uname = 'SliderBar') |
---|
| 172 | dcid = widget_info(id, find_by_uname = 'decimal') |
---|
| 173 | minmax = widget_info(sbid, /SLIDER_MIN_MAX) |
---|
| 174 | value = float(widget_info(dcid, /combobox_gettext)) |
---|
| 175 | return, {value:value, slider_min_max:minmax} |
---|
[2] | 176 | end |
---|
[231] | 177 | ; |
---|
[157] | 178 | ;+ |
---|
[231] | 179 | ; |
---|
[157] | 180 | ; @file_comments |
---|
| 181 | ; |
---|
| 182 | ; @categories |
---|
| 183 | ; Compound widget |
---|
[226] | 184 | ; |
---|
[157] | 185 | ; @param EVENT |
---|
| 186 | ; |
---|
| 187 | ; @returns |
---|
[226] | 188 | ; |
---|
[157] | 189 | ; @uses |
---|
[226] | 190 | ; |
---|
[157] | 191 | ; @restrictions |
---|
[226] | 192 | ; |
---|
[157] | 193 | ; @examples |
---|
[226] | 194 | ; |
---|
[157] | 195 | ; @history |
---|
[226] | 196 | ; |
---|
| 197 | ; @version |
---|
[157] | 198 | ; $Id$ |
---|
[325] | 199 | ; |
---|
[157] | 200 | ;- |
---|
[2] | 201 | FUNCTION cw_slider_pm_event, event |
---|
[114] | 202 | ; |
---|
| 203 | compile_opt idl2, strictarrsubs |
---|
| 204 | ; |
---|
[69] | 205 | widget_control, event.id, get_uvalue = uval |
---|
[2] | 206 | ; |
---|
[69] | 207 | sbid = widget_info(event.handler, find_by_uname = 'SliderBar') |
---|
| 208 | dcid = widget_info(event.handler, find_by_uname = 'decimal') |
---|
| 209 | minmax = widget_info(sbid, /SLIDER_MIN_MAX) |
---|
| 210 | IF uval EQ 'decimal' THEN value = float(event.str) $ |
---|
| 211 | ELSE value = float(widget_info(dcid, /combobox_gettext)) |
---|
| 212 | out = 0 ; defaut case |
---|
| 213 | case uval OF |
---|
| 214 | 'plus': if (value + 1) LE minmax[1] then value2 = value + 1 ELSE out = 1 |
---|
| 215 | 'minus':if (value - 1) GE minmax[0] then value2 = value - 1 ELSE out = -1 |
---|
| 216 | 'SliderBar':if (event.value + value - floor(value)) LE minmax[1] THEN value2 = event.value + value - floor(value) |
---|
[226] | 217 | 'decimal':BEGIN |
---|
[69] | 218 | CASE 1 OF |
---|
| 219 | value GT minmax[1]: value2 = minmax[1] |
---|
| 220 | value LT minmax[0]: value2 = minmax[0] |
---|
| 221 | ELSE: |
---|
| 222 | ENDCASE |
---|
| 223 | END |
---|
| 224 | ELSE: |
---|
| 225 | ENDCASE |
---|
| 226 | IF n_elements(value2) NE 0 THEN BEGIN |
---|
| 227 | value = value2 |
---|
| 228 | widget_control, sbid, set_value = floor(value) |
---|
| 229 | widget_control, dcid, set_value = decvalue(value) |
---|
| 230 | widget_control, dcid, set_combobox_select = decind(value) |
---|
| 231 | ENDIF |
---|
| 232 | return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 233 | , VALUE:value, OUT:OUT} |
---|
[2] | 234 | end |
---|
[231] | 235 | ; |
---|
[150] | 236 | ;+ |
---|
| 237 | ; |
---|
| 238 | ; @file_comments |
---|
[295] | 239 | ; Like WIDGET_SLIDER but here, there are 2 buttons + and - to move the widget from +/- 1 |
---|
[150] | 240 | ; |
---|
| 241 | ; @categories |
---|
[157] | 242 | ; Compound widget |
---|
[226] | 243 | ; |
---|
[150] | 244 | ; @param PARENT {in}{required} |
---|
| 245 | ; The widget ID of the parent widget. |
---|
| 246 | ; |
---|
| 247 | ; @keyword UVALUE |
---|
| 248 | ; The user value to be associated with the widget. |
---|
[226] | 249 | ; |
---|
[150] | 250 | ; @keyword UNAME |
---|
| 251 | ; The user name to be associated with the widget. |
---|
[226] | 252 | ; |
---|
[150] | 253 | ; @keyword VALUE |
---|
| 254 | ; |
---|
[226] | 255 | ; @keyword MAXIMUM |
---|
[150] | 256 | ; |
---|
| 257 | ; @keyword MINIMUM |
---|
| 258 | ; |
---|
| 259 | ; @keyword STRMINLEN |
---|
| 260 | ; |
---|
| 261 | ; @keyword _EXTRA |
---|
[231] | 262 | ; Used to pass keywords |
---|
[150] | 263 | ; |
---|
| 264 | ; @returns |
---|
| 265 | ; The returned value of this function is the widget ID of the |
---|
| 266 | ; newly-created animation widget. |
---|
| 267 | ; |
---|
| 268 | ; @restrictions |
---|
| 269 | ; |
---|
| 270 | ; Widget Events Returned by the CW_SLIDER_PM Widget |
---|
| 271 | ; |
---|
| 272 | ; Slider widgets generate events when the mouse is used to change |
---|
| 273 | ; their value. The event structure returned by the WIDGET_EVENT |
---|
| 274 | ; function is defined by the following statement: |
---|
| 275 | ; |
---|
| 276 | ; {CW_SLIDER_PM, ID:0L, TOP:0L, HANDLER:0L, VALUE:0L, DRAG:0, OUT:0} |
---|
| 277 | ; |
---|
| 278 | ; ID is the widget ID of the button generating the event. TOP is the |
---|
| 279 | ; widget ID of the top level widget containing ID. |
---|
| 280 | ; HANDLER contains the widget ID of the widget associated with the |
---|
| 281 | ; handler routine. |
---|
| 282 | ; VALUE returns the new value of the slider. |
---|
| 283 | ; DRAG returns integer 1 if the slider event was generated as part of |
---|
| 284 | ; a drag operation, or zero if the event was generated when the user |
---|
| 285 | ; had finished positioning the slider. Note that the slider widget |
---|
| 286 | ; only generates events during the drag operation if the DRAG keyword |
---|
| 287 | ; is set, and if the application is running under Motif. When the |
---|
| 288 | ; DRAG keyword is set, the DRAG field can be used to avoid |
---|
| 289 | ; computationally expensive operations until the user releases the |
---|
| 290 | ; slider. |
---|
[226] | 291 | ; OUT:It is an integer which can take 3 values: |
---|
[150] | 292 | ; 1 : If we press + when the index is already at the max |
---|
| 293 | ; Comment: In this case, the index stay at the max |
---|
| 294 | ; -1: If we press - when the index is already at the min |
---|
| 295 | ; Comment: In this case, the index stay at the min |
---|
| 296 | ; 0 : In other cases |
---|
| 297 | ; |
---|
| 298 | ; Keywords to WIDGET_CONTROL |
---|
| 299 | ; |
---|
| 300 | ; A number of keywords to the WIDGET_CONTROL procedure affect the |
---|
| 301 | ; behavior of cw_slider_pm widget: GET_VALUE and SET_VALUE. |
---|
| 302 | ; 1) GET_VALUE |
---|
| 303 | ; widget_control,wid_id,get_value=resultat |
---|
[226] | 304 | ; Send back in the result variable a structure of 2 elements whose name |
---|
| 305 | ; are inspired from keywords we can pass at |
---|
[163] | 306 | ; widget_control when we use WIDGET_SLIDER: |
---|
[150] | 307 | ; VALUE:the value setting of the widget |
---|
| 308 | ; SLIDER_MIN_MAX: a 2 elements array: The minimum and the |
---|
| 309 | ; maximum value of the range encompassed by the slider |
---|
| 310 | ; 2) SET_VALUE |
---|
| 311 | ; widget_control,wid_id,set_value=impose |
---|
[226] | 312 | ; Allows to modify the state of the combobox like we can do it for |
---|
| 313 | ; WIDGET_COMBOBOX. May impose: |
---|
[163] | 314 | ; a) a integer: give the new position of the slider. |
---|
[226] | 315 | ; b) A structure which can have for elements (from 1 to 3): |
---|
[150] | 316 | ; VALUE: an integer which give the new position of the slider |
---|
| 317 | ; SLIDER_MIN:Set to a new minimum value for the specified |
---|
| 318 | ; slider widget. |
---|
| 319 | ; SLIDER_MAX:Set to a new minimum value for the specified |
---|
| 320 | ; slider widget. |
---|
| 321 | ; |
---|
| 322 | ; |
---|
| 323 | ; @examples |
---|
| 324 | ; See the program provided above (testwid and the associated procedure, testwid_event). |
---|
| 325 | ; |
---|
| 326 | ; @history |
---|
[157] | 327 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[150] | 328 | ; 5/9/1999 |
---|
| 329 | ; |
---|
| 330 | ; @version |
---|
| 331 | ; $Id$ |
---|
| 332 | ; |
---|
| 333 | ; @todo |
---|
| 334 | ; seb: documenter |
---|
| 335 | ; |
---|
| 336 | ;- |
---|
[69] | 337 | FUNCTION cw_slider_pm, parent, MAXIMUM = maximum, MINIMUM = minimum $ |
---|
| 338 | , STRMINLEN = strminlen, VALUE = value, UVALUE = uvalue $ |
---|
[262] | 339 | , UNAME = uname, TITLE = title, _EXTRA = ex |
---|
[114] | 340 | ; |
---|
| 341 | compile_opt idl2, strictarrsubs |
---|
| 342 | ; |
---|
[2] | 343 | |
---|
[242] | 344 | IF (N_PARAMS() NE 1) THEN ras = report('Incorrect number of arguments') |
---|
[69] | 345 | ON_ERROR, 2 ;return to caller |
---|
[2] | 346 | ; |
---|
[69] | 347 | if n_elements(minimum) NE 0 then minimum = floor(minimum) ELSE minimum = 0 |
---|
| 348 | if n_elements(maximum) NE 0 then maximum = ceil(maximum) ELSE maximum = 100 |
---|
| 349 | if NOT keyword_set(title) then title = ' ' |
---|
| 350 | ; |
---|
[226] | 351 | ; checking exclusive keywords |
---|
[69] | 352 | column = (keyword_set(column)*(1-keyword_set(row))+keyword_set(vertical)) < 1 |
---|
[226] | 353 | row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column) |
---|
[69] | 354 | if NOT keyword_set(uvalue) then uvalue = '' |
---|
| 355 | if NOT keyword_set(uname) then uname = '' |
---|
| 356 | base = widget_base(parent $ |
---|
| 357 | , EVENT_FUNC = 'cw_slider_pm_event' $ |
---|
| 358 | , FUNC_GET_VALUE = 'cw_slider_pm_get_value' $ |
---|
| 359 | , PRO_SET_VALUE = 'cw_slider_pm_set_value' $ |
---|
[226] | 360 | , space = 0, UVALUE = uvalue, UNAME = uname, _extra = ex) |
---|
[2] | 361 | ; |
---|
[69] | 362 | mlen = (widget_info(base, string_size = 'm'))[0] |
---|
| 363 | |
---|
| 364 | xsize = mlen*strlen(title) |
---|
| 365 | dummyid = widget_label(base, value = title, xsize = xsize) |
---|
| 366 | dummyid = widget_button(base, value = '-', uvalue = 'minus' $ |
---|
| 367 | , yoffset = 15, xsize = 15, ysize = 15) |
---|
| 368 | dummyid = widget_button(base, value = '+', uvalue = 'plus' $ |
---|
| 369 | , xoffset = 15, yoffset = 15, xsize = 15, ysize = 15) |
---|
| 370 | xoff = 30 > xsize |
---|
| 371 | lenstr = max(strlen(strtrim([minimum, maximum], 1))) |
---|
| 372 | if keyword_set(strminlen) then lenstr = strminlen > lenstr |
---|
| 373 | ; xsize = 35 + mlen*(lenstr+1)+3*(lenstr lt 4) |
---|
| 374 | xsize = 35 + mlen*(lenstr+2) |
---|
| 375 | dummyid = widget_combobox(base, value = decvalue(minimum) $ |
---|
| 376 | , UVALUE = 'decimal', UNAME = 'decimal' $ |
---|
| 377 | , xoffset = xoff, yoffset = 2, xsize = xsize) |
---|
| 378 | |
---|
| 379 | dummyid = widget_slider(base, MAXIMUM = maximum, MINIMUM = minimum, UVALUE = 'SliderBar' $ |
---|
| 380 | , UNAME = 'SliderBar', /suppress_value, /drag $ |
---|
| 381 | , yoffset = 30, xsize = xoff + xsize) |
---|
[2] | 382 | ; |
---|
[69] | 383 | if keyword_set(value) then cw_slider_pm_set_value, base, value |
---|
[2] | 384 | ; |
---|
[69] | 385 | return, base |
---|
[2] | 386 | end |
---|