本文整理汇总了C++中GraphicsContext类的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext类的具体用法?C++ GraphicsContext怎么用?C++ GraphicsContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GraphicsContext类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void EndTransparencyLayer::apply(GraphicsContext& context) const
{
context.endTransparencyLayer();
}
示例2: apply
void DrawLineForDocumentMarker::apply(GraphicsContext& context) const
{
context.drawLineForDocumentMarker(m_point, m_width, m_style);
}
示例3: contentWidth
void RenderImage::paintReplaced(PaintInfo& paintInfo, int tx, int ty)
{
int cWidth = contentWidth();
int cHeight = contentHeight();
int leftBorder = borderLeft();
int topBorder = borderTop();
int leftPad = paddingLeft();
int topPad = paddingTop();
GraphicsContext* context = paintInfo.context;
if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) {
if (paintInfo.phase == PaintPhaseSelection)
return;
if (cWidth > 2 && cHeight > 2) {
// Draw an outline rect where the image should be.
#ifdef ANDROID_FIX // see http://b/issue?id=2052757
context->save();
#endif
context->setStrokeStyle(SolidStroke);
context->setStrokeColor(Color::lightGray, style()->colorSpace());
context->setFillColor(Color::transparent, style()->colorSpace());
context->drawRect(IntRect(tx + leftBorder + leftPad, ty + topBorder + topPad, cWidth, cHeight));
#ifdef ANDROID_FIX // see http://b/issue?id=2052757
context->restore();
#endif
bool errorPictureDrawn = false;
int imageX = 0;
int imageY = 0;
// When calculating the usable dimensions, exclude the pixels of
// the ouline rect so the error image/alt text doesn't draw on it.
#ifdef CAPP_WEB_IMG_ALT_TEXT
int usableWidth = cWidth;
int usableHeight = cHeight;
#else
int usableWidth = cWidth - 2;
int usableHeight = cHeight - 2;
#endif
RefPtr<Image> image = m_imageResource->image();
#ifdef CAPP_WEB_IMG_ALT_TEXT
if (m_altText.isEmpty() && m_imageResource->errorOccurred() && !image->isNull() && (usableWidth >= image->width()) && (usableHeight >= image->height())) {
#else
if (m_imageResource->errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) {
#endif
// Center the error image, accounting for border and padding.
int centerX = (usableWidth - image->width()) / 2;
if (centerX < 0)
centerX = 0;
int centerY = (usableHeight - image->height()) / 2;
if (centerY < 0)
centerY = 0;
imageX = leftBorder + leftPad + centerX + 1;
imageY = topBorder + topPad + centerY + 1;
context->drawImage(image.get(), style()->colorSpace(), IntPoint(tx + imageX, ty + imageY));
errorPictureDrawn = true;
}
if (!m_altText.isEmpty()) {
String text = document()->displayStringModifiedByEncoding(m_altText);
context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
int ax = tx + leftBorder + leftPad;
int ay = ty + topBorder + topPad;
const Font& font = style()->font();
const FontMetrics& fontMetrics = font.fontMetrics();
int ascent = fontMetrics.ascent();
// Only draw the alt text if it'll fit within the content box,
// and only if it fits above the error image.
TextRun textRun(text.characters(), text.length());
int textWidth = font.width(textRun);
if (errorPictureDrawn) {
if (usableWidth >= textWidth && fontMetrics.height() <= imageY)
context->drawText(font, textRun, IntPoint(ax, ay + ascent));
#ifdef CAPP_WEB_IMG_ALT_TEXT
} else if (cHeight >= fontMetrics.height()) {
if(usableWidth >= textWidth) {
context->drawText(style()->font(), textRun, IntPoint(ax, ay + ascent));
}
else {
String subString;
unsigned int i, width, iLast;
int spaceI, spaceW, noLines;
noLines = usableHeight / fontMetrics.height();
for (i = 0, iLast = 0; i <= m_altText.length() && noLines; ) {
noLines--;
for (width = 0, spaceI = -1, spaceW = -1; ; i++) {
width += font.primaryFont()->platformWidthForGlyph(m_altText[i]);
if (' ' == m_altText.characterStartingAt(i)) {
spaceI = i;
spaceW = width;
}
if(width >= usableWidth || i > m_altText.length()) {
if (noLines == 0 && i < m_altText.length()) {
subString = m_altText.substring(iLast, i - iLast - 3);
subString.append(String("..."));
//.........这里部分代码省略.........