示例#1
0
void BoardView::setCellsSize()
{
	if (!model_)
		return;
	int row_cnt = model()->rowCount() - 2;
	int col_cnt = model()->columnCount() - 2;
	int board_width = width() - verticalHeader()->width() - (lineWidth() + midLineWidth()) * 2;
	int board_height = height() - horizontalHeader()->height() - (lineWidth() + midLineWidth()) * 2;
	board_width -= 4; board_height -= 4; // Запас для гарантии отсутствия прокрутки
	int cell_width = board_width / (row_cnt) - 1;
	int cell_heigt = board_height / (col_cnt) - 1;
	int cell_size = qMin(cell_width, cell_heigt);
	int h_margin = board_width - cell_size * col_cnt;
	if (h_margin < 0)
		h_margin = 0;
	h_margin /= 2;
	int v_margin = board_height - cell_size * row_cnt;
	if (v_margin < 0)
		v_margin = 0;
	v_margin /= 2;
	horizontalHeader()->setDefaultSectionSize(cell_size);
	verticalHeader()->setDefaultSectionSize(cell_size);
	horizontalHeader()->resizeSection(0, h_margin);
	horizontalHeader()->resizeSection(col_cnt + 1, h_margin);
	verticalHeader()->resizeSection(0, v_margin);
	verticalHeader()->resizeSection(row_cnt + 1, v_margin);
}
示例#2
0
/*!
  Virtual function that draws the mask of the frame's frame.

  If you reimplemented drawFrame(QPainter*) and your widget should
  support transparency you probably have to re-implement this function as well.

  \sa drawFrame(), updateMask(), QWidget::setAutoMask(), QPainter::setClipRect()
*/
void QFrame::drawFrameMask( QPainter* p )
{
    QPoint	p1, p2;
    QRect	r     = frameRect();
    int		type  = fstyle & MShape;
    int		style = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen( color1 );
    p->drawRect( r ); //### a bit too simple
#else
    QColorGroup g(color1, color1, color1, color1, color1, color1, color1, color1, color0);

    switch ( type ) {

    case Box:
	if ( style == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadeRect( p, r, g, style == Sunken, lwidth,
			    midLineWidth() );
	break;

    case Panel:
	if ( style == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadePanel( p, r, g, style == Sunken, lwidth );
	break;

    case WinPanel:
	if ( style == Plain )
	    qDrawPlainRect( p, r, g.foreground(), wpwidth );
	else
	    qDrawWinPanel( p, r, g, style == Sunken );
	break;

    case HLine:
    case VLine:
	if ( type == HLine ) {
	    p1 = QPoint( r.x(), r.height()/2 );
	    p2 = QPoint( r.x()+r.width(), p1.y() );
	}
	else {
	    p1 = QPoint( r.x()+r.width()/2, 0 );
	    p2 = QPoint( p1.x(), r.height() );
	}
	if ( style == Plain ) {
	    QPen oldPen = p->pen();
	    p->setPen( QPen(g.foreground(),lwidth) );
	    p->drawLine( p1, p2 );
	    p->setPen( oldPen );
	}
	else
	    qDrawShadeLine( p, p1, p2, g, style == Sunken,
			    lwidth, midLineWidth() );
	break;
    }
#endif // QT_NO_DRAWUTIL
}
示例#3
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() );
        }
    }
}
示例#5
0
void MultiLineEdit::updateSizeHint()
{
    QFontMetrics fm(font());
    int minPixelHeight = fm.lineSpacing() * _minHeight;
    int maxPixelHeight = fm.lineSpacing() * _maxHeight;
    int scrollBarHeight = horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0;

    // use the style to determine a decent size
    int h = qMin(qMax((int)document()->size().height() + scrollBarHeight, minPixelHeight), maxPixelHeight) + 2 * frameWidth();

    QStyleOptionFrame opt;
    opt.initFrom(this);
    opt.rect = QRect(0, 0, 100, h);
    opt.lineWidth = lineWidth();
    opt.midLineWidth = midLineWidth();
    opt.state |= QStyle::State_Sunken;
    QWidget* widget = this;
#ifdef Q_OS_MAC
    widget = 0;
#endif
    QSize s = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(100, h).expandedTo(QApplication::globalStrut()), widget);
    if (s != _sizeHint) {
        _sizeHint = s;
        updateGeometry();
    }
}
示例#6
0
/*!
  Draw the border of the plot canvas

  \param painter Painter
  \sa setBorderRadius()
*/
void QwtPlotCanvas::drawBorder( QPainter *painter )
{
    if ( d_data->borderRadius > 0 )
    {
        if ( frameWidth() > 0 )
        {
            QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), 
                d_data->borderRadius, d_data->borderRadius,
                palette(), frameWidth(), frameStyle() );
        }
    }
    else
    {
#if QT_VERSION >= 0x040500
#if QT_VERSION < 0x050000
        QStyleOptionFrameV3 opt;
#else
        QStyleOptionFrame opt;
#endif
        opt.init(this);

        int frameShape  = frameStyle() & QFrame::Shape_Mask;
        int frameShadow = frameStyle() & QFrame::Shadow_Mask;

        opt.frameShape = QFrame::Shape( int( opt.frameShape ) | frameShape );
#if 0
        opt.rect = frameRect();
#endif

        switch (frameShape) 
        {
            case QFrame::Box:
            case QFrame::HLine:
            case QFrame::VLine:
            case QFrame::StyledPanel:
            case QFrame::Panel:
            {
                opt.lineWidth = lineWidth();
                opt.midLineWidth = midLineWidth();
                break; 
            }
            default: 
            {
                opt.lineWidth = frameWidth();
                break;
            }
        }
    
        if ( frameShadow == Sunken )
            opt.state |= QStyle::State_Sunken;
        else if ( frameShadow == Raised )
            opt.state |= QStyle::State_Raised;

        style()->drawControl(QStyle::CE_ShapedFrame, &opt, painter, this);
#else
        drawFrame( painter );
#endif
    }
}
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;
}
示例#8
0
void NextWidget::paintEvent(QPaintEvent * e) {
    QFrame::paintEvent(e);
    const QColor orange(255, 127, 0);
    static const QColor colorTable[] = {Qt::black, Qt::magenta, Qt::green, Qt::cyan, orange, Qt::blue, Qt::red, Qt::yellow};
    int t = 2 * lineWidth() + midLineWidth(), *c, i, x, k;
    QPainter painter(this);

    int __action__ = 4;

    while(true) {
        switch(__action__) {
            case 0:
            if(nextBlock == 0) {
                __action__ = 7;
            }
            else {
                __action__ = 5;
            }
            break;

            case 1:
            if(i < 8) {
                __action__ = 3;
            }
            else {
                __action__ = 6;
            }
            break;

            case 3:
            painter.fillRect((c[i] - 3 + x) * 20 + t + 1, c[i + 1] * 20 + t + 1, 18, 18, colorTable[k]);
            i += 2;
            __action__ = 1;
            break;

            case 4:
            painter.fillRect(t, t, 120, 80, colorTable[0]);
            __action__ = 0;
            break;

            case 5:
            c = nextBlock->getCoordinates();
            k = nextBlock->getKind();
            x = k == Block::I || k == Block::O;
            i = 0;
            __action__ = 1;
            break;

            case 6:
            return;
            case 7:
            return;
        }
    }
}
示例#9
0
NextWidget::NextWidget() {
    int border;

    nextBlock = 0;

    setFrameStyle(QFrame::Box | QFrame::Raised);
    setLineWidth(4);
    setMidLineWidth(3);

    border = 4 * lineWidth() + 2 * midLineWidth();
    setFixedSize(120 + border, 80 + border);
}
示例#10
0
void QGroupBox::paintEvent( QPaintEvent *event )
{
    QPainter paint( this );

    if ( lenvisible && !isCheckable() ) {	// draw title
        QFontMetrics fm = paint.fontMetrics();
        int h = fm.height();
        int tw = fm.width( str, lenvisible ) + fm.width(QChar(' '));
        int x;
        int marg = bFlat ? 0 : 8;
        if ( align & AlignHCenter )		// center alignment
            x = frameRect().width()/2 - tw/2;
        else if ( align & AlignRight )	// right alignment
            x = frameRect().width() - tw - marg;
        else if ( align & AlignLeft )		 // left alignment
            x = marg;
        else { // auto align
            if( QApplication::reverseLayout() )
                x = frameRect().width() - tw - marg;
            else
                x = marg;
        }
        QRect r( x, 0, tw, h );
        int va = style().styleHint(QStyle::SH_GroupBox_TextLabelVerticalAlignment, this);
        if(va & AlignTop)
            r.moveBy(0, fm.descent());
        QColor pen( (QRgb) style().styleHint(QStyle::SH_GroupBox_TextLabelColor, this )  );
        if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this))
            va |= NoAccel;
        style().drawItem( &paint, r, ShowPrefix | AlignHCenter | va, colorGroup(),
                          isEnabled(), 0, str, -1, ownPalette() ? 0 : &pen );
        paint.setClipRegion( event->region().subtract( r ) ); // clip everything but title
