Beispiel #1
0
KDEFX_EXPORT void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y,
                   QBitmap *lightColor, QBitmap *midColor,
                   QBitmap *midlightColor, QBitmap *darkColor,
                   QBitmap *blackColor, QBitmap *whiteColor)
{
    QBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor,
        blackColor, whiteColor};

    QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
        Qt::black, Qt::white};

    int i;
    for(i=0; i < 6; ++i){
        if(bitmaps[i]){
            if(!bitmaps[i]->mask())
                bitmaps[i]->setMask(*bitmaps[i]);
            p->setPen(colors[i]);
            p->drawPixmap(x, y, *bitmaps[i]);
        }
    }
}
/*!
  Draw a compass needle 
*/
void QwtCompassMagnetNeedle::drawThinNeedle(
    QPainter *painter, const QColorGroup &cg,
    const QPoint &center, int length, double direction) 
{
    const int colorOffset = 10;
    const int width = QMAX(qRound(length / 6.0), 3);

    painter->save();

    const QPoint arrowCenter(center.x() + 1, center.y() + 1);

    drawPointer(painter, cg.brush(QColorGroup::Dark), colorOffset, 
        arrowCenter, length, width, direction);
    drawPointer(painter, cg.brush(QColorGroup::Light), -colorOffset, 
        arrowCenter, length, width, direction + 180.0);
    
    drawKnob(painter, arrowCenter, width, 
        cg.brush(QColorGroup::Base), TRUE);

    painter->restore();
}
Beispiel #3
0
void Cell::paint( QPainter * p, const QColorGroup & cg, const QRect & cr, bool selected )
{
	p->fillRect( 0, 0, cr.width(), cr.height(),
		     selected ? cg.brush( QColorGroup::Highlight )
	: cg.brush( QColorGroup::Base ) );
 
	int w = cr.width();
	int h = cr.height();
 
	int x = 0;
	if ( !pixmap.isNull() ) {
 		p->drawPixmap( 0, ( cr.height() - pixmap.height() ) / 2, pixmap );
 		x = pixmap.width() + 2;
	}
 
	if ( selected )
		p->setPen( cg.highlightedText() );
	else
		p->setPen( cg.text() );
	p->drawText( x + 2, 0, w - x - 4, h, Qt::AlignRight, text() );
}
Beispiel #4
0
QPixmap LinkDisplay::feedbackPixmap(int width, int height, const QColorGroup &colorGroup, bool isDefaultColor)
{
	int theWidth  = qMin(width, maxWidth());
	int theHeight = qMin(height, heightForWidth(theWidth));
	QPixmap pixmap(theWidth, theHeight);
	pixmap.fill(colorGroup.background());
	QPainter painter(&pixmap);
	paint(&painter, 0, 0, theWidth, theHeight, colorGroup, isDefaultColor,
	      /*isSelected=*/false, /*isHovered=*/false, /*isIconButtonHovered=*/false);
	painter.end();
	return pixmap;
}
Beispiel #5
0
void K3bListViewItem::paintProgressBar( QPainter* p, const QColorGroup& cgh, int col, int width )
{
  ColumnInfo* info = getColumnInfo( col );

  QStyle::SFlags flags = QStyle::Style_Default;
  if( listView()->isEnabled() )
    flags |= QStyle::Style_Enabled;
  if( listView()->hasFocus() )
    flags |= QStyle::Style_HasFocus;

  // FIXME: the QPainter is translated so 0, m_vMargin is the upper left of our paint rect
  QRect r( 0, m_vMargin, width, height()-2*m_vMargin );

  // create the double buffer pixmap
  static QPixmap *doubleBuffer = 0;
  if( !doubleBuffer )
    doubleBuffer = new QPixmap;
  doubleBuffer->resize( width, height() );

  QPainter dbPainter( doubleBuffer );

  // clear the background (we cannot use paintEmptyArea since it's protected in QListView)
  if( K3bListView* lv = dynamic_cast<K3bListView*>(listView()) )
    lv->paintEmptyArea( &dbPainter, r );
  else
    dbPainter.fillRect( 0, 0, width, height(),
			cgh.brush( QPalette::backgroundRoleFromMode(listView()->viewport()->backgroundMode()) ) );

  // we want a little additional margin
  r.setLeft( r.left()+1 );
  r.setWidth( r.width()-2 );
  r.setTop( r.top()+1 );
  r.setHeight( r.height()-2 );

  // this might be a stupid hack but most styles do not reimplement drawPrimitive PE_ProgressBarChunk
  // so this way the user is happy....
  static QProgressBar* s_dummyProgressBar = 0;
  if( !s_dummyProgressBar ) {
    s_dummyProgressBar = new QProgressBar();
  }

  s_dummyProgressBar->setTotalSteps( info->totalProgressSteps );
  s_dummyProgressBar->setProgress( info->progressValue );

  // some styles use the widget's geometry
  s_dummyProgressBar->setGeometry( r );

  listView()->style().drawControl(QStyle::CE_ProgressBarContents, &dbPainter, s_dummyProgressBar, r, cgh, flags );
  listView()->style().drawControl(QStyle::CE_ProgressBarLabel, &dbPainter, s_dummyProgressBar, r, cgh, flags );

  // now we really paint the progress in the listview
  p->drawPixmap( 0, 0, *doubleBuffer );
}
Beispiel #6
0
// Caption
KMDITitleLabel::KMDITitleLabel(QWidget* p, const char* name) :
  QFrame(p, name)
{
//  setAlignment(AlignVCenter|AlignLeft);
//  setMargin   (BORDER);

  QPalette* pal=QApplication::palette();
  QColorGroup  active   = pal->active();
  QColorGroup  disabled = pal->disabled();
  QColorGroup  normal(white, blue,active.light(),
		      active.dark(), active.mid(), white,
		      active.base());
  QPalette npal(normal, disabled, active);
  setPalette(npal);

  options.titlebarPixmapActive = new("QPixmap") QPixmap;
  options.titlebarPixmapInactive = new("QPixmap") QPixmap;
  readConfiguration();

  titlestring_offset=0;
  titlestring_offset_delta=TITLE_ANIMATION_STEP;
}
Beispiel #7
0
void QtCalculator::set_colors(){


  QPalette mypalette = (calc_display->palette()).copy();

  QColorGroup cgrp = mypalette.active();
  QColorGroup ncgrp(kcalcdefaults.forecolor,
                    cgrp.background(),
                    cgrp.light(),
                    cgrp.dark(),
                    cgrp.mid(),
                    kcalcdefaults.forecolor,
                    kcalcdefaults.backcolor);

  mypalette.setActive(ncgrp);
  mypalette.setDisabled(ncgrp);
  mypalette.setActive(ncgrp);

  calc_display->setPalette(mypalette);
  calc_display->setBackgroundColor(kcalcdefaults.backcolor);

}
Beispiel #8
0
QPixmap MarkList::flagPixmap() {
	QColorGroup cg = QApplication::palette()->normal();
	
	QPixmap pm;
	pm.resize(16,16);
	pm.fill( cg.background() );
		
	int xOffset = 4;
	int yOffset = 3;

	QPainter p;
	p.begin( &pm);
	p.setPen( cg.text() );
	p.drawLine( xOffset+4, yOffset, xOffset+4, yOffset+9 );
	p.setPen( red );
	p.drawLine( xOffset+3, yOffset+1, xOffset, yOffset+4 );
	p.drawLine( xOffset+3, yOffset+1, xOffset+3, yOffset+4 );
	p.drawLine( xOffset, yOffset+4, xOffset+3, yOffset+4 );
	p.end();
	
	return pm;
}
Beispiel #9
0
void FreshStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
				     const QColorGroup &g, bool sunken,
				     bool /*editable*/,
				     bool enabled,
				     const QBrush *fill )
{
    drawBevelButton( p, x, y, w, h, g, FALSE, fill );
    drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill );
    drawArrow( p, QStyle::DownArrow, sunken,
	       x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled,
	       &g.brush( QColorGroup::Button ) );

}
Beispiel #10
0
KDEFX_EXPORT void kDrawRoundButton(QPainter *p, const QRect &r, const QColorGroup &g,
                      bool sunken)
{
    int x, y, x2, y2;
    r.coords(&x, &y, &x2, &y2);
    if(r.width() > 16 && r.height() > 16){
        QPen oldPen = p->pen();
        QPointArray hPntArray, lPntArray;
        hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left
                            x+3,y+2, x+2,y+3, x+1,y+4, x+1,y+5,
                            x+1,y2-5, x+1,y2-4, x+2,y2-3, // half corners
                            x2-5,y+1, x2-4,y+1, x2-3,y+2);

        lPntArray.putPoints(0, 17, x2-5,y2-1, x2-4,y2-1, // btm right
                            x2-3,y2-2, x2-2,y2-3, x2-1,y2-5, x2-1,y2-4,
 
                            x+3,y2-2, x+4,y2-1, x+5,y2-1, //half corners
                            x2-2,y+3, x2-1,y+4, x2-1,y+5,

                            x2-5,y2-2, x2-4,y2-2, // testing
                            x2-3,y2-3,
                            x2-2,y2-5, x2-2,y2-4);

        p->setPen(sunken ? g.dark() : g.light());
        p->drawLine(x+6, y, x2-6, y);
        p->drawLine(0, y+6, 0, y2-6);
        p->drawPoints(hPntArray);

        p->setPen(sunken ? g.light() : g.dark());
        p->drawLine(x+6, y2, x2-6, y2);
        p->drawLine(x+6, y2-1, x2-6, y2-1);
        p->drawLine(x2, y+6, x2, y2-6);
        p->drawLine(x2-1, y+6, x2-1, y2-6);
        p->drawPoints(lPntArray);
        p->setPen(oldPen);
    }
    else
        qDrawWinPanel(p, x, y, r.width(), r.height(), g, sunken);
}
Beispiel #11
0
/*! \reimp
*/
void QWindowsStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h,
				   const QColorGroup &g,
				   bool act, bool dis )
{
    const int markW = w > 7 ? 7 : w;
    const int markH = markW;
    int posX = x + ( w - markW )/2 - 1;
    int posY = y + ( h - markH )/2;

    // Could do with some optimizing/caching...
    QPointArray a( markH*2 );
    int i, xx, yy;
    xx = posX;
    yy = 3 + posY;
    for ( i=0; i<markW/2; i++ ) {
	a.setPoint( 2*i,   xx, yy );
	a.setPoint( 2*i+1, xx, yy+2 );
	xx++; yy++;
    }
    yy -= 2;
    for ( ; i<markH; i++ ) {
	a.setPoint( 2*i,   xx, yy );
	a.setPoint( 2*i+1, xx, yy+2 );
	xx++; yy--;
    }
    if ( dis && !act ) {
	int pnt;
	p->setPen( g.highlightedText() );
	QPoint offset(1,1);
	for ( pnt = 0; pnt < (int)a.size(); pnt++ )
	    a[pnt] += offset;
	p->drawLineSegments( a );
	for ( pnt = 0; pnt < (int)a.size(); pnt++ )
	    a[pnt] -= offset;
    }
    p->setPen( g.text() );
    p->drawLineSegments( a );
}
Beispiel #12
0
KDEFX_EXPORT void kColorBitmaps(QPainter *p, const QColorGroup &g, int x, int y, int w,
                   int h, bool isXBitmaps, const uchar *lightColor,
                   const uchar *midColor, const uchar *midlightColor,
                   const uchar *darkColor, const uchar *blackColor,
                   const uchar *whiteColor)
{
    const uchar *data[]={lightColor, midColor, midlightColor, darkColor,
        blackColor, whiteColor};

    QColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
        Qt::black, Qt::white};

    int i;
    QBitmap b;
    for(i=0; i < 6; ++i){
        if(data[i]){
            b = QBitmap(w, h, data[i], isXBitmaps);
            b.setMask(b);
            p->setPen(colors[i]);
            p->drawPixmap(x, y, b);
        }
    }
}
Beispiel #13
0
void KstScalarTable::paintCell( QPainter* painter, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg ) {
  KstScalarList::iterator it = KST::scalarList.begin();
  QString str;
  
  if (selected) {
    painter->eraseRect( 0, 0, cr.width(), cr.height() );
    painter->fillRect( 0, 0, cr.width(), cr.height(), cg.highlight() );
    painter->setPen(cg.highlightedText());
  } else {
    painter->eraseRect( 0, 0, cr.width(), cr.height() );
    painter->fillRect( 0, 0, cr.width(), cr.height(), cg.base() );
    painter->setPen(cg.text());
  }
  
  it += row;
  if( col == 0 ) {
    str = (*it)->tagName();
  } else if( col == 1 ) {
    str = (*it)->label();
  }
  
  painter->drawText(0, 0, cr.width(), cr.height(), AlignLeft, str);
}
Beispiel #14
0
//////////////////////////////////////////////////////////////////////////////////////////
/// CLASS QueueItem
//////////////////////////////////////////////////////////////////////////////////////////
void
QueueItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
    KListViewItem::paintCell( p, cg, column, width, align );

    QString str = QString::number( ( static_cast<KListView *>( listView() ) )->itemIndex( this ) + 1 );

    //draw the symbol's outline
    uint fw = p->fontMetrics().width( str ) + 2;
    const uint w  = 16; //keep this even
    const uint h  = height() - 2;

    p->setBrush( cg.highlight() );
    p->setPen( cg.highlight().dark() ); //TODO blend with background color
    p->drawEllipse( width - fw - w/2, 1, w, h );
    p->drawRect( width - fw, 1, fw, h );
    p->setPen( cg.highlight() );
    p->drawLine( width - fw, 2, width - fw, h - 1 );

    fw += 2; //add some more padding
    p->setPen( cg.highlightedText() );
    p->drawText( width - fw, 2, fw, h-1, Qt::AlignCenter, str );
}
Beispiel #15
0
void MainWindow::buildPalette()
{
    int i;
    QColorGroup cg;
    QColor btn = buttonMainColor->color();
    QColor back = buttonMainColor2->color();
    QPalette automake( btn, back );

    for (i = 0; i<9; i++)
        cg.setColor( centralFromItem(i), automake.active().color( centralFromItem(i) ) );

    editPalette.setActive( cg );
    buildActiveEffect();

    cg = editPalette.inactive();

    QPalette temp( editPalette.active().color( QColorGroup::Button ),
                   editPalette.active().color( QColorGroup::Window ) );

    for (i = 0; i<9; i++)
        cg.setColor( centralFromItem(i), temp.inactive().color( centralFromItem(i) ) );

    editPalette.setInactive( cg );
    buildInactiveEffect();

    cg = editPalette.disabled();

    for (i = 0; i<9; i++)
        cg.setColor( centralFromItem(i), temp.disabled().color( centralFromItem(i) ) );

    editPalette.setDisabled( cg );
    buildDisabledEffect();

    updateColorButtons();

    setModified(true);
}
Beispiel #16
0
void UserViewItemBase::paintCell(QPainter *p, const QColorGroup &cg, int, int width, int)
{
    UserListBase *view = static_cast<UserListBase*>(listView());
    width = view->width() - 4;
    QScrollBar *vBar = view->verticalScrollBar();
    if (vBar->isVisible())
        width -= vBar->width();
    if (width < 1)
        width = 1;
    QPixmap bg(width, height());
    QPainter pp(&bg);
    int margin = 0;
    if (isSelected() && view->hasFocus() && CorePlugin::m_plugin->getUseDblClick()){
        pp.fillRect(QRect(0, 0, width, height()), cg.highlight());
        pp.setPen(cg.highlightedText());
    }else{
        pp.fillRect(QRect(0, 0, width, height()), cg.base());
        PaintView pv;
        pv.p        = &pp;
        pv.pos      = view->viewport()->mapToParent(view->itemRect(this).topLeft());
        pv.size		= QSize(width, height());
        pv.win      = view;
        pv.isStatic = false;
        pv.height   = height();
        pv.margin   = 0;
        if (CorePlugin::m_plugin->getUseSysColors()){
            pp.setPen(cg.text());
        }else{
            pp.setPen(QColor(CorePlugin::m_plugin->getColorOnline()));
        }
        Event e(EventPaintView, &pv);
        e.process();
        view->setStaticBackground(pv.isStatic);
        margin = pv.margin;
    }
    view->drawItem(this, &pp, cg, width, margin);
    pp.end();
    if (view->m_pressedItem == this){
        p->drawPixmap(QPoint(1, 1), bg);
        if (CorePlugin::m_plugin->getUseSysColors()){
            p->setPen(cg.text());
        }else{
            p->setPen(QColor(CorePlugin::m_plugin->getColorOnline()));
        }
        p->moveTo(0, 0);
        p->lineTo(width - 1, 0);
        p->lineTo(width - 1, height() - 1);
        p->lineTo(0, height() - 1);
        p->lineTo(0, 0);
        p->setPen(cg.shadow());
        p->moveTo(width - 2, 1);
        p->lineTo(1, 1);
        p->lineTo(1, height() - 2);
    }else{
        p->drawPixmap(QPoint(0, 0), bg);
    }
}
Beispiel #17
0
void FreshStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h,
	const QColorGroup &cg, int state, bool down, bool enabled )
{
    QColorGroup mycg( cg );
    mycg.setBrush( QColorGroup::Button, QBrush() );
    QBrush fill;
    drawButton( p, x, y, w, h, mycg, TRUE, 0 );
    if ( down )
	fill = cg.brush( QColorGroup::Button );
    else
	fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
    mycg.setBrush( QColorGroup::Button, fill );
    p->fillRect( x+1, y+1, w-2, h-2, fill );
    if ( state != QButton::Off ) {
	QPointArray a( 7*2 );
	int i, xx, yy;
	xx = x+3;
	yy = y+5;
	for ( i=0; i<3; i++ ) {
	    a.setPoint( 2*i,   xx, yy );
	    a.setPoint( 2*i+1, xx, yy+2 );
	    xx++; yy++;
	}
	yy -= 2;
	for ( i=3; i<7; i++ ) {
	    a.setPoint( 2*i,   xx, yy );
	    a.setPoint( 2*i+1, xx, yy+2 );
	    xx++; yy--;
	}
	if ( state == QButton::NoChange ) {
	    p->setPen( mycg.dark() );
	} else {
	    p->setPen( mycg.text() );
	}
	p->drawLineSegments( a );
    }
}
Beispiel #18
0
void FreshStyle::drawButton( QPainter *p, int x, int y, int w, int h,
                                const QColorGroup &cg, bool sunken, const QBrush* fill )
{
    QPen oldPen = p->pen();
    int off = sunken ? 1 : 0;
    p->fillRect( x+1+off, y+1+off, w-3, h-3, fill?(*fill):cg.brush(QColorGroup::Button) );

    int x2 = x+w-1;
    int y2 = y+h-1;

    if ( sunken )
	p->setPen( cg.dark() );
    else
	p->setPen( cg.light() );
    p->drawLine( x, y, x, y2-1 );
    p->drawLine( x, y, x2, y );

    if ( sunken ) {
	p->setPen( white );
	p->drawLine( x+1, y+1, x+1, y2-2 );
	p->drawLine( x+1, y+1, x2-2, y+1 );
    }

    if ( sunken )
	p->setPen( cg.light() );
    else
	p->setPen( cg.dark() );
    p->drawLine( x2, y+1, x2, y2 );
    p->drawLine( x, y2, x2, y2 );

    if ( !sunken ) {
	p->setPen( white );
	p->drawLine( x2-1, y+1, x2-1, y2-1 );
	p->drawLine( x+1, y2-1, x2-1, y2-1 );
    }
    p->setPen( oldPen );
}
/*!
  Paint an axis

  \param painter Painter
  \param axisId Axis id (QwtPolar::Axis)
*/
void QwtPolarGrid::drawAxis( QPainter *painter, int axisId ) const
{
  if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
    return;

  AxisData &axis = d_data->axisData[axisId];

  painter->setPen( axis.pen );
  painter->setFont( axis.font );

#if QT_VERSION < 0x040000
  QColorGroup cg;
  cg.setColor( QColorGroup::Foreground, axis.pen.color() );
  cg.setColor( QColorGroup::Text, axis.pen.color() );

  axis.scaleDraw->draw( painter, cg );
#else
  QPalette pal;
  pal.setColor( QPalette::Foreground, axis.pen.color() );
  pal.setColor( QPalette::Text, axis.pen.color() );

  axis.scaleDraw->draw( painter, pal );
#endif
}
void QSimpleRichText::draw( QPainter *p,  int x, int y, const QRect& clipRect,
			    const QColorGroup& cg, const QBrush* paper ) const
{
    p->save();
    if ( d->cachedWidth < 0 )
	d->adjustSize(p);

    QRect r = clipRect;
    if ( !r.isNull() )
	r.moveBy( -x, -y );

    if ( paper )
	d->doc->setPaper( new QBrush( *paper ) );
    QColorGroup g = cg;
    if ( d->doc->paper() )
	g.setBrush( QColorGroup::Base, *d->doc->paper() );

    if ( !clipRect.isNull() )
	p->setClipRect( clipRect, QPainter::CoordPainter );
    p->translate( x, y );
    d->doc->draw( p, r, g, paper );
    p->translate( -x, -y );
    p->restore();
}
FLAccessControlForm::FLAccessControlForm() : FLAccessControl() {
  QColorGroup cg;
  QColor bg = qApp->palette().color( QPalette::Active, QColorGroup::Background );
  cg.setColor( QColorGroup::Foreground, bg );
  cg.setColor( QColorGroup::Text, bg );
  cg.setColor( QColorGroup::ButtonText, bg );
  cg.setColor( QColorGroup::Base, bg );
  cg.setColor( QColorGroup::Background, bg );
  pal.setDisabled( cg );
}
Beispiel #22
0
void PColorButton::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
{
/*    p->setBrush(value.toColor());
    p->setPen(Qt::NoPen);
    p->drawRect(r);*/
    p->setPen(Qt::NoPen);
    p->setBrush(cg.background());
    p->drawRect(r);

    p->setBrush(value.toColor());
    p->setPen(Qt::SolidLine);
    QRect r2(r);
    r2.setTopLeft(r.topLeft() + QPoint(5,5));
    r2.setBottomRight(r.bottomRight() - QPoint(5,5));
    p->drawRect(r2);
}
Beispiel #23
0
void
QWindowsStyle::drawPanel( QPainter *p, int x, int y, int w, int h,
		const QColorGroup &g, bool sunken,
		   int lineWidth, const QBrush* fill)
{
    if ( lineWidth == 2 ) {
	if (sunken)
	    drawWinShades( p, x, y, w, h,
			   g.dark(), g.light(), g.shadow(), g.midlight(),
			   fill );
	else
	    drawWinShades( p, x, y, w, h,
			   g.light(), g.shadow(), g.midlight(), g.dark(),
			   fill );
    }
    else
	QStyle::drawPanel( p, x, y, w, h, g, sunken, lineWidth, fill );
}
Beispiel #24
0
/** Paint on @p painter
  *       in (@p x, @p y, @p width, @p height)
  *       using @p colorGroup for the button drawing (if @p isHovered)
  *       and the LinkLook color() for the text,
  *       unless [the LinkLook !color.isValid() and it does not useLinkColor()] or [@p isDefaultColor is false]: in this case it will use @p colorGroup.text().
  *       It will draw the button if @p isIconButtonHovered.
  */
