~ubuntu-branches/ubuntu/wily/xpenguins-applet/wily

« back to all changes in this revision

Viewing changes to src/toon.h

  • Committer: Bazaar Package Importer
  • Author(s): Bas Zoetekouw
  • Date: 2001-07-21 16:59:06 UTC
  • Revision ID: james.westby@ubuntu.com-20010721165906-b3mgcd0blpwvud8d
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* toon.h - functions for drawing cartoons on the root window
 
2
 * Copyright (C) 1999-2001  Robin Hogan
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 */
 
18
 
 
19
#include <X11/Intrinsic.h>
 
20
#include <X11/Xlib.h>
 
21
#include <X11/Xos.h>
 
22
#include <X11/xpm.h>
 
23
#include <X11/extensions/shape.h>
 
24
 
 
25
#define TOON_UNASSOCIATED -2
 
26
#define TOON_HERE -1
 
27
#define TOON_LEFT 0
 
28
#define TOON_RIGHT 1
 
29
#define TOON_UP 2
 
30
#define TOON_DOWN 3
 
31
 
 
32
#define TOON_FORCE 1
 
33
#define TOON_MOVE 0
 
34
#define TOON_STILL -1
 
35
 
 
36
#define TOON_OK 1
 
37
#define TOON_PARTIALMOVE 0
 
38
#define TOON_BLOCKED -1
 
39
#define TOON_SQUASHED -2
 
40
 
 
41
/* General configuration options */
 
42
#define TOON_DEFAULTS 0L
 
43
 
 
44
#define TOON_NOEDGEBLOCK (1L<<0)
 
45
#define TOON_EDGEBLOCK (1L<<1)
 
46
#define TOON_SIDEBOTTOMBLOCK (1L<<2)
 
47
#define TOON_NOSOLIDPOPUPS (1L<<4)
 
48
#define TOON_SOLIDPOPUPS (1L<<5)
 
49
#define TOON_NOSHAPEDWINDOWS (1L<<6)
 
50
#define TOON_SHAPEDWINDOWS (1L<<7)
 
51
 
 
52
#define TOON_NOCATCHSIGNALS (1L<<16)
 
53
#define TOON_CATCHSIGNALS (1L<<17)
 
54
#define TOON_EXITGRACEFULLY (1L<<18)
 
55
 
 
56
/* Configuration for individual toon types */
 
57
#define TOON_NOCYCLE (1L<<0)
 
58
#define TOON_INVULNERABLE (1L<<1)
 
59
#define TOON_NOBLOCK (1L<<2)
 
60
 
 
61
#define TOON_MESSAGE_LENGTH 128
 
62
#define TOON_DEFAULTMAXRELOCATE 8
 
63
 
 
64
/*** STRUCTURES ***/
 
65
 
 
66
/* The ToonData structure describes the properties of a type of toon,
 
67
 * such as walker, climber etc. */
 
68
 
 
69
typedef struct __ToonData ToonData;
 
70
 
 
71
struct __ToonData {
 
72
  unsigned long int conf; /* bitmask of toon properties such as cycling etc */
 
73
  char **image;
 
74
  char *filename; /* Name of image file name */
 
75
  ToonData *master; /* If pixmap data is duplicated from another toon, this is it */
 
76
  Pixmap pixmap, mask; /* pointers to X structures */
 
77
  unsigned int nframes; /* number of frames in image */
 
78
  unsigned int ndirections; /* number directions in image (1 or 2) */
 
79
  unsigned int width, height; /* width & height of individual frame/dir */
 
80
  unsigned int acceleration, speed, terminal_velocity;
 
81
  int loop; /* Number of times to repeat cycle */
 
82
  char exists;
 
83
};
 
84
 
 
85
/* The Toon structure describes the properties of a particular toon,
 
86
 * such as its location and speed */
 
87
 
 
88
typedef struct {
 
89
  int x, y, u, v; /* new position and velocity */
 
90
  unsigned int genus, type, frame, direction;
 
91
  int x_map, y_map;
 
92
  unsigned int width_map, height_map;
 
93
    /* properties of the image mapped on the screen */
 
94
  unsigned int associate; /* toon is associated with a window */
 
95
  int xoffset, yoffset; /* location relative to window origin */
 
96
  unsigned int wid; /* window associated with */
 
97
  unsigned int cycle; /* Number of times frame cycle has repeated */
 
98
  char pref_direction;
 
99
  char pref_climb;
 
100
  char hold;
 
101
  char active;
 
102
  char terminating;
 
103
} Toon;
 
104
 
 
105
/*** INTERNAL STRUCTURES AND FUNCTION PROTOTYPES ***/
 
106
typedef struct {
 
107
  int solid;
 
108
  unsigned int wid;
 
109
  XRectangle pos;
 
110
} __ToonWindowData;
 