#ifndef QT_NO_CHECKBOX
    } else if ( d->checkbox ) {
        QRect cbClip = d->checkbox->geometry();
        QFontMetrics fm = paint.fontMetrics();
        cbClip.setX( cbClip.x() - fm.width(QChar(' ')) );
        cbClip.setWidth( cbClip.width() + fm.width(QChar(' ')) );
        paint.setClipRegion( event->region().subtract( cbClip ) );
#endif
    }
    if ( bFlat ) {
        QRect fr = frameRect();
        QPoint p1( fr.x(), fr.y() + 1 );
        QPoint p2( fr.x() + fr.width(), p1.y() );
        // ### This should probably be a style primitive.
        qDrawShadeLine( &paint, p1, p2, colorGroup(), TRUE,
                        lineWidth(), midLineWidth() );
    } else {
        drawFrame(&paint);
    }
    drawContents( &paint );			// draw the contents
}
//! @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);
    }
}
示例#12
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;
}
示例#13
0
void KSeparator::drawFrame( QPainter *p )
{
    QPoint p1, p2;
    QRect r = frameRect();
    const QColorGroup & g = colorGroup();

    if ( frameStyle() & HLine )
    {
        p1 = QPoint( r.x(), r.height() / 2 );
        p2 = QPoint( r.x() + r.width(), p1.y() );
    }
    else
    {
        p1 = QPoint( r.x() + r.width() / 2, 0 );
        p2 = QPoint( p1.x(), r.height() );
    }

    QStyleOption opt( lineWidth(), midLineWidth() );
    style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g,
                           QStyle::Style_Sunken, opt );
}
示例#14
0
void TreeIndicator::paintEvent(QPaintEvent*)
{
    QStyleOptionFrame frame;
    frame.init(this);
    int frameShape  = frameStyle() & QFrame::Shape_Mask;
    int frameShadow = frameStyle() & QFrame::Shadow_Mask;
    frame.frameShape = Shape(int(frame.frameShape) | frameShape);
    frame.rect = frameRect();
    switch (frameShape) {
        case QFrame::Box:
        case QFrame::HLine:
        case QFrame::VLine:
        case QFrame::StyledPanel:
        case QFrame::Panel:
            frame.lineWidth = lineWidth();
            frame.midLineWidth = midLineWidth();
            break;
        default:
            frame.lineWidth = frameWidth();
            break;
    }
    if (frameShadow == Sunken)
        frame.state |= QStyle::State_Sunken;
    else if (frameShadow == Raised)
        frame.state |= QStyle::State_Raised;
    frame.state |= d.state;

    if (d.lag > 0 && d.state == QStyle::State_None) {
        qreal f = qMin(100.0, qSqrt(d.lag)) / 100;
        QColor color = QColor::fromHsl(120 - f * 120, 96, 152); // TODO
        setStyleSheet(QString("background-color:%1").arg(color.name()));
    } else {
        setStyleSheet(QString());
    }

    QStylePainter painter(this);
    painter.drawPrimitive(QStyle::PE_Widget, frame);
    painter.drawControl(QStyle::CE_ShapedFrame, frame);
}
示例#15
0
void QFrame::updateFrameWidth( bool resetLineMetrics )
{
    int frameType  = fstyle & MShape;
    int frameStyle = fstyle & MShadow;

    if ( resetLineMetrics ) {
	switch ( frameType ) {
	case MenuBarPanel:
	    mwidth = 0;
	    lwidth = style().pixelMetric( QStyle::PM_MenuBarFrameWidth, this );
	    break;
	case ToolBarPanel:
	    mwidth = 0;
	    lwidth = style().pixelMetric( QStyle::PM_DockWindowFrameWidth, this );
	    break;
	case LineEditPanel:
	case TabWidgetPanel:
	case PopupPanel:
	    mwidth = 0;
	    lwidth = style().pixelMetric( QStyle::PM_DefaultFrameWidth, this );
	    break;
	}
    }

    fwidth = -1;

    switch ( frameType ) {

    case NoFrame:
	fwidth = 0;
	break;

    case Box:
	switch ( frameStyle ) {
	case Plain:
	    fwidth = lwidth;
	    break;
	case Raised:
	case Sunken:
	    fwidth = (short)(lwidth*2 + midLineWidth() );
	    break;
	}
	break;


    case LineEditPanel:
    case TabWidgetPanel:
    case PopupPanel:
    case GroupBoxPanel:
    case Panel:
    case StyledPanel:
	switch ( frameStyle ) {
	case Plain:
	case Raised:
	case Sunken:
	    fwidth = lwidth;
	    break;
	}
	break;

    case WinPanel:
	switch ( frameStyle ) {
	case Plain:
	case Raised:
	case Sunken:
	    fwidth =  wpwidth; //WinPanel does not use lwidth!
	    break;
	}
	break;
    case MenuBarPanel:
	fwidth = lwidth;
	break;
    case ToolBarPanel:
	fwidth = lwidth;
	break;
    case HLine:
    case VLine:
	switch ( frameStyle ) {
	case Plain:
	    fwidth = lwidth;
	    break;
	case Raised:
	case Sunken:
	    fwidth = (short)(lwidth*2 + midLineWidth());
	    break;
	}
	break;
    }

    if ( fwidth == -1 )				// invalid style
	fwidth = 0;

    fwidth += margin();

    frameChanged();
}
示例#16
0
void Frame::drawFrame(QPainter *p)
{
    QPoint p1, p2;
    QStyleOptionFrame opt;
    opt.init(this);
    if ( hasFocus() ) {
        opt.state |= QStyle::State_HasFocus;
    }
    int frameShape  = frameStyle() & QFrame::Shape_Mask;
    int frameShadow = frameStyle() & QFrame::Shadow_Mask;

    int lw = 0;
    int mlw = 0;
    opt.rect = frameRect();
    switch (frameShape) {
        case QFrame::Box:
        case QFrame::HLine:
        case QFrame::VLine:
        case QFrame::StyledPanel:
            lw = lineWidth();
            mlw = midLineWidth();
            break;
        default:
            // most frame styles do not handle customized line and midline widths
            // (see updateFrameWidth()).
            lw = frameWidth();
            break;
    }
    opt.lineWidth = lw;
    opt.midLineWidth = mlw;
    if (frameShadow == Sunken)
        opt.state |= QStyle::State_Sunken;
    else if (frameShadow == Raised)
        opt.state |= QStyle::State_Raised;

    switch (frameShape) {
        case Box:
            if (frameShadow == Plain)
                qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
            else
                qDrawShadeRect(p, opt.rect, opt.palette, frameShadow == Sunken, lw, mlw);
            break;


        case StyledPanel:
            style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this);
            break;

        case Panel:
            if (frameShadow == Plain)
                qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
            else
                qDrawShadePanel(p, opt.rect, opt.palette, frameShadow == Sunken, lw);
            break;

        case WinPanel:
            if (frameShadow == Plain)
                qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw);
            else
                qDrawWinPanel(p, opt.rect, opt.palette, frameShadow == Sunken);
            break;
        case HLine:
        case VLine:
            if (frameShape == HLine) {
                p1 = QPoint(opt.rect.x(), opt.rect.height() / 2);
                p2 = QPoint(opt.rect.x() + opt.rect.width(), p1.y());
            } else {
                p1 = QPoint(opt.rect.x()+opt.rect.width() / 2, 0);
                p2 = QPoint(p1.x(), opt.rect.height());
            }
            if (frameShadow == Plain) {
                QPen oldPen = p->pen();
                p->setPen(QPen(opt.palette.foreground().color(), lw));
                p->drawLine(p1, p2);
                p->setPen(oldPen);
            } else {
                qDrawShadeLine(p, p1, p2, opt.palette, frameShadow == Sunken, lw, mlw);
            }
            break;
    }
}
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;
}
void QFrame::drawFrame(QPainter *p)
{
    QPoint      p1, p2;
    QRect       r     = frameRect();
    int         type  = fstyle & MShape;
    int         cstyle = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen(black);   // ####
    p->drawRect(r);   //### a bit too simple
#else
    const QColorGroup & g = colorGroup();

#ifndef QT_NO_STYLE
    QStyleOption opt(lineWidth(), midLineWidth());

    QStyle::SFlags flags = QStyle::Style_Default;
    if (isEnabled())
        flags |= QStyle::Style_Enabled;
    if (cstyle == Sunken)
        flags |= QStyle::Style_Sunken;
    else if (cstyle == Raised)
        flags |= QStyle::Style_Raised;
    if (hasFocus())
        flags |= QStyle::Style_HasFocus;
    if (hasMouse())
        flags |= QStyle::Style_MouseOver;
#endif // QT_NO_STYLE

    switch (type) {

    case Box:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadeRect(p, r, g, cstyle == Sunken, lwidth,
                           midLineWidth());
        break;

    case LineEditPanel:
        style().drawPrimitive(QStyle::PE_PanelLineEdit, p, r, g, flags, opt);
        break;

    case GroupBoxPanel:
        style().drawPrimitive(QStyle::PE_PanelGroupBox, p, r, g, flags, opt);
        break;

    case TabWidgetPanel:
        style().drawPrimitive(QStyle::PE_PanelTabWidget, p, r, g, flags, opt);
        break;

    case MenuBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelMenuBar, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case ToolBarPanel:
#ifndef QT_NO_STYLE
        style().drawPrimitive(QStyle::PE_PanelDockWindow, p, rect(), g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case StyledPanel:
#ifndef QT_NO_STYLE
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            style().drawPrimitive(QStyle::PE_Panel, p, r, g, flags, opt);
        break;
#endif // fall through to Panel if QT_NO_STYLE

    case PopupPanel:
#ifndef QT_NO_STYLE
        {
            int vextra = style().pixelMetric(QStyle::PM_PopupMenuFrameVerticalExtra, this),
                         hextra = style().pixelMetric(QStyle::PM_PopupMenuFrameHorizontalExtra, this);
            if (vextra > 0 || hextra > 0) {
                QRect fr = frameRect();
                int   fw = frameWidth();
                if (vextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuVerticalExtra, p, this,
                                        QRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra),
                                        g, flags, opt);
                }
                if (hextra > 0) {
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                    style().drawControl(QStyle::CE_PopupMenuHorizontalExtra, p, this,
                                        QRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
                                        g, flags, opt);
                }
            }

            if (cstyle == Plain)
                qDrawPlainRect(p, r, g.foreground(), lwidth);
            else
                style().drawPrimitive(QStyle::PE_PanelPopup, p, r, g, flags, opt);
            break;
        }
#endif // fall through to Panel if QT_NO_STYLE

    case Panel:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), lwidth);
        else
            qDrawShadePanel(p, r, g, cstyle == Sunken, lwidth);
        break;

    case WinPanel:
        if (cstyle == Plain)
            qDrawPlainRect(p, r, g.foreground(), wpwidth);
        else
            qDrawWinPanel(p, r, g, cstyle == Sunken);
        break;
    case HLine:
    case VLine:
        if (type == HLine) {
            p1 = QPoint(r.x(), r.height() / 2);
            p2 = QPoint(r.x() + r.width(), p1.y());
        } else {
            p1 = QPoint(r.x() + r.width() / 2, 0);
            p2 = QPoint(p1.x(), r.height());
        }
        if (cstyle == Plain) {
            QPen oldPen = p->pen();
            p->setPen(QPen(g.foreground(), lwidth));
            p->drawLine(p1, p2);
            p->setPen(oldPen);
        } else
            qDrawShadeLine(p, p1, p2, g, cstyle == Sunken,
                           lwidth, midLineWidth());
        break;
    }