void LinkDisplay::paint(QPainter *painter, int x, int y, int width, int height, const QColorGroup &colorGroup,
                        bool isDefaultColor, bool isSelected, bool isHovered, bool isIconButtonHovered) const
{
	int BUTTON_MARGIN = kapp->style()->pixelMetric(QStyle::PM_ButtonMargin);
	int LINK_MARGIN   = BUTTON_MARGIN + 2;

	QPixmap pixmap;
	// Load the preview...:
	if (!isHovered && m_look->previewEnabled() && !m_preview.isNull())
		pixmap  = m_preview;
	// ... Or the icon (if no preview or if the "Open" icon should be shown):
	else {
		int           iconSize   = m_look->iconSize();
		QString       iconName   = (isHovered ? Global::openNoteIcon() : m_icon);
		KIconLoader::States iconState  = (isIconButtonHovered ? KIconLoader::ActiveState : KIconLoader::DefaultState);
		pixmap = KIconLoader::global()->loadIcon(
            iconName, KIconLoader::Desktop, iconSize, iconState, QStringList(),
            0L, /*canReturnNull=*/false
            );
	}
	int iconPreviewWidth  = qMax(m_look->iconSize(), (m_look->previewEnabled() ? m_preview.width()  : 0));
	int pixmapX = (iconPreviewWidth - pixmap.width()) / 2;
	int pixmapY = (height - pixmap.height()) / 2;
	// Draw the button (if any) and the icon:
	if (isHovered) {
        QStyleOption opt;
        opt.rect = QRect(-1, -1, iconPreviewWidth + 2*BUTTON_MARGIN, height + 2);        
        opt.state = isIconButtonHovered ? (QStyle::State_MouseOver | QStyle::State_Enabled)  : QStyle::State_Enabled;
		kapp->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, &opt, painter);
    }
	painter->drawPixmap(x + BUTTON_MARGIN - 1 + pixmapX, y + pixmapY, pixmap);

	// Figure out the text color:
	if (isSelected) {
		painter->setPen(kapp->palette().color(QPalette::HighlightedText));
	} else if (isIconButtonHovered)
		painter->setPen(m_look->effectiveHoverColor());
	else if (!isDefaultColor || (!m_look->color().isValid() && !m_look->useLinkColor())) // If the color is FORCED or if the link color default to the text color:
		painter->setPen(colorGroup.text());
	else
		painter->setPen(m_look->effectiveColor());
	// Draw the text:
	painter->setFont(labelFont(m_font, isIconButtonHovered));
	painter->drawText(x + BUTTON_MARGIN - 1 + iconPreviewWidth + LINK_MARGIN, y, width - BUTTON_MARGIN + 1 - iconPreviewWidth - LINK_MARGIN, height,
	                  Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, m_title);
}
Beispiel #25
0
void QSlider::drawTicks( QPainter *p, const QColorGroup& g, int dist, int w,
			 int i ) const
{
    p->setPen( g.foreground() );
    int v = minValue();
    int fudge = slideLength() / 2 + 1;
    if(!i) 
	i = 1;
    while ( v <= maxValue() + 1 ) {
	int pos = positionFromValue( v ) + fudge;
	if ( orient == Horizontal )
	    p->drawLine( pos, dist, pos, dist + w );
	else
	    p->drawLine( dist, pos, dist + w, pos );
	v += i;
    }
}
Beispiel #26
0
/*! \brief Returns a palette with colored scrollbars
 *
 *  This method creates a palette with skin specific scrollbar colors.
 *  Parent should be a widget that holds a "default" active palette, which will
 *  be used as base for the resulting palette.
 *  The returned QPalette is a copy of the parent palette but with modified
 *  scrollbar colors: QColorGroup::Highlight, QColorGroup::Button,
 *  QColorGroup::Foreground, QColorGroup::Background and QColorGroup::ButtonText.
 */
