コード例 #1
0
ファイル: blwidget.cpp プロジェクト: trifolio6/Bulmages
/* Necesario para poner estilos a traves de hojas CSS.
*/
void BlWidget::paintEvent ( QPaintEvent * )
{
    QStyleOption option;
    option.initFrom ( this );
    QPainter painter ( this );
    style()->drawPrimitive ( QStyle::PE_Widget, &option, &painter, this );
}
コード例 #2
0
ファイル: wdisplay.cpp プロジェクト: suyoghc/mixxx
void WDisplay::paintEvent(QPaintEvent* ) {
    QStyleOption option;
    option.initFrom(this);
    QStylePainter p(this);
    p.drawPrimitive(QStyle::PE_Widget, option);

    if (m_pPixmapBack) {
        m_pPixmapBack->draw(0, 0, &p);
    }

    // If we are disabled, use the disabled pixmaps. If not, use the regular
    // pixmaps.
    const QVector<PaintablePointer>& pixmaps = (isDisabled() && m_bDisabledLoaded) ?
            m_disabledPixmaps : m_pixmaps;

    if (pixmaps.empty()) {
        return;
    }

    int idx = getActivePixmapIndex();

    // Clamp active pixmap index to valid ranges.
    if (idx < 0) {
        idx = 0;
    } else if (idx >= pixmaps.size()) {
        idx = pixmaps.size() - 1;
    }

    PaintablePointer pPixmap = pixmaps[idx];
    if (pPixmap) {
        pPixmap->draw(0, 0, &p);
    }
}
コード例 #3
0
ファイル: MapWidget.cpp プロジェクト: amirbawab/PowerGrid
/// This method is required when Q_OBJECT is added
/// Without this method, the CSS will not be applied
void MapWidget::paintEvent(QPaintEvent *pe) {
    QStyleOption o;
    o.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(
        QStyle::PE_Widget, &o, &p, this);
};
コード例 #4
0
/*!
  Fill a pixmap with the content of a widget

  In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy
  for backgrounds with gradients. Thus fillPixmap() offers
  an alternative implementation.

  \param widget Widget
  \param pixmap Pixmap to be filled
  \param offset Offset

  \sa QPixmap::fill()
 */
