Freeciv-3.2
Loading...
Searching...
No Matches
mapview.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__MAPVIEW_H
15#define FC__MAPVIEW_H
16
17// In this case we have to include fc_config.h from header file.
18// Some other headers we include demand that fc_config.h must be
19// included also. Usually all source files include fc_config.h, but
20// there's moc generated meta_mapview.cpp file which does not.
21#ifdef HAVE_CONFIG_H
22#include <fc_config.h>
23#endif
24
25extern "C" {
26#include "mapview_g.h"
27}
28
29// gui-qt
30#include "fonts.h"
31
32// Qt
33#include <QFrame>
34#include <QLabel>
35#include <QMutex>
36#include <QQueue>
37#include <QThread>
38#include <QTimer>
39
40// Forward declarations
41class QMutex;
42class QPixmap;
43
44class minimap_view;
45
46bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye);
47void unscale_point(double scale_factor, int &x, int &y);
49
50/**************************************************************************
51 Struct used for idle callback to execute some callbacks later
52**************************************************************************/
54 void (*callback) (void *data);
55 void *data;
56};
57
58/**************************************************************************
59 Class to handle idle callbacks
60**************************************************************************/
61class mr_idle : public QObject
62{
64public:
65 mr_idle();
66 ~mr_idle();
67
68 void add_callback(call_me_back *cb);
69private slots:
70 void idling();
71private:
74};
75
76/**************************************************************************
77 QWidget used for displaying map
78**************************************************************************/
79class map_view : public QWidget
80{
82 void shortcut_pressed(int key);
83 void shortcut_released(Qt::MouseButton mb);
84public:
85 map_view();
87 void find_place(int pos_x, int pos_y, int &w, int &h, int wdth, int hght,
88 int recursive_nr);
89 void resume_searching(int pos_x, int pos_y, int &w, int &h,
90 int wdth, int hght, int recursive_nr);
91 void update_cursor(enum cursor_type);
93
94protected:
101 void leaveEvent(QEvent *event);
102private slots:
103 void timer_event();
104private:
105 void update_font(const QString &name, const QFont &font);
106
110
111};
112
113/**************************************************************************
114 Information label about clicked tile
115**************************************************************************/
116class info_tile: public QLabel
117{
120public:
121 info_tile(struct tile *ptile, QWidget *parent = 0);
122 struct tile *itile;
123protected:
126private:
128 void calc_size();
129 void update_font(const QString &name, const QFont &font);
130};
131
132/**************************************************************************
133 Widget allowing resizing other widgets
134**************************************************************************/
135class resize_widget : public QLabel
136{
138public:
139 resize_widget(QWidget* parent);
140 void put_to_corner();
141
142protected:
145private:
147};
148
149
150/**************************************************************************
151 Widget allowing moving other widgets
152**************************************************************************/
153class move_widget : public QLabel
154{
156public:
157 move_widget(QWidget* parent);
158 void put_to_corner();
159
160protected:
163private:
165};
166
167/**************************************************************************
168 Abstract class for widgets wanting to do custom action
169 when closing widgets is called (eg. update menu)
170**************************************************************************/
171class fcwidget : public QFrame
172{
174public:
175 virtual void update_menu() = 0;
177};
178
179/**************************************************************************
180 Widget allowing closing other widgets
181**************************************************************************/
182class close_widget : public QLabel
183{
185public:
186 close_widget(QWidget *parent);
187 void put_to_corner();
188protected:
190 void notify_parent();
191};
192
193/**************************************************************************
194 Thread helper for drawing minimap
195**************************************************************************/
196class minimap_thread : public QThread
197{
199public:
200 minimap_thread(QObject *parent = 0);
202 void render(double scale_factor, int width, int height);
203
204signals:
206protected:
207 void run() Q_DECL_OVERRIDE;
208
209private:
211 double scale;
213};
214
215/**************************************************************************
216 QLabel used for displaying overview (minimap)
217**************************************************************************/
219{
221public:
222 minimap_view(QWidget *parent);
224 void paint(QPainter *painter, QPaintEvent *event);
225 virtual void update_menu();
226 void update_image();
227 void reset();
228
229protected:
230 void paintEvent(QPaintEvent *event);
231 void resizeEvent(QResizeEvent *event);
232 void mousePressEvent(QMouseEvent *event);
233 void mouseMoveEvent(QMouseEvent *event);
234 void mouseReleaseEvent(QMouseEvent *event);
235 void wheelEvent(QWheelEvent *event);
236 void moveEvent(QMoveEvent *event);
237 void showEvent(QShowEvent *event);
238
239private slots:
240 void update_pixmap(const QImage &image);
241 void zoom_in();
242 void zoom_out();
243
244private:
245 void draw_viewport(QPainter *painter);
246 void scale(double factor);
247 void scale_point(int &x, int &y);
249 float w_ratio, h_ratio;
256};
257
258
259void mapview_freeze(void);
260void mapview_thaw(void);
261bool mapview_is_frozen(void);
263 struct sprite *ssprite);
264
265#endif // FC__MAPVIEW_H
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int canvas_y
Definition canvas_g.h:43
struct canvas int canvas_x
Definition canvas_g.h:43
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
void put_to_corner()
Definition mapview.cpp:502
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:510
void notify_parent()
Definition mapview.cpp:524
virtual void update_menu()=0
bool was_destroyed
Definition mapview.h:176
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:1435
void calc_size()
Definition mapview.cpp:1367
struct tile * itile
Definition mapview.h:122
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:1423
QStringList str_list
Definition mapview.h:127
QFont info_font
Definition mapview.h:119
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:1406
void leaveEvent(QEvent *event)
Definition mapview.cpp:271
void paintEvent(QPaintEvent *event)
Definition mapview.cpp:279
bool menu_click
Definition mapview.h:92
bool stored_autocenter
Definition mapview.h:107
int cursor_frame
Definition mapview.h:108
void keyPressEvent(QKeyEvent *event)
Definition mapctrl.cpp:119
int cursor
Definition mapview.h:109
void find_place(int pos_x, int pos_y, int &w, int &h, int wdth, int hght, int recursive_nr)
Definition mapview.cpp:328
void mouseMoveEvent(QMouseEvent *event)
Definition mapctrl.cpp:537
void timer_event()
Definition mapview.cpp:231
void update_cursor(enum cursor_type)
Definition mapview.cpp:213
void mousePressEvent(QMouseEvent *event)
Definition mapctrl.cpp:521
void update_font(const QString &name, const QFont &font)
Definition mapview.cpp:252
void resume_searching(int pos_x, int pos_y, int &w, int &h, int wdth, int hght, int recursive_nr)
Definition mapview.cpp:301
void mouseReleaseEvent(QMouseEvent *event)
Definition mapctrl.cpp:529
void paint(QPainter *painter, QPaintEvent *event)
Definition mapview.cpp:291
void focusOutEvent(QFocusEvent *event)
Definition mapview.cpp:263
void shortcut_released(Qt::MouseButton mb)
Definition mapctrl.cpp:483
void shortcut_pressed(int key)
Definition mapctrl.cpp:214
void rendered_image(const QImage &image)
void render(double scale_factor, int width, int height)
Definition mapview.cpp:763
double scale
Definition mapview.h:211
void run() Q_DECL_OVERRIDE
Definition mapview.cpp:775
QMutex mutex
Definition mapview.h:212
QPoint position
Definition mapview.h:254
QPoint cursor
Definition mapview.h:253
float h_ratio
Definition mapview.h:249
double scale_factor
Definition mapview.h:248
QPixmap * pix
Definition mapview.h:252
resize_widget * rw
Definition mapview.h:255
QBrush background
Definition mapview.h:251
minimap_thread thread
Definition mapview.h:250
void put_to_corner()
Definition mapview.cpp:399
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:417
QPoint point
Definition mapview.h:164
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:407
void idling()
Definition mapview.cpp:174
QQueue< call_me_back * > callback_list
Definition mapview.h:72
void add_callback(call_me_back *cb)
Definition mapview.cpp:188
QTimer timer
Definition mapview.h:73
void put_to_corner()
Definition mapview.cpp:443
QPoint point
Definition mapview.h:146
void mouseMoveEvent(QMouseEvent *event)
Definition mapview.cpp:452
void mousePressEvent(QMouseEvent *event)
Definition mapview.cpp:471
char * incite_cost
Definition comments.c:75
enum event_type event
Definition events.c:81
void mapview_freeze(void)
Definition mapview.c:373
void unscale_point(double scale_factor, int &x, int &y)
Definition mapview.cpp:713
void pixmap_put_overlay_tile(int canvas_x, int canvas_y, struct sprite *ssprite)
Definition mapview.cpp:1229
bool mapview_is_frozen(void)
Definition mapview.c:395
bool is_point_in_area(int x, int y, int px, int py, int pxe, int pye)
Definition mapview.cpp:71
void draw_calculated_trade_routes(QPainter *painter)
Definition mapview.cpp:82
void mapview_thaw(void)
Definition mapview.c:381
const char * name
Definition inputfile.c:127
struct player_slot * slots
Definition player.c:51
struct sprite int int y
Definition sprite_g.h:31
struct sprite int x
Definition sprite_g.h:31
void * data
Definition mapview.h:55
Definition tile.h:50
cursor_type
Definition tilespec.h:287