File indexing completed on 2024-03-24 15:43:19

0001 // Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
0002 //
0003 // This library is free software; you can redistribute it and/or
0004 // modify it under the terms of the GNU Lesser General Public
0005 // License version 2.1 as published by the Free Software Foundation.
0006 //
0007 // This library is distributed in the hope that it will be useful,
0008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
0009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0010 // Lesser General Public License for more details.
0011 //
0012 // You should have received a copy of the GNU Lesser General Public License
0013 // along with this library; see the file COPYING.LIB.  If not, write to
0014 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0015 // Boston, MA 02110-1301, USA.
0016 
0017 #ifndef ATLANTIK_ESTATEVIEW_H
0018 #define ATLANTIK_ESTATEVIEW_H
0019 
0020 #include <QWidget>
0021 
0022 enum EstateOrientation { North=0, East=1, South=2, West=3 };
0023 
0024 class QPixmap;
0025 
0026 class Player;
0027 class Estate;
0028 
0029 class EstateView : public QWidget
0030 {
0031 Q_OBJECT
0032 
0033     public:
0034         EstateView(Estate *estate, EstateOrientation orientation, const QString &, 
0035                bool indicateUnowned, bool highlightUnowned, bool darkenMortgaged, bool quartzEffects, QWidget *parent);
0036         ~EstateView();
0037         void setViewProperties(bool indicateUnowned, bool highlightUnowned, bool darkenMortgaged, bool quartzEffects);
0038         Estate *estate() const { return m_estate; }
0039         void updatePE();
0040         EstateOrientation orientation() const { return m_orientation; }
0041         void setAllowEstateSales(bool allow);
0042 
0043     Q_SIGNALS:
0044         void estateToggleMortgage(Estate *estate);
0045         void estateHouseBuy(Estate *estate);
0046         void estateHouseSell(Estate *estate);
0047         void estateSell(Estate *estate);
0048         void newTrade(Player *player);
0049         void LMBClicked(Estate *estate);
0050 
0051     protected:
0052         void paintEvent(QPaintEvent *) override;
0053         void resizeEvent(QResizeEvent *) override;
0054         void contextMenuEvent(QContextMenuEvent *) override;
0055         void mousePressEvent(QMouseEvent *) override;
0056 
0057 private:
0058     void updateToolTip();
0059         void loadIcon(const QString &_icon);
0060 
0061         QPixmap *rotatePixmap(QPixmap *) const;
0062         void drawQuartzBlocks(QPixmap *pi, const QColor &c1, const QColor &c2);
0063 
0064         Estate *m_estate;
0065         QPixmap *qpixmap, *icon;
0066         QPixmap *m_quartzBlocks, *m_pe;
0067         bool m_allowEstateSales : 1;
0068         bool m_indicateUnowned : 1, m_highlightUnowned : 1, m_darkenMortgaged : 1, m_quartzEffects : 1;
0069         bool b_recreate : 1, m_recreateQuartz : 1;
0070         EstateOrientation m_orientation : 3;
0071         int m_titleWidth, m_titleHeight;
0072         QString m_estateIcon;
0073         QColor m_estateColor;
0074 
0075     private Q_SLOTS:
0076         void estateChanged();
0077         void slotToggleMortgage();
0078         void slotHouseBuy();
0079         void slotHouseSell();
0080         void slotSell();
0081         void slotNewTrade();
0082 };
0083 
0084 #endif