ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/crossedit/CrUtil.c
Revision: 1.3
Committed: Sun Aug 13 17:16:01 2006 UTC (17 years, 9 months ago) by elmex
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
Made server compile with C++.
Removed cfanim plugin and crossedit.
C++ here we come.

File Contents

# Content
1 #include <Defines.h>
2 #include <global.h>
3 #include <debug.h>
4 #include <X11.h>
5 #include <CrUtil.h>
6
7
8 extern Pixmap *pixmaps; /* list of pixmaps */
9 extern Pixmap *masks; /* list of pixmaps */
10
11
12
13 /* Draw one of the tiles in a (potentially big) face.
14 *
15 * w, gc - Where you want to paint the face, um.
16 * x, y - The pixel co-ordinates of w where you want the face to appear.
17 *
18 * x_offset, y_offset:
19 *
20 * Which part of the big face you want to draw; how many tiles down and
21 * right from the head you want to offset into the face.
22 *
23 * If you want to draw the bottom-right corner of a 2 wide, 3 tall face,
24 * provide x_offset y_offset 1, 2.
25 *
26 * If you want the top-left corner or are drawing a single-tile face,
27 * give 0, 0.
28 */
29 void DrawFacePart (
30 Widget w, GC gc, New_Face * face, int x, int y,
31 int x_offset, int y_offset
32 ) {
33 int num = face->number;
34
35 if (displaymode == Dm_Png) {
36 XSetClipMask(XtDisplay(w), gc, masks[num]);
37 /* On the other hand, x and y will be bigger, so the mask will be in
38 the right place. */
39 XSetClipOrigin(XtDisplay(w), gc,
40 x - FontSize * x_offset,
41 y - FontSize * y_offset);
42 XCopyArea(XtDisplay(w), pixmaps[num], XtWindow(w), gc,
43 FontSize * x_offset, FontSize * y_offset,
44 FontSize, FontSize,
45 x, y);
46 }
47 }
48
49 /* Draws one tile of op on w, gc at pixel (x, y).
50 *
51 * This does the Right Thing with multi-tile objects: It paints the
52 * particular part of the face when op is not the head, even for a big face.
53 *
54 * When op has a big face, DrawPartObject() calculates the offset to the
55 * head to draw the right part of the big face for op.
56 */
57 void DrawPartObject(Widget w, GC gc, object * op, int x, int y) {
58
59 int x_offset = 0, y_offset = 0;
60
61 if (op->head != NULL) {
62 if (op->face == op->head->face) {
63 /* We're not the head, but we've got the same face. Therefore,
64 we've got a big face; get the offset in tiles. */
65 x_offset = op->x - op->head->x;
66 y_offset = op->y - op->head->y;
67 }
68 }
69
70 DrawFacePart(w, gc,
71 op->face,
72 x, y,
73 x_offset, y_offset);
74 }
75
76 /*
77 *Function: GCCreate
78 *Member-Of: Cr
79 *Description:
80 * Create suitable GC for Cr widgets.
81 *Commentary:
82 * There are inplicit use of use_pixmaps and color_pix, that should
83 * be removed by better structuring of program.
84 */
85 GC GCCreate (Widget w) {
86 GC gc;
87 gc= XtAllocateGC (w, 0, 0L, NULL, GCBackground | GCForeground, 0);
88 XSetGraphicsExposures(XtDisplay(w), gc, False);
89 return gc;
90 }
91
92