[157] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[157] | 3 | ; @file_comments |
---|
| 4 | ; |
---|
| 5 | ; @categories |
---|
| 6 | ; Compound widget |
---|
[231] | 7 | ; |
---|
[157] | 8 | ; @param ID |
---|
| 9 | ; |
---|
| 10 | ; @param VALUE |
---|
| 11 | ; It is the default tick mark value (a floating-point number). |
---|
| 12 | ; |
---|
| 13 | ; @returns |
---|
[231] | 14 | ; |
---|
[157] | 15 | ; @uses |
---|
[231] | 16 | ; |
---|
[157] | 17 | ; @restrictions |
---|
[231] | 18 | ; |
---|
[157] | 19 | ; @examples |
---|
[231] | 20 | ; |
---|
[157] | 21 | ; @history |
---|
[231] | 22 | ; |
---|
| 23 | ; @version |
---|
[157] | 24 | ; $Id$ |
---|
[325] | 25 | ; |
---|
[157] | 26 | ;- |
---|
[231] | 27 | PRO cw_bgroup_setv, id, value |
---|
[242] | 28 | ; |
---|
[114] | 29 | compile_opt hidden, idl2, strictarrsubs |
---|
[242] | 30 | ; |
---|
[69] | 31 | ON_ERROR, 2 ;return to caller |
---|
[2] | 32 | |
---|
| 33 | stash = WIDGET_INFO(id, /CHILD) |
---|
| 34 | WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY |
---|
| 35 | |
---|
| 36 | case state.type of |
---|
| 37 | 0: message,'unable to set plain button group value' |
---|
| 38 | 1: begin |
---|
[69] | 39 | WIDGET_CONTROL, SET_BUTTON=0, state.ids[state.excl_pos] |
---|
| 40 | state.excl_pos = value |
---|
| 41 | WIDGET_CONTROL, /SET_BUTTON, state.ids[value] |
---|
| 42 | end |
---|
[2] | 43 | 2: begin |
---|
[69] | 44 | n = n_elements(value)-1 |
---|
| 45 | for i = 0, n do begin |
---|
| 46 | state.nonexcl_curpos[i] = value[i] |
---|
| 47 | WIDGET_CONTROL, state.ids[i], SET_BUTTON=value[i] |
---|
| 48 | endfor |
---|
| 49 | end |
---|
[2] | 50 | endcase |
---|
| 51 | |
---|
| 52 | WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY |
---|
| 53 | end |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | |
---|
[157] | 57 | ;+ |
---|
| 58 | ; @file_comments |
---|
| 59 | ; Compound widget |
---|
| 60 | ; |
---|
| 61 | ; @categories |
---|
| 62 | ; |
---|
| 63 | ; @param ID |
---|
| 64 | ; |
---|
| 65 | ; |
---|
| 66 | ; @param VALUE |
---|
| 67 | ; It is the default tick mark value (a floating-point number). |
---|
| 68 | ; |
---|
| 69 | ; @returns |
---|
[231] | 70 | ; |
---|
[157] | 71 | ; @uses |
---|
[231] | 72 | ; |
---|
[157] | 73 | ; @restrictions |
---|
[231] | 74 | ; |
---|
[157] | 75 | ; @examples |
---|
[231] | 76 | ; |
---|
[157] | 77 | ; @history |
---|
[231] | 78 | ; |
---|
| 79 | ; @version |
---|
[157] | 80 | ; $Id$ |
---|
[325] | 81 | ; |
---|
[157] | 82 | ;- |
---|
[262] | 83 | FUNCTION cw_bgroup_getv, id, value |
---|
| 84 | ; |
---|
[114] | 85 | compile_opt hidden, idl2, strictarrsubs |
---|
[262] | 86 | ; |
---|
[69] | 87 | ON_ERROR, 2 ;return to caller |
---|
[2] | 88 | |
---|
[69] | 89 | stash = WIDGET_INFO(id, /CHILD) |
---|
| 90 | WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY |
---|
[2] | 91 | |
---|
[69] | 92 | case state.type of |
---|
| 93 | 0: message, 'unable to get plain button group value' |
---|
[2] | 94 | ; 1: ret = state.excl_pos |
---|
[69] | 95 | 1: ret = state.ret_arr[state.excl_pos] |
---|
[2] | 96 | ; 2: ret = state.nonexcl_curpos |
---|
[231] | 97 | 2: BEGIN |
---|
[69] | 98 | index = where(state.nonexcl_curpos NE 0) |
---|
| 99 | if index[0] EQ -1 then begin |
---|
| 100 | if size(state.ret_arr, /type) EQ 7 then ret = '' ELSE ret = -1 |
---|
| 101 | ENDIF ELSE ret = state.ret_arr[index] |
---|
| 102 | END |
---|
| 103 | endcase |
---|
[231] | 104 | |
---|
[69] | 105 | WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY |
---|
[2] | 106 | |
---|
[69] | 107 | return, ret |
---|
[2] | 108 | |
---|
| 109 | end |
---|
[231] | 110 | ; |
---|
[157] | 111 | ;+ |
---|
[231] | 112 | ; |
---|
[157] | 113 | ; @file_comments |
---|
| 114 | ; Compound widget |
---|
| 115 | ; |
---|
| 116 | ; @categories |
---|
| 117 | ; |
---|
| 118 | ; @param EV |
---|
| 119 | ; |
---|
[231] | 120 | ; @returns |
---|
[157] | 121 | ; |
---|
| 122 | ; @uses |
---|
[231] | 123 | ; |
---|
[157] | 124 | ; @restrictions |
---|
[231] | 125 | ; |
---|
[157] | 126 | ; @examples |
---|
[231] | 127 | ; |
---|
[157] | 128 | ; @history |
---|
[231] | 129 | ; |
---|
| 130 | ; @version |
---|
[157] | 131 | ; $Id$ |
---|
[325] | 132 | ; |
---|
[157] | 133 | ;- |
---|
[262] | 134 | FUNCTION cw_bgroup_event, ev |
---|
| 135 | ; |
---|
[114] | 136 | compile_opt hidden, idl2, strictarrsubs |
---|
[262] | 137 | ; |
---|
[2] | 138 | WIDGET_CONTROL, ev.handler, GET_UVALUE=stash |
---|
| 139 | WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY |
---|
| 140 | WIDGET_CONTROL, ev.id, get_uvalue=uvalue |
---|
| 141 | |
---|
[69] | 142 | ret = 1 ;Assume we return a struct |
---|
[2] | 143 | case state.type of |
---|
| 144 | 0: |
---|
| 145 | 1: if (ev.select eq 1) then begin |
---|
[69] | 146 | state.excl_pos = uvalue |
---|
| 147 | ENDIF else begin |
---|
| 148 | if (state.no_release ne 0) then ret = 0 |
---|
| 149 | ENDELSE |
---|
[2] | 150 | 2: begin |
---|
[69] | 151 | ; Keep track of the current state |
---|
| 152 | state.nonexcl_curpos[uvalue] = ev.select |
---|
[2] | 153 | if (state.no_release ne 0) and (ev.select eq 0) then ret = 0 |
---|
[69] | 154 | end |
---|
[2] | 155 | endcase |
---|
| 156 | |
---|
[69] | 157 | if ret then begin ;Return a struct? |
---|
[2] | 158 | ret = { ID:state.base, TOP:ev.top, HANDLER:0L, SELECT:ev.select, $ |
---|
[69] | 159 | VALUE:state.ret_arr[uvalue] } |
---|
[2] | 160 | efun = state.efun |
---|
| 161 | WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY |
---|
| 162 | if efun ne '' then return, CALL_FUNCTION(efun, ret) $ |
---|
| 163 | else return, ret |
---|
[69] | 164 | endif else begin ;Trash the event |
---|
[2] | 165 | WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY |
---|
| 166 | return, 0 |
---|
| 167 | endelse |
---|
| 168 | end |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | |
---|
[150] | 173 | ; |
---|
| 174 | ;+ |
---|
| 175 | ; @file_comments |
---|
| 176 | ; CW_BGROUP is a compound widget that simplifies creating |
---|
| 177 | ; a base of buttons. It handles the details of creating the |
---|
| 178 | ; proper base (standard, exclusive, or non-exclusive) and filling |
---|
| 179 | ; in the desired buttons. Events for the individual buttons are |
---|
| 180 | ; handled transparently, and a CW_BGROUP event returned. This |
---|
| 181 | ; event can return any one of the following: |
---|
| 182 | ; - The Index of the button within the base. |
---|
| 183 | ; - The widget ID of the button. |
---|
| 184 | ; - The name of the button. |
---|
| 185 | ; - An arbitrary value taken from an array of User values. |
---|
| 186 | ; |
---|
| 187 | ; @categories |
---|
[157] | 188 | ; Compound widget |
---|
[150] | 189 | ; |
---|
| 190 | ; @param PARENT {in}{required} |
---|
| 191 | ; The ID of the parent widget. |
---|
[231] | 192 | ; |
---|
[163] | 193 | ; @param NAMES {type=string array} |
---|
[150] | 194 | ; A string array, containing one string per button, |
---|
| 195 | ; giving the name of each button. |
---|
| 196 | ; |
---|
[163] | 197 | ; @keyword BUTTON_UVALUE {type=array} |
---|
[150] | 198 | ; An array of user values to be associated with |
---|
| 199 | ; each button and returned in the event structure. |
---|
[231] | 200 | ; |
---|
[150] | 201 | ; @keyword COLUMN |
---|
| 202 | ; Buttons will be arranged in the number of columns |
---|
| 203 | ; specified by this keyword. |
---|
[231] | 204 | ; |
---|
[150] | 205 | ; @keyword EVENT_FUNCT |
---|
| 206 | ; The name of an optional user-supplied event function |
---|
| 207 | ; for buttons. This function is called with the return |
---|
| 208 | ; value structure whenever a button is pressed, and |
---|
| 209 | ; follows the conventions for user-written event functions. |
---|
[231] | 210 | ; |
---|
[150] | 211 | ; @keyword EXCLUSIVE |
---|
| 212 | ; Buttons will be placed in an exclusive base, with |
---|
| 213 | ; only one button allowed to be selected at a time. |
---|
[231] | 214 | ; |
---|
[150] | 215 | ; @keyword FONT |
---|
| 216 | ; The name of the font to be used for the button |
---|
| 217 | ; titles. If this keyword is not specified, the default |
---|
| 218 | ; font is used. |
---|
[231] | 219 | ; |
---|
[150] | 220 | ; @keyword FRAME |
---|
| 221 | ; Specifies the width of the frame to be drawn around the base. |
---|
[231] | 222 | ; |
---|
[150] | 223 | ; @keyword IDS |
---|
| 224 | ; A named variable into which the button IDs will be |
---|
| 225 | ; stored, as a longword vector. |
---|
[231] | 226 | ; |
---|
[150] | 227 | ; @keyword LABEL_LEFT |
---|
| 228 | ; Creates a text label to the left of the buttons. |
---|
[231] | 229 | ; |
---|
[150] | 230 | ; @keyword LABEL_TOP |
---|
| 231 | ; Creates a text label above the buttons. |
---|
[231] | 232 | ; |
---|
[150] | 233 | ; @keyword MAP |
---|
| 234 | ; If set, the base will be mapped when the widget |
---|
| 235 | ; is realized (the default). |
---|
[231] | 236 | ; |
---|
[150] | 237 | ; @keyword NONEXCLUSIVE |
---|
| 238 | ; Buttons will be placed in an non-exclusive base. |
---|
| 239 | ; The buttons will be independent. |
---|
[231] | 240 | ; |
---|
[150] | 241 | ; @keyword NO_RELEASE |
---|
| 242 | ; If set, button release events will not be returned. |
---|
[231] | 243 | ; |
---|
[150] | 244 | ; @keyword RETURN_ID |
---|
| 245 | ; If set, the VALUE field of returned events will be |
---|
| 246 | ; the widget ID of the button. |
---|
[231] | 247 | ; |
---|
[150] | 248 | ; @keyword RETURN_INDEX |
---|
| 249 | ; If set, the VALUE field of returned events will be |
---|
| 250 | ; the zero-based index of the button within the base. |
---|
| 251 | ; THIS IS THE DEFAULT. |
---|
[231] | 252 | ; |
---|
[150] | 253 | ; @keyword RETURN_NAME |
---|
| 254 | ; If set, the VALUE field of returned events will be |
---|
| 255 | ; the name of the button within the base. |
---|
[231] | 256 | ; |
---|
[150] | 257 | ; @keyword ROW |
---|
| 258 | ; Buttons will be arranged in the number of rows |
---|
| 259 | ; specified by this keyword. |
---|
[231] | 260 | ; |
---|
[150] | 261 | ; @keyword SCROLL |
---|
| 262 | ; If set, the base will include scroll bars to allow |
---|
| 263 | ; viewing a large base through a smaller viewport. |
---|
[231] | 264 | ; |
---|
[150] | 265 | ; @keyword SET_VALUE |
---|
| 266 | ; The initial value of the buttons. This is equivalent |
---|
| 267 | ; to the later statement: |
---|
| 268 | ; |
---|
| 269 | ; WIDGET_CONTROL, widget, set_value=value |
---|
| 270 | ; |
---|
| 271 | ; @keyword SPACE |
---|
| 272 | ; The space, in pixels, to be left around the edges |
---|
| 273 | ; of a row or column major base. This keyword is |
---|
| 274 | ; ignored if EXCLUSIVE or NONEXCLUSIVE are specified. |
---|
[231] | 275 | ; |
---|
[150] | 276 | ; @keyword UVALUE |
---|
| 277 | ; The user value to be associated with the widget. |
---|
[231] | 278 | ; |
---|
[150] | 279 | ; @keyword UNAME |
---|
| 280 | ; The user name to be associated with the widget. |
---|
[231] | 281 | ; |
---|
[150] | 282 | ; @keyword XOFFSET |
---|
| 283 | ; The X offset of the widget relative to its parent. |
---|
[231] | 284 | ; |
---|
[150] | 285 | ; @keyword XPAD |
---|
| 286 | ; The horizontal space, in pixels, between children |
---|
| 287 | ; of a row or column major base. Ignored if EXCLUSIVE |
---|
| 288 | ; or NONEXCLUSIVE are specified. |
---|
[231] | 289 | ; |
---|
[150] | 290 | ; @keyword XSIZE |
---|
| 291 | ; The width of the base. |
---|
| 292 | ; @keyword X_SCROLL_SIZE |
---|
| 293 | ; The width of the viewport if SCROLL is specified. |
---|
[231] | 294 | ; |
---|
[150] | 295 | ; @keyword YOFFSET |
---|
| 296 | ; The Y offset of the widget relative to its parent. |
---|
[231] | 297 | ; |
---|
[150] | 298 | ; @keyword YPAD |
---|
| 299 | ; The vertical space, in pixels, between children of |
---|
| 300 | ; a row or column major base. Ignored if EXCLUSIVE |
---|
| 301 | ; or NONEXCLUSIVE are specified. |
---|
[231] | 302 | ; |
---|
[150] | 303 | ; @keyword YSIZE |
---|
| 304 | ; The height of the base. |
---|
[231] | 305 | ; |
---|
[150] | 306 | ; @keyword Y_SCROLL_SIZE |
---|
| 307 | ; The height of the viewport if SCROLL is specified. |
---|
| 308 | ; |
---|
| 309 | ; @returns |
---|
| 310 | ; The ID of the created widget is returned. |
---|
| 311 | ; |
---|
| 312 | ; @restrictions |
---|
| 313 | ; This widget generates event structures with the following definition: |
---|
| 314 | ; |
---|
| 315 | ; event = { ID:0L, TOP:0L, HANDLER:0L, SELECT:0, VALUE:0 } |
---|
| 316 | ; |
---|
| 317 | ; The SELECT field is passed through from the button event. VALUE is |
---|
| 318 | ; either the INDEX, ID, NAME, or BUTTON_UVALUE of the button, |
---|
| 319 | ; depending on how the widget was created. |
---|
| 320 | ; |
---|
| 321 | ; @restrictions |
---|
| 322 | ; Only buttons with textual names are handled by this widget. |
---|
| 323 | ; Bitmaps are not understood. |
---|
| 324 | ; |
---|
| 325 | ; @history |
---|
| 326 | ; 15 June 1992, AB |
---|
| 327 | ; 7 April 1993, AB, Removed state caching. |
---|
| 328 | ; 6 Oct. 1994, KDB, Font keyword is not applied to the label. |
---|
| 329 | ; 10 FEB 1995, DJC fixed bad bug in event procedure, getting |
---|
| 330 | ; id of stash widget. |
---|
| 331 | ; 11 April 1995, AB Removed Motif special cases. |
---|
| 332 | ; |
---|
| 333 | ; Copyright (c) 1992-2005, Research Systems, Inc. All rights reserved. |
---|
| 334 | ; Unauthorized reproduction prohibited. |
---|
| 335 | ; |
---|
| 336 | ; @version |
---|
| 337 | ; $Id$ |
---|
| 338 | ; |
---|
| 339 | ;- |
---|
[262] | 340 | FUNCTION cw_bgroup, parent, names, $ |
---|
[69] | 341 | BUTTON_UVALUE = button_uvalue, COLUMN=column, EVENT_FUNCT = efun, $ |
---|
| 342 | EXCLUSIVE=excl, FONT=font, FRAME=frame, IDS=ids, LABEL_TOP=label_top, $ |
---|
| 343 | LABEL_LEFT=label_left, MAP=map, $ |
---|
| 344 | NONEXCLUSIVE=nonexcl, NO_RELEASE=no_release, RETURN_ID=return_id, $ |
---|
| 345 | RETURN_INDEX=return_index, RETURN_NAME=return_name, $ |
---|
| 346 | ROW=row, SCROLL=scroll, SET_VALUE=sval, SPACE=space, $ |
---|
| 347 | TAB_MODE=tab_mode, UVALUE=uvalue, $ |
---|
| 348 | XOFFSET=xoffset, XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size,$ |
---|
| 349 | YOFFSET=yoffset, YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ |
---|
| 350 | UNAME=uname |
---|
[262] | 351 | ; |
---|
| 352 | compile_opt hidden, idl2, strictarrsubs |
---|
| 353 | ; |
---|
[242] | 354 | IF (N_PARAMS() ne 2) THEN ras = report('Incorrect number of arguments') |
---|
[2] | 355 | |
---|
[69] | 356 | ON_ERROR, 2 ;return to caller |
---|
[2] | 357 | |
---|
| 358 | ; Set default values for the keywords |
---|
| 359 | version = WIDGET_INFO(/version) |
---|
| 360 | if (version.toolkit eq 'OLIT') then def_space_pad = 4 else def_space_pad = 3 |
---|
[69] | 361 | IF (N_ELEMENTS(column) eq 0) then column = 0 |
---|
| 362 | IF (N_ELEMENTS(excl) eq 0) then excl = 0 |
---|
| 363 | IF (N_ELEMENTS(frame) eq 0) then frame = 0 |
---|
| 364 | IF (N_ELEMENTS(map) eq 0) then map=1 |
---|
| 365 | IF (N_ELEMENTS(nonexcl) eq 0) then nonexcl = 0 |
---|
| 366 | IF (N_ELEMENTS(no_release) eq 0) then no_release = 0 |
---|
| 367 | IF (N_ELEMENTS(row) eq 0) then row = 0 |
---|
| 368 | IF (N_ELEMENTS(scroll) eq 0) then scroll = 0 |
---|
| 369 | IF (N_ELEMENTS(space) eq 0) then space = def_space_pad |
---|
| 370 | IF (N_ELEMENTS(uname) eq 0) then uname = 'CW_BGROUP_UNAME' |
---|
| 371 | IF (N_ELEMENTS(uvalue) eq 0) then uvalue = 0 |
---|
| 372 | IF (N_ELEMENTS(xoffset) eq 0) then xoffset=0 |
---|
| 373 | IF (N_ELEMENTS(xpad) eq 0) then xpad = def_space_pad |
---|
| 374 | IF (N_ELEMENTS(xsize) eq 0) then xsize = 0 |
---|
| 375 | IF (N_ELEMENTS(x_scroll_size) eq 0) then x_scroll_size = 0 |
---|
| 376 | IF (N_ELEMENTS(yoffset) eq 0) then yoffset=0 |
---|
| 377 | IF (N_ELEMENTS(ypad) eq 0) then ypad = def_space_pad |
---|
| 378 | IF (N_ELEMENTS(ysize) eq 0) then ysize = 0 |
---|
| 379 | IF (N_ELEMENTS(y_scroll_size) eq 0) then y_scroll_size = 0 |
---|
[2] | 380 | |
---|
| 381 | |
---|
| 382 | |
---|
[69] | 383 | |
---|
[2] | 384 | top_base = 0L |
---|
| 385 | if (n_elements(label_top) ne 0) then begin |
---|
[69] | 386 | next_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, /COLUMN) |
---|
[2] | 387 | if(keyword_set(font))then $ |
---|
| 388 | junk = WIDGET_LABEL(next_base, value=label_top,font=font) $ |
---|
| 389 | else junk = WIDGET_LABEL(next_base, value=label_top) |
---|
| 390 | top_base = next_base |
---|
| 391 | endif else next_base = parent |
---|
[69] | 392 | |
---|
[2] | 393 | if (n_elements(label_left) ne 0) then begin |
---|
[69] | 394 | next_base = WIDGET_BASE(next_base, XOFFSET=xoffset, YOFFSET=yoffset, /ROW) |
---|
[2] | 395 | if(keyword_set(font))then $ |
---|
| 396 | junk = WIDGET_LABEL(next_base, value=label_left, font=font) $ |
---|
| 397 | else junk = WIDGET_LABEL(next_base, value=label_left) |
---|
| 398 | if (top_base eq 0L) then top_base = next_base |
---|
| 399 | endif |
---|
| 400 | ; We need some kind of outer base to hold the users UVALUE |
---|
| 401 | if (top_base eq 0L) then begin |
---|
[69] | 402 | top_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset) |
---|
[2] | 403 | next_base = top_base |
---|
| 404 | endif |
---|
| 405 | If (top_base EQ next_base) THEN $ |
---|
[69] | 406 | next_base = WIDGET_BASE(top_base, Xpad=1, Ypad=1, Space=1) |
---|
[2] | 407 | |
---|
| 408 | ; Set top level base attributes |
---|
| 409 | WIDGET_CONTROL, top_base, MAP=map, $ |
---|
[69] | 410 | FUNC_GET_VALUE='CW_BGROUP_GETV', PRO_SET_VALUE='CW_BGROUP_SETV', $ |
---|
| 411 | SET_UVALUE=uvalue, SET_UNAME=uname |
---|
[2] | 412 | |
---|
[69] | 413 | ; Tabbing |
---|
| 414 | if (n_elements(tab_mode) ne 0) then begin |
---|
| 415 | WIDGET_CONTROL, top_base, TAB_MODE=tab_mode |
---|
| 416 | WIDGET_CONTROL, next_base, TAB_MODE=tab_mode |
---|
| 417 | end |
---|
| 418 | |
---|
[2] | 419 | ; The actual button holding base |
---|
| 420 | base = WIDGET_BASE(next_base, COLUMN=column, EXCLUSIVE=excl, FRAME=frame, $ |
---|
[69] | 421 | NONEXCLUSIVE=nonexcl, ROW=row, SCROLL=scroll, SPACE=space, $ |
---|
| 422 | XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size, $ |
---|
| 423 | YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ |
---|
| 424 | EVENT_FUNC='CW_BGROUP_EVENT', $ |
---|
| 425 | UVALUE=WIDGET_INFO(top_base, /child)) |
---|
[2] | 426 | |
---|
| 427 | |
---|
| 428 | n = n_elements(names) |
---|
| 429 | ids = lonarr(n) |
---|
| 430 | for i = 0, n-1 do begin |
---|
| 431 | if (n_elements(font) eq 0) then begin |
---|
[69] | 432 | ids[i] = WIDGET_BUTTON(base, value=names[i], UVALUE=i, $ |
---|
| 433 | UNAME=uname+'_BUTTON'+STRTRIM(i,2)) |
---|
[2] | 434 | endif else begin |
---|
[69] | 435 | ids[i] = WIDGET_BUTTON(base, value=names[i], FONT=font, $ |
---|
| 436 | UVALUE=i, UNAME=uname+'_BUTTON'+STRTRIM(i,2)) |
---|
[2] | 437 | endelse |
---|
| 438 | endfor |
---|
| 439 | |
---|
| 440 | ; Keep the state info in the real (inner) base UVALUE. |
---|
| 441 | ; Pick an event value type: |
---|
[69] | 442 | ; 0 - Return ID |
---|
| 443 | ; 1 - Return INDEX |
---|
| 444 | ; 2 - Return NAME |
---|
[2] | 445 | ret_type = 1 |
---|
| 446 | if KEYWORD_SET(RETURN_ID) then ret_type = 0 |
---|
| 447 | if KEYWORD_SET(RETURN_NAME) then ret_type = 2 |
---|
| 448 | if KEYWORD_SET(BUTTON_UVALUE) then ret_type = 3 |
---|
| 449 | case ret_type of |
---|
| 450 | 0: ret_arr = ids |
---|
| 451 | 1: ret_arr = indgen(n) |
---|
| 452 | 2: ret_arr = names |
---|
| 453 | 3: ret_arr = button_uvalue |
---|
| 454 | endcase |
---|
| 455 | type = 0 |
---|
| 456 | if (excl ne 0) then type = 1 |
---|
| 457 | |
---|
| 458 | if (nonexcl ne 0) then type = 2 |
---|
| 459 | if n_elements(efun) le 0 then efun = '' |
---|
[69] | 460 | state = { type:type, $ ; 0-Standard, 1-Exclusive, 2-Non-exclusive |
---|
| 461 | base: top_base, $ ; cw_bgroup base... |
---|
| 462 | ret_arr:ret_arr, $ ; Vector of event values |
---|
| 463 | efun : efun, $ ; Name of event fcn |
---|
| 464 | nonexcl_curpos:intarr(n), $ ; If non-exclus, tracks state |
---|
| 465 | excl_pos:0, $ ; If exclusive, current button |
---|
| 466 | ids:ids, $ ; Ids of buttons |
---|
| 467 | no_release:no_release } |
---|
[2] | 468 | WIDGET_CONTROL, WIDGET_INFO(top_base, /CHILD), SET_UVALUE=state, /NO_COPY |
---|
| 469 | |
---|
| 470 | if (n_elements(sval) ne 0) then CW_BGROUP_SETV, top_base, sval |
---|
| 471 | |
---|
| 472 | return, top_base |
---|
| 473 | END |
---|