1# File src/library/grDevices/R/zzz.R 2# Part of the R package, https://www.R-project.org 3# 4# Copyright (C) 1995-2014 The R Core Team 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# A copy of the GNU General Public License is available at 17# https://www.R-project.org/Licenses/ 18 19.noGenerics <- TRUE 20 21if (.Platform$OS.type == "windows") { 22 utils::globalVariables(c("C_cairoProps", "C_makeQuartzDefault")) 23 utils::suppressForeignCheck(c("C_cairoProps", "C_makeQuartzDefault")) 24} 25 26.onLoad <- function(libname, pkgname) 27{ 28 if (.Platform$OS.type != "windows" && !.Call(C_cairoProps, 2L)) 29 X11.options(type = "Xlib") 30 31 extras <- if(.Platform$OS.type == "windows") 32 list(windowsTimeouts = c(100L,500L)) else 33 list(bitmapType = if(capabilities("aqua")) "quartz" 34 else if(.Call(C_cairoProps, 2L)) "cairo" else "Xlib") 35 op.grDevices <- c(list(locatorBell = TRUE, device.ask.default = FALSE), 36 extras, list(device = .select_device())) 37 toset <- !(names(op.grDevices) %in% names(.Options)) 38 if(any(toset)) options(op.grDevices[toset]) 39} 40 41.onUnload <- function(libpath) 42 library.dynam.unload("grDevices", libpath) 43 44 45### Used by text, mtext, strwidth, strheight, title, axis, 46### L_text and L_textBounds, all of which 47### coerce SYMSXPs and LANGSXPs to EXPRSXPs 48### We don't want to use as.expression here as that is generic 49### even though is.language no longer is 50 51### Possibly later have 52### if (is.language(x)) x 53### else if(isS4(x)) methods::as(x, "character") 54### else if(is.object(x)) as.character(x) 55### else x 56 57as.graphicsAnnot <- function(x) 58 if(is.language(x) || !is.object(x)) x else as.character(x) 59