1 | /* |
2 | Copyright 2003 Russell Steffen <rsteffen@bayarea.net> |
3 | Copyright 2003 Stephan Zehetner <s.zehetner@nevox.org> |
4 | Copyright 2006 Dmitry Suzdalev <dimsuz@gmail.com> |
5 | Copyright 2006 Inge Wallin <inge@lysator.liu.se> |
6 | Copyright 2006 Pierre Ducroquet <pinaraf@gmail.com> |
7 | Copyright Sean D'Epagnier <geckosenator@gmail.com> |
8 | |
9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by |
11 | the Free Software Foundation; either version 2 of the License, or |
12 | (at your option) any later version. |
13 | |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | GNU General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software |
21 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | */ |
23 | |
24 | #ifndef KONQUEST_MINIMAPVIEW_H |
25 | #define KONQUEST_MINIMAPVIEW_H |
26 | |
27 | #include <QWidget> |
28 | |
29 | #include "map/map.h" |
30 | |
31 | |
32 | class MiniMapView : public QWidget |
33 | { |
34 | Q_OBJECT |
35 | |
36 | public: |
37 | explicit MiniMapView(QWidget *parent = 0); |
38 | ~MiniMapView(); |
39 | |
40 | void setMap(Map *newMap); |
41 | |
42 | /** |
43 | * @note Always use hasSelection() first to make sure that the returned |
44 | * selection is valid. |
45 | */ |
46 | |
47 | Coordinate selection() const { return m_selection; } |
48 | |
49 | bool hasSelection() const { return (m_selection.x() >= 0) && (m_selection.x() < m_map->columns()) && (m_selection.y() >= 0) && (m_selection.y() < m_map->rows()); } |
50 | |
51 | signals: |
52 | void sectorSelected(const Coordinate &coord); |
53 | |
54 | protected: |
55 | void mousePressEvent(QMouseEvent *event); |
56 | void paintEvent(QPaintEvent *event); |
57 | |
58 | private: |
59 | void CalculateOffsets(float &, float &, float &); |
60 | |
61 | Map *m_map; |
62 | Coordinate m_selection; |
63 | }; |
64 | |
65 | #endif // KONQUEST_MINIMAPVIEW_H |
66 | |