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