Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtcm / dtcm / calendar.h
1 /*******************************************************************************
2 **
3 **  calendar.h
4 **
5 **  static char sccsid[] = "@(#)calendar.h 1.59 95/02/16 Copyr 1991 Sun Microsystems, Inc."; 
6 **
7 **  $TOG: calendar.h /main/5 1999/02/08 17:00:18 mgreess $
8 **
9 **  RESTRICTED CONFIDENTIAL INFORMATION:
10 **
11 **  The information in this document is subject to special
12 **  restrictions in a confidential disclosure agreement between
13 **  HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
14 **  document outside HP, IBM, Sun, USL, SCO, or Univel without
15 **  Sun's specific written approval.  This document and all copies
16 **  and derivative works thereof must be returned or destroyed at
17 **  Sun's request.
18 **
19 **  Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
20 **
21 *******************************************************************************/
22
23 /*                                                                      *
24  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
25  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
26  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
27  * (c) Copyright 1993, 1994 Novell, Inc.                                *
28  */
29
30 #ifndef _CALENDAR_H
31 #define _CALENDAR_H
32
33 #include <X11/Intrinsic.h>
34 #include <csa.h>
35 #include <nl_types.h>
36 #include <Xm/Xm.h>
37 #include "ansi_c.h"
38 #include "util.h"
39 #include "timeops.h"
40 #include "props.h"
41
42 /* from gettext.h */
43
44 #define MSGFILE_ERROR     "SUNW_DESKSET_CM_ERR"
45 #define MSGFILE_LABEL     "SUNW_DESKSET_CM_LABEL"
46 #define MSGFILE_MESSAGE   "SUNW_DESKSET_CM_MSG"
47
48 /* from graphics.h */
49
50 #define DARKGREY        1
51 #define DIMGREY         2
52 #define GREY            3
53 #define LIGHTGREY       4
54 #define RED                     5
55 #define MIDGREY 150
56
57 #define FAKE_MONOCHROME 1
58
59 #define DTCM_CAT        "dtcm"
60
61 typedef enum {gr_solid, gr_short_dotted, gr_dotted,
62               gr_dot_dashed, gr_short_dashed,
63               gr_long_dashed, gr_odd_dashed} GR_Line_Style;
64
65 typedef enum {gr_mono, gr_color} GR_depth;
66
67 typedef enum {BOLD, MEDIUM} Font_Weight;
68  
69 typedef enum {
70         yearGlance, monthGlance, weekGlance, dayGlance
71 } Glance;
72
73 typedef enum {
74         RENDER_REPAINT, RENDER_CLEAR_FIRST, RENDER_UNMAP
75 } Render_Type;
76
77 typedef struct {Tick    start_time;
78                 Tick    end_time;
79                 int     show_time;
80                 char    *summary;} Paint_cache;
81
82 typedef struct {
83         Pixel           foreground;     /* X Default Foreground Color */
84         Pixel           background;     /* X Default Background Color */
85         XID             xid;            /* XID */
86         Pixel           hilight_color;  /* Default hilight color */
87         /*Drawable        drawable;*/       /* X Drawable */
88         XtAppContext    app;
89         Display         *display;       /* X Display */
90
91         /*
92          * gc is a general purpose GC which is configured on the fly for
93          * infrequent operations.  For frequent operations we use one of
94          * the pre-configured GCs which we never change.
95          */
96         GC              gc;             /* X Graphics Context */
97         XGCValues       *gcvals;        /* X Graphics Context Values */
98         GC              draw_gc;        /* GC for drawing  */
99         GC              clear_gc;       /* GC for clearing */
100         GC              invert_gc;      /* GC for inverting */
101
102         int             screen_depth;   /* screen depth */
103         XColor          colorcell_del[RED+1];/* rgb colors */
104 } new_XContext;
105
106 typedef enum {
107         main_win, browser, tempbrowser
108 } WindowType;
109
110
111 typedef struct {
112         int                     nwks;
113         int                     boxh;
114         int                     boxw;
115         int                     winw;
116         int                     winh;
117         int                     outside_margin;
118         int                     inside_margin;
119         int                     topoffset;
120         time_t                  date;                   
121         time_t                  olddate;
122         Glance                  glance;
123         caddr_t                 day_info;       /* in dayglance.c */
124         caddr_t                 week_info;      /* in weekglance.c */
125         caddr_t                 month_info;     /* in monthglance.c */
126         caddr_t                 year_info;      /* in yearglance.c */
127         char*                   current_calendar; /* in calendarA.c */
128         CSA_reminder_reference  *next_alarm;    /* in appt.c */
129         CSA_uint32              next_alarm_count;
130         int                     rings;          /* number of rings to do in reminder */
131         int                     flashes;        /* number of flashes to do in reminder */
132         XtIntervalId            next_alarm_id;
133         caddr_t                 current_selection; /* in select.c */
134         char*                   wm_cmdstr;      /* WM_COMMAND format 
135                                                    version of argv list */
136         int                     wm_cmdstrlen;   /* Size of the wm_cmdstr 
137                                                    buffer */
138         char                    *sessionfile;   /* file name (if any)
139                                                    provided by -session 
140                                                    parameter */
141         XrmDatabase             sessiondb;      /* X database that is 
142                                                    constructed by the 
143                                                    session file */
144
145
146 } View;
147
148 typedef struct _Cal_Font {
149         XmFontType      cf_type;
150         union {
151                 XFontStruct     *cf_font;
152                 XFontSet         cf_fontset;
153         } f;
154 } Cal_Font;
155
156 typedef struct {
157         Cal_Font        *labelfont;
158         Cal_Font        *viewfont;
159         Cal_Font        *boldfont;
160         Cal_Font        *iconfont;
161         Cal_Font        *userfont;
162 } Cal_Fonts;
163
164 typedef struct {
165         Widget  panel;
166         Widget  button1;                /* unused       */
167         Widget  button2;                /* view button  */
168         Widget  button3;                /* edit button  */
169         Widget  button4;                /* browse button*/
170         Widget  button5;                /* print button */
171         Widget  button6;                /* unused       */
172         Widget  button7;                /* unused       */
173         Widget  button8;                /* prev button  */
174         Widget  button9;                /* today button */
175         Widget  button10;               /* next button  */
176         Widget  menu_bar;
177 } Items;
178
179 typedef struct {
180         int             rc_ts;                  /* timestamp of rc file: browse */
181         int             version;                /* version of cm  */
182         WindowType last_canvas_touched; /* either browser or main */
183 } General; 
184
185 /*
186  * Datatype for application-defined resources.  This is filled in by Xt during
187  * XtVaAppInitialize (for the cmdline args) and during XtGetApplicationResources
188  * for the app-defaults values.  An instance of this is carried around in
189  * calendar->app_data to provide access to properties data.
190  *
191  * Historical note: old properties (.desksetdefaults) should be mapped into
192  * this, and (if they need to be written out) taken form this.
193  */
194 typedef struct {
195         String          default_view;
196         String          default_calendar;
197         String          default_printer;
198         String          labelfont;
199         XmFontList      labelfontlist;
200         XmFontList      viewfontlist;
201         XmFontList      boldfontlist;
202         XmFontList      iconfontlist;
203         String          userfont;
204         XmFontList      userfontlist;
205         String          systemfont;
206         XmFontList      systemfontlist;
207         String          app_font_family;
208         String          session_file;
209         Boolean         debug;
210 } DtCmAppResources, *DtCmAppResourcesPtr;
211
212 typedef struct {
213         unsigned int    icon_width;
214         unsigned int    icon_height;
215         unsigned int    icon_depth;
216         Pixmap          icon;
217         Pixmap          icon_mask;
218 } IconInfo;
219
220 typedef struct {
221         nl_catd         DT_catd;        /* catgets file descriptor */
222         CSA_session_handle cal_handle;  /* browsing calendar rpc connection */
223         unsigned int    user_access;    /* access wrt current viewing cal */
224         CSA_session_handle my_cal_handle; /* my calendar's rpc connection */
225         unsigned int    my_access;
226         int             my_cal_version; /* my calendar rpc connection version */
227         Widget          frame;
228         Widget          panel;
229         Items           *items;
230         General         *general;       /* stuff general to the calendar */
231         Widget          form;           /* main container */
232         Widget          toolbar;        /* frame for toolbar */
233         Widget          canvas;         /* main canvas for graphics*/
234         Widget          menu_bar;       /* top of menu hierarchy */
235         Widget          browse_menu;    /* cached for quick access */
236         Widget          browse_button;  /* for updating browse menu */
237         Widget          message_text;   /* status at foot of main window */
238         Widget          previous;       /* arrow to step back in time */
239         Widget          today;          /* button to jump to "now" */
240         Widget          next;           /* arrow to step forward in time */
241         Widget          radio;          /* container for toolbar scope btns */
242         Widget          day_scope;      /* scope buttns in tool bar */
243         Widget          week_scope;
244         Widget          month_scope;
245         Widget          year_scope;
246         Widget          appt_btn;       /* Quick access to appt editor */
247         Widget          todo_btn;       /* Quick access to todo editor */
248         Widget          todo_edit_menu; /* Menu access to todo editor */
249         Widget          todo_view_menu; /* Menu access to todo list */
250         Widget          month1;         /* month panels in day view */
251         Widget          month2;
252         Widget          month3;
253         Widget          postup;         /* in alarm.c */
254         Widget          mainhelpdialog;
255         Widget          about_dialog;
256         Widget          credits_dialog;
257         View            *view;          /* cached info about current display */
258         DtCmAppResourcesPtr app_data;   /* Xt-populated, listed above */
259         caddr_t         properties;     /* in props.c */
260         caddr_t         properties_pu;  /* in props_pu.c */
261         caddr_t         editor;         /* in editor.c */
262         caddr_t         geditor;        /* in group_editor.c */
263         caddr_t         browser;        /* in browser.c */
264         caddr_t         browselist;     /* in blist.c */
265         caddr_t         todo;           /* in todo.c */
266         caddr_t         alist;          /* in alist.c */
267         caddr_t         print_opts;     /* in printer.c */
268         caddr_t         user;           /* calendar driver */
269         char*           calname;        /* calendar name */
270         new_XContext    *xcontext;      /* XID, Display, GC, GCVals */
271         caddr_t         find;           /* in find.c */
272         caddr_t         goTo;           /* in goto.c */
273         caddr_t         tempbr;         /* in tempbr.c */
274         caddr_t         mail;           /* in mail.c */
275         caddr_t         timezone;       /* in timezone.c */
276         caddr_t         print_data;     /* in print.c - valid when dialog up */
277         char            *tt_procid;     /* Tooltalk process id, used for 
278                                            tooltalk intiialization */
279         Paint_cache     *paint_cache;
280         int             paint_cache_size;
281         Cal_Fonts       *fonts;
282         IconInfo        *icon;
283         IconInfo        *icon_inverted;
284 } Calendar;
285
286 extern Calendar *calendar;
287 extern int _csa_iso8601_to_tick(char *, time_t*);
288 extern int _csa_tick_to_iso8601(time_t, char *);
289
290 #define MAXBUFLEN               4096
291
292 #define CMS_VERS_2  2
293 #define CMS_VERS_3  3
294 #define CMS_VERS_4  4
295
296 /* define to figure out if two XRectangle structures intersect each other */
297
298 #define myrect_intersectsrect(r1,r2) \
299         ((int)(r1)->x<=(int)(r2)->x+(int)(r2)->width && \
300         (int)(r1)->y<=(int)(r2)->y+(int)(r2)->height &&  \
301          (int)(r2)->x<=(int)(r1)->x+(int)(r1)->width && \
302          (int)(r2)->y<=(int)(r1)->y+(int)(r1)->height)
303
304
305 extern void             cache_dims              P((Calendar*, Dimension,
306                                                    Dimension));
307 extern char*            cm_get_relname          P(());
308 extern Boolean          in_range                P((time_t, time_t, time_t));
309 extern int              report_err              P((char*));
310 extern void             reset_alarm             P((Calendar*));
311 extern CSA_return_code  reset_timer             P((Calendar*));
312 extern CSA_return_code  paint_canvas            P((Calendar*, XRectangle*, 
313                                                    Render_Type));
314 extern void             switch_it               P((Calendar*, char*,
315                                                    WindowType));
316 extern int              yyyerror                P((char*));
317 extern void             gr_clear_area           P((new_XContext*, int, int,
318                                                    Dimension, Dimension));
319 extern void             gr_clear_box            P((new_XContext*, int, int, int,
320                                                    int));
321 extern void             gr_make_grayshade       P((new_XContext*, int, int, int,
322                                                    int, int));
323 extern void             gr_make_gray            P((new_XContext*, int, int, int,
324                                                    int, int));
325 extern void             gr_make_rgbcolor        P((new_XContext*, Colormap, int,
326                                                    int, int, int, int, int,
327                                                    int));
328 extern int              gr_nchars               P((int, char*, Cal_Font *));
329 extern void             gr_draw_rgb_box         P((new_XContext*, int, int, int,
330                                                    int, int, int, Colormap));
331 extern void             gr_dissolve_box         P((new_XContext*, int, int, int,
332                                                    int, int));
333 extern int              gr_center               P((int, char*, Cal_Font *));
334 extern void             gr_text                 P((new_XContext*, int, int,
335                                                    Cal_Font *, char*,
336                                                    XRectangle*));
337 extern void             gr_text_rgb             P((new_XContext*, int, int,
338                                                    Cal_Font *, char*, Pixel,
339                                                    Colormap, XRectangle*));
340 extern void             gr_draw_line            P((new_XContext*, int, int, int,
341                                                    int, GR_Line_Style,
342                                                    XRectangle*));
343 extern void             gr_draw_box             P((new_XContext*, int, int, int,
344                                                    int, XRectangle*));
345 extern void             gr_draw_glyph           P((new_XContext*, new_XContext*,
346                                                    Pixmap, int, int, int, int));
347 extern void             gr_set_clip_rectangles  P((new_XContext*, int, int,
348                                                    XRectangle*, int, int));
349 extern void             gr_clear_clip_rectangles P((new_XContext*));
350 extern Boolean          gr_init                 P((new_XContext*, Widget));
351 extern new_XContext     *gr_create_xcontext     P((Calendar*, Widget, GR_depth,
352                                                    XtAppContext));
353 extern Boolean          today_inrange           P((Calendar*, time_t));
354 extern void             update_browse_menu_names P((Calendar*));
355 extern char*            get_user_calendar       P(());
356 extern void             destroy_paint_cache     P((Paint_cache *, int));
357 extern void             invalidate_cache        P((Calendar *));
358
359 extern CSA_return_code  allocate_paint_cache    P((CSA_entry_handle *, int, Paint_cache **));
360
361 extern Boolean          fontlist_to_font        P((XmFontList, Cal_Font *));
362 extern void             CalTextExtents          P((Cal_Font *, char *, int, 
363                                                    int *, int *, int *, int *));
364 extern void             CalDrawString           P((Display *, Drawable,
365                                                    Cal_Font *, GC, int, int,
366                                                    char *, int));
367 extern void             CalFontExtents          P((Cal_Font *, 
368                                                    XFontSetExtents *));
369 #endif