1 /*
2  *  Copyright (C) 1998-2000 by Marco G"otze.
3  *
4  *  This code is part of the wmpinboard source package, which is
5  *  distributed under the terms of the GNU GPL2.
6  */
7 
8 #ifndef WMPINBOARD_H_INCLUDED
9 #define WMPINBOARD_H_INCLUDED
10 
11 #include <time.h>
12 
13 #include <X11/Xlib.h>
14 #include <X11/Xutil.h>
15 
16 #ifdef HAVE_CONFIG_H
17 #include <config.h>
18 #endif
19 
20 #define MAX_NOTES 20  /* maximal number of notes */
21 
22 #define STRING_BUF_SIZE 128  /* size of buffers for font descr. & suchlike */
23 
24 #define C_NUM 20                   /* number of colors */
25 #define C_INNER palette[C_NUM].fg  /* mask color (interior of notes etc.) */
26 #define C_OUTER palette[C_NUM].bg  /* mask color (exterior of notes etc.) */
27 #define C_EXTRA palette[C_NUM].cr  /* additional mask color */
28 
29 /* program modes with respect to interactive behavior... */
30 typedef enum {
31   M_NOOP,  /* "normal" mode (pinboard view) */
32   M_EDIT,  /* edit mode */
33   M_MOVE,  /* note being dragged (implies M_NOOP) */
34   M_BBAR,  /* button bar being displayed (implies M_EDIT) */
35   M_DRAW,  /* sketch mode, drawing (implies M_EDIT) */
36   M_ERAS,  /* sketch mode, erasing (implies M_EDIT) */
37   M_ALRM   /* alarm active */
38 } modes;
39 
40 typedef enum {
41   /* command line actions */
42   A_DUMP,       /* "cooked" dump */
43   A_DUMP_RAW,   /* raw dump */
44   A_IRON,       /* "iron" notes */
45   A_DEL,        /* delete a now */
46   A_ADD,        /* add "cooked" */
47   A_ADD_RAW,    /* add raw */
48   A_EXPORT,     /* export sketch */
49   /* configuration options */
50   C_FONT,       /* change font */
51   C_THEME,      /* change board/panel pixmap */
52   C_ALARM_CMD,  /* change alarm command */
53   /* miscellani */
54   M_INFO        /* prints miscellanous information */
55 } actions;
56 
57 #define PANEL_ANI_INT  2000L  /* usecs interval for panel animation */
58 #define NOTE_ANI_INT  15000L  /* usecs interval for note animation */
59 
60 #define DCLICK_LIMIT 500  /* ms */
61 
62 #define FUNSTUFF
63 
64 typedef enum {
65   ALARM_ON   = 1<<0,
66   ALARM_DATE = 1<<1
67 } alarm_flags_e;
68 
69 typedef struct {
70   int col;
71   int x, y;
72   char text[10*6];
73   int cursor;
74   char sketch[(64/8)*64];   /* bitfield; last byte used for other purposes... */
75   char creases[(16/8)*16];  /* lower-res bitfield representing creases */
76   time_t a_time;            /* alarm time */
77   unsigned char a_flags;    /* alarm flags */
78 } data_t;
79 
80 typedef struct {
81   unsigned long fg, bg, cr;  /* foreground, background, crease color */
82 } palette_t;
83 
84 typedef struct {  /* options and parameters */
85   char *name;          /* the program's file name (argv[0]) */
86   char *display;       /* alternate X display to connect to */
87   int click_to_focus;  /* true if keyboard focus requires a click */
88   int window_state;    /* NormalState, WithdrawnState? */
89   int timeout;         /* timeout value in seconds */
90   int animate;         /* use animations? */
91   char font[STRING_BUF_SIZE];       /* font descriptor to remember */
92   char theme[STRING_BUF_SIZE];      /* theme file to remember */
93   char alarm_cmd[STRING_BUF_SIZE];  /* alarm command */
94 } opts_t;
95 
96 typedef struct {  /* program state information */
97   GC sketchGC;             /* temporary GC in sketch mode */
98   XComposeStatus compose;  /* keyboard compose status */
99   int clicks_count;        /* while emulating click-based focusing */
100   int cur_note;            /* note currently being processed */
101   int moved;               /* true if a note was *moved* (not just raised) */
102   int button, dx, dy;      /* mouse-related stuff */
103   modes mode;              /* program's current mode of operation */
104   int bbar_pressed;        /* *pressed* panel button */
105   int abar_pressed;        /* area on alarm panel that last received a click */
106   int insert;              /* insert state in edit mode? */
107   int selecting;           /* selection in progress? */
108   int sel_from, sel_to;    /* used when selecting text via the mouse */
109   int lp_btn;              /* button last pressed */
110   Time lp_time;            /* time the last button was *pressed* */
111   time_t idle;             /* for the timeout feature */
112   volatile int alarmed;    /* used in animation timing */
113   unsigned int state_bits; /* bit vector with special information */
114   int raw_paste;           /* next paste to be raw? */
115   int counter;             /* total number of notes ever created */
116   struct {
117     time_t time;           /* time_t of next alarm that's due */
118     int note;              /* note that alarm.time is set for */
119     int run;               /* true if the specified alarm was run */
120     int phase;             /* phase of the animation */
121     Pixmap buffer;         /* buffer for the animation phases */
122   } alarm;
123   unsigned char a_edit[5]; /* hour, minute, month, day, year being edited */
124 } state_t;
125 
126 extern Display *display;
127 extern Window win;
128 extern XImage *img;
129 extern Pixmap app, bbar, abar, digits;
130 extern GC normalGC, fontGC, fillGC;
131 #ifdef CREASES
132 extern GC creaseGC;
133 #endif
134 extern XFontStruct *font;
135 
136 extern const char c_group[C_NUM];
137 extern int notes_count;
138 extern data_t ndata[MAX_NOTES];
139 extern palette_t palette[C_NUM+1];
140 extern state_t state;
141 
142 #endif  /* WMPINBOARD_H_INCLUDED */
143 
144