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