// Draws a filled rectangle with a stroked border.
void GraphicsContext::drawRect(const IntRect& rect)
{
    if (paintingDisabled())
        return;

    cairo_t* cr = m_data->cr;
    cairo_save(cr);

    if (fillColor().alpha())
        fillRectSourceOver(cr, rect, fillColor());

    if (strokeStyle() != NoStroke) {
        setColor(cr, strokeColor());
        FloatRect r(rect);
        r.inflate(-.5f);
        cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
        cairo_set_line_width(cr, 1.0);
        cairo_stroke(cr);
    }

    cairo_restore(cr);
}
GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha)
    : m_common(createGraphicsContextPrivate())
    , m_data(new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha)))
{
    CGContextRelease(m_data->m_cgContext.get());
    m_data->m_hdc = hdc;
    setPaintingDisabled(!m_data->m_cgContext);
    if (m_data->m_cgContext) {
        // Make sure the context starts in sync with our state.
        setPlatformFillColor(fillColor(), DeviceColorSpace);
        setPlatformStrokeColor(strokeColor(), DeviceColorSpace);
    }
}
void ScreenShotRestriction::paintEvent(QPaintEvent *e)
{
    Q_UNUSED(e)
    QPainter paint(this);

    paint.drawPixmap(QPoint(0, 0), screen);
    QColor fillColor(128, 128, 128, 100);
    selectionRect = selectionRect.normalized();

    paint.fillRect(0, 0, selectionRect.x(), height(), fillColor);
    paint.fillRect(selectionRect.x(), 0, selectionRect.width(), selectionRect.y(), fillColor);
    paint.fillRect(selectionRect.x()+selectionRect.width(), 0, width()-selectionRect.width(), height(), fillColor);
    paint.fillRect(selectionRect.x(), selectionRect.y()+selectionRect.height(), selectionRect.width(), height()-(selectionRect.y()+selectionRect.height()), fillColor);
}
void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
{
    if (paintingDisabled())
        return;
    if (color.alpha()) {
        CGContextRef context = platformContext();
        Color oldFillColor = fillColor();
        if (oldFillColor != color)
            setCGFillColor(context, color);
        CGContextFillRect(context, rect);
        if (oldFillColor != color)
            setCGFillColor(context, oldFillColor);
    }
}
Beispiel #5
0
IPLImage::IPLImage( IPLData::IPLDataType t, int width, int height )
{
    _type = t;
    _width = width;
    _height = height;
    _rgb32.resize(_height * _width * 4);

    if( _type == IMAGE_COLOR ) _nrOfPlanes = 3; else _nrOfPlanes = 1;
    for( int i=0; i<_nrOfPlanes; i++ )
        _planes.push_back(new IPLImagePlane( width, height ));
    fillColor( 0 );

    _instanceCount++;
}
void GraphicsContext::platformInit(HDC hdc, bool hasAlpha)
{
    if (!hdc)
        return;

    m_data = new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha));
    CGContextRelease(m_data->m_cgContext.get());
    m_data->m_hdc = hdc;
    if (m_data->m_cgContext) {
        // Make sure the context starts in sync with our state.
        setPlatformFillColor(fillColor());
        setPlatformStrokeColor(strokeColor());
    }
}
Beispiel #7
0
void ScrollbarThemeOpus::paintThumb(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
{
    if (!clientOpacityMap->contains(scrollbar))
        return;
    int opacity = clientOpacityMap->get(scrollbar);
    if (!opacity)
        return;
    IntRect thumbRect = rect;
    thumbRect.inflate(-1);
    int scrollThickness = thumbRect.width() < thumbRect.height() ? thumbRect.width() : thumbRect.height();
    IntSize curveSize(scrollThickness / 2, scrollThickness / 2);
    Color fillColor(makeRGBA(128, 128, 128, opacity));
    context->fillRoundedRect(thumbRect, curveSize, curveSize, curveSize, curveSize, fillColor, ColorSpaceDeviceRGB);
}
void TreatDelegator::paint(
		QPainter* p,
		const QStyleOptionViewItem& option,
		const QModelIndex& index) const
{
	QItemDelegate::paint(p, option, index);
	QColor fillColor(Qt::red);
	fillColor.setAlpha(100);

	QSqlRecord treat = m_model->record(index.row());
	if (0 == treat.value(Accounted).toInt())
	{
		p->fillRect(option.rect, fillColor);
	}
}
Beispiel #9
0
void GraphicsContext::platformInit(PlatformGraphicsContext* context)
{
    m_data = new GraphicsContextPlatformPrivate;
    setPaintingDisabled(!context);

    if (context) {
        // Make sure the context starts in sync with our state.
        setPlatformFillColor(fillColor(), ColorSpaceDeviceRGB);
        setPlatformStrokeColor(strokeColor(), ColorSpaceDeviceRGB);
    }
#if USE(WXGC)
    m_data->context = (wxGCDC*)context;
#else
    m_data->context = (wxWindowDC*)context;
#endif
}
void GraphicsContext::platformInit(HDC dc, bool hasAlpha)
{
    cairo_t* cr = 0;
    if (dc)
        cr = createCairoContextWithHDC(dc, hasAlpha);
    else
        setPaintingDisabled(true);

    m_data = new GraphicsContextPlatformPrivateToplevel(new PlatformContextCairo(cr));
    m_data->m_hdc = dc;
    if (platformContext()->cr()) {
        // Make sure the context starts in sync with our state.
        setPlatformFillColor(fillColor(), fillColorSpace());
        setPlatformStrokeColor(strokeColor(), strokeColorSpace());
    }
}
GraphicsContext::GraphicsContext(PlatformGraphicsContext* context)
    : m_common(createGraphicsContextPrivate())
    , m_data(new GraphicsContextPlatformPrivate)
{    
    setPaintingDisabled(!context);
    if (context) {
        // Make sure the context starts in sync with our state.
        setPlatformFillColor(fillColor(), DeviceColorSpace);
        setPlatformStrokeColor(strokeColor(), DeviceColorSpace);
    }
#if USE(WXGC)
    m_data->context = (wxGCDC*)context;
#else
    m_data->context = (wxWindowDC*)context;
#endif
}
Beispiel #12
0
int QDeclarativePaintedItem::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDeclarativeItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 5)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 5;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QSize*>(_v) = contentsSize(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = fillColor(); break;
        case 2: *reinterpret_cast< int*>(_v) = pixelCacheSize(); break;
        case 3: *reinterpret_cast< bool*>(_v) = smoothCache(); break;
        case 4: *reinterpret_cast< qreal*>(_v) = contentsScale(); break;
        }
        _id -= 5;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setContentsSize(*reinterpret_cast< QSize*>(_v)); break;
        case 1: setFillColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setPixelCacheSize(*reinterpret_cast< int*>(_v)); break;
        case 3: setSmoothCache(*reinterpret_cast< bool*>(_v)); break;
        case 4: setContentsScale(*reinterpret_cast< qreal*>(_v)); break;
        }
        _id -= 5;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 5;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #13
