QBrush StateEffects::brush(const QBrush& foreground, const QBrush& background) const { QColor color = foreground.color(); // TODO - actually work on brushes QColor bg = background.color(); // Apply the foreground effects switch (_effects[Contrast]) { case ContrastFade: color = ColorUtils::mix(color, bg, _amount[Contrast]); break; case ContrastTint: color = ColorUtils::tint(color, bg, _amount[Contrast]); break; } // Now apply global effects return brush(color); }
void paintAreas( AbstractDiagram::Private* diagramPrivate, PaintContext* ctx, const QModelIndex& index, const QList< QPolygonF >& areas, uint opacity ) { AbstractDiagram* diagram = diagramPrivate->diagram; QPainterPath path; for ( int i = 0; i < areas.count(); ++i ) { const QPolygonF& p = areas[ i ]; path.addPolygon( p ); diagramPrivate->reverseMapper.addPolygon( index.row(), index.column(), p ); path.closeSubpath(); } ThreeDLineAttributes threeDAttrs = threeDLineAttributes( diagram, index ); QBrush trans = diagram->brush( index ); if ( threeDAttrs.isEnabled() ) { trans = threeDAttrs.threeDBrush( trans, path.boundingRect() ); } QColor transColor = trans.color(); transColor.setAlpha( opacity ); trans.setColor(transColor); QPen indexPen = diagram->pen(index); indexPen.setBrush( trans ); const PainterSaver painterSaver( ctx->painter() ); ctx->painter()->setRenderHint( QPainter::Antialiasing, diagram->antiAliasing() ); ctx->painter()->setPen( PrintingParameters::scalePen( indexPen ) ); ctx->painter()->setBrush( trans ); ctx->painter()->drawPath( path ); }
/** * Draws an ordinary line in 3D by expanding it in the z-axis by the given depth. * * @param line The line to draw * @param brush The brush to fill the resulting polygon with * @param pen The pen to paint the borders of the resulting polygon with * @param props The 3D properties to draw the line with * @return The 3D shape drawn */ QPolygonF StockDiagram::Private::ThreeDPainter::drawThreeDLine( const QLineF &line, const QBrush &brush, const QPen &pen, const ThreeDProperties &props ) { // Restores the painting properties when destroyed PainterSaver painterSaver( painter ); const QPointF p1 = line.p1(); const QPointF p2 = line.p2(); // Project the 2D points of the line in 3D const QPointF deepP1 = projectPoint( p1, props.depth, props.angle ); const QPointF deepP2 = projectPoint( p2, props.depth, props.angle ); // The result is a 3D representation of the 2D line QPolygonF threeDArea; threeDArea << p1 << p2 << deepP2 << deepP1 << p1; // Use shadow colors if ThreeDProperties::useShadowColors is set // Note: Setting a new color on a brush or pen does not effect gradients or textures if ( props.useShadowColors ) { QBrush shadowBrush( brush ); QPen shadowPen( pen ); shadowBrush.setColor( calcShadowColor( brush.color(), props.angle ) ); shadowPen.setColor( calcShadowColor( pen.color(), props.angle ) ); painter->setBrush( shadowBrush ); painter->setPen( shadowPen ); } else { painter->setBrush( brush ); painter->setPen( pen ); } painter->drawPolygon( threeDArea ); return threeDArea; }
void MythD3D9Painter::DrawRect(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha) { int style = fillBrush.style(); if (style == Qt::SolidPattern || style == Qt::NoBrush) { if (!m_render) return; if (style != Qt::NoBrush) m_render->DrawRect(area, fillBrush.color(), alpha); if (linePen.style() != Qt::NoPen) { int lineWidth = linePen.width(); QRect top(QPoint(area.x(), area.y()), QSize(area.width(), lineWidth)); QRect bot(QPoint(area.x(), area.y() + area.height() - lineWidth), QSize(area.width(), lineWidth)); QRect left(QPoint(area.x(), area.y()), QSize(lineWidth, area.height())); QRect right(QPoint(area.x() + area.width() - lineWidth, area.y()), QSize(lineWidth, area.height())); m_render->DrawRect(top, linePen.color(), alpha); m_render->DrawRect(bot, linePen.color(), alpha); m_render->DrawRect(left, linePen.color(), alpha); m_render->DrawRect(right, linePen.color(), alpha); } return; } MythPainter::DrawRect(area, fillBrush, linePen, alpha); }
void NorwegianWoodStyle::polish(QPalette &palette) { QColor brown(212, 140, 95); QColor beige(212, 140, 95); QColor slightlyOpaqueBlack(0, 0, 0, 63); QPixmap backgroundIamge(":/images/woodbackground.png"); QPixmap buttonImage(":/images/woodbutton.png"); QPixmap midImage = buttonImage; QPainter painter; painter.begin(&midImage); painter.setPen(Qt::NoPen); painter.fillRect(midImage.rect(), slightlyOpaqueBlack); painter.end(); palette = QPalette(brown); palette.setBrush(QPalette::BrightText, Qt::white); palette.setBrush(QPalette::Base, beige); palette.setBrush(QPalette::Highlight, Qt::darkGreen); setTexture(palette, QPalette::Button, buttonImage); setTexture(palette, QPalette::Mid, midImage); setTexture(palette, QPalette::Window, backgroundIamge); QBrush brush = palette.background(); brush.setColor(brush.color().dark()); palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); palette.setBrush(QPalette::Disabled, QPalette::Text, brush); palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); palette.setBrush(QPalette::Disabled, QPalette::Base, brush); palette.setBrush(QPalette::Disabled, QPalette::Button, brush); palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); }
static QWidget *qwtBackgroundWidget( QWidget *w ) { if ( w->parentWidget() == NULL ) return w; if ( w->autoFillBackground() ) { const QBrush brush = w->palette().brush( w->backgroundRole() ); if ( brush.color().alpha() > 0 ) return w; } if ( w->testAttribute( Qt::WA_StyledBackground ) ) { QImage image( 1, 1, QImage::Format_ARGB32 ); image.fill( Qt::transparent ); QPainter painter( &image ); painter.translate( -w->rect().center() ); qwtDrawStyledBackground( w, &painter ); painter.end(); if ( qAlpha( image.pixel( 0, 0 ) ) != 0 ) return w; } return qwtBackgroundWidget( w->parentWidget() ); }
void IndexGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *) { Q_UNUSED(options); if(isSilenced()) { QPen pen = _pen; pen.setStyle(Qt::DashDotDotLine); painter->setPen(pen); QBrush brush = _brush; QColor color = brush.color(); color.setAlphaF(0.5); brush.setColor(color); painter->setBrush(brush); } else { painter->setPen(_pen); painter->setBrush(_brush); } painter->drawRect(_rect); if(!_icon.isNull()) { if(isSilenced()) painter->setOpacity(0.5); painter->drawPixmap(_rect.topLeft(), _icon); } }
QVariant AttributesModel::defaultHeaderData ( int section, Qt::Orientation orientation, int role ) const { // Default values if nothing else matches switch ( role ) { case Qt::DisplayRole: //TODO for KDChart 3.0: Change to "return QString::number( section+1 );" return QLatin1String( orientation == Qt::Vertical ? "Series " : "Item " ) + QString::number( section ) ; case KDChart::DatasetBrushRole: { if ( paletteType() == PaletteTypeSubdued ) return Palette::subduedPalette().getBrush( section ); else if ( paletteType() == PaletteTypeRainbow ) return Palette::rainbowPalette().getBrush( section ); else if ( paletteType() == PaletteTypeDefault ) return Palette::defaultPalette().getBrush( section ); else qWarning("Unknown type of fallback palette!"); } break; case KDChart::DatasetPenRole: { // default to the color set for the brush (or it's defaults) // but only if no per model override was set if ( !modelData( role ).isValid() ) { QBrush brush = qVariantValue<QBrush>( headerData( section, orientation, DatasetBrushRole ) ); return QPen( brush.color() ); } } break; default: break; } return QVariant(); }
DesktopBackgroundDialog::DesktopBackgroundDialog(RazorSettings * cfg, int screen, QSize desktopSize, const QBrush & brush, QWidget * parent) : QDialog(parent), m_desktopSize(desktopSize), m_type(RazorWorkSpaceManager::BackgroundColor), m_config(cfg), m_screen(screen) { setupUi(this); // center it to current desktop move(parent->geometry().center() - geometry().center()); // read current wallpaper brush if (brush.texture().isNull()) { m_color = brush.color(); preview(); } else { QPixmap p = brush.texture().scaled(previewLabel->size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); previewLabel->setPixmap(p); } connect(colorButton, SIGNAL(clicked()), this, SLOT(colorButton_clicked())); connect(wallpaperButton, SIGNAL(clicked()), this, SLOT(wallpaperButton_clicked())); connect(systemButton, SIGNAL(clicked()), this, SLOT(systemButton_clicked())); connect(keepAspectCheckBox, SIGNAL(toggled(bool)), this, SLOT(preview())); buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); keepAspectCheckBox->setEnabled(false); }
void CustomStyle::polish(QPalette &palette) { QColor brown(Qt::white); QColor beige(Qt::transparent); QColor slightlyOpaqueBlack(0, 0, 0, 63); // QPainter painter; // painter.begin(&midImage); // painter.setPen(Qt::NoPen); // painter.fillRect(midImage.rect(), slightlyOpaqueBlack); // painter.end(); palette = QPalette(brown); palette.setBrush(QPalette::BrightText, Qt::white); palette.setBrush(QPalette::Base, beige); palette.setBrush(QPalette::Highlight, Qt::darkGreen); palette.setBrush(QPalette::Button, beige); palette.setBrush(QPalette::ButtonText, Qt::white); palette.setBrush(QPalette::Mid, beige); // palette.setBrush(QPalette::Window, QColor(158, 202, 243)); palette.setBrush(QPalette::Window, beige); QBrush brush = palette.background(); brush.setColor(brush.color().dark()); palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); palette.setBrush(QPalette::Disabled, QPalette::Text, brush); palette.setBrush(QPalette::Disabled, QPalette::ButtonText, Qt::gray); palette.setBrush(QPalette::Disabled, QPalette::Base, brush); palette.setBrush(QPalette::Disabled, QPalette::Button, brush); palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); }
void QTableModelWordMLWriter::writeBackgroundColor(QXmlStreamWriter & stream, const QBrush & b) { if (b.style() != Qt::NoBrush){ //stream.writeEmptyElement("w:color"); stream.writeAttribute("w:fill", b.color().name()); } }
bool QBrushPropertyItem::hasChildren() { if (!m_childrenSet) { m_childrenSet = true; QBrush brush = qvariant_cast<QBrush>(m_metaProperty.read(m_parent->qObject())); QPropertyItem* width = new QPropertyItem(brush.color(), "Color", this); m_children.append(width); connect(width, SIGNAL(valueChanged(const QString&, const QVariant&)), this, SLOT(onChildItemValueChanged(const QString&, const QVariant&))); int index = staticQtMetaObject.indexOfEnumerator("BrushStyle"); QMetaEnum enumeration = staticQtMetaObject.enumerator(index); QChildEnumPropertyItem* brushStyle = new QChildEnumPropertyItem((int)brush.style(), "Brush Style",enumeration , this); m_children.append(brushStyle); connect(brushStyle, SIGNAL(valueChanged(const QString&, const QVariant&)), this, SLOT(onChildItemValueChanged(const QString&, const QVariant&))); QChildImagePropertyItem* textureImage = new QChildImagePropertyItem(brush.texture(), "Texture", this); m_children.append(textureImage); connect(textureImage, SIGNAL(valueChanged(const QString&, const QVariant&)), this, SLOT(onChildItemValueChanged(const QString&, const QVariant&))); return true; }
void QBrushPropertyItem::setChildValues() { if (!m_isSettingChildren) { m_isSettingChildren = true; QBrush brush = qvariant_cast<QBrush>(m_metaProperty.read(m_parent->qObject())); for (int i = 0; i < m_children.count(); i++) { QPropertyItem* child = m_children[i]; QString propertyName = child->name(); QVariant tval; if (propertyName == "Color") { tval = brush.color(); } else if (propertyName == "Brush Style") { tval = (int)brush.style(); } else if (propertyName == "Texture") { tval = brush.texture(); } m_model->setData(child->index(), tval); } m_isSettingChildren = false; } }
bool UIMain::eventFilter( QObject* object, QEvent* event ) { if ( object == qmtbInfos ) { if ( event->type() == QEvent::Paint ) { if ( qmtbInfos->queuedMessageWidget()->pendingMessageCount() > 0 ) { QPainter painter( qmtbInfos ); QBrush brush; qmtbInfos->queuedMessageWidget()->currentMessageInformations( 0, &brush, 0 ); painter.setRenderHint( QPainter::Antialiasing ); painter.setPen( QPen( brush.color().darker( 150 ), 0.5 ) ); painter.setBrush( brush ); painter.drawRoundedRect( qmtbInfos->rect().adjusted( 10 -4, -9, -10 +4, -1 ), 9, 9 ); return true; } } } else if ( object == lWiiTDB ) { if ( event->type() == QEvent::MouseButtonPress ) { QDesktopServices::openUrl( lWiiTDB->toolTip() ); } } return QMainWindow::eventFilter( object, event ); }
/*! \brief Draw an intervall of the curve \param painter Painter \param xMap maps x-values into pixel coordinates. \param yMap maps y-values into pixel coordinates. \param from index of the first point to be painted \param to index of the last point to be painted. If to < 0 the curve will be painted to its last point. \sa QwtCurve::drawCurve, QwtCurve::drawDots, QwtCurve::drawLines, QwtCurve::drawSpline, QwtCurve::drawSteps, QwtCurve::drawSticks */ void QwtCurve::draw(QPainter *painter, const QwtDiMap &xMap, const QwtDiMap &yMap, int from, int to) { if ( !painter || dataSize() <= 0 ) return; if (to < 0) to = dataSize() - 1; if ( verifyRange(from, to) > 0 ) { painter->save(); painter->setPen(d_pen); QBrush b = d_brush; if ( b.style() != Qt::NoBrush && !b.color().isValid() ) b.setColor(d_pen.color()); painter->setBrush(b); drawCurve(painter, d_style, xMap, yMap, from, to); painter->restore(); if (d_sym.style() != QwtSymbol::None) { painter->save(); drawSymbols(painter, d_sym, xMap, yMap, from, to); painter->restore(); } } }
void SelectAllButton::paint(QPainter* painter, const QRectF& painterRect) { // the painter painter->setClipRect(painterRect); // if all cells are selected if (m_canvasBase->selection()->isAllSelected() && !m_canvasBase->selection()->referenceSelectionMode() && m_cellToolIsActive) { // selection brush/color QColor selectionColor(palette().highlight().color()); selectionColor.setAlpha(127); const QBrush selectionBrush(selectionColor); painter->setPen(selectionColor.dark(150)); painter->setBrush(selectionBrush); } else { // background brush/color const QBrush backgroundBrush(palette().window()); const QColor backgroundColor(backgroundBrush.color()); painter->setPen(backgroundColor.dark(150)); painter->setBrush(backgroundBrush); } painter->drawRect(painterRect.adjusted(0, 0, -1, -1)); }
static bool pulse(QBrush& ref, bool pulse) { bool invert = false; auto col = ref.color(); auto alpha = col.alphaF(); if (pulse) { alpha += 0.02; if (alpha >= 1) { invert = true; alpha = 1; } col.setAlphaF(alpha); } else { alpha -= 0.02; if (alpha <= 0.5) { invert = true; alpha = 0.5; } col.setAlphaF(alpha); } ref.setColor(col); return invert; }
QBrush FillTab::brush(QBrush b) const { QColor this_color = colorDirty() ? color() : b.color(); Qt::BrushStyle this_style = styleDirty() ? style() : b.style(); if (useGradientDirty()) { // Apply / unapply gradient if (useGradient()) { b = QBrush(gradient()); } else { b.setColor(this_color); b.setStyle(this_style); } } else { // Leave gradient but make other changes. QGradient this_gradient; if (const QGradient *grad = b.gradient()) { if (gradientDirty()) { this_gradient = gradient(); } else { this_gradient = *grad; } b = QBrush(this_gradient); } else { b.setColor(this_color); b.setStyle(this_style); } } return b; }
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *w) { Q_UNUSED(w); QPen pen (QPen(outlinerect_color, iOutlineRectWidth)); QBrush brush (QBrush(background_color, background_style)); QColor color = brush.color(); color.setAlpha(background_alpha); brush.setColor(color); if (opt->state & QStyle::State_Selected) { pen.setStyle(Qt::DotLine); pen.setColor(Qt::darkGray); } painter->setRenderHint(QPainter::Antialiasing); painter->setPen(pen); painter->setBrush(brush); painter->drawPath(shape()); painter->setFont(font); painter->setPen(text_color); painter->rotate(iTextRotationAngle); painter->drawText(outline_rect(), Qt::AlignCenter, text); }
void TrackView::paintEvent( QPaintEvent* event ) { QTreeView::paintEvent( event ); QPainter painter( viewport() ); if ( m_dragging ) { // draw drop indicator { // draw indicator for inserting items QBrush blendedBrush = viewOptions().palette.brush( QPalette::Normal, QPalette::Highlight ); QColor color = blendedBrush.color(); const int y = ( m_dropRect.top() + m_dropRect.bottom() ) / 2; const int thickness = m_dropRect.height() / 2; int alpha = 255; const int alphaDec = alpha / ( thickness + 1 ); for ( int i = 0; i < thickness; i++ ) { color.setAlpha( alpha ); alpha -= alphaDec; painter.setPen( color ); painter.drawLine( 0, y - i, width(), y - i ); painter.drawLine( 0, y + i, width(), y + i ); } } } }
void TitleLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { QBrush windowBrush = palette().window(); windowBrush.setColor(windowBrush.color().darker(150)); painter->fillRect(boundingRect(), windowBrush); painter->drawText(boundingRect(), Qt::AlignLeft | Qt::AlignVCenter, text); }
void QgsComposerLegend::drawPolygonSymbol( QPainter* p, QgsSymbol* s, double currentYCoord, double& currentXPosition, int opacity ) const { if ( !s ) { return; } if ( p ) { //scale brush and set transparencies QBrush symbolBrush = s->brush(); QColor brushColor = symbolBrush.color(); brushColor.setAlpha( opacity ); symbolBrush.setColor( brushColor ); QPaintDevice* paintDevice = p->device(); if ( paintDevice ) { double rasterScaleFactor = ( paintDevice->logicalDpiX() + paintDevice->logicalDpiY() ) / 2.0 / 25.4; QgsRenderer::scaleBrush( symbolBrush, rasterScaleFactor ); } p->setBrush( symbolBrush ); QPen symbolPen = s->pen(); QColor penColor = symbolPen.color(); penColor.setAlpha( opacity ); symbolPen.setColor( penColor ); p->setPen( symbolPen ); p->drawRect( QRectF( currentXPosition, currentYCoord, mSymbolWidth, mSymbolHeight ) ); } currentXPosition += mSymbolWidth; }
StyledButton::StyledButton( const QBrush& b, QWidget* parent, const char* name, WFlags f ) : QButton( parent, name, f ), spix( 0 ), s( 0 ) { col = b.color(); pix = b.pixmap(); setMinimumSize( minimumSizeHint() ); }
//! Draw the knob void QwtDialNeedle::drawKnob( QPainter *painter, double width, const QBrush &brush, bool sunken ) const { QPalette palette( brush.color() ); QColor c1 = palette.color( QPalette::Light ); QColor c2 = palette.color( QPalette::Dark ); if ( sunken ) qSwap( c1, c2 ); QRectF rect( 0.0, 0.0, width, width ); rect.moveCenter( painter->combinedTransform().map( QPointF() ) ); QLinearGradient gradient( rect.topLeft(), rect.bottomRight() ); gradient.setColorAt( 0.0, c1 ); gradient.setColorAt( 0.3, c1 ); gradient.setColorAt( 0.7, c2 ); gradient.setColorAt( 1.0, c2 ); painter->save(); painter->resetTransform(); painter->setPen( QPen( gradient, 1 ) ); painter->setBrush( brush ); painter->drawEllipse( rect ); painter->restore(); }
/*! Fill the area between the curve and the baseline with the curve brush \param painter Painter \param xMap x map \param yMap y map \param canvasRect Contents rectangle of the canvas \param polygon Polygon - will be modified ! \sa setBrush(), setBaseline(), setStyle() */ void QwtPlotCurve::fillCurve( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, QPolygonF &polygon ) const { if ( d_data->brush.style() == Qt::NoBrush ) return; closePolyline( painter, xMap, yMap, polygon ); if ( polygon.count() <= 2 ) // a line can't be filled return; QBrush brush = d_data->brush; if ( !brush.color().isValid() ) brush.setColor( d_data->pen.color() ); if ( d_data->paintAttributes & ClipPolygons ) polygon = QwtClipper::clipPolygonF( canvasRect, polygon, true ); painter->save(); painter->setPen( Qt::NoPen ); painter->setBrush( brush ); QwtPainter::drawPolygon( painter, polygon ); painter->restore(); }
/** * Returns a 255 by 100 QImage containing a Histogram for the given channel. * The background is transparent (Alpha 0, RGB=255) */ QImage Histogram::getImage(Channel channel = LChannel, QBrush pen = Qt::gray) { // Create blank QImage and fill it with transparent background: QImage histImage(255, 100, QImage::Format_ARGB32); histImage.fill(0); QPainter painter(&histImage); painter.setBrush(Qt::transparent); painter.setPen(Qt::transparent); painter.drawRect(0,0,255,100); // Calculate the aspect ratio using the maximal value of the color histograms int maximum = (channel == LChannel ? maximumValue(LChannel) : maximumValue(RGB)); float ratio = 100.0/float(maximum); // Preparing the painter: painter.setBrush(pen); painter.setPen(pen.color()); int h; // Draw histogram QHash<int, int>* hist = get(channel); QHash<int, int>::const_iterator cit = hist->begin(); while (cit != hist->end()) { h = 100 - floor(ratio*cit.value()); painter.drawLine(cit.key(), h, cit.key(), 100); ++cit; } return histImage; }
void KoTableRowStyle::saveOdf(KoGenStyle &style) const { QList<int> keys = d->stylesPrivate.keys(); foreach(int key, keys) { if (key == QTextFormat::BackgroundBrush) { QBrush backBrush = background(); if (backBrush.style() != Qt::NoBrush) style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::TableRowType); else style.addProperty("fo:background-color", "transparent", KoGenStyle::TableRowType); } else if (key == MinimumRowHeight) { style.addPropertyPt("style:min-row-height", minimumRowHeight(), KoGenStyle::TableRowType); } else if (key == RowHeight) { style.addPropertyPt("style:row-height", rowHeight(), KoGenStyle::TableRowType); } else if (key == UseOptimalHeight) { style.addProperty("style:use-optimal-row-height", useOptimalHeight(), KoGenStyle::TableRowType); } else if (key == BreakBefore) { style.addProperty("fo:break-before", KoText::textBreakToString(breakBefore()), KoGenStyle::TableRowType); } else if (key == BreakAfter) { style.addProperty("fo:break-after", KoText::textBreakToString(breakAfter()), KoGenStyle::TableRowType); } else if (key == KeepTogether) { if (keepTogether()) style.addProperty("fo:keep-together", "always", KoGenStyle::TableRowType); else style.addProperty("fo:keep-together", "auto", KoGenStyle::TableRowType); } } }
QBrush StateEffects::brush(const QBrush& background) const { QColor color = background.color(); // TODO - actually work on brushes switch (_effects[Intensity]) { case IntensityShade: color = ColorUtils::shade(color, _amount[Intensity]); break; case IntensityDarken: color = ColorUtils::darken(color, _amount[Intensity]); break; case IntensityLighten: color = ColorUtils::lighten(color, _amount[Intensity]); break; } switch (_effects[Color]) { case ColorDesaturate: color = ColorUtils::darken(color, 0.0, 1.0 - _amount[Color]); break; case ColorFade: color = ColorUtils::mix(color, _color, _amount[Color]); break; case ColorTint: color = ColorUtils::tint(color, _color, _amount[Color]); break; } return QBrush(color); }
void KCSelectAllButton::paintEvent(QPaintEvent* event) { // the painter QPainter painter(this); painter.setClipRect(event->rect()); // if all cells are selected if (m_selection->isAllSelected() && !m_selection->referenceSelectionMode() && m_cellToolIsActive) { // selection brush/color QColor selectionColor(palette().highlight().color()); selectionColor.setAlpha(127); const QBrush selectionBrush(selectionColor); painter.setPen(selectionColor.dark(150)); painter.setBrush(selectionBrush); } else { // background brush/color const QBrush backgroundBrush(palette().window()); const QColor backgroundColor(backgroundBrush.color()); painter.setPen(backgroundColor.dark(150)); painter.setBrush(backgroundBrush); } painter.drawRect(rect().adjusted(0, 0, -1, -1)); }
void HtmlExporter::emitFrame( QTextFrame::Iterator frameIt ) { // kDebug() << "html" << html; if ( !frameIt.atEnd() ) { QTextFrame::Iterator next = frameIt; ++next; if ( next.atEnd() && frameIt.currentFrame() == 0 && frameIt.parentFrame() != doc->rootFrame() && frameIt.currentBlock().begin().atEnd() ) { return; } } for ( QTextFrame::Iterator it = frameIt; !it.atEnd(); ++it ) {; if ( QTextFrame *f = it.currentFrame() ) { // qDebug() << "Its a frame, not a block" << endl; if ( QTextTable * table = qobject_cast<QTextTable *>( f ) ) { emitTable( table ); } else { // qDebug() << "isn't table" << endl; html += QLatin1String( "\n<table" ); QTextFrameFormat format = f->frameFormat(); if ( format.hasProperty( QTextFormat::FrameBorder ) ) { emitAttribute( "border", QString::number( format.border() ) ); } html += QLatin1String( " style=\"-qt-table-type: frame;" ); emitFloatStyle( format.position(), OmitStyleTag ); if ( format.hasProperty( QTextFormat::FrameMargin ) ) { const QString margin = QString::number( format.margin() ); emitMargins( margin, margin, margin, margin ); } html += QLatin1Char( '\"' ); emitTextLength( "width", format.width() ); emitTextLength( "height", format.height() ); QBrush bg = format.background(); if ( bg != Qt::NoBrush ) { emitAttribute( "bgcolor", bg.color().name() ); } html += QLatin1Char( '>' ); html += QLatin1String( "\n<tr>\n<td style=\"border: none;\">" ); emitFrame( f->begin() ); html += QLatin1String( "</td></tr></table>" ); } } else if ( it.currentBlock().isValid() ) { // qDebug()<< "is valid" << endl; emitBlock( it.currentBlock() ); } } }