void HideButton::drawButton(QPainter *p)
{
    if (m_arrow == Qt::LeftArrow)
    {
        p->setPen(palette().color(QPalette::Mid));
        p->drawLine(width()-1, 0, width()-1, height());
    }
    else if (m_arrow == Qt::RightArrow)
    {
        p->setPen(palette().color(QPalette::Mid));
        p->drawLine(0, 0, 0, height());
    }
    else if (m_arrow == Qt::UpArrow)
    {
        p->setPen(palette().color(QPalette::Mid));
        p->drawLine(0, height()-1, width(), height()-1);
    }
    else if (m_arrow == Qt::DownArrow)
    {
        p->setPen(palette().color(QPalette::Mid));
        p->drawLine(0, 0, width(), 0);
    }

    drawButtonLabel(p);
}
Exemple #2
0
void ColorButton::drawButton(QPainter *p)
{
	QStyleOptionButton buttonOptions;
	buttonOptions.init(this);
	buttonOptions.features = QStyleOptionButton::None;
	buttonOptions.rect = rect();
	buttonOptions.palette = palette();
	buttonOptions.state = (isDown() ? QStyle::State_Sunken : QStyle::State_Raised);

	if (!mIsFlat)
	{
		style()->drawPrimitive(QStyle::PE_PanelButtonBevel, &buttonOptions, p, this);
	}
	else
	{
		style()->drawPrimitive(QStyle::PE_FrameDefaultButton, &buttonOptions, p, this);
	}

	p->save();
	drawButtonLabel(p);
	p->restore();

	QStyleOptionFocusRect frectOptions;
	frectOptions.init(this);
	frectOptions.rect = style()->subElementRect(QStyle::SE_PushButtonFocusRect, &buttonOptions, this);
	if (hasFocus())
	{
		style()->drawPrimitive(QStyle::PE_FrameFocusRect, &frectOptions, p, this);
	}
}
Exemple #3
0
void QuickButton::drawButton(QPainter *p)
{
   if (isDown() || isOn()) {
      p->fillRect(rect(), colorGroup().brush(QColorGroup::Mid));
      qDrawWinButton(p, 0, 0, width(), height(), colorGroup(), true);
   }

   drawButtonLabel(p);
}
void StyledButton::drawButton( QPainter *paint )
{
    style().drawPrimitive(QStyle::PE_ButtonBevel, paint, rect(), colorGroup(),
			  isDown() ? QStyle::Style_Sunken : QStyle::Style_Default);
    drawButtonLabel(paint);

    if (hasFocus())
	style().drawPrimitive(QStyle::PE_FocusRect, paint,
			      style().subRect(QStyle::SR_PushButtonFocusRect, this),
			      colorGroup(), QStyle::Style_Default);
}
void StringBody::drawButton(QPainter *painter) {
    if (appearance == HYPERLINK) {
      drawButtonLabel(painter);
      if (hasFocus()) {
        style().drawFocusRect(
            painter, rect(), colorGroup(), &colorGroup().button());
      }
    } else {
      QPushButton::drawButton(painter);
    }
}
Exemple #6
0
void ColorButton::drawButton(QPainter *p)
{
    style().drawPrimitive(QStyle::PE_ButtonBevel, p, rect(), colorGroup(),
			  isDown() ? QStyle::Style_Down : QStyle::Style_Raised);
    drawButtonLabel(p);

    if (hasFocus())
	style().drawPrimitive(QStyle::PE_FocusRect, p,
			      style().subRect(QStyle::SR_PushButtonFocusRect, this),
			      colorGroup(), QStyle::Style_Default);
}
Exemple #7
0
void HoverButton::paintEvent( QPaintEvent * e )
{
    if ( hasMouse() )
    {
        QPushButton::paintEvent( e );
    }
    else
    {
        QPainter p( this );
        p.fillRect(e->rect(), parentWidget() ? parentWidget()->palette().brush(QPalette::Active, QColorGroup::Background) : paletteBackgroundColor());
        drawButtonLabel( &p );
    }
}
Exemple #8
0
void WeatherButton::drawButton( QPainter *p )
{
    if ( isDown() || isOn() )
    {
        p->setPen( Qt::black );
        p->drawLine( 0, 0, width()-1, 0 );
        p->drawLine( 0, 0, 0, height()-1 );
        p->setPen( colorGroup().light() );
        p->drawLine( 0, height()-1, width()-1, height()-1 );
        p->drawLine( width()-1, 0, width()-1, height()-1 );
    }

    drawButtonLabel( p );
}
void ImageBody::drawButton(QPainter *painter) {
  if (appearance == HYPERLINK) {
    drawButtonLabel(painter); 
    // by default focus is drawn on top of the button;
    // hilight might not be visible if image background is black.
    // To make sure that hilight is visible we do not call 
    // QPushButton::drawButton() and draw hilight outside of the image
    if (qteapp_get_application()->focusWidget() == this) { // draw focus
      painter->drawWinFocusRect(2, 2, width() - 4, height() - 4);
    }
  } else {
    QPushButton::drawButton(painter);
  }
}
Exemple #10
0
/*------------------------------------------------------------------*
 * MODIFICATIONS													*
 *	Date		Description							Author			*
 * ===========	==================================	===============	*
 *																	*
 *------------------------------------------------------------------*/
