1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; |
---|
5 | ; @categories |
---|
6 | ; Compound widget |
---|
7 | ; |
---|
8 | ; @param ID |
---|
9 | ; |
---|
10 | ; @param VALUE |
---|
11 | ; It is the default tick mark value (a floating-point number). |
---|
12 | ; |
---|
13 | ; @returns |
---|
14 | ; |
---|
15 | ; @uses |
---|
16 | ; |
---|
17 | ; @restrictions |
---|
18 | ; |
---|
19 | ; @examples |
---|
20 | ; |
---|
21 | ; @history |
---|
22 | ; |
---|
23 | ; @version |
---|
24 | ; $Id$ |
---|
25 | ; |
---|
26 | ;- |
---|
27 | PRO cw_droplist_pm_set_value, id, value |
---|
28 | ; |
---|
29 | compile_opt idl2, strictarrsubs |
---|
30 | ; |
---|
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 |
---|
45 | ; |
---|
46 | ;+ |
---|
47 | ; |
---|
48 | ; @file_comments |
---|
49 | ; Compound widget |
---|
50 | ; |
---|
51 | ; @categories |
---|
52 | ; Compound widget |
---|
53 | ; |
---|
54 | ; @param ID |
---|
55 | ; |
---|
56 | ; @returns |
---|
57 | ; |
---|
58 | ; @uses |
---|
59 | ; |
---|
60 | ; @restrictions |
---|
61 | ; |
---|
62 | ; @examples |
---|
63 | ; |
---|
64 | ; @history |
---|
65 | ; |
---|
66 | ; @version |
---|
67 | ; $Id$ |
---|
68 | ; |
---|
69 | ;- |
---|
70 | FUNCTION cw_droplist_pm_get_value, id |
---|
71 | ; |
---|
72 | compile_opt idl2, strictarrsubs |
---|
73 | ; |
---|
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 |
---|
79 | ; |
---|
80 | ;+ |
---|
81 | ; |
---|
82 | ; @file_comments |
---|
83 | ; Compound widget |
---|
84 | ; |
---|
85 | ; @categories |
---|
86 | ; Compound widget |
---|
87 | ; |
---|
88 | ; @param EVENT |
---|
89 | ; |
---|
90 | ; @returns |
---|
91 | ; |
---|
92 | ; @uses |
---|
93 | ; |
---|
94 | ; @restrictions |
---|
95 | ; |
---|
96 | ; @examples |
---|
97 | ; |
---|
98 | ; @history |
---|
99 | ; |
---|
100 | ; @version |
---|
101 | ; $Id$ |
---|
102 | ; |
---|
103 | ;- |
---|
104 | FUNCTION cw_droplist_pm_event, event |
---|
105 | ; |
---|
106 | compile_opt idl2, strictarrsubs |
---|
107 | ; |
---|
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 |
---|
130 | ; |
---|
131 | ;+ |
---|
132 | ; |
---|
133 | ; @file_comments |
---|
134 | ; Like WIDGET_DROPLIST but here, there are 2 buttons + and - to move the widget from +/- 1 |
---|
135 | ; |
---|
136 | ; @categories |
---|
137 | ; Compound widget |
---|
138 | ; |
---|
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. |
---|
145 | ; |
---|
146 | ; @keyword ROW |
---|
147 | ; Buttons will be arranged in the number of rows |
---|
148 | ; specified by this keyword. |
---|
149 | ; |
---|
150 | ; @keyword UVALUE |
---|
151 | ; The user value to be associated with the widget. |
---|
152 | ; |
---|
153 | ; @keyword UNAME |
---|
154 | ; The user name to be associated with the widget. |
---|
155 | ; |
---|
156 | ; @keyword _EXTRA |
---|
157 | ; Used to pass keywords |
---|
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 |
---|
181 | ; OUT:It is an integer which can take 3 values: |
---|
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 |
---|
194 | ; Send back, in the result variable, a structure of 3 elements whose |
---|
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) |
---|
211 | ; b) A structure which can have for elements (from 1 to 3): |
---|
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 |
---|
229 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
230 | ; 6/9/1999 |
---|
231 | ; |
---|
232 | ; @version |
---|
233 | ; $Id$ |
---|
234 | ; |
---|
235 | ;- |
---|
236 | FUNCTION cw_droplist_pm, parent,UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, _EXTRA = ex |
---|
237 | ; |
---|
238 | compile_opt idl2, strictarrsubs |
---|
239 | ; |
---|
240 | |
---|
241 | IF (N_PARAMS() NE 1) THEN ras = report('Incorrect number of arguments') |
---|
242 | ON_ERROR, 2 ;return to caller |
---|
243 | ; checking for row and column keywords |
---|
244 | row = keyword_set(row)*(1-keyword_set(column)) |
---|
245 | column = keyword_set(column)*(1-keyword_set(row))+(keyword_set(column) EQ row) |
---|
246 | if NOT keyword_set(uvalue) then uvalue = '' |
---|
247 | if NOT keyword_set(uname) then uname = '' |
---|
248 | ; |
---|
249 | base = widget_base(parent, space = 1, xpad = 1, ypad = 1, ROW = row, COLUMN = column $ |
---|
250 | , EVENT_FUNC = 'cw_droplist_pm_event' $ |
---|
251 | , FUNC_GET_VALUE='cw_droplist_pm_get_value' $ |
---|
252 | , PRO_SET_VALUE='cw_droplist_pm_set_value' $ |
---|
253 | , UVALUE = uvalue, UNAME = uname, _extra = ex) |
---|
254 | ; |
---|
255 | if keyword_set(row) THEN nothing = widget_button(base,value= '-', uvalue= 'minus') |
---|
256 | nothing = widget_droplist(base, UVALUE = 'Droplist', UNAME = 'Droplist', _extra = ex) |
---|
257 | if keyword_set(column) then begin |
---|
258 | base1 = widget_base(base, /row, /align_center, space = 1, xpad = 1, ypad = 1) |
---|
259 | nothing = widget_button(base1,value= '-', uvalue= 'minus', xsize = 20, ysize = 20) |
---|
260 | nothing = widget_button(base1,value= '+', uvalue= 'plus', xsize = 20, ysize = 20) |
---|
261 | ENDIF ELSE nothing = widget_button(base,value= '+', uvalue= 'plus') |
---|
262 | ; |
---|
263 | ; widget_control,base,/realize |
---|
264 | ; |
---|
265 | return, base |
---|
266 | end |
---|