void QwtPainter::fillPixmap( const QWidget *widget,
    QPixmap &pixmap, const QPoint &offset )
{
    const QRect rect( offset, pixmap.size() );

    QPainter painter( &pixmap );
    painter.translate( -offset );

    const QBrush autoFillBrush =
        widget->palette().brush( widget->backgroundRole() );

    if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) )
    {
        const QBrush bg = widget->palette().brush( QPalette::Window );
        qwtFillRect( widget, &painter, rect, bg);
    }

    if ( widget->autoFillBackground() )
        qwtFillRect( widget, &painter, rect, autoFillBrush);

    if ( widget->testAttribute(Qt::WA_StyledBackground) )
    {
        painter.setClipRegion( rect );

        QStyleOption opt;
        opt.initFrom( widget );
        widget->style()->drawPrimitive( QStyle::PE_Widget,
            &opt, &painter, widget );
    }
}
コード例 #5
0
ファイル: wknobcomposed.cpp プロジェクト: suyoghc/mixxx
void WKnobComposed::paintEvent(QPaintEvent* e) {
    Q_UNUSED(e);
    QStyleOption option;
    option.initFrom(this);
    QStylePainter p(this);
    p.setRenderHint(QPainter::Antialiasing);
    p.setRenderHint(QPainter::SmoothPixmapTransform);
    p.drawPrimitive(QStyle::PE_Widget, option);

    if (m_pPixmapBack) {
        m_pPixmapBack->draw(0, 0, &p);
    }

    if (!m_pKnob.isNull() && !m_pKnob->isNull()) {
        p.translate(width() / 2.0, height() / 2.0);

        // Value is in the range [0, 1].
        double value = getValue();

        double angle = m_dMinAngle + (m_dMaxAngle - m_dMinAngle) * value;
        p.rotate(angle);

        m_pKnob->draw(-m_pKnob->width() / 2.0, -m_pKnob->height() / 2.0, &p);
    }
}
コード例 #6
0
ファイル: lineedit.cpp プロジェクト: Atrament666/Clementine
ExtendedEditor::ExtendedEditor(QWidget* widget, int extra_right_padding,
                               bool draw_hint)
    : LineEditInterface(widget),
      has_clear_button_(true),
      clear_button_(new QToolButton(widget)),
      reset_button_(new QToolButton(widget)),
      extra_right_padding_(extra_right_padding),
      draw_hint_(draw_hint),
      font_point_size_(widget->font().pointSizeF() - 1),
      is_rtl_(false) {
  clear_button_->setIcon(IconLoader::Load("edit-clear-locationbar-ltr", IconLoader::Base));
  clear_button_->setIconSize(QSize(16, 16));
  clear_button_->setCursor(Qt::ArrowCursor);
  clear_button_->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  clear_button_->setToolTip(widget->tr("Clear"));
  clear_button_->setFocusPolicy(Qt::NoFocus);

  QStyleOption opt;
  opt.initFrom(widget);

  reset_button_->setIcon(widget->style()->standardIcon(
      QStyle::SP_DialogResetButton, &opt, widget));
  reset_button_->setIconSize(QSize(16, 16));
  reset_button_->setCursor(Qt::ArrowCursor);
  reset_button_->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  reset_button_->setToolTip(widget->tr("Reset"));
  reset_button_->setFocusPolicy(Qt::NoFocus);
  reset_button_->hide();

  widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(clear()));
  widget->connect(clear_button_, SIGNAL(clicked()), widget, SLOT(setFocus()));

  UpdateButtonGeometry();
}
コード例 #7
0
ファイル: displayarea.cpp プロジェクト: crapp/labpowerqt
void DisplayArea::paintEvent(ATTR_UNUSED QPaintEvent *event)
{
    QStyleOption o;
    o.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
コード例 #8
0
ファイル: devmode.cpp プロジェクト: MatteoMilandri/DSView
void DevMode::paintEvent(QPaintEvent*)
{
    using pv::view::Trace;

    QStyleOption o;
    o.initFrom(this);
    QPainter painter(this);
    style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);

    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::NoPen);
    for(std::map<boost::shared_ptr<QPushButton>, sr_dev_mode *>::const_iterator i = _mode_button_list.begin();
        i != _mode_button_list.end(); i++) {
        const boost::shared_ptr<device::DevInst> dev_inst = _view.session().get_device();
        assert(dev_inst);
        if (dev_inst->dev_inst()->mode == (*i).second->mode)
            painter.setBrush(Trace::dsBlue);
        else
            painter.setBrush(Trace::dsGray);

        painter.drawRoundedRect((*i).first->geometry(), 4, 4);
    }

    painter.end();
}
コード例 #9
0
void
CQSplitterHandle::
paintEvent(QPaintEvent *)
{
  QStylePainter ps(this);

  QStyleOption opt;

#if 0
  ps.fillRect(rect(), QBrush(QColor(100,100,150)));
#else
  opt.initFrom(this);

  opt.rect  = rect();
  opt.state = (! area_->isVerticalDockArea() ? QStyle::State_None : QStyle::State_Horizontal);

  if (mouseState_.pressed)
    opt.state |= QStyle::State_Sunken;

  if (mouseOver_)
    opt.state |= QStyle::State_MouseOver;

  ps.drawControl(QStyle::CE_Splitter, opt);
#endif
}
コード例 #10
0
ファイル: kled.cpp プロジェクト: ViktorNova/chipsynth
QSize KLed::sizeHint() const
{
    QStyleOption option;
    option.initFrom(this);
    int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, &option, this);
    return QSize( iconSize,  iconSize );
}
コード例 #11
0
ファイル: qwwfilechooser.cpp プロジェクト: TheDZhon/wwwidgets
/*!
 * Constructs a file chooser with a given \a parent.
 * 
 */
QwwFileChooser::QwwFileChooser(QWidget *parent) : QwwButtonLineEdit(*new QwwFileChooserPrivate(this), parent) {
    Q_D(QwwFileChooser);
#if QT_VERSION >= 0x040200 && !defined(QT_NO_COMPLETER)
    d->completer = new QCompleter(this);
    setCompleter(d->completer);
    QStyleOption opt;
    opt.initFrom(this);
    int mar = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, this);
    int siz = style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, this);
#if QT_VERSION >=0x040500
    setTextMargins(siz+2, 0, 0, 0);
#else
    setStyleSheet(QString("QwwFileChooser {padding-left: %1px;}").arg(mar+siz+2));
#endif

