summaryrefslogtreecommitdiffstats
path: root/atlantik/libatlantikui/portfolioestate.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /atlantik/libatlantikui/portfolioestate.cpp
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'atlantik/libatlantikui/portfolioestate.cpp')
-rw-r--r--atlantik/libatlantikui/portfolioestate.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/atlantik/libatlantikui/portfolioestate.cpp b/atlantik/libatlantikui/portfolioestate.cpp
new file mode 100644
index 00000000..625fb055
--- /dev/null
+++ b/atlantik/libatlantikui/portfolioestate.cpp
@@ -0,0 +1,94 @@
+// Copyright (c) 2002 Rob Kaper <[email protected]>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License version 2.1 as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; see the file COPYING.LIB. If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+#include <qcolor.h>
+#include <qpainter.h>
+#include <qrect.h>
+
+#include "portfolioestate.moc"
+#include "estate.h"
+
+PortfolioEstate::PortfolioEstate(Estate *estate, Player *player, bool alwaysOwned, QWidget *parent, const char *name) : QWidget(parent, name)
+{
+ m_estate = estate;
+ m_player = player;
+ m_alwaysOwned = alwaysOwned;
+
+ QSize s(PE_WIDTH, PE_HEIGHT);
+ setFixedSize(s);
+
+ b_recreate = true;
+}
+
+void PortfolioEstate::estateChanged()
+{
+ b_recreate = true;
+ update();
+}
+
+QPixmap PortfolioEstate::drawPixmap(Estate *estate, Player *player, bool alwaysOwned)
+{
+ QColor lightGray(204, 204, 204), darkGray(153, 153, 153);
+ QPixmap qpixmap(PE_WIDTH, PE_HEIGHT);
+ QPainter painter;
+ painter.begin(&qpixmap);
+
+ painter.setPen(lightGray);
+ painter.setBrush(white);
+ painter.drawRect(QRect(0, 0, PE_WIDTH, PE_HEIGHT));
+ if (alwaysOwned || (estate && estate->isOwned() && player == estate->owner()))
+ {
+ painter.setPen(darkGray);
+ for (int y=5;y<=13;y+=2)
+ painter.drawLine(2, y, 10, y);
+
+ painter.setPen(Qt::white);
+ painter.drawPoint(8, 5);
+ painter.drawPoint(8, 7);
+ painter.drawPoint(8, 9);
+ painter.drawPoint(5, 11);
+ painter.drawPoint(9, 11);
+ painter.drawPoint(3, 13);
+ painter.drawPoint(10, 13);
+
+ painter.setPen(estate->color());
+ painter.setBrush(estate->color());
+ }
+ else
+ {
+ painter.setPen(lightGray);
+ painter.setBrush(lightGray);
+ }
+ painter.drawRect(0, 0, PE_WIDTH, 3);
+
+ return qpixmap;
+}
+
+void PortfolioEstate::paintEvent(QPaintEvent *)
+{
+ if (b_recreate)
+ {
+ m_pixmap = drawPixmap(m_estate, m_player, m_alwaysOwned);
+ b_recreate = false;
+ }
+ bitBlt(this, 0, 0, &m_pixmap);
+}
+
+void PortfolioEstate::mousePressEvent(QMouseEvent *e)
+{
+ if (e->button()==LeftButton)
+ emit estateClicked(m_estate);
+}