Beispiel #1
0
static void
cb_complete_run (CutRunContext *run_context, gboolean success,
                 CutPDFReport *report)
{
#ifdef HAVE_GOFFICE
    cairo_save(report->context);
    draw_chart(report, run_context);
    cairo_restore(report->context);
    cairo_show_page(report->context);
#endif

    init_page(report->context);
    show_summary(report, run_context);
}
Beispiel #2
0
static void
draw_week(Calendar *c, XRectangle *rect, Boundary boundary)
{
    Week *w = (Week *)c->view->week_info;
    register int    current_day;
    register int    n;
    register int    x, y;
    int             char_height;
    int             start_date;
    char            **day_names;
    char            label[80];
    char		buf[MAXNAMELEN];
    char		*footer_message = NULL;
    int             start_ind, end_ind;
    int             today_dom, day_om;
    new_XContext        *xc;
    Props           *p = (Props*)c->properties;
    XRectangle      chartrect;
    OrderingType	ot = get_int_prop(p, CP_DATEORDERING);
    Tick		start_tick, end_tick;
    time_t start, stop;
    CSA_return_code stat;
    CSA_entry_handle *list;
    CSA_attribute *range_attrs;
    CSA_enum *ops;
    CSA_uint32 a_total;
    int i, lower_bound = 0, upper_bound = 0;
    XFontSetExtents regfontextents, boldfontextents;
    int	notused, width1, width2, width3;

    CalFontExtents(w->font, &regfontextents);
    char_height = regfontextents.max_logical_extent.height;
    start_date      = w->start_date;
    xc              = c->xcontext;

    start = (time_t) lowerbound(start_date);
    stop = (time_t) next_ndays(start, 7) - 1;

    if (c->paint_cache == NULL) {
        setup_range(&range_attrs, &ops, &i, start, stop, CSA_TYPE_EVENT,
                    0, B_FALSE, c->general->version);
        csa_list_entries(c->cal_handle, i, range_attrs, ops,
                         &a_total, &list, NULL);
        free_range(&range_attrs, &ops, i);
        allocate_paint_cache(list, a_total, &c->paint_cache);
        c->paint_cache_size = a_total;
        csa_free(list);
    }


    gr_clear_box(xc, 0, 0, w->canvas_w, w->canvas_h);

    CalTextExtents(w->font, days2[3], cm_strlen(days2[3]),
                   &notused, &notused, &width1, &notused);
    CalTextExtents(w->font, "  00", cm_strlen("  00"),
                   &notused, &notused, &width2, &notused);
    CalTextExtents(w->font, "Wed 00", cm_strlen("Wed 00"),
                   &notused, &notused, &width3, &notused);
    if (width1 + width2 <= w->day_width - 2)
        day_names = days2;
    else if (width3 <= w->day_width - 2)
        day_names = days;
    else
        day_names = days3;
    x = w->x;
    y = w->y;

    format_week_header(start_date, ot, label);
    gr_text(xc, x, y - char_height / 2, w->font, label, rect);

    /*
     * Draw bold box around first 5 days
     */
    gr_draw_box(xc, x, y, w->width, w->day_height, rect);
    gr_draw_box(xc, x - 1, y - 1, w->width + 2, w->day_height + 2, rect);
    gr_draw_line(xc, x, y + w->label_height, x + w->width,
                 y + w->label_height, gr_solid, rect);

    /*
     * Draw bold box around last 2 days
     */
    x += 3 * w->day_width;
    y += w->day_height;

    gr_draw_box(xc, x, y, 2 * w->day_width, w->day_height, rect);
    gr_draw_box(xc, x - 1, y, 2 * w->day_width + 2, w->day_height + 1,rect);
    gr_draw_line(xc, x, y + w->label_height, x + 2 * w->day_width,
                 y + w->label_height, gr_solid, rect);
    y = w->y;
    x = w->x + w->day_width;
    for (n = 0; n < 4; n++) {
        if (n < 3) {
            gr_draw_line(xc, x, y, x, y + w->day_height,
                         gr_solid, rect);
        } else {
            gr_draw_line(xc, x, y, x, y + 2 * w->day_height,
                         gr_solid, rect);
        }
        x += w->day_width;
    }
    /*
      * Fill in week with appointments
      */
    x = w->x;
    y = w->y;
    current_day = start_date;
    today_dom = dom(time(0));

    /* Crock alert!!!!  The obscure code below is doing something
       really nasty.  The variable boundary indicates whether the
       week being displayed falls across a boundary with the
       beginning or the end of time.  In the case of the beginning
       of time, the code then assumes that the first 2 days in the
       week need to be unbuttoned, and the rest buttoned and painted.
       Likewise, with the end of time case, the code assumes the last
       3 days of the week need similar treatment. */

    for (n = 0; n < 7; n++)  {

        if (n == 5) {
            y += w->day_height;
            x = w->x + 3 * w->day_width;
        }

        if (boundary == okay) {
            day_om = dom(current_day);
            display_hot_btn(c, n, day_om);
            fill_day(c, w, x, y, current_day,
                     c->paint_cache, c->paint_cache_size, rect);
            current_day += daysec;
            if (lower_bound > 0) {
                sprintf(buf, "%s", catgets(c->DT_catd, 1, 623, "Calendar does not display dates prior to January 1, 1970"));
                footer_message = buf;
            }
            else
                footer_message = NULL;
        }
        else if (boundary == lower) {
            /* skip days before Jan 1, 1970 */
            clear_hot_btn(c, n);
            if (lower_bound++ == 2)
                boundary = okay;
        }
        else if (boundary == upper) {
            day_om = dom(current_day);
            if (++upper_bound <= 4)
                display_hot_btn(c, n, day_om);
            fill_day(c, w, x, y, current_day,
                     c->paint_cache, c->paint_cache_size, rect);
            current_day += daysec;
            sprintf(buf, "%s", catgets(c->DT_catd, 1, 624, "Calendar does not display dates after December 31, 2037"));
            footer_message = buf;
            if (upper_bound > 4)
                clear_hot_btn(c, n);
        }
        x += w->day_width;
    }
    if (rect != NULL) {
        CalFontExtents(w->small_bold_font, &boldfontextents);

        chartrect.x = w->x;
        chartrect.y = w->chart_y - w->label_height;
        chartrect.width = w->chart_width +
                          3*boldfontextents.max_logical_extent.width;
        chartrect.height = w->chart_height + 2*w->label_height;
    }

    if (rect == NULL || myrect_intersectsrect(rect,  &chartrect)) {
        for (i = 0; i < c->paint_cache_size; i++) {
            start_tick = (c->paint_cache)[i].start_time;
            end_tick = (c->paint_cache)[i].end_time;
            cm_update_segs(w, start_tick,
                           (end_tick ? (end_tick - start_tick) : 0),
                           &start_ind, &end_ind, True);
        }
        chart_draw_appts(w, 0, w->segs_in_array);
        draw_chart(c, w, NULL);
    }

    /* do not repaint the footer message in a damage display.
       For some reason this causes the damage routine to get called
       again, resulting in a recursive dsaster. */

    if (footer_message && !rect)
        set_message(c->message_text, footer_message);
}