/*! Find the bounding rect for the label. The coordinates of the rect are absolute coordinates ( calculated from pos() ). in direction of the tick. \param font Font used for painting \param value Value \sa labelRect() */ QRect QwtScaleDraw::boundingLabelRect( const QFont &font, double value ) const { QwtText lbl = tickLabel( font, value ); if ( lbl.isEmpty() ) return QRect(); const QPointF pos = labelPosition( value ); QSizeF labelSize = lbl.textSize( font ); const QTransform transform = labelTransformation( pos, labelSize ); return transform.mapRect( QRect( QPoint( 0, 0 ), labelSize.toSize() ) ); }
/*! Find the bounding rect for the label. The coordinates of the rect are absolute coordinates ( calculated from pos() ). in direction of the tick. \param font Font used for painting \param value Value \sa labelRect() */ QRect QwtScaleDraw::boundingLabelRect(const QFont &font, double value) const { QwtText lbl = tickLabel(font, value); if ( lbl.isEmpty() ) return QRect(); const QPoint pos = labelPosition(value); QSize labelSize = lbl.textSize(font); if ( labelSize.height() % 2 ) labelSize.setHeight(labelSize.height() + 1); const QwtMatrix m = labelMatrix( pos, labelSize); return m.mapRect(QRect(QPoint(0, 0), labelSize)); }
/*! Find the bounding rect for the label. The coordinates of the rect are relative to spacing + ticklength from the backbone in direction of the tick. \param font Font used for painting \param value Value */ QRectF QwtScaleDraw::labelRect( const QFont &font, double value ) const { QwtText lbl = tickLabel( font, value ); if ( lbl.isEmpty() ) return QRectF( 0.0, 0.0, 0.0, 0.0 ); const QPointF pos = labelPosition( value ); const QSizeF labelSize = lbl.textSize( font ); const QTransform transform = labelTransformation( pos, labelSize ); QRectF br = transform.mapRect( QRectF( QPointF( 0, 0 ), labelSize ) ); br.translate( -pos.x(), -pos.y() ); return br; }
/*! Draws the label for a major scale tick \param painter Painter \param value Value \sa drawTick(), drawBackbone(), boundingLabelRect() */ void QwtScaleDraw::drawLabel( QPainter *painter, double value ) const { QwtText lbl = tickLabel( painter->font(), value ); if ( lbl.isEmpty() ) return; QPointF pos = labelPosition( value ); QSizeF labelSize = lbl.textSize( painter->font() ); const QTransform transform = labelTransformation( pos, labelSize ); painter->save(); painter->setWorldTransform( transform, true ); lbl.draw ( painter, QRect( QPoint( 0, 0 ), labelSize.toSize() ) ); painter->restore(); }
void ScaleDraw::drawLabel(QPainter *painter, double value) const { if (!d_plot) return; ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis()); /*QwtScaleEngine *qwtsc_engine=d_plot->axisScaleEngine(axis()); ScaleEngine *sc_engine =dynamic_cast< ScaleEngine*>(qwtsc_engine); if(sc_engine!=NULL) {*/ if (sc_engine->hasBreak()){ bool invertedScale = sc_engine->testAttribute(QwtScaleEngine::Inverted); if (invertedScale && sc_engine->axisBreakRight() == value) return; if (!invertedScale && sc_engine->axisBreakLeft() == value) return; } //} QwtText lbl = tickLabel(painter->font(), value); if (lbl.isEmpty()) return; const QPoint pos = labelPosition(value); QSize labelSize = lbl.textSize(painter->font()); if ( labelSize.height() % 2 ) labelSize.setHeight(labelSize.height() + 1); const QMatrix m = labelMatrix(pos, labelSize); painter->save(); painter->setMatrix(m, true); if (d_selected) lbl.setBackgroundPen(QPen(Qt::blue)); else lbl.setBackgroundPen(QPen(Qt::NoPen)); lbl.draw(painter, QRect(QPoint(0, 0), labelSize)); painter->restore(); }
/*! Find the bounding rect for the label. The coordinates of the rect are relative to spacing + ticklength from the backbone in direction of the tick. \param font Font used for painting \param value Value */ QRect QwtScaleDraw::labelRect(const QFont &font, double value) const { QwtText lbl = tickLabel(font, value); if ( lbl.isEmpty() ) return QRect(0, 0, 0, 0); const QPoint pos = labelPosition(value); QSize labelSize = lbl.textSize(font); if ( labelSize.height() % 2 ) { labelSize.setHeight(labelSize.height() + 1); } const QwtMatrix m = labelMatrix(pos, labelSize); #if 0 QRect br = QwtMetricsMap::translate(m, QRect(QPoint(0, 0), labelSize)); #else QwtPolygon pol(4); pol.setPoint(0, 0, 0); pol.setPoint(1, 0, labelSize.height() - 1 ); pol.setPoint(2, labelSize.width() - 1, 0); pol.setPoint(3, labelSize.width() - 1, labelSize.height() - 1 ); pol = QwtMetricsMap::translate(m, pol); QRect br = pol.boundingRect(); #endif #if QT_VERSION < 0x040000 br.moveBy(-pos.x(), -pos.y()); #else br.translate(-pos.x(), -pos.y()); #endif return br; }
/*! Draws the label for a major scale tick \param painter Painter \param value Value \sa drawTick(), drawBackbone(), boundingLabelRect() */ void QwtScaleDraw::drawLabel(QPainter *painter, double value) const { QwtText lbl = tickLabel(painter->font(), value); if ( lbl.isEmpty() ) return; const QPoint pos = labelPosition(value); QSize labelSize = lbl.textSize(painter->font()); if ( labelSize.height() % 2 ) labelSize.setHeight(labelSize.height() + 1); const QwtMatrix m = labelMatrix( pos, labelSize); painter->save(); #if QT_VERSION < 0x040000 painter->setWorldMatrix(m, true); #else painter->setMatrix(m, true); #endif lbl.draw (painter, QRect(QPoint(0, 0), labelSize) ); painter->restore(); }
void KexiDBAutoField::createEditor() { if (subwidget()) { delete(QWidget *)subwidget(); } QWidget *newSubwidget; //kDebug() << "widgetType:" << d->widgetType; switch (d->widgetType) { case Text: case Double: //! @todo setup validator case Integer: //! @todo setup validator case Date: case Time: case DateTime: { KexiDBLineEdit *le = new KexiDBLineEdit(this); newSubwidget = le; le->setFrame(false); break; } case MultiLineText: newSubwidget = new KexiDBTextEdit(this); break; case Boolean: newSubwidget = new KexiDBCheckBox(dataSource(), this); break; case Image: newSubwidget = new KexiDBImageBox(designMode(), this); break; case ComboBox: { KexiDBComboBox *cbox = new KexiDBComboBox(this); newSubwidget = cbox; cbox->setDesignMode(designMode()); break; } default: newSubwidget = 0; changeText(d->caption); break; } //kDebug() << newSubwidget; setSubwidget(newSubwidget); //this will also allow to declare subproperties, see KFormDesigner::WidgetWithSubpropertiesInterface if (newSubwidget) { newSubwidget->setObjectName( QString::fromLatin1("KexiDBAutoField_") + newSubwidget->metaObject()->className()); dynamic_cast<KexiDataItemInterface*>(newSubwidget)->setParentDataItemInterface(this); dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox dynamic_cast<KexiFormDataItemInterface*>(newSubwidget) ->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox newSubwidget->setProperty("dataSource", dataSource()); //needed at least by KexiDBImageBox KFormDesigner::DesignTimeDynamicChildWidgetHandler::childWidgetAdded(this); newSubwidget->show(); d->label->setBuddy(newSubwidget); if (d->focusPolicyChanged) {//if focusPolicy is changed at top level, editor inherits it newSubwidget->setFocusPolicy(focusPolicy()); } else {//if focusPolicy is not changed at top level, inherit it from editor QWidget::setFocusPolicy(newSubwidget->focusPolicy()); } setFocusProxy(newSubwidget); //ok? if (parentWidget()) newSubwidget->setPalette(qApp->palette()); copyPropertiesToEditor(); } setLabelPosition(labelPosition()); }
void ScaleDraw::drawLabel(QPainter *painter, double value) const { if (!d_plot) return; ScaleEngine *sc_engine = (ScaleEngine *)d_plot->axisScaleEngine(axis()); if (sc_engine->hasBreak() && sc_engine->axisBreakLeft() <= value && sc_engine->axisBreakRight() > value) return; QwtValueList majTicks = scaleDiv().ticks(QwtScaleDiv::MajorTick); if (majTicks.contains(value)){ switch (d_show_ticks_policy){ case ShowAll: break; case HideBegin: if (majTicks.first() == value) return; break; case HideEnd: if (majTicks.last() == value) return; break; case HideBeginEnd: if (majTicks.first() == value || majTicks.last() == value) return; break; } } QwtText lbl = tickLabel(painter->font(), value); if ( lbl.isEmpty() ) return; QPoint pos = labelPosition(value); QSize labelSize = lbl.textSize(painter->font()); if ( labelSize.height() % 2 ) labelSize.setHeight(labelSize.height() + 1); const QwtMetricsMap metricsMap = QwtPainter::metricsMap(); QwtPainter::resetMetricsMap(); labelSize = metricsMap.layoutToDevice(labelSize); pos = metricsMap.layoutToDevice(pos); painter->save(); painter->setMatrix(labelMatrix( pos, labelSize), true); if (d_selected) lbl.setBackgroundPen(QPen(Qt::blue)); else lbl.setBackgroundPen(QPen(Qt::NoPen)); lbl.setRenderFlags(labelAlignment()); lbl.draw (painter, QRect(QPoint(0, 0), labelSize) ); QwtPainter::setMetricsMap(metricsMap); // restore metrics map painter->restore(); }