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