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 libraries 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 #if 0 && defined(PRINTING_SUPPORTED)
61 #include <X11/extensions/Print.h>
62 #endif /* PRINTING_SUPPORTED */
65 #include <Xm/DialogS.h>
66 #include <Xm/DrawingA.h>
67 #if 0 && defined(PRINTING_SUPPORTED)
69 #endif /* PRINTING_SUPPORTED */
71 #define XOS_USE_XT_LOCKING
72 #define X_INCLUDE_TIME_H
73 #if defined(__linux__)
76 #include <X11/Xos_r.h>
79 * There is currently a defect in the X Print Server which
80 * causes the print shell to be created with dimensions 1x1
81 * instead of the dimensions appropriate to the X Print Server.
82 * Until this is corrected, defining SHELL_SIZE_BUG will
83 * cause dtcm to size the print shell to 8.5"x11.0".
85 #define SHELL_SIZE_BUG 1
87 #define BUFFERSIZE 512
88 #define DAYS_IN_WEEK 7
90 #define WEEKEND_DAYS 2
91 #define INTERVALS_PER_DAY 96 /* 4 15-minute intervals per hour * 24 hours */
93 #define VMARGIN(gInfo) (2 * gInfo->normalWd)
94 #define HMARGIN(gInfo) (4 * gInfo->normalWd)
95 #define TODO_HINDENT 10
96 #define TODO_VINDENT 10
107 static String dvFonts[DV_NUM_FONTS];
109 /* Week View fonts */
119 static String wvFonts[WV_NUM_FONTS];
121 /* Month View fonts */
134 static String mvFonts[MV_NUM_FONTS];
136 /* Year View fonts */
146 static String yvFonts[YV_NUM_FONTS];
148 /* Appt View fonts */
160 static String avFonts[AV_NUM_FONTS];
162 /* ToDo View fonts */
174 static String tvFonts[TV_NUM_FONTS];
177 typedef struct _PrintResources
179 Pixel lightGrayPixel;
185 * Unfortunately, the dt-application fonts don't support all the point
186 * sizes we'd like. We use the closest approximation.
189 static char bold40PtFont[] =
190 "-*-times-bold-r-normal-*-0-[80 0 0 40]-0-0-p-0-*-*:";
191 static char bold30PtFont[] =
192 "-*-times-bold-r-normal-*-0-300-0-0-p-0-*-*:";
193 static char bold20PtFont[] =
194 "-*-times-bold-r-normal-*-0-200-0-0-p-0-*-*:";
195 static char bold16PtFont[] =
196 "-*-times-bold-r-normal-*-0-160-0-0-p-0-*-*:";
197 static char bold14PtFont[] =
198 "-*-times-bold-r-normal-*-0-140-0-0-p-0-*-*:";
199 static char bold12PtFont[] =
200 "-*-times-bold-r-normal-*-0-120-0-0-p-0-*-*:";
201 static char bold10PtFont[] =
202 "-*-times-bold-r-normal-*-0-100-0-0-p-0-*-*:";
203 static char bold9PtFont[] =
204 "-*-times-bold-r-normal-*-0-90-0-0-p-0-*-*:";
205 static char bold7PtFont[] =
206 "-*-times-bold-r-normal-*-0-70-0-0-p-0-*-*:";
208 static char helv10PtFont[] =
209 "-*-helvetica-medium-r-normal-*-0-100-0-0-p-0-*-*:";
210 static char helv9PtFont[] =
211 "-*-helvetica-medium-r-normal-*-0-90-0-0-p-0-*-*:";
212 static char helv8PtFont[] =
213 "-*-helvetica-medium-r-normal-*-0-80-0-0-p-0-*-*:";
215 static char cour12PtFont[] =
216 "-*-courier-medium-r-normal-*-0-120-0-0-m-0-*-*:";
217 static char cour7PtFont[] =
218 "-*-courier-medium-r-normal-*-0-70-0-0-m-0-*-*:";
220 static char bold40PtFont[] =
221 "-dt-application-bold-r-normal-serif-0-[80 0 0 40]-0-0-p-0-*-*:";
222 static char bold30PtFont[] =
223 "-dt-application-bold-r-normal-serif-0-300-0-0-p-0-*-*:";
224 static char bold20PtFont[] =
225 "-dt-application-bold-r-normal-serif-0-200-0-0-p-0-*-*:";
226 static char bold16PtFont[] =
227 "-dt-application-bold-r-normal-serif-0-160-0-0-p-0-*-*:";
228 static char bold14PtFont[] =
229 "-dt-application-bold-r-normal-serif-0-140-0-0-p-0-*-*:";
230 static char bold12PtFont[] =
231 "-dt-application-bold-r-normal-serif-0-120-0-0-p-0-*-*:";
232 static char bold10PtFont[] =
233 "-dt-application-bold-r-normal-serif-0-100-0-0-p-0-*-*:";
234 static char bold9PtFont[] =
235 "-dt-application-bold-r-normal-serif-0-90-0-0-p-0-*-*:";
236 static char bold7PtFont[] =
237 "-dt-application-bold-r-normal-serif-0-70-0-0-p-0-*-*:";
239 static char helv10PtFont[] =
240 "-dt-application-medium-r-normal-sans-0-100-0-0-p-0-*-*:";
241 static char helv9PtFont[] =
242 "-dt-application-medium-r-normal-sans-0-90-0-0-p-0-*-*:";
243 static char helv8PtFont[] =
244 "-dt-application-medium-r-normal-sans-0-80-0-0-p-0-*-*:";
246 static char cour12PtFont[] =
247 "-dt-application-medium-r-normal-serif-0-120-0-0-m-0-*-*:";
248 static char cour7PtFont[] =
249 "-dt-application-medium-r-normal-serif-0-70-0-0-m-0-*-*:";
252 static XtResource dvDefaultResources[] =
254 {"dvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
255 sizeof(String) * DV_TITLE_FONT, XmRImmediate,
256 (XtPointer)bold16PtFont},
257 {"dvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
258 sizeof(String) * DV_HEADER_FONT, XmRImmediate,
259 (XtPointer)bold9PtFont},
260 {"dvpApptFont", "PrintApptFont", XmRString, sizeof(String),
261 sizeof(String) * DV_APPT_FONT, XmRImmediate,
262 (XtPointer)helv10PtFont},
263 {"dvpTimeFont", "PrintTimeFont", XmRString, sizeof(String),
264 sizeof(String) * DV_TIME_FONT, XmRImmediate,
265 (XtPointer)bold10PtFont}
268 static XtResource wvDefaultResources[] =
270 {"wvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
271 sizeof(String) * WV_TITLE_FONT, XmRImmediate,
272 (XtPointer)bold16PtFont},
273 {"wvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
274 sizeof(String) * WV_HEADER_FONT, XmRImmediate,
275 (XtPointer)bold9PtFont},
276 {"wvpApptFont", "PrintApptFont", XmRString, sizeof(String),
277 sizeof(String) * WV_APPT_FONT, XmRImmediate,
278 (XtPointer)helv9PtFont},
279 {"wvpDayFont", "PrintDayFont", XmRString, sizeof(String),
280 sizeof(String) * WV_DAY_FONT, XmRImmediate,
281 (XtPointer)bold12PtFont},
282 {"wvpBoxFont", "PrintBoxFont", XmRString, sizeof(String),
283 sizeof(String) * WV_BOX_FONT, XmRImmediate,
284 (XtPointer)bold12PtFont}
287 static XtResource mvDefaultResources[] =
289 {"mvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
290 sizeof(String) * MV_TITLE_FONT, XmRImmediate,
291 (XtPointer)bold30PtFont},
292 {"mvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
293 sizeof(String) * MV_HEADER_FONT, XmRImmediate,
294 (XtPointer)bold9PtFont},
295 {"mvpApptFont", "PrintApptFont", XmRString, sizeof(String),
296 sizeof(String) * MV_APPT_FONT, XmRImmediate,
297 (XtPointer)helv8PtFont},
298 {"mvpDayFont", "PrintDayFont", XmRString, sizeof(String),
299 sizeof(String) * MV_DAY_FONT, XmRImmediate,
300 (XtPointer)bold14PtFont},
301 {"mvpDateFont", "PrintDateFont", XmRString, sizeof(String),
302 sizeof(String) * MV_DATE_FONT, XmRImmediate,
303 (XtPointer)bold20PtFont},
304 {"mvpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
305 sizeof(String) * MV_TINY_TITLE_FONT, XmRImmediate,
306 (XtPointer)bold10PtFont},
307 {"mvpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
308 sizeof(String) * MV_TINY_DAY_FONT, XmRImmediate,
309 (XtPointer)cour7PtFont},
310 {"mvpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
311 sizeof(String) * MV_TINY_DATE_FONT, XmRImmediate,
312 (XtPointer)bold7PtFont}
315 static XtResource yvDefaultResources[] =
317 {"yvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
318 sizeof(String) * YV_TITLE_FONT, XmRImmediate,
319 (XtPointer)bold40PtFont},
320 {"yvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
321 sizeof(String) * YV_HEADER_FONT, XmRImmediate,
322 (XtPointer)bold9PtFont},
323 {"yvpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
324 sizeof(String) * YV_TINY_TITLE_FONT, XmRImmediate,
325 (XtPointer)bold16PtFont},
326 {"yvpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
327 sizeof(String) * YV_TINY_DAY_FONT, XmRImmediate,
328 (XtPointer)cour12PtFont},
329 {"yvpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
330 sizeof(String) * YV_TINY_DATE_FONT, XmRImmediate,
331 (XtPointer)bold12PtFont}
334 static XtResource avDefaultResources[] =
336 {"avpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
337 sizeof(String) * AV_TITLE_FONT, XmRImmediate,
338 (XtPointer)bold16PtFont},
339 {"avpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
340 sizeof(String) * AV_HEADER_FONT, XmRImmediate,
341 (XtPointer)bold9PtFont},
342 {"avpApptFont", "PrintApptFont", XmRString, sizeof(String),
343 sizeof(String) * AV_APPT_FONT, XmRImmediate,
344 (XtPointer)helv10PtFont},
345 {"avpItemFont", "PrintItemFont", XmRString, sizeof(String),
346 sizeof(String) * AV_ITEM_FONT, XmRImmediate,
347 (XtPointer)bold10PtFont},
348 {"avpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
349 sizeof(String) * AV_TINY_TITLE_FONT, XmRImmediate,
350 (XtPointer)bold16PtFont},
351 {"avpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
352 sizeof(String) * AV_TINY_DAY_FONT, XmRImmediate,
353 (XtPointer)cour12PtFont},
354 {"avpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
355 sizeof(String) * AV_TINY_DATE_FONT, XmRImmediate,
356 (XtPointer)bold12PtFont}
359 static XtResource tvDefaultResources[] =
361 {"tvpTitleFont", "PrintTitleFont", XmRString, sizeof(String),
362 sizeof(String) * TV_TITLE_FONT, XmRImmediate,
363 (XtPointer)bold16PtFont},
364 {"tvpHeaderFont", "PrintHeaderFont", XmRString, sizeof(String),
365 sizeof(String) * TV_HEADER_FONT, XmRImmediate,
366 (XtPointer)bold9PtFont},
367 {"tvpApptFont", "PrintApptFont", XmRString, sizeof(String),
368 sizeof(String) * TV_APPT_FONT, XmRImmediate,
369 (XtPointer)helv10PtFont},
370 {"tvpItemFont", "PrintItemFont", XmRString, sizeof(String),
371 sizeof(String) * TV_ITEM_FONT, XmRImmediate,
372 (XtPointer)bold10PtFont},
373 {"tvpTinyTitleFont", "PrintTinyTitleFont", XmRString, sizeof(String),
374 sizeof(String) * TV_TINY_TITLE_FONT, XmRImmediate,
375 (XtPointer)bold16PtFont},
376 {"tvpTinyDayFont", "PrintTinyDayFont", XmRString, sizeof(String),
377 sizeof(String) * TV_TINY_DAY_FONT, XmRImmediate,
378 (XtPointer)cour12PtFont},
379 {"tvpTinyDateFont", "PrintTinyDateFont", XmRString, sizeof(String),
380 sizeof(String) * TV_TINY_DATE_FONT, XmRImmediate,
381 (XtPointer)bold12PtFont}
385 static XtResource displayResources[] =
387 {"lightGrayPixel", "LightGrayPixel", XmRPixel, sizeof(Pixel),
388 XtOffsetOf(PrintResources, lightGrayPixel), XmRString,
390 {"darkGrayPixel", "DarkGrayPixel", XmRPixel, sizeof(Pixel),
391 XtOffsetOf(PrintResources, darkGrayPixel), XmRString,
395 static PrintResources printResources;
398 typedef int CMFontEnum;
409 typedef struct _CMFontInfo
415 typedef struct _CMDayInfo
425 typedef struct _CMToDoInfo
427 int outerX1, outerY1;
428 int innerX1, innerY1;
429 int innerX2, innerY2;
430 int outerX2, outerY2;
436 typedef struct _CMWeekInfo
446 int schedBoxX1, schedBoxY1;
447 int schedBoxX2, schedBoxY2;
448 char schedBucket[INTERVALS_PER_DAY];
451 typedef struct _CMMonthInfo
459 int lineMaxX, lineMaxY;
462 typedef struct _CMGraphicsInfo
469 char timestamp[BUFFERSIZE];
470 Boolean reverseVideo;
472 Pixmap lightPixmap, darkPixmap;
477 /* Scaled line thicknesses */
487 CMFontInfo *fontInfo;
496 CMMonthInfo monthInfo;
501 static void local_dayname(Calendar *, char **, int);
502 static void local_dayname3(Calendar *, char **, int);
503 static char *get_report_type_string(CMGraphicsInfo *);
504 #if 0 && defined(PRINTING_SUPPORTED)
505 static void filePrintDoneCB(Display *, XPContext, XPGetDocStatus,
507 #endif /* PRINTING_SUPPORTED */
508 static void filePrintReportStatus(Calendar *, Boolean);
509 static void showBadAllocError(Calendar *);
511 /* X Graphics stuff. */
512 static void x_print_string(CMGraphicsInfo *, char *, int, int, int);
513 static void x_fill_light_box(CMGraphicsInfo *, int, int, int, int, int);
514 static void x_fill_dark_box(CMGraphicsInfo *, int, int, int, int, int);
515 static void x_fill_black_box(CMGraphicsInfo *, int, int, int, int);
516 static void x_fill_box(CMGraphicsInfo *, int, int, int, int, Pixmap, int);
517 static void x_draw_box(CMGraphicsInfo *, int, int, int, int, int);
518 static void x_draw_line(CMGraphicsInfo *, int, int, int, int, int);
519 static void x_set_clip_box(CMGraphicsInfo *, int, int, int, int);
520 static void x_unset_clip_box(CMGraphicsInfo *);
523 static Boolean x_load_font(CMGraphicsInfo *, CMFontInfo *, char *);
526 static Boolean cm_load_font(CMGraphicsInfo *, CMFontEnum, char *);
527 static void cm_load_font_error(CMGraphicsInfo *, char *);
528 static void cm_release_fonts(CMGraphicsInfo *);
529 static Boolean cm_set_font(CMGraphicsInfo *, CMFontEnum);
530 static CMFontInfo *cm_find_font(CMGraphicsInfo *, CMFontEnum);
531 static void cm_font_extents(CMGraphicsInfo *, CMFontInfo *, int *, int *);
532 static int cm_font_height(CMGraphicsInfo *, CMFontInfo *);
533 static int cm_font_width(CMGraphicsInfo *, CMFontInfo *);
534 static int cm_string_width(CMGraphicsInfo *, CMFontInfo *, char *);
535 static void cm_reverse_video(CMGraphicsInfo *, Boolean);
537 static CMFontEnum cm_get_title_enum(CMGraphicsInfo *);
538 static CMFontEnum cm_get_header_enum(CMGraphicsInfo *);
539 static CMFontEnum cm_get_tiny_title_enum(CMGraphicsInfo *);
540 static CMFontEnum cm_get_tiny_day_enum(CMGraphicsInfo *);
541 static CMFontEnum cm_get_tiny_date_enum(CMGraphicsInfo *);
542 static void cm_adjust_margins(CMGraphicsInfo *);
543 static int cm_cvt_margin(CMGraphicsInfo *, Props_op, int);
544 static void cm_print_header_string(CMGraphicsInfo *, Props_op,
548 /* Day/Week View stuff */
549 static void cm_print_time(CMGraphicsInfo *, char *, Glance);
550 static void cm_print_appt_text(CMGraphicsInfo *, char *, int, Glance);
551 static void cm_print_text(CMGraphicsInfo *, char *, int, Glance);
552 static void cm_week_sched_update(CMGraphicsInfo *,
553 Dtcm_appointment *, Props *);
554 static int cm_week_sched_box_indent(CMGraphicsInfo *);
556 /* ToDo/Appt. View stuff */
557 static void cm_set_todo_text_clipping(CMGraphicsInfo *);
558 static void cm_unset_todo_text_clipping(CMGraphicsInfo *);
559 static void cm_print_todo_text(CMGraphicsInfo *, char *, CSA_sint32,
561 static int cm_tiny_month_height(CMGraphicsInfo *, int);
562 static void cm_print_todo_months(CMGraphicsInfo *, time_t);
563 static int cm_count_appts(CMGraphicsInfo *, CSA_entry_handle *,
564 int, CSA_sint32, int);
565 static void cm_get_todo_lines_per_page(CMGraphicsInfo *, CSA_sint32,
567 static void cm_todo_outline(CMGraphicsInfo *, Boolean);
569 /* Month View stuff */
570 static void cm_print_month_time(CMGraphicsInfo *, char *);
571 static void cm_print_month_text(CMGraphicsInfo *, char *, int);
572 static void cm_std_month_dates(CMGraphicsInfo *, int, int, int,
574 static void cm_std_month_weekdays(CMGraphicsInfo *, int, int, int, int);
577 static void tmpFn(Widget, XtPointer, XtPointer);
578 static void tmpSpin(Widget);
579 static Boolean tmpFlag;
585 XtAppContext appContext;
588 appContext = XtWidgetToApplicationContext(w);
591 XtAppNextEvent(appContext, &event);
592 XtDispatchEvent(&event);
597 tmpFn(Widget w, XtPointer uData, XtPointer cbData)
599 XmDrawingAreaCallbackStruct *cbStruct =
600 (XmDrawingAreaCallbackStruct *)cbData;
602 if (cbStruct->reason == XmCR_EXPOSE)
604 if (cbStruct->event->xexpose.count != 0)
609 if (cbStruct->event->type != ButtonPress)
618 x_print_string(CMGraphicsInfo *gInfo, char *str, int x, int y, int flags)
620 Widget w = gInfo->drawingArea;
622 XmFontList fontList = (XmFontList)NULL;
624 Dimension textWd, textHt;
627 XmStringDirection xmStringDirection;
632 XtSetArg(args[nargs], XmNstringDirection, &xmStringDirection); nargs++;
633 XtGetValues(w, args, nargs);
635 if ((gInfo->nFonts == 0) ||
636 (gInfo->curFont == (CMFontInfo *)NULL))
639 XtSetArg(args[nargs], XmNlabelFontList, &fontList); nargs++;
640 XtGetValues(XtParent(w), args, nargs);
644 fontList = gInfo->curFont->fontList;
647 xmString = XmStringCreateLocalized(str);
648 XmStringExtent(fontList, xmString, &textWd, &textHt);
650 xFlags = (flags & (LEFT_AT_X | CENTER_AT_X | RIGHT_AT_X));
651 yFlags = (flags & (TOP_AT_Y | CENTER_AT_Y | BOTTOM_AT_Y));
661 textX = x - (textWd/2);
665 textX = x - textWd + 1;
668 if (xmStringDirection == XmSTRING_DIRECTION_R_TO_L)
679 textY = y - (textHt/2);
687 XSetForeground(XtDisplay(w), gc, gInfo->fg);
688 XmStringDraw(XtDisplay(w), XtWindow(w), fontList, xmString,
689 gc, textX, textY, textWd, XmALIGNMENT_BEGINNING,
690 xmStringDirection, NULL);
691 XmStringFree(xmString);
695 x_fill_light_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2,
699 Widget w = gInfo->drawingArea;
704 XSetForeground(XtDisplay(w), gc, printResources.lightGrayPixel);
708 fillWd = x2 - x1 + 1;
709 fillHt = y2 - y1 + 1;
710 XFillRectangle(XtDisplay(w), XtWindow(w), gc, fillX, fillY, fillWd, fillHt);
713 x_draw_box(gInfo, x1, y1, x2, y2, lineWidth);
715 static char lightStippleData[] = {0x10, 0x00, 0x01, 0x00};
717 if (gInfo->lightPixmap == None)
719 Widget w = gInfo->drawingArea;
722 unsigned long fg, bg;
724 int lightStippleWd = 8;
725 int lightStippleHt = 4;
727 if (gInfo->reverseVideo)
739 XtSetArg(args[nargs], XmNdepth, &depth); nargs++;
740 XtGetValues(w, args, nargs);
743 XCreatePixmapFromBitmapData(XtDisplay(w), XtWindow(w),
745 lightStippleWd, lightStippleHt,
749 x_fill_box(gInfo, x1, y1, x2, y2, gInfo->lightPixmap, lineWidth);
754 x_fill_dark_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2,
758 Widget w = gInfo->drawingArea;
763 XSetForeground(XtDisplay(w), gc, printResources.darkGrayPixel);
767 fillWd = x2 - x1 + 1;
768 fillHt = y2 - y1 + 1;
769 XFillRectangle(XtDisplay(w), XtWindow(w), gc, fillX, fillY, fillWd, fillHt);
772 x_draw_box(gInfo, x1, y1, x2, y2, lineWidth);
774 static char darkStippleData[] = {0x11, 0xaa, 0x44, 0xaa};
776 if (gInfo->darkPixmap == None)
778 Widget w = gInfo->drawingArea;
781 unsigned long fg, bg;
783 int darkStippleWd = 8;
784 int darkStippleHt = 4;
786 if (gInfo->reverseVideo)
798 XtSetArg(args[nargs], XmNdepth, &depth); nargs++;
799 XtGetValues(w, args, nargs);
802 XCreatePixmapFromBitmapData(XtDisplay(w), XtWindow(w),
804 darkStippleWd, darkStippleHt,
808 x_fill_box(gInfo, x1, y1, x2, y2, gInfo->darkPixmap, lineWidth);
813 x_fill_black_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2)
815 x_fill_box(gInfo, x1, y1, x2, y2, None, 0);
819 x_fill_box(CMGraphicsInfo *gInfo, int x1, int y1,
820 int x2, int y2, Pixmap stipple, int lineWidth)
822 Widget w = gInfo->drawingArea;
827 XSetForeground(XtDisplay(w), gc, gInfo->fg);
828 XSetBackground(XtDisplay(w), gc, gInfo->bg);
832 XSetTile(XtDisplay(w), gc, stipple);
833 XSetFillStyle(XtDisplay(w), gc, FillTiled);
838 fillWd = x2 - x1 + 1;
839 fillHt = y2 - y1 + 1;
840 XFillRectangle(XtDisplay(w), XtWindow(w), gc, fillX, fillY, fillWd, fillHt);
843 XSetFillStyle(XtDisplay(w), gc, FillSolid);
846 x_draw_box(gInfo, x1, y1, x2, y2, lineWidth);
850 x_draw_box(CMGraphicsInfo *gInfo, int x1, int y1,
851 int x2, int y2, int lineWidth)
853 Widget w = gInfo->drawingArea;
855 XGCValues newGCValues;
860 newGCValues.line_width = lineWidth;
861 newGCValues.foreground = gInfo->fg;
862 XChangeGC(XtDisplay(w), gc, GCForeground | GCLineWidth, &newGCValues);
865 /* X centers thick lines; we want them wholly within specified rectangle. */
868 int ulOffset = lineWidth / 2;
869 int lrOffset = (lineWidth - 1) / 2;
878 XDrawRectangle(XtDisplay(w), XtWindow(w),
879 gc, x1, y1, x2 - x1, y2 - y1);
883 x_draw_line(CMGraphicsInfo *gInfo, int x1, int y1,
884 int x2, int y2, int lineWidth)
886 Widget w = gInfo->drawingArea;
888 XGCValues newGCValues;
893 newGCValues.line_width = lineWidth;
894 newGCValues.foreground = gInfo->fg;
895 XChangeGC(XtDisplay(w), gc, GCForeground | GCLineWidth, &newGCValues);
897 XDrawLine(XtDisplay(w), XtWindow(w),
902 x_set_clip_box(CMGraphicsInfo *gInfo, int x1, int y1, int x2, int y2)
905 Widget w = gInfo->drawingArea;
909 rect.width = x2 - x1;
910 rect.height = y2 - y1;
912 XSetClipRectangles(XtDisplay(w), gInfo->gc, 0, 0, &rect, 1, YXBanded);
916 x_unset_clip_box(CMGraphicsInfo *gInfo)
918 Widget w = gInfo->drawingArea;
920 XSetClipMask(XtDisplay(w), gInfo->gc, None);
924 x_load_font(CMGraphicsInfo *gInfo, CMFontInfo *fInfo, char *fontPattern)
926 Widget w = gInfo->drawingArea;
929 XmFontList fontList = (XmFontList)NULL;
931 if (fInfo->fontList != (XmFontList)NULL)
934 fromValue.addr = (XPointer)fontPattern;
935 fromValue.size = strlen(fontPattern);
937 toValue.addr = (XPointer)&fontList;
938 toValue.size = sizeof(XmFontList);
942 char *tmpPtr = XtNewString(fontPattern);
945 for (i = 0; tmpPtr[i] != '\0'; i++)
948 (tmpPtr[i] == '0') &&
949 (tmpPtr[i - 1] == '-') &&
950 (tmpPtr[i + 1] == '-'))
953 fromValue.addr = (XPointer)tmpPtr;
955 #endif /* GR_DEBUG */
958 * :( XtConvertAndStore() doesn't return False even when the specified
959 * font cannot be found; Motif plugs in a default font and issues a
962 XtConvertAndStore(w, XmRString, &fromValue, XmRFontList, &toValue);
965 XtFree((char *)fromValue.addr);
968 fInfo->fontList = fontList;
973 cm_load_font(CMGraphicsInfo *gInfo, CMFontEnum fontEnum,
977 CMFontInfo *fInfo = cm_find_font(gInfo, fontEnum);
979 if (fInfo != (CMFontInfo *)NULL)
980 /* It's a no-no to try to load a font more than once! */
983 fInfo = (CMFontInfo *)XtRealloc((char *)gInfo->fontInfo,
984 sizeof(CMFontInfo) * (gInfo->nFonts + 1));
985 if (fInfo == (CMFontInfo *)NULL)
987 gInfo->fontInfo = fInfo;
989 fInfo = &(gInfo->fontInfo[gInfo->nFonts]);
990 fInfo->fontEnum = fontEnum;
991 fInfo->fontList = (XmFontList)NULL;
993 if (!x_load_font(gInfo, fInfo, fontPattern))
995 cm_load_font_error(gInfo, fontPattern);
1004 cm_load_font_error(CMGraphicsInfo *gInfo, char *fontPattern)
1006 Calendar *c = gInfo->c;
1007 Props_pu *pu = (Props_pu *)c->properties_pu;
1013 errFmt = catgets(c->DT_catd, 1, 1119,
1014 "Warning - Unable to load font %s.");
1015 errText = (char *)XtMalloc((strlen(errFmt) + strlen(fontPattern) + 1) *
1017 sprintf(errText, errFmt, fontPattern);
1018 label = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
1019 title = XtNewString(catgets(c->DT_catd, 1, 1118,
1020 "Calendar : Warning - Print"));
1022 dialog_popup(c->frame,
1023 DIALOG_TITLE, title,
1024 DIALOG_TEXT, errText,
1025 BUTTON_IDENT, 1, label,
1026 DIALOG_IMAGE, pu->xm_warning_pixmap,
1035 cm_release_fonts(CMGraphicsInfo *gInfo)
1037 XtFree((char *)gInfo->fontInfo);
1038 gInfo->fontInfo = (CMFontInfo *)NULL;
1043 cm_set_font(CMGraphicsInfo *gInfo, CMFontEnum fontEnum)
1047 if ((gInfo->curFont == (CMFontInfo *)NULL) ||
1048 (gInfo->curFont->fontEnum != fontEnum))
1050 if ((fInfo = cm_find_font(gInfo, fontEnum)) == (CMFontInfo *)NULL)
1053 gInfo->curFont = fInfo;
1060 cm_find_font(CMGraphicsInfo *gInfo, CMFontEnum fontEnum)
1064 for (i = 0; i < gInfo->nFonts; i++)
1066 if (gInfo->fontInfo[i].fontEnum == fontEnum)
1067 return &(gInfo->fontInfo[i]);
1070 return (CMFontInfo *)NULL;
1074 cm_font_extents(CMGraphicsInfo *gInfo, CMFontInfo *fInfo, int *wd, int *ht)
1079 if ((gInfo != (CMGraphicsInfo *)NULL) &&
1080 (fInfo != (CMFontInfo *)NULL))
1082 XmFontContext fontContext;
1084 if (XmFontListInitFontContext(&fontContext, fInfo->fontList))
1086 XmFontListEntry fontListEntry;
1088 XFontStruct *fontStruct;
1089 XtPointer fontEntryFont;
1090 XmFontType fontType;
1091 XFontSetExtents *fontSetExtents;
1094 while ((fontListEntry = XmFontListNextEntry(fontContext))
1095 != (XmFontListEntry)NULL)
1097 fontEntryFont = XmFontListEntryGetFont(fontListEntry, &fontType);
1098 if (fontType == XmFONT_IS_FONT)
1100 fontStruct = (XFontStruct *)fontEntryFont;
1101 thisWd = fontStruct->max_bounds.rbearing -
1102 fontStruct->min_bounds.lbearing;
1103 thisHt = fontStruct->ascent + fontStruct->descent;
1105 else if (fontType == XmFONT_IS_FONTSET)
1107 fontSet = (XFontSet)fontEntryFont;
1108 fontSetExtents = XExtentsOfFontSet(fontSet);
1109 thisWd = fontSetExtents->max_logical_extent.width;
1110 thisHt = fontSetExtents->max_logical_extent.height;
1120 XmFontListFreeFontContext(fontContext);
1124 *wd = (maxWd > 0) ? maxWd : 8;
1125 *ht = (maxHt > 0) ? maxHt : 13;
1129 cm_font_height(CMGraphicsInfo *gInfo, CMFontInfo *fInfo)
1133 cm_font_extents(gInfo, fInfo, &wd, &ht);
1138 cm_font_width(CMGraphicsInfo *gInfo, CMFontInfo *fInfo)
1142 cm_font_extents(gInfo, fInfo, &wd, &ht);
1147 cm_string_width(CMGraphicsInfo *gInfo, CMFontInfo *fInfo, char *str)
1149 if ((gInfo != (CMGraphicsInfo *)NULL) &&
1150 (fInfo != (CMFontInfo *)NULL) &&
1151 (str != (char *)NULL))
1156 XmFontList fontList = fInfo->fontList;
1158 xmStr = XmStringCreateLocalized(str);
1159 XmStringExtent(fontList, xmStr, &textWd, &textHt);
1160 XmStringFree(xmStr);
1169 cm_reverse_video(CMGraphicsInfo *gInfo, Boolean enabled)
1171 if (gInfo->reverseVideo != enabled)
1176 gInfo->fg = gInfo->bg;
1179 gInfo->reverseVideo = enabled;
1184 cm_get_title_enum(CMGraphicsInfo *gInfo)
1186 switch (gInfo->reportType)
1189 return DV_TITLE_FONT;
1192 return WV_TITLE_FONT;
1196 return MV_TITLE_FONT;
1199 return YV_TITLE_FONT;
1202 return AV_TITLE_FONT;
1205 return TV_TITLE_FONT;
1210 cm_get_header_enum(CMGraphicsInfo *gInfo)
1212 switch (gInfo->reportType)
1215 return DV_HEADER_FONT;
1218 return WV_HEADER_FONT;
1222 return MV_HEADER_FONT;
1225 return YV_HEADER_FONT;
1228 return AV_HEADER_FONT;
1231 return TV_HEADER_FONT;
1236 cm_get_tiny_title_enum(CMGraphicsInfo *gInfo)
1238 switch (gInfo->reportType)
1242 return MV_TINY_TITLE_FONT;
1245 return YV_TINY_TITLE_FONT;
1248 return AV_TINY_TITLE_FONT;
1251 return TV_TINY_TITLE_FONT;
1256 cm_get_tiny_day_enum(CMGraphicsInfo *gInfo)
1258 switch (gInfo->reportType)
1262 return MV_TINY_DAY_FONT;
1265 return YV_TINY_DAY_FONT;
1268 return AV_TINY_DAY_FONT;
1271 return TV_TINY_DAY_FONT;
1276 cm_get_tiny_date_enum(CMGraphicsInfo *gInfo)
1278 switch (gInfo->reportType)
1282 return MV_TINY_DATE_FONT;
1285 return YV_TINY_DATE_FONT;
1288 return AV_TINY_DATE_FONT;
1291 return TV_TINY_DATE_FONT;
1296 cm_adjust_margins(CMGraphicsInfo *gInfo)
1299 CMFontEnum titleFont, headerFont;
1301 titleFont = cm_get_title_enum(gInfo);
1302 headerFont = cm_get_header_enum(gInfo);
1305 * Assume MonthFont and StampFont have been
1306 * set as required for header and footer.
1308 if ((fInfo = cm_find_font(gInfo, titleFont)) != (CMFontInfo *)NULL)
1309 gInfo->topMarginY += cm_font_height(gInfo, fInfo);
1311 if ((fInfo = cm_find_font(gInfo, headerFont)) != (CMFontInfo *)NULL)
1312 gInfo->bottomMarginY -= VMARGIN(gInfo) + cm_font_height(gInfo, fInfo);
1316 cm_cvt_margin(CMGraphicsInfo *gInfo, Props_op prop, int defaultVal)
1318 Widget w = gInfo->drawingArea;
1319 Props *p = (Props *) gInfo->c->properties;
1323 /* PostScript dimensions are the same vertically as horizontally. */
1324 returnVal = XmConvertStringToUnits(XtScreen(w),
1325 get_char_prop(p, prop),
1330 return badCvt ? defaultVal : returnVal;
1334 cm_print_time(CMGraphicsInfo *gInfo, char *str, Glance view)
1336 cm_print_text(gInfo, str, (view == dayGlance) ? 0 : 2, view);
1340 cm_print_appt_text(CMGraphicsInfo *gInfo, char *str,
1341 int indentAmt, Glance view)
1344 unsigned long to_len = 0;
1348 _converter_( str, _len, &to, &to_len );
1349 if ( ( to != NULL ) && ( to_len != 0 ) )
1352 cm_print_text(gInfo, str, indentAmt, view);
1356 cm_print_text(CMGraphicsInfo *gInfo, char *str,
1357 int indentAmt, Glance view)
1365 cm_set_font(gInfo, DV_APPT_FONT);
1367 /* Make sure the text fits in the box. */
1368 if (gInfo->u.dayInfo.line1 + cm_font_height(gInfo, gInfo->curFont) +
1369 VMARGIN(gInfo) <= gInfo->u.dayInfo.curY1 - (gInfo->normalWd / 2))
1371 textX = gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1 + HMARGIN(gInfo) +
1372 (indentAmt * cm_font_width(gInfo, gInfo->curFont));
1373 textY = gInfo->u.dayInfo.line1;
1375 clipX2 = gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.boxWd -
1376 ((gInfo->normalWd / 2) + 1) - HMARGIN(gInfo);
1378 gInfo->u.dayInfo.line1 += cm_font_height(gInfo, gInfo->curFont);
1384 cm_set_font(gInfo, WV_APPT_FONT);
1386 /* Make sure the text fits in the box. */
1387 if (gInfo->u.weekInfo.lineY + cm_font_height(gInfo, gInfo->curFont) +
1388 VMARGIN(gInfo) <= gInfo->u.weekInfo.lineMaxY - (gInfo->thickWd / 2))
1390 textX = gInfo->u.weekInfo.lineX +
1391 (gInfo->normalWd / 2) + HMARGIN(gInfo) +
1392 (indentAmt * cm_font_width(gInfo, gInfo->curFont));
1393 textY = gInfo->u.weekInfo.lineY;
1395 clipX2 = gInfo->u.weekInfo.lineX +
1396 (gInfo->u.weekInfo.boxWd / WEEK_DAYS) -
1397 ((gInfo->normalWd / 2) + 1) - HMARGIN(gInfo);
1399 gInfo->u.weekInfo.lineY += cm_font_height(gInfo, gInfo->curFont);
1408 if (clipX2 > clipX1)
1410 x_set_clip_box(gInfo, clipX1, gInfo->topMarginY,
1411 clipX2, gInfo->bottomMarginY - 1);
1412 x_print_string(gInfo, str, textX, textY, LEFT_AT_X | TOP_AT_Y);
1413 x_unset_clip_box(gInfo);
1418 cm_week_sched_update(CMGraphicsInfo *gInfo, Dtcm_appointment *appt, Props *p)
1421 * In order to draw appts in the sched box, all appts for a day are
1422 * mapped into a array, and then drawn later. The array has
1423 * 96 elements, and represents the 96 15-minute segements
1424 * available between the day boundaries
1426 int begin_t = get_int_prop(p, CP_DAYBEGIN);
1427 int end_t = get_int_prop(p, CP_DAYEND);
1433 _csa_iso8601_to_tick(appt->time->value->item.date_time_value, &tick);
1435 _csa_iso8601_to_tick(appt->end_time->value->item.date_time_value,
1439 * Determine the last element in the sched_buckets array which
1440 * corresponds to this time range.
1443 end_slider = (end_t - begin_t) * 4;
1446 * Figure where the begin and end times should be in the array.
1448 start = ((hour(tick) - begin_t) * 4) + (minute(tick) / 15);
1450 end = start + ((end_tick - tick) * 4 / 3600);
1455 * Make sure that the appointment starts/ends within the visible
1458 if (start < 0) start = 0;
1459 if (end < 0) end = 0;
1460 if (start > end_slider) start = end_slider;
1461 if (end > end_slider) end = end_slider;
1464 * Only map if some portion of time is between day boundaries.
1466 if ((start < 0 && end < 0) ||
1467 (start >= end_slider && end >= end_slider))
1471 * Mark the blocks of time affected in the array.
1473 for (i = start; i < end; i++)
1474 gInfo->u.weekInfo.schedBucket[i]++;
1478 cm_week_sched_box_indent(CMGraphicsInfo *gInfo)
1480 CMFontInfo *fInfo = cm_find_font(gInfo, WV_DAY_FONT);
1481 static char *baselineStr = "24";
1483 return cm_string_width(gInfo, fInfo, baselineStr) + HMARGIN(gInfo) +
1488 cm_set_todo_text_clipping(CMGraphicsInfo *gInfo)
1490 x_set_clip_box(gInfo,
1491 gInfo->u.toDoInfo.innerX1,
1492 gInfo->u.toDoInfo.innerY1,
1493 gInfo->u.toDoInfo.boxX2 -
1494 ((gInfo->thickWd / 2) + 1) - HMARGIN(gInfo),
1495 gInfo->u.toDoInfo.boxY2 -
1496 ((gInfo->thickWd / 2) + 1));
1500 cm_unset_todo_text_clipping(CMGraphicsInfo *gInfo)
1502 x_unset_clip_box(gInfo);
1506 cm_print_todo_text(CMGraphicsInfo *gInfo, char *str1, CSA_sint32 as,
1507 CSA_sint32 appt_type, int items)
1513 int i, digitWd, maxDigitWd;
1515 Boolean isTodo = (appt_type == CSA_TYPE_TODO);
1517 cm_set_font(gInfo, isTodo ? TV_ITEM_FONT : AV_ITEM_FONT);
1519 for (i = 0; i <= 9; i++)
1521 sprintf(buf, "%d", i);
1522 if ((digitWd = cm_string_width(gInfo, gInfo->curFont, buf)) > maxDigitWd)
1523 maxDigitWd = digitWd;
1526 sprintf(buf, "%d.", items);
1528 indent = strlen(buf);
1531 textX = gInfo->u.toDoInfo.lineX + (indent * maxDigitWd);
1532 textY = gInfo->u.toDoInfo.lineY;
1533 x_print_string(gInfo, buf, textX, textY,
1534 RIGHT_AT_X | TOP_AT_Y);
1535 textX += maxDigitWd + HMARGIN(gInfo);
1537 cm_set_font(gInfo, isTodo ? TV_APPT_FONT : AV_APPT_FONT);
1538 fontHt = cm_font_height(gInfo, gInfo->curFont);
1542 /* draw check box */
1544 textX + (gInfo->normalWd / 2) + 1,
1545 textY + (gInfo->normalWd / 2) + 1,
1546 textX + fontHt - ((gInfo->normalWd + 1) / 2),
1547 textY + fontHt - ((gInfo->normalWd + 1) / 2),
1550 /* add check to box */
1551 if (as == CSA_STATUS_COMPLETED)
1554 textX + (fontHt / 4),
1555 textY + (fontHt / 2),
1556 textX + (fontHt / 2),
1557 textY + fontHt - ((gInfo->normalWd + 3) / 2),
1560 textX + (fontHt / 2),
1561 textY + fontHt - ((gInfo->normalWd + 3) / 2),
1562 textX + ((5 * fontHt) / 4),
1563 textY + (gInfo->normalWd / 2) + 1,
1566 textX += ((5 * fontHt) / 4) + maxDigitWd + HMARGIN(gInfo);
1571 unsigned long to_len = 0;
1574 _len = strlen(str1);
1575 _converter_( str1, _len, &to, &to_len );
1576 if ( ( to != NULL ) && ( to_len != 0 ) )
1580 str = euc_to_octal(str1);
1582 x_print_string(gInfo, str, textX, textY, LEFT_AT_X | TOP_AT_Y);
1583 gInfo->u.toDoInfo.lineY += fontHt;
1587 cm_tiny_month_height(CMGraphicsInfo *gInfo, int spacing)
1593 * Month boxes need to be tall enough for:
1594 * 1 MonthFont, 1 DayFont, 6 DateFonts
1596 fInfo = cm_find_font(gInfo, cm_get_tiny_title_enum(gInfo));
1597 monthBoxHt = cm_font_height(gInfo, fInfo) + (2 * spacing);
1599 fInfo = cm_find_font(gInfo, cm_get_tiny_day_enum(gInfo));
1600 monthBoxHt += spacing + cm_font_height(gInfo, fInfo);
1602 fInfo = cm_find_font(gInfo, cm_get_tiny_date_enum(gInfo));
1603 monthBoxHt += 6 * (spacing + cm_font_height(gInfo, fInfo));
1609 cm_print_todo_months(CMGraphicsInfo *gInfo, time_t end_time)
1611 int x1, y1, x2, y2, lastX, mon, yr;
1613 int tlOff = (gInfo->thickWd + 1) / 2;
1614 int brOff = (gInfo->thickWd / 2) + 1;
1616 mon = month(end_time);
1617 yr = year(end_time);
1619 x1 = gInfo->u.toDoInfo.boxX1;
1620 lastX = gInfo->u.toDoInfo.boxX2;
1621 monthBoxWd = lastX - x1;
1622 y1 = gInfo->u.toDoInfo.boxY1;
1623 x2 = x1 + (monthBoxWd / 3);
1624 y2 = gInfo->u.toDoInfo.boxY2;
1626 x_draw_line(gInfo, x2, y1, x2, y2, gInfo->thickWd);
1628 x_print_month((void *)gInfo, 12, yr - 1,
1629 x1 + tlOff, y1 + tlOff,
1630 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1632 x_print_month((void *)gInfo, mon - 1, yr,
1633 x1 + tlOff, y1 + tlOff,
1634 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1637 x2 = gInfo->u.toDoInfo.boxX1 + ((2 * monthBoxWd) / 3);
1638 x_draw_line(gInfo, x2, y1, x2, y2, gInfo->thickWd);
1639 x_print_month((void *)gInfo, mon, yr,
1640 x1 + tlOff, y1 + tlOff,
1641 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1646 x_print_month((void *)gInfo, 1, yr + 1,
1647 x1 + tlOff, y1 + tlOff,
1648 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1650 x_print_month((void *)gInfo, mon + 1, yr,
1651 x1 + tlOff, y1 + tlOff,
1652 x2 - brOff, y2 - brOff, VMARGIN(gInfo));
1656 cm_count_appts(CMGraphicsInfo *gInfo, CSA_entry_handle *list, int a_total,
1657 CSA_sint32 appt_type, int vf)
1660 boolean_t skip_appt;
1661 CSA_return_code stat;
1662 Dtcm_appointment *appt;
1663 Calendar *c = gInfo->c;
1664 Props *p = (Props*)c->properties;
1668 meoval = get_int_prop(p, CP_PRINTPRIVACY);
1670 appt = allocate_appt_struct(appt_read,
1671 c->general->version,
1672 CSA_ENTRY_ATTR_CLASSIFICATION_I,
1673 CSA_ENTRY_ATTR_TYPE_I,
1674 CSA_ENTRY_ATTR_STATUS_I,
1675 CSA_ENTRY_ATTR_START_DATE_I,
1676 CSA_ENTRY_ATTR_SUMMARY_I,
1677 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
1678 CSA_ENTRY_ATTR_END_DATE_I,
1680 for (i = 0; i < a_total; i++)
1682 stat = query_appt_struct(c->cal_handle, list[i], appt);
1683 if (stat != CSA_SUCCESS)
1685 free_appt_struct(&appt);
1688 skip_appt = B_FALSE;
1690 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
1691 !(meoval & PRINT_PUBLIC))
1693 else if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
1694 !(meoval & PRINT_SEMIPRIVATE))
1696 else if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
1697 !(meoval & PRINT_PRIVATE))
1700 if ((appt_type == CSA_TYPE_TODO) &&
1701 ((appt->type->value->item.sint32_value != CSA_TYPE_TODO)
1703 ((vf == VIEW_PENDING) &&
1704 (appt->state->value->item.sint32_value ==
1705 CSA_STATUS_COMPLETED)) ||
1706 ((vf == VIEW_COMPLETED) &&
1707 (appt->state->value->item.sint32_value ==
1708 CSA_X_DT_STATUS_ACTIVE))))
1711 if ((appt_type == CSA_TYPE_EVENT) &&
1712 (appt->type->value->item.sint32_value != CSA_TYPE_EVENT))
1723 cm_get_todo_lines_per_page(CMGraphicsInfo *gInfo, CSA_sint32 apptType,
1724 int *linesFullPageP,
1725 int *linesPartialPageP)
1728 cm_find_font(gInfo, (apptType == CSA_TYPE_TODO) ?
1729 TV_APPT_FONT : AV_APPT_FONT);
1730 int fontHt = cm_font_height(gInfo, fInfo);
1732 *linesFullPageP = (gInfo->u.toDoInfo.boxY2 - gInfo->u.toDoInfo.innerY1 -
1733 gInfo->thickWd - (2 * VMARGIN(gInfo))) / fontHt;
1734 *linesPartialPageP = (gInfo->u.toDoInfo.innerY2 - gInfo->u.toDoInfo.innerY1 -
1735 gInfo->thickWd - (2 * VMARGIN(gInfo))) / fontHt;
1739 cm_todo_outline(CMGraphicsInfo *gInfo, Boolean lastPage)
1741 x_fill_dark_box(gInfo, gInfo->u.toDoInfo.outerX1,
1742 gInfo->u.toDoInfo.outerY1,
1743 gInfo->u.toDoInfo.outerX2,
1744 gInfo->u.toDoInfo.outerY2,
1750 x_fill_light_box(gInfo,
1751 gInfo->u.toDoInfo.innerX1,
1752 gInfo->u.toDoInfo.innerY1,
1753 gInfo->u.toDoInfo.innerX2,
1754 gInfo->u.toDoInfo.innerY2,
1758 x_fill_light_box(gInfo,
1759 gInfo->u.toDoInfo.boxX1,
1760 gInfo->u.toDoInfo.boxY1,
1761 gInfo->u.toDoInfo.boxX2,
1762 gInfo->u.toDoInfo.boxY2,
1768 x_fill_light_box(gInfo,
1769 gInfo->u.toDoInfo.innerX1,
1770 gInfo->u.toDoInfo.innerY1,
1771 gInfo->u.toDoInfo.boxX2,
1772 gInfo->u.toDoInfo.boxY2,
1778 cm_print_month_time(CMGraphicsInfo *gInfo, char *str)
1782 static char *baselineTime = "24:00";
1784 cm_set_font(gInfo, MV_APPT_FONT);
1786 /* Make sure the text fits in the box. */
1787 if (gInfo->u.monthInfo.lineY + cm_font_height(gInfo, gInfo->curFont) +
1788 VMARGIN(gInfo) <= gInfo->u.monthInfo.lineMaxY - (gInfo->normalWd / 2))
1790 /* Time is right-justified. */
1791 textX = gInfo->u.monthInfo.lineX + (gInfo->normalWd / 2) +
1792 HMARGIN(gInfo) + cm_string_width(gInfo, gInfo->curFont, baselineTime);
1793 gInfo->u.monthInfo.lastX = textX;
1794 textY = gInfo->u.monthInfo.lineY;
1795 clipX1 = gInfo->u.monthInfo.lineX + (gInfo->normalWd / 2) + HMARGIN(gInfo);
1796 clipX2 = gInfo->u.monthInfo.lineMaxX -
1797 (gInfo->normalWd / 2) - HMARGIN(gInfo);
1799 if (clipX2 > clipX1)
1801 x_set_clip_box(gInfo, clipX1, gInfo->u.monthInfo.lineY,
1802 clipX2, gInfo->u.monthInfo.lineMaxY);
1803 x_print_string(gInfo, str, textX, textY, RIGHT_AT_X | TOP_AT_Y);
1804 x_unset_clip_box(gInfo);
1810 cm_print_month_text(CMGraphicsInfo *gInfo, char *str, int indentAmt)
1815 cm_set_font(gInfo, MV_APPT_FONT);
1817 /* Make sure the text fits in the box. */
1818 if (gInfo->u.monthInfo.lineY + cm_font_height(gInfo, gInfo->curFont) +
1819 VMARGIN(gInfo) <= gInfo->u.monthInfo.lineMaxY - (gInfo->normalWd / 2))
1821 textX = gInfo->u.monthInfo.lastX + (gInfo->normalWd / 2) + HMARGIN(gInfo);
1822 textY = gInfo->u.monthInfo.lineY;
1824 clipX2 = gInfo->u.monthInfo.lineMaxX -
1825 (gInfo->normalWd / 2) - HMARGIN(gInfo);
1827 if (clipX2 > clipX1)
1829 x_set_clip_box(gInfo, clipX1, gInfo->u.monthInfo.lineY,
1830 clipX2, gInfo->u.monthInfo.lineMaxY);
1831 x_print_string(gInfo, str, textX, textY, LEFT_AT_X | TOP_AT_Y);
1832 x_unset_clip_box(gInfo);
1835 gInfo->u.monthInfo.lineY += cm_font_height(gInfo, gInfo->curFont);
1840 cm_std_month_weekdays(CMGraphicsInfo *gInfo, int colWd,
1841 int x1, int y1, int x2)
1843 char *day_of_week[DAYS_IN_WEEK];
1849 for (i = 0; i < DAYS_IN_WEEK; i++)
1850 local_dayname(gInfo->c, &day_of_week[i], i);
1852 x1 += HMARGIN(gInfo);
1853 x2 -= HMARGIN(gInfo);
1855 extraWd = boxWd - (DAYS_IN_WEEK * colWd);
1859 colWd = boxWd / DAYS_IN_WEEK;
1862 /* --- print std month weekdays --- */
1863 cm_set_font(gInfo, cm_get_tiny_day_enum(gInfo));
1864 for (i = 0; i < DAYS_IN_WEEK; i++)
1867 x_print_string(gInfo, day_of_week[i],
1868 x1 + (indent * colWd) + ((indent * extraWd) /
1869 (DAYS_IN_WEEK + 1)),
1870 y1, RIGHT_AT_X | TOP_AT_Y);
1873 for (i = 0; i < DAYS_IN_WEEK; i++)
1874 free(day_of_week[i]);
1878 cm_std_month_dates(CMGraphicsInfo *gInfo, int first_dom, int monlen,
1879 int colWd, int x1, int y1, int x2, int spacing)
1889 cm_set_font(gInfo, cm_get_tiny_date_enum(gInfo));
1890 fontHt = cm_font_height(gInfo, gInfo->curFont);
1892 x1 += HMARGIN(gInfo);
1893 x2 -= HMARGIN(gInfo);
1895 extraWd = boxWd - (DAYS_IN_WEEK * colWd);
1899 colWd = boxWd / DAYS_IN_WEEK;
1902 for (i = 0; i < monlen; i++, first_dom++)
1904 indent = (first_dom % DAYS_IN_WEEK) + 1;
1905 dateX = x1 + (indent * colWd) + ((indent * extraWd) /
1906 (DAYS_IN_WEEK + 1));
1907 dateY = y1 + ((first_dom / DAYS_IN_WEEK) * (spacing + fontHt));
1908 sprintf(dateStr, "%d", i + 1);
1909 x_print_string(gInfo, dateStr,
1910 dateX, dateY, RIGHT_AT_X | TOP_AT_Y);
1915 cm_print_header_string(CMGraphicsInfo *gInfo, Props_op printOp,
1916 char *timeStamp, char *userId,
1917 char *pageStr, char *reportTypeStr)
1919 Props *p = (Props *)gInfo->c->properties;
1920 int xPos, yPos, posFlags;
1924 hdrType = get_int_prop(p, printOp);
1932 case POP_HDR_USER_ID:
1936 case POP_HDR_PAGE_NUMBER:
1940 case POP_HDR_REPORT_TYPE:
1941 str = reportTypeStr;
1945 /* Nothing to print. */
1951 case CP_PRINTLHEADER:
1952 xPos = gInfo->leftMarginX;
1953 yPos = gInfo->topMarginY;
1954 posFlags = LEFT_AT_X | TOP_AT_Y;
1957 case CP_PRINTRHEADER:
1958 xPos = gInfo->rightMarginX - 1;
1959 yPos = gInfo->topMarginY;
1960 posFlags = RIGHT_AT_X | TOP_AT_Y;
1963 case CP_PRINTLFOOTER:
1964 xPos = gInfo->leftMarginX;
1965 if (gInfo->reportType == PR_WEEK_VIEW)
1966 xPos += cm_week_sched_box_indent(gInfo);
1967 yPos = gInfo->bottomMarginY + VMARGIN(gInfo);
1968 posFlags = LEFT_AT_X | TOP_AT_Y;
1971 case CP_PRINTRFOOTER:
1972 xPos = gInfo->rightMarginX - 1;
1973 yPos = gInfo->bottomMarginY + VMARGIN(gInfo);
1974 posFlags = RIGHT_AT_X | TOP_AT_Y;
1981 cm_set_font(gInfo, cm_get_header_enum(gInfo));
1982 x_print_string(gInfo, str, xPos, yPos, posFlags);
1986 local_dayname(Calendar *c, char **array_place, int dayNum)
1991 unsigned long to_len = 0;
1993 static char *defaultDays[DAYS_IN_WEEK] =
1995 "S", "M", "T", "W", "T", "F", "S"
1997 static int dayCatIndex[DAYS_IN_WEEK] =
1999 497, 491, 492, 493, 494, 495, 496
2002 source = catgets(c->DT_catd, 1,
2003 dayCatIndex[dayNum], defaultDays[dayNum]);
2005 _len = strlen( source );
2006 _converter_( source, _len, &to, &to_len );
2007 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2008 str = euc_to_octal(to);
2010 str = euc_to_octal(source);
2013 *array_place = (char *)malloc(sizeof(char) * (cm_strlen(str) + 1));
2014 cm_strcpy(*array_place, str);
2018 local_dayname3(Calendar *c, char **array_place, int dayNum)
2023 unsigned long to_len = 0;
2025 static char *defaultDays[DAYS_IN_WEEK] =
2027 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
2029 static int dayCatIndex[DAYS_IN_WEEK] =
2031 480, 481, 482, 483, 484, 485, 486
2034 source = catgets(c->DT_catd, 1,
2035 dayCatIndex[dayNum], defaultDays[dayNum]);
2037 _len = strlen( source );
2038 _converter_( source, _len, &to, &to_len );
2039 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2040 str = euc_to_octal(to);
2042 str = euc_to_octal(source);
2045 *array_place = (char *)malloc(sizeof(char) * (cm_strlen(str) + 1));
2046 cm_strcpy(*array_place, str);
2050 get_report_type_string(CMGraphicsInfo *gInfo)
2052 Calendar *c = gInfo->c;
2053 int reportType = gInfo->reportType;
2054 static char *defaultStrs[] =
2056 "Day view by Calendar Manager",
2057 "Week view by Calendar Manager",
2058 "Month view by Calendar Manager",
2059 "Year view by Calendar Manager",
2060 "Appt List by Calendar Manager",
2061 "To Do List by Calendar Manager"
2063 static int catIndex[] =
2065 469, 490, 477, 507, 474, 473
2067 static char *reportStrs[] =
2069 NULL, NULL, NULL, NULL, NULL, NULL
2072 if ((reportType < 0) || (reportType >= XtNumber(defaultStrs)))
2075 if (reportStrs[reportType] == (char *)NULL)
2079 unsigned long to_len = 0;
2082 str = catgets(c->DT_catd, 1, catIndex[reportType],
2083 defaultStrs[reportType]);
2085 _len = strlen( str );
2086 _converter_( str, _len, &to, &to_len );
2087 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2090 str = euc_to_octal(str);
2092 reportStrs[reportType] = cm_strdup(str);
2095 return reportStrs[reportType];
2098 #if 0 && defined(PRINTING_SUPPORTED)
2100 filePrintDoneCB(Display *dsp, XPContext context, XPGetDocStatus status,
2103 Calendar *c = (Calendar *)uData;
2105 if (pd_get_bad_alloc_error(c))
2107 showBadAllocError(c);
2108 pd_set_bad_alloc_error(c, False);
2111 filePrintReportStatus(c, (status == XPGetDocFinished));
2113 #endif /* PRINTING_SUPPORTED */
2116 filePrintReportStatus(Calendar *c, Boolean ok)
2118 Props_pu *pu = (Props_pu *)c->properties_pu;
2124 label = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
2127 errText = XtNewString(catgets(c->DT_catd, 1, 1115,
2128 "Error - unable to print to file."));
2129 title = XtNewString(catgets(c->DT_catd, 1, 1114,
2130 "Calendar : Error - Print To File"));
2131 pixmap = pu->xm_error_pixmap;
2135 errText = XtNewString(catgets(c->DT_catd, 1, 1117,
2136 "Print to file has completed."));
2137 title = XtNewString(catgets(c->DT_catd, 1, 1116,
2138 "Calendar : Print To File"));
2139 pixmap = pu->xm_info_pixmap;
2142 dialog_popup(c->frame,
2143 DIALOG_TITLE, title,
2144 DIALOG_TEXT, errText,
2145 BUTTON_IDENT, 1, label,
2146 DIALOG_IMAGE, pixmap,
2155 showBadAllocError(Calendar *c)
2157 Props_pu *pu = (Props_pu *)c->properties_pu;
2163 label = XtNewString(catgets(c->DT_catd, 1, 95, "Continue"));
2164 errText = XtNewString(catgets(c->DT_catd, 1, 1122,
2165 "Print job failed.\n\n\
2166 The X Print Server is temporarily out of resources."));
2167 title = XtNewString(catgets(c->DT_catd, 1, 1121,
2168 "Calendar : Print Server Error"));
2169 pixmap = pu->xm_error_pixmap;
2171 dialog_popup(c->frame,
2172 DIALOG_TITLE, title,
2173 DIALOG_TEXT, errText,
2174 BUTTON_IDENT, 1, label,
2175 DIALOG_IMAGE, pixmap,
2184 x_open_file(Calendar *c)
2186 CMGraphicsInfo *gInfo;
2192 unsigned int gcMask = GCFont | GCForeground | GCBackground |
2193 GCTile | GCFillStyle | GCLineWidth;
2195 WidgetList shellChildren;
2196 #ifdef SHELL_SIZE_BUG
2197 Dimension shellWd = 0, shellHt = 0;
2198 #endif /* SHELL_SIZE_BUG */
2200 static Boolean getResources = True;
2201 _Xltimeparams localtime_buf;
2205 XtGetApplicationResources(c->frame, (XtPointer)&dvFonts,
2206 dvDefaultResources, XtNumber(dvDefaultResources),
2208 XtGetApplicationResources(c->frame, (XtPointer)&wvFonts,
2209 wvDefaultResources, XtNumber(wvDefaultResources),
2211 XtGetApplicationResources(c->frame, (XtPointer)&mvFonts,
2212 mvDefaultResources, XtNumber(mvDefaultResources),
2214 XtGetApplicationResources(c->frame, (XtPointer)&yvFonts,
2215 yvDefaultResources, XtNumber(yvDefaultResources),
2217 XtGetApplicationResources(c->frame, (XtPointer)&avFonts,
2218 avDefaultResources, XtNumber(avDefaultResources),
2220 XtGetApplicationResources(c->frame, (XtPointer)&tvFonts,
2221 tvDefaultResources, XtNumber(tvDefaultResources),
2223 getResources = False;
2226 if ((printShell = pd_get_print_shell(c)) == (Widget)NULL)
2227 return (void *)NULL;
2229 if ((gInfo = (CMGraphicsInfo *)XtMalloc(sizeof(CMGraphicsInfo)))
2230 == (CMGraphicsInfo *)NULL)
2231 return (void *)NULL;
2234 XtGetApplicationResources(printShell, (XtPointer)&printResources,
2235 displayResources, XtNumber(displayResources),
2239 #if 0 && defined(PRINTING_SUPPORTED)
2242 if (!inDebugMode(c))
2245 if (pd_print_to_file(c))
2247 char *fileName = pd_get_file_name(c);
2249 /* Protocol says XpStartJob() MUST be called before XmPrintToFile() */
2250 XpStartJob(XtDisplay(printShell), XPGetData);
2252 XFlush(XtDisplay(printShell));
2254 if (!XmPrintToFile(XtDisplay(printShell), fileName,
2255 filePrintDoneCB, (XtPointer)c))
2257 XpCancelJob(XtDisplay(printShell), False);
2260 XtFree((char *)gInfo);
2262 filePrintReportStatus(c, False);
2264 return (void *)NULL;
2270 XpStartJob(XtDisplay(printShell), XPSpool);
2275 #endif /* PRINTING_SUPPORTED */
2279 #ifdef SHELL_SIZE_BUG
2280 XtSetArg(args[nargs], XmNwidth, &shellWd); nargs++;
2281 XtSetArg(args[nargs], XmNheight, &shellHt); nargs++;
2282 #endif /* SHELL_SIZE_BUG */
2283 XtSetArg(args[nargs], XmNchildren, &shellChildren); nargs++;
2284 XtSetArg(args[nargs], XmNnumChildren, &nChildren); nargs++;
2285 XtGetValues(printShell, args, nargs);
2287 #ifdef SHELL_SIZE_BUG
2288 if ((shellWd < 10) || (shellHt < 10))
2290 shellWd = XmConvertUnits(printShell, XmHORIZONTAL, Xm1000TH_INCHES,
2291 PAGE_WIDTH, XmPIXELS);
2292 shellHt = XmConvertUnits(printShell, XmVERTICAL, Xm1000TH_INCHES,
2293 PAGE_HEIGHT, XmPIXELS);
2296 XtSetArg(args[nargs], XmNwidth, shellWd); nargs++;
2297 XtSetArg(args[nargs], XmNheight, shellHt); nargs++;
2298 XtSetValues(printShell, args, nargs);
2300 #endif /* SHELL_SIZE_BUG */
2305 XtSetArg(args[nargs], XmNunitType, XmPIXELS); nargs++;
2307 if (!inDebugMode(c))
2310 XtSetArg(args[nargs], XmNbackground,
2311 WhitePixelOfScreen(XtScreen(printShell))); nargs++;
2315 drawingArea = XmCreateDrawingArea(printShell, "PrintArea",
2319 drawingArea = shellChildren[0];
2323 XtAddCallback(drawingArea, XmNinputCallback,
2324 tmpFn, (XtPointer)NULL);
2327 gInfo->drawingArea = drawingArea;
2328 gInfo->gc = XtAllocateGC(drawingArea, 0, 0, NULL, gcMask, 0);
2330 gInfo->reportType = PR_MONTH_VIEW; /* Set properly in x_init_*() */
2332 gInfo->fontInfo = gInfo->curFont = (CMFontInfo *)NULL;
2335 gInfo->reverseVideo = False;
2336 gInfo->fg = BlackPixelOfScreen(XtScreen(drawingArea));
2337 gInfo->bg = WhitePixelOfScreen(XtScreen(drawingArea));
2340 XtSetArg(args[nargs], XmNforeground, &(gInfo->fg)); nargs++;
2341 XtSetArg(args[nargs], XmNbackground, &(gInfo->bg)); nargs++;
2342 XtGetValues(drawingArea, args, nargs);
2344 gInfo->lightPixmap = None;
2345 gInfo->darkPixmap = None;
2347 /* set up time stamp */
2348 /* STRING_EXTRACTION SUNW_DESKSET_CM_MSG
2349 * The following string is the date/time format used in printing out
2350 * calendar views. This is the locale's date and time. If this string
2351 * is to be translated, please refer to the man pages for strftime()
2352 * for various format strings.
2355 tm = _XLocaltime(&t, localtime_buf);
2356 strftime(gInfo->timestamp, BUFFERSIZE, "%x %I:%M %p", tm);
2360 unsigned long to_len = 0;
2363 _len = strlen( gInfo->timestamp );
2364 _converter_( gInfo->timestamp, _len, &to, &to_len );
2365 if ( ( to != NULL ) && ( to_len != 0 ) )
2366 strncpy( gInfo->timestamp, to,
2367 ( BUFFERSIZE > to_len ) ? to_len : BUFFERSIZE - 1 );
2370 return (void *)gInfo;
2374 x_print_file(void *gInfoP, Calendar *c)
2376 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2377 Display *dsp = XtDisplay(gInfo->drawingArea);
2380 if (!inDebugMode(c))
2383 #if 0 && defined(PRINTING_SUPPORTED)
2385 #endif /* PRINTING_SUPPORTED */
2387 /* Make sure we know about a BadAlloc if it happens. */
2388 XSync(XtDisplay(gInfo->drawingArea), FALSE);
2391 if (pd_get_bad_alloc_error(c) &&
2392 (!pd_print_to_file(c)))
2394 showBadAllocError(c);
2395 pd_set_bad_alloc_error(c, False);
2398 if (gInfo->lightPixmap != None)
2399 XFreePixmap(dsp, gInfo->lightPixmap);
2400 if (gInfo->darkPixmap != None)
2401 XFreePixmap(dsp, gInfo->darkPixmap);
2403 XtReleaseGC(gInfo->drawingArea, gInfo->gc);
2405 cm_release_fonts(gInfo);
2407 XtFree((char *)gInfo);
2411 x_init_printer(void *gInfoP, short orientation)
2413 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2414 Widget w = gInfo->drawingArea;
2417 unsigned int pageWd, pageHt;
2419 int rMargin, bMargin;
2421 Dimension daWd, daHt;
2423 #if 0 && defined(PRINTING_SUPPORTED)
2425 if (inDebugMode(gInfo->c))
2427 XtAddCallback(w, XmNexposeCallback,
2428 tmpFn, (XtPointer)NULL);
2432 XpStartPage(XtDisplay(w), XtWindow(XtParent(w)));
2433 #endif /* PRINTING_SUPPORTED */
2435 /* XpStartPage() sets the shell width/height correctly. */
2437 XtSetArg(args[nargs], XmNwidth, &daWd); nargs++;
2438 XtSetArg(args[nargs], XmNheight, &daHt); nargs++;
2439 XtGetValues(XtParent(w), args, nargs);
2441 if (XtIsRealized(w))
2443 XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0,
2445 inDebugMode(gInfo->c)
2454 XtSetArg(args[nargs], XmNwidth, daWd); nargs++;
2455 XtSetArg(args[nargs], XmNheight, daHt); nargs++;
2456 XtSetValues(w, args, nargs);
2461 if (inDebugMode(gInfo->c))
2465 XtRemoveCallback(w, XmNexposeCallback,
2466 tmpFn, (XtPointer)NULL);
2468 /* Now that window is displayed, get its actual size, */
2469 /* since the Window Manager may have modified it. */
2471 XtSetArg(args[nargs], XmNwidth, &daWd); nargs++;
2472 XtSetArg(args[nargs], XmNheight, &daHt); nargs++;
2473 XtGetValues(XtParent(w), args, nargs);
2477 /* Get margins from properties. */
2478 inchWd = XmConvertUnits(w, XmHORIZONTAL, Xm1000TH_INCHES,
2480 gInfo->leftMarginX = cm_cvt_margin(gInfo, CP_PRINTLMARGIN, inchWd);
2481 gInfo->topMarginY = cm_cvt_margin(gInfo, CP_PRINTTMARGIN, inchWd);
2482 rMargin = cm_cvt_margin(gInfo, CP_PRINTRMARGIN, inchWd);
2483 bMargin = cm_cvt_margin(gInfo, CP_PRINTBMARGIN, inchWd);
2485 gInfo->rightMarginX = daWd - rMargin;
2486 gInfo->bottomMarginY = daHt - bMargin;
2488 pageWd = XmConvertUnits(w, XmHORIZONTAL, XmPIXELS,
2489 daWd, Xm1000TH_INCHES);
2490 pageHt = XmConvertUnits(w, XmVERTICAL, XmPIXELS,
2491 daHt, Xm1000TH_INCHES);
2492 if (orientation == PORTRAIT)
2494 baseWd = PAGE_WIDTH;
2495 baseHt = PAGE_HEIGHT;
2499 baseWd = PAGE_HEIGHT;
2500 baseHt = PAGE_WIDTH;
2503 gInfo->hscale = (double)pageWd / (double)baseWd;
2504 gInfo->vscale = (double)pageHt / (double)baseHt;
2506 /* Scaled line widths: .25pt, 1pt, 2pt. */
2507 gInfo->thinWd = XmConvertUnits(w, XmHORIZONTAL, Xm100TH_POINTS,
2509 if (gInfo->thinWd < 1)
2511 gInfo->normalWd = XmConvertUnits(w, XmHORIZONTAL, Xm100TH_POINTS,
2513 if (gInfo->normalWd < 1)
2514 gInfo->normalWd = 1;
2515 gInfo->thickWd = XmConvertUnits(w, XmHORIZONTAL, Xm100TH_POINTS,
2517 if (gInfo->thickWd < 1)
2522 x_init_day(void *gInfoP, int timeslots)
2524 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2527 gInfo->reportType = PR_DAY_VIEW;
2529 /* Load day fonts */
2530 if (gInfo->nFonts == 0)
2534 for (i = 0; i < DV_NUM_FONTS; i++)
2535 cm_load_font(gInfo, i, dvFonts[i]);
2537 /* Set curFont to first loaded font. */
2538 gInfo->curFont = gInfo->fontInfo;
2541 cm_adjust_margins(gInfo);
2543 fInfo = cm_find_font(gInfo, DV_TIME_FONT);
2544 gInfo->u.dayInfo.tab1 = (cm_font_height(gInfo, fInfo) * 2) + gInfo->normalWd;
2546 gInfo->u.dayInfo.curX1 = gInfo->leftMarginX + (gInfo->normalWd / 2);
2547 gInfo->u.dayInfo.curX2 = (gInfo->leftMarginX + gInfo->rightMarginX) / 2;
2548 fInfo = cm_find_font(gInfo, DV_HEADER_FONT);
2549 gInfo->u.dayInfo.curY1 =
2550 gInfo->topMarginY + (gInfo->normalWd / 2) + cm_font_height(gInfo, fInfo) +
2551 VMARGIN(gInfo) + gInfo->u.dayInfo.tab1;
2552 gInfo->u.dayInfo.curY2 = gInfo->u.dayInfo.curY1;
2554 gInfo->u.dayInfo.boxHt =
2555 (gInfo->bottomMarginY - ((gInfo->normalWd + 1) / 2) -
2556 gInfo->u.dayInfo.curY1) / timeslots;
2557 gInfo->u.dayInfo.boxWd =
2558 gInfo->u.dayInfo.curX2 - gInfo->u.dayInfo.curX1;
2560 gInfo->u.dayInfo.line1 = 0;
2564 x_get_day_lines_per_page(void *gInfoP)
2566 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2567 CMFontInfo *fInfo = cm_find_font(gInfo, DV_APPT_FONT);
2569 return (gInfo->u.dayInfo.boxHt - gInfo->normalWd - (2 * VMARGIN(gInfo))) /
2570 cm_font_height(gInfo, fInfo);
2574 x_get_week_lines_per_page(void *gInfoP)
2576 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2577 CMFontInfo *fInfo = cm_find_font(gInfo, DV_APPT_FONT);
2579 return (gInfo->u.weekInfo.boxHt - gInfo->u.weekInfo.tab1 -
2580 ((gInfo->normalWd + 1) / 2) -
2581 (gInfo->thickWd / 2) - (2 * VMARGIN(gInfo))) /
2582 cm_font_height(gInfo, fInfo);
2586 x_print_header(void *gInfoP, char *buf, int pageNum, int numPages)
2588 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2589 Calendar *c = gInfo->c;
2591 char str2[BUFFERSIZE];
2592 char pageStr[BUFFERSIZE];
2595 char *reportTypeStr;
2597 /* --- print header info at top --- */
2598 if (buf != (char *)NULL)
2600 cm_set_font(gInfo, cm_get_title_enum(gInfo));
2603 unsigned long to_len = 0;
2606 _len = strlen( buf );
2607 _converter_( buf, _len, &to, &to_len );
2608 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2609 str = euc_to_octal(to);
2611 str = euc_to_octal(buf);
2614 x_print_string(gInfo, str,
2615 (gInfo->rightMarginX + gInfo->leftMarginX) / 2,
2617 CENTER_AT_X | BOTTOM_AT_Y);
2620 /* Get header/footer strings ready. */
2621 timeStamp = gInfo->timestamp;
2622 userId = c->view->current_calendar;
2623 reportTypeStr = get_report_type_string(gInfo);
2628 /* print creation notice at bottom */
2629 cm_strcpy(str2, catgets(c->DT_catd, 1, 468, "Page"));
2632 unsigned long to_len = 0;
2635 _len = strlen( str2 );
2636 _converter_( str2, _len, &to, &to_len );
2637 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2639 ( BUFFERSIZE > to_len ) ? to_len : BUFFERSIZE );
2642 cm_strcpy(str2, euc_to_octal(str2));
2644 str = catgets(c->DT_catd, 1, 476, "of");
2647 unsigned long to_len = 0;
2650 _len = strlen( str );
2651 _converter_( str, _len, &to, &to_len );
2652 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2657 sprintf(pageStr, "%s %d %s %d", str2, pageNum, str, numPages);
2659 /* Header/footer strings are all set - print 'em! */
2660 cm_print_header_string(gInfo, CP_PRINTLHEADER,
2661 timeStamp, userId, pageStr, reportTypeStr);
2662 cm_print_header_string(gInfo, CP_PRINTRHEADER,
2663 timeStamp, userId, pageStr, reportTypeStr);
2664 cm_print_header_string(gInfo, CP_PRINTLFOOTER,
2665 timeStamp, userId, pageStr, reportTypeStr);
2666 cm_print_header_string(gInfo, CP_PRINTRFOOTER,
2667 timeStamp, userId, pageStr, reportTypeStr);
2671 x_day_header (void *gInfoP)
2673 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2676 Calendar *c = gInfo->c;
2680 fInfo = cm_find_font(gInfo, DV_HEADER_FONT);
2681 dayBoxVOffset = (gInfo->normalWd / 2) +
2682 cm_font_height(gInfo, fInfo) + VMARGIN(gInfo);
2684 /* --- print Morning/Afternoon boxes --- */
2685 cm_set_font(gInfo, DV_TIME_FONT);
2687 x_fill_light_box(gInfo, gInfo->u.dayInfo.curX1,
2688 gInfo->topMarginY + dayBoxVOffset,
2689 gInfo->rightMarginX - ((gInfo->normalWd + 1) / 2),
2690 gInfo->topMarginY + dayBoxVOffset + gInfo->u.dayInfo.tab1,
2693 x_fill_dark_box(gInfo, gInfo->u.dayInfo.curX1,
2694 gInfo->topMarginY + dayBoxVOffset,
2695 gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1,
2696 gInfo->topMarginY + dayBoxVOffset + gInfo->u.dayInfo.tab1,
2699 midX = gInfo->u.dayInfo.curX2;
2700 x_fill_dark_box(gInfo, midX,
2701 gInfo->topMarginY + dayBoxVOffset,
2702 midX + gInfo->u.dayInfo.tab1,
2703 gInfo->topMarginY + dayBoxVOffset + gInfo->u.dayInfo.tab1,
2706 str = catgets(c->DT_catd, 1, 470, "Morning");
2710 unsigned long to_len = 0;
2713 _len = strlen( str );
2714 _converter_( str, _len, &to, &to_len );
2715 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2720 x_print_string(gInfo, str,
2721 (gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1 + midX) / 2,
2722 gInfo->topMarginY + dayBoxVOffset +
2723 (gInfo->u.dayInfo.tab1 / 2),
2724 CENTER_AT_X | CENTER_AT_Y);
2726 str = catgets(c->DT_catd, 1, 471, "Afternoon");
2730 unsigned long to_len = 0;
2733 _len = strlen( str );
2734 _converter_( str, _len, &to, &to_len );
2735 if ( ( to != NULL ) && ( to_len != 0 ) ) {
2740 str = euc_to_octal(str);
2741 x_print_string(gInfo, str,
2742 (midX + gInfo->u.dayInfo.tab1 + gInfo->rightMarginX
2743 - ((gInfo->normalWd + 1) / 2)) / 2,
2744 gInfo->topMarginY + dayBoxVOffset +
2745 (gInfo->u.dayInfo.tab1 / 2),
2746 CENTER_AT_X | CENTER_AT_Y);
2750 x_day_timeslots(void *gInfoP, int i, Boolean more)
2752 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2756 Calendar *c = gInfo->c;
2758 sprintf (hourbuf, "%d", (morning(i) || (i == 12)) ? i : (i - 12) );
2759 sprintf (modbuf, "%s", morning(i) ? catgets(c->DT_catd, 1, 4, "am") :
2760 catgets(c->DT_catd, 1, 3, "pm"));
2762 /* --- print hourly boxes for appt entries --- */
2765 gInfo->u.dayInfo.curX1 = gInfo->u.dayInfo.curX2;
2766 gInfo->u.dayInfo.curY1 = gInfo->u.dayInfo.curY2;
2768 /* boxWd may be off by a pixel - set here to ensure correctness. */
2769 gInfo->u.dayInfo.boxWd =
2770 gInfo->rightMarginX - ((gInfo->normalWd + 1) / 2) -
2771 gInfo->u.dayInfo.curX1;
2774 x_draw_box(gInfo, gInfo->u.dayInfo.curX1, gInfo->u.dayInfo.curY1,
2775 gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.boxWd,
2776 gInfo->u.dayInfo.curY1 + gInfo->u.dayInfo.boxHt,
2778 x_fill_light_box(gInfo, gInfo->u.dayInfo.curX1,
2779 gInfo->u.dayInfo.curY1,
2780 gInfo->u.dayInfo.curX1 + gInfo->u.dayInfo.tab1,
2781 gInfo->u.dayInfo.curY1 + gInfo->u.dayInfo.boxHt,
2784 cm_set_font(gInfo, DV_TIME_FONT);
2786 x_print_string(gInfo, hourbuf,
2787 gInfo->u.dayInfo.curX1 + (gInfo->u.dayInfo.tab1 / 2),
2788 gInfo->u.dayInfo.curY1 + (gInfo->u.dayInfo.boxHt / 2) -
2789 (VMARGIN(gInfo) / 2),
2790 CENTER_AT_X | BOTTOM_AT_Y);
2792 x_print_string(gInfo, modbuf,
2793 gInfo->u.dayInfo.curX1 + (gInfo->u.dayInfo.tab1 / 2),
2794 gInfo->u.dayInfo.curY1 + (gInfo->u.dayInfo.boxHt / 2) +
2795 (VMARGIN(gInfo) / 2),
2796 CENTER_AT_X | TOP_AT_Y);
2799 x_print_string(gInfo, "*",
2800 gInfo->u.dayInfo.curX1 + (gInfo->u.dayInfo.tab1 / 2),
2801 gInfo->u.dayInfo.curY1 + (gInfo->u.dayInfo.boxHt / 2) +
2802 cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo),
2803 CENTER_AT_X | TOP_AT_Y);
2805 gInfo->u.dayInfo.line1 = gInfo->u.dayInfo.curY1 +
2806 ((gInfo->normalWd + 1) / 2) + VMARGIN(gInfo);
2807 gInfo->u.dayInfo.curY1 += gInfo->u.dayInfo.boxHt;
2811 x_print_multi_appts(void *gInfoP,
2812 CSA_entry_handle *list,
2818 * This routine is used to print appointments for day and week
2819 * views. The parm "view" is used to differentiate
2820 * who is printing, and personalize the print for that view.
2823 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2824 int indented, indentAmt, multlines=TRUE;
2826 char buf1[128], buf2[257];
2827 Calendar *c = gInfo->c;
2828 Props *pr = (Props*)c->properties;
2829 int meoval = get_int_prop(pr, CP_PRINTPRIVACY);
2830 int dt = get_int_prop(pr, CP_DEFAULTDISP);
2831 int i, j, start, maxlines, pos = 1, line_counter = 0;
2832 Boolean new_appt = FALSE;
2833 CSA_return_code stat;
2834 Dtcm_appointment *appt;
2836 if (view == weekGlance)
2837 maxlines = x_get_week_lines_per_page(gInfoP);
2838 else if (view == dayGlance)
2839 maxlines = x_get_day_lines_per_page(gInfoP);
2842 start = ((num_page - 1) * maxlines) + 1;
2844 appt = allocate_appt_struct(appt_read,
2845 c->general->version,
2846 CSA_ENTRY_ATTR_CLASSIFICATION_I,
2847 CSA_ENTRY_ATTR_START_DATE_I,
2848 CSA_ENTRY_ATTR_SUMMARY_I,
2849 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
2850 CSA_ENTRY_ATTR_END_DATE_I,
2852 for (j = 0; j < a_total; j++) {
2853 stat = query_appt_struct(c->cal_handle, list[j], appt);
2854 if (stat != CSA_SUCCESS) {
2855 free_appt_struct(&appt);
2859 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) && !(meoval & PRINT_PUBLIC))
2861 if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
2862 !(meoval & PRINT_SEMIPRIVATE))
2864 if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
2865 !(meoval & PRINT_PRIVATE))
2868 lp = lines = text_to_lines(appt->what->value->item.string_value,
2869 multlines ? 10 : 1);
2872 /* skip past lines already printed */
2874 if (showtime_set(appt)) {
2876 for (i = 1; i <= num_page; i++)
2877 if (pos == (maxlines * i))
2881 while ((lines != NULL) && (pos < start)) {
2884 lines = lines->next;
2891 /* skip last line if it's a time */
2892 if (showtime_set(appt)) {
2893 if (line_counter == (maxlines - 1)) {
2894 free_appt_struct(&appt);
2899 /* HH:MM xm - HH:MM xm format */
2900 format_line2(appt, buf1, buf2, dt);
2902 indented = (*buf1 != '\0');
2903 indentAmt = (view == dayGlance) ? 0 : 1;
2907 /* only print if appt text found */
2908 if (lines != NULL && lines->s != NULL) {
2909 if ((indented) && (new_appt)) {
2911 if ((line_counter > maxlines) && (lines != NULL)) {
2912 free_appt_struct(&appt);
2916 cm_print_time (gInfo, buf1, view);
2919 cm_print_appt_text (gInfo, lines->s, indentAmt, view);
2921 if ((line_counter > maxlines) && (lines != NULL)) {
2922 free_appt_struct(&appt);
2926 lines = lines->next;
2927 while (lines != NULL) {
2929 if ((line_counter > maxlines) && (lines != NULL)) {
2930 free_appt_struct(&appt);
2934 cm_print_appt_text (gInfo, lines->s, indentAmt, view);
2935 lines = lines->next;
2939 if (view == weekGlance)
2940 cm_week_sched_update(gInfo, appt, pr);
2943 free_appt_struct(&appt);
2948 x_finish_printer(void *gInfoP)
2950 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
2951 Widget w = gInfo->drawingArea;
2954 if (inDebugMode(gInfo->c))
2958 #if 0 && defined(PRINTING_SUPPORTED)
2959 XpEndPage(XtDisplay(w));
2960 #endif /* PRINTING_SUPPORTED */
2964 x_print_list_range(Calendar *c, CSA_sint32 appt_type, int item_data,
2965 Tick start_tick, Tick end_tick)
2967 char buf[MAXNAMELEN], buf2[MAXNAMELEN];
2969 Props *p = (Props *)c->properties;
2971 todo_view_op todo_view = VIEW_ALL;
2972 OrderingType ot = get_int_prop(p, CP_DATEORDERING);
2974 CSA_return_code stat;
2975 CSA_entry_handle *list;
2976 CSA_attribute *range_attrs;
2977 CSA_enum *ops = NULL;
2981 if ((xp = x_open_file(c)) == (void *)NULL)
2984 if (appt_type == CSA_TYPE_TODO) {
2985 todo_view = (todo_view_op)item_data;
2986 glance = c->view->glance;
2988 glance = (Glance)item_data;
2990 x_init_printer(xp, PORTRAIT);
2993 memset(buf, '\0', MAXNAMELEN);
2994 memset(buf2, '\0', MAXNAMELEN);
2996 start = lowerbound(start_tick);
2997 end = nextday(end_tick) - 1;
2999 format_date(start + 1, ot, buf2, 1, 0, 0);
3001 if (appt_type == CSA_TYPE_TODO)
3002 sprintf(buf, catgets(c->DT_catd, 1, 899,
3003 "To Do List Beginning: %s"), buf2);
3005 sprintf(buf, catgets(c->DT_catd, 1, 900,
3006 "Appt List Beginning: %s"), buf2);
3008 setup_range(&range_attrs, &ops, &i, start, end, appt_type,
3009 0, B_FALSE, c->general->version);
3010 stat = csa_list_entries(c->cal_handle, i, range_attrs,
3011 ops, &a_total, &list, NULL);
3013 if (stat != CSA_SUCCESS) {
3017 x_print_todo(xp, list, a_total, appt_type,
3018 (start_tick != end_tick), todo_view, end, buf);
3022 x_finish_printer(xp);
3023 x_print_file(xp, c);
3027 x_init_list(void *gInfoP)
3029 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3034 /* We can ONLY get here printing via dialog - printData is valid. */
3035 gInfo->reportType = pd_get_report_type(gInfo->c);
3037 /* Load list fonts */
3038 if (gInfo->nFonts == 0)
3042 if (gInfo->reportType == PR_APPT_LIST)
3044 for (i = 0; i < AV_NUM_FONTS; i++)
3045 cm_load_font(gInfo, i, avFonts[i]);
3049 for (i = 0; i < TV_NUM_FONTS; i++)
3050 cm_load_font(gInfo, i, tvFonts[i]);
3053 /* Set curFont to first loaded font. */
3054 gInfo->curFont = gInfo->fontInfo;
3057 cm_adjust_margins(gInfo);
3059 cm_set_font(gInfo, cm_get_header_enum(gInfo));
3061 hIndent = TODO_HINDENT * gInfo->hscale * gInfo->normalWd;
3062 vIndent = TODO_VINDENT * gInfo->vscale * gInfo->normalWd;
3063 gInfo->u.toDoInfo.outerX1 = gInfo->leftMarginX + (gInfo->thickWd / 2);
3064 gInfo->u.toDoInfo.outerY1 = gInfo->topMarginY + (gInfo->thickWd / 2) +
3065 cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo);
3066 gInfo->u.toDoInfo.innerX1 = gInfo->u.toDoInfo.outerX1 + hIndent;
3067 gInfo->u.toDoInfo.innerY1 = gInfo->u.toDoInfo.outerY1 + vIndent;
3068 gInfo->u.toDoInfo.outerX2 =
3069 gInfo->rightMarginX - ((gInfo->thickWd + 1) / 2);
3070 gInfo->u.toDoInfo.outerY2 =
3071 gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2);
3072 gInfo->u.toDoInfo.boxX2 = gInfo->u.toDoInfo.outerX2 - hIndent;
3073 gInfo->u.toDoInfo.boxY2 = gInfo->u.toDoInfo.outerY2 - vIndent;
3074 gInfo->u.toDoInfo.boxX1 = gInfo->u.toDoInfo.innerX1;
3075 gInfo->u.toDoInfo.boxY1 = gInfo->u.toDoInfo.boxY2 -
3076 cm_tiny_month_height(gInfo, VMARGIN(gInfo)) - gInfo->thickWd;
3077 gInfo->u.toDoInfo.innerX2 = gInfo->u.toDoInfo.boxX2;
3078 gInfo->u.toDoInfo.innerY2 = gInfo->u.toDoInfo.boxY1 - vIndent;
3080 gInfo->u.toDoInfo.lineX =
3081 gInfo->u.toDoInfo.innerX1 + ((gInfo->thickWd + 1) / 2) + HMARGIN(gInfo);
3082 gInfo->u.toDoInfo.lineY =
3083 gInfo->u.toDoInfo.innerY1 + ((gInfo->thickWd + 1) / 2) + VMARGIN(gInfo);
3087 x_print_todo(void *gInfoP, CSA_entry_handle *list, int a_total,
3088 CSA_sint32 appt_type, Boolean showDate, int vf,
3089 time_t end_time, char *buf)
3091 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3092 int i, items_per_page = 0, meoval;
3093 char buf3[BUFFERSIZE], buf2[BUFFERSIZE], buf1[BUFFERSIZE];
3094 int total_items = 0;
3095 boolean_t skip_appt;
3096 CSA_return_code stat;
3097 Dtcm_appointment *appt;
3098 Calendar *c = gInfo->c;
3099 Props *p = (Props*)c->properties;
3100 DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);
3101 OrderingType ot = get_int_prop(p, CP_DATEORDERING);
3102 SeparatorType st = get_int_prop(p, CP_DATESEPARATOR);
3104 int linesFullPage, linesPartialPage;
3105 int numAppts, numPages, curPage;
3108 cm_get_todo_lines_per_page(gInfo, appt_type, &linesFullPage,
3110 numAppts = cm_count_appts(gInfo, list, a_total, appt_type, vf);
3111 for (numPages = 1, numAppts -= linesPartialPage;
3114 numAppts -= linesFullPage;
3115 x_print_header(gInfoP, buf, curPage, numPages);
3116 cm_todo_outline(gInfo, curPage == numPages);
3117 cm_set_todo_text_clipping(gInfo);
3119 meoval = get_int_prop(p, CP_PRINTPRIVACY);
3120 buf1[0] = buf2[0] = buf3[0] = '\0';
3122 appt = allocate_appt_struct(appt_read,
3123 c->general->version,
3124 CSA_ENTRY_ATTR_CLASSIFICATION_I,
3125 CSA_ENTRY_ATTR_TYPE_I,
3126 CSA_ENTRY_ATTR_STATUS_I,
3127 CSA_ENTRY_ATTR_START_DATE_I,
3128 CSA_ENTRY_ATTR_SUMMARY_I,
3129 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
3130 CSA_ENTRY_ATTR_END_DATE_I,
3132 for (i = 0; i < a_total; i++)
3134 stat = query_appt_struct(c->cal_handle, list[i], appt);
3135 if (stat != CSA_SUCCESS)
3137 free_appt_struct(&appt);
3140 skip_appt = B_FALSE;
3142 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
3143 !(meoval & PRINT_PUBLIC))
3145 else if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
3146 !(meoval & PRINT_SEMIPRIVATE))
3148 else if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
3149 !(meoval & PRINT_PRIVATE))
3152 if ((appt_type == CSA_TYPE_TODO) &&
3153 ((appt->type->value->item.sint32_value != CSA_TYPE_TODO)
3155 ((vf == VIEW_PENDING) &&
3156 (appt->state->value->item.sint32_value ==
3157 CSA_STATUS_COMPLETED)) ||
3158 ((vf == VIEW_COMPLETED) &&
3159 (appt->state->value->item.sint32_value ==
3160 CSA_X_DT_STATUS_ACTIVE))))
3163 if ((appt_type == CSA_TYPE_EVENT) &&
3164 (appt->type->value->item.sint32_value != CSA_TYPE_EVENT))
3170 format_maxchars(appt, buf1, BUFFERSIZE - 5, dt);
3173 _csa_iso8601_to_tick(appt->time->value->item.date_time_value,
3175 format_date3(start_tick, ot, st, buf2);
3176 sprintf(buf3, "%s %s", buf2, buf1);
3178 cm_strcpy(buf3, buf1);
3181 cm_print_todo_text (gInfo, buf3,
3182 appt->state->value->item.sint32_value,
3183 appt_type, total_items);
3184 if ((++items_per_page % linesFullPage) == 0)
3186 cm_unset_todo_text_clipping(gInfo);
3187 x_finish_printer(gInfoP);
3188 x_init_printer(gInfoP, PORTRAIT);
3189 x_init_list(gInfoP);
3190 x_print_header(gInfoP, buf, ++curPage, numPages);
3191 cm_todo_outline(gInfo, curPage == numPages);
3192 cm_set_todo_text_clipping(gInfo);
3195 } /* end for stmt */
3197 free_appt_struct(&appt);
3198 cm_unset_todo_text_clipping(gInfo);
3200 if (items_per_page > linesPartialPage) {
3201 x_finish_printer(gInfoP);
3202 x_init_printer(gInfoP, PORTRAIT);
3203 x_init_list(gInfoP);
3204 x_print_header(gInfoP, buf, ++curPage, numPages);
3205 cm_todo_outline(gInfo, curPage == numPages);
3208 cm_print_todo_months(gInfo, end_time);
3212 x_print_month(void *gInfoP, int mon, int yr, int x1,
3213 int y1, int x2, int y2, int spacing)
3215 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3217 Tick j = monthdayyear(mon, 1, yr); /* starting date Jan 1, y */
3218 int i, colWd, dateWd, monLen;
3219 char str[BUFFERSIZE];
3222 mon = (mon % 13) + 1;
3226 x_set_clip_box(gInfo, x1, y1, x2, y2);
3228 cm_set_font(gInfo, cm_get_tiny_title_enum(gInfo));
3231 cm_strcpy(str, months[mon]);
3235 unsigned long to_len = 0;
3239 _converter_( str, _len, &to, &to_len );
3240 if ( ( to != NULL ) && ( to_len != 0 ) ) {
3245 cm_strcpy(str, euc_to_octal(str));
3246 x_fill_light_box(gInfo, x1 + HMARGIN(gInfo), y1,
3247 x2 - HMARGIN(gInfo),
3248 y1 + cm_font_height(gInfo, gInfo->curFont),
3250 x_print_string(gInfo, str,
3252 CENTER_AT_X | TOP_AT_Y);
3253 y1 += spacing + cm_font_height(gInfo, gInfo->curFont);
3255 fInfo = cm_find_font(gInfo, cm_get_tiny_date_enum(gInfo));
3256 monLen = monthlength(j);
3258 for (i = 0; i < monLen; i++)
3260 sprintf(str, "%d", i + 1);
3261 if ((dateWd = cm_string_width(gInfo, fInfo, str)) > colWd)
3265 cm_std_month_weekdays(gInfo, colWd, x1, y1, x2);
3266 y1 += spacing + cm_font_height(gInfo, gInfo->curFont);
3268 cm_std_month_dates(gInfo, fdom(j), monLen, colWd,
3269 x1, y1, x2, spacing);
3271 x_unset_clip_box(gInfo);
3275 x_init_std_year(void *gInfoP)
3277 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3280 gInfo->reportType = PR_YEAR_VIEW;
3282 /* Load year fonts */
3283 if (gInfo->nFonts == 0)
3287 for (i = 0; i < YV_NUM_FONTS; i++)
3288 cm_load_font(gInfo, i, yvFonts[i]);
3290 /* Set curFont to first loaded font. */
3291 gInfo->curFont = gInfo->fontInfo;
3294 cm_adjust_margins(gInfo);
3298 x_std_year_name(void *gInfoP, int yr)
3300 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3301 char yearBuf[BUFFERSIZE];
3303 /* --- print year centered at top --- */
3304 sprintf(yearBuf, "%d", yr);
3305 x_print_header(gInfoP, yearBuf, 1, 1);
3309 x_print_year(void *gInfoP, int yr)
3311 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3322 fInfo = cm_find_font(gInfo, YV_HEADER_FONT);
3323 monthHt = cm_tiny_month_height(gInfo, VMARGIN(gInfo));
3325 leftX = gInfo->leftMarginX;
3326 topY = gInfo->topMarginY + cm_font_height(gInfo, fInfo) + VMARGIN(gInfo);
3328 pageWd = gInfo->rightMarginX - leftX;
3329 pageHt = gInfo->bottomMarginY - topY;
3330 extraSpace = pageHt - (4 * monthHt);
3332 for (i = 0; i < 12; i++)
3337 x1 = leftX + ((col * pageWd) / 3);
3338 x2 = leftX + (((col + 1) * pageWd) / 3);
3342 y1 = topY + (((row + 1) * extraSpace) / 5) + (row * monthHt);
3343 y2 = topY + (((row + 2) * extraSpace) / 5) + ((row + 1) * monthHt);
3347 y1 = topY + ((row * pageHt) / 4);
3348 y2 = topY + (((row + 1) * pageHt) / 4);
3351 x_print_month(gInfoP, i + 1, yr, x1, y1, x2, y2, VMARGIN(gInfo));
3356 x_init_week(void *gInfoP)
3358 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3361 gInfo->reportType = PR_WEEK_VIEW;
3363 /* Load week fonts */
3364 if (gInfo->nFonts == 0)
3368 for (i = 0; i < WV_NUM_FONTS; i++)
3369 cm_load_font(gInfo, i, wvFonts[i]);
3371 /* Set curFont to first loaded font. */
3372 gInfo->curFont = gInfo->fontInfo;
3375 cm_adjust_margins(gInfo);
3377 fInfo = cm_find_font(gInfo, WV_HEADER_FONT);
3378 gInfo->u.weekInfo.curX1 = gInfo->leftMarginX + (gInfo->thickWd / 2);
3379 gInfo->u.weekInfo.curY1 = gInfo->topMarginY + cm_font_height(gInfo, fInfo) +
3380 VMARGIN(gInfo) + (gInfo->thickWd / 2);
3381 gInfo->u.weekInfo.boxWd =
3382 gInfo->rightMarginX - gInfo->leftMarginX - gInfo->thickWd;
3383 gInfo->u.weekInfo.boxHt =
3384 (gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2) -
3385 gInfo->u.weekInfo.curY1) / 2;
3386 gInfo->u.weekInfo.curY2 =
3387 gInfo->u.weekInfo.curY1 + gInfo->u.weekInfo.boxHt;
3389 fInfo = cm_find_font(gInfo, WV_DAY_FONT);
3390 gInfo->u.weekInfo.tab1 =
3391 ((3 * cm_font_height(gInfo, fInfo)) +
3392 gInfo->thickWd + gInfo->normalWd) / 2;
3396 x_week_appt_boxes(void *gInfoP)
3398 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3400 int innerWd, innerOffset;
3403 /* Draw weekdays box. */
3404 x1 = gInfo->u.weekInfo.curX1;
3405 y1 = gInfo->u.weekInfo.curY1;
3406 x2 = x1 + gInfo->u.weekInfo.boxWd;
3407 y2 = y1 + gInfo->u.weekInfo.tab1;
3409 x_fill_light_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3411 y2 = gInfo->u.weekInfo.curY2;
3412 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->thickWd);
3414 /* Draw weekdays vertical lines. */
3415 innerWd = gInfo->u.weekInfo.boxWd - gInfo->thickWd + gInfo->normalWd;
3416 innerOffset = ((gInfo->thickWd - 1) / 2) - ((gInfo->normalWd - 1) / 2);
3417 for (i = 1; i < WEEK_DAYS; i++)
3419 x1 = gInfo->u.weekInfo.curX1 + innerOffset + ((i * innerWd) / WEEK_DAYS);
3420 x_draw_line(gInfo, x1, y1, x1, y2, gInfo->normalWd);
3423 /* Draw weekends box. */
3424 x1 = gInfo->u.weekInfo.curX1 +
3425 (((WEEK_DAYS - WEEKEND_DAYS) * gInfo->u.weekInfo.boxWd) / WEEK_DAYS);
3427 y2 = y1 + gInfo->u.weekInfo.tab1;
3428 x_fill_light_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3430 y2 = gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2);
3431 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->thickWd);
3433 /* Draw weekends vertical lines. */
3434 for (i = WEEK_DAYS - WEEKEND_DAYS + 1; i < WEEK_DAYS; i++)
3436 x1 = gInfo->u.weekInfo.curX1 + innerOffset + ((i * innerWd) / WEEK_DAYS);
3437 x_draw_line(gInfo, x1, y1, x1, y2, gInfo->normalWd);
3442 x_week_sched_boxes(void *gInfoP)
3444 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3445 char *day_of_week[DAYS_IN_WEEK];
3446 char hourBuf[BUFFERSIZE];
3447 Props *p = (Props *)gInfo->c->properties;
3448 int begin = get_int_prop(p, CP_DAYBEGIN);
3449 int end = get_int_prop(p, CP_DAYEND);
3450 DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);
3454 int boxX1, boxY1, boxX2, boxY2, boxWd, boxHt;
3457 int ulOff = gInfo->thickWd / 2;
3458 int brOff = (gInfo->thickWd - 1) / 2;
3460 /* --- print week sched boxes --- */
3462 /* figure out number of partitions in sched box */
3463 num_hours = end - begin;
3465 /* determine offset of sched box from left margin */
3466 cm_set_font(gInfo, WV_DAY_FONT);
3467 boxIndent = cm_week_sched_box_indent(gInfo);
3468 boxX1 = gInfo->u.weekInfo.curX1 + boxIndent;
3469 boxX2 = gInfo->u.weekInfo.curX1 +
3470 ((3 * gInfo->u.weekInfo.boxWd) / WEEK_DAYS) - boxIndent;
3471 boxY1 = gInfo->u.weekInfo.curY2 +
3472 (2 * cm_font_height(gInfo, gInfo->curFont)) +
3474 boxY2 = gInfo->bottomMarginY - 1 - brOff;
3476 x_draw_box(gInfo, boxX1, boxY1, boxX2, boxY2, gInfo->thickWd);
3478 boxX1 += brOff - ((gInfo->normalWd - 1) / 2);
3479 boxX2 -= ulOff - (gInfo->normalWd / 2);
3480 boxY1 += brOff - ((gInfo->thinWd - 1) / 2);
3481 boxY2 -= ulOff - (gInfo->thinWd / 2);
3482 boxWd = boxX2 - boxX1;
3483 boxHt = boxY2 - boxY1;
3485 for (i = 0; i < DAYS_IN_WEEK; i++)
3486 local_dayname(gInfo->c, &day_of_week[i], (i + 1) % DAYS_IN_WEEK);
3488 /* print abbreviated weekdays on top and draw vertical lines. */
3489 for (i = 0; i < DAYS_IN_WEEK; i++)
3491 x1 = boxX1 + ((i * boxWd) / DAYS_IN_WEEK);
3492 x2 = boxX1 + (((i + 1) * boxWd) / DAYS_IN_WEEK);
3494 x_print_string(gInfo, day_of_week[i],
3495 (x1 + x2) / 2, boxY1 -
3496 gInfo->thickWd - (2 * VMARGIN(gInfo)),
3497 CENTER_AT_X | BOTTOM_AT_Y);
3498 free(day_of_week[i]);
3500 x_draw_line(gInfo, x1, boxY1, x1, boxY2, gInfo->normalWd);
3503 /* Print hours and horizontal lines. */
3504 for (thisHour = begin, i = 0; i <= num_hours; i++, thisHour++)
3511 else if ( dt == HOUR24 )
3516 sprintf(hourBuf, "%d", thisHour);
3517 y1 = boxY1 + ((i * boxHt) / num_hours);
3519 x_print_string(gInfo, hourBuf,
3520 boxX1 - gInfo->thickWd - HMARGIN(gInfo), y1,
3521 RIGHT_AT_X | CENTER_AT_Y);
3523 if ((i > 0) && (i < num_hours))
3524 x_draw_line(gInfo, boxX1, y1, boxX2, y1, gInfo->thinWd);
3527 gInfo->u.weekInfo.schedBoxX1 = boxX1;
3528 gInfo->u.weekInfo.schedBoxY1 = boxY1;
3529 gInfo->u.weekInfo.schedBoxX2 = boxX2;
3530 gInfo->u.weekInfo.schedBoxY2 = boxY2;
3534 x_week_daynames(void *gInfoP, char *dayName, int dayIndex, Boolean more)
3536 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3537 Calendar *c = gInfo->c;
3539 int innerOffset, innerWd;
3540 char dayBuf[BUFFERSIZE];
3542 y1 = (dayIndex < WEEK_DAYS) ? gInfo->u.weekInfo.curY1 :
3543 gInfo->u.weekInfo.curY2;
3544 y2 = y1 + gInfo->u.weekInfo.tab1;
3546 cm_set_font(gInfo, WV_DAY_FONT);
3548 innerWd = gInfo->u.weekInfo.boxWd - gInfo->thickWd + gInfo->normalWd;
3549 innerOffset = ((gInfo->thickWd - 1) / 2) - ((gInfo->normalWd - 1) / 2);
3551 if (dayIndex >= WEEK_DAYS)
3552 dayIndex -= WEEKEND_DAYS;
3553 x1 = gInfo->u.weekInfo.curX1 + innerOffset +
3554 ((dayIndex * innerWd) / WEEK_DAYS);
3555 x2 = gInfo->u.weekInfo.curX1 + innerOffset +
3556 (((dayIndex + 1) * innerWd) / WEEK_DAYS);
3560 unsigned long to_len = 0;
3563 _len = strlen(dayName);
3564 _converter_( dayName, _len, &to, &to_len );
3565 if ( ( to != NULL ) && ( to_len != 0 ) ) {
3570 sprintf(dayBuf, more ? "%s *" : "%s", euc_to_octal(dayName));
3571 x_print_string(gInfo, dayBuf, (x1 + x2) / 2, (y1 + y2) / 2,
3572 CENTER_AT_X | CENTER_AT_Y);
3574 gInfo->u.weekInfo.lineX = x1;
3575 gInfo->u.weekInfo.lineY = y2 + ((gInfo->normalWd + 1) / 2) + VMARGIN(gInfo);
3576 gInfo->u.weekInfo.lineMaxY = y1 + gInfo->u.weekInfo.boxHt;
3580 x_week_sched_init(void *gInfoP)
3582 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3584 memset(gInfo->u.weekInfo.schedBucket, 0,
3585 sizeof(gInfo->u.weekInfo.schedBucket));
3589 x_week_sched_draw(void *gInfoP, int dayIndex)
3591 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3593 Props *p = (Props *)gInfo->c->properties;
3594 int begin = get_int_prop(p, CP_DAYBEGIN);
3595 int end = get_int_prop(p, CP_DAYEND);
3596 int num_hours = end - begin;
3597 int nIntervals = num_hours * 4;
3599 int boxWd = gInfo->u.weekInfo.schedBoxX2 - gInfo->u.weekInfo.schedBoxX1;
3600 int boxHt = gInfo->u.weekInfo.schedBoxY2 - gInfo->u.weekInfo.schedBoxY1;
3601 int currColor, lastColor;
3602 int tOffset, bOffset;
3604 x1 = gInfo->u.weekInfo.schedBoxX1 +
3605 ((dayIndex * boxWd) / DAYS_IN_WEEK) + ((gInfo->normalWd + 1) / 2);
3606 x2 = gInfo->u.weekInfo.schedBoxX1 +
3607 (((dayIndex + 1) * boxWd) / DAYS_IN_WEEK) - (gInfo->normalWd / 2) - 1;
3610 for (i = 0; i < nIntervals; i++)
3612 y1 = gInfo->u.weekInfo.schedBoxY1 + ((i * boxHt) / nIntervals);
3613 y2 = gInfo->u.weekInfo.schedBoxY1 + (((i + 1) * boxHt) / nIntervals);
3614 switch (gInfo->u.weekInfo.schedBucket[i])
3622 tOffset = (i % 4) ? 0 : ((gInfo->thinWd + 1) / 2);
3623 bOffset = ((i + 1) % 4) ? 1 : (gInfo->thinWd / 2) + 1;
3624 x_fill_dark_box(gInfo, x1, y1 + tOffset, x2,
3630 x_fill_black_box(gInfo, x1, y1, x2, y2);
3634 if (currColor != lastColor)
3636 if ((currColor != 2) && (lastColor != 2))
3637 x_draw_line(gInfo, x1, y1, x2 + 1, y1, gInfo->thinWd);
3638 lastColor = currColor;
3644 x_init_month(void *gInfoP, int nRows)
3646 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3649 gInfo->reportType = PR_MONTH_VIEW;
3651 /* Load month fonts */
3652 if (gInfo->nFonts == 0)
3656 for (i = 0; i < MV_NUM_FONTS; i++)
3657 cm_load_font(gInfo, i, mvFonts[i]);
3659 /* Set curFont to first loaded font. */
3660 gInfo->curFont = gInfo->fontInfo;
3663 cm_adjust_margins(gInfo);
3665 /* --- init for month view print --- */
3666 fInfo = cm_find_font(gInfo, MV_HEADER_FONT);
3667 gInfo->u.monthInfo.curX1 = gInfo->leftMarginX + (gInfo->normalWd / 2);
3668 gInfo->u.monthInfo.curY1 =
3669 gInfo->topMarginY + cm_font_height(gInfo, fInfo) +
3670 VMARGIN(gInfo) + (gInfo->normalWd / 2);
3671 gInfo->u.monthInfo.boxWd =
3672 gInfo->rightMarginX - gInfo->leftMarginX - gInfo->normalWd;
3673 gInfo->u.monthInfo.boxHt =
3674 gInfo->bottomMarginY - ((gInfo->normalWd + 1) / 2) -
3675 gInfo->u.monthInfo.curY1;
3676 fInfo = cm_find_font(gInfo, MV_DAY_FONT);
3677 gInfo->u.monthInfo.tab1 = 2 * cm_font_height(gInfo, fInfo);
3678 gInfo->u.monthInfo.nRows = nRows;
3682 x_get_month_lines_per_page(void *gInfoP)
3684 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3685 CMFontInfo *fInfo = cm_find_font(gInfo, MV_APPT_FONT);
3686 CMFontInfo *dateFInfo = cm_find_font(gInfo, MV_DATE_FONT);
3687 int dateSz = HMARGIN(gInfo) + cm_font_height(gInfo, dateFInfo);
3689 return (((gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1) /
3690 gInfo->u.monthInfo.nRows) -
3691 gInfo->normalWd - dateSz - (2 * VMARGIN(gInfo))) /
3692 cm_font_height(gInfo, fInfo);
3696 x_month_daynames(void *gInfoP, int nRows)
3698 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3699 char *day_of_week[DAYS_IN_WEEK];
3701 Calendar *c = gInfo->c;
3705 for (i = 0; i < DAYS_IN_WEEK; i++)
3706 local_dayname3(gInfo->c, &(day_of_week[i]), i);
3708 /* Draw outer box. */
3709 x1 = gInfo->u.monthInfo.curX1;
3710 y1 = gInfo->u.monthInfo.curY1;
3711 x2 = x1 + gInfo->u.monthInfo.boxWd;
3712 y2 = y1 + gInfo->u.monthInfo.boxHt;
3713 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3715 /* Draw box around days. */
3716 y2 = y1 + gInfo->u.monthInfo.tab1;
3717 x_fill_dark_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3719 cm_set_font(gInfo, MV_DAY_FONT);
3720 for (i = 0; i < DAYS_IN_WEEK; i++)
3722 x1 = gInfo->u.monthInfo.curX1 +
3723 ((i * gInfo->u.monthInfo.boxWd) / DAYS_IN_WEEK);
3724 x2 = gInfo->u.monthInfo.curX1 +
3725 (((i + 1) * gInfo->u.monthInfo.boxWd) / DAYS_IN_WEEK);
3727 cm_reverse_video(gInfo, True);
3728 x_print_string(gInfo, day_of_week[i],
3729 (x1 + x2) / 2, (y1 + y2) / 2,
3730 CENTER_AT_X | CENTER_AT_Y);
3731 free(day_of_week[i]);
3733 cm_reverse_video(gInfo, False);
3735 x_draw_line(gInfo, x1, y1, x1, y1 + gInfo->u.monthInfo.boxHt,
3739 x1 = gInfo->u.monthInfo.curX1;
3740 x2 = x1 + gInfo->u.monthInfo.boxWd;
3741 dayBoxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3743 /* Draw horizontal lines. */
3744 for (i = 1; i < nRows; i++)
3746 y1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1 +
3747 ((i * dayBoxHt) / nRows);
3748 x_draw_line(gInfo, x1, y1, x2, y1, gInfo->normalWd);
3753 x_print_little_months(void *gInfoP, Tick tick)
3755 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3756 int m = month(tick); /* current month just printed */
3757 int y = year(tick); /* year of month just printed */
3758 int fday = fdom(tick); /* first day of month, 0=Sun ... */
3760 int nm, nmy, pm, pmy;
3762 int ndays = monthlength(tick);
3763 int nrows = gInfo->u.monthInfo.nRows;
3767 int boxX1, boxY1, boxWd, boxHt;
3768 int ulOffset, brOffset;
3773 * Print out miniature prev & next month on month grid.
3774 * Check if there is enough room at end; if not then
3775 * print at beginning of grid.
3777 nBoxes = nrows * DAYS_IN_WEEK;
3778 if ((fday + ndays + 2) <= nBoxes)
3780 pmIndex = nBoxes - 2;
3808 boxX1 = gInfo->u.monthInfo.curX1;
3809 boxY1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1;
3810 boxWd = gInfo->u.monthInfo.boxWd;
3811 boxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3812 ulOffset = (gInfo->normalWd + 1) / 2;
3813 brOffset = (gInfo->normalWd / 2) + 1;
3815 /* Determine spacing for drawing little months. Can be negative. */
3816 for (spacing = VMARGIN(gInfo);
3817 cm_tiny_month_height(gInfo, spacing) >
3818 (boxHt / nrows) - gInfo->normalWd;
3822 /* Gray out extra boxes. */
3823 y1 = boxY1 + ulOffset;
3824 y2 = boxY1 - brOffset + (boxHt / nrows);
3825 for (i = 0; i < fday; i++)
3827 x1 = boxX1 + ((i * boxWd) / DAYS_IN_WEEK) + ulOffset;
3828 x2 = boxX1 + (((i + 1) * boxWd) / DAYS_IN_WEEK) - brOffset;
3830 x_fill_light_box(gInfo, x1, y1, x2, y2, 0);
3833 x_print_month(gInfoP, pm, pmy, x1, y1, x2, y2, spacing);
3834 else if (i == (pmIndex + 1))
3835 x_print_month(gInfoP, nm, nmy, x1, y1, x2, y2, spacing);
3838 dayRow = (nBoxes - 1) / DAYS_IN_WEEK;
3839 y1 = boxY1 + ((dayRow * boxHt) / nrows) + ulOffset;
3840 y2 = boxY1 + (((dayRow + 1) * boxHt) / nrows) - brOffset;
3841 for (i = fday + ndays; i < nBoxes; i++)
3843 dayCol = i % DAYS_IN_WEEK;
3844 x1 = boxX1 + ((dayCol * boxWd) / DAYS_IN_WEEK) + ulOffset;
3845 x2 = boxX1 + (((dayCol + 1) * boxWd) / DAYS_IN_WEEK) - brOffset;
3847 x_fill_light_box(gInfo, x1, y1, x2, y2, 0);
3850 x_print_month(gInfoP, pm, pmy, x1, y1, x2, y2, spacing);
3851 else if (i == (pmIndex + 1))
3852 x_print_month(gInfoP, nm, nmy, x1, y1, x2, y2, spacing);
3857 x_month_timeslots(void *gInfoP, Tick tick, Boolean more)
3859 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3860 int fday = fdom(tick); /* first day of month, 0=Sun ... */
3861 int thisDay = dom(tick);
3862 int nrows = gInfo->u.monthInfo.nRows;
3864 int boxX1, boxY1, boxWd, boxHt;
3865 int ulOffset, brOffset;
3867 char dateBuf[BUFFERSIZE];
3869 boxX1 = gInfo->u.monthInfo.curX1;
3870 boxY1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1;
3871 boxWd = gInfo->u.monthInfo.boxWd;
3872 boxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3873 ulOffset = (gInfo->normalWd + 1) / 2;
3874 brOffset = (gInfo->normalWd / 2) + 1;
3876 /* Write date into appropriate box. */
3877 cm_set_font(gInfo, MV_DATE_FONT);
3878 dayRow = (thisDay + fday - 1) / DAYS_IN_WEEK;
3879 dayCol = (thisDay + fday - 1) % DAYS_IN_WEEK;
3881 gInfo->u.monthInfo.lineY = boxY1 + ((dayRow * boxHt) / nrows);
3882 gInfo->u.monthInfo.lineX = boxX1 + ((dayCol * boxWd) / DAYS_IN_WEEK);
3883 gInfo->u.monthInfo.lastX = gInfo->u.monthInfo.lineX + ulOffset;
3884 gInfo->u.monthInfo.lineMaxY = boxY1 + (((dayRow + 1) * boxHt) / nrows);
3885 gInfo->u.monthInfo.lineMaxX = boxX1 + (((dayCol + 1) * boxWd) /
3887 y1 = gInfo->u.monthInfo.lineY + ulOffset + HMARGIN(gInfo);
3888 x1 = gInfo->u.monthInfo.lineX + ulOffset + VMARGIN(gInfo);
3890 sprintf(dateBuf, more ? "%d *" : "%d", thisDay);
3891 x_print_string(gInfo, dateBuf, x1, y1, LEFT_AT_X | TOP_AT_Y);
3893 gInfo->u.monthInfo.lineY =
3894 y1 + cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo);
3898 x_print_month_appts(void *gInfoP, CSA_entry_handle *list,
3899 int a_total, int num_page,
3900 time_t hi_hour, int lines_per_box)
3902 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3905 char buf1[BUFFERSIZE];
3906 Calendar *c = gInfo->c;
3907 Props *pr = (Props *)c->properties;
3908 int meoval = get_int_prop(pr, CP_PRINTPRIVACY);
3909 int i, start, pos = 1, line_counter = 0;
3910 CSA_return_code stat;
3911 Dtcm_appointment *appt;
3914 start = ((num_page - 1) * lines_per_box) + 1;
3916 appt = allocate_appt_struct(appt_read,
3917 c->general->version,
3918 CSA_ENTRY_ATTR_CLASSIFICATION_I,
3919 CSA_ENTRY_ATTR_START_DATE_I,
3920 CSA_ENTRY_ATTR_SUMMARY_I,
3921 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
3923 for (i = 0; i < a_total; i++)
3925 stat = query_appt_struct(c->cal_handle, list[i], appt);
3926 if (stat != CSA_SUCCESS)
3928 free_appt_struct(&appt);
3932 _csa_iso8601_to_tick(appt->time->value->item.date_time_value, &start_tick);
3933 if (start_tick >= hi_hour)
3935 free_appt_struct(&appt);
3939 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
3940 !(meoval & PRINT_PUBLIC))
3942 if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
3943 !(meoval & PRINT_SEMIPRIVATE))
3945 if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
3946 !(meoval & PRINT_PRIVATE))
3955 get_time_str(appt, buf1);
3957 indented = (*buf1 != '\0');
3959 lines = text_to_lines(appt->what->value->item.string_value, 1);
3961 if ((line_counter > lines_per_box) && (lines != NULL))
3963 free_appt_struct(&appt);
3967 /* only print if appt text found */
3968 if ((lines != NULL) && (lines->s != NULL))
3970 if (indented) /* time found so print it */
3971 cm_print_month_time(gInfo, buf1);
3972 cm_print_month_text(gInfo, lines->s, indented ? 2 : 0);
3975 destroy_lines(lines);
3979 free_appt_struct(&appt);