/* * This sends the new list of names to the properties database. Note it ignores * items that have been tagged for deletion. */ static void blist_write_list(Browselist *bl, Props *p) { int i, len = 0; char *buf; BlistData *bd; /* * First pass, count the number of bytes we're going to need */ for (i = 1; i <= bl->blist_data->count; i++) { bd = (BlistData *)CmDataListGetData(bl->blist_data, i); if (bd && bd->name && bd->tag != BLIST_DELETE) len += cm_strlen(bd->name) + 2; /* one for spacing */ } if (len <= 0) return; /* * We have names, so build the string, making sure to exclude items * tagged for delete. */ buf = (char *)ckalloc(len); memset(buf, '\0', len); for (i = 1; i <= bl->blist_data->count; i++) { bd = (BlistData *)CmDataListGetData(bl->blist_data, i); if (bd && bd->name && bd->tag != BLIST_DELETE) { cm_strcat(buf, bd->name); cm_strcat(buf, " "); bd->tag = BLIST_ACTIVE; } } set_char_prop(p, CP_DAYCALLIST, buf); save_props(p); free(buf); }
extern void format_abbrev_appt(Dtcm_appointment *appt, char *b, Boolean show_am, DisplayType display) { int hr, mn; Tick tick; Lines *lines=NULL; Boolean am = True; struct tm *tm; _Xltimeparams localtime_buf; if(appt==NULL || b==NULL) return; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); tm = _XLocaltime(&tick, localtime_buf); hr = tm->tm_hour; mn = tm->tm_min; if (showtime_set(appt) && !magic_time(tick)) { if (display == HOUR12) { am = adjust_hour(&hr); if (show_am) sprintf(b, "%2d:%02d%s ", hr, mn, am ? "a" : "p"); else sprintf(b, "%2d:%02d ", hr, mn); } else sprintf(b, "%02d%02d ", hr, mn); } lines = text_to_lines(appt->what->value->item.string_value, 1); if (lines != NULL && lines->s != NULL) { (void) cm_strcat(b, lines->s); destroy_lines(lines); } }
/* The following routine is specific to using FMapType 3 composite fonts * in postscript. Kanji, Asian specific? */ char * euc_to_octal(char *srcStr) { int inKanji = FALSE; char buf[64]; static char dstStr[512]; int i; int len = cm_strlen(srcStr); #ifdef SVR4 memset(dstStr, 0, sizeof(dstStr)); #else bzero(dstStr, sizeof(dstStr)); #endif /* SVR4 */ for (i = 0; i < len; i++) { if (inKanji) { if (!isEUC(srcStr[i])) { inKanji = FALSE; /* NOT NEEDED FOR FMapType 4 (or 5) cm_strcat(dstStr, "\\377\\000"); */ } } else { if (isEUC(srcStr[i])) { inKanji = TRUE; /* NOT NEEDED FOR FMapType 4 (or 5) cm_strcat(dstStr, "\\377\\001"); */ } } if (inKanji) { sprintf(buf, "\\%3.3o\\%3.3o", srcStr[i] & 0xff, srcStr[i+1] & 0xff); i++; } else { sprintf(buf, "%c", srcStr[i]); } cm_strcat(dstStr, buf); } return dstStr; }
/* * Format 2 lines of appt data */ extern void format_maxchars(Dtcm_appointment *appt, char *buf1, int maxchars, DisplayType display) { Tick tick, end_tick = 0; int hour1, min1, hour2, min2; Lines *lines; char *s1, *s2; struct tm *tm; _Xltimeparams localtime_buf; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); if (appt->end_time) _csa_iso8601_to_tick(appt->end_time->value->item.string_value, &end_tick); *buf1 = NULL; if (appt == NULL || appt->what->value->item.string_value == NULL) return; tm = _XLocaltime(&tick, localtime_buf); hour1 = tm->tm_hour; min1 = tm->tm_min; if (showtime_set(appt) && !magic_time(tick)) { s1 = s2 = "am"; if (display == HOUR12 && !adjust_hour(&hour1)) s1="pm"; if (end_tick) { hour2 = hour(end_tick); if (display == HOUR12 && !adjust_hour(&hour2)) s2="pm"; min2 = minute(end_tick); } if (end_tick == 0 || hour1 == hour2 && min1 == min2) { if (display == HOUR24) sprintf(buf1, "%02d%02d ", hour1, min1); else sprintf(buf1, "%d:%.2d%s ", hour1, min1, s1); } else { if (display == HOUR12) sprintf(buf1, "%d:%.2d%s-%d:%.2d%s ", hour1, min1, s1, hour2, min2, s2); else sprintf(buf1, "%02d%02d-%02d%02d ", hour1, min1, hour2, min2); } } lines = (Lines *) text_to_lines(appt->what->value->item.string_value, 10); while (lines != NULL) { if ((cm_strlen(buf1) + cm_strlen(lines->s)) < (maxchars-2)) { cm_strcat(buf1, lines->s); lines = lines->next; if (lines != NULL) cm_strcat(buf1, " - "); } else { strncat(buf1, lines->s, (maxchars - cm_strlen(buf1)-1)); break; } } destroy_lines(lines); }
/* * Format 1 line of appt data. Returns True if begin hour is < 10 - thus * padding needs to be done. */ extern Boolean format_line(Tick tick, char *what, char *buf, int end_tick, Boolean showtime, DisplayType display) { int hr, hr1, mn, mn1; Boolean am=True; Boolean am_end=True; struct tm *tm; Boolean pad = FALSE; _Xltimeparams localtime_buf; if (buf==NULL) return pad; buf[0]=NULL; tm = _XLocaltime(&tick, localtime_buf); hr = tm->tm_hour; mn = tm->tm_min; if (showtime && !magic_time(tick)) { if (display == HOUR12) am = adjust_hour(&hr); if (end_tick && end_tick != tick) { hr1 = hour(end_tick); mn1 = minute(end_tick); if (display == HOUR12) { am_end = adjust_hour(&hr1); if (am_end != am) { (void) sprintf(buf, "%d:%.2d - %d:%.2d%s ", hr, mn, hr1, mn1, am_end ? "am" : "pm"); } else { (void) sprintf(buf, "%d:%.2d - %d:%.2d ", hr, mn, hr1, mn1); } if (hr < 10) pad = TRUE; } else (void) sprintf(buf, "%02d%02d - %02d%02d ", hr, mn, hr1, mn1); } else { /* Check to see if there are 2 digits in in initial time format. If so, pad with 1 space; if not 2. The font is not fixed width, so I have to line it up myself.. */ if (display == HOUR12) { if (hr > 9) (char *)sprintf(buf, "%2d:%.2d%s ", hr, mn, am ? "a" : "p"); else { (char *)sprintf(buf, "%d:%.2d%s ", hr, mn, am ? "a" : "p"); pad = TRUE; } } else (char *)sprintf(buf, "%02d%02d ", hr, mn); } } if (what) (void) cm_strcat(buf, what); return pad; }
static void paint_dayview_appts(Calendar *c, Paint_cache *cache, int a_total, void *rect) { int w = c->view->boxw; int h = c->view->boxh; int begin_time, end_time; int x, x2, y, y2, num_hrs, i, last_hr, hr, x_off; Cal_Font *pf = c->fonts->boldfont; Cal_Font *pf2 = c->fonts->viewfont; XFontSetExtents fontextents; XFontSetExtents fontextents2; Props *p = (Props*)c->properties; Boolean am = True; char buf[5], *appt_str; int pfy, curr_line, maxlines; Lines *lines = NULL, *headlines = NULL; DisplayType disp_t; Colormap cmap; Pixel fg; Tick start_tick, end_tick; int nop, hrbox_margin; CalFontExtents(pf, &fontextents); CalFontExtents(pf2, &fontextents2); XtVaGetValues(c->canvas, XmNcolormap, &cmap, XmNforeground, &fg, NULL); /* draw horizontal lines */ begin_time = get_int_prop(p, CP_DAYBEGIN); end_time = get_int_prop(p, CP_DAYEND); disp_t = get_int_prop(p, CP_DEFAULTDISP); num_hrs = end_time - begin_time + 1; if (disp_t == HOUR12) CalTextExtents(pf, "12pm", 4, &nop, &nop, &hrbox_margin, &nop); else CalTextExtents(pf, "24 ", 3, &nop, &nop, &hrbox_margin, &nop); x = MOBOX_AREA_WIDTH+2; x2 = x + w; y = c->view->topoffset; for (i = 0; i <= num_hrs; i++) { gr_draw_line(c->xcontext, x, y, x2, y, gr_solid, rect); y += h; } /* draw vertical line */ y = c->view->topoffset; y2 = y + num_hrs * h; x += hrbox_margin; gr_draw_line(c->xcontext, x, y, x, y2, gr_solid, rect); x = MOBOX_AREA_WIDTH+3; y += h/2+4; /* draw in hours */ for (i = begin_time - 1; i < end_time; i++) { hr = i; if (i < begin_time) (void) sprintf(buf, ""); else if (disp_t == HOUR12) { am = adjust_hour(&hr); (void) sprintf(buf, "%d%s", hr, am ? "a" : "p"); } else (void) sprintf(buf, "%02d", hr); x_off = gr_center(hrbox_margin, buf, pf); /* REVISIT: unclear why we're still distinguishing between gr_text[_rgb] if (c->xcontext->screen_depth >= 8) gr_text_rgb(c->xcontext, x+x_off, y, pf, buf, fg, cmap, rect); else */ gr_text(c->xcontext, x+x_off, y, pf, buf, rect); y += h; } /* draw in appointments */ x = MOBOX_AREA_WIDTH + hrbox_margin + 6; pfy = fontextents2.max_logical_extent.height; maxlines = (h - 6) / pfy; curr_line = last_hr = 0; /* loop thru, getting out the "no time" appointments */ for (i = 0; i < a_total; i++) { if (i != a_total) last_hr = hr; hr = begin_time; if (cache[i].show_time == 0) { if (last_hr != hr) curr_line = 0; y = c->view->topoffset + 2 + pfy; if (curr_line < maxlines) { y += (curr_line * pfy) + h * (hr - begin_time); headlines = lines = text_to_lines(cache[i].summary, 4); start_tick = cache[i].start_time; end_tick = cache[i].end_time; if (lines != NULL && lines->s != NULL) { appt_str = ckalloc(cm_strlen(lines->s)+18); format_line(start_tick, lines->s, appt_str, end_tick, cache[i].show_time, disp_t); lines = lines->next; } else { appt_str = ckalloc(15); format_line(start_tick, (char*)NULL, appt_str, end_tick, cache[i].show_time, disp_t); } appt_str[cm_strlen(appt_str)]=NULL; /* REVISIT: unclear why we're still distinguishing between gr_text[_rgb] if (c->xcontext->screen_depth >= 8) gr_text_rgb(c->xcontext, x, y, pf2, appt_str, fg, cmap, rect); else */ gr_text(c->xcontext, x, y, pf2, appt_str, rect); free(appt_str); appt_str = NULL; curr_line++; if (curr_line < maxlines && lines != NULL) { appt_str = ckalloc(324); cm_strcpy(appt_str, " "); while (lines != NULL) { if (lines->s != NULL) cm_strcat(appt_str, lines->s); lines = lines->next; if (lines != NULL && lines->s != NULL) cm_strcat(appt_str, " - "); } y += pfy; /* REVISIT: unclear why we're still distinguishing between gr_text[_rgb] if (c->xcontext->screen_depth >= 8) gr_text_rgb(c->xcontext, x, y, pf2, appt_str, fg, cmap, rect); else */ gr_text(c->xcontext, x, y, pf2, appt_str, rect); curr_line++; free(appt_str); appt_str = NULL; } destroy_lines(headlines); lines=NULL; } } } for (i = 0; i < a_total; i++) { if (i != a_total) last_hr = hr; start_tick = cache[i].start_time; end_tick = cache[i].end_time; hr = hour(start_tick); if (hr >= begin_time && hr < end_time && (cache[i].show_time && !magic_time(start_tick))) { if (last_hr != hr) curr_line = 0; y = c->view->topoffset + 2 + pfy; if (curr_line < maxlines) { y += (curr_line * pfy) + h * (hr - begin_time + 1); headlines = lines = text_to_lines(cache[i].summary, 4); if (lines != NULL && lines->s != NULL) { appt_str = ckalloc(cm_strlen(lines->s)+18); format_line(start_tick, lines->s, appt_str, end_tick, cache[i].show_time, disp_t); lines = lines->next; } else { appt_str = ckalloc(15); format_line(start_tick, (char*)NULL, appt_str, end_tick, cache[i].show_time, disp_t); } appt_str[cm_strlen(appt_str)]=NULL; /* REVISIT: unclear why we're still distinguishing between gr_text[_rgb] if (c->xcontext->screen_depth >= 8) gr_text_rgb(c->xcontext, x, y, pf2, appt_str, fg, cmap, rect); else */ gr_text(c->xcontext, x, y, pf2, appt_str, rect); free(appt_str); appt_str = NULL; curr_line++; if (curr_line < maxlines && lines != NULL) { appt_str = ckalloc(324); cm_strcpy(appt_str, " "); while (lines != NULL) { if (lines->s != NULL) cm_strcat(appt_str, lines->s); lines = lines->next; if (lines != NULL && lines->s != NULL) cm_strcat(appt_str, " - "); } y += pfy; /* REVISIT: unclear why we're still distinguishing between gr_text[_rgb] if (c->xcontext->screen_depth >= 8) gr_text_rgb(c->xcontext, x, y, pf2, appt_str, fg, cmap, rect); else */ gr_text(c->xcontext, x, y, pf2, appt_str, rect); curr_line++; free(appt_str); appt_str = NULL; } destroy_lines(headlines); lines=NULL; } } } }