1 | ;+ |
---|
2 | ; |
---|
3 | ; @todo seb |
---|
4 | ; |
---|
5 | ;- |
---|
6 | ; PRO testwid_event, event |
---|
7 | ; ; |
---|
8 | ; compile_opt idl2, strictarrsubs |
---|
9 | ; ; |
---|
10 | ; widget_control, event.id, get_uvalue=uval |
---|
11 | ; if n_elements(uval) EQ 0 then return |
---|
12 | ; case uval of |
---|
13 | ; 'done':widget_control, event.top, /destroy |
---|
14 | ; 'get':BEGIN |
---|
15 | ; id = widget_info(event.top,find_by_uname = 'discret') |
---|
16 | ; widget_control, id, get_value = value1 |
---|
17 | ; help, value1 |
---|
18 | ; print, 'value1', value1 |
---|
19 | ; id = widget_info(event.top,find_by_uname = 'continus') |
---|
20 | ; widget_control, id, get_value = value2 |
---|
21 | ; help, value2 |
---|
22 | ; print, 'value2', value2 |
---|
23 | ; END |
---|
24 | ; ELSE: |
---|
25 | ; endcase |
---|
26 | ; return |
---|
27 | ; end |
---|
28 | ; PRO testwid, _extra = ex |
---|
29 | ; ; |
---|
30 | ; compile_opt idl2, strictarrsubs |
---|
31 | ; ; |
---|
32 | ; base=widget_base(/COLUMN) |
---|
33 | ; nothing = widget_label(base, value = 'beginning of the test') |
---|
34 | ; ; |
---|
35 | ; nothing = cw_selectinterval(base, 10+indgen(5), _extra = ex, uname = 'discret', uvalue = 'discret') |
---|
36 | ; print, nothing |
---|
37 | ; nothing = cw_selectinterval(base, indgen(20), _extra = ex, uname = 'continus', uvalue = 'continus') |
---|
38 | ; print, nothing |
---|
39 | ; ; |
---|
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, /no_block |
---|
44 | ; return |
---|
45 | ; end |
---|
46 | ; |
---|
47 | ;+ |
---|
48 | ; @file_comments |
---|
49 | ; |
---|
50 | ; @categories |
---|
51 | ; Compound widget |
---|
52 | ; |
---|
53 | ; @param ID |
---|
54 | ; |
---|
55 | ; @returns |
---|
56 | ; |
---|
57 | ; @restrictions |
---|
58 | ; |
---|
59 | ; @examples |
---|
60 | ; |
---|
61 | ; @history |
---|
62 | ; |
---|
63 | ; @version |
---|
64 | ; $Id$ |
---|
65 | ;- |
---|
66 | ; |
---|
67 | function cw_selectinterval_get_value, id |
---|
68 | ; |
---|
69 | compile_opt idl2, strictarrsubs |
---|
70 | ; |
---|
71 | bgroupid=widget_info(id, find_by_uname = 'bgroup') |
---|
72 | ; the widget is a set of button |
---|
73 | if bgroupid ne 0 then begin |
---|
74 | widget_control, bgroupid, get_value = selected |
---|
75 | widget_control, bgroupid, get_uvalue = vecteur |
---|
76 | vecteur = vecteur.vecteur |
---|
77 | endif else begin |
---|
78 | ; the widget is 2 sliders |
---|
79 | Minid = Widget_Info(Id, Find_by_uname = 'min') |
---|
80 | widget_control, minid, get_value = minval |
---|
81 | minval = minval.value |
---|
82 | maxid = widget_info(id, find_by_uname = 'max') |
---|
83 | widget_control, maxid, get_value = maxval |
---|
84 | maxval = maxval.value |
---|
85 | widget_control, minid, get_uvalue = vecteur |
---|
86 | vecteur = vecteur.vecteur |
---|
87 | selected = where(vecteur ge minval and vecteur le maxval) |
---|
88 | ENDELSE |
---|
89 | if selected[0] eq -1 then return, -1 else return, vecteur[selected] |
---|
90 | END |
---|
91 | ; |
---|
92 | ;+ |
---|
93 | ; @file_comments |
---|
94 | ; |
---|
95 | ; @categories |
---|
96 | ; Compound widget |
---|
97 | ; |
---|
98 | ; @param EVENT |
---|
99 | ; |
---|
100 | ; @returns |
---|
101 | ; |
---|
102 | ; @restrictions |
---|
103 | ; |
---|
104 | ; @examples |
---|
105 | ; |
---|
106 | ; @history |
---|
107 | ; |
---|
108 | ; @version |
---|
109 | ; $Id$ |
---|
110 | ;- |
---|
111 | ; |
---|
112 | function cw_selectinterval_event, event |
---|
113 | ; |
---|
114 | compile_opt idl2, strictarrsubs |
---|
115 | ; |
---|
116 | widget_control, event.id, get_uvalue=uval |
---|
117 | case uval.name of |
---|
118 | 'min':begin ; change the value if the minimum for the slider called max |
---|
119 | maxid=widget_info(event.handler, find_by_uname = 'max') |
---|
120 | widget_control, maxid, set_value={SLIDER_MIN:event.value+1} |
---|
121 | end |
---|
122 | 'max':begin ; change the value if the maximum for the slider called min |
---|
123 | minid=widget_info(event.handler, find_by_uname = 'min') |
---|
124 | widget_control, minid, set_value={SLIDER_MAX:event.value-1} |
---|
125 | end |
---|
126 | 'bgroup': |
---|
127 | endcase |
---|
128 | return, {ID:event.handler, TOP:event.top, HANDLER:0L} |
---|
129 | END |
---|
130 | ; |
---|
131 | ;+ |
---|
132 | ; @file_comments |
---|
133 | ; |
---|
134 | ; @categories |
---|
135 | ; Compound widget |
---|
136 | ; |
---|
137 | ; @param PARENT |
---|
138 | ; The widget ID of the parent widget. |
---|
139 | ; |
---|
140 | ; @param VECTEUR {type=vector} |
---|
141 | ; A vector whose the first element must be the smallest one and the last |
---|
142 | ; must be the biggest one. |
---|
143 | ; |
---|
144 | ; @keyword _EXTRA |
---|
145 | ; Used to pass keywords |
---|
146 | ; |
---|
147 | ; @returns |
---|
148 | ; |
---|
149 | ; @restrictions |
---|
150 | ; |
---|
151 | ; @examples |
---|
152 | ; |
---|
153 | ; @history |
---|
154 | ; |
---|
155 | ; @version |
---|
156 | ; $Id$ |
---|
157 | ;- |
---|
158 | ; |
---|
159 | FUNCTION cw_selectinterval, parent, vecteur, _EXTRA = ex |
---|
160 | ; |
---|
161 | compile_opt idl2, strictarrsubs |
---|
162 | ; |
---|
163 | |
---|
164 | base = widget_base(parent $ |
---|
165 | , EVENT_FUNC = 'cw_selectinterval_event' $ |
---|
166 | , FUNC_GET_VALUE='cw_selectinterval_get_value' $ |
---|
167 | , PRO_SET_VALUE='cw_selectinterval_set_value' $ |
---|
168 | , /ROW, _extra = ex) |
---|
169 | if n_elements(vecteur) le 10 then begin |
---|
170 | nothing = CW_BGROUP(base, strtrim(vecteur,1),/nonexclusive,/row, uvalue = {name:'bgroup', vecteur:vecteur}, uname='bgroup') |
---|
171 | buttvalue=bytarr(n_elements(nothing)) |
---|
172 | buttvalue[0]=1 |
---|
173 | widget_control, nothing, set_value=buttvalue |
---|
174 | endif else begin |
---|
175 | min=min(floor(vecteur)) |
---|
176 | max=max(ceil(vecteur)) |
---|
177 | nothing=cw_slider_pm(base, value = min, min=min, max=max-1, uvalue = {name:'min', vecteur:vecteur}, uname='min') |
---|
178 | nothing=cw_slider_pm(base, value = max, min=min+1, max=max, uvalue = {name:'max'}, uname='max') |
---|
179 | endelse |
---|
180 | return, base |
---|
181 | end |
---|