示例#19
0
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;
}
示例#20
0
void QFrame::drawFrame( QPainter *p )
{
    QPoint	p1, p2;
    QRect	r     = frameRect();
    int		type  = fstyle & MShape;
    int		cstyle = fstyle & MShadow;
#ifdef QT_NO_DRAWUTIL
    p->setPen( black ); // ####
    p->drawRect( r ); //### a bit too simple
#else

    const QColorGroup & g = colorGroup();

    switch ( type ) {

    case Box:
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadeRect( p, r, g, cstyle == Sunken, lwidth,
			    midLineWidth() );
	break;

    case StyledPanel:
#ifndef QT_NO_STYLE
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    style().drawPanel( p, r.x(), r.y(), r.width(), r.height(), g, cstyle == Sunken, lwidth );
	break;
#endif // fall through to Panel if QT_NO_STYLE

    case PopupPanel:
#ifndef QT_NO_STYLE
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    style().drawPopupPanel( p, r.x(), r.y(), r.width(), r.height(), g, lwidth );
	break;
#endif // fall through to Panel if QT_NO_STYLE

    case Panel:
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), lwidth );
	else
	    qDrawShadePanel( p, r, g, cstyle == Sunken, lwidth );
	break;

    case WinPanel:
	if ( cstyle == Plain )
	    qDrawPlainRect( p, r, g.foreground(), wpwidth );
	else
	    qDrawWinPanel( p, r, g, cstyle == Sunken );
	break;

    case HLine:
    case VLine:
	if ( type == HLine ) {
	    p1 = QPoint( r.x(), r.height()/2 );
	    p2 = QPoint( r.x()+r.width(), p1.y() );
	}
	else {
	    p1 = QPoint( r.x()+r.width()/2, 0 );
	    p2 = QPoint( p1.x(), r.height() );
	}
	if ( cstyle == Plain ) {
	    QPen oldPen = p->pen();
	    p->setPen( QPen(g.foreground(),lwidth) );
	    p->drawLine( p1, p2 );
	    p->setPen( oldPen );
	}
	else
	    qDrawShadeLine( p, p1, p2, g, cstyle == Sunken,
			    lwidth, midLineWidth() );
	break;
    }
