2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: x_graphics.c /main/15 1996/11/25 10:29:30 rswiston $ */
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
34 #include <EUSCompat.h>
44 #include <sys/param.h>
48 #include "datefield.h"
51 #include "x_graphics.h"
54 #include "dayglance.h"
59 #include <X11/Intrinsic.h>
60 #include <X11/extensions/Print.h>
63 #include <Xm/DialogS.h>
64 #include <Xm/DrawingA.h>
67 #define XOS_USE_XT_LOCKING
68 #define X_INCLUDE_TIME_H
72 #include <X11/Xos_r.h>
75 * There is currently a defect in the X Print Server which
76 * causes the print shell to be created with dimensions 1x1
77 * instead of the dimensions appropriate to the X Print Server.
78 * Until this is corrected, defining SHELL_SIZE_BUG will
79 * cause dtcm to size the print shell to 8.5"x11.0".
81 #define SHELL_SIZE_BUG 1
83 #define BUFFERSIZE 512
84 #define DAYS_IN_WEEK 7
86 #define WEEKEND_DAYS 2
87 #define INTERVALS_PER_DAY 96 /* 4 15-minute intervals per hour * 24 hours */
89 #define VMARGIN(gInfo) (2 * gInfo->normalWd)
90 #define HMARGIN(gInfo) (4 * gInfo->normalWd)
91 #define TODO_HINDENT 10
92 #define TODO_VINDENT 10
103 static String dvFonts[DV_NUM_FONTS];
105 /* Week View fonts */
115 static String wvFonts[WV_NUM_FONTS];
117 /* Month View fonts */
130 static String mvFonts[MV_NUM_FONTS];
132 /* Year View fonts */
142 static String yvFonts[YV_NUM_FONTS];
144 /* Appt View fonts */
156 static String avFonts[AV_NUM_FONTS];
158 /* ToDo View fonts */
170 static String tvFonts[TV_NUM_FONTS];
173 typedef struct _PrintResources
175 Pixel lightGrayPixel;
181 * Unfortunately, the dt-application fonts don't support all the point
182 * sizes we'd like. We use the closest approximation.
185 static char bold40PtFont[] =
186 "-*-times-bold-r-normal-*-0-[80 0 0 40]-0-0-p-0-*-*:";
187 static char bold30PtFont[] =
188 "-*-times-bold-r-normal-*-0-300-0-0-p-0-*-*:";
189 static char bold20PtFont[] =
190 "-*-times-bold-r-normal-*-0-200-0-0-p-0-*-*:";
191 static char bold16PtFont[] =
192 "-*-times-bold-r-normal-*-0-160-0-0-p-0-*-*:";
193 static char bold14PtFont[] =
194 "-*-times-bold-r-normal-*-0-140-0-0-p-0-*-*:";
195 static char bold12PtFont[] =
196 "-*-times-bold-r-normal-*-0-120-0-0-p-0-*-*:";
197 static char bold10PtFont[] =
198 "-*-times-bold-r-normal-*-0-100-0-0-p-0-*-*:";
199 static char bold9PtFont[] =
200 "-*-times-bold-r-normal-*-0-90-0-0-p-0-*-*:";
201 static char bold7PtFont[] =
202 "-*-times-bold-r-normal-*-0-70-0-0-p-0-*-*:";
204 static char helv10PtFont[] =
205 "-*-helvetica-medium-r-normal-*-0-100-0-0-p-0-*-*:";
206 static char helv9PtFont[] =
207 "-*-helvetica-medium-r-normal-*-0-90-0-0-p-0-*-*:";
208 static char helv8PtFont[] =
209 "-*-helvetica-medium-r-normal-*-0-80-0-0-p-0-*-*:";
211 static char cour12PtFont[] =
212 "-*-courier-medium-r-normal-*-0-120-0-0-m-0-*-*:";
213 static char cour7PtFont[] =
214 "-*-courier-medium-r-normal-*-0-70-0-0-m-0-*-*:";
216 static char bold40PtFont[] =
217 "-dt-application-bold-r-normal-serif-0-[80 0 0 40]-0-0-p-0-*-*:";
218 static char bold30PtFont[] =
219 "-dt-application-bold-r-normal-serif-0-300-0-0-p-0-*-*:";
220 static char bold20PtFont[] =
221 "-dt-application-bold-r-normal-serif-0-200-0-0-p-0-*-*:";
222 static char bold16PtFont[] =
223 "-dt-application-bold-r-normal-serif-0-160-0-0-p-0-*-*:";
224 static char bold14PtFont[] =
225 "-dt-application-bold-r-normal-serif-0-140-0-0-p-0-*-*:";
226 static char bold12PtFont[] =
227 "-dt-application-bold-r-normal-serif-0-120-0-0-p-0-*-*:";
228 static char bold10PtFont[] =
229 "-dt-application-bold-r-normal-serif-0-100-0-0-p-0-*-*:";
230 static char bold9PtFont[] =
231 "-dt-application-bold-r-normal-serif-0-90-0-0-p-0-*-*:";
232 static char bold7PtFont[] =
233 "-dt-application-bold-r-normal-serif-0-70-0-0-p-0-*-*:";
235 static char helv10PtFont[] =
236 "-dt-application-medium-r-normal-sans-0-100-0-0-p-0-*-*:";
237 static char helv9PtFont[] =
238 "-dt-application-medium-r-normal-sans-0-90-0-0-p-0-*-*:";
239 static char helv8PtFont[] =
240 "-dt-application-medium-r-normal-sans-0-80-0-0-p-0-*-*:";
242 static char cour12PtFont[] =
243 "-dt-application-medium-r-normal-serif-0-120-0-0-m-0-*-*:";
244 static char cour7PtFont[] =
245 "-dt-application-medium-r-normal-serif-0-70-0-0-m-0-*-*:";
248 static XtResource dvDefaultResources[] =
250 {"dvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
251 sizeof(String) * DV_TITLE_FONT, XmRImmediate,
252 (XtPointer)bold16PtFont},
253 {"dvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
254 sizeof(String) * DV_HEADER_FONT, XmRImmediate,
255 (XtPointer)bold9PtFont},
256 {"dvpApptFont", "PrintApptFont", XmRString, sizeof(String),
257 sizeof(String) * DV_APPT_FONT, XmRImmediate,
258 (XtPointer)helv10PtFont},
259 {"dvpTimeFont", "PrintTimeFont", XmRString, sizeof(String),
260 sizeof(String) * DV_TIME_FONT, XmRImmediate,
261 (XtPointer)bold10PtFont}
264 static XtResource wvDefaultResources[] =
266 {"wvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
267 sizeof(String) * WV_TITLE_FONT, XmRImmediate,
268 (XtPointer)bold16PtFont},
269 {"wvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
270 sizeof(String) * WV_HEADER_FONT, XmRImmediate,
271 (XtPointer)bold9PtFont},
272 {"wvpApptFont", "PrintApptFont", XmRString, sizeof(String),
273 sizeof(String) * WV_APPT_FONT, XmRImmediate,
274 (XtPointer)helv9PtFont},
275 {"wvpDayFont", "PrintDayFont", XmRString, sizeof(String),
276 sizeof(String) * WV_DAY_FONT, XmRImmediate,
277 (XtPointer)bold12PtFont},
278 {"wvpBoxFont", "PrintBoxFont", XmRString, sizeof(String),
279 sizeof(String) * WV_BOX_FONT, XmRImmediate,
280 (XtPointer)bold12PtFont}
283 static XtResource mvDefaultResources[] =
285 {"mvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
286 sizeof(String) * MV_TITLE_FONT, XmRImmediate,
287 (XtPointer)bold30PtFont},
288 {"mvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
289 sizeof(String) * MV_HEADER_FONT, XmRImmediate,
290 (XtPointer)bold9PtFont},
291 {"mvpApptFont", "PrintApptFont", XmRString, sizeof(String),
292 sizeof(String) * MV_APPT_FONT, XmRImmediate,
293 (XtPointer)helv8PtFont},
294 {"mvpDayFont", "PrintDayFont", XmRString, sizeof(String),
295 sizeof(String) * MV_DAY_FONT, XmRImmediate,
296 (XtPointer)bold14PtFont},
297 {"mvpDateFont", "PrintDateFont", XmRString, sizeof(String),
298 sizeof(String) * MV_DATE_FONT, XmRImmediate,
299 (XtPointer)bold20PtFont},
300 {"mvpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
301 sizeof(String) * MV_TINY_TITLE_FONT, XmRImmediate,
302 (XtPointer)bold10PtFont},
303 {"mvpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
304 sizeof(String) * MV_TINY_DAY_FONT, XmRImmediate,
305 (XtPointer)cour7PtFont},
306 {"mvpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
307 sizeof(String) * MV_TINY_DATE_FONT, XmRImmediate,
308 (XtPointer)bold7PtFont}
311 static XtResource yvDefaultResources[] =
313 {"yvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
314 sizeof(String) * YV_TITLE_FONT, XmRImmediate,
315 (XtPointer)bold40PtFont},
316 {"yvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
317 sizeof(String) * YV_HEADER_FONT, XmRImmediate,
318 (XtPointer)bold9PtFont},
319 {"yvpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
320 sizeof(String) * YV_TINY_TITLE_FONT, XmRImmediate,
321 (XtPointer)bold16PtFont},
322 {"yvpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
323 sizeof(String) * YV_TINY_DAY_FONT, XmRImmediate,
324 (XtPointer)cour12PtFont},
325 {"yvpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
326 sizeof(String) * YV_TINY_DATE_FONT, XmRImmediate,
327 (XtPointer)bold12PtFont}
330 static XtResource avDefaultResources[] =
332 {"avpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
333 sizeof(String) * AV_TITLE_FONT, XmRImmediate,
334 (XtPointer)bold16PtFont},
335 {"avpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
336 sizeof(String) * AV_HEADER_FONT, XmRImmediate,
337 (XtPointer)bold9PtFont},
338 {"avpApptFont", "PrintApptFont", XmRString, sizeof(String),
339 sizeof(String) * AV_APPT_FONT, XmRImmediate,
340 (XtPointer)helv10PtFont},
341 {"avpItemFont", "PrintItemFont", XmRString, sizeof(String),
342 sizeof(String) * AV_ITEM_FONT, XmRImmediate,
343 (XtPointer)bold10PtFont},
344 {"avpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
345 sizeof(String) * AV_TINY_TITLE_FONT, XmRImmediate,
346 (XtPointer)bold16PtFont},
347 {"avpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
348 sizeof(String) * AV_TINY_DAY_FONT, XmRImmediate,
349 (XtPointer)cour12PtFont},
350 {"avpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
351 sizeof(String) * AV_TINY_DATE_FONT, XmRImmediate,
352 (XtPointer)bold12PtFont}
355 static XtResource tvDefaultResources[] =
357 {"tvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
358 sizeof(String) * TV_TITLE_FONT, XmRImmediate,
359 (XtPointer)bold16PtFont},
360 {"tvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
361 sizeof(String) * TV_HEADER_FONT, XmRImmediate,
362 (XtPointer)bold9PtFont},
363 {"tvpApptFont", "PrintApptFont", XmRString, sizeof(String),
364 sizeof(String) * TV_APPT_FONT, XmRImmediate,
365 (XtPointer)helv10PtFont},
366 {"tvpItemFont", "PrintItemFont", XmRString, sizeof(String),
367 sizeof(String) * TV_ITEM_FONT, XmRImmediate,
368 (XtPointer)bold10PtFont},
369 {"tvpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
370 sizeof(String) * TV_TINY_TITLE_FONT, XmRImmediate,
371 (XtPointer)bold16PtFont},
372 {"tvpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
373 sizeof(String) * TV_TINY_DAY_FONT, XmRImmediate,
374 (XtPointer)cour12PtFont},
375 {"tvpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
376 sizeof(String) * TV_TINY_DATE_FONT, XmRImmediate,
377 (XtPointer)bold12PtFont}
381 static XtResource displayResources[] =
383 {"lightGrayPixel", "LightGrayPixel", XmRPixel, sizeof(Pixel),
384 XtOffsetOf(PrintResources, lightGrayPixel), XmRString,
386 {"darkGrayPixel", "DarkGrayPixel", XmRPixel, sizeof(Pixel),
387 XtOffsetOf(PrintResources, darkGrayPixel), XmRString,
391 static PrintResources printResources;
394 typedef int CMFontEnum;
405 typedef struct _CMFontInfo
411 typedef struct _CMDayInfo
421 typedef struct _CMToDoInfo
423 int outerX1, outerY1;
424 int innerX1, innerY1;
425 int innerX2, innerY2;
426 int outerX2, outerY2;
432 typedef struct _CMWeekInfo
442 int schedBoxX1, schedBoxY1;
443 int schedBoxX2, schedBoxY2;
444 char schedBucket[INTERVALS_PER_DAY];
447 typedef struct _CMMonthInfo
455 int lineMaxX, lineMaxY;
458 typedef struct _CMGraphicsInfo
465 char timestamp[BUFFERSIZE];
466 Boolean reverseVideo;
468 Pixmap lightPixmap, darkPixmap;
473 /* Scaled line thicknesses */
483 CMFontInfo *fontInfo;
492 CMMonthInfo monthInfo;
497 static void local_dayname(Calendar *, char **, int);
498 static void local_dayname3(Calendar *, char **, int);
499 static char *get_report_type_string(CMGraphicsInfo *);
500 static void filePrintDoneCB(Display *, XPContext, XPGetDocStatus,
502 static void filePrintReportStatus(Calendar *, Boolean);
503 static void showBadAllocError(Calendar *);
505 /* X Graphics stuff. */
506 static void x_print_string(CMGraphicsInfo *, char *, int, int, int);
507 static void x_fill_light_box(CMGraphicsInfo *, int, int, int, int, int);
508 static void x_fill_dark_box(CMGraphicsInfo *, int, int, int, int, int);
509 static void x_fill_black_box(CMGraphicsInfo *, int, int, int, int);
510 static void x_fill_box(CMGraphicsInfo *, int, int, int, int, Pixmap, int);
511 static void x_draw_box(CMGraphicsInfo *, int, int, int, int, int);
512 static void x_draw_line(CMGraphicsInfo *, int, int, int, int, int);
513 static void x_set_clip_box(CMGraphicsInfo *, int, int, int, int);
514 static void x_unset_clip_box(CMGraphicsInfo *);
517 static Boolean x_load_font(CMGraphicsInfo *, CMFontInfo *, char *);
520 static Boolean cm_load_font(CMGraphicsInfo *, CMFontEnum, char *);
521 static void cm_load_font_error(CMGraphicsInfo *, char *);
522 static void cm_release_fonts(CMGraphicsInfo *);
523 static Boolean cm_set_font(CMGraphicsInfo *, CMFontEnum);
524 static CMFontInfo *cm_find_font(CMGraphicsInfo *, CMFontEnum);
525 static void cm_font_extents(CMGraphicsInfo *, CMFontInfo *, int *, int *);
526 static int cm_font_height(CMGraphicsInfo *, CMFontInfo *);
527 static int cm_font_width(CMGraphicsInfo *, CMFontInfo *);
528 static int cm_string_width(CMGraphicsInfo *, CMFontInfo *, char *);
529 static void cm_reverse_video(CMGraphicsInfo *, Boolean);
531 static CMFontEnum cm_get_title_enum(CMGraphicsInfo *);
532 static CMFontEnum cm_get_header_enum(CMGraphicsInfo *);
533 static CMFontEnum cm_get_tiny_title_enum(CMGraphicsInfo *);
534 static CMFontEnum cm_get_tiny_day_enum(CMGraphicsInfo *);
535 static CMFontEnum cm_get_tiny_date_enum(CMGraphicsInfo *);
536 static void cm_adjust_margins(CMGraphicsInfo *);
537 static int cm_cvt_margin(CMGraphicsInfo *, Props_op, int);
538 static void cm_print_header_string(CMGraphicsInfo *, Props_op,
542 /* Day/Week View stuff */
543 static void cm_print_time(CMGraphicsInfo *, char *, Glance);
544 static void cm_print_appt_text(CMGraphicsInfo *, char *, int, Glance);
545 static void cm_print_text(CMGraphicsInfo *, char *, int, Glance);
546 static void cm_week_sched_update(CMGraphicsInfo *,
547 Dtcm_appointment *, Props *);
548 static int cm_week_sched_box_indent(CMGraphicsInfo *);
550 /* ToDo/Appt. View stuff */
551 static void cm_set_todo_text_clipping(CMGraphicsInfo *);
552 static void cm_unset_todo_text_clipping(CMGraphicsInfo *);
553 static void cm_print_todo_text(CMGraphicsInfo *, char *, CSA_sint32,
555 static int cm_tiny_month_height(CMGraphicsInfo *, int);
556 static void cm_print_todo_months(CMGraphicsInfo *, time_t);
557 static int cm_count_appts(CMGraphicsInfo *, CSA_entry_handle *,
558 int, CSA_sint32, int);
559 static void cm_get_todo_lines_per_page(CMGraphicsInfo *, CSA_sint32,
561 static void cm_todo_outline(CMGraphicsInfo *, Boolean);
563 /* Month View stuff */
564 static void cm_print_month_time(CMGraphicsInfo *, char *);
565 static void cm_print_month_text(CMGraphicsInfo *, char *, int);
566 static void cm_std_month_dates(CMGraphicsInfo *, int, int, int,
568 static void cm_std_month_weekdays(CMGraphicsInfo *, int, int, int, int);
571 static void tmpFn(Widget, XtPointer, XtPointer);
572 static void tmpSpin(Widget);
573 static Boolean tmpFlag;
579 XtAppContext appContext;
582 appContext = XtWidgetToApplicationContext(w);
585 XtAppNextEvent(appContext, &event);
586 XtDispatchEvent(&event);
591 tmpFn(Widget w, XtPointer uData, XtPointer cbData)
593 XmDrawingAreaCallbackStruct *cbStruct =
594 (XmDrawingAreaCallbackStruct *)cbData;
596 if (cbStruct->reason == XmCR_EXPOSE)
598 if (cbStruct->event->xexpose.count != 0)
603 if (cbStruct->event->type != ButtonPress)
612 x_print_string(CMGraphicsInfo *gInfo, char *str, int x, int y, int flags)
614 Widget w = gInfo->drawingArea;
616 XmFontList fontList = (XmFontList)NULL;
618 Dimension textWd, textHt;
621 XmStringDirection xmStringDirection;
626 XtSetArg(args[nargs], XmNstringDirection, &xmStringDirection); nargs++;
627 XtGetValues(w, args, nargs);
629 if ((gInfo->nFonts == 0) ||
630 (gInfo->curFont == (CMFontInfo *)NULL))
633 XtSetArg(args[nargs], XmNlabelFontList, &fontList); nargs++;
634 XtGetValues(XtParent(w), args, nargs);
638 fontList = gInfo->curFont->fontList;
641 xmString = XmStringCreateLocalized(str);
642 XmStringExtent(fontList, xmString, &textWd, &textHt);
644 xFlags = (flags & (LEFT_AT_X | CENTER_AT_X | RIGHT_AT_X));
645 yFlags = (flags & (TOP_AT_Y | CENTER_AT_Y | BOTTOM_AT_Y));
655 textX = x - (textWd/2);
659 textX = x - textWd + 1;
662 if (xmStringDirection == XmSTRING_DIRECTION_R_TO_L)
673 textY = y - (textHt/2);
681 XSetForeground(XtDisplay(w), gc, gInfo->fg);
682 XmStringDraw(XtDisplay(w), XtWindow(w), fontList, xmString,
683 gc, textX, textY, textWd, XmALIGNMENT_BEGINNING,
684 xmStringDirection, NULL);
685 XmStringFree(xmString);
689 x_fill_light_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2,
693 Widget w = gInfo->drawingArea;
698 XSetForeground(XtDisplay(w), gc, printResources.lightGrayPixel);
702 fillWd = x2 - x1 + 1;
703 fillHt = y2 - y1 + 1;
704 XFillRectangle(XtDisplay(w), XtWindow(w), gc, fillX, fillY, fillWd, fillHt);
707 x_draw_box(gInfo, x1, y1, x2, y2, lineWidth);
709 static char lightStippleData[] = {0x10, 0x00, 0x01, 0x00};
711 if (gInfo->lightPixmap == None)
713 Widget w = gInfo->drawingArea;
716 unsigned long fg, bg;
718 int lightStippleWd = 8;
719 int lightStippleHt = 4;
721 if (gInfo->reverseVideo)
733 XtSetArg(args[nargs], XmNdepth, &depth); nargs++;
734 XtGetValues(w, args, nargs);
737 XCreatePixmapFromBitmapData(XtDisplay(w), XtWindow(w),
739 lightStippleWd, lightStippleHt,
743 x_fill_box(gInfo, x1, y1, x2, y2, gInfo->lightPixmap, lineWidth);
748 x_fill_dark_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2,
752 Widget w = gInfo->drawingArea;
757 XSetForeground(XtDisplay(w), gc, printResources.darkGrayPixel);
761 fillWd = x2 - x1 + 1;
762 fillHt = y2 - y1 + 1;
763 XFillRectangle(XtDisplay(w), XtWindow(w), gc, fillX, fillY, fillWd, fillHt);
766 x_draw_box(gInfo, x1, y1, x2, y2, lineWidth);
768 static char darkStippleData[] = {0x11, 0xaa, 0x44, 0xaa};
770 if (gInfo->darkPixmap == None)
772 Widget w = gInfo->drawingArea;
775 unsigned long fg, bg;
777 int darkStippleWd = 8;
778 int darkStippleHt = 4;
780 if (gInfo->reverseVideo)
792 XtSetArg(args[nargs], XmNdepth, &depth); nargs++;
793 XtGetValues(w, args, nargs);
796 XCreatePixmapFromBitmapData(XtDisplay(w), XtWindow(w),
798 darkStippleWd, darkStippleHt,
802 x_fill_box(gInfo, x1, y1, x2, y2, gInfo->darkPixmap, lineWidth);
807 x_fill_black_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2)
809 x_fill_box(gInfo, x1, y1, x2, y2, None, 0);
813 x_fill_box(CMGraphicsInfo *gInfo, int x1, int y1,
814 int x2, int y2, Pixmap stipple, int lineWidth)
816 Widget w = gInfo->drawingArea;
821 XSetForeground(XtDisplay(w), gc, gInfo->fg);
822 XSetBackground(XtDisplay(w), gc, gInfo->bg);
826 XSetTile(XtDisplay(w), gc, stipple);
827 XSetFillStyle(XtDisplay(w), gc, FillTiled);
832 fillWd = x2 - x1 + 1;
833 fillHt = y2 - y1 + 1;
834 XFillRectangle(XtDisplay(w), XtWindow(w), gc, fillX, fillY, fillWd, fillHt);
837 XSetFillStyle(XtDisplay(w), gc, FillSolid);
840 x_draw_box(gInfo, x1, y1, x2, y2, lineWidth);
844 x_draw_box(CMGraphicsInfo *gInfo, int x1, int y1,
845 int x2, int y2, int lineWidth)
847 Widget w = gInfo->drawingArea;
849 XGCValues newGCValues;
854 newGCValues.line_width = lineWidth;
855 newGCValues.foreground = gInfo->fg;
856 XChangeGC(XtDisplay(w), gc, GCForeground | GCLineWidth, &newGCValues);
859 /* X centers thick lines; we want them wholly within specified rectangle. */
862 int ulOffset = lineWidth / 2;
863 int lrOffset = (lineWidth - 1) / 2;
872 XDrawRectangle(XtDisplay(w), XtWindow(w),
873 gc, x1, y1, x2 - x1, y2 - y1);
877 x_draw_line(CMGraphicsInfo *gInfo, int x1, int y1,
878 int x2, int y2, int lineWidth)
880 Widget w = gInfo->drawingArea;
882 XGCValues newGCValues;
887 newGCValues.line_width = lineWidth;
888 newGCValues.foreground = gInfo->fg;
889 XChangeGC(XtDisplay(w), gc, GCForeground | GCLineWidth, &newGCValues);
891 XDrawLine(XtDisplay(w), XtWindow(w),
896 x_set_clip_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2)
899 Widget w = gInfo->drawingArea;
903 rect.width = x2 - x1;
904 rect.height = y2 - y1;
906 XSetClipRectangles(XtDisplay(w), gInfo->gc, 0, 0, &rect, 1, YXBanded);
910 x_unset_clip_box(CMGraphicsInfo *gInfo)
912 Widget w = gInfo->drawingArea;
914 XSetClipMask(XtDisplay(w), gInfo->gc, None);
918 x_load_font(CMGraphicsInfo *gInfo, CMFontInfo *fInfo, char *fontPattern)
920 Widget w = gInfo->drawingArea;
923 XmFontList fontList = (XmFontList)NULL;
925 if (fInfo->fontList != (XmFontList)NULL)
928 fromValue.addr = (XPointer)fontPattern;
929 fromValue.size = strlen(fontPattern);
931 toValue.addr = (XPointer)&fontList;
932 toValue.size = sizeof(XmFontList);
936 char *tmpPtr = XtNewString(fontPattern);
939 for (i = 0; tmpPtr[i] != '\0'; i++)
942 (tmpPtr[i] == '0') &&
943 (tmpPtr[i - 1] == '-') &&
944 (tmpPtr[i + 1] == '-'))
947 fromValue.addr = (XPointer)tmpPtr;
949 #endif /* GR_DEBUG */
952 * :( XtConvertAndStore() doesn't return False even when the specified
953 * font cannot be found; Motif plugs in a default font and issues a
956 XtConvertAndStore(w, XmRString, &fromValue, XmRFontList, &toValue);
959 XtFree((char *)fromValue.addr);
962 fInfo->fontList = fontList;
967 cm_load_font(CMGraphicsInfo *gInfo, CMFontEnum fontEnum,
971 CMFontInfo *fInfo = cm_find_font(gInfo, fontEnum);
973 if (fInfo != (CMFontInfo *)NULL)
974 /* It's a no-no to try to load a font more than once! */
977 fInfo = (CMFontInfo *)XtRealloc((char *)gInfo->fontInfo,
978 sizeof(CMFontInfo) * (gInfo->nFonts + 1));
979 if (fInfo == (CMFontInfo *)NULL)
981 gInfo->fontInfo = fInfo;
983 fInfo = &(gInfo->fontInfo[gInfo->nFonts]);
984 fInfo->fontEnum = fontEnum;
985 fInfo->fontList = (XmFontList)NULL;
987 if (!x_load_font(gInfo, fInfo, fontPattern))
989 cm_load_font_error(gInfo, fontPattern);
998 cm_load_font_error(CMGraphicsInfo *gInfo, char *fontPattern)
1000 Calendar *c = gInfo->c;
1001 Props_pu *pu = (Props_pu *)c->properties_pu;
1007 errFmt = catgets(c->DT_catd, 1, 1119,
1008 "Warning - Unable to load font %s.");
1009 errText = (char *)XtMalloc((strlen(errFmt) + strlen(fontPattern) + 1) *
1011 sprintf(errText, errFmt, fontPattern);
1012 label = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
1013 title = XtNewString(catgets(c->DT_catd, 1, 1118,
1014 "Calendar : Warning - Print"));
1016 dialog_popup(c->frame,
1017 DIALOG_TITLE, title,
1018 DIALOG_TEXT, errText,
1019 BUTTON_IDENT, 1, label,
1020 DIALOG_IMAGE, pu->xm_warning_pixmap,
1029 cm_release_fonts(CMGraphicsInfo *gInfo)
1031 XtFree((char *)gInfo->fontInfo);
1032 gInfo->fontInfo = (CMFontInfo *)NULL;
1037 cm_set_font(CMGraphicsInfo *gInfo, CMFontEnum fontEnum)
1041 if ((gInfo->curFont == (CMFontInfo *)NULL) ||
1042 (gInfo->curFont->fontEnum != fontEnum))
1044 if ((fInfo = cm_find_font(gInfo, fontEnum)) == (CMFontInfo *)NULL)
1047 gInfo->curFont = fInfo;
1054 cm_find_font(CMGraphicsInfo *gInfo, CMFontEnum fontEnum)
1058 for (i = 0; i < gInfo->nFonts; i++)
1060 if (gInfo->fontInfo[i].fontEnum == fontEnum)
1061 return &(gInfo->fontInfo[i]);
1064 return (CMFontInfo *)NULL;
1068 cm_font_extents(CMGraphicsInfo *gInfo, CMFontInfo *fInfo, int *wd, int *ht)
1073 if ((gInfo != (CMGraphicsInfo *)NULL) &&
1074 (fInfo != (CMFontInfo *)NULL))
1076 XmFontContext fontContext;
1078 if (XmFontListInitFontContext(&fontContext, fInfo->fontList))
1080 XmFontListEntry fontListEntry;
1082 XFontStruct *fontStruct;
1083 XtPointer fontEntryFont;
1084 XmFontType fontType;
1085 XFontSetExtents *fontSetExtents;
1088 while ((fontListEntry = XmFontListNextEntry(fontContext))
1089 != (XmFontListEntry)NULL)
1091 fontEntryFont = XmFontListEntryGetFont(fontListEntry, &fontType);
1092 if (fontType == XmFONT_IS_FONT)
1094 fontStruct = (XFontStruct *)fontEntryFont;
1095 thisWd = fontStruct->max_bounds.rbearing -
1096 fontStruct->min_bounds.lbearing;
1097 thisHt = fontStruct->ascent + fontStruct->descent;
1099 else if (fontType == XmFONT_IS_FONTSET)
1101 fontSet = (XFontSet)fontEntryFont;
1102 fontSetExtents = XExtentsOfFontSet(fontSet);
1103 thisWd = fontSetExtents->max_logical_extent.width;
1104 thisHt = fontSetExtents->max_logical_extent.height;
1114 XmFontListFreeFontContext(fontContext);
1118 *wd = (maxWd > 0) ? maxWd : 8;
1119 *ht = (maxHt > 0) ? maxHt : 13;
1123 cm_font_height(CMGraphicsInfo *gInfo, CMFontInfo *fInfo)
1127 cm_font_extents(gInfo, fInfo, &wd, &ht);
1132 cm_font_width(CMGraphicsInfo *gInfo, CMFontInfo *fInfo)
1136 cm_font_extents(gInfo, fInfo, &wd, &ht);
1141 cm_string_width(CMGraphicsInfo *gInfo, CMFontInfo *fInfo, char *str)
1143 if ((gInfo != (CMGraphicsInfo *)NULL) &&
1144 (fInfo != (CMFontInfo *)NULL) &&
1145 (str != (char *)NULL))
1150 XmFontList fontList = fInfo->fontList;
1152 xmStr = XmStringCreateLocalized(str);
1153 XmStringExtent(fontList, xmStr, &textWd, &textHt);
1154 XmStringFree(xmStr);
1163 cm_reverse_video(CMGraphicsInfo *gInfo, Boolean enabled)
1165 if (gInfo->reverseVideo != enabled)
1170 gInfo->fg = gInfo->bg;
1173 gInfo->reverseVideo = enabled;
1178 cm_get_title_enum(CMGraphicsInfo *gInfo)
1180 switch (gInfo->reportType)
1183 return DV_TITLE_FONT;
1186 return WV_TITLE_FONT;
1190 return MV_TITLE_FONT;
1193 return YV_TITLE_FONT;
1196 return AV_TITLE_FONT;
1199 return TV_TITLE_FONT;
1204 cm_get_header_enum(CMGraphicsInfo *gInfo)
1206 switch (gInfo->reportType)
1209 return DV_HEADER_FONT;
1212 return WV_HEADER_FONT;
1216 return MV_HEADER_FONT;
1219 return YV_HEADER_FONT;
1222 return AV_HEADER_FONT;
1225 return TV_HEADER_FONT;
1230 cm_get_tiny_title_enum(CMGraphicsInfo *gInfo)
1232 switch (gInfo->reportType)
1236 return MV_TINY_TITLE_FONT;
1239 return YV_TINY_TITLE_FONT;
1242 return AV_TINY_TITLE_FONT;
1245 return TV_TINY_TITLE_FONT;
1250 cm_get_tiny_day_enum(CMGraphicsInfo *gInfo)
1252 switch (gInfo->reportType)
1256 return MV_TINY_DAY_FONT;
1259 return YV_TINY_DAY_FONT;
1262 return AV_TINY_DAY_FONT;
1265 return TV_TINY_DAY_FONT;
1270 cm_get_tiny_date_enum(CMGraphicsInfo *gInfo)
1272 switch (gInfo->reportType)
1276 return MV_TINY_DATE_FONT;
1279 return YV_TINY_DATE_FONT;
1282 return AV_TINY_DATE_FONT;
1285 return TV_TINY_DATE_FONT;
1290 cm_adjust_margins(CMGraphicsInfo *gInfo)
1293 CMFontEnum titleFont, headerFont;
1295 titleFont = cm_get_title_enum(gInfo);
1296 headerFont = cm_get_header_enum(gInfo);
1299 * Assume MonthFont and StampFont have been
1300 * set as required for header and footer.
1302 if ((fInfo = cm_find_font(gInfo, titleFont)) != (CMFontInfo *)NULL)
1303 gInfo->topMarginY += cm_font_height(gInfo, fInfo);
1305 if ((fInfo = cm_find_font(gInfo, headerFont)) != (CMFontInfo *)NULL)
1306 gInfo->bottomMarginY -= VMARGIN(gInfo) + cm_font_height(gInfo, fInfo);
1310 cm_cvt_margin(CMGraphicsInfo *gInfo, Props_op prop, int defaultVal)
1312 Widget w = gInfo->drawingArea;
1313 Props *p = (Props *) gInfo->c->properties;
1317 /* PostScript dimensions are the same vertically as horizontally. */
1318 returnVal = XmConvertStringToUnits(XtScreen(w),
1319 get_char_prop(p, prop),
1324 return badCvt ? defaultVal : returnVal;
1328 cm_print_time(CMGraphicsInfo *gInfo, char *str, Glance view)
1330 cm_print_text(gInfo, str, (view == dayGlance) ? 0 : 2, view);
1334 cm_print_appt_text(CMGraphicsInfo *gInfo, char *str,
1335 int indentAmt, Glance view)
1338 unsigned long to_len = 0;
1342 _converter_( str, _len, &to, &to_len );
1343 if ( ( to != NULL ) && ( to_len != 0 ) )
1346 cm_print_text(gInfo, str, indentAmt, view);
1350 cm_print_text(CMGraphicsInfo *gInfo, char *str,
1351 int indentAmt, Glance view)
1359 cm_set_font(gInfo, DV_APPT_FONT);
1361 /* Make sure the text fits in the box. */
1362 if (gInfo->u.dayInfo.line1 + cm_font_height(gInfo, gInfo->curFont) +
1363 VMARGIN(gInfo) <= gInfo->u.dayInfo.curY1 - (gInfo->normalWd / 2))
1365 textX = gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1 + HMARGIN(gInfo) +
1366 (indentAmt * cm_font_width(gInfo, gInfo->curFont));
1367 textY = gInfo->u.dayInfo.line1;
1369 clipX2 = gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.boxWd -
1370 ((gInfo->normalWd / 2) + 1) - HMARGIN(gInfo);
1372 gInfo->u.dayInfo.line1 += cm_font_height(gInfo, gInfo->curFont);
1378 cm_set_font(gInfo, WV_APPT_FONT);
1380 /* Make sure the text fits in the box. */
1381 if (gInfo->u.weekInfo.lineY + cm_font_height(gInfo, gInfo->curFont) +
1382 VMARGIN(gInfo) <= gInfo->u.weekInfo.lineMaxY - (gInfo->thickWd / 2))
1384 textX = gInfo->u.weekInfo.lineX +
1385 (gInfo->normalWd / 2) + HMARGIN(gInfo) +
1386 (indentAmt * cm_font_width(gInfo, gInfo->curFont));
1387 textY = gInfo->u.weekInfo.lineY;
1389 clipX2 = gInfo->u.weekInfo.lineX +
1390 (gInfo->u.weekInfo.boxWd / WEEK_DAYS) -
1391 ((gInfo->normalWd / 2) + 1) - HMARGIN(gInfo);
1393 gInfo->u.weekInfo.lineY += cm_font_height(gInfo, gInfo->curFont);
1402 if (clipX2 > clipX1)
1404 x_set_clip_box(gInfo, clipX1, gInfo->topMarginY,
1405 clipX2, gInfo->bottomMarginY - 1);
1406 x_print_string(gInfo, str, textX, textY, LEFT_AT_X | TOP_AT_Y);
1407 x_unset_clip_box(gInfo);
1412 cm_week_sched_update(CMGraphicsInfo *gInfo, Dtcm_appointment *appt, Props *p)
1415 * In order to draw appts in the sched box, all appts for a day are
1416 * mapped into a array, and then drawn later. The array has
1417 * 96 elements, and represents the 96 15-minute segements
1418 * available between the day boundaries
1420 int begin_t = get_int_prop(p, CP_DAYBEGIN);
1421 int end_t = get_int_prop(p, CP_DAYEND);
1427 _csa_iso8601_to_tick(appt->time->value->item.date_time_value, &tick);
1429 _csa_iso8601_to_tick(appt->end_time->value->item.date_time_value,
1433 * Determine the last element in the sched_buckets array which
1434 * corresponds to this time range.
1437 end_slider = (end_t - begin_t) * 4;
1440 * Figure where the begin and end times should be in the array.
1442 start = ((hour(tick) - begin_t) * 4) + (minute(tick) / 15);
1444 end = start + ((end_tick - tick) * 4 / 3600);
1449 * Make sure that the appointment starts/ends within the visible
1452 if (start < 0) start = 0;
1453 if (end < 0) end = 0;
1454 if (start > end_slider) start = end_slider;
1455 if (end > end_slider) end = end_slider;
1458 * Only map if some portion of time is between day boundaries.
1460 if ((start < 0 && end < 0) ||
1461 (start >= end_slider && end >= end_slider))
1465 * Mark the blocks of time affected in the array.
1467 for (i = start; i < end; i++)
1468 gInfo->u.weekInfo.schedBucket[i]++;
1472 cm_week_sched_box_indent(CMGraphicsInfo *gInfo)
1474 CMFontInfo *fInfo = cm_find_font(gInfo, WV_DAY_FONT);
1475 static char *baselineStr = "24";
1477 return cm_string_width(gInfo, fInfo, baselineStr) + HMARGIN(gInfo) +
1482 cm_set_todo_text_clipping(CMGraphicsInfo *gInfo)
1484 x_set_clip_box(gInfo,
1485 gInfo->u.toDoInfo.innerX1,
1486 gInfo->u.toDoInfo.innerY1,
1487 gInfo->u.toDoInfo.boxX2 -
1488 ((gInfo->thickWd / 2) + 1) - HMARGIN(gInfo),
1489 gInfo->u.toDoInfo.boxY2 -
1490 ((gInfo->thickWd / 2) + 1));
1494 cm_unset_todo_text_clipping(CMGraphicsInfo *gInfo)
1496 x_unset_clip_box(gInfo);
1500 cm_print_todo_text(CMGraphicsInfo *gInfo, char *str1, CSA_sint32 as,
1501 CSA_sint32 appt_type, int items)
1507 int i, digitWd, maxDigitWd;
1509 Boolean isTodo = (appt_type == CSA_TYPE_TODO);
1511 cm_set_font(gInfo, isTodo ? TV_ITEM_FONT : AV_ITEM_FONT);
1513 for (i = 0; i <= 9; i++)
1515 sprintf(buf, "%d", i);
1516 if ((digitWd = cm_string_width(gInfo, gInfo->curFont, buf)) > maxDigitWd)
1517 maxDigitWd = digitWd;
1520 sprintf(buf, "%d.", items);
1522 indent = strlen(buf);
1525 textX = gInfo->u.toDoInfo.lineX + (indent * maxDigitWd);
1526 textY = gInfo->u.toDoInfo.lineY;
1527 x_print_string(gInfo, buf, textX, textY,
1528 RIGHT_AT_X | TOP_AT_Y);
1529 textX += maxDigitWd + HMARGIN(gInfo);
1531 cm_set_font(gInfo, isTodo ? TV_APPT_FONT : AV_APPT_FONT);
1532 fontHt = cm_font_height(gInfo, gInfo->curFont);
1536 /* draw check box */
1538 textX + (gInfo->normalWd / 2) + 1,
1539 textY + (gInfo->normalWd / 2) + 1,
1540 textX + fontHt - ((gInfo->normalWd + 1) / 2),
1541 textY + fontHt - ((gInfo->normalWd + 1) / 2),
1544 /* add check to box */
1545 if (as == CSA_STATUS_COMPLETED)
1548 textX + (fontHt / 4),
1549 textY + (fontHt / 2),
1550 textX + (fontHt / 2),
1551 textY + fontHt - ((gInfo->normalWd + 3) / 2),
1554 textX + (fontHt / 2),
1555 textY + fontHt - ((gInfo->normalWd + 3) / 2),
1556 textX + ((5 * fontHt) / 4),
1557 textY + (gInfo->normalWd / 2) + 1,
1560 textX += ((5 * fontHt) / 4) + maxDigitWd + HMARGIN(gInfo);
1565 unsigned long to_len = 0;
1568 _len = strlen(str1);
1569 _converter_( str1, _len, &to, &to_len );
1570 if ( ( to != NULL ) && ( to_len != 0 ) )
1574 str = euc_to_octal(str1);
1576 x_print_string(gInfo, str, textX, textY, LEFT_AT_X | TOP_AT_Y);
1577 gInfo->u.toDoInfo.lineY += fontHt;
1581 cm_tiny_month_height(CMGraphicsInfo *gInfo, int spacing)
1587 * Month boxes need to be tall enough for:
1588 * 1 MonthFont, 1 DayFont, 6 DateFonts
1590 fInfo = cm_find_font(gInfo, cm_get_tiny_title_enum(gInfo));
1591 monthBoxHt = cm_font_height(gInfo, fInfo) + (2 * spacing);
1593 fInfo = cm_find_font(gInfo, cm_get_tiny_day_enum(gInfo));
1594 monthBoxHt += spacing + cm_font_height(gInfo, fInfo);
1596 fInfo = cm_find_font(gInfo, cm_get_tiny_date_enum(gInfo));
1597 monthBoxHt += 6 * (spacing + cm_font_height(gInfo, fInfo));
1603 cm_print_todo_months(CMGraphicsInfo *gInfo, time_t end_time)
1605 int x1, y1, x2, y2, lastX, mon, yr;
1607 int tlOff = (gInfo->thickWd + 1) / 2;
1608 int brOff = (gInfo->thickWd / 2) + 1;
1610 mon = month(end_time);
1611 yr = year(end_time);
1613 x1 = gInfo->u.toDoInfo.boxX1;
1614 lastX = gInfo->u.toDoInfo.boxX2;
1615 monthBoxWd = lastX - x1;
1616 y1 = gInfo->u.toDoInfo.boxY1;
1617 x2 = x1 + (monthBoxWd / 3);
1618 y2 = gInfo->u.toDoInfo.boxY2;
1620 x_draw_line(gInfo, x2, y1, x2, y2, gInfo->thickWd);
1622 x_print_month((void *)gInfo, 12, yr - 1,
1623 x1 + tlOff, y1 + tlOff,
1624 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1626 x_print_month((void *)gInfo, mon - 1, yr,
1627 x1 + tlOff, y1 + tlOff,
1628 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1631 x2 = gInfo->u.toDoInfo.boxX1 + ((2 * monthBoxWd) / 3);
1632 x_draw_line(gInfo, x2, y1, x2, y2, gInfo->thickWd);
1633 x_print_month((void *)gInfo, mon, yr,
1634 x1 + tlOff, y1 + tlOff,
1635 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1640 x_print_month((void *)gInfo, 1, yr + 1,
1641 x1 + tlOff, y1 + tlOff,
1642 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1644 x_print_month((void *)gInfo, mon + 1, yr,
1645 x1 + tlOff, y1 + tlOff,
1646 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1650 cm_count_appts(CMGraphicsInfo *gInfo, CSA_entry_handle *list, int a_total,
1651 CSA_sint32 appt_type, int vf)
1654 boolean_t skip_appt;
1655 CSA_return_code stat;
1656 Dtcm_appointment *appt;
1657 Calendar *c = gInfo->c;
1658 Props *p = (Props*)c->properties;
1662 meoval = get_int_prop(p, CP_PRINTPRIVACY);
1664 appt = allocate_appt_struct(appt_read,
1665 c->general->version,
1666 CSA_ENTRY_ATTR_CLASSIFICATION_I,
1667 CSA_ENTRY_ATTR_TYPE_I,
1668 CSA_ENTRY_ATTR_STATUS_I,
1669 CSA_ENTRY_ATTR_START_DATE_I,
1670 CSA_ENTRY_ATTR_SUMMARY_I,
1671 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
1672 CSA_ENTRY_ATTR_END_DATE_I,
1674 for (i = 0; i < a_total; i++)
1676 stat = query_appt_struct(c->cal_handle, list[i], appt);
1677 if (stat != CSA_SUCCESS)
1679 free_appt_struct(&appt);
1682 skip_appt = B_FALSE;
1684 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
1685 !(meoval & PRINT_PUBLIC))
1687 else if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
1688 !(meoval & PRINT_SEMIPRIVATE))
1690 else if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
1691 !(meoval & PRINT_PRIVATE))
1694 if ((appt_type == CSA_TYPE_TODO) &&
1695 ((appt->type->value->item.sint32_value != CSA_TYPE_TODO)
1697 ((vf == VIEW_PENDING) &&
1698 (appt->state->value->item.sint32_value ==
1699 CSA_STATUS_COMPLETED)) ||
1700 ((vf == VIEW_COMPLETED) &&
1701 (appt->state->value->item.sint32_value ==
1702 CSA_X_DT_STATUS_ACTIVE))))
1705 if ((appt_type == CSA_TYPE_EVENT) &&
1706 (appt->type->value->item.sint32_value != CSA_TYPE_EVENT))
1717 cm_get_todo_lines_per_page(CMGraphicsInfo *gInfo, CSA_sint32 apptType,
1718 int *linesFullPageP,
1719 int *linesPartialPageP)
1722 cm_find_font(gInfo, (apptType == CSA_TYPE_TODO) ?
1723 TV_APPT_FONT : AV_APPT_FONT);
1724 int fontHt = cm_font_height(gInfo, fInfo);
1726 *linesFullPageP = (gInfo->u.toDoInfo.boxY2 - gInfo->u.toDoInfo.innerY1 -
1727 gInfo->thickWd - (2 * VMARGIN(gInfo))) / fontHt;
1728 *linesPartialPageP = (gInfo->u.toDoInfo.innerY2 - gInfo->u.toDoInfo.innerY1 -
1729 gInfo->thickWd - (2 * VMARGIN(gInfo))) / fontHt;
1733 cm_todo_outline(CMGraphicsInfo *gInfo, Boolean lastPage)
1735 x_fill_dark_box(gInfo, gInfo->u.toDoInfo.outerX1,
1736 gInfo->u.toDoInfo.outerY1,
1737 gInfo->u.toDoInfo.outerX2,
1738 gInfo->u.toDoInfo.outerY2,
1744 x_fill_light_box(gInfo,
1745 gInfo->u.toDoInfo.innerX1,
1746 gInfo->u.toDoInfo.innerY1,
1747 gInfo->u.toDoInfo.innerX2,
1748 gInfo->u.toDoInfo.innerY2,
1752 x_fill_light_box(gInfo,
1753 gInfo->u.toDoInfo.boxX1,
1754 gInfo->u.toDoInfo.boxY1,
1755 gInfo->u.toDoInfo.boxX2,
1756 gInfo->u.toDoInfo.boxY2,
1762 x_fill_light_box(gInfo,
1763 gInfo->u.toDoInfo.innerX1,
1764 gInfo->u.toDoInfo.innerY1,
1765 gInfo->u.toDoInfo.boxX2,
1766 gInfo->u.toDoInfo.boxY2,
1772 cm_print_month_time(CMGraphicsInfo *gInfo, char *str)
1776 static char *baselineTime = "24:00";
1778 cm_set_font(gInfo, MV_APPT_FONT);
1780 /* Make sure the text fits in the box. */
1781 if (gInfo->u.monthInfo.lineY + cm_font_height(gInfo, gInfo->curFont) +
1782 VMARGIN(gInfo) <= gInfo->u.monthInfo.lineMaxY - (gInfo->normalWd / 2))
1784 /* Time is right-justified. */
1785 textX = gInfo->u.monthInfo.lineX + (gInfo->normalWd / 2) +
1786 HMARGIN(gInfo) + cm_string_width(gInfo, gInfo->curFont, baselineTime);
1787 gInfo->u.monthInfo.lastX = textX;
1788 textY = gInfo->u.monthInfo.lineY;
1789 clipX1 = gInfo->u.monthInfo.lineX + (gInfo->normalWd / 2) + HMARGIN(gInfo);
1790 clipX2 = gInfo->u.monthInfo.lineMaxX -
1791 (gInfo->normalWd / 2) - HMARGIN(gInfo);
1793 if (clipX2 > clipX1)
1795 x_set_clip_box(gInfo, clipX1, gInfo->u.monthInfo.lineY,
1796 clipX2, gInfo->u.monthInfo.lineMaxY);
1797 x_print_string(gInfo, str, textX, textY, RIGHT_AT_X | TOP_AT_Y);
1798 x_unset_clip_box(gInfo);
1804 cm_print_month_text(CMGraphicsInfo *gInfo, char *str, int indentAmt)
1809 cm_set_font(gInfo, MV_APPT_FONT);
1811 /* Make sure the text fits in the box. */
1812 if (gInfo->u.monthInfo.lineY + cm_font_height(gInfo, gInfo->curFont) +
1813 VMARGIN(gInfo) <= gInfo->u.monthInfo.lineMaxY - (gInfo->normalWd / 2))
1815 textX = gInfo->u.monthInfo.lastX + (gInfo->normalWd / 2) + HMARGIN(gInfo);
1816 textY = gInfo->u.monthInfo.lineY;
1818 clipX2 = gInfo->u.monthInfo.lineMaxX -
1819 (gInfo->normalWd / 2) - HMARGIN(gInfo);
1821 if (clipX2 > clipX1)
1823 x_set_clip_box(gInfo, clipX1, gInfo->u.monthInfo.lineY,
1824 clipX2, gInfo->u.monthInfo.lineMaxY);
1825 x_print_string(gInfo, str, textX, textY, LEFT_AT_X | TOP_AT_Y);
1826 x_unset_clip_box(gInfo);
1829 gInfo->u.monthInfo.lineY += cm_font_height(gInfo, gInfo->curFont);
1834 cm_std_month_weekdays(CMGraphicsInfo *gInfo, int colWd,
1835 int x1, int y1, int x2)
1837 char *day_of_week[DAYS_IN_WEEK];
1843 for (i = 0; i < DAYS_IN_WEEK; i++)
1844 local_dayname(gInfo->c, &day_of_week[i], i);
1846 x1 += HMARGIN(gInfo);
1847 x2 -= HMARGIN(gInfo);
1849 extraWd = boxWd - (DAYS_IN_WEEK * colWd);
1853 colWd = boxWd / DAYS_IN_WEEK;
1856 /* --- print std month weekdays --- */
1857 cm_set_font(gInfo, cm_get_tiny_day_enum(gInfo));
1858 for (i = 0; i < DAYS_IN_WEEK; i++)
1861 x_print_string(gInfo, day_of_week[i],
1862 x1 + (indent * colWd) + ((indent * extraWd) /
1863 (DAYS_IN_WEEK + 1)),
1864 y1, RIGHT_AT_X | TOP_AT_Y);
1867 for (i = 0; i < DAYS_IN_WEEK; i++)
1868 free(day_of_week[i]);
1872 cm_std_month_dates(CMGraphicsInfo *gInfo, int first_dom, int monlen,
1873 int colWd, int x1, int y1, int x2, int spacing)
1883 cm_set_font(gInfo, cm_get_tiny_date_enum(gInfo));
1884 fontHt = cm_font_height(gInfo, gInfo->curFont);
1886 x1 += HMARGIN(gInfo);
1887 x2 -= HMARGIN(gInfo);
1889 extraWd = boxWd - (DAYS_IN_WEEK * colWd);
1893 colWd = boxWd / DAYS_IN_WEEK;
1896 for (i = 0; i < monlen; i++, first_dom++)
1898 indent = (first_dom % DAYS_IN_WEEK) + 1;
1899 dateX = x1 + (indent * colWd) + ((indent * extraWd) /
1900 (DAYS_IN_WEEK + 1));
1901 dateY = y1 + ((first_dom / DAYS_IN_WEEK) * (spacing + fontHt));
1902 sprintf(dateStr, "%d", i + 1);
1903 x_print_string(gInfo, dateStr,
1904 dateX, dateY, RIGHT_AT_X | TOP_AT_Y);
1909 cm_print_header_string(CMGraphicsInfo *gInfo, Props_op printOp,
1910 char *timeStamp, char *userId,
1911 char *pageStr, char *reportTypeStr)
1913 Props *p = (Props *)gInfo->c->properties;
1914 int xPos, yPos, posFlags;
1918 hdrType = get_int_prop(p, printOp);
1926 case POP_HDR_USER_ID:
1930 case POP_HDR_PAGE_NUMBER:
1934 case POP_HDR_REPORT_TYPE:
1935 str = reportTypeStr;
1939 /* Nothing to print. */
1945 case CP_PRINTLHEADER:
1946 xPos = gInfo->leftMarginX;
1947 yPos = gInfo->topMarginY;
1948 posFlags = LEFT_AT_X | TOP_AT_Y;
1951 case CP_PRINTRHEADER:
1952 xPos = gInfo->rightMarginX - 1;
1953 yPos = gInfo->topMarginY;
1954 posFlags = RIGHT_AT_X | TOP_AT_Y;
1957 case CP_PRINTLFOOTER:
1958 xPos = gInfo->leftMarginX;
1959 if (gInfo->reportType == PR_WEEK_VIEW)
1960 xPos += cm_week_sched_box_indent(gInfo);
1961 yPos = gInfo->bottomMarginY + VMARGIN(gInfo);
1962 posFlags = LEFT_AT_X | TOP_AT_Y;
1965 case CP_PRINTRFOOTER:
1966 xPos = gInfo->rightMarginX - 1;
1967 yPos = gInfo->bottomMarginY + VMARGIN(gInfo);
1968 posFlags = RIGHT_AT_X | TOP_AT_Y;
1975 cm_set_font(gInfo, cm_get_header_enum(gInfo));
1976 x_print_string(gInfo, str, xPos, yPos, posFlags);
1980 local_dayname(Calendar *c, char **array_place, int dayNum)
1985 unsigned long to_len = 0;
1987 static char *defaultDays[DAYS_IN_WEEK] =
1989 "S", "M", "T", "W", "T", "F", "S"
1991 static int dayCatIndex[DAYS_IN_WEEK] =
1993 497, 491, 492, 493, 494, 495, 496
1996 source = catgets(c->DT_catd, 1,
1997 dayCatIndex[dayNum], defaultDays[dayNum]);
1999 _len = strlen( source );
2000 _converter_( source, _len, &to, &to_len );
2001 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2002 str = euc_to_octal(to);
2004 str = euc_to_octal(source);
2007 *array_place = (char *)malloc(sizeof(char) * (cm_strlen(str) + 1));
2008 cm_strcpy(*array_place, str);
2012 local_dayname3(Calendar *c, char **array_place, int dayNum)
2017 unsigned long to_len = 0;
2019 static char *defaultDays[DAYS_IN_WEEK] =
2021 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
2023 static int dayCatIndex[DAYS_IN_WEEK] =
2025 480, 481, 482, 483, 484, 485, 486
2028 source = catgets(c->DT_catd, 1,
2029 dayCatIndex[dayNum], defaultDays[dayNum]);
2031 _len = strlen( source );
2032 _converter_( source, _len, &to, &to_len );
2033 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2034 str = euc_to_octal(to);
2036 str = euc_to_octal(source);
2039 *array_place = (char *)malloc(sizeof(char) * (cm_strlen(str) + 1));
2040 cm_strcpy(*array_place, str);
2044 get_report_type_string(CMGraphicsInfo *gInfo)
2046 Calendar *c = gInfo->c;
2047 int reportType = gInfo->reportType;
2048 static char *defaultStrs[] =
2050 "Day view by Calendar Manager",
2051 "Week view by Calendar Manager",
2052 "Month view by Calendar Manager",
2053 "Year view by Calendar Manager",
2054 "Appt List by Calendar Manager",
2055 "To Do List by Calendar Manager"
2057 static int catIndex[] =
2059 469, 490, 477, 507, 474, 473
2061 static char *reportStrs[] =
2063 NULL, NULL, NULL, NULL, NULL, NULL
2066 if ((reportType < 0) || (reportType >= XtNumber(defaultStrs)))
2069 if (reportStrs[reportType] == (char *)NULL)
2073 unsigned long to_len = 0;
2076 str = catgets(c->DT_catd, 1, catIndex[reportType],
2077 defaultStrs[reportType]);
2079 _len = strlen( str );
2080 _converter_( str, _len, &to, &to_len );
2081 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2084 str = euc_to_octal(str);
2086 reportStrs[reportType] = cm_strdup(str);
2089 return reportStrs[reportType];
2093 filePrintDoneCB(Display *dsp, XPContext context, XPGetDocStatus status,
2096 Calendar *c = (Calendar *)uData;
2098 if (pd_get_bad_alloc_error(c))
2100 showBadAllocError(c);
2101 pd_set_bad_alloc_error(c, False);
2104 filePrintReportStatus(c, (status == XPGetDocFinished));
2108 filePrintReportStatus(Calendar *c, Boolean ok)
2110 Props_pu *pu = (Props_pu *)c->properties_pu;
2116 label = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
2119 errText = XtNewString(catgets(c->DT_catd, 1, 1115,
2120 "Error - unable to print to file."));
2121 title = XtNewString(catgets(c->DT_catd, 1, 1114,
2122 "Calendar : Error - Print To File"));
2123 pixmap = pu->xm_error_pixmap;
2127 errText = XtNewString(catgets(c->DT_catd, 1, 1117,
2128 "Print to file has completed."));
2129 title = XtNewString(catgets(c->DT_catd, 1, 1116,
2130 "Calendar : Print To File"));
2131 pixmap = pu->xm_info_pixmap;
2134 dialog_popup(c->frame,
2135 DIALOG_TITLE, title,
2136 DIALOG_TEXT, errText,
2137 BUTTON_IDENT, 1, label,
2138 DIALOG_IMAGE, pixmap,
2147 showBadAllocError(Calendar *c)
2149 Props_pu *pu = (Props_pu *)c->properties_pu;
2155 label = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
2156 errText = XtNewString(catgets(c->DT_catd, 1, 1122,
2157 "Print job failed.\n\n\
2158 The X Print Server is temporarily out of resources."));
2159 title = XtNewString(catgets(c->DT_catd, 1, 1121,
2160 "Calendar : Print Server Error"));
2161 pixmap = pu->xm_error_pixmap;
2163 dialog_popup(c->frame,
2164 DIALOG_TITLE, title,
2165 DIALOG_TEXT, errText,
2166 BUTTON_IDENT, 1, label,
2167 DIALOG_IMAGE, pixmap,
2176 x_open_file(Calendar *c)
2178 CMGraphicsInfo *gInfo;
2184 unsigned int gcMask = GCFont | GCForeground | GCBackground |
2185 GCTile | GCFillStyle | GCLineWidth;
2187 WidgetList shellChildren;
2188 #ifdef SHELL_SIZE_BUG
2189 Dimension shellWd = 0, shellHt = 0;
2190 #endif /* SHELL_SIZE_BUG */
2192 static Boolean getResources = True;
2193 _Xltimeparams localtime_buf;
2197 XtGetApplicationResources(c->frame, (XtPointer)&dvFonts,
2198 dvDefaultResources, XtNumber(dvDefaultResources),
2200 XtGetApplicationResources(c->frame, (XtPointer)&wvFonts,
2201 wvDefaultResources, XtNumber(wvDefaultResources),
2203 XtGetApplicationResources(c->frame, (XtPointer)&mvFonts,
2204 mvDefaultResources, XtNumber(mvDefaultResources),
2206 XtGetApplicationResources(c->frame, (XtPointer)&yvFonts,
2207 yvDefaultResources, XtNumber(yvDefaultResources),
2209 XtGetApplicationResources(c->frame, (XtPointer)&avFonts,
2210 avDefaultResources, XtNumber(avDefaultResources),
2212 XtGetApplicationResources(c->frame, (XtPointer)&tvFonts,
2213 tvDefaultResources, XtNumber(tvDefaultResources),
2215 getResources = False;
2218 if ((printShell = pd_get_print_shell(c)) == (Widget)NULL)
2219 return (void *)NULL;
2221 if ((gInfo = (CMGraphicsInfo *)XtMalloc(sizeof(CMGraphicsInfo)))
2222 == (CMGraphicsInfo *)NULL)
2223 return (void *)NULL;
2226 XtGetApplicationResources(printShell, (XtPointer)&printResources,
2227 displayResources, XtNumber(displayResources),
2231 #if defined(PRINTING_SUPPORTED)
2234 if (!inDebugMode(c))
2237 if (pd_print_to_file(c))
2239 char *fileName = pd_get_file_name(c);
2241 /* Protocol says XpStartJob() MUST be called before XmPrintToFile() */
2242 XpStartJob(XtDisplay(printShell), XPGetData);
2244 XFlush(XtDisplay(printShell));
2246 if (!XmPrintToFile(XtDisplay(printShell), fileName,
2247 filePrintDoneCB, (XtPointer)c))
2249 XpCancelJob(XtDisplay(printShell), False);
2252 XtFree((char *)gInfo);
2254 filePrintReportStatus(c, False);
2256 return (void *)NULL;
2262 XpStartJob(XtDisplay(printShell), XPSpool);
2267 #endif /* PRINTING_SUPPORTED */
2271 #ifdef SHELL_SIZE_BUG
2272 XtSetArg(args[nargs], XmNwidth, &shellWd); nargs++;
2273 XtSetArg(args[nargs], XmNheight, &shellHt); nargs++;
2274 #endif /* SHELL_SIZE_BUG */
2275 XtSetArg(args[nargs], XmNchildren, &shellChildren); nargs++;
2276 XtSetArg(args[nargs], XmNnumChildren, &nChildren); nargs++;
2277 XtGetValues(printShell, args, nargs);
2279 #ifdef SHELL_SIZE_BUG
2280 if ((shellWd < 10) || (shellHt < 10))
2282 shellWd = XmConvertUnits(printShell, XmHORIZONTAL, Xm1000TH_INCHES,
2283 PAGE_WIDTH, XmPIXELS);
2284 shellHt = XmConvertUnits(printShell, XmVERTICAL, Xm1000TH_INCHES,
2285 PAGE_HEIGHT, XmPIXELS);
2288 XtSetArg(args[nargs], XmNwidth, shellWd); nargs++;
2289 XtSetArg(args[nargs], XmNheight, shellHt); nargs++;
2290 XtSetValues(printShell, args, nargs);
2292 #endif /* SHELL_SIZE_BUG */
2297 XtSetArg(args[nargs], XmNunitType, XmPIXELS); nargs++;
2299 if (!inDebugMode(c))
2302 XtSetArg(args[nargs], XmNbackground,
2303 WhitePixelOfScreen(XtScreen(printShell))); nargs++;
2307 drawingArea = XmCreateDrawingArea(printShell, "PrintArea",
2311 drawingArea = shellChildren[0];
2315 XtAddCallback(drawingArea, XmNinputCallback,
2316 tmpFn, (XtPointer)NULL);
2319 gInfo->drawingArea = drawingArea;
2320 gInfo->gc = XtAllocateGC(drawingArea, 0, 0, NULL, gcMask, 0);
2322 gInfo->reportType = PR_MONTH_VIEW; /* Set properly in x_init_*() */
2324 gInfo->fontInfo = gInfo->curFont = (CMFontInfo *)NULL;
2327 gInfo->reverseVideo = False;
2328 gInfo->fg = BlackPixelOfScreen(XtScreen(drawingArea));
2329 gInfo->bg = WhitePixelOfScreen(XtScreen(drawingArea));
2332 XtSetArg(args[nargs], XmNforeground, &(gInfo->fg)); nargs++;
2333 XtSetArg(args[nargs], XmNbackground, &(gInfo->bg)); nargs++;
2334 XtGetValues(drawingArea, args, nargs);
2336 gInfo->lightPixmap = None;
2337 gInfo->darkPixmap = None;
2339 /* set up time stamp */
2340 /* STRING_EXTRACTION SUNW_DESKSET_CM_MSG
2341 * The following string is the date/time format used in printing out
2342 * calendar views. This is the locale's date and time. If this string
2343 * is to be translated, please refer to the man pages for strftime()
2344 * for various format strings.
2347 tm = _XLocaltime(&t, localtime_buf);
2348 strftime(gInfo->timestamp, BUFFERSIZE, "%x %I:%M %p", tm);
2352 unsigned long to_len = 0;
2355 _len = strlen( gInfo->timestamp );
2356 _converter_( gInfo->timestamp, _len, &to, &to_len );
2357 if ( ( to != NULL ) && ( to_len != 0 ) )
2358 strncpy( gInfo->timestamp, to,
2359 ( BUFFERSIZE > to_len ) ? to_len : BUFFERSIZE - 1 );
2362 return (void *)gInfo;
2366 x_print_file(void *gInfoP, Calendar *c)
2368 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2369 Display *dsp = XtDisplay(gInfo->drawingArea);
2372 if (!inDebugMode(c))
2377 /* Make sure we know about a BadAlloc if it happens. */
2378 XSync(XtDisplay(gInfo->drawingArea), FALSE);
2381 if (pd_get_bad_alloc_error(c) &&
2382 (!pd_print_to_file(c)))
2384 showBadAllocError(c);
2385 pd_set_bad_alloc_error(c, False);
2388 if (gInfo->lightPixmap != None)
2389 XFreePixmap(dsp, gInfo->lightPixmap);
2390 if (gInfo->darkPixmap != None)
2391 XFreePixmap(dsp, gInfo->darkPixmap);
2393 XtReleaseGC(gInfo->drawingArea, gInfo->gc);
2395 cm_release_fonts(gInfo);
2397 XtFree((char *)gInfo);
2401 x_init_printer(void *gInfoP, short orientation)
2403 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2404 Widget w = gInfo->drawingArea;
2407 unsigned int pageWd, pageHt;
2409 int rMargin, bMargin;
2411 Dimension daWd, daHt;
2414 if (inDebugMode(gInfo->c))
2416 XtAddCallback(w, XmNexposeCallback,
2417 tmpFn, (XtPointer)NULL);
2421 XpStartPage(XtDisplay(w), XtWindow(XtParent(w)));
2423 /* XpStartPage() sets the shell width/height correctly. */
2425 XtSetArg(args[nargs], XmNwidth, &daWd); nargs++;
2426 XtSetArg(args[nargs], XmNheight, &daHt); nargs++;
2427 XtGetValues(XtParent(w), args, nargs);
2429 if (XtIsRealized(w))
2431 XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0,
2433 inDebugMode(gInfo->c)
2442 XtSetArg(args[nargs], XmNwidth, daWd); nargs++;
2443 XtSetArg(args[nargs], XmNheight, daHt); nargs++;
2444 XtSetValues(w, args, nargs);
2449 if (inDebugMode(gInfo->c))
2453 XtRemoveCallback(w, XmNexposeCallback,
2454 tmpFn, (XtPointer)NULL);
2456 /* Now that window is displayed, get its actual size, */
2457 /* since the Window Manager may have modified it. */
2459 XtSetArg(args[nargs], XmNwidth, &daWd); nargs++;
2460 XtSetArg(args[nargs], XmNheight, &daHt); nargs++;
2461 XtGetValues(XtParent(w), args, nargs);
2465 /* Get margins from properties. */
2466 inchWd = XmConvertUnits(w, XmHORIZONTAL, Xm1000TH_INCHES,
2468 gInfo->leftMarginX = cm_cvt_margin(gInfo, CP_PRINTLMARGIN, inchWd);
2469 gInfo->topMarginY = cm_cvt_margin(gInfo, CP_PRINTTMARGIN, inchWd);
2470 rMargin = cm_cvt_margin(gInfo, CP_PRINTRMARGIN, inchWd);
2471 bMargin = cm_cvt_margin(gInfo, CP_PRINTBMARGIN, inchWd);
2473 gInfo->rightMarginX = daWd - rMargin;
2474 gInfo->bottomMarginY = daHt - bMargin;
2476 pageWd = XmConvertUnits(w, XmHORIZONTAL, XmPIXELS,
2477 daWd, Xm1000TH_INCHES);
2478 pageHt = XmConvertUnits(w, XmVERTICAL, XmPIXELS,
2479 daHt, Xm1000TH_INCHES);
2480 if (orientation == PORTRAIT)
2482 baseWd = PAGE_WIDTH;
2483 baseHt = PAGE_HEIGHT;
2487 baseWd = PAGE_HEIGHT;
2488 baseHt = PAGE_WIDTH;
2491 gInfo->hscale = (double)pageWd / (double)baseWd;
2492 gInfo->vscale = (double)pageHt / (double)baseHt;
2494 /* Scaled line widths: .25pt, 1pt, 2pt. */
2495 gInfo->thinWd = XmConvertUnits(w, XmHORIZONTAL, Xm100TH_POINTS,
2497 if (gInfo->thinWd < 1)
2499 gInfo->normalWd = XmConvertUnits(w, XmHORIZONTAL, Xm100TH_POINTS,
2501 if (gInfo->normalWd < 1)
2502 gInfo->normalWd = 1;
2503 gInfo->thickWd = XmConvertUnits(w, XmHORIZONTAL, Xm100TH_POINTS,
2505 if (gInfo->thickWd < 1)
2510 x_init_day(void *gInfoP, int timeslots)
2512 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2515 gInfo->reportType = PR_DAY_VIEW;
2517 /* Load day fonts */
2518 if (gInfo->nFonts == 0)
2522 for (i = 0; i < DV_NUM_FONTS; i++)
2523 cm_load_font(gInfo, i, dvFonts[i]);
2525 /* Set curFont to first loaded font. */
2526 gInfo->curFont = gInfo->fontInfo;
2529 cm_adjust_margins(gInfo);
2531 fInfo = cm_find_font(gInfo, DV_TIME_FONT);
2532 gInfo->u.dayInfo.tab1 = (cm_font_height(gInfo, fInfo) * 2) + gInfo->normalWd;
2534 gInfo->u.dayInfo.curX1 = gInfo->leftMarginX + (gInfo->normalWd / 2);
2535 gInfo->u.dayInfo.curX2 = (gInfo->leftMarginX + gInfo->rightMarginX) / 2;
2536 fInfo = cm_find_font(gInfo, DV_HEADER_FONT);
2537 gInfo->u.dayInfo.curY1 =
2538 gInfo->topMarginY + (gInfo->normalWd / 2) + cm_font_height(gInfo, fInfo) +
2539 VMARGIN(gInfo) + gInfo->u.dayInfo.tab1;
2540 gInfo->u.dayInfo.curY2 = gInfo->u.dayInfo.curY1;
2542 gInfo->u.dayInfo.boxHt =
2543 (gInfo->bottomMarginY - ((gInfo->normalWd + 1) / 2) -
2544 gInfo->u.dayInfo.curY1) / timeslots;
2545 gInfo->u.dayInfo.boxWd =
2546 gInfo->u.dayInfo.curX2 - gInfo->u.dayInfo.curX1;
2548 gInfo->u.dayInfo.line1 = 0;
2552 x_get_day_lines_per_page(void *gInfoP)
2554 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2555 CMFontInfo *fInfo = cm_find_font(gInfo, DV_APPT_FONT);
2557 return (gInfo->u.dayInfo.boxHt - gInfo->normalWd - (2 * VMARGIN(gInfo))) /
2558 cm_font_height(gInfo, fInfo);
2562 x_get_week_lines_per_page(void *gInfoP)
2564 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2565 CMFontInfo *fInfo = cm_find_font(gInfo, DV_APPT_FONT);
2567 return (gInfo->u.weekInfo.boxHt - gInfo->u.weekInfo.tab1 -
2568 ((gInfo->normalWd + 1) / 2) -
2569 (gInfo->thickWd / 2) - (2 * VMARGIN(gInfo))) /
2570 cm_font_height(gInfo, fInfo);
2574 x_print_header(void *gInfoP, char *buf, int pageNum, int numPages)
2576 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2577 Calendar *c = gInfo->c;
2579 char str2[BUFFERSIZE];
2580 char pageStr[BUFFERSIZE];
2583 char *reportTypeStr;
2585 /* --- print header info at top --- */
2586 if (buf != (char *)NULL)
2588 cm_set_font(gInfo, cm_get_title_enum(gInfo));
2591 unsigned long to_len = 0;
2594 _len = strlen( buf );
2595 _converter_( buf, _len, &to, &to_len );
2596 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2597 str = euc_to_octal(to);
2599 str = euc_to_octal(buf);
2602 x_print_string(gInfo, str,
2603 (gInfo->rightMarginX + gInfo->leftMarginX) / 2,
2605 CENTER_AT_X | BOTTOM_AT_Y);
2608 /* Get header/footer strings ready. */
2609 timeStamp = gInfo->timestamp;
2610 userId = c->view->current_calendar;
2611 reportTypeStr = get_report_type_string(gInfo);
2616 /* print creation notice at bottom */
2617 cm_strcpy(str2, catgets(c->DT_catd, 1, 468, "Page"));
2620 unsigned long to_len = 0;
2623 _len = strlen( str2 );
2624 _converter_( str2, _len, &to, &to_len );
2625 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2627 ( BUFFERSIZE > to_len ) ? to_len : BUFFERSIZE );
2630 cm_strcpy(str2, euc_to_octal(str2));
2632 str = catgets(c->DT_catd, 1, 476, "of");
2635 unsigned long to_len = 0;
2638 _len = strlen( str );
2639 _converter_( str, _len, &to, &to_len );
2640 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2645 sprintf(pageStr, "%s %d %s %d", str2, pageNum, str, numPages);
2647 /* Header/footer strings are all set - print 'em! */
2648 cm_print_header_string(gInfo, CP_PRINTLHEADER,
2649 timeStamp, userId, pageStr, reportTypeStr);
2650 cm_print_header_string(gInfo, CP_PRINTRHEADER,
2651 timeStamp, userId, pageStr, reportTypeStr);
2652 cm_print_header_string(gInfo, CP_PRINTLFOOTER,
2653 timeStamp, userId, pageStr, reportTypeStr);
2654 cm_print_header_string(gInfo, CP_PRINTRFOOTER,
2655 timeStamp, userId, pageStr, reportTypeStr);
2659 x_day_header (void *gInfoP)
2661 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2664 Calendar *c = gInfo->c;
2668 fInfo = cm_find_font(gInfo, DV_HEADER_FONT);
2669 dayBoxVOffset = (gInfo->normalWd / 2) +
2670 cm_font_height(gInfo, fInfo) + VMARGIN(gInfo);
2672 /* --- print Morning/Afternoon boxes --- */
2673 cm_set_font(gInfo, DV_TIME_FONT);
2675 x_fill_light_box(gInfo, gInfo->u.dayInfo.curX1,
2676 gInfo->topMarginY + dayBoxVOffset,
2677 gInfo->rightMarginX - ((gInfo->normalWd + 1) / 2),
2678 gInfo->topMarginY + dayBoxVOffset + gInfo->u.dayInfo.tab1,
2681 x_fill_dark_box(gInfo, gInfo->u.dayInfo.curX1,
2682 gInfo->topMarginY + dayBoxVOffset,
2683 gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1,
2684 gInfo->topMarginY + dayBoxVOffset + gInfo->u.dayInfo.tab1,
2687 midX = gInfo->u.dayInfo.curX2;
2688 x_fill_dark_box(gInfo, midX,
2689 gInfo->topMarginY + dayBoxVOffset,
2690 midX + gInfo->u.dayInfo.tab1,
2691 gInfo->topMarginY + dayBoxVOffset + gInfo->u.dayInfo.tab1,
2694 str = catgets(c->DT_catd, 1, 470, "Morning");
2698 unsigned long to_len = 0;
2701 _len = strlen( str );
2702 _converter_( str, _len, &to, &to_len );
2703 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2708 x_print_string(gInfo, str,
2709 (gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1 + midX) / 2,
2710 gInfo->topMarginY + dayBoxVOffset +
2711 (gInfo->u.dayInfo.tab1 / 2),
2712 CENTER_AT_X | CENTER_AT_Y);
2714 str = catgets(c->DT_catd, 1, 471, "Afternoon");
2718 unsigned long to_len = 0;
2721 _len = strlen( str );
2722 _converter_( str, _len, &to, &to_len );
2723 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2728 str = euc_to_octal(str);
2729 x_print_string(gInfo, str,
2730 (midX + gInfo->u.dayInfo.tab1 + gInfo->rightMarginX
2731 - ((gInfo->normalWd + 1) / 2)) / 2,
2732 gInfo->topMarginY + dayBoxVOffset +
2733 (gInfo->u.dayInfo.tab1 / 2),
2734 CENTER_AT_X | CENTER_AT_Y);
2738 x_day_timeslots(void *gInfoP, int i, Boolean more)
2740 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2744 Calendar *c = gInfo->c;
2746 sprintf (hourbuf, "%d", (morning(i) || (i == 12)) ? i : (i - 12) );
2747 sprintf (modbuf, "%s", morning(i) ? catgets(c->DT_catd, 1, 4, "am") :
2748 catgets(c->DT_catd, 1, 3, "pm"));
2750 /* --- print hourly boxes for appt entries --- */
2753 gInfo->u.dayInfo.curX1 = gInfo->u.dayInfo.curX2;
2754 gInfo->u.dayInfo.curY1 = gInfo->u.dayInfo.curY2;
2756 /* boxWd may be off by a pixel - set here to ensure correctness. */
2757 gInfo->u.dayInfo.boxWd =
2758 gInfo->rightMarginX - ((gInfo->normalWd + 1) / 2) -
2759 gInfo->u.dayInfo.curX1;
2762 x_draw_box(gInfo, gInfo->u.dayInfo.curX1, gInfo->u.dayInfo.curY1,
2763 gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.boxWd,
2764 gInfo->u.dayInfo.curY1 + gInfo->u.dayInfo.boxHt,
2766 x_fill_light_box(gInfo, gInfo->u.dayInfo.curX1,
2767 gInfo->u.dayInfo.curY1,
2768 gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1,
2769 gInfo->u.dayInfo.curY1 + gInfo->u.dayInfo.boxHt,
2772 cm_set_font(gInfo, DV_TIME_FONT);
2774 x_print_string(gInfo, hourbuf,
2775 gInfo->u.dayInfo.curX1 + (gInfo->u.dayInfo.tab1 / 2),
2776 gInfo->u.dayInfo.curY1 + (gInfo->u.dayInfo.boxHt / 2) -
2777 (VMARGIN(gInfo) / 2),
2778 CENTER_AT_X | BOTTOM_AT_Y);
2780 x_print_string(gInfo, modbuf,
2781 gInfo->u.dayInfo.curX1 + (gInfo->u.dayInfo.tab1 / 2),
2782 gInfo->u.dayInfo.curY1 + (gInfo->u.dayInfo.boxHt / 2) +
2783 (VMARGIN(gInfo) / 2),
2784 CENTER_AT_X | TOP_AT_Y);
2787 x_print_string(gInfo, "*",
2788 gInfo->u.dayInfo.curX1 + (gInfo->u.dayInfo.tab1 / 2),
2789 gInfo->u.dayInfo.curY1 + (gInfo->u.dayInfo.boxHt / 2) +
2790 cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo),
2791 CENTER_AT_X | TOP_AT_Y);
2793 gInfo->u.dayInfo.line1 = gInfo->u.dayInfo.curY1 +
2794 ((gInfo->normalWd + 1) / 2) + VMARGIN(gInfo);
2795 gInfo->u.dayInfo.curY1 += gInfo->u.dayInfo.boxHt;
2799 x_print_multi_appts(void *gInfoP,
2800 CSA_entry_handle *list,
2806 * This routine is used to print appointments for day and week
2807 * views. The parm "view" is used to differentiate
2808 * who is printing, and personalize the print for that view.
2811 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2812 int indented, indentAmt, multlines=TRUE;
2814 char buf1[128], buf2[257];
2815 Calendar *c = gInfo->c;
2816 Props *pr = (Props*)c->properties;
2817 int meoval = get_int_prop(pr, CP_PRINTPRIVACY);
2818 int dt = get_int_prop(pr, CP_DEFAULTDISP);
2819 int i, j, start, maxlines, pos = 1, line_counter = 0;
2820 Boolean new_appt = FALSE;
2821 CSA_return_code stat;
2822 Dtcm_appointment *appt;
2824 if (view == weekGlance)
2825 maxlines = x_get_week_lines_per_page(gInfoP);
2826 else if (view == dayGlance)
2827 maxlines = x_get_day_lines_per_page(gInfoP);
2830 start = ((num_page - 1) * maxlines) + 1;
2832 appt = allocate_appt_struct(appt_read,
2833 c->general->version,
2834 CSA_ENTRY_ATTR_CLASSIFICATION_I,
2835 CSA_ENTRY_ATTR_START_DATE_I,
2836 CSA_ENTRY_ATTR_SUMMARY_I,
2837 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
2838 CSA_ENTRY_ATTR_END_DATE_I,
2840 for (j = 0; j < a_total; j++) {
2841 stat = query_appt_struct(c->cal_handle, list[j], appt);
2842 if (stat != CSA_SUCCESS) {
2843 free_appt_struct(&appt);
2847 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) && !(meoval & PRINT_PUBLIC))
2849 if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
2850 !(meoval & PRINT_SEMIPRIVATE))
2852 if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
2853 !(meoval & PRINT_PRIVATE))
2856 lp = lines = text_to_lines(appt->what->value->item.string_value,
2857 multlines ? 10 : 1);
2860 /* skip past lines already printed */
2862 if (showtime_set(appt)) {
2864 for (i = 1; i <= num_page; i++)
2865 if (pos == (maxlines * i))
2869 while ((lines != NULL) && (pos < start)) {
2872 lines = lines->next;
2879 /* skip last line if it's a time */
2880 if (showtime_set(appt)) {
2881 if (line_counter == (maxlines - 1)) {
2882 free_appt_struct(&appt);
2887 /* HH:MM xm - HH:MM xm format */
2888 format_line2(appt, buf1, buf2, dt);
2890 indented = (*buf1 != '\0');
2891 indentAmt = (view == dayGlance) ? 0 : 1;
2895 /* only print if appt text found */
2896 if (lines != NULL && lines->s != NULL) {
2897 if ((indented) && (new_appt)) {
2899 if ((line_counter > maxlines) && (lines != NULL)) {
2900 free_appt_struct(&appt);
2904 cm_print_time (gInfo, buf1, view);
2907 cm_print_appt_text (gInfo, lines->s, indentAmt, view);
2909 if ((line_counter > maxlines) && (lines != NULL)) {
2910 free_appt_struct(&appt);
2914 lines = lines->next;
2915 while (lines != NULL) {
2917 if ((line_counter > maxlines) && (lines != NULL)) {
2918 free_appt_struct(&appt);
2922 cm_print_appt_text (gInfo, lines->s, indentAmt, view);
2923 lines = lines->next;
2927 if (view == weekGlance)
2928 cm_week_sched_update(gInfo, appt, pr);
2931 free_appt_struct(&appt);
2936 x_finish_printer(void *gInfoP)
2938 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2939 Widget w = gInfo->drawingArea;
2942 if (inDebugMode(gInfo->c))
2946 XpEndPage(XtDisplay(w));
2950 x_print_list_range(Calendar *c, CSA_sint32 appt_type, int item_data,
2951 Tick start_tick, Tick end_tick)
2953 char buf[MAXNAMELEN], buf2[MAXNAMELEN];
2955 Props *p = (Props *)c->properties;
2957 todo_view_op todo_view = VIEW_ALL;
2958 OrderingType ot = get_int_prop(p, CP_DATEORDERING);
2960 CSA_return_code stat;
2961 CSA_entry_handle *list;
2962 CSA_attribute *range_attrs;
2967 if ((xp = x_open_file(c)) == (void *)NULL)
2970 if (appt_type == CSA_TYPE_TODO) {
2971 todo_view = (todo_view_op)item_data;
2972 glance = c->view->glance;
2974 glance = (Glance)item_data;
2976 x_init_printer(xp, PORTRAIT);
2979 memset(buf, '\0', MAXNAMELEN);
2980 memset(buf2, '\0', MAXNAMELEN);
2982 start = lowerbound(start_tick);
2983 end = nextday(end_tick) - 1;
2985 format_date(start + 1, ot, buf2, 1, 0, 0);
2987 if (appt_type == CSA_TYPE_TODO)
2988 sprintf(buf, catgets(c->DT_catd, 1, 899,
2989 "To Do List Beginning: %s"), buf2);
2991 sprintf(buf, catgets(c->DT_catd, 1, 900,
2992 "Appt List Beginning: %s"), buf2);
2994 setup_range(&range_attrs, &ops, &i, start, end, appt_type,
2995 0, B_FALSE, c->general->version);
2996 stat = csa_list_entries(c->cal_handle, i, range_attrs,
2997 ops, &a_total, &list, NULL);
2998 if (stat != CSA_SUCCESS) {
3002 x_print_todo(xp, list, a_total, appt_type,
3003 (start_tick != end_tick), todo_view, end, buf);
3007 x_finish_printer(xp);
3008 x_print_file(xp, c);
3012 x_init_list(void *gInfoP)
3014 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3019 /* We can ONLY get here printing via dialog - printData is valid. */
3020 gInfo->reportType = pd_get_report_type(gInfo->c);
3022 /* Load list fonts */
3023 if (gInfo->nFonts == 0)
3027 if (gInfo->reportType == PR_APPT_LIST)
3029 for (i = 0; i < AV_NUM_FONTS; i++)
3030 cm_load_font(gInfo, i, avFonts[i]);
3034 for (i = 0; i < TV_NUM_FONTS; i++)
3035 cm_load_font(gInfo, i, tvFonts[i]);
3038 /* Set curFont to first loaded font. */
3039 gInfo->curFont = gInfo->fontInfo;
3042 cm_adjust_margins(gInfo);
3044 cm_set_font(gInfo, cm_get_header_enum(gInfo));
3046 hIndent = TODO_HINDENT * gInfo->hscale * gInfo->normalWd;
3047 vIndent = TODO_VINDENT * gInfo->vscale * gInfo->normalWd;
3048 gInfo->u.toDoInfo.outerX1 = gInfo->leftMarginX + (gInfo->thickWd / 2);
3049 gInfo->u.toDoInfo.outerY1 = gInfo->topMarginY + (gInfo->thickWd / 2) +
3050 cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo);
3051 gInfo->u.toDoInfo.innerX1 = gInfo->u.toDoInfo.outerX1 + hIndent;
3052 gInfo->u.toDoInfo.innerY1 = gInfo->u.toDoInfo.outerY1 + vIndent;
3053 gInfo->u.toDoInfo.outerX2 =
3054 gInfo->rightMarginX - ((gInfo->thickWd + 1) / 2);
3055 gInfo->u.toDoInfo.outerY2 =
3056 gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2);
3057 gInfo->u.toDoInfo.boxX2 = gInfo->u.toDoInfo.outerX2 - hIndent;
3058 gInfo->u.toDoInfo.boxY2 = gInfo->u.toDoInfo.outerY2 - vIndent;
3059 gInfo->u.toDoInfo.boxX1 = gInfo->u.toDoInfo.innerX1;
3060 gInfo->u.toDoInfo.boxY1 = gInfo->u.toDoInfo.boxY2 -
3061 cm_tiny_month_height(gInfo, VMARGIN(gInfo)) - gInfo->thickWd;
3062 gInfo->u.toDoInfo.innerX2 = gInfo->u.toDoInfo.boxX2;
3063 gInfo->u.toDoInfo.innerY2 = gInfo->u.toDoInfo.boxY1 - vIndent;
3065 gInfo->u.toDoInfo.lineX =
3066 gInfo->u.toDoInfo.innerX1 + ((gInfo->thickWd + 1) / 2) + HMARGIN(gInfo);
3067 gInfo->u.toDoInfo.lineY =
3068 gInfo->u.toDoInfo.innerY1 + ((gInfo->thickWd + 1) / 2) + VMARGIN(gInfo);
3072 x_print_todo(void *gInfoP, CSA_entry_handle *list, int a_total,
3073 CSA_sint32 appt_type, Boolean showDate, int vf,
3074 time_t end_time, char *buf)
3076 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3077 int i, items_per_page = 0, meoval;
3078 char buf3[BUFFERSIZE], buf2[BUFFERSIZE], buf1[BUFFERSIZE];
3079 int total_items = 0;
3080 boolean_t skip_appt;
3081 CSA_return_code stat;
3082 Dtcm_appointment *appt;
3083 Calendar *c = gInfo->c;
3084 Props *p = (Props*)c->properties;
3085 DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);
3086 OrderingType ot = get_int_prop(p, CP_DATEORDERING);
3087 SeparatorType st = get_int_prop(p, CP_DATESEPARATOR);
3089 int linesFullPage, linesPartialPage;
3090 int numAppts, numPages, curPage;
3093 cm_get_todo_lines_per_page(gInfo, appt_type, &linesFullPage,
3095 numAppts = cm_count_appts(gInfo, list, a_total, appt_type, vf);
3096 for (numPages = 1, numAppts -= linesPartialPage;
3099 numAppts -= linesFullPage;
3100 x_print_header(gInfoP, buf, curPage, numPages);
3101 cm_todo_outline(gInfo, curPage == numPages);
3102 cm_set_todo_text_clipping(gInfo);
3104 meoval = get_int_prop(p, CP_PRINTPRIVACY);
3105 buf1[0] = buf2[0] = buf3[0] = '\0';
3107 appt = allocate_appt_struct(appt_read,
3108 c->general->version,
3109 CSA_ENTRY_ATTR_CLASSIFICATION_I,
3110 CSA_ENTRY_ATTR_TYPE_I,
3111 CSA_ENTRY_ATTR_STATUS_I,
3112 CSA_ENTRY_ATTR_START_DATE_I,
3113 CSA_ENTRY_ATTR_SUMMARY_I,
3114 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
3115 CSA_ENTRY_ATTR_END_DATE_I,
3117 for (i = 0; i < a_total; i++)
3119 stat = query_appt_struct(c->cal_handle, list[i], appt);
3120 if (stat != CSA_SUCCESS)
3122 free_appt_struct(&appt);
3125 skip_appt = B_FALSE;
3127 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
3128 !(meoval & PRINT_PUBLIC))
3130 else if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
3131 !(meoval & PRINT_SEMIPRIVATE))
3133 else if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
3134 !(meoval & PRINT_PRIVATE))
3137 if ((appt_type == CSA_TYPE_TODO) &&
3138 ((appt->type->value->item.sint32_value != CSA_TYPE_TODO)
3140 ((vf == VIEW_PENDING) &&
3141 (appt->state->value->item.sint32_value ==
3142 CSA_STATUS_COMPLETED)) ||
3143 ((vf == VIEW_COMPLETED) &&
3144 (appt->state->value->item.sint32_value ==
3145 CSA_X_DT_STATUS_ACTIVE))))
3148 if ((appt_type == CSA_TYPE_EVENT) &&
3149 (appt->type->value->item.sint32_value != CSA_TYPE_EVENT))
3155 format_maxchars(appt, buf1, BUFFERSIZE - 5, dt);
3158 _csa_iso8601_to_tick(appt->time->value->item.date_time_value,
3160 format_date3(start_tick, ot, st, buf2);
3161 sprintf(buf3, "%s %s", buf2, buf1);
3163 cm_strcpy(buf3, buf1);
3166 cm_print_todo_text (gInfo, buf3,
3167 appt->state->value->item.sint32_value,
3168 appt_type, total_items);
3169 if ((++items_per_page % linesFullPage) == 0)
3171 cm_unset_todo_text_clipping(gInfo);
3172 x_finish_printer(gInfoP);
3173 x_init_printer(gInfoP, PORTRAIT);
3174 x_init_list(gInfoP);
3175 x_print_header(gInfoP, buf, ++curPage, numPages);
3176 cm_todo_outline(gInfo, curPage == numPages);
3177 cm_set_todo_text_clipping(gInfo);
3180 } /* end for stmt */
3182 free_appt_struct(&appt);
3183 cm_unset_todo_text_clipping(gInfo);
3185 if (items_per_page > linesPartialPage) {
3186 x_finish_printer(gInfoP);
3187 x_init_printer(gInfoP, PORTRAIT);
3188 x_init_list(gInfoP);
3189 x_print_header(gInfoP, buf, ++curPage, numPages);
3190 cm_todo_outline(gInfo, curPage == numPages);
3193 cm_print_todo_months(gInfo, end_time);
3197 x_print_month(void *gInfoP, int mon, int yr, int x1,
3198 int y1, int x2, int y2, int spacing)
3200 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3202 Tick j = monthdayyear(mon, 1, yr); /* starting date Jan 1, y */
3203 int i, colWd, dateWd, monLen;
3204 char str[BUFFERSIZE];
3207 mon = (mon % 13) + 1;
3211 x_set_clip_box(gInfo, x1, y1, x2, y2);
3213 cm_set_font(gInfo, cm_get_tiny_title_enum(gInfo));
3216 cm_strcpy(str, months[mon]);
3220 unsigned long to_len = 0;
3224 _converter_( str, _len, &to, &to_len );
3225 if ( ( to != NULL ) && ( to_len != 0 ) ) {
3230 cm_strcpy(str, euc_to_octal(str));
3231 x_fill_light_box(gInfo, x1 + HMARGIN(gInfo), y1,
3232 x2 - HMARGIN(gInfo),
3233 y1 + cm_font_height(gInfo, gInfo->curFont),
3235 x_print_string(gInfo, str,
3237 CENTER_AT_X | TOP_AT_Y);
3238 y1 += spacing + cm_font_height(gInfo, gInfo->curFont);
3240 fInfo = cm_find_font(gInfo, cm_get_tiny_date_enum(gInfo));
3241 monLen = monthlength(j);
3243 for (i = 0; i < monLen; i++)
3245 sprintf(str, "%d", i + 1);
3246 if ((dateWd = cm_string_width(gInfo, fInfo, str)) > colWd)
3250 cm_std_month_weekdays(gInfo, colWd, x1, y1, x2);
3251 y1 += spacing + cm_font_height(gInfo, gInfo->curFont);
3253 cm_std_month_dates(gInfo, fdom(j), monLen, colWd,
3254 x1, y1, x2, spacing);
3256 x_unset_clip_box(gInfo);
3260 x_init_std_year(void *gInfoP)
3262 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3265 gInfo->reportType = PR_YEAR_VIEW;
3267 /* Load year fonts */
3268 if (gInfo->nFonts == 0)
3272 for (i = 0; i < YV_NUM_FONTS; i++)
3273 cm_load_font(gInfo, i, yvFonts[i]);
3275 /* Set curFont to first loaded font. */
3276 gInfo->curFont = gInfo->fontInfo;
3279 cm_adjust_margins(gInfo);
3283 x_std_year_name(void *gInfoP, int yr)
3285 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3286 char yearBuf[BUFFERSIZE];
3288 /* --- print year centered at top --- */
3289 sprintf(yearBuf, "%d", yr);
3290 x_print_header(gInfoP, yearBuf, 1, 1);
3294 x_print_year(void *gInfoP, int yr)
3296 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3307 fInfo = cm_find_font(gInfo, YV_HEADER_FONT);
3308 monthHt = cm_tiny_month_height(gInfo, VMARGIN(gInfo));
3310 leftX = gInfo->leftMarginX;
3311 topY = gInfo->topMarginY + cm_font_height(gInfo, fInfo) + VMARGIN(gInfo);
3313 pageWd = gInfo->rightMarginX - leftX;
3314 pageHt = gInfo->bottomMarginY - topY;
3315 extraSpace = pageHt - (4 * monthHt);
3317 for (i = 0; i < 12; i++)
3322 x1 = leftX + ((col * pageWd) / 3);
3323 x2 = leftX + (((col + 1) * pageWd) / 3);
3327 y1 = topY + (((row + 1) * extraSpace) / 5) + (row * monthHt);
3328 y2 = topY + (((row + 2) * extraSpace) / 5) + ((row + 1) * monthHt);
3332 y1 = topY + ((row * pageHt) / 4);
3333 y2 = topY + (((row + 1) * pageHt) / 4);
3336 x_print_month(gInfoP, i + 1, yr, x1, y1, x2, y2, VMARGIN(gInfo));
3341 x_init_week(void *gInfoP)
3343 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3346 gInfo->reportType = PR_WEEK_VIEW;
3348 /* Load week fonts */
3349 if (gInfo->nFonts == 0)
3353 for (i = 0; i < WV_NUM_FONTS; i++)
3354 cm_load_font(gInfo, i, wvFonts[i]);
3356 /* Set curFont to first loaded font. */
3357 gInfo->curFont = gInfo->fontInfo;
3360 cm_adjust_margins(gInfo);
3362 fInfo = cm_find_font(gInfo, WV_HEADER_FONT);
3363 gInfo->u.weekInfo.curX1 = gInfo->leftMarginX + (gInfo->thickWd / 2);
3364 gInfo->u.weekInfo.curY1 = gInfo->topMarginY + cm_font_height(gInfo, fInfo) +
3365 VMARGIN(gInfo) + (gInfo->thickWd / 2);
3366 gInfo->u.weekInfo.boxWd =
3367 gInfo->rightMarginX - gInfo->leftMarginX - gInfo->thickWd;
3368 gInfo->u.weekInfo.boxHt =
3369 (gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2) -
3370 gInfo->u.weekInfo.curY1) / 2;
3371 gInfo->u.weekInfo.curY2 =
3372 gInfo->u.weekInfo.curY1 + gInfo->u.weekInfo.boxHt;
3374 fInfo = cm_find_font(gInfo, WV_DAY_FONT);
3375 gInfo->u.weekInfo.tab1 =
3376 ((3 * cm_font_height(gInfo, fInfo)) +
3377 gInfo->thickWd + gInfo->normalWd) / 2;
3381 x_week_appt_boxes(void *gInfoP)
3383 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3385 int innerWd, innerOffset;
3388 /* Draw weekdays box. */
3389 x1 = gInfo->u.weekInfo.curX1;
3390 y1 = gInfo->u.weekInfo.curY1;
3391 x2 = x1 + gInfo->u.weekInfo.boxWd;
3392 y2 = y1 + gInfo->u.weekInfo.tab1;
3394 x_fill_light_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3396 y2 = gInfo->u.weekInfo.curY2;
3397 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->thickWd);
3399 /* Draw weekdays vertical lines. */
3400 innerWd = gInfo->u.weekInfo.boxWd - gInfo->thickWd + gInfo->normalWd;
3401 innerOffset = ((gInfo->thickWd - 1) / 2) - ((gInfo->normalWd - 1) / 2);
3402 for (i = 1; i < WEEK_DAYS; i++)
3404 x1 = gInfo->u.weekInfo.curX1 + innerOffset + ((i * innerWd) / WEEK_DAYS);
3405 x_draw_line(gInfo, x1, y1, x1, y2, gInfo->normalWd);
3408 /* Draw weekends box. */
3409 x1 = gInfo->u.weekInfo.curX1 +
3410 (((WEEK_DAYS - WEEKEND_DAYS) * gInfo->u.weekInfo.boxWd) / WEEK_DAYS);
3412 y2 = y1 + gInfo->u.weekInfo.tab1;
3413 x_fill_light_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3415 y2 = gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2);
3416 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->thickWd);
3418 /* Draw weekends vertical lines. */
3419 for (i = WEEK_DAYS - WEEKEND_DAYS + 1; i < WEEK_DAYS; i++)
3421 x1 = gInfo->u.weekInfo.curX1 + innerOffset + ((i * innerWd) / WEEK_DAYS);
3422 x_draw_line(gInfo, x1, y1, x1, y2, gInfo->normalWd);
3427 x_week_sched_boxes(void *gInfoP)
3429 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3430 char *day_of_week[DAYS_IN_WEEK];
3431 char hourBuf[BUFFERSIZE];
3432 Props *p = (Props *)gInfo->c->properties;
3433 int begin = get_int_prop(p, CP_DAYBEGIN);
3434 int end = get_int_prop(p, CP_DAYEND);
3435 DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);
3439 int boxX1, boxY1, boxX2, boxY2, boxWd, boxHt;
3442 int ulOff = gInfo->thickWd / 2;
3443 int brOff = (gInfo->thickWd - 1) / 2;
3445 /* --- print week sched boxes --- */
3447 /* figure out number of partitions in sched box */
3448 num_hours = end - begin;
3450 /* determine offset of sched box from left margin */
3451 cm_set_font(gInfo, WV_DAY_FONT);
3452 boxIndent = cm_week_sched_box_indent(gInfo);
3453 boxX1 = gInfo->u.weekInfo.curX1 + boxIndent;
3454 boxX2 = gInfo->u.weekInfo.curX1 +
3455 ((3 * gInfo->u.weekInfo.boxWd) / WEEK_DAYS) - boxIndent;
3456 boxY1 = gInfo->u.weekInfo.curY2 +
3457 (2 * cm_font_height(gInfo, gInfo->curFont)) +
3459 boxY2 = gInfo->bottomMarginY - 1 - brOff;
3461 x_draw_box(gInfo, boxX1, boxY1, boxX2, boxY2, gInfo->thickWd);
3463 boxX1 += brOff - ((gInfo->normalWd - 1) / 2);
3464 boxX2 -= ulOff - (gInfo->normalWd / 2);
3465 boxY1 += brOff - ((gInfo->thinWd - 1) / 2);
3466 boxY2 -= ulOff - (gInfo->thinWd / 2);
3467 boxWd = boxX2 - boxX1;
3468 boxHt = boxY2 - boxY1;
3470 for (i = 0; i < DAYS_IN_WEEK; i++)
3471 local_dayname(gInfo->c, &day_of_week[i], (i + 1) % DAYS_IN_WEEK);
3473 /* print abbreviated weekdays on top and draw vertical lines. */
3474 for (i = 0; i < DAYS_IN_WEEK; i++)
3476 x1 = boxX1 + ((i * boxWd) / DAYS_IN_WEEK);
3477 x2 = boxX1 + (((i + 1) * boxWd) / DAYS_IN_WEEK);
3479 x_print_string(gInfo, day_of_week[i],
3480 (x1 + x2) / 2, boxY1 -
3481 gInfo->thickWd - (2 * VMARGIN(gInfo)),
3482 CENTER_AT_X | BOTTOM_AT_Y);
3483 free(day_of_week[i]);
3485 x_draw_line(gInfo, x1, boxY1, x1, boxY2, gInfo->normalWd);
3488 /* Print hours and horizontal lines. */
3489 for (thisHour = begin, i = 0; i <= num_hours; i++, thisHour++)
3496 else if ( dt == HOUR24 )
3501 sprintf(hourBuf, "%d", thisHour);
3502 y1 = boxY1 + ((i * boxHt) / num_hours);
3504 x_print_string(gInfo, hourBuf,
3505 boxX1 - gInfo->thickWd - HMARGIN(gInfo), y1,
3506 RIGHT_AT_X | CENTER_AT_Y);
3508 if ((i > 0) && (i < num_hours))
3509 x_draw_line(gInfo, boxX1, y1, boxX2, y1, gInfo->thinWd);
3512 gInfo->u.weekInfo.schedBoxX1 = boxX1;
3513 gInfo->u.weekInfo.schedBoxY1 = boxY1;
3514 gInfo->u.weekInfo.schedBoxX2 = boxX2;
3515 gInfo->u.weekInfo.schedBoxY2 = boxY2;
3519 x_week_daynames(void *gInfoP, char *dayName, int dayIndex, Boolean more)
3521 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3522 Calendar *c = gInfo->c;
3524 int innerOffset, innerWd;
3525 char dayBuf[BUFFERSIZE];
3527 y1 = (dayIndex < WEEK_DAYS) ? gInfo->u.weekInfo.curY1 :
3528 gInfo->u.weekInfo.curY2;
3529 y2 = y1 + gInfo->u.weekInfo.tab1;
3531 cm_set_font(gInfo, WV_DAY_FONT);
3533 innerWd = gInfo->u.weekInfo.boxWd - gInfo->thickWd + gInfo->normalWd;
3534 innerOffset = ((gInfo->thickWd - 1) / 2) - ((gInfo->normalWd - 1) / 2);
3536 if (dayIndex >= WEEK_DAYS)
3537 dayIndex -= WEEKEND_DAYS;
3538 x1 = gInfo->u.weekInfo.curX1 + innerOffset +
3539 ((dayIndex * innerWd) / WEEK_DAYS);
3540 x2 = gInfo->u.weekInfo.curX1 + innerOffset +
3541 (((dayIndex + 1) * innerWd) / WEEK_DAYS);
3545 unsigned long to_len = 0;
3548 _len = strlen(dayName);
3549 _converter_( dayName, _len, &to, &to_len );
3550 if ( ( to != NULL ) && ( to_len != 0 ) ) {
3555 sprintf(dayBuf, more ? "%s *" : "%s", euc_to_octal(dayName));
3556 x_print_string(gInfo, dayBuf, (x1 + x2) / 2, (y1 + y2) / 2,
3557 CENTER_AT_X | CENTER_AT_Y);
3559 gInfo->u.weekInfo.lineX = x1;
3560 gInfo->u.weekInfo.lineY = y2 + ((gInfo->normalWd + 1) / 2) + VMARGIN(gInfo);
3561 gInfo->u.weekInfo.lineMaxY = y1 + gInfo->u.weekInfo.boxHt;
3565 x_week_sched_init(void *gInfoP)
3567 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3569 memset(gInfo->u.weekInfo.schedBucket, 0,
3570 sizeof(gInfo->u.weekInfo.schedBucket));
3574 x_week_sched_draw(void *gInfoP, int dayIndex)
3576 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3578 Props *p = (Props *)gInfo->c->properties;
3579 int begin = get_int_prop(p, CP_DAYBEGIN);
3580 int end = get_int_prop(p, CP_DAYEND);
3581 int num_hours = end - begin;
3582 int nIntervals = num_hours * 4;
3584 int boxWd = gInfo->u.weekInfo.schedBoxX2 - gInfo->u.weekInfo.schedBoxX1;
3585 int boxHt = gInfo->u.weekInfo.schedBoxY2 - gInfo->u.weekInfo.schedBoxY1;
3586 int currColor, lastColor;
3587 int tOffset, bOffset;
3589 x1 = gInfo->u.weekInfo.schedBoxX1 +
3590 ((dayIndex * boxWd) / DAYS_IN_WEEK) + ((gInfo->normalWd + 1) / 2);
3591 x2 = gInfo->u.weekInfo.schedBoxX1 +
3592 (((dayIndex + 1) * boxWd) / DAYS_IN_WEEK) - (gInfo->normalWd / 2) - 1;
3595 for (i = 0; i < nIntervals; i++)
3597 y1 = gInfo->u.weekInfo.schedBoxY1 + ((i * boxHt) / nIntervals);
3598 y2 = gInfo->u.weekInfo.schedBoxY1 + (((i + 1) * boxHt) / nIntervals);
3599 switch (gInfo->u.weekInfo.schedBucket[i])
3607 tOffset = (i % 4) ? 0 : ((gInfo->thinWd + 1) / 2);
3608 bOffset = ((i + 1) % 4) ? 1 : (gInfo->thinWd / 2) + 1;
3609 x_fill_dark_box(gInfo, x1, y1 + tOffset, x2,
3615 x_fill_black_box(gInfo, x1, y1, x2, y2);
3619 if (currColor != lastColor)
3621 if ((currColor != 2) && (lastColor != 2))
3622 x_draw_line(gInfo, x1, y1, x2 + 1, y1, gInfo->thinWd);
3623 lastColor = currColor;
3629 x_init_month(void *gInfoP, int nRows)
3631 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3634 gInfo->reportType = PR_MONTH_VIEW;
3636 /* Load month fonts */
3637 if (gInfo->nFonts == 0)
3641 for (i = 0; i < MV_NUM_FONTS; i++)
3642 cm_load_font(gInfo, i, mvFonts[i]);
3644 /* Set curFont to first loaded font. */
3645 gInfo->curFont = gInfo->fontInfo;
3648 cm_adjust_margins(gInfo);
3650 /* --- init for month view print --- */
3651 fInfo = cm_find_font(gInfo, MV_HEADER_FONT);
3652 gInfo->u.monthInfo.curX1 = gInfo->leftMarginX + (gInfo->normalWd / 2);
3653 gInfo->u.monthInfo.curY1 =
3654 gInfo->topMarginY + cm_font_height(gInfo, fInfo) +
3655 VMARGIN(gInfo) + (gInfo->normalWd / 2);
3656 gInfo->u.monthInfo.boxWd =
3657 gInfo->rightMarginX - gInfo->leftMarginX - gInfo->normalWd;
3658 gInfo->u.monthInfo.boxHt =
3659 gInfo->bottomMarginY - ((gInfo->normalWd + 1) / 2) -
3660 gInfo->u.monthInfo.curY1;
3661 fInfo = cm_find_font(gInfo, MV_DAY_FONT);
3662 gInfo->u.monthInfo.tab1 = 2 * cm_font_height(gInfo, fInfo);
3663 gInfo->u.monthInfo.nRows = nRows;
3667 x_get_month_lines_per_page(void *gInfoP)
3669 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3670 CMFontInfo *fInfo = cm_find_font(gInfo, MV_APPT_FONT);
3671 CMFontInfo *dateFInfo = cm_find_font(gInfo, MV_DATE_FONT);
3672 int dateSz = HMARGIN(gInfo) + cm_font_height(gInfo, dateFInfo);
3674 return (((gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1) /
3675 gInfo->u.monthInfo.nRows) -
3676 gInfo->normalWd - dateSz - (2 * VMARGIN(gInfo))) /
3677 cm_font_height(gInfo, fInfo);
3681 x_month_daynames(void *gInfoP, int nRows)
3683 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3684 char *day_of_week[DAYS_IN_WEEK];
3686 Calendar *c = gInfo->c;
3690 for (i = 0; i < DAYS_IN_WEEK; i++)
3691 local_dayname3(gInfo->c, &(day_of_week[i]), i);
3693 /* Draw outer box. */
3694 x1 = gInfo->u.monthInfo.curX1;
3695 y1 = gInfo->u.monthInfo.curY1;
3696 x2 = x1 + gInfo->u.monthInfo.boxWd;
3697 y2 = y1 + gInfo->u.monthInfo.boxHt;
3698 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3700 /* Draw box around days. */
3701 y2 = y1 + gInfo->u.monthInfo.tab1;
3702 x_fill_dark_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3704 cm_set_font(gInfo, MV_DAY_FONT);
3705 for (i = 0; i < DAYS_IN_WEEK; i++)
3707 x1 = gInfo->u.monthInfo.curX1 +
3708 ((i * gInfo->u.monthInfo.boxWd) / DAYS_IN_WEEK);
3709 x2 = gInfo->u.monthInfo.curX1 +
3710 (((i + 1) * gInfo->u.monthInfo.boxWd) / DAYS_IN_WEEK);
3712 cm_reverse_video(gInfo, True);
3713 x_print_string(gInfo, day_of_week[i],
3714 (x1 + x2) / 2, (y1 + y2) / 2,
3715 CENTER_AT_X | CENTER_AT_Y);
3716 free(day_of_week[i]);
3718 cm_reverse_video(gInfo, False);
3720 x_draw_line(gInfo, x1, y1, x1, y1 + gInfo->u.monthInfo.boxHt,
3724 x1 = gInfo->u.monthInfo.curX1;
3725 x2 = x1 + gInfo->u.monthInfo.boxWd;
3726 dayBoxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3728 /* Draw horizontal lines. */
3729 for (i = 1; i < nRows; i++)
3731 y1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1 +
3732 ((i * dayBoxHt) / nRows);
3733 x_draw_line(gInfo, x1, y1, x2, y1, gInfo->normalWd);
3738 x_print_little_months(void *gInfoP, Tick tick)
3740 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3741 int m = month(tick); /* current month just printed */
3742 int y = year(tick); /* year of month just printed */
3743 int fday = fdom(tick); /* first day of month, 0=Sun ... */
3745 int nm, nmy, pm, pmy;
3747 int ndays = monthlength(tick);
3748 int nrows = gInfo->u.monthInfo.nRows;
3752 int boxX1, boxY1, boxWd, boxHt;
3753 int ulOffset, brOffset;
3758 * Print out miniature prev & next month on month grid.
3759 * Check if there is enough room at end; if not then
3760 * print at beginning of grid.
3762 nBoxes = nrows * DAYS_IN_WEEK;
3763 if ((fday + ndays + 2) <= nBoxes)
3765 pmIndex = nBoxes - 2;
3793 boxX1 = gInfo->u.monthInfo.curX1;
3794 boxY1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1;
3795 boxWd = gInfo->u.monthInfo.boxWd;
3796 boxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3797 ulOffset = (gInfo->normalWd + 1) / 2;
3798 brOffset = (gInfo->normalWd / 2) + 1;
3800 /* Determine spacing for drawing little months. Can be negative. */
3801 for (spacing = VMARGIN(gInfo);
3802 cm_tiny_month_height(gInfo, spacing) >
3803 (boxHt / nrows) - gInfo->normalWd;
3807 /* Gray out extra boxes. */
3808 y1 = boxY1 + ulOffset;
3809 y2 = boxY1 - brOffset + (boxHt / nrows);
3810 for (i = 0; i < fday; i++)
3812 x1 = boxX1 + ((i * boxWd) / DAYS_IN_WEEK) + ulOffset;
3813 x2 = boxX1 + (((i + 1) * boxWd) / DAYS_IN_WEEK) - brOffset;
3815 x_fill_light_box(gInfo, x1, y1, x2, y2, 0);
3818 x_print_month(gInfoP, pm, pmy, x1, y1, x2, y2, spacing);
3819 else if (i == (pmIndex + 1))
3820 x_print_month(gInfoP, nm, nmy, x1, y1, x2, y2, spacing);
3823 dayRow = (nBoxes - 1) / DAYS_IN_WEEK;
3824 y1 = boxY1 + ((dayRow * boxHt) / nrows) + ulOffset;
3825 y2 = boxY1 + (((dayRow + 1) * boxHt) / nrows) - brOffset;
3826 for (i = fday + ndays; i < nBoxes; i++)
3828 dayCol = i % DAYS_IN_WEEK;
3829 x1 = boxX1 + ((dayCol * boxWd) / DAYS_IN_WEEK) + ulOffset;
3830 x2 = boxX1 + (((dayCol + 1) * boxWd) / DAYS_IN_WEEK) - brOffset;
3832 x_fill_light_box(gInfo, x1, y1, x2, y2, 0);
3835 x_print_month(gInfoP, pm, pmy, x1, y1, x2, y2, spacing);
3836 else if (i == (pmIndex + 1))
3837 x_print_month(gInfoP, nm, nmy, x1, y1, x2, y2, spacing);
3842 x_month_timeslots(void *gInfoP, Tick tick, Boolean more)
3844 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3845 int fday = fdom(tick); /* first day of month, 0=Sun ... */
3846 int thisDay = dom(tick);
3847 int nrows = gInfo->u.monthInfo.nRows;
3849 int boxX1, boxY1, boxWd, boxHt;
3850 int ulOffset, brOffset;
3852 char dateBuf[BUFFERSIZE];
3854 boxX1 = gInfo->u.monthInfo.curX1;
3855 boxY1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1;
3856 boxWd = gInfo->u.monthInfo.boxWd;
3857 boxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3858 ulOffset = (gInfo->normalWd + 1) / 2;
3859 brOffset = (gInfo->normalWd / 2) + 1;
3861 /* Write date into appropriate box. */
3862 cm_set_font(gInfo, MV_DATE_FONT);
3863 dayRow = (thisDay + fday - 1) / DAYS_IN_WEEK;
3864 dayCol = (thisDay + fday - 1) % DAYS_IN_WEEK;
3866 gInfo->u.monthInfo.lineY = boxY1 + ((dayRow * boxHt) / nrows);
3867 gInfo->u.monthInfo.lineX = boxX1 + ((dayCol * boxWd) / DAYS_IN_WEEK);
3868 gInfo->u.monthInfo.lastX = gInfo->u.monthInfo.lineX + ulOffset;
3869 gInfo->u.monthInfo.lineMaxY = boxY1 + (((dayRow + 1) * boxHt) / nrows);
3870 gInfo->u.monthInfo.lineMaxX = boxX1 + (((dayCol + 1) * boxWd) /
3872 y1 = gInfo->u.monthInfo.lineY + ulOffset + HMARGIN(gInfo);
3873 x1 = gInfo->u.monthInfo.lineX + ulOffset + VMARGIN(gInfo);
3875 sprintf(dateBuf, more ? "%d *" : "%d", thisDay);
3876 x_print_string(gInfo, dateBuf, x1, y1, LEFT_AT_X | TOP_AT_Y);
3878 gInfo->u.monthInfo.lineY =
3879 y1 + cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo);
3883 x_print_month_appts(void *gInfoP, CSA_entry_handle *list,
3884 int a_total, int num_page,
3885 time_t hi_hour, int lines_per_box)
3887 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3890 char buf1[BUFFERSIZE];
3891 Calendar *c = gInfo->c;
3892 Props *pr = (Props *)c->properties;
3893 int meoval = get_int_prop(pr, CP_PRINTPRIVACY);
3894 int i, start, pos = 1, line_counter = 0;
3895 CSA_return_code stat;
3896 Dtcm_appointment *appt;
3899 start = ((num_page - 1) * lines_per_box) + 1;
3901 appt = allocate_appt_struct(appt_read,
3902 c->general->version,
3903 CSA_ENTRY_ATTR_CLASSIFICATION_I,
3904 CSA_ENTRY_ATTR_START_DATE_I,
3905 CSA_ENTRY_ATTR_SUMMARY_I,
3906 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
3908 for (i = 0; i < a_total; i++)
3910 stat = query_appt_struct(c->cal_handle, list[i], appt);
3911 if (stat != CSA_SUCCESS)
3913 free_appt_struct(&appt);
3917 _csa_iso8601_to_tick(appt->time->value->item.date_time_value, &start_tick);
3918 if (start_tick >= hi_hour)
3920 free_appt_struct(&appt);
3924 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
3925 !(meoval & PRINT_PUBLIC))
3927 if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
3928 !(meoval & PRINT_SEMIPRIVATE))
3930 if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
3931 !(meoval & PRINT_PRIVATE))
3940 get_time_str(appt, buf1);
3942 indented = (*buf1 != '\0');
3944 lines = text_to_lines(appt->what->value->item.string_value, 1);
3946 if ((line_counter > lines_per_box) && (lines != NULL))
3948 free_appt_struct(&appt);
3952 /* only print if appt text found */
3953 if ((lines != NULL) && (lines->s != NULL))
3955 if (indented) /* time found so print it */
3956 cm_print_month_time(gInfo, buf1);
3957 cm_print_month_text(gInfo, lines->s, indented ? 2 : 0);
3960 destroy_lines(lines);
3964 free_appt_struct(&appt);