1use super::*;
3
4pub const R_GE_version: u32 = 16;
5pub type DevDesc = _DevDesc;
7pub type pDevDesc = *mut DevDesc;
8pub type pGEcontext = *mut R_GE_gcontext;
9pub type pGEDevDesc = *mut GEDevDesc;
10
11pub const LTY_BLANK: i32 = -1;
13pub const LTY_SOLID: u32 = 0;
14pub const LTY_DASHED: u32 = 68;
15pub const LTY_DOTTED: u32 = 49;
16pub const LTY_DOTDASH: u32 = 13361;
17pub const LTY_LONGDASH: u32 = 55;
18pub const LTY_TWODASH: u32 = 9762;
19pub const R_GE_definitions: u32 = 13;
20
21#[repr(u32)]
23#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
24pub enum GEUnit {
25 GE_DEVICE = 0,
26 GE_NDC = 1,
27 GE_INCHES = 2,
28 GE_CM = 3,
29}
30
31#[repr(u32)]
32#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
33pub enum R_GE_lineend {
34 GE_ROUND_CAP = 1,
35 GE_BUTT_CAP = 2,
36 GE_SQUARE_CAP = 3,
37}
38
39#[repr(u32)]
40#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
41pub enum R_GE_linejoin {
42 GE_ROUND_JOIN = 1,
43 GE_MITRE_JOIN = 2,
44 GE_BEVEL_JOIN = 3,
45}
46
47#[repr(C)]
49#[derive(Debug, Copy, Clone)]
50pub struct R_GE_gcontext {
51 pub col: ::std::os::raw::c_int,
52 pub fill: ::std::os::raw::c_int,
53 pub gamma: f64,
54 pub lwd: f64,
55 pub lty: ::std::os::raw::c_int,
56 pub lend: R_GE_lineend,
57 pub ljoin: R_GE_linejoin,
58 pub lmitre: f64,
59 pub cex: f64,
60 pub ps: f64,
61 pub lineheight: f64,
62 pub fontface: ::std::os::raw::c_int,
63 pub fontfamily: [::std::os::raw::c_char; 201usize],
64 pub patternFill: SEXP,
65}
66
67#[repr(C)]
68#[derive(Debug, Copy, Clone)]
69pub struct _DevDesc {
70 #[doc = "left raster coordinate"]
71 pub left: f64,
72 #[doc = "right raster coordinate"]
73 pub right: f64,
74 #[doc = "bottom raster coordinate"]
75 pub bottom: f64,
76 #[doc = "top raster coordinate"]
77 pub top: f64,
78 #[doc = "R only has the notion of a rectangular clipping region"]
79 pub clipLeft: f64,
80 pub clipRight: f64,
81 pub clipBottom: f64,
82 pub clipTop: f64,
83 #[doc = "x character addressing offset - unused"]
84 pub xCharOffset: f64,
85 #[doc = "y character addressing offset"]
86 pub yCharOffset: f64,
87 #[doc = "1/2 interline space as frac of line height"]
88 pub yLineBias: f64,
89 #[doc = "Inches per raster; \\[0\\]=x, \\[1\\]=y"]
90 pub ipr: [f64; 2usize],
91 #[doc = "Character size in rasters; \\[0\\]=x, \\[1\\]=y"]
92 pub cra: [f64; 2usize],
93 #[doc = "(initial) Device Gamma Correction"]
94 pub gamma: f64,
95 #[doc = "Device-level clipping"]
96 pub canClip: Rboolean,
97 #[doc = "can the gamma factor be modified?"]
98 pub canChangeGamma: Rboolean,
99 #[doc = "Can do at least some horiz adjust of text\n0 = none, 1 = {0,0.5,1}, 2 = \\[0,1\\]"]
100 pub canHAdj: ::std::os::raw::c_int,
101 #[doc = "Device initial settings\n/\n/* These are things that the device must set up when it is created.\n The graphics system can modify them and track current values,"]
102 pub startps: f64,
103 #[doc = "sets par(\"fg\"), par(\"col\") and gpar(\"col\")"]
104 pub startcol: ::std::os::raw::c_int,
105 #[doc = "sets par(\"bg\") and gpar(\"fill\")"]
106 pub startfill: ::std::os::raw::c_int,
107 pub startlty: ::std::os::raw::c_int,
108 pub startfont: ::std::os::raw::c_int,
109 pub startgamma: f64,
110 #[doc = "pointer to device specific parameters"]
111 pub deviceSpecific: *mut ::std::os::raw::c_void,
112 #[doc = "toggle for initial display list status"]
113 pub displayListOn: Rboolean,
114 #[doc = "can the device generate mousedown events"]
115 pub canGenMouseDown: Rboolean,
116 #[doc = "can the device generate mousemove events"]
117 pub canGenMouseMove: Rboolean,
118 #[doc = "can the device generate mouseup events"]
119 pub canGenMouseUp: Rboolean,
120 #[doc = "can the device generate keyboard events"]
121 pub canGenKeybd: Rboolean,
122 #[doc = "can the device generate idle events"]
123 pub canGenIdle: Rboolean,
124 #[doc = "This is set while getGraphicsEvent\nis actively looking for events"]
125 pub gettingEvent: Rboolean,
126 pub activate: ::std::option::Option<unsafe extern "C" fn(arg1: pDevDesc)>,
127 pub circle: ::std::option::Option<
128 unsafe extern "C" fn(x: f64, y: f64, r: f64, gc: pGEcontext, dd: pDevDesc),
129 >,
130 pub clip: ::std::option::Option<
131 unsafe extern "C" fn(x0: f64, x1: f64, y0: f64, y1: f64, dd: pDevDesc),
132 >,
133 pub close: ::std::option::Option<unsafe extern "C" fn(dd: pDevDesc)>,
134 pub deactivate: ::std::option::Option<unsafe extern "C" fn(arg1: pDevDesc)>,
135 pub locator: ::std::option::Option<
136 unsafe extern "C" fn(x: *mut f64, y: *mut f64, dd: pDevDesc) -> Rboolean,
137 >,
138 pub line: ::std::option::Option<
139 unsafe extern "C" fn(x1: f64, y1: f64, x2: f64, y2: f64, gc: pGEcontext, dd: pDevDesc),
140 >,
141 pub metricInfo: ::std::option::Option<
142 unsafe extern "C" fn(
143 c: ::std::os::raw::c_int,
144 gc: pGEcontext,
145 ascent: *mut f64,
146 descent: *mut f64,
147 width: *mut f64,
148 dd: pDevDesc,
149 ),
150 >,
151 pub mode:
152 ::std::option::Option<unsafe extern "C" fn(mode: ::std::os::raw::c_int, dd: pDevDesc)>,
153 pub newPage: ::std::option::Option<unsafe extern "C" fn(gc: pGEcontext, dd: pDevDesc)>,
154 pub polygon: ::std::option::Option<
155 unsafe extern "C" fn(
156 n: ::std::os::raw::c_int,
157 x: *mut f64,
158 y: *mut f64,
159 gc: pGEcontext,
160 dd: pDevDesc,
161 ),
162 >,
163 pub polyline: ::std::option::Option<
164 unsafe extern "C" fn(
165 n: ::std::os::raw::c_int,
166 x: *mut f64,
167 y: *mut f64,
168 gc: pGEcontext,
169 dd: pDevDesc,
170 ),
171 >,
172 pub rect: ::std::option::Option<
173 unsafe extern "C" fn(x0: f64, y0: f64, x1: f64, y1: f64, gc: pGEcontext, dd: pDevDesc),
174 >,
175 pub path: ::std::option::Option<
176 unsafe extern "C" fn(
177 x: *mut f64,
178 y: *mut f64,
179 npoly: ::std::os::raw::c_int,
180 nper: *mut ::std::os::raw::c_int,
181 winding: Rboolean,
182 gc: pGEcontext,
183 dd: pDevDesc,
184 ),
185 >,
186 pub raster: ::std::option::Option<
187 unsafe extern "C" fn(
188 raster: *mut ::std::os::raw::c_uint,
189 w: ::std::os::raw::c_int,
190 h: ::std::os::raw::c_int,
191 x: f64,
192 y: f64,
193 width: f64,
194 height: f64,
195 rot: f64,
196 interpolate: Rboolean,
197 gc: pGEcontext,
198 dd: pDevDesc,
199 ),
200 >,
201 pub cap: ::std::option::Option<unsafe extern "C" fn(dd: pDevDesc) -> SEXP>,
202 pub size: ::std::option::Option<
203 unsafe extern "C" fn(
204 left: *mut f64,
205 right: *mut f64,
206 bottom: *mut f64,
207 top: *mut f64,
208 dd: pDevDesc,
209 ),
210 >,
211 pub strWidth: ::std::option::Option<
212 unsafe extern "C" fn(
213 str_: *const ::std::os::raw::c_char,
214 gc: pGEcontext,
215 dd: pDevDesc,
216 ) -> f64,
217 >,
218 pub text: ::std::option::Option<
219 unsafe extern "C" fn(
220 x: f64,
221 y: f64,
222 str_: *const ::std::os::raw::c_char,
223 rot: f64,
224 hadj: f64,
225 gc: pGEcontext,
226 dd: pDevDesc,
227 ),
228 >,
229 pub onExit: ::std::option::Option<unsafe extern "C" fn(dd: pDevDesc)>,
230 #[doc = "device_getEvent is no longer used, but the slot is kept for back\n compatibility of the structure."]
231 pub getEvent: ::std::option::Option<
232 unsafe extern "C" fn(arg1: SEXP, arg2: *const ::std::os::raw::c_char) -> SEXP,
233 >,
234 pub newFrameConfirm: ::std::option::Option<unsafe extern "C" fn(dd: pDevDesc) -> Rboolean>,
235 #[doc = "and strWidthUTF8"]
236 pub hasTextUTF8: Rboolean,
237 pub textUTF8: ::std::option::Option<
238 unsafe extern "C" fn(
239 x: f64,
240 y: f64,
241 str_: *const ::std::os::raw::c_char,
242 rot: f64,
243 hadj: f64,
244 gc: pGEcontext,
245 dd: pDevDesc,
246 ),
247 >,
248 pub strWidthUTF8: ::std::option::Option<
249 unsafe extern "C" fn(
250 str_: *const ::std::os::raw::c_char,
251 gc: pGEcontext,
252 dd: pDevDesc,
253 ) -> f64,
254 >,
255 pub wantSymbolUTF8: Rboolean,
256 #[doc = "Is rotated text good enough to be preferable to Hershey in\ncontour labels? Old default was FALSE."]
257 pub useRotatedTextInContour: Rboolean,
258 #[doc = "This is an environment holding event handlers."]
259 pub eventEnv: SEXP,
260 pub eventHelper:
261 ::std::option::Option<unsafe extern "C" fn(dd: pDevDesc, code: ::std::os::raw::c_int)>,
262 pub holdflush: ::std::option::Option<
263 unsafe extern "C" fn(dd: pDevDesc, level: ::std::os::raw::c_int) -> ::std::os::raw::c_int,
264 >,
265 #[doc = "1 = no, 2 = yes"]
266 pub haveTransparency: ::std::os::raw::c_int,
267 #[doc = "1 = no, 2 = fully, 3 = semi"]
268 pub haveTransparentBg: ::std::os::raw::c_int,
269 #[doc = "1 = no, 2 = yes, 3 = except for missing values"]
270 pub haveRaster: ::std::os::raw::c_int,
271 #[doc = "1 = no, 2 = yes"]
272 pub haveCapture: ::std::os::raw::c_int,
273 #[doc = "1 = no, 2 = yes"]
274 pub haveLocator: ::std::os::raw::c_int,
275 pub setPattern:
276 ::std::option::Option<unsafe extern "C" fn(pattern: SEXP, dd: pDevDesc) -> SEXP>,
277 pub releasePattern: ::std::option::Option<unsafe extern "C" fn(ref_: SEXP, dd: pDevDesc)>,
278 pub setClipPath:
279 ::std::option::Option<unsafe extern "C" fn(path: SEXP, ref_: SEXP, dd: pDevDesc) -> SEXP>,
280 pub releaseClipPath: ::std::option::Option<unsafe extern "C" fn(ref_: SEXP, dd: pDevDesc)>,
281 pub setMask:
282 ::std::option::Option<unsafe extern "C" fn(path: SEXP, ref_: SEXP, dd: pDevDesc) -> SEXP>,
283 pub releaseMask: ::std::option::Option<unsafe extern "C" fn(ref_: SEXP, dd: pDevDesc)>,
284 #[doc = "This should match R_GE_version,\n BUT it does not have to.\n It give the graphics engine a chance to work with\n graphics device packages BEFORE they update to\n changes in R_GE_version."]
285 pub deviceVersion: ::std::os::raw::c_int,
286 #[doc = "This can be used to OVERRIDE canClip so that graphics engine\n leaves ALL clipping to the graphics device"]
287 pub deviceClip: Rboolean,
288 pub defineGroup: ::std::option::Option<
289 unsafe extern "C" fn(
290 source: SEXP,
291 op: ::std::os::raw::c_int,
292 destination: SEXP,
293 dd: pDevDesc,
294 ) -> SEXP,
295 >,
296 pub useGroup:
297 ::std::option::Option<unsafe extern "C" fn(ref_: SEXP, trans: SEXP, dd: pDevDesc)>,
298 pub releaseGroup: ::std::option::Option<unsafe extern "C" fn(ref_: SEXP, dd: pDevDesc)>,
299 pub stroke:
300 ::std::option::Option<unsafe extern "C" fn(path: SEXP, gc: pGEcontext, dd: pDevDesc)>,
301 pub fill: ::std::option::Option<
302 unsafe extern "C" fn(path: SEXP, rule: ::std::os::raw::c_int, gc: pGEcontext, dd: pDevDesc),
303 >,
304 pub fillStroke: ::std::option::Option<
305 unsafe extern "C" fn(path: SEXP, rule: ::std::os::raw::c_int, gc: pGEcontext, dd: pDevDesc),
306 >,
307 pub capabilities: ::std::option::Option<unsafe extern "C" fn(cap: SEXP) -> SEXP>,
308 pub glyph: ::std::option::Option<
309 unsafe extern "C" fn(
310 n: ::std::os::raw::c_int,
311 glyphs: *mut ::std::os::raw::c_int,
312 x: *mut f64,
313 y: *mut f64,
314 font: SEXP,
315 size: f64,
316 colour: ::std::os::raw::c_int,
317 rot: f64,
318 dd: pDevDesc,
319 ),
320 >,
321 #[doc = "Area for future expansion.\nBy zeroing this, devices are more likely to work if loaded\ninto a later version of R than that they were compiled under."]
322 pub reserved: [::std::os::raw::c_char; 64usize],
323}
324
325#[repr(C)]
326#[derive(Debug, Copy, Clone)]
327pub struct _GEDevDesc {
328 #[doc = "Stuff that the devices can see (and modify).\n All detailed in GraphicsDevice.h"]
329 pub dev: pDevDesc,
330 #[doc = "toggle for display list status"]
331 pub displayListOn: Rboolean,
332 #[doc = "display list"]
333 pub displayList: SEXP,
334 #[doc = "A pointer to the end of the display list\nto avoid traversing pairlists"]
335 pub DLlastElt: SEXP,
336 #[doc = "The last element of the display list\n just prior to when the display list\n was last initialised"]
337 pub savedSnapshot: SEXP,
338 #[doc = "Has the device received any output?"]
339 pub dirty: Rboolean,
340 #[doc = "Should a graphics call be stored\n on the display list?\n Set to FALSE by do_recordGraphics,\n do_dotcallgr, and do_Externalgr\n so that nested calls are not\n recorded on the display list"]
341 pub recordGraphics: Rboolean,
342 #[doc = "Stuff about the device that only graphics systems see.\n The graphics engine has no idea what is in here.\n Used by graphics systems to store system state per device."]
343 pub gesd: [*mut GESystemDesc; 24usize],
344 #[doc = "per-device setting for 'ask' (use NewFrameConfirm)"]
345 pub ask: Rboolean,
346 #[doc = "Is a device appending a path ?"]
347 pub appending: Rboolean,
348}
349
350pub type GEcallback = ::std::option::Option<
351 unsafe extern "C" fn(arg1: GEevent, arg2: *mut GEDevDesc, arg3: SEXP) -> SEXP,
352>;
353
354#[repr(u32)]
355#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
356pub enum GEevent {
357 #[doc = "In response to this event, the registered graphics system\n should allocate and initialise the systemSpecific structure\n\n Should return R_NilValue on failure so that engine\n can tidy up memory allocation"]
358 GE_InitState = 0,
359 #[doc = "This event gives the registered system a chance to undo\n anything done in the initialisation."]
360 GE_FinaliseState = 1,
361 #[doc = "This is sent by the graphics engine prior to initialising\n the display list. It give the graphics system the chance\n to squirrel away information it will need for redrawing the\n the display list"]
362 GE_SaveState = 2,
363 #[doc = "This is sent by the graphics engine prior to replaying the\n display list. It gives the graphics system the chance to\n restore any information it saved on the GE_SaveState event"]
364 GE_RestoreState = 6,
365 #[doc = "Copy system state information to the current device.\n This is used when copying graphics from one device to another\n so all the graphics system needs to do is to copy across\n the bits required for the display list to draw faithfully\n on the new device."]
366 GE_CopyState = 3,
367 #[doc = "Create a snapshot of the system state that is sufficient\n for the current \"image\" to be reproduced"]
368 GE_SaveSnapshotState = 4,
369 #[doc = "Restore the system state that is saved by GE_SaveSnapshotState"]
370 GE_RestoreSnapshotState = 5,
371 #[doc = "When replaying the display list, the graphics engine\n checks, after each replayed action, that the action\n produced valid output. This is the graphics system's\n chance to say that the output is crap (in which case the\n graphics engine will abort the display list replay)."]
372 GE_CheckPlot = 7,
373 #[doc = "The device wants to scale the current pointsize\n (for scaling an image)\n This is not a nice general solution, but a quick fix for\n the Windows device."]
374 GE_ScalePS = 8,
375}
376
377pub type GEDevDesc = _GEDevDesc;
378
379#[repr(C)]
380#[derive(Debug, Copy, Clone)]
381pub struct GESystemDesc {
382 #[doc = "An array of information about each graphics system that\n has registered with the graphics engine.\n This is used to store graphics state for each graphics\n system on each device."]
383 pub systemSpecific: *mut ::std::os::raw::c_void,
384 #[doc = "An array of function pointers, one per graphics system that\n has registered with the graphics engine.\n\n system_Callback is called when the graphics engine wants\n to give a graphics system the chance to play with its\n device-specific information (stored in systemSpecific)\n There are two parameters: an \"event\" to tell the graphics\n system why the graphics engine has called this function,\n and the systemSpecific pointer. The graphics engine\n has to pass the systemSpecific pointer because only\n the graphics engine will know what array index to use."]
385 pub callback: GEcallback,
386}
387
388extern "C" {
389
390 pub fn GEaddDevice2(arg1: pGEDevDesc, arg2: *const ::std::os::raw::c_char);
392 pub fn GECap(dd: pGEDevDesc) -> SEXP;
393 pub fn GECircle(x: f64, y: f64, radius: f64, gc: pGEcontext, dd: pGEDevDesc);
394 pub fn GEcreateDevDesc(dev: pDevDesc) -> pGEDevDesc;
395 pub fn GEcurrentDevice() -> pGEDevDesc;
396 pub fn GEdeviceNumber(arg1: pGEDevDesc) -> ::std::os::raw::c_int;
397 pub fn GEExpressionHeight(expr: SEXP, gc: pGEcontext, dd: pGEDevDesc) -> f64;
398 pub fn GEExpressionMetric(
399 expr: SEXP,
400 gc: pGEcontext,
401 ascent: *mut f64,
402 descent: *mut f64,
403 width: *mut f64,
404 dd: pGEDevDesc,
405 );
406 pub fn GEExpressionWidth(expr: SEXP, gc: pGEcontext, dd: pGEDevDesc) -> f64;
407 pub fn GEfromDeviceHeight(value: f64, to: GEUnit, dd: pGEDevDesc) -> f64;
408 pub fn GEfromDeviceWidth(value: f64, to: GEUnit, dd: pGEDevDesc) -> f64;
409 pub fn GEfromDeviceX(value: f64, to: GEUnit, dd: pGEDevDesc) -> f64;
410 pub fn GEfromDeviceY(value: f64, to: GEUnit, dd: pGEDevDesc) -> f64;
411 pub fn GEgetDevice(arg1: ::std::os::raw::c_int) -> pGEDevDesc;
412 pub fn GEinitDisplayList(dd: pGEDevDesc);
413 pub fn GELine(x1: f64, y1: f64, x2: f64, y2: f64, gc: pGEcontext, dd: pGEDevDesc);
414 pub fn GEMathText(
415 x: f64,
416 y: f64,
417 expr: SEXP,
418 xc: f64,
419 yc: f64,
420 rot: f64,
421 gc: pGEcontext,
422 dd: pGEDevDesc,
423 );
424 pub fn GEMetricInfo(
425 c: ::std::os::raw::c_int,
426 gc: pGEcontext,
427 ascent: *mut f64,
428 descent: *mut f64,
429 width: *mut f64,
430 dd: pGEDevDesc,
431 );
432 pub fn GEMode(mode: ::std::os::raw::c_int, dd: pGEDevDesc);
433 pub fn GENewPage(gc: pGEcontext, dd: pGEDevDesc);
434 pub fn GEPath(
435 x: *mut f64,
436 y: *mut f64,
437 npoly: ::std::os::raw::c_int,
438 nper: *mut ::std::os::raw::c_int,
439 winding: Rboolean,
440 gc: pGEcontext,
441 dd: pGEDevDesc,
442 );
443 pub fn GEPolygon(
444 n: ::std::os::raw::c_int,
445 x: *mut f64,
446 y: *mut f64,
447 gc: pGEcontext,
448 dd: pGEDevDesc,
449 );
450 pub fn GEPolyline(
451 n: ::std::os::raw::c_int,
452 x: *mut f64,
453 y: *mut f64,
454 gc: pGEcontext,
455 dd: pGEDevDesc,
456 );
457 pub fn GERaster(
458 raster: *mut ::std::os::raw::c_uint,
459 w: ::std::os::raw::c_int,
460 h: ::std::os::raw::c_int,
461 x: f64,
462 y: f64,
463 width: f64,
464 height: f64,
465 rot: f64,
466 interpolate: Rboolean,
467 gc: pGEcontext,
468 dd: pGEDevDesc,
469 );
470 pub fn GERect(x0: f64, y0: f64, x1: f64, y1: f64, gc: pGEcontext, dd: pGEDevDesc);
471 pub fn GESetClip(x1: f64, y1: f64, x2: f64, y2: f64, dd: pGEDevDesc);
472 pub fn GEStrHeight(
473 str_: *const ::std::os::raw::c_char,
474 enc: cetype_t,
475 gc: pGEcontext,
476 dd: pGEDevDesc,
477 ) -> f64;
478 pub fn GEStrMetric(
479 str_: *const ::std::os::raw::c_char,
480 enc: cetype_t,
481 gc: pGEcontext,
482 ascent: *mut f64,
483 descent: *mut f64,
484 width: *mut f64,
485 dd: pGEDevDesc,
486 );
487 pub fn GEStrWidth(
488 str_: *const ::std::os::raw::c_char,
489 enc: cetype_t,
490 gc: pGEcontext,
491 dd: pGEDevDesc,
492 ) -> f64;
493 pub fn GESymbol(
494 x: f64,
495 y: f64,
496 pch: ::std::os::raw::c_int,
497 size: f64,
498 gc: pGEcontext,
499 dd: pGEDevDesc,
500 );
501 pub fn GEText(
502 x: f64,
503 y: f64,
504 str_: *const ::std::os::raw::c_char,
505 enc: cetype_t,
506 xc: f64,
507 yc: f64,
508 rot: f64,
509 gc: pGEcontext,
510 dd: pGEDevDesc,
511 );
512 pub fn GEtoDeviceHeight(value: f64, from: GEUnit, dd: pGEDevDesc) -> f64;
513 pub fn GEtoDeviceWidth(value: f64, from: GEUnit, dd: pGEDevDesc) -> f64;
514 pub fn GEtoDeviceX(value: f64, from: GEUnit, dd: pGEDevDesc) -> f64;
515 pub fn GEtoDeviceY(value: f64, from: GEUnit, dd: pGEDevDesc) -> f64;
516 pub fn R_CheckDeviceAvailable();
517 pub fn R_GE_checkVersionOrDie(version: ::std::os::raw::c_int);
518}