#endif // QT_NO_DRAWUTIL
}
示例#21
0
void QFrame::updateFrameWidth()
{
    int type  = fstyle & MShape;
    int style = fstyle & MShadow;

    fwidth = -1;

    switch ( type ) {

    case NoFrame:
	fwidth = 0;
	break;

    case Box:
	switch ( style ) {
	case Plain:
	    fwidth = lwidth;
	    break;
	case Raised:
	case Sunken:
	    fwidth = (short)(lwidth*2 + midLineWidth() );
	    break;
	}
	break;

    case Panel:
    case StyledPanel:
    case PopupPanel:
	switch ( style ) {
	case Plain:
	case Raised:
	case Sunken:
	    fwidth = lwidth;
	    break;
	}
	break;

    case WinPanel:
	switch ( style ) {
	case Plain:
	case Raised:
	case Sunken:
	    fwidth =  wpwidth; //WinPanel does not use lwidth!
	    break;
	}
	break;

    case HLine:
    case VLine:
	switch ( style ) {
	case Plain:
	    fwidth = lwidth;
	    break;
	case Raised:
	case Sunken:
	    fwidth = (short)(lwidth*2 + midLineWidth());
	    break;
	}
	break;
    }

    if ( fwidth == -1 )				// invalid style
	fwidth = 0;

    fwidth += margin();

    frameChanged();
}