mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
backgroundBrushStyle property has been added
This commit is contained in:
parent
f72f1a743e
commit
7da0cfd7e2
@ -85,7 +85,7 @@ void ShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
pen.setStyle(m_penStyle);
|
||||
painter->setPen(pen);
|
||||
QBrush brush(m_shapeBrushColor,m_shapeBrushType);
|
||||
|
||||
brush.setTransform(painter->worldTransform().inverted());
|
||||
painter->setBrush(brush);
|
||||
painter->setBackground(QBrush(Qt::NoBrush));
|
||||
painter->setOpacity(qreal(m_opacity)/100);
|
||||
|
@ -68,6 +68,7 @@ class TextItem : public LimeReport::ContentItemDesignIntf, IPageInit {
|
||||
Q_PROPERTY(QString format READ format WRITE setFormat)
|
||||
Q_PROPERTY(ValueType valueType READ valueType WRITE setValueType)
|
||||
Q_PROPERTY(QString followTo READ followTo WRITE setFollowTo)
|
||||
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
||||
public:
|
||||
|
||||
enum AutoWidth{NoneAutoWidth,MaxWordLength,MaxStringLength};
|
||||
|
@ -183,16 +183,20 @@ BandDesignIntf::~BandDesignIntf()
|
||||
delete m_bandNameLabel;
|
||||
}
|
||||
|
||||
void BandDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
if (backgroundColor()!=Qt::white) {
|
||||
ppainter->fillRect(rect(),backgroundColor());
|
||||
|
||||
if ( !(backgroundColor() == Qt::white && backgroundBrushStyle() == SolidPattern) ) {
|
||||
QBrush brush(backgroundColor(), static_cast<Qt::BrushStyle>(backgroundBrushStyle()));
|
||||
brush.setTransform(painter->worldTransform().inverted());
|
||||
painter->fillRect(rect(), brush);
|
||||
}
|
||||
if (itemMode()&DesignMode){
|
||||
ppainter->save();
|
||||
|
||||
if (itemMode() & DesignMode){
|
||||
painter->save();
|
||||
QString bandText = objectName();
|
||||
if (parentBand()) bandText+=QLatin1String(" connected to ")+parentBand()->objectName();
|
||||
QFont font("Arial",7*Const::fontFACTOR,-1,true);
|
||||
QFont font("Arial", 7 * Const::fontFACTOR, -1, true);
|
||||
QFontMetrics fontMetrics(font);
|
||||
|
||||
QVector<QRectF> bandNameRects;
|
||||
@ -204,22 +208,22 @@ void BandDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
||||
//if (isSelected()) ppainter->setPen(QColor(167,244,167));
|
||||
// else ppainter->setPen(QColor(220,220,220));
|
||||
|
||||
ppainter->setFont(font);
|
||||
painter->setFont(font);
|
||||
for (int i=0;i<bandNameRects.count();i++){
|
||||
QRectF labelRect = bandNameRects[i].adjusted(-2,-2,2,2);
|
||||
if ((labelRect.height())<height() && (childBaseItems().isEmpty()) && !isSelected()){
|
||||
ppainter->setRenderHint(QPainter::Antialiasing);
|
||||
ppainter->setBrush(bandColor());
|
||||
ppainter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
|
||||
ppainter->drawRoundedRect(labelRect,8,8);
|
||||
ppainter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
|
||||
ppainter->setPen(Qt::black);
|
||||
ppainter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setBrush(bandColor());
|
||||
painter->setOpacity(Const::BAND_NAME_AREA_OPACITY);
|
||||
painter->drawRoundedRect(labelRect,8,8);
|
||||
painter->setOpacity(Const::BAND_NAME_TEXT_OPACITY);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawText(bandNameRects[i],Qt::AlignHCenter,bandText);
|
||||
}
|
||||
}
|
||||
ppainter->restore();
|
||||
painter->restore();
|
||||
}
|
||||
BaseDesignIntf::paint(ppainter,option,widget);
|
||||
BaseDesignIntf::paint(painter,option,widget);
|
||||
}
|
||||
|
||||
BandDesignIntf::BandsType BandDesignIntf::bandType() const
|
||||
|
@ -92,6 +92,7 @@ class BandDesignIntf : public BaseDesignIntf
|
||||
Q_PROPERTY(bool keepBottomSpace READ keepBottomSpaceOption WRITE setKeepBottomSpaceOption )
|
||||
Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
|
||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
|
||||
Q_PROPERTY(BrushStyle backgroundBrushStyle READ backgroundBrushStyle WRITE setBackgroundBrushStyle)
|
||||
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
|
||||
Q_ENUMS(BandColumnsLayoutType)
|
||||
friend class BandMarker;
|
||||
@ -121,7 +122,7 @@ public:
|
||||
BandDesignIntf(BandsType bandType, const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
~BandDesignIntf();
|
||||
|
||||
void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
virtual BandsType bandType() const;
|
||||
virtual QString bandTitle() const;
|
||||
virtual QIcon bandIcon() const;
|
||||
|
@ -64,14 +64,13 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
|
||||
m_BGMode(OpaqueMode),
|
||||
m_opacity(100),
|
||||
m_borderLinesFlags(0),
|
||||
m_hintFrame(0),
|
||||
m_storageTypeName(storageTypeName),
|
||||
m_itemMode(DesignMode),
|
||||
m_objectState(ObjectCreated),
|
||||
m_selectionMarker(0),
|
||||
m_joinMarker(0),
|
||||
m_backgroundBrush(Solid),
|
||||
m_backgroundBrushcolor(Qt::white),
|
||||
m_backgroundBrushStyle(SolidPattern),
|
||||
m_backgroundColor(Qt::white),
|
||||
m_margin(4),
|
||||
m_itemAlign(DesignedItemAlign),
|
||||
m_changingItemAlign(false),
|
||||
@ -122,21 +121,23 @@ QString BaseDesignIntf::parentReportItemName() const
|
||||
else return "";
|
||||
}
|
||||
|
||||
void BaseDesignIntf::setBackgroundBrushMode(BaseDesignIntf::BrushMode value)
|
||||
void BaseDesignIntf::setBackgroundBrushStyle(BrushStyle value)
|
||||
{
|
||||
if ( value != m_backgroundBrush ){
|
||||
m_backgroundBrush=value;
|
||||
if ( value != m_backgroundBrushStyle ){
|
||||
BrushStyle oldValue = m_backgroundBrushStyle;
|
||||
m_backgroundBrushStyle=value;
|
||||
if (!isLoading()) update();
|
||||
notify("backgroundBrushStyle", static_cast<int>(oldValue), static_cast<int>(value));
|
||||
}
|
||||
}
|
||||
|
||||
void BaseDesignIntf::setBackgroundColor(QColor value)
|
||||
{
|
||||
if (value != m_backgroundBrushcolor){
|
||||
QColor oldValue = m_backgroundBrushcolor;
|
||||
m_backgroundBrushcolor=value;
|
||||
if (value != m_backgroundColor){
|
||||
QColor oldValue = m_backgroundColor;
|
||||
m_backgroundColor=value;
|
||||
if (!isLoading()) update();
|
||||
notify("backgroundColor",oldValue,m_backgroundBrushcolor);
|
||||
notify("backgroundColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,7 +497,6 @@ void BaseDesignIntf::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *o
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
setupPainter(ppainter);
|
||||
|
||||
drawBorder(ppainter, rect());
|
||||
if (isSelected()) {drawSelection(ppainter, rect());}
|
||||
drawResizeZone(ppainter);
|
||||
@ -512,24 +512,28 @@ QColor calcColor(QColor color){
|
||||
return Qt::white;
|
||||
else
|
||||
return Qt::black;
|
||||
};
|
||||
}
|
||||
|
||||
void BaseDesignIntf::prepareRect(QPainter *ppainter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
void BaseDesignIntf::prepareRect(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
ppainter->save();
|
||||
painter->save();
|
||||
|
||||
QBrush brush(m_backgroundColor,static_cast<Qt::BrushStyle>(m_backgroundBrushStyle));
|
||||
brush.setTransform(painter->worldTransform().inverted());
|
||||
|
||||
if (isSelected() && (opacity() == 100) && (m_BGMode!=TransparentMode)) {
|
||||
ppainter->fillRect(rect(), QBrush(QColor(m_backgroundBrushcolor)));
|
||||
painter->fillRect(rect(), brush);
|
||||
}
|
||||
else {
|
||||
if (m_BGMode == OpaqueMode) {
|
||||
ppainter->setOpacity(qreal(m_opacity) / 100);
|
||||
ppainter->fillRect(rect(), QBrush(m_backgroundBrushcolor));
|
||||
painter->setOpacity(qreal(m_opacity) / 100);
|
||||
painter->fillRect(rect(), brush);
|
||||
} else if (itemMode() & DesignMode){
|
||||
ppainter->setOpacity(0.1);
|
||||
ppainter->fillRect(rect(), QBrush(QPixmap(":/report/empty")));
|
||||
painter->setOpacity(0.1);
|
||||
painter->fillRect(rect(), QBrush(QPixmap(":/report/images/empty")));
|
||||
}
|
||||
}
|
||||
ppainter->restore();
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void BaseDesignIntf::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
@ -83,7 +83,7 @@ class BaseDesignIntf :
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
Q_ENUMS(BGMode)
|
||||
Q_ENUMS(Qt::BrushStyle)
|
||||
Q_ENUMS(BrushMode)
|
||||
Q_ENUMS(BrushStyle)
|
||||
Q_ENUMS(ItemAlign)
|
||||
Q_FLAGS(BorderLines)
|
||||
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometryProperty NOTIFY geometryChanged)
|
||||
@ -96,8 +96,23 @@ class BaseDesignIntf :
|
||||
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
|
||||
|
||||
public:
|
||||
enum BGMode { TransparentMode,OpaqueMode};
|
||||
enum BrushMode{Solid,None};
|
||||
enum BGMode { TransparentMode, OpaqueMode};
|
||||
|
||||
enum BrushStyle{ NoBrush,
|
||||
SolidPattern,
|
||||
Dense1Pattern,
|
||||
Dense2Pattern,
|
||||
Dense3Pattern,
|
||||
Dense4Pattern,
|
||||
Dense5Pattern,
|
||||
Dense6Pattern,
|
||||
Dense7Pattern,
|
||||
HorPattern,
|
||||
VerPattern,
|
||||
CrossPattern,
|
||||
BDiagPattern,
|
||||
FDiagPattern };
|
||||
|
||||
enum ResizeFlags { Fixed = 0,
|
||||
ResizeLeft = 1,
|
||||
ResizeRight = 2,
|
||||
@ -124,13 +139,13 @@ public:
|
||||
BaseDesignIntf(const QString& storageTypeName, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual ~BaseDesignIntf();
|
||||
|
||||
void setParentReportItem(const QString& value);
|
||||
void setParentReportItem(const QString& value);
|
||||
QString parentReportItemName() const;
|
||||
|
||||
BrushMode backgroundBrushMode() const {return m_backgroundBrush;}
|
||||
void setBackgroundBrushMode(BrushMode value);
|
||||
QColor backgroundColor() const {return m_backgroundBrushcolor;}
|
||||
void setBackgroundColor(QColor value);
|
||||
BrushStyle backgroundBrushStyle() const {return m_backgroundBrushStyle;}
|
||||
void setBackgroundBrushStyle(BrushStyle value);
|
||||
QColor backgroundColor() const {return m_backgroundColor;}
|
||||
void setBackgroundColor(QColor value);
|
||||
|
||||
QPen pen() const;
|
||||
void setPen(QPen& pen);
|
||||
@ -155,7 +170,7 @@ public:
|
||||
virtual QSizeF sizeMM() const;
|
||||
|
||||
void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
void prepareRect(QPainter* ppainter, const QStyleOptionGraphicsItem*, QWidget*);
|
||||
void prepareRect(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
|
||||
virtual QPainterPath shape() const;
|
||||
|
||||
void setFixedPos(bool fixedPos);
|
||||
@ -329,13 +344,13 @@ private:
|
||||
void turnOnSelectionMarker(bool value);
|
||||
private:
|
||||
QPointF m_startPos;
|
||||
//QPointF m_startScenePos;
|
||||
int m_resizeHandleSize;
|
||||
int m_selectionPenSize;
|
||||
int m_possibleResizeDirectionFlags;
|
||||
int m_possibleMoveDirectionFlags;
|
||||
int m_resizeDirectionFlags;
|
||||
qreal m_width, m_height;
|
||||
qreal m_width;
|
||||
qreal m_height;
|
||||
QPen m_pen;
|
||||
QFont m_font;
|
||||
QColor m_fontColor;
|
||||
@ -357,7 +372,6 @@ private:
|
||||
QRectF m_rightRect;
|
||||
|
||||
QVector<QRectF*> m_resizeAreas;
|
||||
QFrame* m_hintFrame;
|
||||
QString m_storageTypeName;
|
||||
ItemMode m_itemMode;
|
||||
|
||||
@ -365,8 +379,9 @@ private:
|
||||
SelectionMarker* m_selectionMarker;
|
||||
Marker* m_joinMarker;
|
||||
|
||||
BrushMode m_backgroundBrush;
|
||||
QColor m_backgroundBrushcolor;
|
||||
BrushStyle m_backgroundBrushStyle;
|
||||
QColor m_backgroundColor;
|
||||
|
||||
RenderPass m_currentPass;
|
||||
int m_margin;
|
||||
QString m_itemTypeName;
|
||||
|
Loading…
Reference in New Issue
Block a user