File indexing completed on 2024-04-21 14:55:51

0001 /*
0002  * This file is part of the KDE project.
0003  * Copyright © 2010 Christoph Feck <christoph@maxiom.de>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License version 2 as published by the Free Software Foundation.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "kcolorhelpers_p.h"
0021 
0022 #include <QColor>
0023 #include <QPainter>
0024 #include <QPixmap>
0025 
0026 namespace KDEPrivate
0027 {
0028 
0029 void fillOpaqueRect(QPainter *painter, const QRect &rect, const QBrush &brush)
0030 {
0031     if (!brush.isOpaque()) {
0032         QPixmap chessboardPattern(16, 16);
0033         QPainter patternPainter(&chessboardPattern);
0034         patternPainter.fillRect(0, 0, 8, 8, Qt::black);
0035         patternPainter.fillRect(8, 8, 8, 8, Qt::black);
0036         patternPainter.fillRect(0, 8, 8, 8, Qt::white);
0037         patternPainter.fillRect(8, 0, 8, 8, Qt::white);
0038         patternPainter.end();
0039         painter->fillRect(rect, QBrush(chessboardPattern));
0040     }
0041     painter->fillRect(rect, brush);
0042 }
0043 
0044 } // namespace KDEPrivate