111
typedef int __ToonErrorHandler();
 
112
void __ToonSignalHandler(int sig);
 
113
int __ToonError(Display *toon_display, XErrorEvent *error);
 
114
void __ToonExitGracefully(int sig);
 
115
 
 
116
/* OK, OK, global variables are gross but it makes the interface easier,
 
117
 * and we're unlikely to want to two threads in the same program writing
 
118
 * to two different screens */
 
119
extern Display *toon_display;
 
120
extern Window toon_root; /* the window to draw to */
 
121
extern Window toon_parent; /* the parent window of all the client windows */
 
122
extern Window toon_root_override; /* override both toon_root and toon_parent */
 
123
extern int toon_x_offset, toon_y_offset; /* toon_root relative to toon_parent */
 
124
extern int toon_display_width, toon_display_height;
 
125
extern GC toon_drawGC;
 
126
extern Region toon_windows;
 
127
extern unsigned int toon_nwindows;
 
128
extern __ToonWindowData *toon_windata;
 
129
extern ToonData **toon_data;
 
130
extern int toon_ngenera;
 
131
extern int toon_ntypes;
 
132
extern int toon_errno;
 
133
extern char toon_edge_block;
 
134
extern char toon_shaped_windows;
 
135
extern char toon_solid_popups;
 
136
extern int toon_signal;
 
137
extern char toon_error_message[TOON_MESSAGE_LENGTH];
 
138
extern char toon_message[TOON_MESSAGE_LENGTH];
 
139
extern int toon_max_relocate_up;
 
140
extern int toon_max_relocate_down;
 
141
extern int toon_max_relocate_left;
 
142
extern int toon_max_relocate_right;
 
143
 
 
144
/*** FUNCTION PROTOTYPES ***/
 
145
 
 
146
/* HANDLE STRANGE WINDOW MANAGERS (toon_root.c) */
 
147
Window ToonGetRootWindow(Display *display, int screen,
 
148
                         Window *clientparent);
 
149
 
 
150
/* SIGNAL AND ERROR HANDLING FUNCTIONS (toon_signal.c) */
 
151
int ToonSignal();
 
152
char *ToonErrorMessage();
 
153
 
 
154
/* STARTUP FUNCTIONS (toon_init.c) */
 
155
Display *ToonOpenDisplay(char *display_name);
 
156
int ToonInit(Display *display);
 
157
int ToonConfigure(unsigned long int code);
 
158
int ToonInstallData(ToonData **data, int ngenera, int ntypes);
 
159
#define ToonSetRoot(id) toon_root_override = (Window) id
 
160
 
 
161
/* FINISHING UP (toon_end.c) */
 
162
int ToonFinishUp();
 
163
int ToonFreeData();
 
164
int ToonCloseDisplay();
 
165
 
 
166
/* DRAWING FUNCTIONS (toon_draw.c) */
 
167
int ToonDraw(Toon *toon,int n);
 
168
int ToonErase(Toon *toon,int n);
 
169
void ToonFlush();
 
170
 
 
171
/* QUERY FUNCTIONS (toon_query.c) */
 
172
#define ToonDisplayWidth() (toon_display_width)
 
173
#define ToonDisplayHeight() (toon_display_height)
 
174
int ToonBlocked(Toon *toon, int direction);
 
175
int ToonOffsetBlocked(Toon *toon, int xoffset, int yoffset);
 
176
int ToonWindowsMoved();
 
177
 
 
178
/* ASSIGNMENT FUNCTIONS (toon_set.c) */
 
179
void ToonMove(Toon *toon, int xoffset, int yoffset);
 
180
void ToonSetPosition(Toon *toon, int x, int y);
 
181
void ToonSetGenusAndType(Toon *toon, int genus, int type, int direction,
 
182
                         int gravity);
 
183
#define ToonSetType(toon, type, direction, gravity) \
 
184
     ToonSetGenusAndType(toon, (toon)->genus, type, direction, gravity)
 
185
void ToonSetVelocity(Toon *toon, int u, int v);
 
186
 
 
187
/* CORE FUNCTIONS (toon_core.c) */
 
188
int ToonAdvance(Toon *toon, int mode);
 
189
int ToonLocateWindows();
 
190
int ToonSleep(unsigned long usecs);
 
191
 
 
192
/* HANDLING TOON ASSOCIATIONS WITH MOVING WINDOWS (toon_associate.c) */
 
193
void ToonSetAssociation(Toon *toon, int direction);
 
194
void ToonSetMaximumRelocate(int up, int down, int left, int right);
 
195
int ToonRelocateAssociated(Toon *toon, int n);
 
196
int ToonCalculateAssociations(Toon *toon, int n);
 
197
 
 
198