//     connect(this, SIGNAL(textEdited(const QString&)), d->completer, SLOT(setCompletionPrefix(const QString&)));
#endif
    setModel(new QDirModel(this));
    setButtonPosition(RightOutside);
    connect(this, SIGNAL(buttonClicked()), this, SLOT(chooseFile()));
    setAutoRaise(true);
    setAcceptMode(QFileDialog::AcceptOpen);

    QShortcut *sc = new QShortcut(QKeySequence("Ctrl+Space"), this);
    connect(sc, SIGNAL(activated()), d->completer, SLOT(complete()));
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(_q_textChanged(const QString&)));
}
コード例 #12
0
    virtual void paintEvent( QPaintEvent* ) {
        QPainter p( this );
        QStyleOption opt;
        opt.initFrom( this );
        QRect r = rect();

        const bool reverse = opt.direction == Qt::RightToLeft;
        const int menuButtonWidth = 12;
        const int rightSpacing = 10;
        const int right = !reverse ? r.right() - rightSpacing : r.left() + menuButtonWidth;
        const int height = r.height();

        QLine l1( 1, 0, right, height / 2 );
        QLine l2( 1, height, right, height / 2 );

        p.setRenderHint( QPainter::Antialiasing, true );

        // Draw the shadow
        QColor shadow( 0, 0, 0, 100 );
        p.translate( 0, 1 );
        p.setPen( shadow );
        p.drawLine( l1 );
        p.drawLine( l2 );

        // Draw the main arrow
        QColor foreGround( "#747474" );
        p.translate( 0, -1 );
        p.setPen( foreGround );
        p.drawLine( l1 );
        p.drawLine( l2 );
    }
