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