extern void paint_day(Calendar *c) { Day *day_info = (Day *) c->view->day_info; c->view->glance = dayGlance; XmToggleButtonGadgetSetState(c->day_scope, True, False); gr_clear_area(c->xcontext, 0, 0, c->view->winw, c->view->winh); if (day_info->month_panels == (Widget *) NULL) (void)init_dayview(c); paint_dayview(c, True, NULL, True); calendar_select(c, hourSelect, (caddr_t)NULL); }
static void day_btn_cb(Widget w, XtPointer client, XtPointer call) { XmMonthPanelCallbackStruct *cbs = (XmMonthPanelCallbackStruct *) call; Calendar *c = (Calendar *)client; int monthno, year; int date = c->view->date; invalidate_cache(c); XtVaGetValues(w, XmNmonth, &monthno, XmNyear, &year, NULL); if (cbs->type == MONTH_SELECTION) { XtUnmapWidget(c->canvas); /* * Date update: * if month chosen is not current month * set date to 1st of new month, otherwise * don't change date. */ if (month(c->view->date) != monthno) { calendar_deselect (c); c->view->olddate = c->view->date; c->view->date = monthdayyear(monthno, 1, year); c->view->nwks = numwks(c->view->date); calendar_select (c, monthSelect, NULL); } /* switch to month view */ c->view->glance = monthGlance; cleanup_after_dayview(c); prepare_to_paint_monthview(c, NULL); XtMapWidget(c->canvas); } else { /* type == DAY_SELECTION */ c->view->olddate = c->view->date; c->view->date = monthdayyear(monthno, cbs->day, year); gr_clear_area(c->xcontext, 0, 0, c->view->winw, c->view->winh); paint_dayview(c, True, NULL, False); calendar_select(c, hourSelect, (caddr_t)NULL); } }
extern void cleanup_after_dayview(Calendar *c) { Day *d = (Day *)c->view->day_info; invalidate_cache(c); XtUnmanageChild(d->panel_form); XmToggleButtonGadgetSetState(c->day_scope, False, False); /* make canvas attach to form, and ignore its XmNleftPosition */ /* DITTO ABOVE: THIS ISN'T NEEDED TILL WE ACTUALLY DO RESIZE THE CANVAS TO ADJOIN THE MONTHPANELS WHILE DAY VIEW IS UP XtVaSetValues(c->canvas, XmNleftAttachment, XmATTACH_FORM, NULL); */ gr_clear_area(calendar->xcontext, 0, 0, calendar->view->winw, calendar->view->winh); set_message(c->message_text, ""); }
extern void paint_dayview(Calendar *c, Boolean repaint, XRectangle *rect, Boolean update_months) { Props *p = (Props*)c->properties; int num_hrs; int beg = get_int_prop(p, CP_DAYBEGIN); int end = get_int_prop(p, CP_DAYEND); time_t start, stop; CSA_attribute *range_attrs; CSA_entry_handle *list; CSA_enum *ops; int i, j; CSA_uint32 a_total; int panel0_year, panel0_month; int panel1_year, panel1_month; int panel2_year, panel2_month; int year_num, month_num; Boolean day_not_on_panel = False; Day *d = (Day *)c->view->day_info; int top_panel = 0; int bottom_panel = 2; num_hrs = end - beg + 1; if (c->paint_cache == NULL) { start = (time_t) lower_bound(0, c->view->date); stop = (time_t) next_nhours(start, end+1) - 1; setup_range(&range_attrs, &ops, &j, start, stop, CSA_TYPE_EVENT, NULL, B_FALSE, c->general->version); csa_list_entries(c->cal_handle, j, range_attrs, ops, &a_total, &list, NULL); free_range(&range_attrs, &ops, j); allocate_paint_cache(list, a_total, &c->paint_cache); c->paint_cache_size = a_total; csa_free(list); } year_num = year(c->view->date); month_num = month(c->view->date); XtVaGetValues(d->month_panels[1], XmNyear, &panel1_year, XmNmonth, &panel1_month, NULL); if ((panel1_year == year(get_bot())) && (panel1_month == 1)) top_panel = 1; else if ((panel1_year == year(get_eot())) && (panel1_month == 12)) bottom_panel = 1; XtVaGetValues(d->month_panels[top_panel], XmNyear, &panel0_year, XmNmonth, &panel0_month, NULL); if ((year_num < panel0_year) || ((year_num == panel0_year) && (month_num < panel0_month))) day_not_on_panel = True; XtVaGetValues(d->month_panels[bottom_panel], XmNyear, &panel2_year, XmNmonth, &panel2_month, NULL); if ((year_num > panel2_year) || ((year_num == panel2_year) && (month_num > panel2_month))) day_not_on_panel = True; /* set up month panels */ if (update_months || day_not_on_panel) update_quarter(c); /* no need to do this on a damage event */ if (!rect) display_monthpanels(c); /* repaint appointment area */ if (repaint) { int line_length; gr_clear_area(c->xcontext, 0, 0, c->view->winw, c->view->winh); line_length = c->view->topoffset + ((end - beg + 1) * c->view->boxh); /* draw line separating mo. boxes and appts. */ gr_draw_line(c->xcontext, (int)MOBOX_AREA_WIDTH+1, 0, (int)MOBOX_AREA_WIDTH+1, line_length, gr_solid, rect); gr_draw_line(c->xcontext, (int)MOBOX_AREA_WIDTH+2, 0, (int)MOBOX_AREA_WIDTH+2, line_length, gr_solid, rect); gr_draw_line(c->xcontext, (int)MOBOX_AREA_WIDTH+2, c->view->topoffset-1, c->view->winw, c->view->topoffset-1, gr_solid, rect); gr_draw_line(c->xcontext, (int)MOBOX_AREA_WIDTH+2, c->view->topoffset, c->view->winw, c->view->topoffset, gr_solid, rect); paint_dayview_appts(c, c->paint_cache, c->paint_cache_size, rect); } /* just repaint schedule area */ else { gr_clear_area(c->xcontext, (int)MOBOX_AREA_WIDTH+4, 0, c->view->winw - (int)MOBOX_AREA_WIDTH+4, c->view->winh); gr_draw_line(c->xcontext, (int)MOBOX_AREA_WIDTH+2, c->view->topoffset, c->view->winw, c->view->topoffset, gr_solid, rect); gr_draw_line(c->xcontext, (int)MOBOX_AREA_WIDTH+2, c->view->topoffset+1, c->view->winw, c->view->topoffset+1, gr_solid, rect); paint_dayview_appts(c, c->paint_cache, c->paint_cache_size, rect); } paint_day_header(c, c->view->date, rect); }
static void chart_draw_appts(Week *w, int start, int end) { int x, y, h, i, segs_in_col, no_boxes; Calendar *c = calendar; int col_remainder, boxseg_h; Colormap cms; XtVaGetValues(c->canvas, XmNcolormap, &cms, NULL); h = boxseg_h = (double)w->chart_hour_height / (double)BOX_SEG; segs_in_col = (w->segs_in_array / 7); /* find starting segment in column */ col_remainder = (start % segs_in_col); no_boxes = (double)(col_remainder+1) / (double)BOX_SEG; y = w->chart_y + ((double)col_remainder * (double)boxseg_h) + ((double)w->add_pixels * (double)no_boxes) + 1; x = w->chart_x + ((double)start / (double)segs_in_col * (double)w->chart_day_width); for (i = start; i < end; i++) { if (w->time_array[i] == 0) { /* batch up repaints */ if ( (i+1) < w->segs_in_array && w->time_array[i+1] == 0 && ((i+1) % segs_in_col) != 0 ) { h += boxseg_h; add_extra_pixels(i, w->add_pixels, &h); continue; } add_extra_pixels(i, w->add_pixels, &h); gr_clear_area(c->xcontext, x, y, w->chart_day_width, h); } else if (w->time_array[i] == 1) { /* batch up for one repaint */ if ( (i+1) < w->segs_in_array && w->time_array[i+1] == 1 && ((i+1) % segs_in_col) != 0 ) { h += boxseg_h; add_extra_pixels(i, w->add_pixels, &h); continue; } add_extra_pixels(i, w->add_pixels, &h); if ((c->xcontext->screen_depth < 8) || FAKE_MONOCHROME) gr_make_gray(c->xcontext, x, y, w->chart_day_width, h, 25); else gr_make_grayshade(c->xcontext, x, y, w->chart_day_width, h, LIGHTGREY); } else if (w->time_array[i] == 2) { /* batch up for one repaint */ if ( (i+1) < w->segs_in_array && w->time_array[i+1] == 2 && ((i+1) % segs_in_col) != 0 ) { h += boxseg_h; add_extra_pixels(i, w->add_pixels, &h); continue; } add_extra_pixels(i, w->add_pixels, &h); if ((c->xcontext->screen_depth < 8) || FAKE_MONOCHROME) gr_make_gray(c->xcontext, x, y, w->chart_day_width, h, 50); else gr_make_rgbcolor(c->xcontext, cms, x, y, w->chart_day_width, h, MIDGREY, MIDGREY, MIDGREY); } else if (w->time_array[i] >= 3) { /* batch up for one repaint */ if ( (i+1) < w->segs_in_array && w->time_array[i+1] >= 3 && ((i+1) % segs_in_col) != 0 ) { h += boxseg_h; add_extra_pixels(i, w->add_pixels, &h); continue; } add_extra_pixels(i, w->add_pixels, &h); if ((c->xcontext->screen_depth < 8) || FAKE_MONOCHROME) gr_make_gray(c->xcontext, x, y, w->chart_day_width, h, 75); else gr_make_grayshade(c->xcontext, x, y, w->chart_day_width, h, DIMGREY); } if (i != 0 && (((i+1) % segs_in_col) == 0)) { x += w->chart_day_width; y = w->chart_y + 1; h = ((double)w->chart_hour_height/(double)BOX_SEG); } else { y += h; h = boxseg_h; } } }