[231] | 1 | ;+ |
---|
[157] | 2 | ; |
---|
| 3 | ; @file_comments |
---|
| 4 | ; |
---|
| 5 | ; @categories |
---|
| 6 | ; Compound widget |
---|
[226] | 7 | ; |
---|
[157] | 8 | ; @param ID |
---|
| 9 | ; |
---|
| 10 | ; @param VALUE |
---|
| 11 | ; It is the default tick mark value (a floating-point number). |
---|
| 12 | ; |
---|
| 13 | ; @returns |
---|
[226] | 14 | ; |
---|
[157] | 15 | ; @uses |
---|
[226] | 16 | ; |
---|
[157] | 17 | ; @restrictions |
---|
[226] | 18 | ; |
---|
[157] | 19 | ; @examples |
---|
[226] | 20 | ; |
---|
[157] | 21 | ; @history |
---|
[226] | 22 | ; |
---|
| 23 | ; @version |
---|
[157] | 24 | ; $Id$ |
---|
| 25 | ;- |
---|
[231] | 26 | ; |
---|
[2] | 27 | PRO cw_droplist_pm_set_value, id, value |
---|
[114] | 28 | ; |
---|
| 29 | compile_opt idl2, strictarrsubs |
---|
| 30 | ; |
---|
[2] | 31 | DroplistId = widget_info(id,find_by_uname = 'Droplist') |
---|
| 32 | if size(value, /type) eq 8 then BEGIN ; this is a structure |
---|
| 33 | tagnames = tag_names(value) |
---|
| 34 | for tag = 0, n_tags(value)-1 do begin |
---|
| 35 | case strtrim(strlowcase(tagnames[tag]), 2) of |
---|
| 36 | 'dynamic_resize':widget_control, DroplistId, dynamic_resize = value.dynamic_resize |
---|
| 37 | 'droplist_select':widget_control, DroplistId, set_droplist_select = value.droplist_select |
---|
| 38 | 'value':widget_control, DroplistId, set_value = value.value |
---|
| 39 | ELSE:ras = report('mauvais nom de l''argument de la structure ds cw_droplist_pm_set_value') |
---|
| 40 | endcase |
---|
| 41 | endfor |
---|
| 42 | ENDIF ELSE widget_control, DroplistId, set_value = value |
---|
| 43 | return |
---|
| 44 | end |
---|
[231] | 45 | ; |
---|
[157] | 46 | ;+ |
---|
[231] | 47 | ; |
---|
[157] | 48 | ; @file_comments |
---|
| 49 | ; Compound widget |
---|
| 50 | ; |
---|
| 51 | ; @categories |
---|
| 52 | ; Compound widget |
---|
[226] | 53 | ; |
---|
[157] | 54 | ; @param ID |
---|
| 55 | ; |
---|
| 56 | ; @returns |
---|
[226] | 57 | ; |
---|
[157] | 58 | ; @uses |
---|
[226] | 59 | ; |
---|
[157] | 60 | ; @restrictions |
---|
[226] | 61 | ; |
---|
[157] | 62 | ; @examples |
---|
[226] | 63 | ; |
---|
[157] | 64 | ; @history |
---|
[226] | 65 | ; |
---|
| 66 | ; @version |
---|
[157] | 67 | ; $Id$ |
---|
| 68 | ;- |
---|
[231] | 69 | ; |
---|
[2] | 70 | FUNCTION cw_droplist_pm_get_value, id |
---|
[114] | 71 | ; |
---|
| 72 | compile_opt idl2, strictarrsubs |
---|
| 73 | ; |
---|
[2] | 74 | DroplistId = widget_info(id,find_by_uname = 'Droplist') |
---|
| 75 | return, {droplist_number:widget_info(DroplistId, /droplist_number) $ |
---|
| 76 | , droplist_select:widget_info(DroplistId, /droplist_select) $ |
---|
| 77 | , dynamic_resize:widget_info(DroplistId, /dynamic_resize)} |
---|
| 78 | end |
---|
[231] | 79 | ; |
---|
[157] | 80 | ;+ |
---|
[231] | 81 | ; |
---|
[157] | 82 | ; @file_comments |
---|
| 83 | ; Compound widget |
---|
| 84 | ; |
---|
| 85 | ; @categories |
---|
| 86 | ; Compound widget |
---|
[226] | 87 | ; |
---|
[157] | 88 | ; @param EVENT |
---|
| 89 | ; |
---|
[226] | 90 | ; @returns |
---|
[157] | 91 | ; |
---|
| 92 | ; @uses |
---|
[226] | 93 | ; |
---|
[157] | 94 | ; @restrictions |
---|
[226] | 95 | ; |
---|
[157] | 96 | ; @examples |
---|
[226] | 97 | ; |
---|
[157] | 98 | ; @history |
---|
[226] | 99 | ; |
---|
| 100 | ; @version |
---|
[157] | 101 | ; $Id$ |
---|
| 102 | ;- |
---|
[231] | 103 | ; |
---|
[2] | 104 | FUNCTION cw_droplist_pm_event, event |
---|
[114] | 105 | ; |
---|
| 106 | compile_opt idl2, strictarrsubs |
---|
| 107 | ; |
---|
[2] | 108 | widget_control, event.id, get_uvalue=uval |
---|
| 109 | ; |
---|
| 110 | if uval EQ 'Droplist' then $ |
---|
| 111 | return, {CW_DROPLIST_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 112 | , INDEX:event.index, OUT:0} |
---|
| 113 | ; |
---|
| 114 | DroplistId = widget_info(event.handler,find_by_uname = 'Droplist') |
---|
| 115 | index = widget_info(DroplistId, /droplist_select) |
---|
| 116 | case uval OF |
---|
| 117 | 'plus':BEGIN |
---|
| 118 | indexmax = widget_info(DroplistId, /droplist_number)-1 |
---|
| 119 | if index NE indexmax then widget_control, DroplistId,set_droplist_select = index+1 |
---|
| 120 | return, {CW_DROPLIST_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 121 | , INDEX:(index+1) < indexmax, OUT:long(index EQ indexmax)} |
---|
| 122 | END |
---|
| 123 | 'minus':BEGIN |
---|
| 124 | if index NE 0 then widget_control, DroplistId,set_droplist_select = index-1 |
---|
| 125 | return, {CW_DROPLIST_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 126 | , INDEX:0 > (index-1), OUT:-long(index EQ 0)} |
---|
| 127 | END |
---|
| 128 | endcase |
---|
| 129 | end |
---|
[231] | 130 | ; |
---|
[150] | 131 | ;+ |
---|
| 132 | ; |
---|
| 133 | ; @file_comments |
---|
| 134 | ; Like WIDGET_DROPLIST but here, their are 2 buttons + and - to move the widget from +/- 1 |
---|
| 135 | ; |
---|
| 136 | ; @categories |
---|
[157] | 137 | ; Compound widget |
---|
[226] | 138 | ; |
---|
[150] | 139 | ; @param PARENT {in}{required} |
---|
| 140 | ; The widget ID of the parent widget. |
---|
| 141 | ; |
---|
| 142 | ; @keyword COLUMN |
---|
| 143 | ; Buttons will be arranged in the number of columns |
---|
| 144 | ; specified by this keyword. |
---|
[226] | 145 | ; |
---|
[150] | 146 | ; @keyword ROW |
---|
| 147 | ; Buttons will be arranged in the number of rows |
---|
| 148 | ; specified by this keyword. |
---|
[226] | 149 | ; |
---|
[150] | 150 | ; @keyword UVALUE |
---|
| 151 | ; The user value to be associated with the widget. |
---|
[226] | 152 | ; |
---|
[150] | 153 | ; @keyword UNAME |
---|
| 154 | ; The user name to be associated with the widget. |
---|
[226] | 155 | ; |
---|
[150] | 156 | ; @keyword _EXTRA |
---|
[231] | 157 | ; Used to pass keywords |
---|
[150] | 158 | ; |
---|
| 159 | ; @returns |
---|
| 160 | ; The returned value of this function is the widget ID of the |
---|
| 161 | ; newly-created animation widget. |
---|
| 162 | ; |
---|
| 163 | ; @restrictions |
---|
| 164 | ; |
---|
| 165 | ; Widget Events Returned by Droplist Widgets |
---|
| 166 | ; |
---|
| 167 | ; Pressing the mouse button while the mouse cursor is over an |
---|
| 168 | ; element of a droplist widget causes the widget to change the label |
---|
| 169 | ; on the droplist button and to generate an event. The appearance of |
---|
| 170 | ; any previously selected element is restored to normal at the same |
---|
| 171 | ; time. The event structure returned by the WIDGET_EVENT function is |
---|
| 172 | ; defined by the following statement: |
---|
| 173 | ; |
---|
| 174 | ; { CW_DROPLIST_PM, ID:0L, TOP:0L, HANDLER:0L, INDEX:0L, OUT:0 } |
---|
| 175 | ; |
---|
| 176 | ; The first three fields are the standard fields found in every |
---|
| 177 | ; widget event. |
---|
| 178 | ; INDEX returns the index of the selected item. This can be used to |
---|
| 179 | ; index the array of names originally used to set the widget''s |
---|
| 180 | ; value |
---|
[226] | 181 | ; OUT:It is an integer which can take 3 values: |
---|
[150] | 182 | ; 1 : If we press + when the index is already at the max |
---|
| 183 | ; Comment: In this case, the index stay at the max |
---|
| 184 | ; -1: If we press - when the index is already at the min |
---|
| 185 | ; Comment: In this case, the index stay at the min |
---|
| 186 | ; 0 : In other cases |
---|
| 187 | ; |
---|
| 188 | ; Keywords to WIDGET_CONTROL |
---|
| 189 | ; |
---|
| 190 | ; A number of keywords to the WIDGET_CONTROL procedure affect the |
---|
| 191 | ; behavior of cw_slider_pm widget: GET_VALUE and SET_VALUE. |
---|
| 192 | ; 1) GET_VALUE |
---|
| 193 | ; widget_control,wid_id,get_value=resultat |
---|
[226] | 194 | ; Send back, in the result variable, a structure of 3 elements whose |
---|
[150] | 195 | ; names are inspired by keywords we can pass at widget_control when |
---|
| 196 | ; we use WIDGET_COMBOBOX: |
---|
| 197 | ; DROPLIST_NUMBER: the number of elements currently |
---|
| 198 | ; contained in the specified droplist widget. |
---|
| 199 | ; DROPLIST_SELECT: the zero-based number of the |
---|
| 200 | ; currently-selected element (i.e., the currently-displayed |
---|
| 201 | ; element) in the specified droplist widget. |
---|
| 202 | ; DYNAMIC_RESIZE: a True value (1) if the widget specified |
---|
| 203 | ; by Widget_ID is a button, droplist, or label widget that |
---|
| 204 | ; has had its DYNAMIC_RESIZE attribute set. Otherwise, |
---|
| 205 | ; False (0) is returned. |
---|
| 206 | ; 2) SET_VALUE |
---|
| 207 | ; widget_control,wid_id,set_value=impose |
---|
| 208 | ; permet de modifier l''etat de la droplist comme on peut le faire |
---|
| 209 | ; pour WIDGET_DROPLIST Impose peut etre: |
---|
| 210 | ; a) The contents of the list widget (string or string array) |
---|
[226] | 211 | ; b) A structure which can have for elements (from 1 to 3): |
---|
[150] | 212 | ; DYNAMIC_RESIZE:Set this keyword to activate (if set to 1) |
---|
| 213 | ; or deactivate (if set to 0) dynamic resizing of the |
---|
| 214 | ; specified CW_DROPLIST_PM widget (see the documentation |
---|
| 215 | ; for the DYNAMIC_RESIZE keyword to WIDGET_DROPLIST |
---|
| 216 | ; procedure for more information about dynamic widget |
---|
| 217 | ; resizing). |
---|
| 218 | ; DROPLIST_SELECT:Set this keyword to return the zero-based |
---|
| 219 | ; number of the currently-selected element (i.e., the |
---|
| 220 | ; currently-displayed element) in the specified droplist |
---|
| 221 | ; widget. |
---|
| 222 | ; VALUE: The contents of the list widget (string or string |
---|
| 223 | ; array) |
---|
| 224 | ; |
---|
| 225 | ; @examples |
---|
| 226 | ; See the program provided above (testwid and the associated procedure, testwid_event). |
---|
| 227 | ; |
---|
| 228 | ; @history |
---|
[157] | 229 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[150] | 230 | ; 6/9/1999 |
---|
| 231 | ; |
---|
| 232 | ; @version |
---|
| 233 | ; $Id$ |
---|
| 234 | ; |
---|
| 235 | ;- |
---|
[231] | 236 | ; |
---|
[232] | 237 | FUNCTION cw_droplist_pm, parent,UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, _EXTRA = ex |
---|
[114] | 238 | ; |
---|
| 239 | compile_opt idl2, strictarrsubs |
---|
| 240 | ; |
---|
[2] | 241 | |
---|
[242] | 242 | IF (N_PARAMS() NE 1) THEN ras = report('Incorrect number of arguments') |
---|
[2] | 243 | ON_ERROR, 2 ;return to caller |
---|
[226] | 244 | ; checking for row and column keywords |
---|
| 245 | row = keyword_set(row)*(1-keyword_set(column)) |
---|
| 246 | column = keyword_set(column)*(1-keyword_set(row))+(keyword_set(column) EQ row) |
---|
[2] | 247 | if NOT keyword_set(uvalue) then uvalue = '' |
---|
| 248 | if NOT keyword_set(uname) then uname = '' |
---|
| 249 | ; |
---|
| 250 | base = widget_base(parent, space = 1, xpad = 1, ypad = 1, ROW = row, COLUMN = column $ |
---|
| 251 | , EVENT_FUNC = 'cw_droplist_pm_event' $ |
---|
| 252 | , FUNC_GET_VALUE='cw_droplist_pm_get_value' $ |
---|
| 253 | , PRO_SET_VALUE='cw_droplist_pm_set_value' $ |
---|
[226] | 254 | , UVALUE = uvalue, UNAME = uname, _extra = ex) |
---|
[2] | 255 | ; |
---|
| 256 | if keyword_set(row) THEN nothing = widget_button(base,value= '-', uvalue= 'minus') |
---|
| 257 | nothing = widget_droplist(base, UVALUE = 'Droplist', UNAME = 'Droplist', _extra = ex) |
---|
| 258 | if keyword_set(column) then begin |
---|
| 259 | base1 = widget_base(base, /row, /align_center, space = 1, xpad = 1, ypad = 1) |
---|
| 260 | nothing = widget_button(base1,value= '-', uvalue= 'minus', xsize = 20, ysize = 20) |
---|
| 261 | nothing = widget_button(base1,value= '+', uvalue= 'plus', xsize = 20, ysize = 20) |
---|
| 262 | ENDIF ELSE nothing = widget_button(base,value= '+', uvalue= 'plus') |
---|
| 263 | ; |
---|
| 264 | ; widget_control,base,/realize |
---|
| 265 | ; |
---|
| 266 | return, base |
---|
| 267 | end |
---|