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 = NULL;
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);
3014 if (stat != CSA_SUCCESS) {
3018 x_print_todo(xp, list, a_total, appt_type,
3019 (start_tick != end_tick), todo_view, end, buf);
3023 x_finish_printer(xp);
3024 x_print_file(xp, c);
3028 x_init_list(void *gInfoP)
3030 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3035 /* We can ONLY get here printing via dialog - printData is valid. */
3036 gInfo->reportType = pd_get_report_type(gInfo->c);
3038 /* Load list fonts */
3039 if (gInfo->nFonts == 0)
3043 if (gInfo->reportType == PR_APPT_LIST)
3045 for (i = 0; i < AV_NUM_FONTS; i++)
3046 cm_load_font(gInfo, i, avFonts[i]);
3050 for (i = 0; i < TV_NUM_FONTS; i++)
3051 cm_load_font(gInfo, i, tvFonts[i]);
3054 /* Set curFont to first loaded font. */
3055 gInfo->curFont = gInfo->fontInfo;
3058 cm_adjust_margins(gInfo);
3060 cm_set_font(gInfo, cm_get_header_enum(gInfo));
3062 hIndent = TODO_HINDENT * gInfo->hscale * gInfo->normalWd;
3063 vIndent = TODO_VINDENT * gInfo->vscale * gInfo->normalWd;
3064 gInfo->u.toDoInfo.outerX1 = gInfo->leftMarginX + (gInfo->thickWd / 2);
3065 gInfo->u.toDoInfo.outerY1 = gInfo->topMarginY + (gInfo->thickWd / 2) +
3066 cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo);
3067 gInfo->u.toDoInfo.innerX1 = gInfo->u.toDoInfo.outerX1 + hIndent;
3068 gInfo->u.toDoInfo.innerY1 = gInfo->u.toDoInfo.outerY1 + vIndent;
3069 gInfo->u.toDoInfo.outerX2 =
3070 gInfo->rightMarginX - ((gInfo->thickWd + 1) / 2);
3071 gInfo->u.toDoInfo.outerY2 =
3072 gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2);
3073 gInfo->u.toDoInfo.boxX2 = gInfo->u.toDoInfo.outerX2 - hIndent;
3074 gInfo->u.toDoInfo.boxY2 = gInfo->u.toDoInfo.outerY2 - vIndent;
3075 gInfo->u.toDoInfo.boxX1 = gInfo->u.toDoInfo.innerX1;
3076 gInfo->u.toDoInfo.boxY1 = gInfo->u.toDoInfo.boxY2 -
3077 cm_tiny_month_height(gInfo, VMARGIN(gInfo)) - gInfo->thickWd;
3078 gInfo->u.toDoInfo.innerX2 = gInfo->u.toDoInfo.boxX2;
3079 gInfo->u.toDoInfo.innerY2 = gInfo->u.toDoInfo.boxY1 - vIndent;
3081 gInfo->u.toDoInfo.lineX =
3082 gInfo->u.toDoInfo.innerX1 + ((gInfo->thickWd + 1) / 2) + HMARGIN(gInfo);
3083 gInfo->u.toDoInfo.lineY =
3084 gInfo->u.toDoInfo.innerY1 + ((gInfo->thickWd + 1) / 2) + VMARGIN(gInfo);
3088 x_print_todo(void *gInfoP, CSA_entry_handle *list, int a_total,
3089 CSA_sint32 appt_type, Boolean showDate, int vf,
3090 time_t end_time, char *buf)
3092 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3093 int i, items_per_page = 0, meoval;
3094 char buf3[BUFFERSIZE], buf2[BUFFERSIZE], buf1[BUFFERSIZE];
3095 int total_items = 0;
3096 boolean_t skip_appt;
3097 CSA_return_code stat;
3098 Dtcm_appointment *appt;
3099 Calendar *c = gInfo->c;
3100 Props *p = (Props*)c->properties;
3101 DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);
3102 OrderingType ot = get_int_prop(p, CP_DATEORDERING);
3103 SeparatorType st = get_int_prop(p, CP_DATESEPARATOR);
3105 int linesFullPage, linesPartialPage;
3106 int numAppts, numPages, curPage;
3109 cm_get_todo_lines_per_page(gInfo, appt_type, &linesFullPage,
3111 numAppts = cm_count_appts(gInfo, list, a_total, appt_type, vf);
3112 for (numPages = 1, numAppts -= linesPartialPage;
3115 numAppts -= linesFullPage;
3116 x_print_header(gInfoP, buf, curPage, numPages);
3117 cm_todo_outline(gInfo, curPage == numPages);
3118 cm_set_todo_text_clipping(gInfo);
3120 meoval = get_int_prop(p, CP_PRINTPRIVACY);
3121 buf1[0] = buf2[0] = buf3[0] = '\0';
3123 appt = allocate_appt_struct(appt_read,
3124 c->general->version,
3125 CSA_ENTRY_ATTR_CLASSIFICATION_I,
3126 CSA_ENTRY_ATTR_TYPE_I,
3127 CSA_ENTRY_ATTR_STATUS_I,
3128 CSA_ENTRY_ATTR_START_DATE_I,
3129 CSA_ENTRY_ATTR_SUMMARY_I,
3130 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
3131 CSA_ENTRY_ATTR_END_DATE_I,
3133 for (i = 0; i < a_total; i++)
3135 stat = query_appt_struct(c->cal_handle, list[i], appt);
3136 if (stat != CSA_SUCCESS)
3138 free_appt_struct(&appt);
3141 skip_appt = B_FALSE;
3143 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
3144 !(meoval & PRINT_PUBLIC))
3146 else if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
3147 !(meoval & PRINT_SEMIPRIVATE))
3149 else if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
3150 !(meoval & PRINT_PRIVATE))
3153 if ((appt_type == CSA_TYPE_TODO) &&
3154 ((appt->type->value->item.sint32_value != CSA_TYPE_TODO)
3156 ((vf == VIEW_PENDING) &&
3157 (appt->state->value->item.sint32_value ==
3158 CSA_STATUS_COMPLETED)) ||
3159 ((vf == VIEW_COMPLETED) &&
3160 (appt->state->value->item.sint32_value ==
3161 CSA_X_DT_STATUS_ACTIVE))))
3164 if ((appt_type == CSA_TYPE_EVENT) &&
3165 (appt->type->value->item.sint32_value != CSA_TYPE_EVENT))
3171 format_maxchars(appt, buf1, BUFFERSIZE - 5, dt);
3174 _csa_iso8601_to_tick(appt->time->value->item.date_time_value,
3176 format_date3(start_tick, ot, st, buf2);
3177 sprintf(buf3, "%s %s", buf2, buf1);
3179 cm_strcpy(buf3, buf1);
3182 cm_print_todo_text (gInfo, buf3,
3183 appt->state->value->item.sint32_value,
3184 appt_type, total_items);
3185 if ((++items_per_page % linesFullPage) == 0)
3187 cm_unset_todo_text_clipping(gInfo);
3188 x_finish_printer(gInfoP);
3189 x_init_printer(gInfoP, PORTRAIT);
3190 x_init_list(gInfoP);
3191 x_print_header(gInfoP, buf, ++curPage, numPages);
3192 cm_todo_outline(gInfo, curPage == numPages);
3193 cm_set_todo_text_clipping(gInfo);
3196 } /* end for stmt */
3198 free_appt_struct(&appt);
3199 cm_unset_todo_text_clipping(gInfo);
3201 if (items_per_page > linesPartialPage) {
3202 x_finish_printer(gInfoP);
3203 x_init_printer(gInfoP, PORTRAIT);
3204 x_init_list(gInfoP);
3205 x_print_header(gInfoP, buf, ++curPage, numPages);
3206 cm_todo_outline(gInfo, curPage == numPages);
3209 cm_print_todo_months(gInfo, end_time);
3213 x_print_month(void *gInfoP, int mon, int yr, int x1,
3214 int y1, int x2, int y2, int spacing)
3216 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3218 Tick j = monthdayyear(mon, 1, yr); /* starting date Jan 1, y */
3219 int i, colWd, dateWd, monLen;
3220 char str[BUFFERSIZE];
3223 mon = (mon % 13) + 1;
3227 x_set_clip_box(gInfo, x1, y1, x2, y2);
3229 cm_set_font(gInfo, cm_get_tiny_title_enum(gInfo));
3232 cm_strcpy(str, months[mon]);
3236 unsigned long to_len = 0;
3240 _converter_( str, _len, &to, &to_len );
3241 if ( ( to != NULL ) && ( to_len != 0 ) ) {
3246 cm_strcpy(str, euc_to_octal(str));
3247 x_fill_light_box(gInfo, x1 + HMARGIN(gInfo), y1,
3248 x2 - HMARGIN(gInfo),
3249 y1 + cm_font_height(gInfo, gInfo->curFont),
3251 x_print_string(gInfo, str,
3253 CENTER_AT_X | TOP_AT_Y);
3254 y1 += spacing + cm_font_height(gInfo, gInfo->curFont);
3256 fInfo = cm_find_font(gInfo, cm_get_tiny_date_enum(gInfo));
3257 monLen = monthlength(j);
3259 for (i = 0; i < monLen; i++)
3261 sprintf(str, "%d", i + 1);
3262 if ((dateWd = cm_string_width(gInfo, fInfo, str)) > colWd)
3266 cm_std_month_weekdays(gInfo, colWd, x1, y1, x2);
3267 y1 += spacing + cm_font_height(gInfo, gInfo->curFont);
3269 cm_std_month_dates(gInfo, fdom(j), monLen, colWd,
3270 x1, y1, x2, spacing);
3272 x_unset_clip_box(gInfo);
3276 x_init_std_year(void *gInfoP)
3278 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3281 gInfo->reportType = PR_YEAR_VIEW;
3283 /* Load year fonts */
3284 if (gInfo->nFonts == 0)
3288 for (i = 0; i < YV_NUM_FONTS; i++)
3289 cm_load_font(gInfo, i, yvFonts[i]);
3291 /* Set curFont to first loaded font. */
3292 gInfo->curFont = gInfo->fontInfo;
3295 cm_adjust_margins(gInfo);
3299 x_std_year_name(void *gInfoP, int yr)
3301 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3302 char yearBuf[BUFFERSIZE];
3304 /* --- print year centered at top --- */
3305 sprintf(yearBuf, "%d", yr);
3306 x_print_header(gInfoP, yearBuf, 1, 1);
3310 x_print_year(void *gInfoP, int yr)
3312 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3323 fInfo = cm_find_font(gInfo, YV_HEADER_FONT);
3324 monthHt = cm_tiny_month_height(gInfo, VMARGIN(gInfo));
3326 leftX = gInfo->leftMarginX;
3327 topY = gInfo->topMarginY + cm_font_height(gInfo, fInfo) + VMARGIN(gInfo);
3329 pageWd = gInfo->rightMarginX - leftX;
3330 pageHt = gInfo->bottomMarginY - topY;
3331 extraSpace = pageHt - (4 * monthHt);
3333 for (i = 0; i < 12; i++)
3338 x1 = leftX + ((col * pageWd) / 3);
3339 x2 = leftX + (((col + 1) * pageWd) / 3);
3343 y1 = topY + (((row + 1) * extraSpace) / 5) + (row * monthHt);
3344 y2 = topY + (((row + 2) * extraSpace) / 5) + ((row + 1) * monthHt);
3348 y1 = topY + ((row * pageHt) / 4);
3349 y2 = topY + (((row + 1) * pageHt) / 4);
3352 x_print_month(gInfoP, i + 1, yr, x1, y1, x2, y2, VMARGIN(gInfo));
3357 x_init_week(void *gInfoP)
3359 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3362 gInfo->reportType = PR_WEEK_VIEW;
3364 /* Load week fonts */
3365 if (gInfo->nFonts == 0)
3369 for (i = 0; i < WV_NUM_FONTS; i++)
3370 cm_load_font(gInfo, i, wvFonts[i]);
3372 /* Set curFont to first loaded font. */
3373 gInfo->curFont = gInfo->fontInfo;
3376 cm_adjust_margins(gInfo);
3378 fInfo = cm_find_font(gInfo, WV_HEADER_FONT);
3379 gInfo->u.weekInfo.curX1 = gInfo->leftMarginX + (gInfo->thickWd / 2);
3380 gInfo->u.weekInfo.curY1 = gInfo->topMarginY + cm_font_height(gInfo, fInfo) +
3381 VMARGIN(gInfo) + (gInfo->thickWd / 2);
3382 gInfo->u.weekInfo.boxWd =
3383 gInfo->rightMarginX - gInfo->leftMarginX - gInfo->thickWd;
3384 gInfo->u.weekInfo.boxHt =
3385 (gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2) -
3386 gInfo->u.weekInfo.curY1) / 2;
3387 gInfo->u.weekInfo.curY2 =
3388 gInfo->u.weekInfo.curY1 + gInfo->u.weekInfo.boxHt;
3390 fInfo = cm_find_font(gInfo, WV_DAY_FONT);
3391 gInfo->u.weekInfo.tab1 =
3392 ((3 * cm_font_height(gInfo, fInfo)) +
3393 gInfo->thickWd + gInfo->normalWd) / 2;
3397 x_week_appt_boxes(void *gInfoP)
3399 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3401 int innerWd, innerOffset;
3404 /* Draw weekdays box. */
3405 x1 = gInfo->u.weekInfo.curX1;
3406 y1 = gInfo->u.weekInfo.curY1;
3407 x2 = x1 + gInfo->u.weekInfo.boxWd;
3408 y2 = y1 + gInfo->u.weekInfo.tab1;
3410 x_fill_light_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3412 y2 = gInfo->u.weekInfo.curY2;
3413 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->thickWd);
3415 /* Draw weekdays vertical lines. */
3416 innerWd = gInfo->u.weekInfo.boxWd - gInfo->thickWd + gInfo->normalWd;
3417 innerOffset = ((gInfo->thickWd - 1) / 2) - ((gInfo->normalWd - 1) / 2);
3418 for (i = 1; i < WEEK_DAYS; i++)
3420 x1 = gInfo->u.weekInfo.curX1 + innerOffset + ((i * innerWd) / WEEK_DAYS);
3421 x_draw_line(gInfo, x1, y1, x1, y2, gInfo->normalWd);
3424 /* Draw weekends box. */
3425 x1 = gInfo->u.weekInfo.curX1 +
3426 (((WEEK_DAYS - WEEKEND_DAYS) * gInfo->u.weekInfo.boxWd) / WEEK_DAYS);
3428 y2 = y1 + gInfo->u.weekInfo.tab1;
3429 x_fill_light_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3431 y2 = gInfo->bottomMarginY - ((gInfo->thickWd + 1) / 2);
3432 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->thickWd);
3434 /* Draw weekends vertical lines. */
3435 for (i = WEEK_DAYS - WEEKEND_DAYS + 1; i < WEEK_DAYS; i++)
3437 x1 = gInfo->u.weekInfo.curX1 + innerOffset + ((i * innerWd) / WEEK_DAYS);
3438 x_draw_line(gInfo, x1, y1, x1, y2, gInfo->normalWd);
3443 x_week_sched_boxes(void *gInfoP)
3445 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3446 char *day_of_week[DAYS_IN_WEEK];
3447 char hourBuf[BUFFERSIZE];
3448 Props *p = (Props *)gInfo->c->properties;
3449 int begin = get_int_prop(p, CP_DAYBEGIN);
3450 int end = get_int_prop(p, CP_DAYEND);
3451 DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);
3455 int boxX1, boxY1, boxX2, boxY2, boxWd, boxHt;
3458 int ulOff = gInfo->thickWd / 2;
3459 int brOff = (gInfo->thickWd - 1) / 2;
3461 /* --- print week sched boxes --- */
3463 /* figure out number of partitions in sched box */
3464 num_hours = end - begin;
3466 /* determine offset of sched box from left margin */
3467 cm_set_font(gInfo, WV_DAY_FONT);
3468 boxIndent = cm_week_sched_box_indent(gInfo);
3469 boxX1 = gInfo->u.weekInfo.curX1 + boxIndent;
3470 boxX2 = gInfo->u.weekInfo.curX1 +
3471 ((3 * gInfo->u.weekInfo.boxWd) / WEEK_DAYS) - boxIndent;
3472 boxY1 = gInfo->u.weekInfo.curY2 +
3473 (2 * cm_font_height(gInfo, gInfo->curFont)) +
3475 boxY2 = gInfo->bottomMarginY - 1 - brOff;
3477 x_draw_box(gInfo, boxX1, boxY1, boxX2, boxY2, gInfo->thickWd);
3479 boxX1 += brOff - ((gInfo->normalWd - 1) / 2);
3480 boxX2 -= ulOff - (gInfo->normalWd / 2);
3481 boxY1 += brOff - ((gInfo->thinWd - 1) / 2);
3482 boxY2 -= ulOff - (gInfo->thinWd / 2);
3483 boxWd = boxX2 - boxX1;
3484 boxHt = boxY2 - boxY1;
3486 for (i = 0; i < DAYS_IN_WEEK; i++)
3487 local_dayname(gInfo->c, &day_of_week[i], (i + 1) % DAYS_IN_WEEK);
3489 /* print abbreviated weekdays on top and draw vertical lines. */
3490 for (i = 0; i < DAYS_IN_WEEK; i++)
3492 x1 = boxX1 + ((i * boxWd) / DAYS_IN_WEEK);
3493 x2 = boxX1 + (((i + 1) * boxWd) / DAYS_IN_WEEK);
3495 x_print_string(gInfo, day_of_week[i],
3496 (x1 + x2) / 2, boxY1 -
3497 gInfo->thickWd - (2 * VMARGIN(gInfo)),
3498 CENTER_AT_X | BOTTOM_AT_Y);
3499 free(day_of_week[i]);
3501 x_draw_line(gInfo, x1, boxY1, x1, boxY2, gInfo->normalWd);
3504 /* Print hours and horizontal lines. */
3505 for (thisHour = begin, i = 0; i <= num_hours; i++, thisHour++)
3512 else if ( dt == HOUR24 )
3517 sprintf(hourBuf, "%d", thisHour);
3518 y1 = boxY1 + ((i * boxHt) / num_hours);
3520 x_print_string(gInfo, hourBuf,
3521 boxX1 - gInfo->thickWd - HMARGIN(gInfo), y1,
3522 RIGHT_AT_X | CENTER_AT_Y);
3524 if ((i > 0) && (i < num_hours))
3525 x_draw_line(gInfo, boxX1, y1, boxX2, y1, gInfo->thinWd);
3528 gInfo->u.weekInfo.schedBoxX1 = boxX1;
3529 gInfo->u.weekInfo.schedBoxY1 = boxY1;
3530 gInfo->u.weekInfo.schedBoxX2 = boxX2;
3531 gInfo->u.weekInfo.schedBoxY2 = boxY2;
3535 x_week_daynames(void *gInfoP, char *dayName, int dayIndex, Boolean more)
3537 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3538 Calendar *c = gInfo->c;
3540 int innerOffset, innerWd;
3541 char dayBuf[BUFFERSIZE];
3543 y1 = (dayIndex < WEEK_DAYS) ? gInfo->u.weekInfo.curY1 :
3544 gInfo->u.weekInfo.curY2;
3545 y2 = y1 + gInfo->u.weekInfo.tab1;
3547 cm_set_font(gInfo, WV_DAY_FONT);
3549 innerWd = gInfo->u.weekInfo.boxWd - gInfo->thickWd + gInfo->normalWd;
3550 innerOffset = ((gInfo->thickWd - 1) / 2) - ((gInfo->normalWd - 1) / 2);
3552 if (dayIndex >= WEEK_DAYS)
3553 dayIndex -= WEEKEND_DAYS;
3554 x1 = gInfo->u.weekInfo.curX1 + innerOffset +
3555 ((dayIndex * innerWd) / WEEK_DAYS);
3556 x2 = gInfo->u.weekInfo.curX1 + innerOffset +
3557 (((dayIndex + 1) * innerWd) / WEEK_DAYS);
3561 unsigned long to_len = 0;
3564 _len = strlen(dayName);
3565 _converter_( dayName, _len, &to, &to_len );
3566 if ( ( to != NULL ) && ( to_len != 0 ) ) {
3571 sprintf(dayBuf, more ? "%s *" : "%s", euc_to_octal(dayName));
3572 x_print_string(gInfo, dayBuf, (x1 + x2) / 2, (y1 + y2) / 2,
3573 CENTER_AT_X | CENTER_AT_Y);
3575 gInfo->u.weekInfo.lineX = x1;
3576 gInfo->u.weekInfo.lineY = y2 + ((gInfo->normalWd + 1) / 2) + VMARGIN(gInfo);
3577 gInfo->u.weekInfo.lineMaxY = y1 + gInfo->u.weekInfo.boxHt;
3581 x_week_sched_init(void *gInfoP)
3583 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3585 memset(gInfo->u.weekInfo.schedBucket, 0,
3586 sizeof(gInfo->u.weekInfo.schedBucket));
3590 x_week_sched_draw(void *gInfoP, int dayIndex)
3592 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3594 Props *p = (Props *)gInfo->c->properties;
3595 int begin = get_int_prop(p, CP_DAYBEGIN);
3596 int end = get_int_prop(p, CP_DAYEND);
3597 int num_hours = end - begin;
3598 int nIntervals = num_hours * 4;
3600 int boxWd = gInfo->u.weekInfo.schedBoxX2 - gInfo->u.weekInfo.schedBoxX1;
3601 int boxHt = gInfo->u.weekInfo.schedBoxY2 - gInfo->u.weekInfo.schedBoxY1;
3602 int currColor, lastColor;
3603 int tOffset, bOffset;
3605 x1 = gInfo->u.weekInfo.schedBoxX1 +
3606 ((dayIndex * boxWd) / DAYS_IN_WEEK) + ((gInfo->normalWd + 1) / 2);
3607 x2 = gInfo->u.weekInfo.schedBoxX1 +
3608 (((dayIndex + 1) * boxWd) / DAYS_IN_WEEK) - (gInfo->normalWd / 2) - 1;
3611 for (i = 0; i < nIntervals; i++)
3613 y1 = gInfo->u.weekInfo.schedBoxY1 + ((i * boxHt) / nIntervals);
3614 y2 = gInfo->u.weekInfo.schedBoxY1 + (((i + 1) * boxHt) / nIntervals);
3615 switch (gInfo->u.weekInfo.schedBucket[i])
3623 tOffset = (i % 4) ? 0 : ((gInfo->thinWd + 1) / 2);
3624 bOffset = ((i + 1) % 4) ? 1 : (gInfo->thinWd / 2) + 1;
3625 x_fill_dark_box(gInfo, x1, y1 + tOffset, x2,
3631 x_fill_black_box(gInfo, x1, y1, x2, y2);
3635 if (currColor != lastColor)
3637 if ((currColor != 2) && (lastColor != 2))
3638 x_draw_line(gInfo, x1, y1, x2 + 1, y1, gInfo->thinWd);
3639 lastColor = currColor;
3645 x_init_month(void *gInfoP, int nRows)
3647 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3650 gInfo->reportType = PR_MONTH_VIEW;
3652 /* Load month fonts */
3653 if (gInfo->nFonts == 0)
3657 for (i = 0; i < MV_NUM_FONTS; i++)
3658 cm_load_font(gInfo, i, mvFonts[i]);
3660 /* Set curFont to first loaded font. */
3661 gInfo->curFont = gInfo->fontInfo;
3664 cm_adjust_margins(gInfo);
3666 /* --- init for month view print --- */
3667 fInfo = cm_find_font(gInfo, MV_HEADER_FONT);
3668 gInfo->u.monthInfo.curX1 = gInfo->leftMarginX + (gInfo->normalWd / 2);
3669 gInfo->u.monthInfo.curY1 =
3670 gInfo->topMarginY + cm_font_height(gInfo, fInfo) +
3671 VMARGIN(gInfo) + (gInfo->normalWd / 2);
3672 gInfo->u.monthInfo.boxWd =
3673 gInfo->rightMarginX - gInfo->leftMarginX - gInfo->normalWd;
3674 gInfo->u.monthInfo.boxHt =
3675 gInfo->bottomMarginY - ((gInfo->normalWd + 1) / 2) -
3676 gInfo->u.monthInfo.curY1;
3677 fInfo = cm_find_font(gInfo, MV_DAY_FONT);
3678 gInfo->u.monthInfo.tab1 = 2 * cm_font_height(gInfo, fInfo);
3679 gInfo->u.monthInfo.nRows = nRows;
3683 x_get_month_lines_per_page(void *gInfoP)
3685 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3686 CMFontInfo *fInfo = cm_find_font(gInfo, MV_APPT_FONT);
3687 CMFontInfo *dateFInfo = cm_find_font(gInfo, MV_DATE_FONT);
3688 int dateSz = HMARGIN(gInfo) + cm_font_height(gInfo, dateFInfo);
3690 return (((gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1) /
3691 gInfo->u.monthInfo.nRows) -
3692 gInfo->normalWd - dateSz - (2 * VMARGIN(gInfo))) /
3693 cm_font_height(gInfo, fInfo);
3697 x_month_daynames(void *gInfoP, int nRows)
3699 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3700 char *day_of_week[DAYS_IN_WEEK];
3702 Calendar *c = gInfo->c;
3706 for (i = 0; i < DAYS_IN_WEEK; i++)
3707 local_dayname3(gInfo->c, &(day_of_week[i]), i);
3709 /* Draw outer box. */
3710 x1 = gInfo->u.monthInfo.curX1;
3711 y1 = gInfo->u.monthInfo.curY1;
3712 x2 = x1 + gInfo->u.monthInfo.boxWd;
3713 y2 = y1 + gInfo->u.monthInfo.boxHt;
3714 x_draw_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3716 /* Draw box around days. */
3717 y2 = y1 + gInfo->u.monthInfo.tab1;
3718 x_fill_dark_box(gInfo, x1, y1, x2, y2, gInfo->normalWd);
3720 cm_set_font(gInfo, MV_DAY_FONT);
3721 for (i = 0; i < DAYS_IN_WEEK; i++)
3723 x1 = gInfo->u.monthInfo.curX1 +
3724 ((i * gInfo->u.monthInfo.boxWd) / DAYS_IN_WEEK);
3725 x2 = gInfo->u.monthInfo.curX1 +
3726 (((i + 1) * gInfo->u.monthInfo.boxWd) / DAYS_IN_WEEK);
3728 cm_reverse_video(gInfo, True);
3729 x_print_string(gInfo, day_of_week[i],
3730 (x1 + x2) / 2, (y1 + y2) / 2,
3731 CENTER_AT_X | CENTER_AT_Y);
3732 free(day_of_week[i]);
3734 cm_reverse_video(gInfo, False);
3736 x_draw_line(gInfo, x1, y1, x1, y1 + gInfo->u.monthInfo.boxHt,
3740 x1 = gInfo->u.monthInfo.curX1;
3741 x2 = x1 + gInfo->u.monthInfo.boxWd;
3742 dayBoxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3744 /* Draw horizontal lines. */
3745 for (i = 1; i < nRows; i++)
3747 y1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1 +
3748 ((i * dayBoxHt) / nRows);
3749 x_draw_line(gInfo, x1, y1, x2, y1, gInfo->normalWd);
3754 x_print_little_months(void *gInfoP, Tick tick)
3756 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3757 int m = month(tick); /* current month just printed */
3758 int y = year(tick); /* year of month just printed */
3759 int fday = fdom(tick); /* first day of month, 0=Sun ... */
3761 int nm, nmy, pm, pmy;
3763 int ndays = monthlength(tick);
3764 int nrows = gInfo->u.monthInfo.nRows;
3768 int boxX1, boxY1, boxWd, boxHt;
3769 int ulOffset, brOffset;
3774 * Print out miniature prev & next month on month grid.
3775 * Check if there is enough room at end; if not then
3776 * print at beginning of grid.
3778 nBoxes = nrows * DAYS_IN_WEEK;
3779 if ((fday + ndays + 2) <= nBoxes)
3781 pmIndex = nBoxes - 2;
3809 boxX1 = gInfo->u.monthInfo.curX1;
3810 boxY1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1;
3811 boxWd = gInfo->u.monthInfo.boxWd;
3812 boxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3813 ulOffset = (gInfo->normalWd + 1) / 2;
3814 brOffset = (gInfo->normalWd / 2) + 1;
3816 /* Determine spacing for drawing little months. Can be negative. */
3817 for (spacing = VMARGIN(gInfo);
3818 cm_tiny_month_height(gInfo, spacing) >
3819 (boxHt / nrows) - gInfo->normalWd;
3823 /* Gray out extra boxes. */
3824 y1 = boxY1 + ulOffset;
3825 y2 = boxY1 - brOffset + (boxHt / nrows);
3826 for (i = 0; i < fday; i++)
3828 x1 = boxX1 + ((i * boxWd) / DAYS_IN_WEEK) + ulOffset;
3829 x2 = boxX1 + (((i + 1) * boxWd) / DAYS_IN_WEEK) - brOffset;
3831 x_fill_light_box(gInfo, x1, y1, x2, y2, 0);
3834 x_print_month(gInfoP, pm, pmy, x1, y1, x2, y2, spacing);
3835 else if (i == (pmIndex + 1))
3836 x_print_month(gInfoP, nm, nmy, x1, y1, x2, y2, spacing);
3839 dayRow = (nBoxes - 1) / DAYS_IN_WEEK;
3840 y1 = boxY1 + ((dayRow * boxHt) / nrows) + ulOffset;
3841 y2 = boxY1 + (((dayRow + 1) * boxHt) / nrows) - brOffset;
3842 for (i = fday + ndays; i < nBoxes; i++)
3844 dayCol = i % DAYS_IN_WEEK;
3845 x1 = boxX1 + ((dayCol * boxWd) / DAYS_IN_WEEK) + ulOffset;
3846 x2 = boxX1 + (((dayCol + 1) * boxWd) / DAYS_IN_WEEK) - brOffset;
3848 x_fill_light_box(gInfo, x1, y1, x2, y2, 0);
3851 x_print_month(gInfoP, pm, pmy, x1, y1, x2, y2, spacing);
3852 else if (i == (pmIndex + 1))
3853 x_print_month(gInfoP, nm, nmy, x1, y1, x2, y2, spacing);
3858 x_month_timeslots(void *gInfoP, Tick tick, Boolean more)
3860 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3861 int fday = fdom(tick); /* first day of month, 0=Sun ... */
3862 int thisDay = dom(tick);
3863 int nrows = gInfo->u.monthInfo.nRows;
3865 int boxX1, boxY1, boxWd, boxHt;
3866 int ulOffset, brOffset;
3868 char dateBuf[BUFFERSIZE];
3870 boxX1 = gInfo->u.monthInfo.curX1;
3871 boxY1 = gInfo->u.monthInfo.curY1 + gInfo->u.monthInfo.tab1;
3872 boxWd = gInfo->u.monthInfo.boxWd;
3873 boxHt = gInfo->u.monthInfo.boxHt - gInfo->u.monthInfo.tab1;
3874 ulOffset = (gInfo->normalWd + 1) / 2;
3875 brOffset = (gInfo->normalWd / 2) + 1;
3877 /* Write date into appropriate box. */
3878 cm_set_font(gInfo, MV_DATE_FONT);
3879 dayRow = (thisDay + fday - 1) / DAYS_IN_WEEK;
3880 dayCol = (thisDay + fday - 1) % DAYS_IN_WEEK;
3882 gInfo->u.monthInfo.lineY = boxY1 + ((dayRow * boxHt) / nrows);
3883 gInfo->u.monthInfo.lineX = boxX1 + ((dayCol * boxWd) / DAYS_IN_WEEK);
3884 gInfo->u.monthInfo.lastX = gInfo->u.monthInfo.lineX + ulOffset;
3885 gInfo->u.monthInfo.lineMaxY = boxY1 + (((dayRow + 1) * boxHt) / nrows);
3886 gInfo->u.monthInfo.lineMaxX = boxX1 + (((dayCol + 1) * boxWd) /
3888 y1 = gInfo->u.monthInfo.lineY + ulOffset + HMARGIN(gInfo);
3889 x1 = gInfo->u.monthInfo.lineX + ulOffset + VMARGIN(gInfo);
3891 sprintf(dateBuf, more ? "%d *" : "%d", thisDay);
3892 x_print_string(gInfo, dateBuf, x1, y1, LEFT_AT_X | TOP_AT_Y);
3894 gInfo->u.monthInfo.lineY =
3895 y1 + cm_font_height(gInfo, gInfo->curFont) + VMARGIN(gInfo);
3899 x_print_month_appts(void *gInfoP, CSA_entry_handle *list,
3900 int a_total, int num_page,
3901 time_t hi_hour, int lines_per_box)
3903 CMGraphicsInfo *gInfo = (CMGraphicsInfo *)gInfoP;
3906 char buf1[BUFFERSIZE];
3907 Calendar *c = gInfo->c;
3908 Props *pr = (Props *)c->properties;
3909 int meoval = get_int_prop(pr, CP_PRINTPRIVACY);
3910 int i, start, pos = 1, line_counter = 0;
3911 CSA_return_code stat;
3912 Dtcm_appointment *appt;
3915 start = ((num_page - 1) * lines_per_box) + 1;
3917 appt = allocate_appt_struct(appt_read,
3918 c->general->version,
3919 CSA_ENTRY_ATTR_CLASSIFICATION_I,
3920 CSA_ENTRY_ATTR_START_DATE_I,
3921 CSA_ENTRY_ATTR_SUMMARY_I,
3922 CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
3924 for (i = 0; i < a_total; i++)
3926 stat = query_appt_struct(c->cal_handle, list[i], appt);
3927 if (stat != CSA_SUCCESS)
3929 free_appt_struct(&appt);
3933 _csa_iso8601_to_tick(appt->time->value->item.date_time_value, &start_tick);
3934 if (start_tick >= hi_hour)
3936 free_appt_struct(&appt);
3940 if ((privacy_set(appt) == CSA_CLASS_PUBLIC) &&
3941 !(meoval & PRINT_PUBLIC))
3943 if ((privacy_set(appt) == CSA_CLASS_CONFIDENTIAL) &&
3944 !(meoval & PRINT_SEMIPRIVATE))
3946 if ((privacy_set(appt) == CSA_CLASS_PRIVATE) &&
3947 !(meoval & PRINT_PRIVATE))
3956 get_time_str(appt, buf1);
3958 indented = (*buf1 != '\0');
3960 lines = text_to_lines(appt->what->value->item.string_value, 1);
3962 if ((line_counter > lines_per_box) && (lines != NULL))
3964 free_appt_struct(&appt);
3968 /* only print if appt text found */
3969 if ((lines != NULL) && (lines->s != NULL))
3971 if (indented) /* time found so print it */
3972 cm_print_month_time(gInfo, buf1);
3973 cm_print_month_text(gInfo, lines->s, indented ? 2 : 0);
3976 destroy_lines(lines);
3980 free_appt_struct(&appt);