;+ ; ; @file_comments ; ; @categories ; Compound widget ; ; @param ID ; ; @param VALUE ; It is the default tick mark value (a floating-point number). ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ;- ; PRO cw_droplist_pm_set_value, id, value ; compile_opt idl2, strictarrsubs ; DroplistId = widget_info(id,find_by_uname = 'Droplist') if size(value, /type) eq 8 then BEGIN ; this is a structure tagnames = tag_names(value) for tag = 0, n_tags(value)-1 do begin case strtrim(strlowcase(tagnames[tag]), 2) of 'dynamic_resize':widget_control, DroplistId, dynamic_resize = value.dynamic_resize 'droplist_select':widget_control, DroplistId, set_droplist_select = value.droplist_select 'value':widget_control, DroplistId, set_value = value.value ELSE:ras = report('mauvais nom de l''argument de la structure ds cw_droplist_pm_set_value') endcase endfor ENDIF ELSE widget_control, DroplistId, set_value = value return end ; ;+ ; ; @file_comments ; Compound widget ; ; @categories ; Compound widget ; ; @param ID ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ;- ; FUNCTION cw_droplist_pm_get_value, id ; compile_opt idl2, strictarrsubs ; DroplistId = widget_info(id,find_by_uname = 'Droplist') return, {droplist_number:widget_info(DroplistId, /droplist_number) $ , droplist_select:widget_info(DroplistId, /droplist_select) $ , dynamic_resize:widget_info(DroplistId, /dynamic_resize)} end ; ;+ ; ; @file_comments ; Compound widget ; ; @categories ; Compound widget ; ; @param EVENT ; ; @returns ; ; @uses ; ; @restrictions ; ; @examples ; ; @history ; ; @version ; $Id$ ;- ; FUNCTION cw_droplist_pm_event, event ; compile_opt idl2, strictarrsubs ; widget_control, event.id, get_uvalue=uval ; if uval EQ 'Droplist' then $ return, {CW_DROPLIST_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ , INDEX:event.index, OUT:0} ; DroplistId = widget_info(event.handler,find_by_uname = 'Droplist') index = widget_info(DroplistId, /droplist_select) case uval OF 'plus':BEGIN indexmax = widget_info(DroplistId, /droplist_number)-1 if index NE indexmax then widget_control, DroplistId,set_droplist_select = index+1 return, {CW_DROPLIST_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ , INDEX:(index+1) < indexmax, OUT:long(index EQ indexmax)} END 'minus':BEGIN if index NE 0 then widget_control, DroplistId,set_droplist_select = index-1 return, {CW_DROPLIST_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ , INDEX:0 > (index-1), OUT:-long(index EQ 0)} END endcase end ; ;+ ; ; @file_comments ; Like WIDGET_DROPLIST but here, their are 2 buttons + and - to move the widget from +/- 1 ; ; @categories ; Compound widget ; ; @param PARENT {in}{required} ; The widget ID of the parent widget. ; ; @keyword COLUMN ; Buttons will be arranged in the number of columns ; specified by this keyword. ; ; @keyword ROW ; Buttons will be arranged in the number of rows ; specified by this keyword. ; ; @keyword UVALUE ; The user value to be associated with the widget. ; ; @keyword UNAME ; The user name to be associated with the widget. ; ; @keyword _EXTRA ; Used to pass keywords ; ; @returns ; The returned value of this function is the widget ID of the ; newly-created animation widget. ; ; @restrictions ; ; Widget Events Returned by Droplist Widgets ; ; Pressing the mouse button while the mouse cursor is over an ; element of a droplist widget causes the widget to change the label ; on the droplist button and to generate an event. The appearance of ; any previously selected element is restored to normal at the same ; time. The event structure returned by the WIDGET_EVENT function is ; defined by the following statement: ; ; { CW_DROPLIST_PM, ID:0L, TOP:0L, HANDLER:0L, INDEX:0L, OUT:0 } ; ; The first three fields are the standard fields found in every ; widget event. ; INDEX returns the index of the selected item. This can be used to ; index the array of names originally used to set the widget''s ; value ; OUT:It is an integer which can take 3 values: ; 1 : If we press + when the index is already at the max ; Comment: In this case, the index stay at the max ; -1: If we press - when the index is already at the min ; Comment: In this case, the index stay at the min ; 0 : In other cases ; ; Keywords to WIDGET_CONTROL ; ; A number of keywords to the WIDGET_CONTROL procedure affect the ; behavior of cw_slider_pm widget: GET_VALUE and SET_VALUE. ; 1) GET_VALUE ; widget_control,wid_id,get_value=resultat ; Send back, in the result variable, a structure of 3 elements whose ; names are inspired by keywords we can pass at widget_control when ; we use WIDGET_COMBOBOX: ; DROPLIST_NUMBER: the number of elements currently ; contained in the specified droplist widget. ; DROPLIST_SELECT: the zero-based number of the ; currently-selected element (i.e., the currently-displayed ; element) in the specified droplist widget. ; DYNAMIC_RESIZE: a True value (1) if the widget specified ; by Widget_ID is a button, droplist, or label widget that ; has had its DYNAMIC_RESIZE attribute set. Otherwise, ; False (0) is returned. ; 2) SET_VALUE ; widget_control,wid_id,set_value=impose ; permet de modifier l''etat de la droplist comme on peut le faire ; pour WIDGET_DROPLIST Impose peut etre: ; a) The contents of the list widget (string or string array) ; b) A structure which can have for elements (from 1 to 3): ; DYNAMIC_RESIZE:Set this keyword to activate (if set to 1) ; or deactivate (if set to 0) dynamic resizing of the ; specified CW_DROPLIST_PM widget (see the documentation ; for the DYNAMIC_RESIZE keyword to WIDGET_DROPLIST ; procedure for more information about dynamic widget ; resizing). ; DROPLIST_SELECT:Set this keyword to return the zero-based ; number of the currently-selected element (i.e., the ; currently-displayed element) in the specified droplist ; widget. ; VALUE: The contents of the list widget (string or string ; array) ; ; @examples ; See the program provided above (testwid and the associated procedure, testwid_event). ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 6/9/1999 ; ; @version ; $Id$ ; ;- ; FUNCTION cw_droplist_pm, parent,UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, _EXTRA = ex ; compile_opt idl2, strictarrsubs ; IF (N_PARAMS() NE 1) THEN ras = report('Incorrect number of arguments') ON_ERROR, 2 ;return to caller ; checking for row and column keywords row = keyword_set(row)*(1-keyword_set(column)) column = keyword_set(column)*(1-keyword_set(row))+(keyword_set(column) EQ row) if NOT keyword_set(uvalue) then uvalue = '' if NOT keyword_set(uname) then uname = '' ; base = widget_base(parent, space = 1, xpad = 1, ypad = 1, ROW = row, COLUMN = column $ , EVENT_FUNC = 'cw_droplist_pm_event' $ , FUNC_GET_VALUE='cw_droplist_pm_get_value' $ , PRO_SET_VALUE='cw_droplist_pm_set_value' $ , UVALUE = uvalue, UNAME = uname, _extra = ex) ; if keyword_set(row) THEN nothing = widget_button(base,value= '-', uvalue= 'minus') nothing = widget_droplist(base, UVALUE = 'Droplist', UNAME = 'Droplist', _extra = ex) if keyword_set(column) then begin base1 = widget_base(base, /row, /align_center, space = 1, xpad = 1, ypad = 1) nothing = widget_button(base1,value= '-', uvalue= 'minus', xsize = 20, ysize = 20) nothing = widget_button(base1,value= '+', uvalue= 'plus', xsize = 20, ysize = 20) ENDIF ELSE nothing = widget_button(base,value= '+', uvalue= 'plus') ; ; widget_control,base,/realize ; return, base end