0
void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace colorSpace)
{
    if (paintingDisabled())
        return;

    CGContextRef context = platformContext();
    Color oldFillColor = fillColor();
    ColorSpace oldColorSpace = fillColorSpace();

    if (oldFillColor != color || oldColorSpace != colorSpace)
        setCGFillColor(context, color, colorSpace);

    CGContextFillRect(context, rect);

    if (oldFillColor != color || oldColorSpace != colorSpace)
        setCGFillColor(context, oldFillColor, oldColorSpace);
}
Beispiel #14
0
void EditFrame::paintEvent(QPaintEvent* /*event*/)
{
	QRect r( rect() );
	r.adjust(0, 0, -1, -1);
	
	QPainter painter(this);
	
	QColor color(m_Selected ? QColor(0,200,60) : QColor(255,255,255));
	
	if( m_Selected )
	{
		QColor fillColor(color);
		fillColor.setAlpha(40);
		painter.fillRect(r, fillColor);
		
		QWidget *pParent = parentWidget();
		if( pParent )
		{
			QRect g( pParent->geometry() );
			QString label = QString("(%1,%2)\n%3x%4").arg(g.x()).arg(g.y()).arg(g.width()).arg(g.height());
			painter.setPen( QColor(0,0,0) );
			painter.drawText(r.adjusted(1,1,1,1), Qt::AlignCenter, label);
			painter.setPen( QColor(255,255,255) );
			painter.drawText(r, Qt::AlignCenter, label);
		}
	}
	
	r.adjust(HANDLE_MARGIN, HANDLE_MARGIN, -HANDLE_MARGIN-1, -HANDLE_MARGIN-1);
	
	for(int i=0; i<2; i++)
	{
		QColor handleColor((i==0) ? QColor(0,0,0) : color);
		
		painter.setBrush(Qt::NoBrush);
		if(i == 0)
			painter.setPen( QPen(handleColor,3) );
		else
			painter.setPen(handleColor);
		painter.drawRect(r);
	
		QRect scaleRect(width()-HANDLE_SIZE-1, height()-HANDLE_SIZE-1, HANDLE_SIZE, HANDLE_SIZE);
		if(i == 0)
			scaleRect.adjust(-1, -1, 1, 1);
		painter.fillRect(scaleRect, handleColor);
	}
}
void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
{
    if (paintingDisabled() || !color.alpha())
        return;

    CGContextRef context = platformContext();
    Color oldFillColor = fillColor();
    if (oldFillColor != color)
        setCGFillColor(context, color);

    // Add the four ellipses to the path.  Technically this really isn't good enough, since we could end up
    // not clipping the other 3/4 of the ellipse we don't care about.  We're relying on the fact that for
    // normal use cases these ellipses won't overlap one another (or when they do the curvature of one will
    // be subsumed by the other).
    CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.y(), topLeft.width() * 2, topLeft.height() * 2));
    CGContextAddEllipseInRect(context, CGRectMake(rect.right() - topRight.width() * 2, rect.y(),
                                                  topRight.width() * 2, topRight.height() * 2));
    CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.bottom() - bottomLeft.height() * 2,
                                                  bottomLeft.width() * 2, bottomLeft.height() * 2));
    CGContextAddEllipseInRect(context, CGRectMake(rect.right() - bottomRight.width() * 2,
                                                  rect.bottom() - bottomRight.height() * 2,
                                                  bottomRight.width() * 2, bottomRight.height() * 2));
    
    // Now add five rects (one for each edge rect in between the rounded corners and one for the interior).
    CGContextAddRect(context, CGRectMake(rect.x() + topLeft.width(), rect.y(),
                                         rect.width() - topLeft.width() - topRight.width(),
                                         max(topLeft.height(), topRight.height())));
    CGContextAddRect(context, CGRectMake(rect.x() + bottomLeft.width(), 
                                         rect.bottom() - max(bottomLeft.height(), bottomRight.height()),
                                         rect.width() - bottomLeft.width() - bottomRight.width(),
                                         max(bottomLeft.height(), bottomRight.height())));
    CGContextAddRect(context, CGRectMake(rect.x(), rect.y() + topLeft.height(),
                                         max(topLeft.width(), bottomLeft.width()), rect.height() - topLeft.height() - bottomLeft.height()));
    CGContextAddRect(context, CGRectMake(rect.right() - max(topRight.width(), bottomRight.width()),
                                         rect.y() + topRight.height(),
                                         max(topRight.width(), bottomRight.width()), rect.height() - topRight.height() - bottomRight.height()));
    CGContextAddRect(context, CGRectMake(rect.x() + max(topLeft.width(), bottomLeft.width()),
                                         rect.y() + max(topLeft.height(), topRight.height()),
                                         rect.width() - max(topLeft.width(), bottomLeft.width()) - max(topRight.width(), bottomRight.width()),
                                         rect.height() - max(topLeft.height(), topRight.height()) - max(bottomLeft.height(), bottomRight.height())));
    CGContextFillPath(context);
    if (oldFillColor != color)
        setCGFillColor(context, oldFillColor);
}
Beispiel #16
0
void Window::resize(int w, int h)
{
	m_bufWidth = w;
	m_bufHeight = h;

	setVisibleDimensions(w, h);

	// preserve alpha
	bool hasAlpha = m_screenPixmap.hasAlpha();
	if (m_type != Type_QtNativePaintWindow)
	{
		m_screenPixmap = QPixmap(w, h);

		QColor fillColor(255, 255, 255, hasAlpha ? 0 : 255);
		m_screenPixmap.fill(fillColor);
	}
//	g_debug("%s: Window resized to %d x %d", __PRETTY_FUNCTION__,
//			m_bufWidth, m_bufHeight);
}
int StickMan::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = penColor(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = fillColor(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isDead(); break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPenColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setFillColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setIsDead(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 3;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #18
0
void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color, ColorSpace colorSpace)
{
    if (paintingDisabled())
        return;

    CGContextRef context = platformContext();
    Color oldFillColor = fillColor();
    ColorSpace oldColorSpace = fillColorSpace();

    if (oldFillColor != color || oldColorSpace != colorSpace)
        setCGFillColor(context, color, colorSpace);

    Path path;
    path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight);
    fillPath(path);

    if (oldFillColor != color || oldColorSpace != colorSpace)
        setCGFillColor(context, oldFillColor, oldColorSpace);
}
Beispiel #19
0
void DebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
{
	const float32 k_segments = 16.0f;
	const float32 k_increment = 2.0f * b2_pi / k_segments;
    float32 sinInc = sinf(k_increment);
    float32 cosInc = cosf(k_increment);
    b2Vec2 v0 = center;
    b2Vec2 r1(cosInc, sinInc);
    b2Vec2 v1 = center + radius * r1;
	b2Color fillColor(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);
	for (int32 i = 0; i < k_segments; ++i)
	{
        // Perform rotation to avoid additional trigonometry.
        b2Vec2 r2;
        r2.x = cosInc * r1.x - sinInc * r1.y;
        r2.y = sinInc * r1.x + cosInc * r1.y;
		b2Vec2 v2 = center + radius * r2;
		m_triangles->Vertex(v0, fillColor);
        m_triangles->Vertex(v1, fillColor);
        m_triangles->Vertex(v2, fillColor);
        r1 = r2;
        v1 = v2;
	}

    r1.Set(1.0f, 0.0f);
    v1 = center + radius * r1;
	for (int32 i = 0; i < k_segments; ++i)
	{
        b2Vec2 r2;
        r2.x = cosInc * r1.x - sinInc * r1.y;
        r2.y = sinInc * r1.x + cosInc * r1.y;
		b2Vec2 v2 = center + radius * r2;
        m_lines->Vertex(v1, color);
        m_lines->Vertex(v2, color);
        r1 = r2;
        v1 = v2;
	}

    // Draw a line fixed in the circle to animate rotation.
	b2Vec2 p = center + radius * axis;
	m_lines->Vertex(center, color);
	m_lines->Vertex(p, color);
}
Beispiel #20
0
void GraphicsContext::fillRect(const FloatRect& rect)
{
    if (paintingDisabled())
        return;

    QPainter *p = m_data->p();

    switch (m_common->state.fillColorSpace) {
    case SolidColorSpace:
        if (fillColor().alpha())
            p->fillRect(rect, p->brush());
        break;
    case PatternColorSpace:
        p->fillRect(rect, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
        break;
    case GradientColorSpace:
        p->fillRect(rect, QBrush(*(m_common->state.fillGradient.get()->platformGradient())));
        break;
    }
}
Beispiel #21
0
bool fillColor(enum color *screen, int x, int y, enum color oldcolor, enum color newcolor) {
//bool fillColor(enum color screen[][MAX_LEN], int x, int y, enum color oldcolor, enum color newcolor) {
	if (x < 0 || x >= MAX_LEN || y < 0 || y >= MAX_LEN) {
		return false;
	}

	if (*(screen+y*MAX_LEN+x) == oldcolor) {
		*(screen+y*MAX_LEN+x) = newcolor;
	//if (screen[x][y] == oldcolor) {
	//	screen[x][y] = newcolor;
		fillColor(screen, x-1, y-1, oldcolor, newcolor);
		fillColor(screen, x  , y-1, oldcolor, newcolor);
		fillColor(screen, x+1, y-1, oldcolor, newcolor);
		fillColor(screen, x+1, y  , oldcolor, newcolor);
		fillColor(screen, x+1, y+1, oldcolor, newcolor);
		fillColor(screen, x  , y+1, oldcolor, newcolor);
		fillColor(screen, x-1, y+1, oldcolor, newcolor);
		fillColor(screen, x-1, y  , oldcolor, newcolor);
	}

	return true;
}
GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha)
    : m_common(createGraphicsContextPrivate())
    , m_data(new GraphicsContextPlatformPrivate)
{
    if (dc) {
        cairo_surface_t* surface = cairo_win32_surface_create(dc);
        m_data->cr = cairo_create(surface);
        m_data->m_hdc = dc;
    } else {
        setPaintingDisabled(true);
        m_data->cr = 0;
        m_data->m_hdc = 0;
    }

    if (m_data->cr) {
        // Make sure the context starts in sync with our state.
        setPlatformFillColor(fillColor());
        setPlatformStrokeColor(strokeColor());
    }
}
Beispiel #23
0
void DebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{
	b2Color fillColor(0.5f * color.r, 0.5f * color.g, 0.5f * color.b, 0.5f);

    for (int32 i = 1; i < vertexCount - 1; ++i)
    {
        m_triangles->Vertex(vertices[0], fillColor);
        m_triangles->Vertex(vertices[i], fillColor);
        m_triangles->Vertex(vertices[i+1], fillColor);
    }

    b2Vec2 p1 = vertices[vertexCount - 1];
	for (int32 i = 0; i < vertexCount; ++i)
	{
        b2Vec2 p2 = vertices[i];
		m_lines->Vertex(p1, color);
		m_lines->Vertex(p2, color);
        p1 = p2;
	}
}
Beispiel #24
0
void RenderAudio_update(struct TrackData* trackData, int xPos, int yPos, int rowCount, int rowOffset, int rowSpacing, int endY)
{
    uint32_t* fftData = trackData->musicData.fftData;

    if (!fftData)
        return;

    // first calculate the total number of textures we need (we allocate 128 x 1024 textures to be compatible to fairly low-end GPUs)

    int count = (int)(((float)endY) / (float)TEXTURE_HEIGHT) + 1;

    if (s_data.textureCount < count)
    {
        for (int i = s_data.textureCount; i < count; ++i)
        {
            s_data.textureIds[i] = EMGFXBackend_createTexture(0, 128, TEXTURE_HEIGHT, 4);
            s_data.textureData[i] = malloc(128 * TEXTURE_HEIGHT * 4);
        }

        s_data.textureCount = count;
    }

    int texturePos = 0;

	if (rowOffset < 0)
	{
	    rowOffset = -rowOffset;

	    for (int i = 0; i < rowOffset; ++i) {
            const int textureIndex = texturePos >> 17;
            const int textureOffset = texturePos & 0x1ffff;

            uint32_t* textureDest = &s_data.textureData[textureIndex][textureOffset];

            fillColor(textureDest, Emgui_color32(0, 0, 0, 255), rowSpacing);
            texturePos += 128 * rowSpacing;
	    }

		yPos += rowSpacing * rowOffset;
        rowOffset = 0;
	}
bool RenderThemeApollo::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
    ASSERT(o);
    ASSERT(o->style());

    Color fillColor( 0xff, 0xff, 0xee );
    fillColor = o->style()->visitedDependentColor(CSSPropertyBackgroundColor);
    Color rectColor( 0x18, 0x52, 0x84 );
    if ( o->node() && !isEnabled(o))
    {
        rectColor = Color( 0xce, 0xce, 0xdb );
    }
    i.context->save();
    i.context->setStrokeThickness(1);
    i.context->setStrokeColor(rectColor.rgb(), DeviceColorSpace);
    i.context->setFillColor(fillColor, DeviceColorSpace);
    i.context->drawRect(r);
    i.context->restore();

    return false;
}
Beispiel #26
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());
}
// Draws a filled rectangle with a stroked border.
void GraphicsContext::drawRect(const IntRect& rect)
{
    if (paintingDisabled())
        return;

    cairo_t* cr = platformContext()->cr();
    cairo_save(cr);

    fillRectWithColor(cr, rect, fillColor());

    if (strokeStyle() != NoStroke) {
        setSourceRGBAFromColor(cr, strokeColor());
        FloatRect r(rect);
        r.inflate(-.5f);
        cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
        cairo_set_line_width(cr, 1.0);
        cairo_stroke(cr);
    }

    cairo_restore(cr);
}
void GraphicsContext::fillRect(const FloatRect& rect)
{
    if (paintingDisabled())
        return;

    QPainter *p = m_data->p();

    switch (m_common->state.fillColorSpace) {
    case SolidColorSpace:
        if (fillColor().alpha())
            p->fillRect(rect, p->brush());
        break;
    case PatternColorSpace: {
        TransformationMatrix affine;
        p->fillRect(rect, QBrush(m_common->state.fillPattern->createPlatformPattern(affine)));
        break;
    }
    case GradientColorSpace:
        p->fillRect(rect, QBrush(*(m_common->state.fillGradient.get()->platformGradient())));
        break;
    }
    m_data->currentPath = QPainterPath();
}
Beispiel #29
0
void TabBar::startDrag(int index)
{
    int sessionId = sessionAtTab(index);

    m_startPos.setX(0);
    m_startPos.setY(0);

    int x = index ? m_tabWidths.at(index - 1) : m_skin->tabBarPosition().x();
    int tabWidth = m_tabWidths.at(index) - x;
    QString title = tabTitle(sessionId);

    QPixmap tab(tabWidth, height());
    QColor fillColor(Settings::backgroundColor());

    if (m_mainWindow->useTranslucency())
        fillColor.setAlphaF(qreal(Settings::backgroundColorOpacity()) / 100);

    tab.fill(fillColor);

    QPainter painter(&tab);
    painter.initFrom(this);
    painter.setPen(m_skin->tabBarTextColor());

    drawButton(0, 0, index, painter);
    painter.end();

    QMimeData* mimeData = new QMimeData;
    mimeData->setText(QVariant(sessionId).toString());

    QDrag* drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(tab);
    drag->exec(Qt::MoveAction);

    return;
}
Beispiel #30
0
void GraphicsContext::fillRectWithRoundedHole(const IntRect& rect, const FloatRoundedRect& roundedHoleRect, const Color& color)
{
    if (paintingDisabled())
        return;

    Path path;
    path.addRect(rect);

    if (!roundedHoleRect.radii().isZero())
        path.addRoundedRect(roundedHoleRect);
    else
        path.addRect(roundedHoleRect.rect());

    WindRule oldFillRule = fillRule();
    Color oldFillColor = fillColor();
    
    setFillRule(RULE_EVENODD);
    setFillColor(color);

    fillPath(path);
    
    setFillRule(oldFillRule);
    setFillColor(oldFillColor);
}