The R Project SVN R

Rev

Rev 86005 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
61044 murrell 1
% File src/library/grid/man/makeContent.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
88524 hornik 3
% Copyright 1995-2025 R Core Team
61044 murrell 4
% Distributed under GPL 2 or later
5
 
6
\name{makeContent}
7
\alias{makeContent}
8
\alias{makeContext}
9
\title{ Customised grid Grobs }
10
\description{
11
  These generic hook functions are called whenever a grid grob is drawn.
12
  They provide an opportunity for customising the drawing context
13
  and drawing content of a
86005 hornik 14
  new class derived from grob (or \I{gTree}).
61044 murrell 15
}
16
\usage{
17
makeContext(x)
18
makeContent(x)
19
}
20
\arguments{
21
  \item{x}{ A grid grob. }
22
}
23
\details{
24
  These functions are called by the \code{grid.draw} methods for grobs
86005 hornik 25
  and \I{gTree}s.
61433 ripley 26
 
61044 murrell 27
  \code{makeContext} is called first during the drawing of a grob.
28
  This function should be used to \emph{modify} the \code{vp} slot
29
  of \code{x} (and/or the \code{childrenvp} slot if \code{x}
86005 hornik 30
  is a \I{gTree}).  The function \emph{must} return the modified \code{x}.
61044 murrell 31
  Note that
32
  the default behaviour for grobs is to push any viewports in the
86005 hornik 33
  \code{vp} slot, and for \I{gTree}s is to also push and up any viewports in the
61044 murrell 34
  \code{childrenvp} slot, so this function is used to customise the
86005 hornik 35
  drawing context for a grob or \I{gTree}.
61433 ripley 36
 
61044 murrell 37
  \code{makeContent} is called next and is where any additional
38
  calculations should occur and graphical content should
39
  be generated (see, for example,
74363 maechler 40
  \code{grid:::makeContent.xaxis}).
61044 murrell 41
  This function should be used to \emph{modify} the \code{children}
86005 hornik 42
  of a \I{gTree}.
61044 murrell 43
  The function \emph{must} return the modified \code{x}.
44
  Note that the default behaviour
86005 hornik 45
  for \I{gTree}s is to draw all grobs in the \code{children} slot,
46
  so this function is used to customise the drawing content for a \I{gTree}.
61044 murrell 47
  It is also possible to customise the drawing content for a simple
48
  grob, but more care needs to be taken;  for example, the function
49
  should return a standard grid primitive with a \code{drawDetails()}
50
  method in this case.
51
 
52
  Note that these functions should be \emph{cumulative} in their
53
  effects, so that the \code{x} returned by \code{makeContent()}
54
  \emph{includes} any changes made by \code{makeContext()}.
55
 
56
  Note that \code{makeContext} is
57
  also called in the calculation of \code{"grobwidth"} and
58
  \code{"grobheight"} units.
59
}
60
\value{
86005 hornik 61
  Both functions are expected to return a grob or \I{gTree}
61044 murrell 62
  (a modified version of \code{x}).
63
}
64
\author{ Paul Murrell }
88524 hornik 65
\references{
66
  \bibshow{R:Murrell:2013}
67
}
61044 murrell 68
\seealso{ \code{\link{grid.draw}} }
69
\keyword{ dplot }