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