QPalette CSkin::palette(QWidget *parent)
{
  QPalette pal;
  QColorGroup cg;
  cg = parent->QWidget::palette().active(); // copy active palette from parent
  // ButtonText +  arrow of scrollbar
  if (colors.btnTxt)
  {
    cg.setColor(QColorGroup::ButtonText, QColor(colors.btnTxt));
    cg.setColor(QColorGroup::Foreground, cg.buttonText());
  }
  // Scrollbar
  if (colors.scrollbar)
  {
    cg.setColor(QColorGroup::Highlight, QColor(colors.scrollbar));
    cg.setColor(QColorGroup::Button, cg.highlight());
    cg.setColor(QColorGroup::Background, cg.highlight());
  }
  pal.setActive(cg);
  pal.setInactive(cg);
  pal.setDisabled(cg);
  return pal;
}
Beispiel #27
0
void QWindowsStyle::drawExclusiveIndicator( QPainter* p,
				   int x, int y, int w, int h, const QColorGroup &g,
				   bool on, bool down, bool enabled )
{

    static const QCOORD pts1[] = {		// dark lines
	1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
    static const QCOORD pts2[] = {		// black lines
	2,8, 1,7, 1,4, 2,3, 2,2, 3,2, 4,1, 7,1, 8,2, 9,2 };
    static const QCOORD pts3[] = {		// background lines
	2,9, 3,9, 4,10, 7,10, 8,9, 9,9, 9,8, 10,7, 10,4, 9,3 };
    static const QCOORD pts4[] = {		// white lines
	2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
	11,4, 10,3, 10,2 };
    static const QCOORD pts5[] = {		// inner fill
	4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
    p->eraseRect( x, y, w, h );
    QPointArray a( QCOORDARRLEN(pts1), pts1 );
    a.translate( x, y );
    p->setPen( g.dark() );
    p->drawPolyline( a );
    a.setPoints( QCOORDARRLEN(pts2), pts2 );
    a.translate( x, y );
    p->setPen( g.shadow() );
    p->drawPolyline( a );
    a.setPoints( QCOORDARRLEN(pts3), pts3 );
    a.translate( x, y );
    p->setPen( g.midlight() );
    p->drawPolyline( a );
    a.setPoints( QCOORDARRLEN(pts4), pts4 );
    a.translate( x, y );
    p->setPen( g.light() );
    p->drawPolyline( a );
    a.setPoints( QCOORDARRLEN(pts5), pts5 );
    a.translate( x, y );
    QColor fillColor = ( down || !enabled ) ? g.button() : g.base();
    p->setPen( fillColor );
    p->setBrush( fillColor  ) ;
    p->drawPolygon( a );
    if ( on ) {
	p->setPen( NoPen );
	p->setBrush( g.text() );
	p->drawRect( x+5, y+4, 2, 4 );
	p->drawRect( x+4, y+5, 4, 2 );
    }

}
void ConfigurationItem::paintCell(QPainter *p, const QColorGroup &cg, int column,
    int width, int align)
{
    if ( (column == 0) || (column == 1) || (column == 2) )
    {
        if ( !p )
            return;
    
        QListView *lv = listView();
        if ( !lv )
            return;
    
        const BackgroundMode bgmode = lv->viewport()->backgroundMode();
        const QColorGroup::ColorRole crole = QPalette::backgroundRoleFromMode( bgmode );
        p->fillRect(0, 0, width, height(), cg.brush(crole));

        QFontMetrics fm(lv->fontMetrics());
        int boxsize = lv->style().pixelMetric(QStyle::PM_CheckListButtonSize, lv);
        int marg = lv->itemMargin();
        int styleflags = QStyle::Style_Default;
                
        if (((column == 0) && m_contents) || ((column == 1) && m_index) || ((column == 2) && m_fullTextSearch))
            styleflags |= QStyle::Style_On;
        else
            styleflags |= QStyle::Style_Off;
        if ((column == 0) || ((column == 1) && m_indexPossible) || ((column == 2) && m_fullTextSearchPossible))
            styleflags |= QStyle::Style_Enabled;

        int x = 0;
        int y = 0;
        x += 3;
        if (align & AlignVCenter)
            y = ((height() - boxsize) / 2) + marg;
        else
            y = (fm.height() + 2 + marg - boxsize) / 2;

        QStyleOption opt(this);
        lv->style().drawPrimitive(QStyle::PE_CheckListIndicator, p,
            QRect(x, y, boxsize, fm.height() + 2 + marg), cg, styleflags, opt);
               
        return;
    }
    QListViewItem::paintCell(p, cg, column, width, align);
}
Beispiel #29
0
void WorkspaceItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
{
    QColorGroup g( cg );
    g.setColor( QColorGroup::Base, backgroundColor() );
    g.setColor( QColorGroup::Foreground, Qt::black );

    if ( type() == FormSourceType &&
	 ( !formFile->hasFormCode() || ( formFile->codeFileState() == FormFile::Deleted && formFile->formWindow() ) ) &&
	 parent() && parent()->parent() && ( (WorkspaceItem*)parent()->parent() )->project &&
	 ( (WorkspaceItem*)parent()->parent() )->project->isCpp() ) {
	g.setColor( QColorGroup::Text, listView()->palette().disabled().color( QColorGroup::Text) );
	g.setColor( QColorGroup::HighlightedText, listView()->palette().disabled().color( QColorGroup::Text) );
    } else {
	g.setColor( QColorGroup::Text, Qt::black );
    }
    p->save();

    if ( isModified() ) {
	QFont f = p->font();
	f.setBold( TRUE );
	p->setFont( f );
    }

    QListViewItem::paintCell( p, g, column, width, align );
    p->setPen( QPen( cg.dark(), 1 ) );
    if ( column == 0 )
	p->drawLine( 0, 0, 0, height() - 1 );
    if ( listView()->firstChild() != this ) {
	if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) {
	    int d = depth() - itemBelow()->depth();
	    p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 );
	}
    }
    p->drawLine( 0, height() - 1, width, height() - 1 );
    p->drawLine( width - 1, 0, width - 1, height() );
    p->restore();
}
Beispiel #30
0
void DriverItem::paintCell(QPainter *p, const QColorGroup &cg, int, int width, int)
{
    // background
    p->fillRect(0, 0, width, height(), cg.base());

    // highlight rectangle
    if(isSelected())
        p->fillRect(0, 0, /*2+p->fontMetrics().width(text(0))+(pixmap(0) ? pixmap(0)->width()+2 : 0)*/ width, height(),
                    (m_conflict ? red : cg.highlight()));

    // draw pixmap
    int w(0);
    if(pixmap(0) && !pixmap(0)->isNull())
    {
        int h((height() - pixmap(0)->height()) / 2);
        p->drawPixmap(w, h, *pixmap(0));
        w += (pixmap(0)->width() + 2);
    }

    // draw Text
    if(!m_item || !m_item->isOption() || isSelected())
    {
        p->setPen((isSelected() ? cg.highlightedText() : (m_conflict ? red : cg.text())));
        p->drawText(w, 0, width - w, height(), Qt::AlignLeft | Qt::AlignVCenter, text(0));
    }
    else
    {
        int w1(0);
        QString s(m_item->get("text") + ": <");
        w1 = p->fontMetrics().width(s);
        p->setPen(cg.text());
        p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s);
        w += w1;
        p->setPen((m_conflict ? red : darkGreen));
        s = m_item->prettyText();
        w1 = p->fontMetrics().width(s);
        p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s);
        w += w1;
        p->setPen(cg.text());
        s = QString::fromLatin1(">");
        w1 = p->fontMetrics().width(s);
        p->drawText(w, 0, w1, height(), Qt::AlignLeft | Qt::AlignVCenter, s);
    }
}