[2] | 1 | ; IDL> testwid,julday(1,1,1980)+lindgen(100)*5 |
---|
| 2 | ; |
---|
[69] | 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 |
---|
[226] | 9 | ; 'set':BEGIN |
---|
[69] | 10 | ; widget_control, event.id, get_value = value |
---|
| 11 | ; widget_control, ComboboxId, set_value = value |
---|
| 12 | ; END |
---|
[226] | 13 | ; 'get':BEGIN |
---|
[69] | 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 |
---|
[2] | 37 | ; |
---|
| 38 | ; |
---|
[157] | 39 | ;+ |
---|
[231] | 40 | ; |
---|
[157] | 41 | ; @file_comments |
---|
[2] | 42 | ; |
---|
[157] | 43 | ; @categories |
---|
| 44 | ; Compound widget |
---|
[226] | 45 | ; |
---|
[157] | 46 | ; @param ID |
---|
| 47 | ; |
---|
| 48 | ; @param VALUE |
---|
| 49 | ; It is the default tick mark value (a floating-point number). |
---|
| 50 | ; |
---|
| 51 | ; @returns |
---|
[226] | 52 | ; |
---|
[157] | 53 | ; @uses |
---|
[226] | 54 | ; |
---|
[157] | 55 | ; @restrictions |
---|
[226] | 56 | ; |
---|
[157] | 57 | ; @examples |
---|
[226] | 58 | ; |
---|
[157] | 59 | ; @history |
---|
[226] | 60 | ; |
---|
| 61 | ; @version |
---|
[157] | 62 | ; $Id$ |
---|
[325] | 63 | ; |
---|
[157] | 64 | ;- |
---|
[69] | 65 | PRO cw_calendar_set_value, id, value |
---|
[2] | 66 | ; |
---|
[226] | 67 | compile_opt strictarr, strictarrsubs |
---|
[2] | 68 | ; |
---|
[69] | 69 | @cm_4cal |
---|
| 70 | ; get back the calendar and its related informations |
---|
| 71 | winfo_id = widget_info(id, find_by_uname = 'infocal') |
---|
| 72 | widget_control, winfo_id, get_uvalue = infowid |
---|
| 73 | key_caltype = infowid.caltype |
---|
| 74 | ; high freqeuncy calendar |
---|
| 75 | IF keyword_set(infowid.fakecal) THEN BEGIN |
---|
| 76 | value2 = date2jul(long(value)) - infowid.fakecal |
---|
[226] | 77 | IF value2 LT n_elements(infowid.calendar) AND value2 GE 0 THEN BEGIN |
---|
[69] | 78 | stepid = widget_info(id, find_by_uname = 'step') |
---|
| 79 | widget_control, stepid, set_value = {combobox_select:value2} |
---|
| 80 | infowid.date = jul2date(value2 + infowid.fakecal) |
---|
| 81 | widget_control, winfo_id, set_uvalue = infowid |
---|
| 82 | ENDIF |
---|
[226] | 83 | ENDIF ELSE BEGIN |
---|
[279] | 84 | jdval = date2jul(value) |
---|
[69] | 85 | ; check that the date exists in the calendar |
---|
[279] | 86 | if (where(abs(infowid.calendar - jdval) LT 1.d/86400.d))[0] EQ - 1 then return |
---|
[69] | 87 | ; update the value of infocal |
---|
| 88 | infowid.date = value |
---|
| 89 | widget_control, winfo_id, set_uvalue = infowid |
---|
| 90 | ; update the combobox if needed... |
---|
| 91 | possiblecase = ['day', 'month', 'year'] |
---|
| 92 | for name = 2, 0, -1 do BEGIN |
---|
| 93 | ; call set_cal_combobox with out = 2 to specify that the call is coming |
---|
| 94 | ; from cw_calendar_set_value |
---|
| 95 | if widget_info(id, find_by_uname = possiblecase[name]) NE 0 then $ |
---|
| 96 | set_cal_combobox, {handler:id, out:2}, possiblecase[name], value |
---|
| 97 | ENDFOR |
---|
| 98 | ENDELSE |
---|
| 99 | ; |
---|
| 100 | return |
---|
[2] | 101 | end |
---|
| 102 | ;---------------------------------------------------------------------- |
---|
[157] | 103 | ;+ |
---|
| 104 | ; @file_comments |
---|
| 105 | ; |
---|
| 106 | ; |
---|
| 107 | ; @categories |
---|
| 108 | ; Compound widget |
---|
[226] | 109 | ; |
---|
[157] | 110 | ; @param ID |
---|
| 111 | ; |
---|
| 112 | ; |
---|
| 113 | ; @returns |
---|
[226] | 114 | ; |
---|
[157] | 115 | ; @uses |
---|
[226] | 116 | ; |
---|
[157] | 117 | ; @restrictions |
---|
[226] | 118 | ; |
---|
[157] | 119 | ; @examples |
---|
[226] | 120 | ; |
---|
[157] | 121 | ; @history |
---|
[226] | 122 | ; |
---|
| 123 | ; @version |
---|
[157] | 124 | ; $Id$ |
---|
[325] | 125 | ; |
---|
[157] | 126 | ;- |
---|
[2] | 127 | FUNCTION cw_calendar_get_value, id |
---|
[69] | 128 | ; |
---|
[226] | 129 | compile_opt strictarr, strictarrsubs |
---|
[69] | 130 | ; |
---|
| 131 | winfo_id = widget_info(id, find_by_uname = 'infocal') |
---|
| 132 | widget_control, winfo_id, get_uvalue = infowid |
---|
| 133 | return, infowid.date |
---|
| 134 | END |
---|
| 135 | ;---------------------------------------------------------------------- |
---|
[157] | 136 | ;+ |
---|
| 137 | ; @file_comments |
---|
| 138 | ; |
---|
| 139 | ; |
---|
| 140 | ; @categories |
---|
| 141 | ; Compound widget |
---|
[226] | 142 | ; |
---|
[157] | 143 | ; @param ID |
---|
| 144 | ; |
---|
| 145 | ; |
---|
| 146 | ; @param WINFOID |
---|
| 147 | ; |
---|
| 148 | ; |
---|
| 149 | ; @returns |
---|
[226] | 150 | ; |
---|
[157] | 151 | ; @uses |
---|
[226] | 152 | ; |
---|
[157] | 153 | ; @restrictions |
---|
[226] | 154 | ; |
---|
[157] | 155 | ; @examples |
---|
[226] | 156 | ; |
---|
[157] | 157 | ; @history |
---|
[226] | 158 | ; |
---|
| 159 | ; @version |
---|
[157] | 160 | ; $Id$ |
---|
[325] | 161 | ; |
---|
[157] | 162 | ;- |
---|
[226] | 163 | FUNCTION get_cal_value, id, winfoid |
---|
[69] | 164 | ; |
---|
[226] | 165 | compile_opt strictarr, strictarrsubs |
---|
[69] | 166 | ; |
---|
| 167 | winfo_id = widget_info(id, find_by_uname = 'infocal') |
---|
| 168 | widget_control, winfo_id, get_uvalue = infowid |
---|
| 169 | oldate = infowid.date |
---|
| 170 | ;-------------day----------------- |
---|
| 171 | wid_id = widget_info(id, find_by_uname = 'day') |
---|
| 172 | if wid_id NE 0 then BEGIN |
---|
| 173 | widget_control, wid_id, get_value = wid_value |
---|
[279] | 174 | widget_control, wid_id, get_uvalue = wid_uvalue |
---|
| 175 | date = double(wid_value.combobox_gettext) + wid_uvalue.hms[wid_value.combobox_index] |
---|
[69] | 176 | ENDIF ELSE date = oldate MOD 100L |
---|
| 177 | ;-------------month--------------- |
---|
| 178 | wid_id = widget_info(id, find_by_uname = 'month') |
---|
| 179 | if wid_id NE 0 then BEGIN |
---|
| 180 | widget_control, wid_id, get_value = wid_value |
---|
| 181 | allmonths = string(format = '(C(CMoA))', 31*(indgen(12))) |
---|
[226] | 182 | month = (where(allmonths EQ wid_value.combobox_gettext))[0] + 1 |
---|
[69] | 183 | date = date + 100L * long(month) |
---|
[74] | 184 | ENDIF ELSE date = date + (oldate MOD 10000L)/100L*100L |
---|
[69] | 185 | ;-------------year---------------- |
---|
| 186 | wid_id = widget_info(id, find_by_uname = 'year') |
---|
| 187 | widget_control, wid_id, get_value = wid_value |
---|
| 188 | date = date + 10000L * long(wid_value.combobox_gettext) |
---|
| 189 | ; |
---|
| 190 | IF arg_present(winfoid) NE 0 THEN BEGIN |
---|
| 191 | winfoid = winfo_id |
---|
| 192 | infowid.date = date |
---|
| 193 | return, infowid |
---|
| 194 | ENDIF ELSE return, date |
---|
[2] | 195 | end |
---|
| 196 | ;---------------------------------------------------------------------- |
---|
[69] | 197 | ; redefine the value and index position of the combobox |
---|
[157] | 198 | ;+ |
---|
| 199 | ; @file_comments |
---|
| 200 | ; |
---|
| 201 | ; |
---|
| 202 | ; @categories |
---|
| 203 | ; Compound widget |
---|
[226] | 204 | ; |
---|
[157] | 205 | ; @param EVENT |
---|
| 206 | ; |
---|
| 207 | ; |
---|
| 208 | ; @param CASENAME |
---|
| 209 | ; |
---|
| 210 | ; |
---|
| 211 | ; @param DATE0 |
---|
| 212 | ; |
---|
| 213 | ; |
---|
| 214 | ; @returns |
---|
[226] | 215 | ; |
---|
[157] | 216 | ; @uses |
---|
[226] | 217 | ; |
---|
[279] | 218 | ; @restrictions< |
---|
[226] | 219 | ; |
---|
[157] | 220 | ; @examples |
---|
[226] | 221 | ; |
---|
[157] | 222 | ; @history |
---|
[226] | 223 | ; |
---|
| 224 | ; @version |
---|
[157] | 225 | ; $Id$ |
---|
[325] | 226 | ; |
---|
[157] | 227 | ;- |
---|
[69] | 228 | PRO set_cal_combobox, event, casename, date0 |
---|
| 229 | ; |
---|
[226] | 230 | compile_opt strictarr, strictarrsubs |
---|
[69] | 231 | ; |
---|
| 232 | ; casename: Which widget shall we move: 'day', 'month' or 'year' ? |
---|
| 233 | wid_id = widget_info(event.handler, find_by_uname = casename) |
---|
| 234 | ; we get back the calendar... |
---|
| 235 | winfo_id = widget_info(event.handler, find_by_uname = 'infocal') |
---|
| 236 | widget_control, winfo_id, get_uvalue = infowid |
---|
[279] | 237 | caldat, infowid.calendar, monthcal, daycal, yearcal, hourcal, mincal, seccal |
---|
[69] | 238 | ; ... and the current date |
---|
| 239 | IF n_elements(date0) EQ 0 then date0 = get_cal_value(event.handler) |
---|
[279] | 240 | jdate0 = date2jul(date0, month = month0, day = day0, year = year0) |
---|
[69] | 241 | ; index of days/months/years according to date0 |
---|
| 242 | case casename of |
---|
[226] | 243 | 'day':BEGIN |
---|
[69] | 244 | ; list of days corresponding to month0 and year0 |
---|
| 245 | index = where(monthcal EQ month0 AND yearcal EQ year0) |
---|
| 246 | current = daycal[index] |
---|
[279] | 247 | hms = hourcal[index] / 24.0d0 + mincal[index]/1440.0d0 + seccal[index] / 86400.0d0 |
---|
[69] | 248 | END |
---|
[226] | 249 | 'month':BEGIN |
---|
[69] | 250 | ; list of months corresponding to year0 |
---|
| 251 | index = where(yearcal EQ year0) |
---|
| 252 | current = monthcal[index] |
---|
| 253 | ; keep only the uniq values |
---|
| 254 | indexbis = uniq(current) |
---|
| 255 | index = index[indexbis] |
---|
| 256 | current = current[indexbis] |
---|
| 257 | END |
---|
[226] | 258 | 'year':BEGIN |
---|
[69] | 259 | ; keep only the uniq years |
---|
| 260 | index = uniq(yearcal) |
---|
| 261 | current = yearcal[index] |
---|
| 262 | END |
---|
| 263 | ENDCASE |
---|
| 264 | ; we update the uvalue of the widget |
---|
[279] | 265 | IF casename EQ 'day' THEN widget_control, wid_id, set_uvalue = {name:casename, hms:hms} |
---|
[69] | 266 | ; for event.out = 0, we store the previous position of the combobox to use |
---|
| 267 | ; it as the default position. |
---|
| 268 | IF event.out EQ 0 THEN widget_control, wid_id, get_value = oldselect |
---|
| 269 | ; we redefine the new list |
---|
| 270 | if casename EQ 'month' then begin |
---|
| 271 | widget_control, wid_id, set_value = string(format = '(C(CMoA))', 31*(current-1)) |
---|
[226] | 272 | ENDIF ELSE BEGIN |
---|
[69] | 273 | widget_control, wid_id, set_value = strtrim(current, 1) |
---|
[2] | 274 | ENDELSE |
---|
[69] | 275 | ; specify the index position within the new list of values. |
---|
| 276 | widget_control, wid_id, get_value = combobox |
---|
| 277 | CASE event.out OF |
---|
| 278 | ; -1: we put to the biggest position |
---|
| 279 | -1:selected = combobox.combobox_number - 1 |
---|
| 280 | ; 0: same as the previous position is the best choice... |
---|
| 281 | 0:selected = oldselect.combobox_index < (combobox.combobox_number - 1) |
---|
| 282 | ; 1: we put to the smallest position |
---|
| 283 | 1:selected = 0 |
---|
| 284 | ; 2: a new date has been specified... |
---|
[226] | 285 | 2:BEGIN |
---|
[69] | 286 | case casename of |
---|
| 287 | 'day':selected = (where(current EQ day0))[0] |
---|
| 288 | 'month':selected = (where(current EQ month0))[0] |
---|
| 289 | 'year':selected = (where(current EQ year0))[0] |
---|
| 290 | ENDCASE |
---|
| 291 | END |
---|
| 292 | ENDCASE |
---|
| 293 | widget_control, wid_id, set_value = {combobox_select:selected} |
---|
| 294 | ; update the date... |
---|
| 295 | infowid.date = get_cal_value(event.handler) |
---|
| 296 | widget_control, winfo_id, set_uvalue = infowid |
---|
| 297 | return |
---|
[2] | 298 | end |
---|
| 299 | ;---------------------------------------------------------------------- |
---|
[226] | 300 | ; move cyclically the calendar to the |
---|
[69] | 301 | ; value 0 if event.out=1 or combobox_number-1 if event.out=-1 |
---|
[157] | 302 | ;+ |
---|
| 303 | ; @file_comments |
---|
| 304 | ; |
---|
| 305 | ; |
---|
| 306 | ; @categories |
---|
| 307 | ; Compound widget |
---|
[226] | 308 | ; |
---|
[157] | 309 | ; @param EVENT |
---|
| 310 | ; |
---|
| 311 | ; |
---|
| 312 | ; @param CASENAME |
---|
| 313 | ; |
---|
| 314 | ; |
---|
| 315 | ; @returns |
---|
[226] | 316 | ; |
---|
[157] | 317 | ; @uses |
---|
[226] | 318 | ; |
---|
[157] | 319 | ; @restrictions |
---|
[226] | 320 | ; |
---|
[157] | 321 | ; @examples |
---|
[226] | 322 | ; |
---|
[157] | 323 | ; @history |
---|
[226] | 324 | ; |
---|
| 325 | ; @version |
---|
[157] | 326 | ; $Id$ |
---|
[325] | 327 | ; |
---|
[157] | 328 | ;- |
---|
[279] | 329 | PRO cw_cal_move, event, casename |
---|
[69] | 330 | ; |
---|
[226] | 331 | compile_opt strictarr, strictarrsubs |
---|
[69] | 332 | ; |
---|
| 333 | possiblecase = ['day', 'month', 'year', 'impossiblecase'] |
---|
| 334 | id = widget_info(event.handler, find_by_uname = casename) |
---|
| 335 | widget_control, id, get_value = wvalue |
---|
| 336 | ; we try to move but we are already at the beginning/end of the combobox |
---|
| 337 | ; wvalue.combobox_index EQ (wvalue.combobox_number-1) and event.out EQ 1 |
---|
| 338 | ; wvalue.combobox_index EQ 0 and event.out EQ -1 (move is not called when out eq 0) |
---|
[2] | 339 | whichcase = (where(possiblecase EQ casename))[0] |
---|
[69] | 340 | if wvalue.combobox_index EQ (wvalue.combobox_number-1)*(event.out EQ 1) THEN BEGIN |
---|
| 341 | if widget_info(event.handler, find_by_uname = possiblecase[whichcase+1]) EQ 0 then begin |
---|
| 342 | ; it is impossible to move the "next" combobox... |
---|
| 343 | widget_control, id, get_value = widvalue |
---|
| 344 | ; we set to "widvalue.combobox_number-1" when event.out EQ -1 |
---|
| 345 | ; and to 0 when event.out EQ 1 |
---|
| 346 | selected = (widvalue.combobox_number-1)*(event.out EQ -1) |
---|
| 347 | widget_control, id, set_value = {combobox_select:selected} |
---|
| 348 | ; we call move for the next combobox |
---|
[279] | 349 | ENDIF ELSE cw_cal_move, event, possiblecase[whichcase+1] |
---|
[69] | 350 | ; it is possible to move from +/- 1 |
---|
| 351 | ENDIF ELSE widget_control, id, set_value = {combobox_select:wvalue.combobox_index+event.out} |
---|
| 352 | set_cal_combobox, event, possiblecase[whichcase-1] |
---|
[2] | 353 | return |
---|
| 354 | end |
---|
| 355 | ;---------------------------------------------------------------------- |
---|
[157] | 356 | ;+ |
---|
| 357 | ; @file_comments |
---|
| 358 | ; |
---|
| 359 | ; |
---|
| 360 | ; @categories |
---|
| 361 | ; Compound widget |
---|
[226] | 362 | ; |
---|
[157] | 363 | ; @param EVENT |
---|
| 364 | ; |
---|
| 365 | ; |
---|
| 366 | ; @returns |
---|
[226] | 367 | ; |
---|
[157] | 368 | ; @uses |
---|
[226] | 369 | ; |
---|
[157] | 370 | ; @restrictions |
---|
[226] | 371 | ; |
---|
[157] | 372 | ; @examples |
---|
[226] | 373 | ; |
---|
[157] | 374 | ; @history |
---|
[226] | 375 | ; |
---|
| 376 | ; @version |
---|
[157] | 377 | ; $Id$ |
---|
[325] | 378 | ; |
---|
[157] | 379 | ;- |
---|
[2] | 380 | FUNCTION cw_calendar_event, event |
---|
[69] | 381 | ; |
---|
| 382 | @cm_4cal |
---|
[226] | 383 | compile_opt strictarr, strictarrsubs |
---|
[69] | 384 | ; |
---|
[74] | 385 | winfo_id = widget_info(event.handler, find_by_uname = 'infocal') |
---|
[69] | 386 | widget_control, winfo_id, get_uvalue = infowid |
---|
| 387 | key_caltype = infowid.caltype |
---|
| 388 | ; |
---|
| 389 | widget_control, event.id, get_uvalue = uval |
---|
| 390 | ; high frequency calendar |
---|
[226] | 391 | IF uval.name EQ 'step' THEN BEGIN |
---|
[69] | 392 | infowid.date = jul2date(event.index + infowid.fakecal) |
---|
| 393 | ENDIF ELSE BEGIN |
---|
| 394 | ; |
---|
| 395 | possiblecase = ['day', 'month', 'year', 'impossiblecase'] |
---|
| 396 | whichcase = (where(possiblecase EQ uval.name))[0] |
---|
| 397 | if event.out NE 0 then BEGIN ; we use the +/- button and we want to go out of the combobox: |
---|
| 398 | ; to index = -1 (event.out=-1) or to index = combobox_number (event.out=1) |
---|
| 399 | ; we try to move the combobox just right, with name: possiblecase[whichcase+1] |
---|
| 400 | if widget_info(event.handler, find_by_uname = possiblecase[whichcase+1]) EQ 0 then BEGIN |
---|
[226] | 401 | ; this widget do not exist we set cyclically the current widget to the |
---|
[69] | 402 | ; value 0 if event.out=1 or combobox_number-1 if event.out=-1 |
---|
| 403 | widget_control, event.id, get_value = widvalue |
---|
| 404 | selected = (widvalue.combobox_number-1)*(event.out EQ -1) |
---|
| 405 | widget_control, event.id, set_value = {combobox_select:selected} |
---|
[279] | 406 | ENDIF ELSE cw_cal_move, event, possiblecase[whichcase+1] |
---|
[69] | 407 | ENDIF |
---|
| 408 | ; if we changed month(year), we need to update the day (and month) list |
---|
| 409 | if uval.name NE 'day' then begin |
---|
[2] | 410 | event.out = 0 |
---|
[69] | 411 | for name = whichcase-1, 0, -1 do BEGIN |
---|
| 412 | if widget_info(event.handler, find_by_uname = possiblecase[name]) NE 0 then $ |
---|
| 413 | set_cal_combobox, event, possiblecase[name] |
---|
[2] | 414 | endfor |
---|
[69] | 415 | ENDIF |
---|
| 416 | ; we update the date |
---|
| 417 | infowid = get_cal_value(event.handler, winfo_id) |
---|
[226] | 418 | ENDELSE |
---|
[69] | 419 | ; |
---|
| 420 | widget_control, winfo_id, set_uvalue = infowid |
---|
| 421 | return, {CW_CALENDAR, ID:event.handler, TOP:event.top, HANDLER:0L $ |
---|
| 422 | , VALUE:infowid.date, FAKECAL: infowid.fakecal} |
---|
[2] | 423 | end |
---|
| 424 | ;---------------------------------------------------------------------- |
---|
[69] | 425 | ;---------------------------------------------------------------------- |
---|
[150] | 426 | ;+ |
---|
| 427 | ; @file_comments |
---|
| 428 | ; |
---|
| 429 | ; |
---|
| 430 | ; @categories |
---|
[157] | 431 | ; Compound widget |
---|
[226] | 432 | ; |
---|
[150] | 433 | ; @param PARENT {in}{required} |
---|
| 434 | ; The widget ID of the parent widget. |
---|
| 435 | ; |
---|
| 436 | ; @param CALENDAR |
---|
| 437 | ; |
---|
| 438 | ; |
---|
| 439 | ; @param JDATE0 |
---|
| 440 | ; |
---|
| 441 | ; @keyword CALTYPE |
---|
[226] | 442 | ; |
---|
[150] | 443 | ; @keyword FAKECAL |
---|
| 444 | ; |
---|
[226] | 445 | ; |
---|
[150] | 446 | ; @keyword UVALUE |
---|
| 447 | ; |
---|
| 448 | ; @keyword UNAME |
---|
| 449 | ; |
---|
[226] | 450 | ; |
---|
[150] | 451 | ; @keyword _EXTRA |
---|
[231] | 452 | ; Used to pass keywords |
---|
[226] | 453 | ; |
---|
[150] | 454 | ; @returns |
---|
[226] | 455 | ; |
---|
[150] | 456 | ; @uses |
---|
[226] | 457 | ; |
---|
[150] | 458 | ; @restrictions |
---|
[226] | 459 | ; |
---|
[150] | 460 | ; @examples |
---|
[226] | 461 | ; |
---|
[150] | 462 | ; @history |
---|
[226] | 463 | ; |
---|
| 464 | ; @version |
---|
[150] | 465 | ; $Id$ |
---|
| 466 | ; |
---|
| 467 | ; @todo |
---|
| 468 | ; seb |
---|
[226] | 469 | ; |
---|
[150] | 470 | ;- |
---|
[232] | 471 | FUNCTION cw_calendar, parent, calendar, jdate0, CALTYPE = CALTYPE, FAKECAL = fakecal, UVALUE = uvalue, UNAME = uname, _EXTRA = ex |
---|
| 472 | ; |
---|
[69] | 473 | @cm_4cal |
---|
| 474 | ; |
---|
[226] | 475 | compile_opt strictarr, strictarrsubs |
---|
[69] | 476 | ; |
---|
| 477 | if keyword_set(caltype) then key_caltype = caltype |
---|
| 478 | ; months days years found in the calendar |
---|
[279] | 479 | caldat, calendar, monthcal, daycal, yearcal, hourcal, mincal, seccal |
---|
| 480 | hmscal = hourcal / 24.0d0 + mincal/1440.0d0 + seccal / 86400.0d0 |
---|
[69] | 481 | ; starting date |
---|
| 482 | if n_elements(jdate0) EQ 0 then jdate0 = calendar[0] |
---|
| 483 | if (where(calendar EQ jdate0))[0] EQ -1 then jdate0 = calendar[0] |
---|
[74] | 484 | ; |
---|
[69] | 485 | caldat, jdate0, month0, day0, year0 |
---|
| 486 | ; test the type of calendar |
---|
| 487 | if n_elements(calendar) GT 1 then BEGIN |
---|
| 488 | ; each day have the same value |
---|
| 489 | if n_elements(uniq(daycal, sort(daycal))) EQ 1 then monthly = 1 |
---|
| 490 | ; each month and each day have the same value |
---|
| 491 | if keyword_set(monthly) AND n_elements(uniq(monthcal, sort(monthcal))) EQ 1 then yearly = 1 |
---|
| 492 | endif |
---|
[2] | 493 | ;--------------------------------------------------------------------------------------- |
---|
[69] | 494 | if NOT keyword_set(uvalue) then uvalue = {dummy:''} |
---|
| 495 | if NOT keyword_set(uname) then uname = '' |
---|
| 496 | base0 = widget_base(parent, /ROW $ |
---|
[2] | 497 | , EVENT_FUNC = 'cw_calendar_event' $ |
---|
[69] | 498 | , FUNC_GET_VALUE = 'cw_calendar_get_value' $ |
---|
| 499 | , PRO_SET_VALUE = 'cw_calendar_set_value' $ |
---|
| 500 | , UVALUE = uvalue, UNAME = uname, space = 0, _extra = ex) |
---|
| 501 | ; |
---|
| 502 | |
---|
| 503 | if n_elements(fakecal) eq 0 then fakecal = 0 |
---|
| 504 | base = widget_base(base0, space = 0, uname = 'infocal' $ |
---|
| 505 | , uvalue = {calendar:calendar, date:jul2date(jdate0), fakecal:fakecal, caltype: key_caltype}) |
---|
| 506 | ; |
---|
[226] | 507 | IF keyword_set(fakecal) THEN BEGIN |
---|
[69] | 508 | cmbbid = cw_combobox_pm(base, UVALUE = {name:'step'}, UNAME = 'step' $ |
---|
| 509 | , value = strtrim(indgen(n_elements(calendar)), 1)) |
---|
| 510 | widget_control, cmbbid, set_value = {combobox_select:(where(calendar EQ jdate0))[0]} |
---|
[226] | 511 | ENDIF ELSE BEGIN |
---|
[69] | 512 | ; |
---|
| 513 | vallen = widget_info(base, string_size = 'm') |
---|
| 514 | ;-------------day----------------- |
---|
| 515 | if NOT keyword_set(monthly) then begin |
---|
| 516 | dayindex = where(monthcal EQ month0 AND yearcal EQ year0) |
---|
[2] | 517 | currentday = daycal[dayindex] |
---|
[69] | 518 | currentday = strtrim(currentday, 1) |
---|
[279] | 519 | hms = hmscal[dayindex] |
---|
| 520 | cmbbid = cw_combobox_pm(base, UVALUE = {name:'day', hms:hms}, UNAME = 'day', value = currentday) |
---|
[69] | 521 | widget_control, cmbbid, set_value = {combobox_select:(where(long(currentday) EQ day0))[0]} |
---|
| 522 | endif |
---|
| 523 | ;-------------month--------------- |
---|
| 524 | if NOT keyword_set(yearly) then BEGIN |
---|
| 525 | monthindex = where(yearcal EQ year0) |
---|
[2] | 526 | currentmonth = long(monthcal[monthindex]) |
---|
[69] | 527 | ; we suppress the repeted months |
---|
[2] | 528 | monthindexbis = uniq(currentmonth, sort(currentmonth)) |
---|
| 529 | monthindex = monthindex[monthindexbis] |
---|
| 530 | currentmonth = currentmonth[monthindexbis] |
---|
[69] | 531 | xoff = (34 + 2*vallen[0])*(1-keyword_set(monthly)) |
---|
| 532 | cmbbid = cw_combobox_pm(base, UVALUE = {name:'month'}, UNAME = 'month', value = string(format = '(C(CMoA))', 31*(currentmonth-1)), xoffset = xoff) |
---|
| 533 | widget_control, cmbbid, set_value = {combobox_select:(where(long(currentmonth) EQ month0))[0]} |
---|
| 534 | endif |
---|
[2] | 535 | ;-------------year---------------- |
---|
[69] | 536 | yearindex = uniq(yearcal, sort(yearcal)) |
---|
| 537 | currentyear = strtrim(yearcal[yearindex], 1) |
---|
| 538 | xoff = (34 + 2*vallen[0])*(1-keyword_set(monthly)) + (33 + 3*vallen[0])*(1-keyword_set(yearly)) |
---|
| 539 | cmbbid = cw_combobox_pm(base, UVALUE = {name:'year'}, UNAME = 'year', value = currentyear, xoffset = xoff) |
---|
| 540 | widget_control, cmbbid, set_value = {combobox_select:(where(long(currentyear) EQ year0))[0]} |
---|
[2] | 541 | ;----------------------------- |
---|
[69] | 542 | ENDELSE |
---|
[2] | 543 | ; |
---|
[69] | 544 | return, base |
---|
[2] | 545 | end |
---|