void QgsComposerItem::init( const bool manageZValue ) { setFlag( QGraphicsItem::ItemIsSelectable, true ); //set default pen and brush setBrush( QBrush( QColor( 255, 255, 255, 255 ) ) ); QPen defaultPen( QColor( 0, 0, 0 ) ); defaultPen.setWidthF( 0.3 ); defaultPen.setJoinStyle( mFrameJoinStyle ); setPen( defaultPen ); //let z-Value be managed by composition if ( mComposition && manageZValue ) { mCompositionManagesZValue = true; mComposition->addItemToZList( this ); } else { mCompositionManagesZValue = false; } // Setup composer effect mEffect = new QgsComposerEffect(); setGraphicsEffect( mEffect ); // data defined strings mDataDefinedNames.insert( QgsComposerObject::PageNumber, QString( "dataDefinedPageNumber" ) ); mDataDefinedNames.insert( QgsComposerObject::PositionX, QString( "dataDefinedPositionX" ) ); mDataDefinedNames.insert( QgsComposerObject::PositionY, QString( "dataDefinedPositionY" ) ); mDataDefinedNames.insert( QgsComposerObject::ItemWidth, QString( "dataDefinedWidth" ) ); mDataDefinedNames.insert( QgsComposerObject::ItemHeight, QString( "dataDefinedHeight" ) ); mDataDefinedNames.insert( QgsComposerObject::ItemRotation, QString( "dataDefinedRotation" ) ); mDataDefinedNames.insert( QgsComposerObject::Transparency, QString( "dataDefinedTransparency" ) ); mDataDefinedNames.insert( QgsComposerObject::BlendMode, QString( "dataDefinedBlendMode" ) ); mDataDefinedNames.insert( QgsComposerObject::ExcludeFromExports, QString( "dataDefinedExcludeExports" ) ); }
QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition, bool manageZValue ) : QObject( 0 ) , QGraphicsRectItem( 0, 0, width, height, 0 ) , mComposition( composition ) , mBoundingResizeRectangle( 0 ) , mFrame( true ) , mItemPositionLocked( false ) , mLastValidViewScaleFactor( -1 ) , mRotation( 0 ) { setFlag( QGraphicsItem::ItemIsSelectable, true ); setAcceptsHoverEvents( true ); QTransform t; t.translate( x, y ); setTransform( t ); //set default pen and brush setBrush( QBrush( QColor( 255, 255, 255, 255 ) ) ); QPen defaultPen( QColor( 0, 0, 0 ) ); defaultPen.setWidthF( 0.3 ); setPen( defaultPen ); //let z-Value be managed by composition if ( mComposition && manageZValue ) { mComposition->addItemToZList( this ); } }
QGeoMapCircleObject * MapBox::addCircle(const QGeoCoordinate & center, qreal radius) { QGeoMapCircleObject * circle = new QGeoMapCircleObject(center, radius); circle->setPen(defaultPen()); circle->setBrush(defaultBrush()); m_mapWidget->addMapObject(circle); return circle; }
QGeoMapPolylineObject * MapBox::addPolyline(const QList<QGeoCoordinate> & path) { QGeoMapPolylineObject * polyline = new QGeoMapPolylineObject(); polyline->setPen(defaultPen()); // TODO: check polyline->setPath(path); m_mapWidget->addMapObject(polyline); return polyline; }
QGeoMapRectangleObject * MapBox::addRectangle(const QGeoCoordinate & topLeft, const QGeoCoordinate & bottomRight) { QGeoMapRectangleObject * rectangle = new QGeoMapRectangleObject(topLeft, bottomRight); rectangle->setPen(defaultPen()); rectangle->setBrush(defaultBrush()); m_mapWidget->addMapObject(rectangle); return rectangle; }
QGeoMapPolygonObject * MapBox::addPolygon(const QList<QGeoCoordinate> & path) { QGeoMapPolygonObject * polygon = new QGeoMapPolygonObject(); polygon->setPen(defaultPen()); polygon->setBrush(defaultBrush()); polygon->setPath(path); m_mapWidget->addMapObject(polygon); return polygon; }
void QgsComposerItem::init( bool manageZValue ) { setFlag( QGraphicsItem::ItemIsSelectable, true ); setAcceptsHoverEvents( true ); //set default pen and brush setBrush( QBrush( QColor( 255, 255, 255, 255 ) ) ); QPen defaultPen( QColor( 0, 0, 0 ) ); defaultPen.setWidthF( 0.3 ); setPen( defaultPen ); //let z-Value be managed by composition if ( mComposition && manageZValue ) { mComposition->addItemToZList( this ); } }
void QgsComposerItem::init( bool manageZValue ) { setFlag( QGraphicsItem::ItemIsSelectable, true ); //set default pen and brush setBrush( QBrush( QColor( 255, 255, 255, 255 ) ) ); QPen defaultPen( QColor( 0, 0, 0 ) ); defaultPen.setWidthF( 0.3 ); defaultPen.setJoinStyle( mFrameJoinStyle ); setPen( defaultPen ); //let z-Value be managed by composition if ( mComposition && manageZValue ) { mComposition->addItemToZList( this ); } // Setup composer effect mEffect = new QgsComposerEffect(); setGraphicsEffect( mEffect ); }
void QgsComposerItem::init( const bool manageZValue ) { setFlag( QGraphicsItem::ItemIsSelectable, true ); //set default pen and brush setBrush( mBackgroundColor ); QPen defaultPen( mFrameColor ); defaultPen.setWidthF( mFrameWidth ); defaultPen.setJoinStyle( mFrameJoinStyle ); setPen( defaultPen ); //let z-Value be managed by composition if ( mComposition && manageZValue ) { mCompositionManagesZValue = true; mComposition->addItemToZList( this ); } else { mCompositionManagesZValue = false; } // Setup composer effect mEffect = new QgsComposerEffect(); setGraphicsEffect( mEffect ); }
void PaletteColorPicker::OnPaint(wxPaintEvent& evt) { wxPaintDC dc(this); wxPen defaultPen(wxColor(64, 64, 64)), selectedPen(wxColor(255, 255, 0), 2); int symbol_width = GetSize().GetWidth() / 16; int symbol_height = GetSize().GetHeight() - 16; wxColor colors[16]; for (int i = 0; i < 256; i += 16) { colors[i / 16] = wxColor(255 - i, 255 - i, 255 - i); } for (int i = 0; i < 256; i += 80) { colors[i / 80] = wxColor(255 - i, 255 - i, 255 - i); } for (int i = 0; i < 16; ++i) { wxPoint position; position.x = symbol_width * i; position.y = 0; wxBrush tempBrush = wxBrush(colors[i]); dc.SetBrush(tempBrush); if (m_selectedColor == i) { dc.SetPen(selectedPen); } else { dc.SetPen(defaultPen); } dc.DrawRectangle(position, wxSize(symbol_width, symbol_height)); dc.DrawText(wxString::Format("%d", i), wxPoint(position.x, symbol_height + 2)); } }
void SaagharItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { // if (parent()->objectName()=="searchTable") // { // qDebug() << keywordList; // } const bool flagRightToLeft = true; int textHMargin = 0; if (tableStyle) { textHMargin = tableStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, &option) +1 ; } QBrush itemBrush = painter->brush(); itemBrush.setColor(SaagharWidget::matchedTextColor); itemBrush.setStyle(Qt::SolidPattern); QString text=""; QString cleanedText = ""; int lastX,x; const QFontMetrics fontMetric(option.fontMetrics); const QString tatweel = QString(0x0640); int iconWidth = 0; if (index.data().isValid()) { text = index.data().toString(); if (index.data(Qt::DecorationRole).isValid()) { QIcon icon = index.data(Qt::DecorationRole).value<QIcon>(); iconWidth = icon.pixmap(100, 100).width()+5; } cleanedText = QGanjoorDbBrowser::cleanString(text); // if (text.contains( QString::fromLocal8Bit( // "پسر چون ز مادر بران گونه زاد" //// "پرپر شد ..." // /*"وَز ســوری و نــعــمـان وزد، هـر دم شـمـیـم عـنـبـریـن"*/))) // { // qDebug() << "textt="<<text; // qDebug() << "clean="<<cleanedText; // } text = QGanjoorDbBrowser::cleanString(text/*, false*/); } //qDebug() << "text="<<text<<"cleanedText="<<cleanedText; Qt::Alignment itemAlignment = 0; QVariant alignValue = index.data(Qt::TextAlignmentRole); if (alignValue.isValid() && !alignValue.isNull()) itemAlignment = Qt::Alignment(alignValue.toInt()); int keywordsCount = keywordList.size(); for (int i=0; i<keywordsCount; ++i) { lastX = x = option.rect.x()+textHMargin; //QString keyword = keywordList.isEmpty() ? "" : keywordList.at(0); QString keyword = keywordList.at(i); keyword.replace(QChar(0x200C), "", Qt::CaseInsensitive);//replace ZWNJ by "" //qDebug() << "keyword1="<<keyword; keyword = keyword.split("", QString::SkipEmptyParts).join(tatweel+"*"); //qDebug() << "keyword2="<<keyword; keyword.replace("@"+tatweel+"*", "\\S*", Qt::CaseInsensitive);//replace wildcard by word chars //qDebug() << "keyword3="<<keyword; QRegExp maybeTatweel(keyword, Qt::CaseInsensitive); maybeTatweel.indexIn(text); //qDebug() << text<<"count=" << maybeTatweel.captureCount()<<maybeTatweel.capturedTexts(); //qDebug() << "Match: "<<maybeTatweel.cap(0); keyword = maybeTatweel.cap(0); if (!(keyword.isEmpty() || text.indexOf(keyword) == -1 ) ) { QString txt = text; while (txt.size() > 0) { int index = txt.indexOf(keyword); QString thisPart; if (index == -1) { thisPart = txt; txt = QString(); } else { if (index == 0) { thisPart = txt.mid(0, keyword.size()); if (txt == keyword) txt = QString(); else txt = txt.mid(keyword.size(), txt.size() - keyword.size()); } else { thisPart = txt.mid(0, index); txt = txt.mid(index); } } QSize sz = fontMetric.boundingRect(thisPart).size(); if (index == 0) { if (flagRightToLeft) { switch (itemAlignment^Qt::AlignVCenter) { case Qt::AlignRight: lastX = option.rect.left()+textHMargin+fontMetric.boundingRect(text).width()-(lastX-option.rect.x()+sz.width()-textHMargin); break; case Qt::AlignHCenter: lastX = option.rect.left()+textHMargin+fontMetric.boundingRect(text).width()-(lastX-option.rect.x()+sz.width()-textHMargin)+((option.rect.width()-fontMetric.boundingRect(text).width()-textHMargin)/2); break; case Qt::AlignLeft: default: lastX = option.rect.right()+textHMargin-1 - (lastX-option.rect.x()+sz.width()); break; } } QRectF rectf(lastX , option.rect.y()+((option.rect.height()-qMin(option.rect.height(), fontMetric.height()))/2), sz.width(), fontMetric.height() ); qreal oldOpacity = painter->opacity(); painter->setOpacity(0.65); rectf.adjust(-iconWidth, 0, -iconWidth, 0); QPainterPath roundedRect; roundedRect.addRoundRect(rectf, 50, 50); QPen defaultPen(painter->pen()); painter->setPen(SaagharWidget::matchedTextColor.darker(150)); painter->drawPath(roundedRect); painter->fillPath( roundedRect, itemBrush ); painter->setOpacity(oldOpacity); painter->setPen(defaultPen); //painter->fillRect( rectf, itemBrush ); } x += option.fontMetrics.width(thisPart); lastX = x; } } else if (!(keyword.isEmpty() || cleanedText.indexOf(keyword) == -1 ) ) { qreal oldOpacity = painter->opacity(); painter->setOpacity(0.35); painter->fillRect( option.rect, itemBrush ); painter->setOpacity(oldOpacity); //painter->fillRect( rectf, itemBrush ); } } QStyledItemDelegate::paint(painter, option, index); }
wxPenRefData( const wxPenRefData& data ) : wxGDIRefData() { m_qtPen = data.m_qtPen; defaultPen(); }
wxPenRefData() { defaultPen(); }