386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / gdevx.h
CommitLineData
b6b26c6d
WJ
1/* Copyright (C) 1989, 1992 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies. */
19
20/* gdevx.h */
21/* Header file with X device structure */
22/* Requires gxdevice.h and x_.h */
23
24/* Define the type of an X pixel. */
25typedef unsigned long x_pixel;
26
27/*
28 * We have two alternatives in mapping between X pixel values and
29 * Ghostscript gx_color_index values. If we make them the same,
30 * Ghostscript will get confused if there is an X pixel value
31 * corresponding to gx_no_color_index. If we make them different,
32 * we have to keep some kind of map, with all the associated bookkeeping.
33 *
34 * We opt for the first solution. When we open the device,
35 * we check whether black or white maps to gx_no_color_index.
36 * (Since gx_no_color_index is all 1's, we assume no other color
37 * could have this pixel value.) If this is the case, we xor all
38 * pixel values with a value chosen so that no pixel value will map
39 * to gx_no_color_index.
40 */
41#define pixel_to_color_index(px) ((px) ^ xdev->pixel_fix)
42#define color_index_to_pixel(ci) ((ci) ^ xdev->pixel_fix)
43
44/* Define a rectangle structure for update bookkeeping */
45typedef struct rect_s {
46 int xo, yo, xe, ye;
47} rect;
48
49/* Define the X Windows device */
50typedef struct gx_device_X_s {
51 gx_device_common;
52
53 /* An XImage object for writing bitmap images to the screen */
54 XImage image;
55
56 /* Global X state */
57 Display *dpy;
58 Screen *scr;
59 XVisualInfo *vinfo;
60 Colormap cmap;
61 Window win;
62 GC gc;
63
64 /* A backing pixmap so X will handle exposure automatically */
65 Pixmap bpixmap; /* 0 if use_backing is false, */
66 /* or if it can't be allocated */
67 int ghostview; /* flag to tell if ghostview is in control */
68 Window mwin; /* window to receive ghostview messages */
69/* Don't include standard colormap stuff for X11R3 and earlier */
70#if HaveStdCMap
71 XStandardColormap *std_cmap; /* standard color map if available */
72#endif
73 gs_matrix initial_matrix; /* the initial transformation */
74 Atom next, page, done; /* Atoms used to talk to ghostview */
75 rect update; /* region needing updating */
76 long up_area; /* total area of update */
77 /* (always 0 if no backing pixmap) */
78 int up_count; /* # of updates since flush */
79 Pixmap dest; /* bpixmap if non-0, else win */
80 x_pixel colors_or; /* 'or' of all device colors used so far */
81 x_pixel colors_and; /* 'and' ditto */
82
83 /* An intermediate pixmap for the stencil case of copy_mono */
84 struct {
85 Pixmap pixmap;
86 GC gc;
87 int raster, height;
88 } cp;
89
90 /* Structure for dealing with the halftone tile. */
91 /* Later this might become a multi-element cache. */
92 struct {
93 Pixmap pixmap;
94 Pixmap no_pixmap; /* kludge to get around X bug */
95 gx_bitmap_id id;
96 int width, height, raster;
97 x_pixel fore_c, back_c;
98 } ht;
99
100 /* Cache the function and fill style from the GC */
101 int function;
102 int fill_style;
103
104#define set_fill_style(style)\
105 if ( xdev->fill_style != style )\
106 XSetFillStyle(xdev->dpy, xdev->gc, (xdev->fill_style = style))
107#define set_function(func)\
108 if ( xdev->function != func )\
109 XSetFunction(xdev->dpy, xdev->gc, (xdev->function = func))
110
111 /* Map color indices to X pixel values */
112 unsigned long pixel_fix;
113 x_pixel colors[8]; /* primary colors */
114#define pixel_black xdev->colors[0]
115#define pixel_white xdev->colors[7]
116 x_pixel back_color, fore_color;
117
118#define note_color(pixel)\
119 xdev->colors_or |= pixel,\
120 xdev->colors_and &= pixel
121#define set_back_color(pixel)\
122 if ( xdev->back_color != pixel )\
123 { xdev->back_color = pixel;\
124 note_color(pixel);\
125 XSetBackground(xdev->dpy, xdev->gc, pixel);\
126 }
127#define set_fore_color(pixel)\
128 if ( xdev->fore_color != pixel )\
129 { xdev->fore_color = pixel;\
130 note_color(pixel);\
131 XSetForeground(xdev->dpy, xdev->gc, pixel);\
132 }
133
134} gx_device_X;
135
136/* Default window size */
137#define DEFAULT_WIDTH_INCHES 8.5
138#define DEFAULT_HEIGHT_INCHES 11
139
140/* Define a fake value for X and Y resolution, */
141/* so an uninitialized value can be detected easily. */
142#define FAKE_RES 2 /* easily detected fake value */