コード例 #13
0
void ExpandButton::paintEvent(QPaintEvent* event) {
	QStylePainter painter(this);

	QStyleOption option;
	option.initFrom(this);

	QString pixmapName;
	if (isChecked()) {
		if (_expandDirection == ED_Down) {
			pixmapName = "down";
		} else {
			pixmapName = "up";
		}
	} else {
		pixmapName = "right";
	}

	if (option.state & QStyle::State_MouseOver) {
		pixmapName += "_hover";
	}
	QPixmap pixmap(QString(":/pics/expand_button/%1.png").arg(pixmapName));
	painter.drawPixmap(0, 0, pixmap);

	QRect textRect = rect();
	textRect.setLeft(pixmap.width());

	painter.drawItemText(textRect, Qt::TextShowMnemonic, option.palette, isEnabled(), text());
}
コード例 #14
0
ファイル: showwidget.cpp プロジェクト: superAzalea/qt_ocean
void ShowWidget::paintEvent(QPaintEvent *)
{
    QStyleOption op;
    op.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &op, &p, this);
}
コード例 #15
0
/*!
  Draw the background of the canvas
  \param painter Painter
*/ 
void QwtPlotGLCanvas::drawBackground( QPainter *painter )
{
    painter->save();

    QWidget *w = qwtBGWidget( this );

    const QPoint off = mapTo( w, QPoint() );
    painter->translate( -off );

    const QRect fillRect = rect().translated( off );

    if ( w->testAttribute( Qt::WA_StyledBackground ) )
    {
        painter->setClipRect( fillRect );

        QStyleOption opt;
        opt.initFrom( w );
        w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w);
    }
    else 
    {
        painter->fillRect( fillRect,
            w->palette().brush( w->backgroundRole() ) );
    }

    painter->restore();
}
コード例 #16
0
ファイル: lxqtgrouppopup.cpp プロジェクト: jsm222/lxqt-panel
void LXQtGroupPopup::paintEvent(QPaintEvent *event)
{
    QPainter p(this);
    QStyleOption opt;
    opt.initFrom(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
コード例 #17
0
/*!
   Calculate the painter path for a styled or rounded border

   When the canvas has no styled background or rounded borders
   the painter path is empty.

   \param rect Bounding rectangle of the canvas
   \return Painter path, that can be used for clipping
*/
QPainterPath QwtPlotCanvas::borderPath( const QRect &rect ) const
{
    if ( testAttribute(Qt::WA_StyledBackground ) )
    {
        QwtStyleSheetRecorder recorder( rect.size() );

        QPainter painter( &recorder );

        QStyleOption opt;
        opt.initFrom(this);
        opt.rect = rect;
        style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);

        painter.end();

        if ( !recorder.background.path.isEmpty() )
            return recorder.background.path;

        if ( !recorder.border.rectList.isEmpty() )
            return qwtCombinePathList( rect, recorder.border.pathList );
    }
    else if ( d_data->borderRadius > 0.0 )
    {
        double fw2 = frameWidth() * 0.5;
        QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 );

        QPainterPath path;
        path.addRoundedRect( r, d_data->borderRadius, d_data->borderRadius );
        return path;
    }
    
    return QPainterPath();
}
コード例 #18
0
//! Update the cached informations about the current style sheet
void QwtPlotCanvas::updateStyleSheetInfo()
{
    if ( !testAttribute(Qt::WA_StyledBackground ) )
        return;

    QwtStyleSheetRecorder recorder( size() );
    
    QPainter painter( &recorder );
    
    QStyleOption opt;
    opt.initFrom(this);
    style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);
    
    painter.end();

    d_data->styleSheet.hasBorder = !recorder.border.rectList.isEmpty();
    d_data->styleSheet.cornerRects = recorder.clipRects;

    if ( recorder.background.path.isEmpty() )
    {
        if ( !recorder.border.rectList.isEmpty() )
        {
            d_data->styleSheet.borderPath = 
                qwtCombinePathList( rect(), recorder.border.pathList );
        }
    }
    else
    {
        d_data->styleSheet.borderPath = recorder.background.path;
        d_data->styleSheet.background.brush = recorder.background.brush;
        d_data->styleSheet.background.origin = recorder.background.origin;
    }
}
コード例 #19
0
void PanelAppletOverlay::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

    QStyleOption op;
    op.initFrom(this);

    bool hovered = op.state & QStyle::State_MouseOver;
    bool mover = mouseGrabber() == this;
    if (!hovered || mover) {
        return;
    }

    QPainter p(this);
    KIcon icon("transform-move");
    int iconSize;
    QRect iconRect;


    if (!m_applet) {
        return;
    }

    if (m_orientation == Qt::Horizontal) {
        iconSize = qMin(qMin(height(), int(m_applet->size().width())), 64);
        iconRect = QRect(rect().center() - QPoint(iconSize / 2, iconSize / 2), QSize(iconSize, iconSize));
    } else {
        iconSize = qMin(qMin(width(), int(m_applet->size().height())), 64);
        iconRect = QRect(rect().center() - QPoint(iconSize / 2, iconSize / 2), QSize(iconSize, iconSize));
    }

    p.drawPixmap(iconRect, icon.pixmap(iconSize, iconSize));
}
コード例 #20
0
void 
Context::AppletItemOverlay::paintEvent( QPaintEvent *event )
{
    Q_UNUSED( event )
    QStyleOption op;
    op.initFrom( this );

    bool hovered = op.state & QStyle::State_MouseOver;
    bool mover = mouseGrabber() == this;
    if( !hovered || mover ) 
    {
        return;
    }

    QPainter p( this );
    p.save();
    KIcon icon( "transform-move" );
    int iconSize;
    QRect iconRect;

    if( m_applet )
    {   // it's possible m_applet is null if we just opened amarok and it failed to load the applet plugin
        // so the user is seeing a big red X and trying to get rid of item
        iconSize = qMin( qMin( height(), int( m_applet->size().width() ) ), 64 );
        iconRect = QRect( rect().center() - QPoint( iconSize / 2, iconSize / 2 ), QSize( iconSize, iconSize ) );
        p.drawPixmap( iconRect, icon.pixmap( iconSize, iconSize ) );        
    }

    p.restore();
}
コード例 #21
0
void ScopeWidget::setIcon( const QIcon &icon )
{
  QStyleOption option;
  option.initFrom( this );
  mUi.iconLabel->setPixmap(
    icon.pixmap( style()->pixelMetric( QStyle::PM_MessageBoxIconSize, &option, this ) ) );
}
コード例 #22
0
ファイル: TextPreview.cpp プロジェクト: JeMaCheHi/deling
void TextPreview::paintEvent(QPaintEvent */* event */)
{
	QPixmap pix(320, 224);
	QPainter painter(&pix);

	/* Screen background */

	painter.setBrush(Qt::black);
	painter.drawRect(0, 0, 320, 224);

	drawTextArea(&painter);

	painter.end();

	QPainter painter2(this);

	if(!isEnabled()) {
		QStyleOption opt;
		opt.initFrom(this);
		painter2.drawPixmap(0, 0, QWidget::style()->generatedIconPixmap(QIcon::Disabled, pix, &opt));
	}
	else {
		painter2.drawPixmap(0, 0, pix);
	}

	painter2.end();
}
コード例 #23
0
ファイル: LineCbBox.cpp プロジェクト: subprotocol/xflr5
void LineCbBox::paintEvent (QPaintEvent *event)
{
	QStyleOption opt;
	opt.initFrom(this);
	QPainter painter(this);
	style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);

	painter.save();

