| 29338 |
ripley |
1 |
/*
|
|
|
2 |
* R : A Computer Language for Statistical Data Analysis
|
|
|
3 |
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
|
| 58977 |
ripley |
4 |
* Copyright (C) 1997--2008 The R Core Team
|
| 29338 |
ripley |
5 |
*
|
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
9 |
* (at your option) any later version.
|
|
|
10 |
*
|
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
14 |
* GNU General Public License for more details.
|
|
|
15 |
*
|
|
|
16 |
* You should have received a copy of the GNU General Public License
|
| 42307 |
ripley |
17 |
* along with this program; if not, a copy is available at
|
|
|
18 |
* http://www.r-project.org/Licenses/
|
| 29338 |
ripley |
19 |
*/
|
|
|
20 |
|
| 44345 |
ripley |
21 |
#ifndef R_DEV_X11_H
|
|
|
22 |
#define R_DEV_X11_H
|
| 13974 |
hornik |
23 |
|
| 32428 |
ripley |
24 |
#define SYMBOL_FONTFACE 5
|
|
|
25 |
|
| 13974 |
hornik |
26 |
/* These are the currently supported device "models" */
|
|
|
27 |
typedef enum {
|
|
|
28 |
MONOCHROME = 0,
|
|
|
29 |
GRAYSCALE,
|
|
|
30 |
PSEUDOCOLOR1,
|
|
|
31 |
PSEUDOCOLOR2,
|
|
|
32 |
TRUECOLOR
|
|
|
33 |
} X_COLORTYPE;
|
|
|
34 |
|
|
|
35 |
typedef enum {
|
|
|
36 |
WINDOW, /* NB: have "type > WINDOW" below ... */
|
| 44595 |
ripley |
37 |
XIMAGE,
|
| 13974 |
hornik |
38 |
PNG,
|
|
|
39 |
JPEG,
|
| 44595 |
ripley |
40 |
TIFF,
|
|
|
41 |
PNGdirect,
|
|
|
42 |
SVG,
|
|
|
43 |
PDF,
|
| 44639 |
ripley |
44 |
PS,
|
|
|
45 |
BMP
|
| 13974 |
hornik |
46 |
} X_GTYPE;
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
#include <stdio.h>
|
|
|
50 |
#include <X11/X.h>
|
|
|
51 |
#include <X11/Xlib.h>
|
|
|
52 |
#include <X11/Xatom.h>
|
|
|
53 |
#include <X11/Xutil.h>
|
|
|
54 |
#include <X11/cursorfont.h>
|
|
|
55 |
#include <X11/Intrinsic.h> /*-> Xlib.h Xutil.h Xresource.h .. */
|
|
|
56 |
|
| 44551 |
ripley |
57 |
#ifdef HAVE_WORKING_CAIRO
|
| 44593 |
ripley |
58 |
# ifdef HAVE_PANGOCAIRO
|
|
|
59 |
# include <pango/pango.h>
|
|
|
60 |
# include <pango/pangocairo.h>
|
|
|
61 |
# else
|
|
|
62 |
# include <cairo.h>
|
|
|
63 |
# endif
|
|
|
64 |
# include <cairo-xlib.h>
|
| 44551 |
ripley |
65 |
#endif
|
| 13974 |
hornik |
66 |
|
| 44345 |
ripley |
67 |
Rboolean X11DeviceDriver(pDevDesc, const char*, double, double, double,
|
| 45475 |
ripley |
68 |
double, X_COLORTYPE, int, int, int, SEXP,
|
| 55693 |
ripley |
69 |
int, int, int, const char *, int, int, const char *);
|
| 13974 |
hornik |
70 |
|
|
|
71 |
|
|
|
72 |
/********************************************************/
|
|
|
73 |
/* Each driver can have its own device-specic graphical */
|
|
|
74 |
/* parameters and resources. these should be wrapped */
|
|
|
75 |
/* in a structure (like the x11Desc structure below) */
|
|
|
76 |
/* and attached to the overall device description via */
|
|
|
77 |
/* the dd->deviceSpecific pointer */
|
|
|
78 |
/* NOTE that there are generic graphical parameters */
|
|
|
79 |
/* which must be set by the device driver, but are */
|
|
|
80 |
/* common to all device types (see Graphics.h) */
|
|
|
81 |
/* so go in the GPar structure rather than this device- */
|
|
|
82 |
/* specific structure */
|
|
|
83 |
/********************************************************/
|
|
|
84 |
|
|
|
85 |
typedef struct {
|
| 16935 |
hornik |
86 |
/* Graphics Parameters */
|
| 13974 |
hornik |
87 |
/* Local device copy so that we can detect */
|
|
|
88 |
/* when parameter changes. */
|
|
|
89 |
|
| 45475 |
ripley |
90 |
/* Used to detect changes */
|
| 13974 |
hornik |
91 |
int lty; /* Line type */
|
|
|
92 |
double lwd;
|
| 30925 |
murrell |
93 |
R_GE_lineend lend;
|
|
|
94 |
R_GE_linejoin ljoin;
|
| 44442 |
ripley |
95 |
|
| 44583 |
ripley |
96 |
double lwdscale; /* scaling to get a multiple
|
|
|
97 |
of 1/96" */
|
|
|
98 |
|
| 13974 |
hornik |
99 |
int col; /* Color */
|
| 16935 |
hornik |
100 |
int fill;
|
| 44551 |
ripley |
101 |
int bg; /* bg */
|
| 44583 |
ripley |
102 |
int canvas; /* Canvas colour */
|
|
|
103 |
int fontface; /* Typeface 1:5 */
|
| 13974 |
hornik |
104 |
int fontsize; /* Size in points */
|
| 44553 |
ripley |
105 |
double pointsize; /* Size in points */
|
| 29974 |
murrell |
106 |
char basefontfamily[500]; /* Initial font family */
|
| 13974 |
hornik |
107 |
|
|
|
108 |
/* X11 Driver Specific */
|
|
|
109 |
/* Parameters with copy per X11 device. */
|
|
|
110 |
|
|
|
111 |
int windowWidth; /* Window width (pixels) */
|
|
|
112 |
int windowHeight; /* Window height (pixels) */
|
|
|
113 |
int resize; /* Window resized */
|
|
|
114 |
Window window; /* Graphics Window */
|
|
|
115 |
GC wgc; /* GC for window */
|
|
|
116 |
XSetWindowAttributes attributes; /* Window attributes */
|
|
|
117 |
XRectangle clip; /* The clipping rectangle */
|
|
|
118 |
|
| 32596 |
ripley |
119 |
R_XFont *font;
|
| 29974 |
murrell |
120 |
char fontfamily[500]; /* CURRENT fontfamily */
|
| 27069 |
ripley |
121 |
char symbolfamily[500];
|
| 13974 |
hornik |
122 |
X_GTYPE type; /* Window or pixmap? */
|
| 55773 |
ripley |
123 |
int npages; /* counter for a bitmap device */
|
| 13974 |
hornik |
124 |
FILE *fp; /* file for a bitmap device */
|
| 25331 |
ripley |
125 |
char filename[PATH_MAX]; /* filename for a bitmap device */
|
| 44601 |
ripley |
126 |
int quality; /* JPEG quality/TIFF compression */
|
| 13974 |
hornik |
127 |
|
| 44345 |
ripley |
128 |
Rboolean handleOwnEvents; /* Flag indicating whether events will
|
|
|
129 |
be handled externally from R (TRUE),
|
| 45475 |
ripley |
130 |
or whether R is to handle the events
|
| 44345 |
ripley |
131 |
(FALSE) */
|
| 55773 |
ripley |
132 |
int res_dpi; /* used for png/jpeg/tiff */
|
| 44595 |
ripley |
133 |
Rboolean warn_trans; /* have we warned about translucent cols? */
|
| 43742 |
ripley |
134 |
char title[101];
|
| 44624 |
ripley |
135 |
Rboolean onefile;
|
| 44551 |
ripley |
136 |
|
|
|
137 |
#ifdef HAVE_WORKING_CAIRO
|
| 55917 |
ripley |
138 |
/* In the buffered cases, xcc and xcs are the xlib context and surface
|
| 55773 |
ripley |
139 |
whereas cc, cs are an RGB24 image surface.
|
|
|
140 |
In the non-buffered case, xcc and xcs are NULL and cc, cs are the
|
|
|
141 |
cairo context and surface used directly.
|
|
|
142 |
*/
|
| 44646 |
ripley |
143 |
Rboolean useCairo, buffered;
|
| 44551 |
ripley |
144 |
cairo_t *cc, *xcc;
|
|
|
145 |
cairo_surface_t *cs, *xcs;
|
|
|
146 |
cairo_antialias_t antialias;
|
| 55797 |
ripley |
147 |
double last, last_activity, update_interval;
|
| 44551 |
ripley |
148 |
#endif
|
| 47228 |
ripley |
149 |
|
|
|
150 |
double fontscale;
|
| 55828 |
ripley |
151 |
int holdlevel;
|
| 44345 |
ripley |
152 |
} X11Desc;
|
| 13974 |
hornik |
153 |
|
| 44345 |
ripley |
154 |
typedef X11Desc* pX11Desc;
|
| 13974 |
hornik |
155 |
|
| 44445 |
ripley |
156 |
/* This is a private header, so why are these here? */
|
|
|
157 |
|
| 44345 |
ripley |
158 |
X11Desc *Rf_allocX11DeviceDesc(double ps);
|
| 13974 |
hornik |
159 |
|
| 44345 |
ripley |
160 |
int Rf_setX11Display(Display *dpy, double gamma_fac, X_COLORTYPE colormodel,
|
|
|
161 |
int maxcube, Rboolean setHandlers);
|
| 13974 |
hornik |
162 |
|
| 44345 |
ripley |
163 |
int Rf_setX11DeviceData(pDevDesc dd, double gamma_fac, X11Desc *xd);
|
| 13974 |
hornik |
164 |
#endif
|