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