1 /*
2    XMascot Ver 2.6
3    Copyright(c) 1996,1997 Go Watanabe     go@cclub.tutcc.tut.ac.jp
4                           Tsuyoshi IIda   iida@cclub.tutcc.tut.ac.jp
5 */
6 
7 #ifndef __XMASCOT
8 #define __XMASCOT
9 
10 #include <X11/Xlib.h>
11 #include <X11/Intrinsic.h>
12 #include <X11/IntrinsicP.h>
13 #include <X11/StringDefs.h>
14 #include <X11/Xaw/Label.h>
15 
16 #include "image.h"
17 
18 #define	I2P(n)	((void *)(uintptr_t)(n))
19 
20 #define CHAIN_SIZE 8
21 
22 #define DT 100				/* ���ߥ�졼�������� */
23 
24 #ifdef USE_DOUBLE
25 #define ANGLE_PI (M_PI)
26 #else
27 /* isin.c */
28 void isin_init(void);
29 int isin(int deg);
30 int icos(int deg);
31 #define ANGLE_PI (M_PI*256)
32 #endif
33 
34 #define ROLL_DEG  (ANGLE_PI/32)
35 #define RAD       (M_PI/ANGLE_PI)
36 
37 #define ALARM_NUM 3							/* ���顼��ο�     */
38 #define ALARM_ALLNUM (ALARM_NUM+4)			/* ���顼���Ϣ��� */
39 #define XtRRgb	"Rgb"
40 
41 /* �ޥ����åȹ�¤�� */
42 typedef struct{
43 	Widget entry;
44 	String title;		/* �ޥ����å�̾�� */
45 	String fname;		/* �ե�����̾     */
46 	int    col0;		/* Ʃ����(pixel)  */
47 	int    rgb0;		/* Ʃ����(rgb)    */
48 	float  mmag;		/* ����Ψ */
49 #ifdef SOUND
50 	String start_snd;	/* ��ư�������   */
51 	String click_snd;   /* ����å�������� */
52 	String end_snd;		/* ��λ�������   */
53 #ifdef BIFF
54 	String mail_snd;	/* �᡼���忮������� */
55 #endif
56 #endif
57 #ifdef BIFF
58 	XtJustify biff_justify;	/* �᡼������ޡ������� */
59 #endif
60 } Mascot;
61 
62 /* �ޥ����åȥ�˥塼��¤�� */
63 typedef struct{
64 	String title;		/* ��˥塼̾��     */
65 	int n_mascots;		/* �ޥ����å����   */
66 	Mascot *mascots;	/* �ޥ����åȹ�¤�� */
67 } MascotMenu;
68 
69 /* ���顼�๽¤�� */
70 typedef struct{
71 	int sw;				/* ���顼���ͭ������ */
72 	int hour;			/* ���顼�� ����      */
73 	int min;			/*          ʬ        */
74 	String action;		/* ���顼�ॢ������� */
75 	XtIntervalId id;	/* ������ ID        */
76 } Alarm;
77 
78 /* XMascot ���ܹ�¤�� */
79 typedef struct{
80 	Boolean	verbose;		/* �ܺ�ɽ��   				*/
81 	int 	grav;			/* �������   				*/
82 	int 	chain_len;		/* ����Ĺ��   				*/
83 	float 	f_damping;		/* ���그��   				*/
84 	double	damping;
85 	float	magnify;		/* ����Ψ					*/
86 	String 	search_path; 	/* �������ѥ� 				*/
87 	String	pin_pat;		/* �ԥ�Υѥ�����ե�����   */
88 	int		pcol0;			/* �ԥ��Ʃ��������ǥå��� */
89 	int		prgb0;			/* �ԥ��Ʃ���� RGB         */
90 	int		chain_num;		/* ���ο� 					*/
91 	int		draw_timing;	/* �������� 				*/
92 #ifdef USE_CHAINPAT
93 	String	chain_pat;		/* ɳ(��)�Υѥ�����ե�����     */
94 	int		ccol0;			/* ɳ(��)��Ʃ��������ǥå���   */
95 	int		crgb0;			/* ɳ(��)��Ʃ���� RGB           */
96 #endif
97 	int		menus_num;		/* ��˥塼����� */
98 	int     menu_no;		/* ��ư����˥塼�ֹ�   */
99 	int 	no;				/* ��ư���ޥ����å��ֹ� */
100 	String	def_act;		/* �ǥե���ȤΥ������������ */
101 	int     th;				/* �������  */
102 	Boolean random;			/* ����饯���Υ������ѹ� */
103 	int		change_time;	/* ���ؤޤǤλ��� (ʬ����)  */
104 	Boolean all_menu;		/* ���ؤ�����˥塼         */
105 #ifdef BIFF
106 	Boolean biff_mode;		/* biff ��ͭ������   */
107 	String  biff_action;	/* biff �Υ�������� */
108 	int	    biff_update;	/* biff �����ֳ�     */
109 	Boolean biff_once;  	/* �������������������� */
110 	String  biff_cmd;		/* �ᥤ����������å����ޥ�� */
111 	String	biff_pat;		/* biff ����ޡ����ѥ�����ե�����           */
112 	String  biff_filter;	/* biff �᡼�����ɽ���ѥե��륿             */
113 	int     biff_popdown;	/* biff ������᡼������ξä���ޤǤλ���   */
114 	int		bcol0;			/* biff ����ޡ����ѥ�����Ʃ��������ǥå��� */
115 	int		brgb0;			/* biff ����ޡ����ѥ�����Ʃ���� RGB         */
116 #ifdef YOUBIN
117 	char *server;			/* youbin server �ۥ���̾ */
118 	int   youbin;			/* youbin �⡼�ɤ��ɤ���  */
119 #endif
120 #endif
121 #ifdef SOUND
122 	String snd_cmd;			/* ���������ѥ��ޥ�� */
123 #endif
124 #ifdef SHADOW
125 	int		shadow;			/* �Ƥ��� */
126 #endif
127 	Cursor cursor_normal;
128 	Cursor cursor_click;
129 	Cursor cursor_drag;
130 
131 /* XMascot �ǡ����� */
132 	MascotMenu *mascot_menus;	/* �ޥ����åȥ�˥塼��¤�� */
133 	int      mascot_number;		/* ������Υޥ����å�		 */
134 	int		 chain_disp_num;
135 
136 
137 } XMascotData, AppData, *AppDataPtr;
138 
139 typedef enum {
140 	SOUND_START, SOUND_END, SOUND_CLICK, SOUND_MAIL
141 } SoundType;
142 
143 /* menu.c */
144 
145 void menu_add_line(Widget menu);
146 Widget menu_add_cascade(Widget menu,char *title,Widget cascade);
147 Widget menu_add_dialog(Widget menu,char *title,Widget dialog);
148 Widget menu_add_callback(Widget menu,char *title,XtCallbackProc callback);
149 
150 Widget change_menu(Widget top,int n);
151 Widget preference_dialog(Widget top);
152 Widget alarm_dialog(Widget top);
153 Widget about_dialog(Widget top);
154 void set_new_string(String *s, String new);
155 
156 /* resource.c */
157 void set_sim_param(void);
158 void get_resources(Widget top);
159 void usage(int *argc, char **argv);
160 
161 /* etc.c */
162 #include "etc.h"
163 
164 /* pattern.c */
165 void set_mas(XMascotData *adat);
166 void set_widget_pattern(Widget w,char *name,int c,int r);
167 void set_chain_pat(char *name, int c, int r);
168 
169 /* timer.c */
170 void start_timer(void);
171 void stop_timer(void);
172 void restart_timer(void);
173 
174 /* action.c */
175 
176 void change_mascot(Widget w,XtPointer dat,XtPointer call);
177 void change_mascot_with_sound(Widget w,XtPointer dat,XtPointer call);
178 
179 void RaiseAll(void);
180 void ExitApp(void);
181 void Quit(Widget w,XEvent *e,String *p,Cardinal *n);
182 void QuitMsg(Widget w,XEvent *e,String *p,Cardinal *n);
183 void MapWin(Widget w,XEvent *e,String *p,Cardinal *n);
184 void UnMapWin(Widget w,XEvent *e,String *p,Cardinal *n);
185 void ConfigWin(Widget w,XEvent *e,String *p,Cardinal *n);
186 void Press(Widget w,XEvent *e,String *p,Cardinal *n);
187 void ReleasePin(Widget w,XEvent *e,String *p,Cardinal *n);
188 void ReleaseMascot(Widget w,XEvent *e,String *p,Cardinal *n);
189 void MotionPin(Widget w,XEvent *e,String *p,Cardinal *n);
190 void MotionMascot(Widget w,XEvent *e,String *p,Cardinal *n);
191 
192 void Sound(Widget w,XEvent *e,String *p,Cardinal *n);
193 void SoundStart(Widget w,XEvent *e,String *p,Cardinal *n);
194 void SoundClick(Widget w,XEvent *e,String *p,Cardinal *n);
195 void SoundEnd(Widget w,XEvent *e,String *p,Cardinal *n);
196 void SoundMail(Widget w,XEvent *e,String *p,Cardinal *n);
197 
198 void ChangeMascot(Widget w,XEvent *e,String *p,Cardinal *n);
199 void ChangeMascotFile(Widget w,XEvent *e,String *p,Cardinal *n);
200 void ChangeMascotNext(Widget w,XEvent *e,String *p,Cardinal *n);
201 void ChangeMascotNextAll(Widget w,XEvent *e,String *p,Cardinal *n);
202 void ChangeMascotRandom(Widget w,XEvent *e,String *p,Cardinal *n);
203 void ChangeMascotRandomAll(Widget w,XEvent *e,String *p,Cardinal *n);
204 
205 void StartMove(Widget w,XEvent *e,String *p,Cardinal *);
206 void System(Widget w,XEvent *e,String *p,Cardinal *n);
207 void ChangeParam(Widget w,XEvent *e,String *p,Cardinal *n);
208 void Bell(Widget w,XEvent *e,String *p,Cardinal *n);
209 
210 /* sim.c */
211 void reset_pos(void);
212 void set_pos(void);
213 void sim(void);
214 
215 #ifdef SOUND
216 /* sound.c */
217 void sound_play(char *name);
218 void sounds_play(char **names,int num);
219 void xmascot_sound(XMascotData *adat, SoundType num);
220 #endif
221 
222 #ifdef BIFF
223 /* biff.c */
224 
225 void set_biff(void);
226 
227 void ShowBiffNotice(Widget w,XEvent *e,String *p,Cardinal *n);
228 void BiffEnter(Widget w,XEvent *e,String *p,Cardinal *n);
229 
230 #endif
231 
232 /* alarm.c */
233 void set_alarms(void);
234 
235 /* file.c */
236 void get_rcfile(void);
237 void put_rcfile(void);
238 void action_parse(char *action);
239 
240 typedef enum {
241 	NODAT, STRING, ID, SYMBOL, RESERVE
242 } TokenType;
243 
244 void set_token(char *p);
245 int get_token2(void);
246 
247 /* main.c */
248 void create_chains(int num);
249 
250 #endif
251 
252