Example #1
0
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
    if (paintingDisabled())
        return;

    m_data->m_view->StrokeArc(rect, startAngle, angleSpan, getHaikuStrokeStyle());
}
Example #2
0
// This is only used to draw borders.
void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
{
    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
        return;

    m_data->view()->StrokeLine(point1, point2, getHaikuStrokeStyle());
}
Example #3
0
// Draws a filled rectangle with a stroked border.
void GraphicsContext::drawRect(const IntRect& rect)
{
    if (paintingDisabled())
        return;

    m_data->m_view->FillRect(rect);
    if (strokeStyle() != NoStroke)
        m_data->m_view->StrokeRect(rect, getHaikuStrokeStyle());
}
Example #4
0
void GraphicsContext::strokeRect(const FloatRect& rect, float width)
{
    if (paintingDisabled())
        return;

    float oldSize = m_data->m_view->PenSize();
    m_data->m_view->SetPenSize(width);
    m_data->m_view->StrokeRect(rect, getHaikuStrokeStyle());
    m_data->m_view->SetPenSize(oldSize);
}
Example #5
0
// This is only used to draw borders.
void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
{
    if (paintingDisabled())
        return;

    if (strokeStyle() == NoStroke)
        return;

    m_data->m_view->StrokeLine(point1, point2, getHaikuStrokeStyle());
}
Example #6
0
void GraphicsContext::strokeRect(const FloatRect& rect, float width)
{
    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
        return;

    float oldSize = m_data->view()->PenSize();
    m_data->view()->SetPenSize(width);
    m_data->view()->StrokeRect(rect, getHaikuStrokeStyle());
    m_data->view()->SetPenSize(oldSize);
}
Example #7
0
void GraphicsContext::drawConvexPolygon(size_t pointsLength, const FloatPoint* points, bool shouldAntialias)
{
    if (paintingDisabled())
        return;

    BPoint bPoints[pointsLength];
    for (size_t i = 0; i < pointsLength; i++)
        bPoints[i] = points[i];

    m_data->m_view->FillPolygon(bPoints, pointsLength);
    if (strokeStyle() != NoStroke)
        // Stroke with low color
        m_data->m_view->StrokePolygon(bPoints, pointsLength, true, getHaikuStrokeStyle());
}
Example #8
0
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
        return;

    // TODO: The code below will only make round-corner boxen look nice. For an utterly shocking
    // implementation of round corner drawing, see RenderBoxModelObject::paintBorder(). It tries
    // to use one (or two) alpha mask(s) per box corner to cut off a thicker stroke and doubles
    // the stroke with. All this to align the arc with the box sides...

    m_data->view()->PushState();
    float penSize = strokeThickness() / 2.0f;
    m_data->view()->SetPenSize(penSize);
    BRect bRect(rect.x(), rect.y(), rect.maxX(), rect.maxY());
    if (startAngle >= 0 && startAngle < 90) {
		bRect.left += penSize / 2 - 0.5;
        bRect.top += penSize / 2 - 0.5;
        bRect.right -= penSize / 2 + 0.5;
        bRect.bottom -= penSize / 2 - 0.5;
    } else if (startAngle >= 90 && startAngle < 180) {
        bRect.left += penSize / 2 - 0.5;
        bRect.top += penSize / 2 - 0.5;
        bRect.right -= penSize / 2 - 0.5;
        bRect.bottom -= penSize / 2 - 0.5;
    } else if (startAngle >= 180 && startAngle < 270) {
        bRect.left += penSize / 2 - 0.5;
        bRect.top += penSize / 2 - 0.5;
        bRect.right -= penSize / 2 - 0.5;
        bRect.bottom -= penSize / 2 + 0.5;
    } else if (startAngle >= 270 && startAngle < 360) {
        bRect.left += penSize / 2 - 0.5;
        bRect.top += penSize / 2 - 0.5;
        bRect.right -= penSize / 2 + 0.5;
        bRect.bottom -= penSize / 2 + 0.5;
    }
    uint32 flags = m_data->view()->Flags();
    m_data->view()->SetFlags(flags | B_SUBPIXEL_PRECISE);
    m_data->view()->StrokeArc(bRect, startAngle, angleSpan, getHaikuStrokeStyle());
    m_data->view()->SetFlags(flags);

    m_data->view()->PopState();
}
Example #9
0
// This method is only used to draw the little circles used in lists.
void GraphicsContext::drawEllipse(const IntRect& rect)
{
    if (paintingDisabled())
        return;

    if (m_state.fillPattern || m_state.fillGradient || fillColor().alpha()) {
//        TODO: What's this shadow business?
        if (m_state.fillPattern)
            notImplemented();
        else if (m_state.fillGradient) {
            BGradient* gradient = m_state.fillGradient->platformGradient();
//            gradient->SetTransform(m_state.fillGradient->gradientSpaceTransform());
            m_data->view()->FillEllipse(rect, *gradient);
        } else
            m_data->view()->FillEllipse(rect);
    }

    // TODO: Support gradients
    if (strokeStyle() != NoStroke && strokeThickness() > 0.0f && strokeColor().alpha())
        m_data->view()->StrokeEllipse(rect, getHaikuStrokeStyle());
}