Added Abhishek Bansal patch:

Diagram::background_color is now selectable
and make component color reverse color for contrast, thanks Abhishek


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2670 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2013-12-26 17:59:58 +00:00
parent ef4bbdf0e3
commit 106b57ba3c
7 changed files with 91 additions and 6 deletions

View File

@@ -37,6 +37,8 @@ const int Diagram::xGrid = 10;
const int Diagram::yGrid = 10;
const qreal Diagram::margin = 5.0;
// static variable to keep track of present background color of the diagram.
QColor Diagram::background_color = Qt::white;
/**
Constructeur
@param parent Le QObject parent du schema
@@ -121,12 +123,17 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
// dessine un fond blanc
p -> setPen(Qt::NoPen);
p -> setBrush(Qt::white);
//set brush color to present background color.
p -> setBrush(Diagram::background_color);
p -> drawRect(r);
if (draw_grid_) {
// dessine les points de la grille
p -> setPen(Qt::black);
// if background color is black, then grid spots shall be white, else they shall be black in color.
if (Diagram::background_color == Qt::black)
p -> setPen(Qt::white);
else
p -> setPen(Qt::black);
p -> setBrush(Qt::NoBrush);
qreal limite_x = r.x() + r.width();
qreal limite_y = r.y() + r.height();