//	painter.setRenderHint(QPainter::Antialiasing);

	QColor ContourColor = Qt::gray;

	if(!isEnabled()) ContourColor = Qt::lightGray;

	QRect r = event->rect();
//	QRect g = rect();
	painter.setBrush(Qt::NoBrush);
	painter.setBackgroundMode(Qt::TransparentMode);

	QPen LinePen(m_Color);
	LinePen.setStyle(getStyle(m_Style));
	LinePen.setWidth(m_Width);
	painter.setPen(LinePen);
	painter.drawLine(r.left()+5, r.height()/2, r.width()-10, r.height()/2);

//	QPen ContourPen(ContourColor);
//	painter.setPen(ContourPen);
//	r.adjust(0,2,-1,-3);
//	painter.drawRoundRect(r,5,40);

	painter.restore();
}
コード例 #24
0
static inline void qwtDrawStyledBackground( 
    QWidget *w, QPainter *painter )
{
    QStyleOption opt;
    opt.initFrom(w);
    w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w);
}
コード例 #25
0
ファイル: contentpane.cpp プロジェクト: magland/mountainlab
void ContentPane::paintEvent(ATTR_UNUSED QPaintEvent* event)
{
    Q_UNUSED(event)
    QStyleOption o;
    o.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
コード例 #26
0
void SelectionPad::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QStyleOption myOption;
    myOption.initFrom(this);
    QPainter myPainter(this);
    style()->drawPrimitive( QStyle::PE_Widget, &myOption, &myPainter, this);
}
コード例 #27
0
ファイル: contactwidget.cpp プロジェクト: critter33/tessa
void ContactWidget::paintEvent(QPaintEvent *) {
    QStyleOption option;
    option.initFrom(this);
    option.state = QStyle::State_Open;

    QPainter painter(this);
    //style().drawControl(QStyle::CE_Widget, &option, &painter, this);
}
コード例 #28
0
/*!
    \reimp
*/
void QColumnViewGrip::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QStyleOption opt;
    opt.initFrom(this);
    style()->drawControl(QStyle::CE_ColumnViewGrip, &opt, &painter, this);
    event->accept();
}
コード例 #29
0
void ColorWheel::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QStyleOption opt;
    opt.initFrom(this);
    painter.drawPixmap(0,0,wheel);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
}
コード例 #30
0
ファイル: ui_qt.cpp プロジェクト: DoctorGoat/RetroArch_LibNX
void ThumbnailLabel::paintEvent(QPaintEvent *event)
{
   int w = width();
   int h = height();
   QStyleOption o;
   QPainter p;

   event->accept();

   o.initFrom(this);
   p.begin(this);
   style()->drawPrimitive(
     QStyle::PE_Widget, &o, &p, this);
   p.end();

   if (!m_pixmap || m_pixmap->isNull())
   {
      m_pixmap = new QPixmap(sizeHint());
      m_pixmap->fill(QColor(0, 0, 0, 0));
   }

   if (w > 0 && h > 0 && m_pixmap && !m_pixmap->isNull())
   {
      int newHeight = (m_pixmap->height() / static_cast<float>(m_pixmap->width())) * width();
      QPixmap pixmapScaled = *m_pixmap;
      QPixmap pixmap;
      QPainter pScale;
      int pw = 0;
      int ph = 0;
      unsigned *buf = new unsigned[w * h];

      if (newHeight > h)
         pixmapScaled = pixmapScaled.scaledToHeight(h, Qt::SmoothTransformation);
      else
         pixmapScaled = pixmapScaled.scaledToWidth(w, Qt::SmoothTransformation);

      pw = pixmapScaled.width();
      ph = pixmapScaled.height();

      pixmap = QPixmap(w, h);
      pixmap.fill(QColor(0, 0, 0, 0));

      pScale.begin(&pixmap);
      pScale.drawPixmap(QRect((w - pw) / 2, (h - ph) / 2, pw, ph), pixmapScaled, pixmapScaled.rect());
      pScale.end();

      if (!pixmap.isNull())
      {
         p.begin(this);
         p.drawPixmap(rect(), pixmap, pixmap.rect());
         p.end();
      }

      delete []buf;
   }
   else
      QWidget::paintEvent(event);
}