Ignore:
Timestamp:
05/11/06 12:35:53 (18 years ago)
Author:
smasson
Message:

debug + new xxx

Location:
trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET
Files:
1 added
3 deleted
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/.idlwave_catalog

    r68 r69  
    22;; IDLWAVE catalog for library saxo 
    33;; Automatically Generated -- do not edit. 
    4 ;; Created by idlwave_catalog on Tue Jan 24 17:06:19 2006 
     4;; Created by idlwave_catalog on Thu May  4 08:42:55 2006 
    55;; 
    66(setq idlwave-library-catalog-libname "saxo") 
     
    99   ("CW_BGROUP_GETV" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(id, value)" (nil)) 
    1010   ("CW_BGROUP_EVENT" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(ev)" (nil)) 
    11    ("CW_BGROUP" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(parent, names)" (nil ("_EXTRA") ("BUTTON_UVALUE") ("COLUMN") ("EVENT_FUNCT") ("EXCLUSIVE") ("FONT") ("FRAME") ("IDS") ("LABEL_LEFT") ("LABEL_TOP") ("MAP") ("NO_RELEASE") ("NONEXCLUSIVE") ("RETURN_ID") ("RETURN_INDEX") ("RETURN_NAME") ("ROW") ("SCROLL") ("SET_VALUE") ("SPACE") ("UNAME") ("UVALUE") ("X_SCROLL_SIZE") ("XOFFSET") ("XPAD") ("XSIZE") ("Y_SCROLL_SIZE") ("YOFFSET") ("YPAD") ("YSIZE"))) 
    12    ("testwid_event" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event" (nil)) 
    13    ("testwid" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, calendar, date0" (nil ("_extra"))) 
     11   ("CW_BGROUP" fun nil (lib "cw_bgroup.pro" nil "saxo") "Result = %s(parent, names)" (nil ("BUTTON_UVALUE") ("COLUMN") ("EVENT_FUNCT") ("EXCLUSIVE") ("FONT") ("FRAME") ("IDS") ("LABEL_LEFT") ("LABEL_TOP") ("MAP") ("NO_RELEASE") ("NONEXCLUSIVE") ("RETURN_ID") ("RETURN_INDEX") ("RETURN_NAME") ("ROW") ("SCROLL") ("SET_VALUE") ("SPACE") ("TAB_MODE") ("UNAME") ("UVALUE") ("X_SCROLL_SIZE") ("XOFFSET") ("XPAD") ("XSIZE") ("Y_SCROLL_SIZE") ("YOFFSET") ("YPAD") ("YSIZE"))) 
    1412   ("cw_calendar_set_value" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, id, value" (nil)) 
    1513   ("cw_calendar_get_value" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(id)" (nil)) 
    16    ("set_droplist" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event, casename, date0" (nil)) 
     14   ("get_cal_value" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(id, winfoid)" (nil)) 
     15   ("set_cal_combobox" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event, casename, date0" (nil)) 
    1716   ("move" pro nil (lib "cw_calendar.pro" nil "saxo") "%s, event, casename" (nil)) 
    1817   ("cw_calendar_event" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(event)" (nil)) 
    19    ("cw_calendar" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(parent, calendar, date0)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE"))) 
     18   ("cw_calendar" fun nil (lib "cw_calendar.pro" nil "saxo") "Result = %s(parent, calendar, jdate0)" (nil ("_extra") ("CALTYPE") ("FAKECAL") ("UNAME") ("UVALUE"))) 
     19   ("cw_combobox_pm_set_value" pro nil (lib "cw_combobox_pm.pro" nil "saxo") "%s, id, value" (nil)) 
     20   ("cw_combobox_pm_get_value" fun nil (lib "cw_combobox_pm.pro" nil "saxo") "Result = %s(id)" (nil)) 
     21   ("cw_combobox_pm_event" fun nil (lib "cw_combobox_pm.pro" nil "saxo") "Result = %s(event)" (nil)) 
     22   ("cw_combobox_pm" fun nil (lib "cw_combobox_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE") ("VALUE"))) 
    2023   ("cw_domain_set_value" pro nil (lib "cw_domain.pro" nil "saxo") "%s, id, value" (nil)) 
    2124   ("cw_domain_get_value" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(id)" (nil)) 
    2225   ("cw_domain_event" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(event)" (nil)) 
    23    ("cw_domain" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("BOXZOOM") ("COLUMN") ("ROW") ("STRICT") ("UNAME") ("UNZOOM") ("UVALUE"))) 
     26   ("cw_domain" fun nil (lib "cw_domain.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("BOXZOOM") ("STRICT") ("UNAME") ("UNZOOM") ("UVALUE"))) 
    2427   ("cw_droplist_pm_set_value" pro nil (lib "cw_droplist_pm.pro" nil "saxo") "%s, id, value" (nil)) 
    2528   ("cw_droplist_pm_get_value" fun nil (lib "cw_droplist_pm.pro" nil "saxo") "Result = %s(id)" (nil)) 
    2629   ("cw_droplist_pm_event" fun nil (lib "cw_droplist_pm.pro" nil "saxo") "Result = %s(event)" (nil)) 
    2730   ("cw_droplist_pm" fun nil (lib "cw_droplist_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE"))) 
    28    ("cw_fourparameter_get_value" fun nil (lib "cw_fourparameter.pro" nil "saxo") "Result = %s(id)" (nil)) 
    29    ("cw_fourparameter_event" fun nil (lib "cw_fourparameter.pro" nil "saxo") "Result = %s(event)" (nil)) 
    30    ("cw_fourparameter" fun nil (lib "cw_fourparameter.pro" nil "saxo") "Result = %s(parent, xgloin, xin, xminin, xmaxin, direction, type)" (nil ("CLEAR") ("EDITABLE") ("UNAME") ("UVALUE"))) 
    31    ("cw_miseenpage_event" fun nil (lib "cw_miseenpage.pro" nil "saxo") "Result = %s(event)" (nil)) 
    32    ("cw_miseenpage" fun nil (lib "cw_miseenpage.pro" nil "saxo") "Result = %s(parent, small)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UNZOOM") ("UVALUE"))) 
    33    ("CW_PDMENU_EVENT" fun nil (lib "cw_pdmenu.pro" nil "saxo") "Result = %s(ev)" (nil)) 
    34    ("CW_PDMENU_BUILD" pro nil (lib "cw_pdmenu.pro" nil "saxo") "%s, parent, desc, cur, n, ev_type, full_qual_str, delim, ids, mbars, HELP_KW" (nil ("FONT"))) 
    35    ("CW_PDMENU" fun nil (lib "cw_pdmenu.pro" nil "saxo") "Result = %s(parent, desc)" (nil ("_EXTRA") ("COLUMN") ("DELIMITER") ("FONT") ("HELP") ("IDS") ("MBAR") ("RETURN_FULL_NAME") ("RETURN_ID") ("RETURN_INDEX") ("RETURN_NAME") ("UNAME") ("UVALUE") ("XOFFSET") ("YOFFSET"))) 
     31   ("cw_pagelayout_event" fun nil (lib "cw_pagelayout.pro" nil "saxo") "Result = %s(event)" (nil)) 
     32   ("cw_pagelayout" fun nil (lib "cw_pagelayout.pro" nil "saxo") "Result = %s(parent, small)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UNZOOM") ("UVALUE"))) 
    3633   ("cw_slide_slice_set_value" pro nil (lib "cw_slide_slice.pro" nil "saxo") "%s, id, value" (nil)) 
    3734   ("cw_slide_slice_event" fun nil (lib "cw_slide_slice.pro" nil "saxo") "Result = %s(event)" (nil)) 
    3835   ("cw_slide_slice" fun nil (lib "cw_slide_slice.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("boxzoom") ("COLUMN") ("FRAME") ("ROW") ("UNAME") ("UVALUE"))) 
     36   ("decvalue" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(value)" (nil)) 
     37   ("decind" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(value)" (nil)) 
    3938   ("cw_slider_pm_set_value" pro nil (lib "cw_slider_pm.pro" nil "saxo") "%s, id, value" (nil)) 
    4039   ("cw_slider_pm_get_value" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(id)" (nil)) 
    4140   ("cw_slider_pm_event" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(event)" (nil)) 
    42    ("cw_slider_pm" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("ROW") ("UNAME") ("UVALUE") ("VERTICAL"))) 
     41   ("cw_slider_pm" fun nil (lib "cw_slider_pm.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("MAXIMUM") ("MINIMUM") ("STRMINLEN") ("title") ("UNAME") ("UVALUE") ("VALUE"))) 
    4342   ("cw_specifie_set_value" pro nil (lib "cw_specifie.pro" nil "saxo") "%s, id, value" (nil)) 
    4443   ("cw_specifie_get_value" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(id)" (nil)) 
    4544   ("cw_specifie_event" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(event)" (nil)) 
    46    ("cw_specifie" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("FORXXX") ("FRAME") ("ROW") ("UNAME") ("UVALUE"))) 
    47    ("testwid_event" pro nil (lib "testwid.pro" nil "saxo") "%s, event" (nil)) 
    48    ("testwid" pro nil (lib "testwid.pro" nil "saxo") "%s, calendar, date0" (nil ("_extra"))))) 
     45   ("cw_specifie" fun nil (lib "cw_specifie.pro" nil "saxo") "Result = %s(parent)" (nil ("_extra") ("COLUMN") ("FORXXX") ("FRAME") ("ROW") ("UNAME") ("UVALUE"))))) 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_bgroup.pro

    r51 r69  
    11; $Id$ 
    22; 
    3 ; Copyright (c) 1992-1998, Research Systems, Inc.  All rights reserved. 
    4 ;       Unauthorized reproduction prohibited. 
     3; Copyright (c) 1992-2005, Research Systems, Inc.  All rights reserved. 
     4;   Unauthorized reproduction prohibited. 
    55;+ 
    66; NAME: 
    7 ;       CW_BGROUP 
     7;   CW_BGROUP 
    88; 
    99; PURPOSE: 
    10 ;       CW_BGROUP is a compound widget that simplifies creating 
    11 ;       a base of buttons. It handles the details of creating the 
    12 ;       proper base (standard, exclusive, or non-exclusive) and filling 
    13 ;       in the desired buttons. Events for the individual buttons are 
    14 ;       handled transparently, and a CW_BGROUP event returned. This 
    15 ;       event can return any one of the following: 
    16 ;               - The Index of the button within the base. 
    17 ;               - The widget ID of the button. 
    18 ;               - The name of the button. 
    19 ;               - An arbitrary value taken from an array of User values. 
     10;   CW_BGROUP is a compound widget that simplifies creating 
     11;   a base of buttons. It handles the details of creating the 
     12;   proper base (standard, exclusive, or non-exclusive) and filling 
     13;   in the desired buttons. Events for the individual buttons are 
     14;   handled transparently, and a CW_BGROUP event returned. This 
     15;   event can return any one of the following: 
     16;       - The Index of the button within the base. 
     17;       - The widget ID of the button. 
     18;       - The name of the button. 
     19;       - An arbitrary value taken from an array of User values. 
    2020; 
    2121; CATEGORY: 
    22 ;       Compound widgets. 
     22;   Compound widgets. 
    2323; 
    2424; CALLING SEQUENCE: 
    25 ;               Widget = CW_BGROUP(Parent, Names) 
    26 ; 
    27 ;       To get or set the value of a CW_BGROUP, use the GET_VALUE and 
    28 ;       SET_VALUE keywords to WIDGET_CONTROL. The value of a CW_BGROUP 
    29 ;       is: 
    30 ; 
    31 ;               ----------------------------------------------- 
    32 ;               Type            Value 
    33 ;               ----------------------------------------------- 
    34 ;               normal          None 
    35 ;               exclusive       Index of currently set button 
    36 ;               non-exclusive   Vector indicating the position 
    37 ;                               of each button (1-set, 0-unset) 
    38 ;               ----------------------------------------------- 
     25;       Widget = CW_BGROUP(Parent, Names) 
     26; 
     27;   To get or set the value of a CW_BGROUP, use the GET_VALUE and 
     28;   SET_VALUE keywords to WIDGET_CONTROL. The value of a CW_BGROUP 
     29;   is: 
     30; 
     31;       ----------------------------------------------- 
     32;       Type        Value 
     33;       ----------------------------------------------- 
     34;       normal      None 
     35;       exclusive       Index of currently set button 
     36;       non-exclusive   Vector indicating the position 
     37;               of each button (1-set, 0-unset) 
     38;       ----------------------------------------------- 
    3939; 
    4040; 
    4141; INPUTS: 
    42 ;       Parent:         The ID of the parent widget. 
    43 ;       Names:          A string array, containing one string per button, 
    44 ;                       giving the name of each button. 
     42;       Parent:     The ID of the parent widget. 
     43;   Names:      A string array, containing one string per button, 
     44;           giving the name of each button. 
    4545; 
    4646; KEYWORD PARAMETERS: 
    4747; 
    48 ;       BUTTON_UVALUE:  An array of user values to be associated with 
    49 ;                       each button and returned in the event structure. 
    50 ;       COLUMN:         Buttons will be arranged in the number of columns 
    51 ;                       specified by this keyword. 
    52 ;       EVENT_FUNCT:    The name of an optional user-supplied event function  
    53 ;                       for buttons. This function is called with the return 
    54 ;                       value structure whenever a button is pressed, and  
    55 ;                       follows the conventions for user-written event 
    56 ;                       functions. 
    57 ;       EXCLUSIVE:      Buttons will be placed in an exclusive base, with 
    58 ;                       only one button allowed to be selected at a time. 
    59 ;       FONT:           The name of the font to be used for the button 
    60 ;                       titles. If this keyword is not specified, the default 
    61 ;                       font is used. 
    62 ;       FRAME:          Specifies the width of the frame to be drawn around 
    63 ;                       the base. 
    64 ;       IDS:            A named variable into which the button IDs will be 
    65 ;                       stored, as a longword vector. 
    66 ;       LABEL_LEFT:     Creates a text label to the left of the buttons. 
    67 ;       LABEL_TOP:      Creates a text label above the buttons. 
    68 ;       MAP:            If set, the base will be mapped when the widget 
    69 ;                       is realized (the default). 
    70 ;       NONEXCLUSIVE:   Buttons will be placed in an non-exclusive base. 
    71 ;                       The buttons will be independent. 
    72 ;       NO_RELEASE:     If set, button release events will not be returned. 
    73 ;       RETURN_ID:      If set, the VALUE field of returned events will be 
    74 ;                       the widget ID of the button. 
    75 ;       RETURN_INDEX:   If set, the VALUE field of returned events will be 
    76 ;                       the zero-based index of the button within the base. 
    77 ;                       THIS IS THE DEFAULT. 
    78 ;       RETURN_NAME:    If set, the VALUE field of returned events will be 
    79 ;                       the name of the button within the base. 
    80 ;       ROW:            Buttons will be arranged in the number of rows 
    81 ;                       specified by this keyword. 
    82 ;       SCROLL:         If set, the base will include scroll bars to allow 
    83 ;                       viewing a large base through a smaller viewport. 
    84 ;       SET_VALUE:      The initial value of the buttons. This is equivalent 
    85 ;                       to the later statement: 
    86 ; 
    87 ;                       WIDGET_CONTROL, widget, set_value=value 
    88 ; 
    89 ;       SPACE:          The space, in pixels, to be left around the edges 
    90 ;                       of a row or column major base. This keyword is 
    91 ;                       ignored if EXCLUSIVE or NONEXCLUSIVE are specified. 
    92 ;       UVALUE:         The user value to be associated with the widget. 
    93 ;       XOFFSET:        The X offset of the widget relative to its parent. 
    94 ;       XPAD:           The horizontal space, in pixels, between children 
    95 ;                       of a row or column major base. Ignored if EXCLUSIVE 
    96 ;                       or NONEXCLUSIVE are specified. 
    97 ;       XSIZE:          The width of the base.  
    98 ;       X_SCROLL_SIZE:  The width of the viewport if SCROLL is specified. 
    99 ;       YOFFSET:        The Y offset of the widget relative to its parent. 
    100 ;       YPAD:           The vertical space, in pixels, between children of 
    101 ;                       a row or column major base. Ignored if EXCLUSIVE 
    102 ;                       or NONEXCLUSIVE are specified. 
    103 ;       YSIZE:          The height of the base.  
    104 ;       Y_SCROLL_SIZE:  The height of the viewport if SCROLL is specified. 
     48;   BUTTON_UVALUE:  An array of user values to be associated with 
     49;           each button and returned in the event structure. 
     50;   COLUMN:     Buttons will be arranged in the number of columns 
     51;           specified by this keyword. 
     52;   EVENT_FUNCT:    The name of an optional user-supplied event function 
     53;           for buttons. This function is called with the return 
     54;           value structure whenever a button is pressed, and 
     55;           follows the conventions for user-written event 
     56;           functions. 
     57;   EXCLUSIVE:  Buttons will be placed in an exclusive base, with 
     58;           only one button allowed to be selected at a time. 
     59;   FONT:       The name of the font to be used for the button 
     60;           titles. If this keyword is not specified, the default 
     61;           font is used. 
     62;   FRAME:      Specifies the width of the frame to be drawn around 
     63;           the base. 
     64;   IDS:        A named variable into which the button IDs will be 
     65;           stored, as a longword vector. 
     66;   LABEL_LEFT: Creates a text label to the left of the buttons. 
     67;   LABEL_TOP:  Creates a text label above the buttons. 
     68;   MAP:        If set, the base will be mapped when the widget 
     69;           is realized (the default). 
     70;   NONEXCLUSIVE:   Buttons will be placed in an non-exclusive base. 
     71;           The buttons will be independent. 
     72;   NO_RELEASE: If set, button release events will not be returned. 
     73;   RETURN_ID:  If set, the VALUE field of returned events will be 
     74;           the widget ID of the button. 
     75;   RETURN_INDEX:   If set, the VALUE field of returned events will be 
     76;           the zero-based index of the button within the base. 
     77;           THIS IS THE DEFAULT. 
     78;   RETURN_NAME:    If set, the VALUE field of returned events will be 
     79;           the name of the button within the base. 
     80;   ROW:        Buttons will be arranged in the number of rows 
     81;           specified by this keyword. 
     82;   SCROLL:     If set, the base will include scroll bars to allow 
     83;           viewing a large base through a smaller viewport. 
     84;   SET_VALUE:  The initial value of the buttons. This is equivalent 
     85;           to the later statement: 
     86; 
     87;           WIDGET_CONTROL, widget, set_value=value 
     88; 
     89;   SPACE:      The space, in pixels, to be left around the edges 
     90;           of a row or column major base. This keyword is 
     91;           ignored if EXCLUSIVE or NONEXCLUSIVE are specified. 
     92;   UVALUE:     The user value to be associated with the widget. 
     93;   UNAME:      The user name to be associated with the widget. 
     94;   XOFFSET:    The X offset of the widget relative to its parent. 
     95;   XPAD:       The horizontal space, in pixels, between children 
     96;           of a row or column major base. Ignored if EXCLUSIVE 
     97;           or NONEXCLUSIVE are specified. 
     98;   XSIZE:      The width of the base. 
     99;   X_SCROLL_SIZE:  The width of the viewport if SCROLL is specified. 
     100;   YOFFSET:    The Y offset of the widget relative to its parent. 
     101;   YPAD:       The vertical space, in pixels, between children of 
     102;           a row or column major base. Ignored if EXCLUSIVE 
     103;           or NONEXCLUSIVE are specified. 
     104;   YSIZE:      The height of the base. 
     105;   Y_SCROLL_SIZE:  The height of the viewport if SCROLL is specified. 
    105106; 
    106107; OUTPUTS: 
     
    108109; 
    109110; SIDE EFFECTS: 
    110 ;       This widget generates event structures with the following definition: 
    111 ; 
    112 ;               event = { ID:0L, TOP:0L, HANDLER:0L, SELECT:0, VALUE:0 } 
    113 ; 
    114 ;       The SELECT field is passed through from the button event. VALUE is 
    115 ;       either the INDEX, ID, NAME, or BUTTON_UVALUE of the button, 
    116 ;       depending on how the widget was created. 
     111;   This widget generates event structures with the following definition: 
     112; 
     113;       event = { ID:0L, TOP:0L, HANDLER:0L, SELECT:0, VALUE:0 } 
     114; 
     115;   The SELECT field is passed through from the button event. VALUE is 
     116;   either the INDEX, ID, NAME, or BUTTON_UVALUE of the button, 
     117;   depending on how the widget was created. 
    117118; 
    118119; RESTRICTIONS: 
    119 ;       Only buttons with textual names are handled by this widget. 
    120 ;       Bitmaps are not understood. 
     120;   Only buttons with textual names are handled by this widget. 
     121;   Bitmaps are not understood. 
    121122; 
    122123; MODIFICATION HISTORY: 
    123 ;       15 June 1992, AB 
    124 ;       7 April 1993, AB, Removed state caching. 
    125 ;       6 Oct. 1994, KDB, Font keyword is not applied to the label. 
     124;   15 June 1992, AB 
     125;   7 April 1993, AB, Removed state caching. 
     126;   6 Oct. 1994, KDB, Font keyword is not applied to the label. 
    126127;       10 FEB 1995, DJC  fixed bad bug in event procedure, getting 
    127128;                         id of stash widget. 
    128 ;       11 April 1995, AB Removed Motif special cases. 
     129;   11 April 1995, AB Removed Motif special cases. 
    129130;- 
    130131 
    131132 
    132133pro CW_BGROUP_SETV, id, value 
    133  
    134   ON_ERROR, 2                                           ;return to caller 
     134  compile_opt hidden 
     135 
     136  ON_ERROR, 2                       ;return to caller 
    135137 
    136138  stash = WIDGET_INFO(id, /CHILD) 
     
    140142    0: message,'unable to set plain button group value' 
    141143    1: begin 
    142           WIDGET_CONTROL, SET_BUTTON=0, state.ids[state.excl_pos] 
    143           state.excl_pos = value 
    144           WIDGET_CONTROL, /SET_BUTTON, state.ids[value] 
    145         end 
     144      WIDGET_CONTROL, SET_BUTTON=0, state.ids[state.excl_pos] 
     145      state.excl_pos = value 
     146      WIDGET_CONTROL, /SET_BUTTON, state.ids[value] 
     147    end 
    146148    2: begin 
    147           n = n_elements(value)-1 
    148           for i = 0, n do begin 
    149             state.nonexcl_curpos[i] = value[i] 
    150             WIDGET_CONTROL, state.ids[i], SET_BUTTON=value[i] 
    151           endfor 
    152         end 
     149      n = n_elements(value)-1 
     150      for i = 0, n do begin 
     151        state.nonexcl_curpos[i] = value[i] 
     152        WIDGET_CONTROL, state.ids[i], SET_BUTTON=value[i] 
     153      endfor 
     154    end 
    153155  endcase 
    154156 
     
    160162function CW_BGROUP_GETV, id, value 
    161163 
    162    ON_ERROR, 2                  ;return to caller 
    163  
    164    stash = WIDGET_INFO(id, /CHILD) 
    165    WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY 
    166  
    167    case state.type of 
    168       0: message,'unable to get plain button group value' 
     164  compile_opt hidden 
     165  ON_ERROR, 2                       ;return to caller 
     166 
     167  stash = WIDGET_INFO(id, /CHILD) 
     168  WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY 
     169 
     170  case state.type of 
     171    0: message, 'unable to get plain button group value' 
    169172;    1: ret = state.excl_pos 
    170       1: ret = state.ret_arr[state.excl_pos] 
     173    1: ret = state.ret_arr[state.excl_pos] 
    171174;    2: ret = state.nonexcl_curpos 
    172       2: BEGIN  
    173          index = where(state.nonexcl_curpos NE 0) 
    174          if index[0] EQ -1 then begin 
    175             if size(state.ret_arr, /type) EQ 7 then ret = '' ELSE ret = -1 
    176          ENDIF ELSE ret = state.ret_arr[index] 
    177       END 
    178    endcase 
    179  
    180    WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
    181  
    182    return, ret 
     175    2: BEGIN  
     176      index = where(state.nonexcl_curpos NE 0) 
     177      if index[0] EQ -1 then begin 
     178        if size(state.ret_arr, /type) EQ 7 then ret = '' ELSE ret = -1 
     179      ENDIF ELSE ret = state.ret_arr[index] 
     180    END 
     181  endcase 
     182   
     183  WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
     184 
     185  return, ret 
    183186 
    184187end 
     
    187190 
    188191function CW_BGROUP_EVENT, ev 
     192  compile_opt hidden 
    189193  WIDGET_CONTROL, ev.handler, GET_UVALUE=stash 
    190194  WIDGET_CONTROL, stash, GET_UVALUE=state, /NO_COPY 
    191195  WIDGET_CONTROL, ev.id, get_uvalue=uvalue 
    192196 
    193   ret = 1                       ;Assume we return a struct 
     197  ret = 1           ;Assume we return a struct 
    194198  case state.type of 
    195199    0: 
    196200    1: if (ev.select eq 1) then begin 
    197           state.excl_pos = uvalue 
    198         ENDIF else begin 
    199           if (state.no_release ne 0) then ret = 0 
    200         ENDELSE 
     201      state.excl_pos = uvalue 
     202    ENDIF else begin 
     203      if (state.no_release ne 0) then ret = 0 
     204    ENDELSE 
    201205    2: begin 
    202           ; Keep track of the current state 
    203           state.nonexcl_curpos[uvalue] = ev.select 
     206      ; Keep track of the current state 
     207      state.nonexcl_curpos[uvalue] = ev.select 
    204208          if (state.no_release ne 0) and (ev.select eq 0) then ret = 0 
    205         end 
     209    end 
    206210  endcase 
    207211 
    208   if ret then begin             ;Return a struct? 
     212  if ret then begin     ;Return a struct? 
    209213      ret = { ID:state.base, TOP:ev.top, HANDLER:0L, SELECT:ev.select, $ 
    210                VALUE:state.ret_arr[uvalue] } 
     214           VALUE:state.ret_arr[uvalue] } 
    211215      efun = state.efun 
    212216      WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
    213217      if efun ne '' then return, CALL_FUNCTION(efun, ret) $ 
    214218      else return, ret 
    215   endif else begin              ;Trash the event 
     219  endif else begin      ;Trash the event 
    216220      WIDGET_CONTROL, stash, SET_UVALUE=state, /NO_COPY 
    217221      return, 0 
     
    226230 
    227231function CW_BGROUP, parent, names, $ 
    228         BUTTON_UVALUE = button_uvalue, COLUMN=column, EVENT_FUNCT = efun, $ 
    229         EXCLUSIVE=excl, FONT=font, FRAME=frame, IDS=ids, LABEL_TOP=label_top, $ 
    230         LABEL_LEFT=label_left, MAP=map, $ 
    231         NONEXCLUSIVE=nonexcl, NO_RELEASE=no_release, RETURN_ID=return_id, $ 
    232         RETURN_INDEX=return_index, RETURN_NAME=return_name, $ 
    233         ROW=row, SCROLL=scroll, SET_VALUE=sval, SPACE=space, UVALUE=uvalue, UNAME = uname, $ 
    234         XOFFSET=xoffset, XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size,$ 
    235         YOFFSET=yoffset, YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
    236            _EXTRA = ex 
     232    BUTTON_UVALUE = button_uvalue, COLUMN=column, EVENT_FUNCT = efun, $ 
     233    EXCLUSIVE=excl, FONT=font, FRAME=frame, IDS=ids, LABEL_TOP=label_top, $ 
     234    LABEL_LEFT=label_left, MAP=map, $ 
     235    NONEXCLUSIVE=nonexcl, NO_RELEASE=no_release, RETURN_ID=return_id, $ 
     236    RETURN_INDEX=return_index, RETURN_NAME=return_name, $ 
     237    ROW=row, SCROLL=scroll, SET_VALUE=sval, SPACE=space, $ 
     238    TAB_MODE=tab_mode, UVALUE=uvalue, $ 
     239    XOFFSET=xoffset, XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size,$ 
     240    YOFFSET=yoffset, YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
     241    UNAME=uname 
    237242 
    238243 
    239244  IF (N_PARAMS() ne 2) THEN MESSAGE, 'Incorrect number of arguments' 
    240245 
    241   ON_ERROR, 2                                           ;return to caller 
     246  ON_ERROR, 2                       ;return to caller 
    242247 
    243248  ; Set default values for the keywords 
    244249  version = WIDGET_INFO(/version) 
    245250  if (version.toolkit eq 'OLIT') then def_space_pad = 4 else def_space_pad = 3 
    246   IF (N_ELEMENTS(column) eq 0)          then column = 0 
    247   IF (N_ELEMENTS(excl) eq 0)            then excl = 0 
    248   IF (N_ELEMENTS(frame) eq 0)           then frame = 0 
    249   IF (N_ELEMENTS(map) eq 0)             then map=1 
    250   IF (N_ELEMENTS(nonexcl) eq 0)         then nonexcl = 0 
    251   IF (N_ELEMENTS(no_release) eq 0)      then no_release = 0 
    252   IF (N_ELEMENTS(row) eq 0)             then row = 0 
    253   IF (N_ELEMENTS(scroll) eq 0)          then scroll = 0 
    254   IF (N_ELEMENTS(space) eq 0)           then space = def_space_pad 
    255   IF (N_ELEMENTS(uvalue) eq 0)          then uvalue = 0 
    256   IF (N_ELEMENTS(uname) eq 0)           then uname = ' ' 
    257   IF (N_ELEMENTS(xoffset) eq 0)         then xoffset=0 
    258   IF (N_ELEMENTS(xpad) eq 0)            then xpad = def_space_pad 
    259   IF (N_ELEMENTS(xsize) eq 0)           then xsize = 0 
    260   IF (N_ELEMENTS(x_scroll_size) eq 0)   then x_scroll_size = 0 
    261   IF (N_ELEMENTS(yoffset) eq 0)         then yoffset=0 
    262   IF (N_ELEMENTS(ypad) eq 0)            then ypad = def_space_pad 
    263   IF (N_ELEMENTS(ysize) eq 0)           then ysize = 0 
    264   IF (N_ELEMENTS(y_scroll_size) eq 0)   then y_scroll_size = 0 
    265    
     251  IF (N_ELEMENTS(column) eq 0)      then column = 0 
     252  IF (N_ELEMENTS(excl) eq 0)        then excl = 0 
     253  IF (N_ELEMENTS(frame) eq 0)       then frame = 0 
     254  IF (N_ELEMENTS(map) eq 0)     then map=1 
     255  IF (N_ELEMENTS(nonexcl) eq 0)     then nonexcl = 0 
     256  IF (N_ELEMENTS(no_release) eq 0)  then no_release = 0 
     257  IF (N_ELEMENTS(row) eq 0)     then row = 0 
     258  IF (N_ELEMENTS(scroll) eq 0)      then scroll = 0 
     259  IF (N_ELEMENTS(space) eq 0)       then space = def_space_pad 
     260  IF (N_ELEMENTS(uname) eq 0)      then uname = 'CW_BGROUP_UNAME' 
     261  IF (N_ELEMENTS(uvalue) eq 0)      then uvalue = 0 
     262  IF (N_ELEMENTS(xoffset) eq 0)     then xoffset=0 
     263  IF (N_ELEMENTS(xpad) eq 0)        then xpad = def_space_pad 
     264  IF (N_ELEMENTS(xsize) eq 0)       then xsize = 0 
     265  IF (N_ELEMENTS(x_scroll_size) eq 0)   then x_scroll_size = 0 
     266  IF (N_ELEMENTS(yoffset) eq 0)     then yoffset=0 
     267  IF (N_ELEMENTS(ypad) eq 0)        then ypad = def_space_pad 
     268  IF (N_ELEMENTS(ysize) eq 0)       then ysize = 0 
     269  IF (N_ELEMENTS(y_scroll_size) eq 0)   then y_scroll_size = 0 
     270 
    266271 
    267272 
     
    269274  top_base = 0L 
    270275  if (n_elements(label_top) ne 0) then begin 
    271     next_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, /COLUMN, _EXTRA = ex) 
     276    next_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, /COLUMN) 
    272277    if(keyword_set(font))then $ 
    273278       junk = WIDGET_LABEL(next_base, value=label_top,font=font) $ 
     
    275280    top_base = next_base 
    276281  endif else next_base = parent 
     282 
    277283  if (n_elements(label_left) ne 0) then begin 
    278     next_base = WIDGET_BASE(next_base, XOFFSET=xoffset, YOFFSET=yoffset, /ROW, _EXTRA = ex) 
     284    next_base = WIDGET_BASE(next_base, XOFFSET=xoffset, YOFFSET=yoffset, /ROW) 
    279285    if(keyword_set(font))then $ 
    280286       junk = WIDGET_LABEL(next_base, value=label_left, font=font) $ 
     
    284290  ; We need some kind of outer base to hold the users UVALUE 
    285291  if (top_base eq 0L) then begin 
    286     top_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset, _EXTRA = ex) 
     292    top_base = WIDGET_BASE(parent, XOFFSET=xoffset, YOFFSET=yoffset) 
    287293    next_base = top_base 
    288294  endif 
    289295  If (top_base EQ next_base) THEN $ 
    290      next_base = WIDGET_BASE(top_base, Xpad=1, Ypad=1, Space=1, _EXTRA = ex) 
     296     next_base = WIDGET_BASE(top_base, Xpad=1, Ypad=1, Space=1) 
    291297 
    292298  ; Set top level base attributes 
    293299  WIDGET_CONTROL, top_base, MAP=map, $ 
    294         FUNC_GET_VALUE='CW_BGROUP_GETV', PRO_SET_VALUE='CW_BGROUP_SETV', $ 
    295         SET_UVALUE=uvalue, SET_UNAME = uname 
     300    FUNC_GET_VALUE='CW_BGROUP_GETV', PRO_SET_VALUE='CW_BGROUP_SETV', $ 
     301    SET_UVALUE=uvalue, SET_UNAME=uname 
     302 
     303  ; Tabbing 
     304  if (n_elements(tab_mode) ne 0) then begin 
     305    WIDGET_CONTROL, top_base, TAB_MODE=tab_mode 
     306    WIDGET_CONTROL, next_base, TAB_MODE=tab_mode 
     307  end 
    296308 
    297309  ; The actual button holding base 
    298310  base = WIDGET_BASE(next_base, COLUMN=column, EXCLUSIVE=excl, FRAME=frame, $ 
    299         NONEXCLUSIVE=nonexcl, ROW=row, SCROLL=scroll, SPACE=space, $ 
    300         XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size, $ 
    301         YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
    302         EVENT_FUNC='CW_BGROUP_EVENT', _EXTRA = ex, $ 
    303         UVALUE=WIDGET_INFO(top_base, /child)) 
     311    NONEXCLUSIVE=nonexcl, ROW=row, SCROLL=scroll, SPACE=space, $ 
     312    XPAD=xpad, XSIZE=xsize, X_SCROLL_SIZE=x_scroll_size, $ 
     313    YPAD=ypad, YSIZE=ysize, Y_SCROLL_SIZE=y_scroll_size, $ 
     314    EVENT_FUNC='CW_BGROUP_EVENT', $ 
     315    UVALUE=WIDGET_INFO(top_base, /child)) 
    304316 
    305317 
     
    308320  for i = 0, n-1 do begin 
    309321    if (n_elements(font) eq 0) then begin 
    310       ids[i] = WIDGET_BUTTON(base, value=names[i], UVALUE=i) 
     322      ids[i] = WIDGET_BUTTON(base, value=names[i], UVALUE=i, $ 
     323      UNAME=uname+'_BUTTON'+STRTRIM(i,2)) 
    311324    endif else begin 
    312       ids[i] = WIDGET_BUTTON(base, value=names[i], FONT=font, UVALUE=i) 
     325      ids[i] = WIDGET_BUTTON(base, value=names[i], FONT=font, $ 
     326      UVALUE=i, UNAME=uname+'_BUTTON'+STRTRIM(i,2)) 
    313327    endelse 
    314328  endfor 
     
    316330  ; Keep the state info in the real (inner) base UVALUE. 
    317331  ; Pick an event value type: 
    318   ;     0 - Return ID 
    319   ;     1 - Return INDEX 
    320   ;     2 - Return NAME 
     332  ; 0 - Return ID 
     333  ; 1 - Return INDEX 
     334  ; 2 - Return NAME 
    321335  ret_type = 1 
    322336  if KEYWORD_SET(RETURN_ID) then ret_type = 0 
     
    334348  if (nonexcl ne 0) then type = 2 
    335349  if n_elements(efun) le 0 then efun = '' 
    336   state = { type:type, $        ; 0-Standard, 1-Exclusive, 2-Non-exclusive 
    337             base: top_base, $   ; cw_bgroup base... 
    338             ret_arr:ret_arr, $  ; Vector of event values 
    339             efun : efun, $      ; Name of event fcn 
    340             nonexcl_curpos:intarr(n), $ ; If non-exclus, tracks state 
    341             excl_pos:0, $                       ; If exclusive, current button 
    342             ids:ids, $                  ; Ids of buttons 
    343             no_release:no_release } 
     350  state = { type:type, $    ; 0-Standard, 1-Exclusive, 2-Non-exclusive 
     351        base: top_base, $   ; cw_bgroup base... 
     352        ret_arr:ret_arr, $  ; Vector of event values 
     353        efun : efun, $  ; Name of event fcn 
     354        nonexcl_curpos:intarr(n), $ ; If non-exclus, tracks state 
     355        excl_pos:0, $           ; If exclusive, current button 
     356        ids:ids, $          ; Ids of buttons 
     357        no_release:no_release } 
    344358  WIDGET_CONTROL, WIDGET_INFO(top_base, /CHILD), SET_UVALUE=state, /NO_COPY 
    345359 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_calendar.pro

    r51 r69  
    11; IDL> testwid,julday(1,1,1980)+lindgen(100)*5 
    22; 
    3 PRO testwid_event, event 
    4     DroplistId = widget_info(event.top,find_by_uname = 'c''est lui') 
    5    widget_control, event.id, get_uvalue=uval 
    6    if n_elements(uval) EQ 0 then return 
    7    case uval of 
    8       'done':widget_control, event.top, /destroy 
    9       'set':BEGIN  
    10          widget_control, event.id, get_value = value 
    11          widget_control, DroplistId, set_value = value 
    12       END 
    13       'get':BEGIN  
    14          widget_control, DroplistId, get_value = value 
    15          help,  value, /struct 
    16       END 
    17       ELSE: 
    18    endcase 
     3; PRO testwid_event, event 
     4;     ComboboxId = widget_info(event.top,find_by_uname = 'c''est lui') 
     5;    widget_control, event.id, get_uvalue=uval 
     6;    if n_elements(uval) EQ 0 then return 
     7;    case uval of 
     8;       'done':widget_control, event.top, /destroy 
     9;       'set':BEGIN  
     10;          widget_control, event.id, get_value = value 
     11;          widget_control, ComboboxId, set_value = value 
     12;       END 
     13;       'get':BEGIN  
     14;          widget_control, ComboboxId, get_value = value 
     15;          help,  value, /struct 
     16;       END 
     17;       ELSE: 
     18;    endcase 
     19;    return 
     20; end 
     21; PRO testwid, calendar, date0, _extra = ex 
     22;    base=widget_base(/COLUMN) 
     23; print, 'base=', base 
     24;    nothing = widget_label(base, value = 'beginning of the test') 
     25; ; 
     26;    nothing = cw_calendar(base,calendar, date0, _extra = ex, uname = 'c''est lui', uvalue = 'c''est lui' ) 
     27; print, 'cw_calendar ID =', nothing 
     28; ; 
     29;    nothing = widget_label(base, value = 'end of the test') 
     30;     nothing = widget_text(base, value = string(calendar[0]), uvalue = 'set', /editable) 
     31;     nothing = widget_button(base, value = 'get', uvalue = 'get') 
     32;     nothing = widget_button(base, value = 'done', uvalue = 'done') 
     33;    widget_control, base, /REALIZE 
     34;    xmanager,'testwid', base 
     35;    return 
     36; END 
     37; 
     38; 
     39; 
     40PRO cw_calendar_set_value, id, value 
     41; 
     42  compile_opt strictarr, strictarrsubs  
     43; 
     44; 
     45@cm_4cal 
     46; get back the calendar and its related informations 
     47  winfo_id = widget_info(id, find_by_uname = 'infocal') 
     48  widget_control, winfo_id, get_uvalue = infowid 
     49  key_caltype = infowid.caltype 
     50   
     51; high freqeuncy calendar 
     52  IF keyword_set(infowid.fakecal) THEN BEGIN 
     53    value2 = date2jul(long(value)) - infowid.fakecal 
     54    IF value2 LT n_elements(infowid.calendar) AND value2 GE 0 THEN BEGIN   
     55      stepid = widget_info(id, find_by_uname = 'step') 
     56      widget_control, stepid, set_value = {combobox_select:value2} 
     57      infowid.date = jul2date(value2 + infowid.fakecal) 
     58      widget_control, winfo_id, set_uvalue = infowid 
     59    ENDIF 
     60  ENDIF ELSE BEGIN  
     61; 
     62    value = long(value[0]) 
     63; define year month day 
     64    year = value/10000l 
     65    month = (value MOD 10000L)/100L 
     66    day = value MOD 100L 
     67; make sure the values correspond to real dates 
     68    if year EQ 0 then year = -1  
     69    if month EQ 0 then month = 6 
     70    if day EQ 0 then day = 15 
     71; check that the date exists in the calendar 
     72  if (where(infowid.calendar EQ julday(month, day, year)))[0] EQ - 1 then return 
     73; update the value of infocal 
     74    infowid.date = value 
     75    widget_control, winfo_id, set_uvalue = infowid 
     76; update the combobox if needed... 
     77    possiblecase = ['day', 'month', 'year'] 
     78    for name = 2, 0, -1 do BEGIN 
     79; call set_cal_combobox with out = 2 to specify that the call is coming 
     80; from cw_calendar_set_value 
     81      if widget_info(id, find_by_uname = possiblecase[name]) NE 0 then $ 
     82         set_cal_combobox, {handler:id, out:2}, possiblecase[name], value 
     83    ENDFOR 
     84  ENDELSE 
     85; 
     86  return 
     87end 
     88;---------------------------------------------------------------------- 
     89FUNCTION cw_calendar_get_value, id 
     90; 
     91  compile_opt strictarr, strictarrsubs  
     92; 
     93  winfo_id = widget_info(id, find_by_uname = 'infocal') 
     94  widget_control, winfo_id, get_uvalue = infowid 
     95  return, infowid.date 
     96END 
     97;---------------------------------------------------------------------- 
     98FUNCTION get_cal_value, id, winfoid  
     99; 
     100  compile_opt strictarr, strictarrsubs  
     101; 
     102  winfo_id = widget_info(id, find_by_uname = 'infocal') 
     103  widget_control, winfo_id, get_uvalue = infowid 
     104  oldate = infowid.date 
     105;-------------day----------------- 
     106  wid_id = widget_info(id, find_by_uname = 'day') 
     107  if wid_id NE 0 then BEGIN 
     108    widget_control, wid_id, get_value = wid_value 
     109    date = long(wid_value.combobox_gettext) 
     110  ENDIF ELSE date = oldate MOD 100L 
     111;-------------month--------------- 
     112  wid_id = widget_info(id, find_by_uname = 'month') 
     113  if wid_id NE 0 then BEGIN 
     114    widget_control, wid_id, get_value = wid_value 
     115    allmonths = string(format = '(C(CMoA))', 31*(indgen(12))) 
     116    month = (where(allmonths EQ wid_value.combobox_gettext))[0] + 1  
     117    date = date + 100L * long(month) 
     118  ENDIF ELSE date = date + (oldate MOD 10000L)/100L 
     119;-------------year---------------- 
     120  wid_id = widget_info(id, find_by_uname = 'year') 
     121  widget_control, wid_id, get_value = wid_value 
     122  date = date + 10000L * long(wid_value.combobox_gettext) 
     123; 
     124  IF arg_present(winfoid) NE 0 THEN BEGIN 
     125    winfoid = winfo_id 
     126    infowid.date = date 
     127    return, infowid 
     128  ENDIF ELSE return, date 
     129end 
     130;---------------------------------------------------------------------- 
     131; redefine the value and index position of the combobox 
     132PRO set_cal_combobox, event, casename, date0 
     133; 
     134  compile_opt strictarr, strictarrsubs  
     135; 
     136; casename: Which widget shall we move: 'day', 'month' or 'year' ? 
     137  wid_id = widget_info(event.handler, find_by_uname = casename) 
     138; we get back the calendar... 
     139  winfo_id = widget_info(event.handler, find_by_uname = 'infocal') 
     140  widget_control, winfo_id, get_uvalue = infowid 
     141  caldat, infowid.calendar, monthcal, daycal, yearcal 
     142; ... and the current date 
     143  IF n_elements(date0) EQ 0 then date0 = get_cal_value(event.handler) 
     144  year0 = date0/10000L 
     145  month0 = (date0 MOD 10000L)/100L 
     146  day0 = date0 MOD 100L 
     147; index of days/months/years according to date0 
     148  case casename of 
     149    'day':BEGIN  
     150; list of days corresponding to month0 and year0 
     151      index = where(monthcal EQ month0 AND yearcal EQ year0) 
     152      current = daycal[index] 
     153    END 
     154    'month':BEGIN  
     155; list of months corresponding to year0 
     156      index = where(yearcal EQ year0) 
     157      current = monthcal[index] 
     158; keep only the uniq values 
     159      indexbis = uniq(current) 
     160      index = index[indexbis] 
     161      current = current[indexbis] 
     162    END 
     163    'year':BEGIN  
     164; keep only the uniq years 
     165      index = uniq(yearcal) 
     166      current = yearcal[index] 
     167    END 
     168  ENDCASE 
     169; we update the uvalue of the widget 
     170  widget_control, wid_id, set_uvalue = {name:casename} 
     171; for event.out = 0, we store the previous position of the combobox to use 
     172; it as the default position. 
     173  IF event.out EQ 0 THEN widget_control, wid_id, get_value = oldselect 
     174; we redefine the new list 
     175  if casename EQ 'month' then begin 
     176    widget_control, wid_id, set_value = string(format = '(C(CMoA))', 31*(current-1)) 
     177  ENDIF ELSE BEGIN  
     178    widget_control, wid_id, set_value = strtrim(current, 1) 
     179  ENDELSE 
     180; specify the index position within the new list of values. 
     181  widget_control, wid_id, get_value = combobox 
     182  CASE event.out OF 
     183; -1: we put to the biggest position 
     184    -1:selected = combobox.combobox_number - 1 
     185; 0: same as the previous position is the best choice... 
     186    0:selected = oldselect.combobox_index < (combobox.combobox_number - 1) 
     187; 1: we put to the smallest position 
     188    1:selected = 0 
     189; 2: a new date has been specified... 
     190    2:BEGIN  
     191      case casename of 
     192        'day':selected = (where(current EQ day0))[0] 
     193        'month':selected = (where(current EQ month0))[0] 
     194        'year':selected = (where(current EQ year0))[0] 
     195      ENDCASE 
     196    END 
     197  ENDCASE 
     198  widget_control, wid_id, set_value = {combobox_select:selected} 
     199; update the date... 
     200  infowid.date = get_cal_value(event.handler) 
     201  widget_control, winfo_id, set_uvalue = infowid 
     202  return 
     203end 
     204;---------------------------------------------------------------------- 
     205; move cyclicly the calendar to the 
     206; value 0 if event.out=1 or combobox_number-1 if event.out=-1 
     207PRO move, event, casename 
     208; 
     209  compile_opt strictarr, strictarrsubs  
     210; 
     211   possiblecase = ['day', 'month', 'year', 'impossiblecase'] 
     212   id = widget_info(event.handler, find_by_uname = casename) 
     213   widget_control, id, get_value = wvalue 
     214; we try to move but we are already at the beginning/end of the combobox 
     215; wvalue.combobox_index EQ (wvalue.combobox_number-1) and event.out EQ 1 
     216; wvalue.combobox_index EQ 0 and event.out EQ -1 (move is not called when out eq 0) 
     217   whichcase = (where(possiblecase EQ casename))[0] 
     218   if wvalue.combobox_index EQ (wvalue.combobox_number-1)*(event.out EQ 1) THEN BEGIN 
     219      if widget_info(event.handler, find_by_uname = possiblecase[whichcase+1]) EQ 0 then begin 
     220; it is impossible to move the "next" combobox... 
     221         widget_control, id, get_value = widvalue 
     222; we set to "widvalue.combobox_number-1" when event.out EQ -1 
     223; and to 0 when event.out EQ 1 
     224         selected = (widvalue.combobox_number-1)*(event.out EQ -1) 
     225         widget_control, id, set_value = {combobox_select:selected} 
     226; we call move for the next combobox 
     227      ENDIF ELSE move, event, possiblecase[whichcase+1] 
     228; it is possible to move from +/- 1 
     229   ENDIF ELSE widget_control, id, set_value = {combobox_select:wvalue.combobox_index+event.out} 
     230   set_cal_combobox, event, possiblecase[whichcase-1] 
    19231   return 
    20232end 
    21 PRO testwid, calendar, date0, _extra = ex 
    22    base=widget_base(/COLUMN) 
    23 print, 'base=', base 
    24    nothing = widget_label(base, value = 'beginning of the test') 
    25 ; 
    26    nothing = cw_calendar(base,calendar, date0, _extra = ex, uname = 'c''est lui', uvalue = 'c''est lui' ) 
    27 print, 'cw_calendar ID =', nothing 
    28 ; 
    29    nothing = widget_label(base, value = 'end of the test') 
    30     nothing = widget_text(base, value = string(calendar[0]), uvalue = 'set', /editable) 
    31     nothing = widget_button(base, value = 'get', uvalue = 'get') 
    32     nothing = widget_button(base, value = 'done', uvalue = 'done') 
    33    widget_control, base, /REALIZE 
    34    xmanager,'testwid', base 
    35    return 
    36 END 
    37 ; 
    38 ; 
    39 ; 
    40 PRO cw_calendar_set_value, id, value 
    41    possiblecase = ['day', 'month', 'year', 'century'] 
    42    name = 0 
    43    repeat begin 
    44       wid_id = widget_info(id,find_by_uname = possiblecase[name]) 
    45       name = name+1 
    46    endrep until wid_id NE 0 
    47    widget_control,wid_id, get_uvalue=wid_uvalue 
    48    value = long(value[0]) 
    49    year = value/10000l & month = (value-year*10000l)/100L & day = value-year*10000l-month*100L 
    50    if year EQ 0 then year = -1 & if month EQ 0 then month = 6 & if day EQ 0 then day = 15 
    51    julianvalue = julday(month, day, year) 
    52    if (where(wid_uvalue.calendar EQ julianvalue))[0] EQ - 1 then return 
    53    for name = 3, 0, -1 do BEGIN 
    54       if widget_info(id,find_by_uname = possiblecase[name]) NE 0  then $ 
    55          set_droplist, {handler:id, out:2}, possiblecase[name], value 
    56    endfor 
    57    return 
    58 end 
    59 ;---------------------------------------------------------------------- 
    60 FUNCTION cw_calendar_get_value, id 
    61    possiblecase = ['day', 'month', 'year', 'century'] 
    62    name = 0 
    63    repeat begin 
    64       wid_id = widget_info(id,find_by_uname = possiblecase[name]) 
    65       name = name+1 
    66    endrep until wid_id NE 0 
    67    widget_control,wid_id, get_uvalue=wid_uvalue 
    68    caldat, wid_uvalue.calendar,monthcal,daycal,yearcal 
    69    centurycal = yearcal/100L 
    70    if n_elements(centurycal[uniq(centurycal, sort(centurycal))]) NE 1 then $  
    71     yearcal = yearcal-centurycal*100 
    72    droplistname = ['day','month','year','century'] 
    73    for name = 0, n_elements(droplistname)-1  do begin 
    74       nothing = execute('wid_id = widget_info(id,find_by_uname = '''+droplistname[name]+''')') 
    75       if wid_id NE 0 then begin 
    76          widget_control,wid_id, get_value=wid_value 
    77          widget_control,wid_id, get_uvalue=wid_uvalue 
    78          nothing = execute('array = '+droplistname[name]+'cal[wid_uvalue.index]') 
    79          nothing = execute(droplistname[name]+' = array[wid_value.droplist_select]') 
    80       ENDIF ELSE nothing = execute(droplistname[name]+'= 0') 
    81    ENDFOR 
    82    return, 10000L*(year+100L*century)+100L*month+day 
    83 end 
    84 ;---------------------------------------------------------------------- 
    85 PRO set_droplist, event, casename, date0 
    86 ; casename: quel est le widget que l''on veut bouger: 'day', 'month', 
    87 ; 'year', 'century' ??? 
    88    wid_id = widget_info(event.handler,find_by_uname = casename) 
    89    possiblecase = ['day', 'month', 'year', 'century'] 
    90    whichcase = (where(possiblecase EQ casename))[0] 
    91 ; on recupere la uvalue attache au widget et qui nous donne ques sont 
    92 ; les 'day', 'month', 'year', 'century' en train d''etre traites et le 
    93 ; calendrier 
    94 ; on recuper ici le calendrier 
    95    widget_control,wid_id, get_uvalue=wid_uvalue 
    96    caldat, wid_uvalue.calendar,monthcal,daycal,yearcal 
    97    centurycal = yearcal/100 
    98 ; et la date courrante 
    99    if n_elements(date0) EQ 0 then date0 = cw_calendar_get_value(event.handler) 
    100    year0 = date0/10000l 
    101    century0 = year0/100 
    102    month0 = (date0-year0*10000l)/100L 
    103    day0 = date0-year0*10000l-month0*100L 
    104    if n_elements(centurycal[uniq(centurycal, sort(centurycal))]) NE 1 then BEGIN  
    105       yearcal = yearcal-centurycal*100 
    106       year0   = year0  -centurycal*100 
    107    ENDIF 
    108 ; index: 'day', 'month', 'year', 'century' possibles pour la date donnee 
    109    case casename of 
    110       'day':index = where(monthcal EQ month0 AND yearcal EQ year0 AND centurycal EQ century0) 
    111       'month':index = where(yearcal EQ year0 AND centurycal EQ century0) 
    112       'year':index = where(centurycal EQ century0) 
    113       'century':index = uniq(centurycal, sort(long(centurycal))) 
    114    ENDCASE 
    115 ; current: liste des mois possibles par ex 
    116    nothing = execute('current = '+possiblecase[whichcase]+'cal[index]') 
    117 ; supprime les boublons 
    118    indexbis = uniq(current, sort(current)) 
    119    index = index[indexbis]; 
    120 ; nouvelle liste des possibilites offertes par la droplist (par ex 
    121 ; liste des mois possibles) 
    122    current = current[indexbis] 
    123 ; on accualise la uvalue du widget (par ex on met la nouvelle liste de 
    124 ; mois possibles) 
    125    widget_control, wid_id, set_uvalue = {name:wid_uvalue.name, calendar:wid_uvalue.calendar, index:index} 
    126 ;on met en place la nouvelle liste possible 
    127    widget_control, wid_id, get_value = oldselect 
    128    if casename EQ 'month' then begin 
    129       widget_control, wid_id, set_value = string(format='(C(CMoA))',31*(current-1)) 
    130    ENDIF ELSE BEGIN  
    131       widget_control, wid_id, set_value = strtrim(current, 1) 
    132   ENDELSE 
    133 ; quel est l''index qu'il faut selectionner parmis la nouvelle liste! 
    134    widget_control, wid_id, get_value = droplist 
    135    if event.out EQ 2 then BEGIN  
    136     nothing = execute('widget_control, wid_id, set_value = {droplist_select:(where(current EQ '+casename+'0))[0]}')  
    137    ENDIF ELSE widget_control, wid_id, set_value $ 
    138     = {droplist_select:((droplist.droplist_number-1)*(event.out EQ -1)+oldselect.droplist_select*(event.out EQ 0)) < (droplist.droplist_number-1)} 
    139    return 
    140 end 
    141 ;---------------------------------------------------------------------- 
    142 PRO move, event, casename 
    143    possiblecase = ['day', 'month', 'year', 'century', 'impossiblecase'] 
    144    whichcase = (where(possiblecase EQ casename))[0] 
    145    id = widget_info(event.handler,find_by_uname = casename) 
    146    widget_control, id, get_value=wvalue 
    147    if wvalue.droplist_select EQ (wvalue.droplist_number-1)*(event.out EQ 1) THEN BEGIN 
    148       if casename EQ 'century' $ 
    149        OR widget_info(event.handler,find_by_uname = possiblecase[whichcase+1]) EQ 0 then begin 
    150          widget_control, id, get_value=widvalue 
    151          widget_control, id, set_value={droplist_select:(widvalue.droplist_number-1)*(event.out EQ -1)} 
    152       ENDIF ELSE nothing = execute('move, event,'''+possiblecase[whichcase+1]+'''')  
    153    ENDIF ELSE widget_control, id, set_value={droplist_select:wvalue.droplist_select+event.out} 
    154    nothing = execute('set_droplist, event,'''+possiblecase[whichcase-1]+'''') 
    155    return 
    156 end 
    157233;---------------------------------------------------------------------- 
    158234FUNCTION cw_calendar_event, event 
    159 ;help,  /struct, event 
    160    widget_control, event.id, get_uvalue=uval 
    161    possiblecase = ['day', 'month', 'year', 'century', 'impossiblecase'] 
    162    whichcase = (where(possiblecase EQ uval.name))[0] 
    163    if event.out NE 0 then BEGIN ; we use the +/- button and we want to go out of the droplist: 
    164 ; to index -1 (event.out=-1) or to index droplist_number (event.out=1) 
    165 ; we try to move the droplist just right named possiblecase[whichcase+1] 
    166       if widget_info(event.handler,find_by_uname = possiblecase[whichcase+1]) EQ 0 then BEGIN 
     235; 
     236@cm_4cal 
     237  compile_opt strictarr, strictarrsubs  
     238; 
     239  winfo_id = widget_info(event.top, find_by_uname = 'infocal') 
     240  widget_control, winfo_id, get_uvalue = infowid 
     241  key_caltype = infowid.caltype 
     242; 
     243  widget_control, event.id, get_uvalue = uval 
     244; high frequency calendar 
     245  IF uval.name EQ 'step' THEN BEGIN  
     246    infowid.date = jul2date(event.index + infowid.fakecal) 
     247  ENDIF ELSE BEGIN 
     248; 
     249    possiblecase = ['day', 'month', 'year', 'impossiblecase'] 
     250    whichcase = (where(possiblecase EQ uval.name))[0] 
     251    if event.out NE 0 then BEGIN ; we use the +/- button and we want to go out of the combobox: 
     252; to index = -1 (event.out=-1) or to index = combobox_number (event.out=1) 
     253; we try to move the combobox just right, with name: possiblecase[whichcase+1] 
     254      if widget_info(event.handler, find_by_uname = possiblecase[whichcase+1]) EQ 0 then BEGIN 
    167255; this widget do not exist we set cyclicly the current widget to the 
    168 ; value 0 if event.out=1 or droplist_number-1 if event.out=-1 
    169          widget_control, event.id, get_value=widvalue 
    170          widget_control, event.id, set_value={droplist_select:(widvalue.droplist_number-1)*(event.out EQ -1)} 
     256; value 0 if event.out=1 or combobox_number-1 if event.out=-1 
     257        widget_control, event.id, get_value = widvalue 
     258        selected = (widvalue.combobox_number-1)*(event.out EQ -1) 
     259        widget_control, event.id, set_value = {combobox_select:selected} 
    171260      ENDIF ELSE move, event, possiblecase[whichcase+1] 
    172    ENDIF 
    173    if uval.name NE 'day' then begin 
     261    ENDIF 
     262; if we changed month(year), we need to update the day (and month) list 
     263    if uval.name NE 'day' then begin 
    174264      event.out = 0 
    175       for name = whichcase-1, 0, -1 do begin 
    176          if widget_info(event.handler,find_by_uname = possiblecase[name]) NE 0 then $ 
    177           set_droplist, event, possiblecase[name] 
     265      for name = whichcase-1, 0, -1 do BEGIN 
     266        if widget_info(event.handler, find_by_uname = possiblecase[name]) NE 0 then $ 
     267           set_cal_combobox, event, possiblecase[name] 
    178268      endfor 
    179    endif 
    180    return, {CW_CALENDAR, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    181             , VALUE:cw_calendar_get_value(event.handler)} 
    182 end 
    183 ;---------------------------------------------------------------------- 
    184 FUNCTION cw_calendar, parent, calendar, date0, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, _extra = ex 
    185 ; cheking for row and column keywords 
    186    column = keyword_set(column)*(1-keyword_set(row)) 
    187    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
    188 ; liste des mois, jours annee disponibles ds le calendrier 
    189    caldat, calendar,monthcal,daycal,yearcal 
    190    centurycal = yearcal/100 
    191 ; date de depart 
    192    if n_elements(date0) EQ 0 then date0 = calendar[0] 
    193    if (where(calendar EQ date0))[0] EQ -1 then date0 = calendar[0] 
    194    caldat, date0,month0,day0,year0 
    195    century0 = year0/100 
    196 ; test du type de calendrier 
    197    if n_elements(calendar) GT 1 then begin 
    198       if total(daycal eq 15) EQ n_elements(calendar) then monthly = 1 
    199    if total(monthcal EQ 6) EQ n_elements(calendar) AND n_elements(uniq(daycal, sort(daycal))) EQ 1 then BEGIN  & monthly = 1 & yearly = 1 & endif 
    200    if total(yearcal EQ 50) EQ n_elements(calendar) then BEGIN  & monthly = 1 & yearly = 1 & centuryly = 1 & ENDIF 
    201    endif 
     269    ENDIF 
     270; we update the date 
     271    infowid = get_cal_value(event.handler, winfo_id) 
     272  ENDELSE  
     273; 
     274  widget_control, winfo_id, set_uvalue = infowid 
     275  return, {CW_CALENDAR, ID:event.handler, TOP:event.top, HANDLER:0L $ 
     276           , VALUE:infowid.date, FAKECAL: infowid.fakecal} 
     277end 
     278;---------------------------------------------------------------------- 
     279;---------------------------------------------------------------------- 
     280FUNCTION cw_calendar, parent, calendar, jdate0, CALTYPE = CALTYPE, FAKECAL = fakecal, UVALUE = uvalue, UNAME = uname, _extra = ex 
     281; 
     282@cm_4cal 
     283; 
     284  compile_opt strictarr, strictarrsubs  
     285; 
     286  if keyword_set(caltype) then key_caltype = caltype 
     287; months days years found in the calendar 
     288  caldat, calendar, monthcal, daycal, yearcal, hourcal, mincal, scdcal 
     289; starting date 
     290  if n_elements(jdate0) EQ 0 then jdate0 = calendar[0] 
     291  if (where(calendar EQ jdate0))[0] EQ -1 then jdate0 = calendar[0] 
     292 
     293  caldat, jdate0, month0, day0, year0 
     294; test the type of calendar 
     295  if n_elements(calendar) GT 1 then BEGIN 
     296; each day have the same value 
     297    if n_elements(uniq(daycal, sort(daycal))) EQ 1 then monthly = 1 
     298; each month and each day have the same value 
     299    if keyword_set(monthly) AND n_elements(uniq(monthcal, sort(monthcal))) EQ 1 then yearly = 1 
     300  endif 
    202301;--------------------------------------------------------------------------------------- 
    203    if NOT keyword_set(uvalue) then uvalue = '' 
    204    if NOT keyword_set(uname) then uname = '' 
    205    base = widget_base(parent, ROW = row, COLUMN = column $ 
     302  if NOT keyword_set(uvalue) then uvalue = {dummy:''} 
     303  if NOT keyword_set(uname) then uname = '' 
     304  base0 = widget_base(parent, /ROW $ 
    206305                      , EVENT_FUNC = 'cw_calendar_event' $ 
    207                       , FUNC_GET_VALUE='cw_calendar_get_value' $ 
    208                       , PRO_SET_VALUE='cw_calendar_set_value' $ 
    209                       , UVALUE = uvalue, UNAME = uname, _extra = ex)    
    210 ;-------------day---------------- 
    211    if NOT keyword_set(monthly)  then begin 
    212       dayindex = where(monthcal EQ month0 AND yearcal EQ year0 AND centurycal EQ century0) 
     306                      , FUNC_GET_VALUE = 'cw_calendar_get_value' $ 
     307                      , PRO_SET_VALUE = 'cw_calendar_set_value' $ 
     308                      , UVALUE = uvalue, UNAME = uname, space = 0, _extra = ex) 
     309; 
     310 
     311  if n_elements(fakecal) eq 0 then fakecal = 0 
     312  base = widget_base(base0, space = 0, uname = 'infocal' $ 
     313                     , uvalue = {calendar:calendar, date:jul2date(jdate0), fakecal:fakecal, caltype: key_caltype}) 
     314; 
     315  IF keyword_set(fakecal) THEN BEGIN  
     316    cmbbid = cw_combobox_pm(base, UVALUE = {name:'step'}, UNAME = 'step' $ 
     317                            , value = strtrim(indgen(n_elements(calendar)), 1)) 
     318    widget_control, cmbbid, set_value = {combobox_select:(where(calendar EQ jdate0))[0]} 
     319  ENDIF ELSE BEGIN  
     320; 
     321    vallen = widget_info(base, string_size = 'm') 
     322;-------------day----------------- 
     323    if NOT keyword_set(monthly)  then begin 
     324      dayindex = where(monthcal EQ month0 AND yearcal EQ year0) 
    213325      currentday = daycal[dayindex] 
    214       currentday = string(currentday) 
    215       for i = 0, n_elements(currentday)-1 do currentday[i] = strtrim(currentday[i], 1) 
    216       rien = cw_droplist_pm(base,UVALUE = {name:'day', calendar:calendar, index:dayindex}, UNAME = 'day', value = currentday) 
    217       widget_control, rien, set_value = {droplist_select:(where(long(currentday) EQ day0))[0]} 
    218    endif 
    219 ;-------------month---------------- 
    220    if NOT keyword_set(yearly)  then BEGIN 
    221 ; les mois du siecle en cours et de l''anne en cours 
    222       monthindex = where(yearcal EQ year0 AND centurycal EQ century0) 
     326      currentday = strtrim(currentday, 1) 
     327      cmbbid = cw_combobox_pm(base, UVALUE = {name:'day'}, UNAME = 'day', value = currentday) 
     328      widget_control, cmbbid, set_value = {combobox_select:(where(long(currentday) EQ day0))[0]} 
     329    endif 
     330;-------------month--------------- 
     331    if NOT keyword_set(yearly)  then BEGIN 
     332      monthindex = where(yearcal EQ year0) 
    223333      currentmonth = long(monthcal[monthindex]) 
    224 ; on supprime les elements repetes 
     334; we suppress the repeted months 
    225335      monthindexbis = uniq(currentmonth, sort(currentmonth)) 
    226336      monthindex = monthindex[monthindexbis] 
    227337      currentmonth = currentmonth[monthindexbis] 
    228 ; on cree une droplist avec comme valeur tous les mois possibles de 
    229 ; l''annee courrante (year0) 
    230 ;       rien = cw_droplist_pm(base,UVALUE = {name:'month', calendar:calendar, index:monthindex}, UNAME = 'month', value = string(format='(C(CMoA))',31*indgen(12))) 
    231       rien = cw_droplist_pm(base,UVALUE = {name:'month', calendar:calendar, index:monthindex}, UNAME = 'month', value = string(format='(C(CMoA))',31*(currentmonth-1))) 
    232 ; on possitionne le mois courrant sur le bon mois parmis les mois 
    233 ; possibles de l''annee courrante 
    234       widget_control, rien, set_value = {droplist_select:(where(long(currentmonth) EQ month0))[0]} 
    235    endif 
     338      xoff = (34 + 2*vallen[0])*(1-keyword_set(monthly)) 
     339      cmbbid = cw_combobox_pm(base, UVALUE = {name:'month'}, UNAME = 'month', value = string(format = '(C(CMoA))', 31*(currentmonth-1)), xoffset = xoff) 
     340      widget_control, cmbbid, set_value = {combobox_select:(where(long(currentmonth) EQ month0))[0]} 
     341    endif 
    236342;-------------year---------------- 
    237    if NOT keyword_set(centuryly)  then begin 
    238       if n_elements(centurycal[uniq(centurycal, sort(centurycal))]) NE 1 then BEGIN  
    239          yearcal = yearcal-centurycal*100 
    240          year0   = year0-centurycal*100 
    241       endif 
    242       yearindex = where(centurycal EQ century0) 
    243       currentyear = yearcal[yearindex] 
    244       yearindexbis = uniq(currentyear, sort(long(currentyear))) 
    245       yearindex = yearindex[yearindexbis] 
    246       currentyear = currentyear[yearindexbis] 
    247       currentyear = string(currentyear) 
    248       for i = 0, n_elements(currentyear)-1 do currentyear[i] = strtrim(currentyear[i], 1) 
    249       rien = cw_droplist_pm(base,UVALUE = {name:'year', calendar:calendar, index:yearindex}, UNAME = 'year', value = currentyear) 
    250       widget_control, rien, set_value = {droplist_select:(where(long(currentyear) EQ year0))[0]} 
    251    endif 
    252 ;-------------century---------------- 
    253    centuryindex = uniq(centurycal, sort(long(centurycal))) 
    254    currentcentury = centurycal[centuryindex] 
    255    currentcentury = string(currentcentury) 
    256    for i = 0, n_elements(currentcentury)-1 do currentcentury[i] = strtrim(currentcentury[i], 1) 
    257    if n_elements(uniq(centurycal, sort(centurycal))) NE 1 then BEGIN 
    258       rien = cw_droplist_pm(base,UVALUE = {name:'century', calendar:calendar, index:centuryindex}, UNAME = 'century', value = currentcentury) 
    259       widget_control, rien, set_value = {droplist_select:(where(long(currentcentury) EQ century0))[0]} 
    260    endif 
     343    yearindex = uniq(yearcal, sort(yearcal)) 
     344    currentyear = strtrim(yearcal[yearindex], 1) 
     345    xoff = (34 + 2*vallen[0])*(1-keyword_set(monthly)) + (33 + 3*vallen[0])*(1-keyword_set(yearly)) 
     346    cmbbid = cw_combobox_pm(base, UVALUE = {name:'year'}, UNAME = 'year', value = currentyear, xoffset = xoff) 
     347    widget_control, cmbbid, set_value = {combobox_select:(where(long(currentyear) EQ year0))[0]} 
    261348;----------------------------- 
    262 ; 
    263 ; 
    264    return, base 
    265 end 
     349  ENDELSE 
     350; 
     351  return, base 
     352end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_domain.pro

    r51 r69  
    4040;********************************************************************* 
    4141pro cw_domain_set_value, id, value 
    42 @common 
     42@cm_4mesh 
     43; 
     44   topid = findtopid(id) 
     45   widget_control, topid, get_uvalue = top_uvalue 
     46;------------------------------------------------ 
     47; make sure that we have the good grid stored in the cm_4mesh common parameters. 
     48   currentfile = extractatt(top_uvalue, 'currentfile') 
     49   currentgrid = *(extractatt(top_uvalue, 'meshparameters'))[currentfile] 
     50   change = changegrid(currentgrid) 
    4351;------------------------------------------------ 
    4452; quel est le type de boxzoom? 
    45    topid = findtopid(id) 
    46    widget_control, topid, get_uvalue=top_uvalue 
    4753   currentplot = (extractatt(top_uvalue, 'smallin'))[2]-1 
    4854   options = extractatt(top_uvalue, 'options')    
     
    6268      lonn1 = firstxt 
    6369      lonn2 = lastxt 
    64       xtitle = 'x index' 
     70      xtitle = 'x ind' 
    6571   ENDELSE 
    6672   IF ytype EQ  'geographic' then begin 
     
    7177      latt1 = firstyt 
    7278      latt2 = lastyt 
    73       ytitle = 'y index' 
     79      ytitle = 'y ind' 
    7480   ENDELSE 
    7581;------------------------------------------------ 
     
    8894      6:boxzoom = Value 
    8995      Else:BEGIN  
    90          rien = report('Mauvaise Definition de Boxzoom') 
     96         rien = report('Wrong Definition of Boxzoom') 
    9197      END 
    9298   ENDCASE 
     
    187193   ENDELSE 
    188194; 
    189 ; 
    190195   if n_elements(boxzoom) EQ 4 then return 
    191196; 
    192 ; la profondeur 
    193 ; 
    194    depthlev1id = widget_info(id,find_by_uname = 'depthlev1') 
    195    depthlev2id = widget_info(id,find_by_uname = 'depthlev2') 
    196    depth1id = widget_info(id,find_by_uname = 'depth1') 
    197    depth2id = widget_info(id,find_by_uname = 'depth2') 
    198    widget_control, depthlev1id, get_uvalue = depthlev1_uval 
    199 ; a-t-on change de type de grille ?, faut=il changerl''axe verticale? 
    200    widget_control, findtopid(id),  get_uvalue = top_uvalue 
    201    zgrid = extractatt(top_uvalue, 'zgrid') 
    202    grid_t = zgrid EQ 'T' 
    203    if grid_t NE depthlev1_uval.grid_t then BEGIN 
    204       widget_control, depthlev2id, get_uvalue = depthlev2_uval 
    205       depthlev1_uval.grid_t = grid_t 
    206       depthlev2_uval.grid_t = grid_t 
    207 ; 
    208       if grid_t then gdep = gdept ELSE gdep = gdepw 
     197; depth 
     198; 
     199   dthlv1id = widget_info(id, find_by_uname = 'dthlv1') 
     200   dthlv2id = widget_info(id, find_by_uname = 'dthlv2') 
     201   depth1id = widget_info(id, find_by_uname = 'depth1') 
     202   depth2id = widget_info(id, find_by_uname = 'depth2') 
     203; which type of point? 
     204   widget_control, dthlv1id, get_uvalue = dthlv1_uval 
     205; get the new axis 
     206   if dthlv1_uval.grid_t EQ 1 then gdep = gdept ELSE gdep = gdepw 
     207 ; Did we change the vertical axis? 
     208   widget_control, dthlv1id, get_value = dthlv1_value 
     209   gdep1 = floor(fix(dthlv1_value.combobox_value)) 
     210   IF array_equal(gdep1, floor(gdep)) NE 1 THEN BEGIN 
    209211      gdep1 = floor(gdep) 
    210212      gdep2 = ceil(gdep) 
    211       identique = where(gdep2-gdep1 EQ 0) 
    212       if identique[0] NE -1 then gdep2[identique] = gdep2[identique] +1 
    213       depthlev1_uval.value = gdep1 
    214       depthlev2_uval.value = gdep2 
    215 ; 
    216       widget_control, depthlev1id, set_value = {value:strtrim(gdep1, 1)} 
    217       widget_control, depthlev2id, set_value = {value:strtrim(gdep2, 1)} 
    218 ; 
    219       widget_control, depthlev1id, set_uvalue = depthlev1_uval 
    220       widget_control, depthlev2id, set_uvalue = depthlev2_uval 
    221    ENDIF ELSE BEGIN  
    222       gdep1 = depthlev1_uval.value 
    223       gdep2 = gdep1+1 
    224    ENDELSE 
     213      same = where(gdep2-gdep1 EQ 0) 
     214      if same[0] NE -1 then gdep2[same] = gdep2[same] + 1 
     215      widget_control, dthlv1id, set_value = {value:strtrim(gdep1, 1)} 
     216      widget_control, dthlv2id, set_value = {value:strtrim(gdep2, 1)} 
     217   ENDIF ELSE gdep2 = gdep1+1 
    225218; on s''assure que les profs donnees contiennent bien au moins un 
    226219; niveau. 
     
    238231   if indice1 EQ indice2 then BEGIN 
    239232      if (where(gdep1 GE boxzoom[4] AND gdep2 LE boxzoom[5]))[0]  EQ -1 then begin 
    240          indice1 = 0 > (indice1-(grid_t EQ 1)) 
     233         indice1 = 0 > (indice1-(dthlv1_uval.grid_t EQ 1)) 
    241234         indice2 = indice1 
    242235      endif 
     
    246239; maintenant que les values et les indexes sont definis proprement, 
    247240; on peut les appliquer 
    248    widget_control, depthlev1id, set_value = {droplist_select:indice1} 
    249    widget_control, depthlev2id, set_value = {droplist_select:indice2} 
     241   widget_control, dthlv1id, set_value = {combobox_select:indice1} 
     242   widget_control, dthlv2id, set_value = {combobox_select:indice2} 
    250243; controler les min et les max des sliders... 
    251244   if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] 
     
    265258FUNCTION cw_domain_get_value, id 
    266259   box = lonarr(6) 
    267    possiblecase = ['lon1', 'lon2','lat1', 'lat2','depth1','depth2'] 
     260   possiblecase = ['lon1', 'lon2', 'lat1', 'lat2', 'depth1', 'depth2'] 
    268261   for i = 0, 5 do begin 
    269       widget_control,widget_info(id,find_by_uname = possiblecase[i]) $ 
     262      widget_control, widget_info(id, find_by_uname = possiblecase[i]) $ 
    270263       , get_value = value 
    271264      box[i] = value.value 
     
    278271; help,  /struct, event 
    279272   if (where(tag_names(event) EQ 'OUT'))[0] NE -1 then if event.out NE 0 then return,  -1 
    280    widget_control, event.id, get_uvalue=uval 
     273   widget_control, event.id, get_uvalue = uval 
    281274   case uval.name of 
    282275      'lon1':widget_control,widget_info(event.handler,find_by_uname = 'lon2') $ 
     
    306299         widget_control, id, set_value = value.slider_min_max[1] 
    307300      END 
    308       'depthlev1':BEGIN 
     301      'dthlv1':BEGIN 
    309302; ids... 
    310303         depth1id = widget_info(event.handler,find_by_uname = 'depth1') 
    311304         depth2id = widget_info(event.handler,find_by_uname = 'depth2') 
    312          depthlev2id = widget_info(event.handler,find_by_uname = 'depthlev2') 
    313 ; faut-il changer depthlev2 ? 
    314          widget_control, depthlev2id, get_value = depthlev2_value 
    315          if depthlev2_value.droplist_select LT event.index then BEGIN 
    316 ; on redefinie la valeur de depthlev2id 
    317             widget_control, depthlev2id, set_value = {droplist_select:event.index} 
     305         dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') 
     306; faut-il changer dthlv2 ? 
     307         widget_control, event.id, get_value = dthlv1_value 
     308         gdep1 = fix(dthlv1_value.combobox_value) 
     309         widget_control, dthlv2id, get_value = dthlv2_value 
     310         gdep2 = fix(dthlv2_value.combobox_value) 
     311         if dthlv2_value.combobox_index LT event.index then BEGIN 
     312; on redefinie la valeur de dthlv2id 
     313            widget_control, dthlv2id, set_value = {combobox_select:event.index} 
    318314; donc on redefinit la valeur et le max du slider 2 
    319             widget_control, depthlev2id, get_uvalue = depthlev2_uval 
    320315            if event.index EQ jpk-1 then BEGIN  
    321316               max = max([gdept, gdepw]) 
    322317               max = strtrim(string(max,format='(e8.0)'), 1) 
    323318               max = float('1'+strmid(max, 1))+float(max) 
    324             ENDIF ELSE max = depthlev2_uval.value[event.index+1]-1 
     319            ENDIF ELSE max = gdep2[event.index+1]-1 
    325320            widget_control, depth2id $ 
    326              , set_value = {slider_max:max, value:depthlev2_uval.value[event.index]} 
     321             , set_value = {slider_max:max, value:gdep2[event.index]} 
    327322; du coup on redefinie donc le max du slider 1  
    328             widget_control, depth1id, set_value = {slider_max:uval.value[event.index]} 
     323            widget_control, depth1id, set_value = {slider_max:gdep1[event.index]} 
    329324         END  
    330325; on redefinie la valeur et le min du slider depth 1 
    331          if event.index EQ 0 then min = 0 ELSE min = uval.value[event.index-1]+1 
    332          widget_control, depth1id, set_value = {slider_min:min, value:uval.value[event.index]} 
     326         if event.index EQ 0 then min = 0 ELSE min = gdep1[event.index-1]+1 
     327         widget_control, depth1id, set_value = {slider_min:min, value:gdep1[event.index]} 
    333328; du coup on change aussi la valeur du min du slider depth 2 
    334          widget_control, depth2id, set_value = {slider_min:uval.value[event.index]+1} 
    335       END 
    336       'depthlev2':BEGIN 
     329         widget_control, depth2id, set_value = {slider_min:gdep1[event.index]+1} 
     330      END 
     331      'dthlv2':BEGIN 
    337332; ids... 
    338333         depth1id = widget_info(event.handler,find_by_uname = 'depth1') 
    339334         depth2id = widget_info(event.handler,find_by_uname = 'depth2') 
    340          depthlev1id = widget_info(event.handler,find_by_uname = 'depthlev1') 
    341 ; faut-il changer depthlev1 ? 
    342          widget_control, depthlev1id, get_value = depthlev1_value 
    343          if depthlev1_value.droplist_select GT event.index then BEGIN 
    344 ; on redefinie la valeur de depthlev1id 
    345             widget_control, depthlev1id, set_value = {droplist_select:event.index} 
     335         dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') 
     336; faut-il changer dthlv1 ? 
     337         widget_control, dthlv1id, get_value = dthlv1_value 
     338         gdep1 = fix(dthlv1_value.combobox_value) 
     339         widget_control, event.id, get_value = dthlv2_value 
     340         gdep2 = fix(dthlv2_value.combobox_value) 
     341         if dthlv1_value.combobox_index GT event.index then BEGIN 
     342; on redefinie la valeur de dthlv1id 
     343            widget_control, dthlv1id, set_value = {combobox_select:event.index} 
    346344; donc on redefinit la valeur et le min du slider 1 
    347             widget_control, depthlev1id, get_uvalue = depthlev1_uval 
    348             if event.index EQ 0 then min = 0 ELSE min = uval.value[event.index-1] 
     345            if event.index EQ 0 then min = 0 ELSE min = gdep2[event.index-1] 
    349346            widget_control, depth1id $ 
    350              , set_value = {slider_min:min, value:depthlev1_uval.value[event.index]} 
     347             , set_value = {slider_min:min, value:gdep1[event.index]} 
    351348; du coup on redefinie donc le min du slider 2 
    352             widget_control, depth2id, set_value = {slider_min:uval.value[event.index]} 
     349            widget_control, depth2id, set_value = {slider_min:gdep2[event.index]} 
    353350         END  
    354351; on redefinie la valeur et le max du slider depth 2 
     
    357354            max = strtrim(string(max,format='(e8.0)'), 1) 
    358355            max = float('1'+strmid(max, 1))+float(max) 
    359          ENDIF ELSE max = uval.value[event.index+1]-1 
    360          widget_control, depth2id, set_value = {slider_max:max, value:uval.value[event.index]} 
     356         ENDIF ELSE max = gdep2[event.index+1]-1 
     357         widget_control, depth2id, set_value = {slider_max:max, value:gdep2[event.index]} 
    361358; du coup on change aussi la valeur du max du slider depth 1 
    362          widget_control, depth1id, set_value = {slider_max:uval.value[event.index]-1} 
     359         widget_control, depth1id, set_value = {slider_max:gdep2[event.index]-1} 
    363360      END 
    364361      'depth1':BEGIN 
    365362; ids... 
    366363         depth2id = widget_info(event.handler,find_by_uname = 'depth2') 
    367          depthlev1id = widget_info(event.handler,find_by_uname = 'depthlev1') 
    368 ; doit-on changer depthlev1 ? 
    369          widget_control, depthlev1id, get_value = depthlev1_value 
    370          widget_control, depthlev1id, get_uvalue = depthlev1_uval 
    371          rien = where(depthlev1_uval.value LT event.value, indice) 
     364         dthlv1id = widget_info(event.handler,find_by_uname = 'dthlv1') 
     365; doit-on changer dthlv1 ? 
     366         widget_control, dthlv1id, get_value = dthlv1_value 
     367         gdep1 = fix(dthlv1_value.combobox_value) 
     368         rien = where(gdep1 LT event.value, indice) 
    372369         indice = indice < (jpk-1) 
    373          if indice NE depthlev1_value.droplist_select then begin 
     370         if indice NE dthlv1_value.combobox_index then begin 
    374371; on change le min de depth2 
    375             widget_control, depth2id, set_value = {slider_min:depthlev1_uval.value[indice]+1} 
    376 ; on redefinie la valeur de depthlev1id 
    377             widget_control, depthlev1id, set_value = {droplist_select:indice} 
     372            widget_control, depth2id, set_value = {slider_min:gdep1[indice]+1} 
     373; on redefinie la valeur de dthlv1id 
     374            widget_control, dthlv1id, set_value = {combobox_select:indice} 
    378375; donc on redefinit le min du slider 1 
    379             if indice EQ 0 then min = 0 ELSE min = depthlev1_uval.value[indice-1]+1 
     376            if indice EQ 0 then min = 0 ELSE min = gdep1[indice-1]+1 
    380377            widget_control, event.id, set_value = {slider_min:min} 
    381378         endif 
     
    384381; ids... 
    385382         depth1id = widget_info(event.handler,find_by_uname = 'depth1') 
    386          depthlev2id = widget_info(event.handler,find_by_uname = 'depthlev2') 
    387 ; doit-on changer depthlev2 ? 
    388          widget_control, depthlev2id, get_value = depthlev2_value 
    389          widget_control, depthlev2id, get_uvalue = depthlev2_uval 
    390          rien = where(depthlev2_uval.value LE event.value, indice) 
     383         dthlv2id = widget_info(event.handler,find_by_uname = 'dthlv2') 
     384; doit-on changer dthlv2 ? 
     385         widget_control, dthlv2id, get_value = dthlv2_value 
     386         gdep2 = fix(dthlv2_value.combobox_value) 
     387         rien = where(gdep2 LE event.value, indice) 
    391388         indice = 0 > (indice-1) 
    392          if indice NE depthlev2_value.droplist_select then begin 
     389         if indice NE dthlv2_value.combobox_index then begin 
    393390; on change le max de depth1 
    394             widget_control, depth1id, set_value = {slider_max:depthlev2_uval.value[indice]-1} 
    395 ; on redefinie la valeur de depthlev2id 
    396             widget_control, depthlev2id, set_value = {droplist_select:indice} 
     391            widget_control, depth1id, set_value = {slider_max:gdep2[indice]-1} 
     392; on redefinie la valeur de dthlv2id 
     393            widget_control, dthlv2id, set_value = {combobox_select:indice} 
    397394; donc on redefinit le max du slider 2 
    398395            if indice EQ jpk-1 then BEGIN  
     
    400397               max = strtrim(string(max,format='(e8.0)'), 1) 
    401398               max = float('1'+strmid(max, 1))+float(max) 
    402             ENDIF ELSE max = depthlev2_uval.value[indice+1]-1 
     399            ENDIF ELSE max = gdep2[indice+1]-1 
    403400            widget_control, event.id, set_value = {slider_max:max} 
    404401         endif 
     
    412409end 
    413410;********************************************************************* 
    414 FUNCTION cw_domain, parent, BOXZOOM = boxzoom, STRICT = strict, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, UNZOOM = unzoom, _extra = ex 
    415 ; 
    416 @common 
    417 ; cheking exclusive keywords 
    418    column = keyword_set(column)*(1-keyword_set(row)) 
    419    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
     411FUNCTION cw_domain, parent, BOXZOOM = boxzoom, STRICT = strict, UVALUE = uvalue, UNAME = uname, UNZOOM = unzoom, _extra = ex 
     412; 
     413@cm_4mesh 
     414@cm_4data 
     415; 
    420416; def de la boxzoom 
    421    if NOT keyword_set(boxzoom) then boxzoom = [lon1, lon2, lat1, lat2 $ 
    422                                            , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ] 
    423    Case N_Elements(Boxzoom) OF 
    424       0:boxzoom = [lon1, lon2, lat1, lat2, vert1, vert2] 
    425       1:boxzoom=[lon1, lon2, lat1, lat2, 0.,boxzoom[0]] 
    426       2:boxzoom=[lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] 
    427       4:boxzoom=[Boxzoom, vert1, vert2] 
    428       5:boxzoom=[Boxzoom[0:3], 0, Boxzoom[4]] 
    429       6: 
    430       Else: return, report('Mauvaise Definition de Boxzoom') 
    431    ENDCASE 
    432 ; 
    433    boxzoom[0] = floor(boxzoom[0]) 
    434    boxzoom[1] = ceil(boxzoom[1]) 
    435    boxzoom[2] = floor(boxzoom[2]) 
    436    boxzoom[3] = ceil(boxzoom[3]) 
    437    boxzoom[4] = floor(boxzoom[4]) 
    438    boxzoom[5] = ceil(boxzoom[5]) 
    439 ;------------------------------------------------ 
    440    if NOT keyword_set(uvalue) then uvalue = '' 
    441    if NOT keyword_set(uname) then uname = '' 
    442    base = widget_base(parent, /row  $ 
    443                       , space = 1,  xpad = 1,  ypad = 1 $ 
    444                       , EVENT_FUNC = 'cw_domain_event' $ 
    445                       , FUNC_GET_VALUE='cw_domain_get_value' $ 
    446                       , PRO_SET_VALUE='cw_domain_set_value' $ 
    447                       , UVALUE = uvalue, UNAME = uname, _extra = ex)    
     417  Case N_Elements(Boxzoom) OF 
     418    0:boxzoom = [lon1, lon2, lat1, lat2 $ 
     419                 , min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]]) ] 
     420    1:boxzoom = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] 
     421    2:boxzoom = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]] 
     422    4:boxzoom = [Boxzoom, vert1, vert2] 
     423    5:boxzoom = [Boxzoom[0:3], 0, Boxzoom[4]] 
     424    6: 
     425    Else: return, report('Mauvaise Definition de Boxzoom') 
     426  ENDCASE 
     427  IF total(Boxzoom) EQ 0 THEN $ 
     428     boxzoom = [lon1, lon2, lat1, lat2, min([gdepw[0], gdept[0]]), max([gdepw[0], gdept[0]])] 
     429; 
     430  boxzoom[0] = floor(boxzoom[0]) 
     431  boxzoom[1] = ceil(boxzoom[1]) 
     432  boxzoom[2] = floor(boxzoom[2]) 
     433  boxzoom[3] = ceil(boxzoom[3]) 
     434  boxzoom[4] = floor(boxzoom[4]) 
     435  boxzoom[5] = ceil(boxzoom[5]) 
     436;------------------------------------------------ 
     437  if NOT keyword_set(uvalue) then uvalue = '' 
     438  if NOT keyword_set(uname) then uname = '' 
     439  base = widget_base(parent, row = 2, space = 0 $ 
     440                     , EVENT_FUNC = 'cw_domain_event' $ 
     441                     , FUNC_GET_VALUE = 'cw_domain_get_value' $ 
     442                     , PRO_SET_VALUE = 'cw_domain_set_value' $ 
     443                     , UVALUE = uvalue, UNAME = uname, _extra = ex)    
     444;------------------------------------------------ 
     445  baseh = widget_base(base, column = 1+keyword_set(unzoom), space = 0) 
     446;------------------------------------------------ 
     447  baseh1 = widget_base(baseh, row = 2, space = 0) 
    448448;-------------longitude--------------------------- 
    449    basehori = widget_base(base, ROW = row, COLUMN = column) 
    450 ;-------------longitude--------------------------- 
    451    min = floor(min([glamt,glamf], max = max)) 
    452    max = ceil(max) 
    453    lonbase = widget_base(basehori, /ROW, space = 1, xpad = 1, ypad = 1, uname = 'lonbase') 
    454    lon1id = cw_slider_pm(lonbase,value=min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ 
    455                        , uvalue={name:'lon1', strict:keyword_set(strict)},uname ='lon1' $ 
    456                        , title = 'lon1', minimum = min $ 
    457                        , maximum = (boxzoom[1] < max)-keyword_set(strict)) 
    458    lon2id = cw_slider_pm(lonbase,value=((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ 
    459                        , uvalue={name:'lon2', strict:keyword_set(strict)} $ 
    460                        , uname='lon2', title = 'lon2', maximum = max $ 
    461                        , minimum = (min > boxzoom[0])+keyword_set(strict)) 
    462    widget_control, lonbase, set_uvalue = {name:'geographic'} 
     449  min = floor(min([glamt, glamf], max = max)) 
     450  max = ceil(max) 
     451  IF max-min EQ 361 AND keyword_set(key_periodic) THEN max = max-1 
     452  lonbase = widget_base(baseh1, column = 2, space = 0, uname = 'lonbase', uvalue = {name:'geographic'}) 
     453  lon1id = cw_slider_pm(lonbase, value = min > boxzoom[0] < ((boxzoom[1] < max)-keyword_set(strict)) $ 
     454                        , uvalue = {name:'lon1', strict:keyword_set(strict)}, uname = 'lon1' $ 
     455                        , title = 'lon1', minimum = min $ 
     456                        , maximum = (boxzoom[1] < max)-keyword_set(strict)) 
     457  lon2id = cw_slider_pm(lonbase, value = ((min > boxzoom[0])+keyword_set(strict)) > boxzoom[1] < max $ 
     458                        , uvalue = {name:'lon2', strict:keyword_set(strict)} $ 
     459                        , uname = 'lon2', title = 'lon2', maximum = max $ 
     460                        , minimum = (min > boxzoom[0])+keyword_set(strict)) 
    463461;---------------latitude------------------------- 
    464    min = floor(min([gphit,gphif], max = max)) 
    465    max = ceil(max) 
    466    latbase = widget_base(basehori, /ROW, space = 1, xpad = 1, ypad = 1, uname = 'latbase') 
    467    lat1id = cw_slider_pm(latbase,value=min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ 
    468                        , uvalue={name:'lat1', strict:keyword_set(strict)},uname ='lat1' $ 
    469                        , title = 'lat1', minimum =min $ 
    470                        , maximum = ((boxzoom[3] < max)-keyword_set(strict))) 
    471    lat2id = cw_slider_pm(latbase,value=((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ 
    472                        , uvalue={name:'lat2', strict:keyword_set(strict)} $ 
    473                        , uname ='lat2', title = 'lat2' ,maximum =  max $ 
    474                        , minimum =(min > boxzoom[2])+keyword_set(strict)) 
    475    widget_control, latbase, set_uvalue = {name:'geographic'} 
     462  min = floor(min([gphit, gphif], max = max)) 
     463  max = ceil(max) 
     464  latbase = widget_base(baseh1, column = 2, space = 0, uname = 'latbase', uvalue = {name:'geographic'}) 
     465  lat1id = cw_slider_pm(latbase, value = min > boxzoom[2] < ((boxzoom[3] < max)-keyword_set(strict)) $ 
     466                        , uvalue = {name:'lat1', strict:keyword_set(strict)}, uname = 'lat1' $ 
     467                        , title = 'lat1', minimum = min $ 
     468                        , maximum = ((boxzoom[3] < max)-keyword_set(strict))) 
     469  lat2id = cw_slider_pm(latbase, value = ((min > boxzoom[2])+keyword_set(strict)) > boxzoom[3] < max $ 
     470                        , uvalue = {name:'lat2', strict:keyword_set(strict)} $ 
     471                        , uname = 'lat2', title = 'lat2', maximum =  max $ 
     472                        , minimum = (min > boxzoom[2])+keyword_set(strict)) 
    476473;----------------unzoom------------------------ 
    477    if keyword_set(unzoom) then rien = widget_button(basehori,value='unzoom', uvalue={name:'unzoom'}) 
     474  if keyword_set(unzoom) then rien = widget_button(baseh, value = 'unzoom', uvalue = {name:'unzoom'}, xsize = 60, ysize = 110) 
    478475;----------------depth------------------------ 
    479    basevert = widget_base(base, ROW = row, COLUMN = column) 
    480    basedepth = widget_base(basevert, /row) 
    481 ; 
    482    if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept 
    483    gdep1 = floor(gdep) 
    484    gdep2 = ceil(gdep) 
    485    identique = where(gdep2-gdep1 EQ 0) 
    486    if identique[0] NE -1 then gdep2[identique] = gdep2[identique] +1 
    487    sgdep1 = strtrim(gdep1, 1) 
    488    sgdep2 = strtrim(gdep2, 1) 
    489 ; 
    490    basedepthdrop = widget_base(basedepth, column = column,  row = row) 
    491 ; 
    492    dephtid=cw_droplist_pm(basedepthdrop,value=''+sgdep1, uvalue={name:'depthlev1', value:gdep1, grid_t:strupcase(vargrid) NE 'W'}, uname='depthlev1') 
    493    rien = where(gdep1 LT boxzoom[4], indice1) 
    494    indice1 = indice1 < (jpk-1) 
    495    widget_control, dephtid, set_value = {droplist_select:indice1} 
    496 ; 
    497    dephtid=cw_droplist_pm(basedepthdrop,value=''+sgdep2, uvalue={name:'depthlev2', value:gdep2, grid_t:strupcase(vargrid) NE 'W'}, uname='depthlev2') 
    498    rien = where(gdep2 LE boxzoom[5], indice2) 
    499    indice2 = indice1 > (indice2-1) 
    500    widget_control, dephtid, set_value = {droplist_select:indice2} 
    501 ; 
    502    basedepthslid = widget_base(basedepth, column = column,  row = row) 
    503 ; 
    504    if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] 
    505    max1 = (min1+1) > gdep1[indice2] 
    506    rien = cw_slider_pm(basedepthslid, value= min1 > boxzoom[4] < (boxzoom[5] < max1) $ 
    507                        , uvalue = {name:'depth1'}, uname = 'depth1' $ 
    508                        , title = 'depth1', minimum = min1, maximum = max1) 
    509 ; 
    510    min2 = gdep2[indice1] 
    511    if indice2 EQ jpk-1 then BEGIN  
    512       max2 = max([gdept, gdepw]) 
    513       max2 = strtrim(string(max2,format='(e8.0)'), 1) 
    514       max2 = float('1'+strmid(max2, 1))+float(max2) 
    515    ENDIF ELSE max2 = gdep1[indice2+1] 
    516    if max2 EQ min2 then max2 = min2+1 
    517    rien = cw_slider_pm(basedepthslid, value= (min2 > boxzoom[4]) > boxzoom[5] < max2 $ 
    518                        , uvalue={name:'depth2'}, minimum = min2 $ 
    519                        , uname = 'depth2', title = 'depth2' ,maximum =  max2) 
     476  basez = widget_base(base, column = 3, space = 0, /base_align_center) 
     477;------------------------------------------------ 
     478  basezdrp = widget_base(basez, row = 2, space = 0) 
     479; 
     480  if strupcase(vargrid) EQ 'W' then gdep = gdepw ELSE gdep = gdept 
     481  gdep1 = floor(gdep) 
     482  gdep2 = ceil(gdep) 
     483  same = where(gdep2-gdep1 EQ 0) 
     484  if same[0] NE -1 then gdep2[same] = gdep2[same] +1 
     485  sgdep1 = strtrim(gdep1, 1) 
     486  sgdep2 = strtrim(gdep2, 1) 
     487; 
     488  dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep1, uvalue = {name:'dthlv1', grid_t:strupcase(vargrid) NE 'W'}, uname = 'dthlv1') 
     489  rien = where(gdep1 LT boxzoom[4], indice1) 
     490  indice1 = indice1 < (jpk-1) 
     491  widget_control, dephtid, set_value = {combobox_select:indice1} 
     492; 
     493  dephtid = cw_combobox_pm(basezdrp, value = ''+sgdep2, uvalue = {name:'dthlv2'}, uname = 'dthlv2') 
     494  rien = where(gdep2 LE boxzoom[5], indice2) 
     495  indice2 = indice1 > (indice2-1) 
     496  widget_control, dephtid, set_value = {combobox_select:indice2} 
     497; 
     498;------ 
     499;   basedepthslid = widget_base(base, column = 2, space = 0) 
     500  strminlen = max(strlen(strtrim(round([gdept, gdepw]), 1))) 
     501; 
     502  if indice1 EQ 0 then min1 = 0 ELSE min1 = gdep2[indice1-1] 
     503  max1 = (min1+1) > gdep1[indice2] 
     504  rien = cw_slider_pm(basez, value = min1 > boxzoom[4] < (boxzoom[5] < max1) $ 
     505                      , uvalue = {name:'depth1'}, uname = 'depth1', strminlen = strminlen $ 
     506                      , title = 'z1', minimum = min1, maximum = max1) 
     507; 
     508  min2 = gdep2[indice1] 
     509  if indice2 EQ jpk-1 then BEGIN  
     510    max2 = max([gdept, gdepw]) 
     511    max2 = strtrim(string(max2, format = '(e8.0)'), 1) 
     512    max2 = float('1'+strmid(max2, 1))+float(max2) 
     513  ENDIF ELSE max2 = gdep1[indice2+1] 
     514  if max2 EQ min2 then max2 = min2+1 
     515  rien = cw_slider_pm(basez, value = (min2 > boxzoom[4]) > boxzoom[5] < max2 $ 
     516                      , uvalue = {name:'depth2'}, minimum = min2, maximum =  max2 $ 
     517                      , uname = 'depth2', title = 'z2', strminlen = strminlen) 
    520518;-------------------------------------------- 
    521519; 
    522 ; 
    523 ; 
    524    return, base 
     520  return, base 
    525521end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_pagelayout.pro

    r68 r69  
    11;********************************************************************* 
    22;********************************************************************* 
    3 FUNCTION cw_miseenpage_event, event 
     3FUNCTION cw_pagelayout_event, event 
    44 
    55   widget_control, event.id, get_uvalue=uval 
     
    4646      createhistory, event.top, smallin 
    4747;          
    48          options = extractatt(top_uvalue, 'options')    
    49          flags = extractatt(top_uvalue, 'optionsflag') 
    50          xlonindex = where(options EQ 'Longitude / x index') 
    51          xlonflag = flags[xlonindex, numdessinin] & xlonflag = xlonflag[0] 
    52          ylatindex = where(options EQ 'Latitude / y index') 
    53          ylatflag = flags[ylatindex, numdessinin] & ylatflag = ylatflag[0] 
     48      options = extractatt(top_uvalue, 'options')    
     49      flags = extractatt(top_uvalue, 'optionsflag') 
     50      flag = flags[*, numdessinin] 
    5451;          
    55       flag = [1, key_portrait, 0, 0, 0, 0] 
    56       flag[xlonindex] = xlonflag 
    57       flag[ylatindex] = ylatflag 
    58 ;          
    59 ; actualisation de la top_uvalue... 
     52; update and reset all values of the top_uvalue... 
    6053; 
    6154      *top_uvalue[1, findline(top_uvalue, 'smallin')] = smallin 
     
    6659      *top_uvalue[1, findline(top_uvalue, 'yenvs')] = replicate(!y, nbredessin) 
    6760; 
    68       old = (extractatt(top_uvalue, 'nameprocedures'))[numdessinin] 
    69       new = strarr(nbredessin) 
    70       new[0] = old 
    71       *top_uvalue[1, findline(top_uvalue, 'nameprocedures')] = new 
    72 ; 
    73       old = (extractatt(top_uvalue, 'types'))[numdessinin] 
    74       new = strarr(nbredessin) 
    75       new[0] = old 
    76       *top_uvalue[1, findline(top_uvalue, 'types')] = new 
    77 ; 
    78       old = (extractatt(top_uvalue,  'champs'))[*, numdessinin] 
    79       new = strarr(2, nbredessin) 
    80       new[*, 0] = old 
    81       *top_uvalue[1, findline(top_uvalue, 'champs')] = new 
    82 ; 
    83       old = (extractatt(top_uvalue, 'domaines'))[*, numdessinin] 
    84       new = fltarr(6, nbredessin) 
    85       new[*, 0] = old 
    86       *top_uvalue[1, findline(top_uvalue, 'domaines')] = new 
    87 ; 
    88       old = (extractatt(top_uvalue, 'dates'))[*, numdessinin] 
    89       new = lonarr(2, nbredessin) 
    90       new[*, 0] = old 
    91       *top_uvalue[1, findline(top_uvalue, 'dates')] = new 
    92 ; 
    93       old = (extractatt(top_uvalue,  'prefixes'))[numdessinin] 
    94       new = strarr(nbredessin) 
    95       new[0] = old 
    96       *top_uvalue[1, findline(top_uvalue, 'prefixes')] = new 
    97 ; 
    98       new = flag#replicate(1, nbredessin) 
    99       *top_uvalue[1, findline(top_uvalue, 'optionsflag')] = new 
     61      *top_uvalue[1, findline(top_uvalue, 'nameprocedures')] = strarr(nbredessin) 
     62      *top_uvalue[1, findline(top_uvalue, 'types')] = strarr(nbredessin) 
     63      *top_uvalue[1, findline(top_uvalue, 'varinfo')] = strarr(2, nbredessin) 
     64      *top_uvalue[1, findline(top_uvalue, 'domaines')] = fltarr(6, nbredessin) 
     65      *top_uvalue[1, findline(top_uvalue, 'dates')] = lonarr(2, nbredessin) 
     66      *top_uvalue[1, findline(top_uvalue, 'txtcmd')] = strarr(nbredessin) 
     67      *top_uvalue[1, findline(top_uvalue, 'optionsflag')] = flag#replicate(1, nbredessin) 
    10068; 
    10169      ptr_free, extractatt(top_uvalue, 'exextra') 
     
    10876end 
    10977;********************************************************************* 
    110 FUNCTION cw_miseenpage, parent, small, UVALUE = uvalue, UNAME = uname, ROW = row, COLUMN = column, UNZOOM = unzoom, _extra = ex 
    111 ; cheking exclusive keywords 
    112    column = keyword_set(column)*(1-keyword_set(row)) 
    113    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column) 
     78FUNCTION cw_pagelayout, parent, small, UVALUE = uvalue, UNAME = uname, UNZOOM = unzoom, COLUMN = column, ROW = row, _extra = ex 
    11479;------------------------------------------------ 
    115    if NOT keyword_set(uvalue) then uvalue = '' 
    116    if NOT keyword_set(uname) then uname = '' 
    117    base = widget_base(parent, ROW = row, COLUMN = column  $ 
    118                       , EVENT_FUNC = 'cw_miseenpage_event' $ 
    119                       , FUNC_GET_VALUE='cw_miseenpage_get_value' $ 
    120                       , PRO_SET_VALUE='cw_miseenpage_set_value' $ 
    121                       , UVALUE = uvalue, UNAME = uname, _extra = ex)    
     80  row = keyword_set(row)*(1-keyword_set(column))   
     81  if NOT keyword_set(uvalue) then uvalue = '' 
     82  if NOT keyword_set(uname) then uname = '' 
     83  base = widget_base(parent $ 
     84                     , EVENT_FUNC = 'cw_pagelayout_event' $ 
     85                     , FUNC_GET_VALUE = 'cw_pagelayout_get_value' $ 
     86                     , PRO_SET_VALUE = 'cw_pagelayout_set_value' $ 
     87                     , UVALUE = uvalue, UNAME = uname, space = 0, _extra = ex)    
    12288;------------------------------------------------ 
    123    IF n_elements(small) eq 0 then small = [1, 1, 1] 
    124    basedroplist = widget_base(base, /column, /align_center) 
    125    id=widget_droplist(basedroplist, value=strtrim(indgen(10)+1, 1), title ='column' $ 
    126                         , uvalue ={name:'column'}, uname='column') 
    127    widget_control, id, set_droplist_select = small[0]-1 
    128    id=widget_droplist(basedroplist, value=strtrim(indgen(10)+1, 1), title =' row ' $ 
    129                         , uvalue ={name:'row'}, uname='row') 
    130    widget_control, id, set_droplist_select = small[1]-1 
    131    basebutton = widget_base(base, /column, /align_center) 
    132    rien = widget_button(basebutton, value = 'Clear', uvalue ={name:'clear'}, uname='clear') 
    133    rien = widget_button(basebutton, value = 'Undo', uvalue ={name:'undo'}, uname='undo') 
     89  IF n_elements(small) eq 0 then small = [1, 1, 1] 
     90; 
     91  dummy = widget_label(base, value = 'cln', yoffset = 3) 
     92  id = widget_combobox(base, value = strtrim(indgen(9)+1, 1), uvalue = {name:'column'} $ 
     93                       , uname = 'column', xoffset = 20, xsize = 40) 
     94  widget_control, id, set_combobox_select = small[0]-1 
     95; 
     96  IF keyword_set(row) THEN BEGIN  
     97    xoff = 60 
     98    yoff = 0 
     99  ENDIF ELSE BEGIN  
     100    xoff = 0 
     101    yoff = 20 
     102  ENDELSE  
     103  dummy = widget_label(base, value = 'row', xoffset = xoff, yoffset = yoff+3) 
     104  id = widget_combobox(base, value = strtrim(indgen(9)+1, 1), uvalue = {name:'row'} $ 
     105                       , uname = 'row', xoffset = xoff+20, xsize = 40, yoffset = yoff) 
     106  widget_control, id, set_combobox_select = small[1]-1 
    134107;------------------------------------------------ 
    135108;------------------------------------------------ 
    136    return, base 
     109  return, base 
    137110end 
    138111;********************************************************************* 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_slider_pm.pro

    r51 r69  
    135135; end 
    136136;---------------------------------------------------------------------- 
     137FUNCTION decvalue, value 
     138  a = float(value[0]) 
     139  return, strtrim(string(floor(a) + 0.1*indgen(10), format = '(f15.1)'), 2) 
     140end 
     141;---------------------------------------------------------------------- 
     142FUNCTION decind, value 
     143  a = float(value[0]) 
     144  return, round(10*(a - floor(a))) ; !! computation accuracy 
     145end 
     146;---------------------------------------------------------------------- 
    137147PRO cw_slider_pm_set_value, id, value 
    138    SliderBarId = widget_info(id,find_by_uname = 'SliderBar') 
    139    if size(value, /type) eq 8 then BEGIN ; this is a structure 
    140       tagnames = tag_names(value) 
    141       for tag = 0, n_tags(value)-1 do begin 
    142          case strtrim(strlowcase(tagnames[tag]), 2) of 
    143             'slider_min':widget_control, SliderBarId, set_slider_min = value.slider_min 
    144             'slider_max':widget_control, SliderBarId, set_slider_max = value.slider_max 
    145             'value':widget_control, SliderBarId, set_value = value.value 
    146             ELSE:ras = report('mauvais nom de l''argument de la structure ds cw_slider_pm_set_value') 
    147          endcase 
    148       endfor 
    149    ENDIF ELSE widget_control, SliderBarId, set_value = value[0] 
    150    return 
     148  sbid = widget_info(id, find_by_uname = 'SliderBar') 
     149  dcid = widget_info(id, find_by_uname = 'decimal') 
     150  minmax = widget_info(sbid, /SLIDER_MIN_MAX) 
     151  if size(value, /type) eq 8 then BEGIN ; this is a structure 
     152    tagnames = tag_names(value) 
     153    for tag = 0, n_tags(value)-1 do begin 
     154      case strtrim(strlowcase(tagnames[tag]), 2) of 
     155        'slider_min':BEGIN 
     156;          IF float(value.slider_min[0]) LT minmax[1] THEN BEGIN  
     157            minmax[0] = value.slider_min[0] 
     158            widget_control, sbid, set_slider_min = floor(float(value.slider_min[0])) 
     159            valuedc = float(widget_info(dcid, /combobox_gettext)) 
     160            IF valuedc LT value.slider_min THEN BEGIN 
     161              widget_control, sbid, set_value = floor(float(value.slider_min[0])) 
     162              widget_control, dcid, set_value = decvalue(value.slider_min) 
     163              widget_control, dcid, set_combobox_select = decind(value.slider_min) 
     164            ENDIF  
     165;          ENDIF  
     166        end 
     167        'slider_max':BEGIN 
     168;          IF float(value.slider_max[0]) GT minmax[0] THEN BEGIN  
     169            minmax[1] = value.slider_max[0] 
     170            widget_control, sbid, set_slider_max = ceil(float(value.slider_max[0])) 
     171            valuedc = float(widget_info(dcid, /combobox_gettext)) 
     172            IF valuedc GT value.slider_max THEN BEGIN 
     173              widget_control, sbid, set_value = ceil(float(value.slider_max[0])) 
     174              widget_control, dcid, set_value = decvalue(value.slider_max) 
     175              widget_control, dcid, set_combobox_select = decind(value.slider_max) 
     176            ENDIF  
     177;          ENDIF  
     178        end 
     179        'value':IF float(value.value[0]) GE minmax[0] $ 
     180          AND float(value.value[0]) LE minmax[1] THEN value2 = float(value.value[0]) 
     181        ELSE:ras = report('wrong tag name in argument "value" of cw_slider_pm_set_value') 
     182      endcase 
     183    endfor 
     184  ENDIF ELSE BEGIN  
     185    IF float(value[0]) GE minmax[0] $ 
     186      AND float(value[0]) LE minmax[1] THEN value2 = float(value[0]) 
     187  ENDELSE 
     188  IF n_elements(value2) NE 0 THEN BEGIN  
     189    widget_control, sbid, set_value = fix(value2) 
     190    widget_control, dcid, set_value = decvalue(value2) 
     191    widget_control, dcid, set_combobox_select = decind(value2) 
     192  ENDIF  
     193  return 
    151194end 
    152195;---------------------------------------------------------------------- 
    153196FUNCTION cw_slider_pm_get_value, id 
    154    SliderBarId = widget_info(id,find_by_uname = 'SliderBar') 
    155    widget_control, SliderBarId, get_value = value 
    156    return, {value:value, slider_min_max:widget_info(SliderBarId, /slider_min_max)} 
     197  sbid = widget_info(id, find_by_uname = 'SliderBar') 
     198  dcid = widget_info(id, find_by_uname = 'decimal') 
     199  minmax = widget_info(sbid, /SLIDER_MIN_MAX) 
     200  value = float(widget_info(dcid, /combobox_gettext)) 
     201   return, {value:value, slider_min_max:minmax} 
    157202end 
    158203;---------------------------------------------------------------------- 
    159204FUNCTION cw_slider_pm_event, event 
    160    widget_control, event.id, get_uvalue=uval 
    161 ; 
    162    if uval EQ 'SliderBar' then $ 
    163     return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    164              , VALUE:event.value, OUT:0} 
    165 ; 
    166    SliderBarId = widget_info(event.handler,find_by_uname = 'SliderBar') 
    167    minmax = widget_info(SliderBarId, /SLIDER_MIN_MAX) 
    168    widget_control, SliderBarId, get_value = value 
    169    case uval OF 
    170       'plus':BEGIN 
    171          if value NE minmax[1] then widget_control, SliderBarId,set_value = value+1 
    172          return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    173                   , VALUE:(value+1) < minmax[1], OUT:long(value eq minmax[1])} 
    174       END 
    175       'minus':BEGIN 
    176          if value NE minmax[0] then widget_control, SliderBarId,set_value = value-1 
    177          return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
    178                   , VALUE:0 > (value-1), OUT:-long(value EQ minmax[0])} 
    179       END 
    180    endcase 
    181 end 
    182 ;---------------------------------------------------------------------- 
    183 FUNCTION cw_slider_pm, parent, ROW = row, COLUMN = column, VERTICAL = vertical, UVALUE = uvalue, UNAME = uname, _extra = ex 
     205  widget_control, event.id, get_uvalue = uval 
     206; 
     207  sbid = widget_info(event.handler, find_by_uname = 'SliderBar') 
     208  dcid = widget_info(event.handler, find_by_uname = 'decimal') 
     209  minmax = widget_info(sbid, /SLIDER_MIN_MAX) 
     210  IF uval EQ 'decimal' THEN value = float(event.str) $ 
     211  ELSE value = float(widget_info(dcid, /combobox_gettext)) 
     212  out = 0 ; defaut case 
     213  case uval OF 
     214    'plus': if (value + 1) LE minmax[1] then value2 = value + 1 ELSE out = 1 
     215    'minus':if (value - 1) GE minmax[0] then value2 = value - 1 ELSE out = -1 
     216    'SliderBar':if (event.value + value - floor(value)) LE minmax[1] THEN value2 = event.value + value - floor(value) 
     217    'decimal':BEGIN  
     218      CASE 1 OF 
     219        value GT minmax[1]: value2 = minmax[1] 
     220        value LT minmax[0]: value2 = minmax[0] 
     221        ELSE: 
     222      ENDCASE 
     223    END 
     224    ELSE: 
     225  ENDCASE 
     226  IF n_elements(value2) NE 0  THEN BEGIN 
     227    value = value2 
     228    widget_control, sbid, set_value = floor(value) 
     229    widget_control, dcid, set_value = decvalue(value) 
     230    widget_control, dcid, set_combobox_select = decind(value) 
     231  ENDIF 
     232  return, {CW_SLIDER_PM, ID:event.handler, TOP:event.top, HANDLER:0L $ 
     233           , VALUE:value, OUT:OUT} 
     234end 
     235;---------------------------------------------------------------------- 
     236FUNCTION cw_slider_pm, parent, MAXIMUM = maximum, MINIMUM = minimum $ 
     237                       , STRMINLEN = strminlen, VALUE = value, UVALUE = uvalue $ 
     238                       , UNAME = uname, title = title, _extra = ex 
    184239 
    185    IF (N_PARAMS() NE 1) THEN MESSAGE, 'Incorrect number of arguments' 
    186    ON_ERROR, 2                  ;return to caller 
     240  IF (N_PARAMS() NE 1) THEN MESSAGE, 'Incorrect number of arguments' 
     241  ON_ERROR, 2                   ;return to caller 
     242; 
     243  if n_elements(minimum) NE 0 then minimum = floor(minimum) ELSE minimum = 0 
     244  if n_elements(maximum) NE 0 then maximum = ceil(maximum) ELSE maximum = 100 
     245  if NOT keyword_set(title) then title = '    ' 
    187246; 
    188247; cheking exclusive keywords 
    189    column = (keyword_set(column)*(1-keyword_set(row))+keyword_set(vertical)) < 1 
    190    row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
    191    if NOT keyword_set(uvalue) then uvalue = '' 
    192    if NOT keyword_set(uname) then uname = '' 
    193    base = widget_base(parent, space = 1, xpad = 1, ypad = 1 $ 
    194                       , EVENT_FUNC = 'cw_slider_pm_event' $ 
    195                       , FUNC_GET_VALUE='cw_slider_pm_get_value' $ 
    196                       , PRO_SET_VALUE='cw_slider_pm_set_value' $ 
    197                       , ROW = row, COLUMN = column, UVALUE = uvalue, UNAME = uname, _extra = ex)    
    198 ; 
    199    if keyword_set(vertical) then BEGIN 
    200       if keyword_set(row) then begin 
    201          nothing = widget_slider(base, /VERTICAL, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    202          base1 = widget_base(base, space = 1, xpad = 1, ypad = 1 $ 
    203                              , /column, /align_center) 
    204          nothing = widget_button(base1,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    205          nothing = widget_button(base1,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    206       ENDIF ELSE BEGIN  
    207          nothing = widget_button(base,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    208          nothing = widget_slider(base, /VERTICAL, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    209          nothing = widget_button(base,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    210       ENDELSE 
    211    ENDIF ELSE BEGIN 
    212       if keyword_set(row) then begin 
    213          nothing = widget_button(base,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    214          nothing = widget_slider(base, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    215          nothing = widget_button(base,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    216       ENDIF ELSE BEGIN  
    217          nothing = widget_slider(base, UVALUE = 'SliderBar', UNAME = 'SliderBar', _extra = ex) 
    218          base1 = widget_base(base, space = 1, xpad = 1, ypad = 1 $ 
    219                              , /row, /align_center) 
    220          nothing = widget_button(base1,value= '-', uvalue='minus', xsize = 15, ysize = 15) 
    221          nothing = widget_button(base1,value= '+', uvalue='plus', xsize = 15, ysize = 15) 
    222       ENDELSE 
    223    ENDELSE 
    224 ; 
    225 ; 
    226    return, base 
    227 end 
     248  column = (keyword_set(column)*(1-keyword_set(row))+keyword_set(vertical)) < 1 
     249  row = keyword_set(row)*(1-keyword_set(column)) +(keyword_set(row) EQ column)  
     250  if NOT keyword_set(uvalue) then uvalue = '' 
     251  if NOT keyword_set(uname) then uname = '' 
     252  base = widget_base(parent $ 
     253                     , EVENT_FUNC = 'cw_slider_pm_event' $ 
     254                     , FUNC_GET_VALUE = 'cw_slider_pm_get_value' $ 
     255                     , PRO_SET_VALUE = 'cw_slider_pm_set_value' $ 
     256                     , space = 0, UVALUE = uvalue, UNAME = uname, _extra = ex)    
     257; 
     258  mlen = (widget_info(base, string_size = 'm'))[0] 
     259 
     260  xsize = mlen*strlen(title) 
     261  dummyid = widget_label(base, value = title, xsize = xsize) 
     262  dummyid = widget_button(base, value = '-', uvalue = 'minus' $ 
     263                          , yoffset = 15, xsize = 15, ysize = 15) 
     264  dummyid = widget_button(base, value = '+', uvalue = 'plus' $ 
     265                          , xoffset = 15, yoffset = 15, xsize = 15, ysize = 15) 
     266  xoff = 30 > xsize 
     267  lenstr = max(strlen(strtrim([minimum, maximum], 1))) 
     268  if keyword_set(strminlen) then lenstr = strminlen > lenstr 
     269;  xsize = 35 + mlen*(lenstr+1)+3*(lenstr lt 4) 
     270  xsize = 35 + mlen*(lenstr+2) 
     271  dummyid = widget_combobox(base, value = decvalue(minimum) $ 
     272                            , UVALUE = 'decimal', UNAME = 'decimal' $ 
     273                            , xoffset = xoff, yoffset = 2, xsize = xsize) 
     274 
     275  dummyid = widget_slider(base, MAXIMUM = maximum, MINIMUM = minimum, UVALUE = 'SliderBar' $ 
     276                          , UNAME = 'SliderBar', /suppress_value, /drag $ 
     277                          , yoffset = 30, xsize = xoff + xsize) 
     278; 
     279  if keyword_set(value) then cw_slider_pm_set_value, base, value 
     280; 
     281  return, base 
     282end 
  • trunk/ToBeReviewed/WIDGET/COMPOUND_WIDGET/cw_specifie.pro

    r51 r69  
    1414      if strtrim(autresautres, 2) NE '' then begin 
    1515         nothing = execute('autresautres = get_extra('+autresautres+')') 
     16;         autresautres = createfunc('get_extra('+autresautres+')') 
    1617         autres = mixstru(autres, autresautres) 
    1718      endif 
     
    3839   if strtrim(autres, 2) NE '' then $ 
    3940    rien = execute('exextra = get_extra('+autres+', _extra = exextra)') 
     41;    exextra = createfunc('get_extra('+autres+', _extra = exextra)') 
    4042   return, exextra 
    4143end 
     
    4749;------------------------------------------------------------ 
    4850;------------------------------------------------------------ 
    49    widget_control, event.id, get_uvalue = uval 
    50    widget_control, event.top, get_uvalue = top_uvalue 
    51    smallin = extractatt(top_uvalue, 'smallin') 
    52    numdessinin = smallin[2]-1 
    53    smallout = extractatt(top_uvalue, 'smallout') 
    54    numdessinout = smallout[2]-1 
     51  widget_control, event.id, get_uvalue = uval 
     52  widget_control, event.top, get_uvalue = top_uvalue 
     53  smallin = extractatt(top_uvalue, 'smallin') 
     54  numdessinin = smallin[2]-1 
     55  smallout = extractatt(top_uvalue, 'smallout') 
     56  numdessinout = smallout[2]-1 
    5557;------------------------------------------------------------ 
    56    case uval of 
    57       'default':BEGIN  
     58  case uval of 
     59    'default':BEGIN  
    5860;--------------- 
    5961; on trouve le nom de la variable: 
    6062;--------------- 
    61          champid = widget_info(event.top, find_by_uname = 'champ') 
    62          currentfile = extractatt(top_uvalue, 'currentfile') 
    63          listvar = (*(extractatt(top_uvalue, 'fileparameters'))[currentfile]).listvar 
    64          varname = listvar[widget_info(champid, /droplist_select)] 
     63      vlstid = widget_info(base, find_by_uname = 'varlist') 
     64      fieldname = widget_info(vlstid, /combobox_gettext) 
    6565;--------------- 
    66          exextra = definedefaultextra(varname) 
    67          widget_control, widget_info(event.handler,find_by_uname='min'), set_value = strtrim(exextra.min, 1) 
    68          widget_control, widget_info(event.handler,find_by_uname='max'), set_value = strtrim(exextra.max, 1) 
    69          widget_control, widget_info(event.handler,find_by_uname='int'), set_value = strtrim(exextra.inter, 1) 
    70          widget_control, widget_info(event.handler,find_by_uname='palnum'), set_value = strtrim(exextra.lct, 1) 
    71          widget_control, widget_info(event.handler,find_by_uname='autres'), set_value = '' 
    72       END 
    73       'palcol':BEGIN  
    74          ind = fix(strmid(event.value, 0, strpos(event.value, '-'))) 
    75          widget_control, widget_info(event.handler,find_by_uname='palnum'), set_value = strtrim(ind, 1) 
    76       END 
    77       'ok': 
    78       ELSE: 
    79    endcase 
    80    return,{ID:event.handler, TOP:event.top, HANDLER:0L, OK:uval EQ 'ok'} 
     66      exextra = definedefaultextra(varname) 
     67      widget_control, widget_info(event.handler, find_by_uname = 'min'), set_value = strtrim(exextra.min, 1) 
     68      widget_control, widget_info(event.handler, find_by_uname = 'max'), set_value = strtrim(exextra.max, 1) 
     69      widget_control, widget_info(event.handler, find_by_uname = 'int'), set_value = strtrim(exextra.inter, 1) 
     70      widget_control, widget_info(event.handler, find_by_uname = 'palnum'), set_value = strtrim(exextra.lct, 1) 
     71      widget_control, widget_info(event.handler, find_by_uname = 'autres'), set_value = '' 
     72    END 
     73    'palcol':BEGIN  
     74      ind = fix(strmid(event.value, 0, strpos(event.value, '-'))) 
     75      widget_control, widget_info(event.handler, find_by_uname = 'palnum'), set_value = strtrim(ind, 1) 
     76    END 
     77    ELSE: 
     78  endcase 
     79  return, {ID:event.handler, TOP:event.top, HANDLER:0L, OK:uval EQ 'ok'} 
    8180end 
    8281;***************************************************** 
     
    8988   if NOT keyword_set(uvalue) then uvalue = '' 
    9089   if NOT keyword_set(uname) then uname = '' 
    91    base = widget_base(parent, ROW = row, COLUMN = column $ 
     90   base = widget_base(parent, space = 0, /frame $ 
    9291                      , EVENT_FUNC = 'cw_specifie_event' $ 
    9392                      , FUNC_GET_VALUE='cw_specifie_get_value' $ 
    9493                      , PRO_SET_VALUE='cw_specifie_set_value' $ 
    9594                      , UVALUE = uvalue, UNAME = uname, _extra = ex)    
    96 ; base1 pour specifier le min, le max et l''intervalle 
    97    base1 = widget_base(base, /row, /frame) 
    98    rien = widget_label(base1, value = 'Min') 
    99    rien = widget_text(base1, value = '', /editable, xsize = 5, uname = 'min', uvalue = 'min') 
    100    rien = widget_label(base1, value = 'Max') 
    101    rien = widget_text(base1, value = '', /editable, xsize = 5, uname = 'max', uvalue = 'max') 
    102    rien = widget_label(base1, value = 'Int') 
    103    rien = widget_text(base1, value = '', /editable, xsize = 5, uname = 'int', uvalue = 'int') 
    104 ; base2 por specifier la palette de couleur (soit par numero soit ds 
    105 ; un menu deroulant) 
    106    if keyword_set(FORXXX) then base2 = widget_base(base, /row, /frame) ELSE base2 = base1 
    107    rien = widget_label(base2, value = 'Pal Numb') 
    108    if keyword_set(forxxx) then colvalue = '' ELSE colvalue = '39' 
    109    rien = widget_text(base2, value = colvalue, /editable, xsize = 3, uname = 'palnum', uvalue = 'palnum') 
    110    lct,  get_name = nomcouleur 
     95; base1  
     96   base1 = widget_base(base) 
     97   rien = widget_label(base1, value = 'Min', xoffset =  85, yoffset = 15) 
     98   rien = widget_label(base1, value = 'Max', xoffset = 145, yoffset = 15) 
     99   rien = widget_label(base1, value = 'Int', xoffset = 210, yoffset = 15) 
     100; 
     101   lct, get_name = nomcouleur 
    111102   nbrligne = 30 
    112103   nbrlist = n_elements(nomcouleur)/nbrligne 
    113104   nomcouleur = strtrim(sindgen(n_elements(nomcouleur)), 1)+'- '+nomcouleur 
    114105   nomcouleur = '0\'+nomcouleur 
    115    nomcouleur = ['1\color palette', nomcouleur] 
     106   nomcouleur = ['1\Color', nomcouleur] 
    116107   if nbrlist GT 1 then for i = 1,nbrlist do $ 
    117108    nomcouleur = [nomcouleur[0:nbrligne*i-1+i], '1\ ', nomcouleur[nbrligne*i+i:n_elements(nomcouleur)-1]] 
    118    rien = cw_pdmenu(base2,nomcouleur, /RETURN_NAME , uvalue = 'palcol', uname = 'palcol') 
     109   rien = cw_pdmenu(base1, nomcouleur, /RETURN_NAME , uvalue = 'palcol', uname = 'palcol', xoffset = 250, yoffset = 0) 
     110; base2 
     111   base2 = widget_base(base, column = 4+keyword_set(forxxx), yoffset = 30) 
     112   if keyword_set(forxxx) then rien = widget_button(base2,value='Default', uvalue = 'default', /frame, tooltip = 'see '+find('definedefaultextra')) 
     113   rien = widget_text(base2, value = '', /editable, xsize = 7, uname = 'min', uvalue = 'min') 
     114   rien = widget_text(base2, value = '', /editable, xsize = 7, uname = 'max', uvalue = 'max') 
     115   rien = widget_text(base2, value = '', /editable, xsize = 7, uname = 'int', uvalue = 'int') 
     116   if keyword_set(forxxx) then colvalue = '' ELSE colvalue = '39' 
     117   rien = widget_text(base2, value = colvalue, /editable, xsize = 2, uname = 'palnum', uvalue = 'palnum') 
    119118 
    120 ; baseavantfin pour passer tous les mots cles possibles... 
     119 
     120 
    121121; widget text contennant les autres mots cles passe ds top_uvalue.exextra 
    122122; en reste-t-il? si oui, il faut les mettres sous forme de string 
     123    
     124   rien = widget_text(base, value = '  ', /editable, uname = 'autres', uvalue = 'autres', xsize = 54, ysize = 3, yoffset = 65, /wrap, /no_newline) 
    123125 
    124    baseavantfin = widget_base(base, /row, /frame) 
    125    rien = widget_label(baseavantfin, value = 'Keywords') 
    126    rien = widget_text(baseavantfin, value = '  ', /editable, uname = 'autres', uvalue = 'autres', scr_xsize = 400) 
    127    if keyword_set(forxxx)  then begin 
    128 ; basefin pour en finir, 2 boutons: Default/OK 
    129       basefin = widget_base(base, /row, /frame, /align_center) 
    130       rien = widget_button(basefin,value='Default', uvalue = 'default') 
    131       rien = widget_button(basefin,value='OK', uvalue = 'ok') 
    132 ; on intialise les widget_text: 
    133       cw_specifie_set_value, base, definedefaultextra('rien_du_tout') 
    134    endif 
     126    if keyword_set(forxxx) then cw_specifie_set_value, base, definedefaultextra('rien_du_tout') 
    135127 
    136128;------------------------------------------------ 
Note: See TracChangeset for help on using the changeset viewer.