本文整理汇总了C++中GraphicsContext::drawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::drawLine方法的具体用法?C++ GraphicsContext::drawLine怎么用?C++ GraphicsContext::drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::drawLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintMediaTimelineContainer
static bool paintMediaTimelineContainer(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
{
HTMLMediaElement* mediaElement = toParentMediaElement(object);
if (!mediaElement)
return false;
if (!rect.isEmpty()) {
GraphicsContext* context = paintInfo.context;
Color originalColor = context->strokeColor();
float originalThickness = context->strokeThickness();
StrokeStyle originalStyle = context->strokeStyle();
context->setStrokeStyle(SolidStroke);
// Draw the left border using CSS defined width and color.
context->setStrokeThickness(object->style()->borderLeftWidth());
context->setStrokeColor(object->style()->borderLeftColor().rgb());
context->drawLine(IntPoint(rect.x() + 1, rect.y()),
IntPoint(rect.x() + 1, rect.y() + rect.height()));
// Draw the right border using CSS defined width and color.
context->setStrokeThickness(object->style()->borderRightWidth());
context->setStrokeColor(object->style()->borderRightColor().rgb());
context->drawLine(IntPoint(rect.x() + rect.width() - 1, rect.y()),
IntPoint(rect.x() + rect.width() - 1, rect.y() + rect.height()));
context->setStrokeColor(originalColor);
context->setStrokeThickness(originalThickness);
context->setStrokeStyle(originalStyle);
}
return true;
}
示例2: paintButton
bool RenderThemeAndroid::paintButton(RenderObject* obj, const PaintInfo& info, const IntRect& rect)
{
// If it is a disabled button, simply paint it to the master picture.
Node* node = obj->node();
Element* formControlElement = static_cast<Element*>(node);
if (formControlElement) {
android::WebFrame* webFrame = getWebFrame(node);
if (webFrame) {
GraphicsContext *context = info.context;
IntRect innerrect = IntRect(rect.x() + paddingButton, rect.y() + paddingButton,
rect.width() - 2 * paddingButton, rect.height() - 2 * paddingButton);
IntSize cornerrect = IntSize(cornerButton, cornerButton);
Color bg, bright, dark, medium;
if (formControlElement->isEnabledFormControl()) {
bg = Color(defaultBgColor);
bright = Color(defaultBgBright);
dark = Color(defaultBgDark);
medium = Color(defaultBgMedium);
} else {
bg = Color(disabledBgColor);
bright = Color(disabledBgBright);
dark = Color(disabledBgDark);
medium = Color(disabledBgMedium);
}
context->save();
context->clip(
IntRect(innerrect.x(), innerrect.y(), innerrect.width(), 1));
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, bright, context->fillColorSpace());
context->restore();
context->save();
context->clip(IntRect(innerrect.x(), innerrect.y() + innerrect.height() - 1,
innerrect.width(), 1));
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, dark, context->fillColorSpace());
context->restore();
context->save();
context->clip(IntRect(innerrect.x(), innerrect.y() + 1, innerrect.width(),
innerrect.height() - 2));
context->fillRoundedRect(innerrect, cornerrect, cornerrect,
cornerrect, cornerrect, bg, context->fillColorSpace());
context->restore();
context->setStrokeColor(medium, context->strokeColorSpace());
context->setStrokeThickness(1.0f);
context->drawLine(IntPoint(innerrect.x(), innerrect.y() + cornerButton),
IntPoint(innerrect.x(), innerrect.y() + innerrect.height() - cornerButton));
context->drawLine(IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + cornerButton),
IntPoint(innerrect.x() + innerrect.width(), innerrect.y() + innerrect.height() - cornerButton));
}
}
// We always return false so we do not request to be redrawn.
return false;
}
示例3: spoolAllPagesWithBoundaries
void PrintContext::spoolAllPagesWithBoundaries(Frame* frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
{
if (!frame->document() || !frame->view() || !frame->document()->renderer())
return;
frame->document()->updateLayout();
PrintContext printContext(frame);
printContext.begin(pageSizeInPixels.width(), pageSizeInPixels.height());
float pageHeight;
printContext.computePageRects(FloatRect(FloatPoint(0, 0), pageSizeInPixels), 0, 0, 1, pageHeight);
const float pageWidth = pageSizeInPixels.width();
const Vector<IntRect>& pageRects = printContext.pageRects();
int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
// Fill the whole background by white.
graphicsContext.setFillColor(Color(255, 255, 255));
graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
graphicsContext.save();
graphicsContext.translate(0, totalHeight);
graphicsContext.scale(FloatSize(1, -1));
int currentHeight = 0;
for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
// Draw a line for a page boundary if this isn't the first page.
if (pageIndex > 0) {
graphicsContext.save();
graphicsContext.setStrokeColor(Color(0, 0, 255));
graphicsContext.setFillColor(Color(0, 0, 255));
graphicsContext.drawLine(IntPoint(0, currentHeight),
IntPoint(pageWidth, currentHeight));
graphicsContext.restore();
}
graphicsContext.save();
graphicsContext.translate(0, currentHeight);
printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
graphicsContext.restore();
currentHeight += pageSizeInPixels.height() + 1;
}
graphicsContext.restore();
}
示例4: paintMediaVolumeSlider
static bool paintMediaVolumeSlider(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
{
HTMLMediaElement* mediaElement = toParentMediaElement(object);
if (!mediaElement)
return false;
GraphicsContext* context = paintInfo.context;
Color originalColor = context->strokeColor();
if (originalColor != Color::white)
context->setStrokeColor(Color::white, ColorSpaceDeviceRGB);
int x = rect.x() + rect.width() / 2;
context->drawLine(IntPoint(x, rect.y()), IntPoint(x, rect.y() + rect.height()));
if (originalColor != Color::white)
context->setStrokeColor(originalColor, ColorSpaceDeviceRGB);
return true;
}
示例5: spoolAllPagesWithBoundaries
void PrintContext::spoolAllPagesWithBoundaries(Frame& frame, GraphicsContext& graphicsContext, const FloatSize& pageSizeInPixels)
{
PrintContext printContext(&frame);
if (!printContext.beginAndComputePageRectsWithPageSize(frame, pageSizeInPixels))
return;
const float pageWidth = pageSizeInPixels.width();
const Vector<IntRect>& pageRects = printContext.pageRects();
int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
// Fill the whole background by white.
graphicsContext.setFillColor(Color(255, 255, 255));
graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
graphicsContext.save();
int currentHeight = 0;
for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
// Draw a line for a page boundary if this isn't the first page.
if (pageIndex > 0) {
#if PLATFORM(COCOA)
int boundaryLineY = currentHeight;
#else
int boundaryLineY = currentHeight - 1;
#endif
graphicsContext.save();
graphicsContext.setStrokeColor(Color(0, 0, 255));
graphicsContext.setFillColor(Color(0, 0, 255));
graphicsContext.drawLine(IntPoint(0, boundaryLineY), IntPoint(pageWidth, boundaryLineY));
graphicsContext.restore();
}
graphicsContext.save();
graphicsContext.translate(0, currentHeight);
printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
graphicsContext.restore();
currentHeight += pageSizeInPixels.height() + 1;
}
graphicsContext.restore();
}
示例6: apply
void DrawLine::apply(GraphicsContext& context) const
{
context.drawLine(m_point1, m_point2);
}