void ZPushButton::drawButton(QPainter *p)
{
	QRect	vRect = rect();
	QPixmap *vPix;

	if (!isEnabled())
		vPix = mDisabledPix;
	else if (isDown())
		vPix = mDownPix;
	else
		vPix = mUpPix;
	
	if (pixmap() != NULL)
		p->drawPixmap(vRect.x() , vRect.y(), *vPix);
	drawButtonLabel(p);
}
Exemple #11
0
void KKeyButton::paint( QPainter *painter )
{
	QPointArray a( 4 );
	a.setPoint( 0, 0, 0) ;
	a.setPoint( 1, width(), 0 );
	a.setPoint( 2, 0, height() );
	a.setPoint( 3, 0, 0 );

	QRegion r1( a );
	painter->setClipRegion( r1 );
	painter->setBrush( backgroundColor().light() );
	painter->drawRoundRect( 0, 0, width(), height(), 20, 20);

	a.setPoint( 0, width(), height() );
	a.setPoint( 1, width(), 0 );
	a.setPoint( 2, 0, height() );
	a.setPoint( 3, width(), height() );

	QRegion r2( a );
	painter->setClipRegion( r2 );
	painter->setBrush( backgroundColor().dark() );
	painter->drawRoundRect( 0, 0, width(), height(), 20, 20 );

	painter->setClipping( FALSE );
	if( width() > 12 && height() > 8 )
	qDrawShadePanel( painter, 6, 4, width() - 12, height() - 8, 
								colorGroup(), TRUE, 1, 0L );
	if ( editing ) {
		painter->setPen( colorGroup().base() );
		painter->setBrush( colorGroup().base() );
	} else {
		painter->setPen( backgroundColor() );
		painter->setBrush( backgroundColor() );
	}
	if( width() > 14 && height() > 10 )
	painter->drawRect( 7, 5, width() - 14, height() - 10 ); 

	drawButtonLabel( painter );
	
	painter->setPen( colorGroup().text() );
	painter->setBrush( NoBrush );
	if( hasFocus() || editing ) {
		if( width() > 16 && height() > 12 )
		painter->drawRect( 8, 6, width() - 16, height() - 12 );
	}	
}
Exemple #12
0
void SimpleButton::drawButton( QPainter *p )
{
    p->setPen(colorGroup().mid());

    if (m_orientation == Qt::Vertical)
    {
        p->drawLine(0, height() - 1, width(), height() - 1);
    }
    else if (kapp->reverseLayout())
    {
        p->drawLine(0, 0, 0, height());
    }
    else
    {
        p->drawLine(width() - 1, 0, width() - 1, height());
    }

    drawButtonLabel(p);
}
Exemple #13
0
void FLCheckBox::drawButton(QPainter *p)
{
  QRect rect, wrect(this->rect());
  rect.setRect((wrect.width() - 13) / 2, (wrect.height() - 13) / 2, 13, 13);

  if (state() == QButton::On) {
    QBrush bu(green, SolidPattern);
    p->fillRect(0, 0, wrect.width() - 1, wrect.height() - 1, bu);
  }

  QRect irect = QStyle::visualRect(rect, this);
  p->fillRect(irect, Qt::white);
  p->drawRect(irect);

  if (state() == QButton::On) {
    QPointArray a(7 * 2);
    int i, xx, yy;
    xx = irect.x() + 3;
    yy = irect.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--;
    }

    p->drawLineSegments(a);
  }

  drawButtonLabel(p);
}
Exemple #14
0
void PanelButton::drawButton(QPainter *p)
{
    if (m_tileColor.isValid())
    {
        p->fillRect(rect(), m_tileColor);
        style().drawPrimitive(QStyle::PE_Panel, p, rect(), colorGroup());
    }
    else if (paletteBackgroundPixmap())
    {
        // Draw the background. This is always needed, even when using tiles,
        // because they don't have to cover the entire button.
        p->drawPixmap(0, 0, *paletteBackgroundPixmap());
    }

    const QPixmap& tile = (isDown() || isOn()) ? m_down : m_up;
    if (!tile.isNull())
    {
        // Draw the tile.
        p->drawPixmap(0, 0, tile);
    }
    else if (isDown() || isOn())
    {
        // Draw shapes to indicate the down state.
        style().drawPrimitive(QStyle::PE_Panel, p, rect(), colorGroup(), QStyle::Style_Sunken);
    }

    drawButtonLabel(p);

    if (hasFocus() || m_hasAcceptedDrag)
    {
        int x1, y1, x2, y2;
        rect().coords(&x1, &y1, &x2, &y2);
        QRect r(x1+2, y1+2, x2-x1-3, y2-y1-3);
        style().drawPrimitive(QStyle::PE_FocusRect, p, r, colorGroup(),
        QStyle::Style_Default, colorGroup().button());
    }
}
Exemple #15
0
void QwtArrowButton::paintEvent(QPaintEvent *event)
{
    QPushButton::paintEvent(event);
    QPainter painter(this);
    drawButtonLabel(&painter);
}
Exemple #16
0
/*!\reimp
*/
void QRadioButton::drawButton( QPainter *paint )
{
    QPainter	*p = paint;
    const QColorGroup & g = colorGroup();
    int		 x, y;

    QFontMetrics fm = fontMetrics();
    QSize lsz = fm.size(ShowPrefix, text());
    QSize sz = style().exclusiveIndicatorSize();
    x = text().isEmpty() ? 1 : 0;
    y = (height() - lsz.height() + fm.height() - sz.height())/2;

#ifndef QT_NO_TEXTSTREAM
#define SAVE_RADIOBUTTON_PIXMAPS
#endif

#if defined(SAVE_RADIOBUTTON_PIXMAPS)
    QString pmkey;				// pixmap key
    int kf = 0;
    if ( isDown() )
	kf |= 1;
    if ( isOn() )
	kf |= 2;
    if ( isEnabled() )
	kf |= 4;
    QTextOStream os(&pmkey);
    os << "$qt_radio_" << style().className() << "_"
			 << palette().serialNumber() << "_" << kf;
    QPixmap *pm = QPixmapCache::find( pmkey );
    if ( pm ) {					// pixmap exists
	drawButtonLabel( p );
	p->drawPixmap( x, y, *pm );
	return;
    }
    bool use_pm = TRUE;
    QPainter pmpaint;
    int wx, wy;
    if ( use_pm ) {
	pm = new QPixmap( sz );			// create new pixmap
	CHECK_PTR( pm );
	pmpaint.begin( pm );
	p = &pmpaint;				// draw in pixmap
	wx=x;  wy=y;				// save x,y coords
	x = y = 0;
	p->setBackgroundColor( g.background() );
    }
#endif

#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)

    style().drawExclusiveIndicator(p, x, y, sz.width(), sz.height(), g, isOn(), isDown(), isEnabled() );

#if defined(SAVE_RADIOBUTTON_PIXMAPS)
    if ( use_pm ) {
	pmpaint.end();
	if ( backgroundPixmap() || backgroundMode() == X11ParentRelative ) {
	    QBitmap bm( pm->size() );
	    bm.fill( color0 );
	    pmpaint.begin( &bm );
	    style().drawExclusiveIndicatorMask( &pmpaint, 0, 0, bm.width(), bm.height(), isOn() );
	    pmpaint.end();
	    pm->setMask( bm );
	}
	p = paint;				// draw in default device
	p->drawPixmap( wx, wy, *pm );
	if (!QPixmapCache::insert(pmkey, pm) )	// save in cache
	    delete pm;
    }
#endif
    drawButtonLabel( p );
}