Example #1
0
int KexiDBImageBox::realLineWidth() const
{
    switch (frameShape()) {
    case QFrame::NoFrame:
        // shadow, line, midline unused
        return 0;
    case QFrame::Box:
        switch (frameShadow()) {
        case QFrame::Plain:
            // midline unused
            return lineWidth();
        default: // sunken, raised:
            return 2 * lineWidth() + midLineWidth();
        }
        break;
    case QFrame::Panel:
        // shadow, midline unused
        return lineWidth();
    case QFrame::WinPanel:
        // shadow, line, midline unused
        return 2;
    case QFrame::StyledPanel: {
        // shadow, line, midline unused
        QStyleOptionFrameV3 option;
        option.initFrom(this);
        return style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, this);
    }
    default:
        return lineWidth();
    }
}
/*!
  Draw the border of the canvas
  \param painter Painter
*/
void QwtPlotGLCanvas::drawBorder( QPainter *painter )
{
    const int fw = frameWidth();
    if ( fw <= 0 )
        return;

    if ( frameShadow() == QwtPlotGLCanvas::Plain )
    {
        qDrawPlainRect( painter, frameRect(), 
            palette().shadow().color(), lineWidth() );
    }
    else
    {
        if ( frameShape() == QwtPlotGLCanvas::Box )
        {
            qDrawShadeRect( painter, frameRect(), palette(),
                frameShadow() == Sunken, lineWidth(), midLineWidth() );
        }
        else
        {
            qDrawShadePanel( painter, frameRect(), palette(), 
                frameShadow() == Sunken, lineWidth() );
        }
    }
}
Example #3
0
void KexiDBLabel::paintEvent(QPaintEvent* e)
{
    QPainter p(this);
    KexiDBTextWidgetInterface::paint(this, &p, text().isEmpty(), alignment(), false);
    p.end();

    QPalette origPal;
    if (editingMode()) {
        origPal = palette();
        QPalette pal(palette());
        pal.setBrush(QPalette::WindowText, Qt::transparent);
        setPalette(pal);
    }
    QLabel::paintEvent(e);
    if (editingMode()) {
        setPalette(origPal);
    }

    const bool hasFrame = frameWidth() >= 1 && frameShape() != QFrame::NoFrame;
    if (designMode() && !hasFrame) {
        p.begin(this);
        KFormDesigner::paintWidgetFrame(p, rect());
        p.end();
    }
}
Qt::Orientation
Line::orientation() const
{
    if (frameShape() == HLine)
        return Qt::Horizontal;
    else
        return Qt::Vertical;
}
int QwtPlotGLCanvas::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::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;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 2)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break;
        case 1: *reinterpret_cast< Shape*>(_v) = frameShape(); break;
        case 2: *reinterpret_cast< int*>(_v) = lineWidth(); break;
        case 3: *reinterpret_cast< int*>(_v) = midLineWidth(); break;
        case 4: *reinterpret_cast< int*>(_v) = frameWidth(); break;
        case 5: *reinterpret_cast< QRect*>(_v) = frameRect(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break;
        case 1: setFrameShape(*reinterpret_cast< Shape*>(_v)); break;
        case 2: setLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 3: setMidLineWidth(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 6;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 6)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 6;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #6
0
void KexiFrame::paintEvent(QPaintEvent *pe)
{
    QFrame::paintEvent(pe);
    if (designMode()) {
        const bool hasFrame = frameWidth() >= 1 && frameShape() != QFrame::NoFrame;
        if (!hasFrame) {
            QPainter p(this);
            KFormDesigner::paintWidgetFrame(p, rect());
        }
    }
}
//! @todo add more frame types
void ClassName::drawFrame(QPainter *p)
{
    if (frameShape() == QFrame::Box) {
        if (frameShadow() == Plain)
            qDrawPlainRect(p, frameRect(), d->frameColor, lineWidth());
        else
            qDrawShadeRect(p, frameRect(), palette(), frameShadow() == QFrame::Sunken,
                           lineWidth(), midLineWidth());
    } else {
        SuperClassName::drawFrame(p);
    }
}
Example #8
0
int QFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Shape*>(_v) = frameShape(); break;
        case 1: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break;
        case 2: *reinterpret_cast< int*>(_v) = lineWidth(); break;
        case 3: *reinterpret_cast< int*>(_v) = midLineWidth(); break;
        case 4: *reinterpret_cast< int*>(_v) = frameWidth(); break;
        case 5: *reinterpret_cast< QRect*>(_v) = frameRect(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFrameShape(*reinterpret_cast< Shape*>(_v)); break;
        case 1: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break;
        case 2: setLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 3: setMidLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 5: setFrameRect(*reinterpret_cast< QRect*>(_v)); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 6;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
int MessageListScript::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = MessageList::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = criColor(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = attColor(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = normColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = backColor(); break;
        case 4: *reinterpret_cast< vtlmeta::types::NamedList*>(_v) = getList(); break;
        case 5: *reinterpret_cast< QString*>(_v) = sourcerName(); break;
        case 6: *reinterpret_cast< QString*>(_v) = toolTip(); break;
        case 7: *reinterpret_cast< VISIBLE*>(_v) = getVisible(); break;
        case 8: *reinterpret_cast< bool*>(_v) = useMask(); break;
        case 9: *reinterpret_cast< QString*>(_v) = globalListName(); break;
        case 10: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 11: *reinterpret_cast< QRect*>(_v) = geometry(); break;
        case 12: *reinterpret_cast< Shape*>(_v) = frameShape(); break;
        case 13: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break;
        case 14: *reinterpret_cast< int*>(_v) = lineWidth(); break;
        case 15: *reinterpret_cast< int*>(_v) = midLineWidth(); break;
        case 16: *reinterpret_cast< int*>(_v) = margin(); break;
        case 17: *reinterpret_cast< vtlmeta::types::NamedList*>(_v) = getFuncList(); break;
        }
        _id -= 18;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setCriColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setAttColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setNormColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setBackColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setList(*reinterpret_cast< vtlmeta::types::NamedList*>(_v)); break;
        case 5: setSourcerName(*reinterpret_cast< QString*>(_v)); break;
        case 6: setToolTip(*reinterpret_cast< QString*>(_v)); break;
        case 7: setVisible(*reinterpret_cast< VISIBLE*>(_v)); break;
        case 8: setUseMask(*reinterpret_cast< bool*>(_v)); break;
        case 9: setGlobalListName(*reinterpret_cast< QString*>(_v)); break;
        case 10: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 11: setGeometry(*reinterpret_cast< QRect*>(_v)); break;
        case 12: setFrameShape(*reinterpret_cast< Shape*>(_v)); break;
        case 13: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break;
        case 14: setLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 15: setMidLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 16: setMargin(*reinterpret_cast< int*>(_v)); break;
        case 17: setFuncList(*reinterpret_cast< vtlmeta::types::NamedList*>(_v)); break;
        }
        _id -= 18;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 18;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 18;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #10
0
void KexiDBImageBox::paintEvent(QPaintEvent *pe)
{
    if (!m_paintEventEnabled)
        return;
    QPainter p(this);
    p.setClipRect(pe->rect());
    const int _realLineWidth = realLineWidth();
    KexiUtils::WidgetMargins margins(this);
    margins += KexiUtils::WidgetMargins(_realLineWidth);
//Qt3 replaced with 'margins': const int m = realLineWidth() + margin();
    const QBrush bgBrush(palette().brush(backgroundRole()));
    if (designMode() && pixmap().isNull()) {
        QRect r(
            QPoint(margins.left, margins.top),
            size() - QSize(margins.left + margins.right, margins.top + margins.bottom));
//        p.fillRect(0, 0, width(), height(), bgBrush);

        updatePixmap();
        QPixmap *imagBoxPm = scaledImageBoxIcon(margins, size());
        if (imagBoxPm) {
//        QImage img(imagBoxPm->toImage());
//          QPixmap converted(QPixmap::fromImage(img));
            p.drawPixmap(2, height() - margins.top - margins.bottom - imagBoxPm->height() - 2, *imagBoxPm);
        }
        QFont f(qApp->font());
        p.setFont(f);
//        p.setPen(KexiUtils::contrastColor(bg));
        QString text;
        if (dataSource().isEmpty()) {
            text = objectName() + "\n" + i18nc("Unbound Image Box", "(unbound)");
        }
        else {
            text = dataSource();
            const QFontMetrics fm(fontMetrics());
            const QPixmap dataSourceTagIcon(KexiFormUtils::dataSourceTagIcon());
            if (width() >= (dataSourceTagIcon.width() + 2 + fm.boundingRect(r, Qt::AlignCenter, text).width())) {
                r.setLeft( r.left() + dataSourceTagIcon.width() + 2 ); // make some room for the [>] icon
                QRect bounding = fm.boundingRect(r, Qt::AlignCenter, text);
                p.drawPixmap(
                    bounding.left() - dataSourceTagIcon.width() - 2,
                    bounding.top() + bounding.height() / 2 - dataSourceTagIcon.height() / 2,
                    dataSourceTagIcon);
            }
        }
        p.drawText(r, Qt::AlignCenter, text);
    }
    else {
        QSize internalSize(size());
        if (m_chooser && m_dropDownButtonVisible && !dataSource().isEmpty())
            internalSize.setWidth(internalSize.width() - m_chooser->width());

        //clearing needed here because we may need to draw a pixmap with transparency
 //       p.fillRect(0, 0, width(), height(), bgBrush);

        const QRect internalRect(QPoint(0, 0), internalSize);
        if (m_currentScaledPixmap.isNull() || internalRect != m_currentRect) {
            m_currentRect = internalRect;
            m_currentPixmapPos = QPoint(0, 0);
            m_currentScaledPixmap = KexiUtils::scaledPixmap(
                margins, m_currentRect, pixmap(), m_currentPixmapPos, m_alignment,
                m_scaledContents, m_keepAspectRatio,
                m_smoothTransformation ? Qt::SmoothTransformation : Qt::FastTransformation);
        }
        p.drawPixmap(m_currentPixmapPos, m_currentScaledPixmap);
//        KexiUtils::drawPixmap(p, margins, QRect(QPoint(0, 0), internalSize), pixmap(), m_alignment,
//                              m_scaledContents, m_keepAspectRatio);
    }
    KexiFrame::drawFrame(&p);

    if (designMode()) {
        const bool hasFrame = frameWidth() >= 1 && frameShape() != QFrame::NoFrame;
        if (!hasFrame) {
            KFormDesigner::paintWidgetFrame(p, rect());
        }
    }
    else { // data mode
        // if the widget is focused, draw focus indicator rect _if_ there is no chooser button
        if (   !dataSource().isEmpty()
            && hasFocus()
            && (!m_chooser || !m_chooser->isVisible()))
        {
            QStyleOptionFocusRect option;
            option.initFrom(this);
            //option.rect = style().subRect(QStyle::SR_PushButtonContents);
            style()->drawPrimitive(
                QStyle::PE_FrameFocusRect, &option, &p, this
                /*Qt4 , palette().active()*/);
        }
    }
}
int Text::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = VtlWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: { QString _r = getText();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 1: setText((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = backColor(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = normColor(); break;
        case 2: *reinterpret_cast< QString*>(_v) = getText(); break;
        case 3: *reinterpret_cast< bool*>(_v) = useMask(); break;
        case 4: *reinterpret_cast< QString*>(_v) = sourcerName(); break;
        case 5: *reinterpret_cast< QString*>(_v) = toolTip(); break;
        case 6: *reinterpret_cast< VISIBLE*>(_v) = getVisible(); break;
        case 7: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 8: *reinterpret_cast< QRect*>(_v) = geometry(); break;
        case 9: *reinterpret_cast< Shape*>(_v) = frameShape(); break;
        case 10: *reinterpret_cast< Shadow*>(_v) = frameShadow(); break;
        case 11: *reinterpret_cast< int*>(_v) = lineWidth(); break;
        case 12: *reinterpret_cast< int*>(_v) = midLineWidth(); break;
        case 13: *reinterpret_cast< int*>(_v) = margin(); break;
        }
        _id -= 14;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setBackColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setNormColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setText(*reinterpret_cast< QString*>(_v)); break;
        case 3: setUseMask(*reinterpret_cast< bool*>(_v)); break;
        case 4: setSourcerName(*reinterpret_cast< QString*>(_v)); break;
        case 5: setToolTip(*reinterpret_cast< QString*>(_v)); break;
        case 6: setVisible(*reinterpret_cast< VISIBLE*>(_v)); break;
        case 7: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 8: setGeometry(*reinterpret_cast< QRect*>(_v)); break;
        case 9: setFrameShape(*reinterpret_cast< Shape*>(_v)); break;
        case 10: setFrameShadow(*reinterpret_cast< Shadow*>(_v)); break;
        case 11: setLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 12: setMidLineWidth(*reinterpret_cast< int*>(_v)); break;
        case 13: setMargin(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 14;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 14;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 14;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #12
0
void VideoFrame::paintEvent(QPaintEvent *AEvent)
{
	QFrame::paintEvent(AEvent);

	QPainter p(this);
	QRect clipRect = rect().adjusted(lineWidth(),lineWidth(),-lineWidth(),-lineWidth());
	if (frameShape() != QFrame::NoFrame)
		p.setClipRect(clipRect,Qt::IntersectClip);
	p.fillRect(rect(), Qt::black);
	
	if (FCollapsed)
	{
		QRect iconRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,sizeHint(),rect());
		p.drawPixmap(iconRect, FCollapsedIcon);
	}
	else if (isNull())
	{
		if (!FNullVideoImage.isNull())
		{
			QSize availSize = rect().size();
			QSize iconSize = FNullVideoImage.size();
			if (iconSize.height()>availSize.height() || iconSize.width()>availSize.width())
				iconSize.scale(availSize,Qt::KeepAspectRatio);
			QRect iconRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,iconSize,rect());
			p.drawImage(iconRect, FNullVideoImage);
		}
		else
		{
			QString text = FDeviceState==ISipDevice::DS_DISABLED ? tr("Camera disabled") : tr("Camera unavailable");

			QSize textSize = fontMetrics().size(Qt::AlignHCenter|Qt::AlignTop|Qt::TextSingleLine,text);
			QSize iconSize = FCameraDisabledIcon.size();

			QSize iconTextSize(qMax(textSize.width(),iconSize.width()),iconSize.height()+textSize.height()+5);
			QRect iconTextRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,iconTextSize,rect());

			QRect iconRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignHCenter|Qt::AlignTop,iconSize,iconTextRect);
			QRect textRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignHCenter|Qt::AlignBottom,textSize,iconTextRect);

			p.drawPixmap(iconRect, FCameraDisabledIcon);
			p.drawText(textRect,Qt::AlignCenter,text);
		}
	}
	else if (!isEmpty())
	{
		const QPixmap *frame = pixmap();
		QSize frameSize = frame->size();
		frameSize.scale(size(),Qt::KeepAspectRatio);
		QRect frameRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,frameSize,rect());
		p.drawPixmap(frameRect, *frame);
	}
	else
	{
		QRect waitRect = QStyle::alignedRect(Qt::LeftToRight,Qt::AlignCenter,FWaitMovie->currentPixmap().size(),rect());
		p.drawPixmap(waitRect, FWaitMovie->currentPixmap());
	}

	if (!FCollapsed && FResizeEnabled && underMouse())
	{
		QRect iconRect = QRect(rect().topLeft(),FResizeIcon.size());
		iconRect.moveCenter(QPoint(0,0));
		for (int i=0; i<4; i++)
		{
			if ((FAlignment & Corners[i].align) == 0)
			{
				p.save();
				p.translate(QStyle::alignedRect(Qt::LeftToRight,Corners[i].align,FResizeIcon.size(),clipRect).center());
				p.rotate(Corners[i].rotateAngel);
				p.drawPixmap(iconRect,FResizeIcon);
				p.restore();
			}
		}
	}
}