source: trunk/SRC/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_droplist_pm.pro @ 226

Last change on this file since 226 was 226, checked in by pinsard, 17 years ago

corrections of some misspellings in some *.pro

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