[69] | 1 | ; testwid, value=strtrim(indgen(10),2) |
---|
| 2 | ; PRO testwid_event, event |
---|
| 3 | ; ; help, event, /STRUCT |
---|
| 4 | ; ComboboxId = widget_info(event.top,find_by_uname = 'c''est lui') |
---|
| 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 | ; 'dynamic_resize':BEGIN |
---|
| 10 | ; widget_control, event.id, get_value = value |
---|
| 11 | ; widget_control, ComboboxId, set_value = {dynamic_resize:value} |
---|
| 12 | ; END |
---|
| 13 | ; 'combobox_select':BEGIN |
---|
| 14 | ; widget_control, event.id, get_value = value |
---|
| 15 | ; widget_control, ComboboxId, set_value = {combobox_select:value} |
---|
| 16 | ; END |
---|
| 17 | ; 'value':BEGIN |
---|
| 18 | ; widget_control, event.id, get_value = value |
---|
| 19 | ; widget_control, ComboboxId, set_value = value |
---|
| 20 | ; END |
---|
| 21 | ; 'get':BEGIN |
---|
| 22 | ; widget_control, ComboboxId, get_value = value |
---|
| 23 | ; help, value, /struct |
---|
| 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_combobox_pm(base, _extra = ex, uname = 'c''est lui', uvalue = 'c''est lui') |
---|
| 35 | ; print, 'cw_combobox_pm ID =', nothing |
---|
| 36 | ; ; |
---|
| 37 | ; nothing = widget_label(base, value = 'end of the test') |
---|
| 38 | ; nothing = widget_text(base, value = '0', uvalue = 'dynamic_resize', /editable) |
---|
| 39 | ; nothing = widget_text(base, value = '10', uvalue = 'combobox_select', /editable) |
---|
| 40 | ; nothing = widget_text(base, value = '5', uvalue = '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 |
---|
| 47 | ;---------------------------------------------------------------------- |
---|
[157] | 48 | ;+ |
---|
| 49 | ; @file_comments |
---|
| 50 | ; |
---|
| 51 | ; |
---|
| 52 | ; @categories |
---|
| 53 | ; Compound widget |
---|
| 54 | ; |
---|
| 55 | ; @param ID |
---|
| 56 | ; |
---|
| 57 | ; |
---|
| 58 | ; @param VALUE |
---|
| 59 | ; It is the default tick mark value (a floating-point number). |
---|
| 60 | ; |
---|
| 61 | ; @returns |
---|
| 62 | ; |
---|
| 63 | ; |
---|
| 64 | ; @uses |
---|
| 65 | ; |
---|
| 66 | ; |
---|
| 67 | ; @restrictions |
---|
| 68 | ; |
---|
| 69 | ; |
---|
| 70 | ; @examples |
---|
| 71 | ; |
---|
| 72 | ; |
---|
| 73 | ; @history |
---|
| 74 | ; |
---|
| 75 | ; |
---|
| 76 | ; @version |
---|
| 77 | ; $Id$ |
---|
| 78 | ;- |
---|
[69] | 79 | PRO cw_combobox_pm_set_value, id, value |
---|
[114] | 80 | ; |
---|
| 81 | compile_opt idl2, strictarrsubs |
---|
| 82 | ; |
---|
[69] | 83 | ComboboxId = widget_info(id,find_by_uname = 'Combobox') |
---|
| 84 | if size(value, /type) eq 8 then BEGIN ; this is a structure |
---|
| 85 | tagnames = tag_names(value) |
---|
| 86 | for tag = 0, n_tags(value)-1 do begin |
---|
| 87 | case strtrim(strlowcase(tagnames[tag]), 2) of |
---|
| 88 | 'dynamic_resize':widget_control, ComboboxId, dynamic_resize = value.dynamic_resize |
---|
| 89 | ; for compatibility |
---|
| 90 | 'droplist_select':widget_control, ComboboxId, set_combobox_select = value.droplist_select |
---|
| 91 | 'combobox_select':widget_control, ComboboxId, set_combobox_select = value.combobox_select |
---|
| 92 | 'value':widget_control, ComboboxId, set_value = value.value |
---|
| 93 | ELSE:ras = report('wrong tag name in argument "value" of cw_combobox_pm_set_value') |
---|
| 94 | endcase |
---|
| 95 | endfor |
---|
| 96 | ENDIF ELSE widget_control, ComboboxId, set_value = value |
---|
| 97 | return |
---|
| 98 | end |
---|
| 99 | ;---------------------------------------------------------------------- |
---|
[157] | 100 | ;+ |
---|
| 101 | ; @file_comments |
---|
| 102 | ; |
---|
| 103 | ; |
---|
| 104 | ; @categories |
---|
| 105 | ; Compound widget |
---|
| 106 | ; |
---|
| 107 | ; @param ID |
---|
| 108 | ; |
---|
| 109 | ; |
---|
| 110 | ; @returns |
---|
| 111 | ; |
---|
| 112 | ; |
---|
| 113 | ; @uses |
---|
| 114 | ; |
---|
| 115 | ; |
---|
| 116 | ; @restrictions |
---|
| 117 | ; |
---|
| 118 | ; |
---|
| 119 | ; @examples |
---|
| 120 | ; |
---|
| 121 | ; |
---|
| 122 | ; @history |
---|
| 123 | ; |
---|
| 124 | ; |
---|
| 125 | ; @version |
---|
| 126 | ; $Id$ |
---|
| 127 | ;- |
---|
[69] | 128 | FUNCTION cw_combobox_pm_get_value, id |
---|
[114] | 129 | ; |
---|
| 130 | compile_opt idl2, strictarrsubs |
---|
| 131 | ; |
---|
[69] | 132 | ComboboxId = widget_info(id,find_by_uname = 'Combobox') |
---|
| 133 | widget_control, ComboboxId, get_value = cmbbval |
---|
| 134 | cmbbtxt = widget_info(ComboboxId, /combobox_gettext) |
---|
| 135 | cmbbnumb = widget_info(ComboboxId, /combobox_number) |
---|
| 136 | index = (where(cmbbval EQ cmbbtxt))[0] |
---|
| 137 | return, {combobox_number:cmbbnumb, combobox_gettext:cmbbtxt $ |
---|
| 138 | , combobox_index:index, combobox_value:cmbbval $ |
---|
| 139 | , dynamic_resize:widget_info(ComboboxId, /dynamic_resize)} |
---|
| 140 | end |
---|
| 141 | ;---------------------------------------------------------------------- |
---|
[157] | 142 | ;---------------------------------------------------------------------- |
---|
| 143 | ;+ |
---|
| 144 | ; @file_comments |
---|
| 145 | ; |
---|
| 146 | ; |
---|
| 147 | ; @categories |
---|
| 148 | ; Compound widget |
---|
| 149 | ; |
---|
| 150 | ; @param EVENT |
---|
| 151 | ; |
---|
| 152 | ; |
---|
| 153 | ; @returns |
---|
| 154 | ; |
---|
| 155 | ; |
---|
| 156 | ; @uses |
---|
| 157 | ; |
---|
| 158 | ; |
---|
| 159 | ; @restrictions |
---|
| 160 | ; |
---|
| 161 | ; |
---|
| 162 | ; @examples |
---|
| 163 | ; |
---|
| 164 | ; |
---|
| 165 | ; @history |
---|
| 166 | ; |
---|
| 167 | ; |
---|
| 168 | ; @version |
---|
| 169 | ; $Id$ |
---|
| 170 | ;- |
---|
[69] | 171 | FUNCTION cw_combobox_pm_event, event |
---|
[114] | 172 | ; |
---|
| 173 | compile_opt idl2, strictarrsubs |
---|
| 174 | ; |
---|
[69] | 175 | widget_control, event.id, get_uvalue=uval |
---|
| 176 | ; |
---|
| 177 | if uval EQ 'Combobox' then $ |
---|
| 178 | return, {CW_COMBOBOX_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 179 | , INDEX:event.index, STR:event.str, OUT:0} |
---|
| 180 | ; |
---|
| 181 | ComboboxId = widget_info(event.handler,find_by_uname = 'Combobox') |
---|
| 182 | widget_control, ComboboxId, get_value = cmbbval |
---|
| 183 | cmbbtxt = widget_info(ComboboxId, /combobox_gettext) |
---|
| 184 | cmbbnumb = widget_info(ComboboxId, /combobox_number) |
---|
| 185 | index = (where(cmbbval EQ cmbbtxt))[0] |
---|
| 186 | out = 0 |
---|
| 187 | case uval OF |
---|
| 188 | 'plus':BEGIN |
---|
| 189 | if index LT (cmbbnumb - 1) then BEGIN |
---|
| 190 | index = index + 1 |
---|
| 191 | widget_control, ComboboxId, set_combobox_select = index |
---|
| 192 | ENDIF ELSE out = 1 |
---|
| 193 | END |
---|
| 194 | 'minus':BEGIN |
---|
| 195 | if index GT 0 then BEGIN |
---|
| 196 | index = index - 1 |
---|
| 197 | widget_control, ComboboxId, set_combobox_select = index |
---|
| 198 | ENDIF ELSE out = -1 |
---|
| 199 | END |
---|
| 200 | endcase |
---|
| 201 | return, {CW_COMBOBOX_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 202 | , INDEX:index, STR:cmbbtxt, OUT:out} |
---|
| 203 | end |
---|
[150] | 204 | ;------------------------------------------------------------ |
---|
| 205 | ;------------------------------------------------------------ |
---|
| 206 | ;------------------------------------------------------------ |
---|
| 207 | ;+ |
---|
| 208 | ; |
---|
| 209 | ; @file_comments |
---|
| 210 | ; Like WIDGET_COMBOBOX but here, their are 2 buttons + and - to move the widget from +/- 1 |
---|
| 211 | ; |
---|
| 212 | ; @categories |
---|
[157] | 213 | ; Compound widget |
---|
[150] | 214 | ; |
---|
| 215 | ; @param PARENT {in}{required} |
---|
| 216 | ; The widget ID of the parent widget. |
---|
| 217 | ; |
---|
| 218 | ; @keyword COLUMN |
---|
| 219 | ; Buttons will be arranged in the number of columns |
---|
| 220 | ; specified by this keyword. |
---|
| 221 | ; |
---|
| 222 | ; @keyword ROW |
---|
| 223 | ; Buttons will be arranged in the number of rows |
---|
| 224 | ; specified by this keyword. |
---|
| 225 | ; |
---|
| 226 | ; @keyword UVALUE |
---|
| 227 | ; The user value to be associated with the widget. |
---|
| 228 | ; |
---|
| 229 | ; @keyword UNAME |
---|
| 230 | ; The user name to be associated with the widget. |
---|
| 231 | ; |
---|
| 232 | ; @keyword VALUE |
---|
| 233 | ; |
---|
| 234 | ; |
---|
| 235 | ; @keyword _EXTRA |
---|
| 236 | ; Used to pass your keywords |
---|
| 237 | ; |
---|
| 238 | ; @returns |
---|
| 239 | ; The returned value of this function is the widget ID of the |
---|
| 240 | ; newly-created animation widget. |
---|
| 241 | ; |
---|
| 242 | ; @restrictions |
---|
| 243 | ; |
---|
| 244 | ; Widget Events Returned by Combobox Widgets |
---|
| 245 | ; |
---|
| 246 | ; Pressing the mouse button while the mouse cursor is over an |
---|
| 247 | ; element of a combobox widget causes the widget to change the label |
---|
| 248 | ; on the combobox button and to generate an event. The appearance of |
---|
| 249 | ; any previously selected element is restored to normal at the same |
---|
| 250 | ; time. The event structure returned by the WIDGET_EVENT function is |
---|
| 251 | ; defined by the following statement: |
---|
| 252 | ; |
---|
| 253 | ; { CW_COMBOBOX_PM, ID:0L, TOP:0L, HANDLER:0L, INDEX:0L, OUT:0 } |
---|
| 254 | ; |
---|
| 255 | ; The first three fields are the standard fields found in every |
---|
| 256 | ; widget event. |
---|
| 257 | ; INDEX returns the index of the selected item. This can be used to |
---|
| 258 | ; index the array of names originally used to set the widget''s |
---|
| 259 | ; value |
---|
| 260 | ; OUT:It is an integer which can take 3 values: |
---|
| 261 | ; 1 : If we press + when the index is already at the max |
---|
| 262 | ; Comment: In this case, the index stay at the max |
---|
| 263 | ; -1: If we press - when the index is already at the min |
---|
| 264 | ; Comment: In this case, the index stay at the min |
---|
| 265 | ; 0 : In other cases |
---|
| 266 | ; |
---|
| 267 | ; Keywords to WIDGET_CONTROL |
---|
| 268 | ; |
---|
| 269 | ; A number of keywords to the WIDGET_CONTROL procedure affect the |
---|
| 270 | ; behavior of cw_slider_pm widget: GET_VALUE and SET_VALUE. |
---|
| 271 | ; 1) GET_VALUE |
---|
| 272 | ; widget_control,wid_id,get_value=resultat |
---|
| 273 | ; Send back, in the result variable, a structure of 3 elements whose |
---|
| 274 | ; names are inspired by keywords we can pass at widget_control when |
---|
| 275 | ; we use WIDGET_COMBOBOX: |
---|
| 276 | ; COMBOBOX_NUMBER: the number of elements currently |
---|
| 277 | ; contained in the specified combobox widget. |
---|
| 278 | ; COMBOBOX_SELECT: the zero-based number of the |
---|
| 279 | ; currently-selected element (i.e., the currently-displayed |
---|
| 280 | ; element) in the specified combobox widget. |
---|
| 281 | ; DYNAMIC_RESIZE: a True value (1) if the widget specified |
---|
| 282 | ; by Widget_ID is a button, combobox, or label widget that |
---|
| 283 | ; has had its DYNAMIC_RESIZE attribute set. Otherwise, |
---|
| 284 | ; False (0) is returned. |
---|
| 285 | ; 2) SET_VALUE |
---|
| 286 | ; widget_control,wid_id,set_value=impose |
---|
| 287 | ; Allows to modify the state of the combobox like we can do it for |
---|
| 288 | ; WIDGET_COMBOBOX. May impose: |
---|
| 289 | ; a) The contents of the list widget (string or string array) |
---|
| 290 | ; b) A structure which can have for elements (from 1 to 3): |
---|
| 291 | ; DYNAMIC_RESIZE:Set this keyword to activate (if set to 1) |
---|
| 292 | ; or deactivate (if set to 0) dynamic resizing of the |
---|
| 293 | ; specified CW_COMBOBOX_PM widget (see the documentation |
---|
| 294 | ; for the DYNAMIC_RESIZE keyword to WIDGET_COMBOBOX |
---|
| 295 | ; procedure for more information about dynamic widget |
---|
| 296 | ; resizing). |
---|
| 297 | ; COMBOBOX_SELECT:Set this keyword to return the zero-based |
---|
| 298 | ; number of the currently-selected element (i.e., the |
---|
| 299 | ; currently-displayed element) in the specified combobox |
---|
| 300 | ; widget. |
---|
| 301 | ; VALUE: The contents of the list widget (string or string |
---|
| 302 | ; array) |
---|
| 303 | ; |
---|
| 304 | ; @examples |
---|
| 305 | ; See the program provided above (testwid and the associated procedure, testwid_event). |
---|
| 306 | ; |
---|
| 307 | ; @history |
---|
[157] | 308 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[150] | 309 | ; 6/9/1999 |
---|
| 310 | ; |
---|
| 311 | ; @version |
---|
| 312 | ; $Id$ |
---|
| 313 | ; |
---|
| 314 | ;- |
---|
| 315 | ;------------------------------------------------------------ |
---|
| 316 | ;------------------------------------------------------------ |
---|
| 317 | ;------------------------------------------------------------ |
---|
[69] | 318 | FUNCTION cw_combobox_pm, parent, VALUE = value, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, _extra = ex |
---|
[114] | 319 | ; |
---|
| 320 | compile_opt idl2, strictarrsubs |
---|
| 321 | ; |
---|
[69] | 322 | |
---|
| 323 | IF (N_PARAMS() NE 1) THEN MESSAGE, 'Incorrect number of arguments' |
---|
| 324 | ON_ERROR, 2 ;return to caller |
---|
| 325 | ; cheking for row and column keywords |
---|
| 326 | row = keyword_set(row)*(1-keyword_set(column)) |
---|
| 327 | column = keyword_set(column)*(1-keyword_set(row))+(keyword_set(column) EQ row) |
---|
| 328 | if NOT keyword_set(uvalue) then uvalue = '' |
---|
| 329 | if NOT keyword_set(uname) then uname = '' |
---|
| 330 | ; |
---|
| 331 | base = widget_base(parent, space = 0 $ |
---|
| 332 | , EVENT_FUNC = 'cw_combobox_pm_event' $ |
---|
| 333 | , FUNC_GET_VALUE='cw_combobox_pm_get_value' $ |
---|
| 334 | , PRO_SET_VALUE='cw_combobox_pm_set_value' $ |
---|
| 335 | , UVALUE = uvalue, UNAME = uname, _extra = ex) |
---|
| 336 | ; |
---|
| 337 | vallen = widget_info(base, string_size = 'm') |
---|
| 338 | vallen = 35 + (vallen[0]-1)*max(strlen(value)) |
---|
| 339 | if keyword_set(row) THEN BEGIN |
---|
| 340 | nothing = widget_button(base, value = '-', uvalue = 'minus', xoffset = 0 $ |
---|
| 341 | , yoffset = 5, xsize = 15, ysize = 15) |
---|
| 342 | nothing = widget_combobox(base, VALUE = value, UVALUE = 'Combobox', UNAME = 'Combobox' $ |
---|
| 343 | , xoffset = 13, yoffset = 0, xsize = vallen) |
---|
| 344 | nothing = widget_button(base, value = '+', uvalue = 'plus' $ |
---|
| 345 | , xoffset = vallen+11, yoffset = 5 $ |
---|
| 346 | , xsize = 15, ysize = 15) |
---|
| 347 | ENDIF ELSE BEGIN |
---|
| 348 | nothing = widget_combobox(base, VALUE = value, UVALUE = 'Combobox', UNAME = 'Combobox' $ |
---|
| 349 | , xoffset = 0, yoffset = 0, xsize = vallen) |
---|
| 350 | nothing = widget_button(base, value = '-', uvalue = 'minus' $ |
---|
| 351 | , xoffset = vallen/2-15 $ |
---|
| 352 | , yoffset = 24, xsize = 15, ysize = 15) |
---|
| 353 | nothing = widget_button(base, value = '+', uvalue = 'plus' $ |
---|
| 354 | , xoffset = vallen/2 $ |
---|
| 355 | , yoffset = 24, xsize = 15, ysize = 15) |
---|
| 356 | ENDELSE |
---|
| 357 | ; |
---|
| 358 | ; widget_control,base,/realize |
---|
| 359 | ; |
---|
| 360 | return, base |
---|
| 361 | end |
---|