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)
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 ***********************************************************************/
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.
22 #include <fc_config.h>
26 #include "mapview_g.h"
33 #include <QHBoxLayout>
36 #include <QPushButton>
42 // Forward declarations
47 bool is_point_in_area(int x
, int y
, int px
, int py
, int pxe
, int pye
);
48 void draw_calculated_trade_routes(QPainter
*painter
);
50 /**************************************************************************
51 Struct used for idle callback to execute some callbacks later
52 **************************************************************************/
54 void (*callback
) (void *data
);
58 /**************************************************************************
59 Class to handle idle callbacks
60 **************************************************************************/
61 class mr_idle
: public QObject
66 void add_callback(call_me_back
* cb
);
67 QQueue
<call_me_back
*> callback_list
;
74 /**************************************************************************
75 QWidget used for displaying map
76 **************************************************************************/
77 class map_view
: public QWidget
80 void shortcut_pressed(int key
);
81 void shortcut_released(Qt::MouseButton mb
);
84 void paint(QPainter
*painter
, QPaintEvent
*event
);
85 void find_place(int pos_x
, int pos_y
, int &w
, int &h
, int wdth
, int hght
,
87 void resume_searching(int pos_x
,int pos_y
,int &w
, int &h
,
88 int wdtht
, int hght
, int recursive_nr
);
89 void update_cursor(enum cursor_type
);
92 void paintEvent(QPaintEvent
*event
);
93 void keyPressEvent(QKeyEvent
*event
);
94 void mousePressEvent(QMouseEvent
*event
);
95 void mouseReleaseEvent(QMouseEvent
*event
);
96 void mouseMoveEvent(QMouseEvent
*event
);
97 void focusOutEvent(QFocusEvent
*event
);
98 void leaveEvent(QEvent
*event
);
102 void update_font(const QString
&name
, const QFont
&font
);
109 /**************************************************************************
110 Information label about clicked tile
111 **************************************************************************/
112 class info_tile
: public QLabel
117 info_tile(struct tile
*ptile
, QWidget
*parent
= 0);
120 void paintEvent(QPaintEvent
*event
);
121 void paint(QPainter
*painter
, QPaintEvent
*event
);
123 QStringList str_list
;
125 void update_font(const QString
&name
, const QFont
&font
);
128 /**************************************************************************
129 Widget allowing resizing other widgets
130 **************************************************************************/
131 class resize_widget
: public QLabel
135 resize_widget(QWidget
* parent
);
136 void put_to_corner();
139 void mouseMoveEvent(QMouseEvent
*event
);
140 void mousePressEvent(QMouseEvent
*event
);
146 /**************************************************************************
147 Widget allowing moving other widgets
148 **************************************************************************/
149 class move_widget
: public QLabel
153 move_widget(QWidget
* parent
);
154 void put_to_corner();
157 void mouseMoveEvent(QMouseEvent
*event
);
158 void mousePressEvent(QMouseEvent
*event
);
163 /**************************************************************************
164 Abstract class for widgets wanting to do custom action
165 when closing widgets is called (eg. update menu)
166 **************************************************************************/
167 class fcwidget
: public QFrame
171 virtual void update_menu() = 0;
175 /**************************************************************************
176 Widget allowing closing other widgets
177 **************************************************************************/
178 class close_widget
: public QLabel
182 close_widget(QWidget
*parent
);
183 void put_to_corner();
185 void mousePressEvent(QMouseEvent
*event
);
186 void notify_parent();
189 /**************************************************************************
190 QLabel used for displaying overview (minimap)
191 **************************************************************************/
192 class minimap_view
: public fcwidget
196 minimap_view(QWidget
*parent
);
198 void paint(QPainter
*painter
, QPaintEvent
*event
);
199 virtual void update_menu();
204 void paintEvent(QPaintEvent
*event
);
205 void resizeEvent(QResizeEvent
*event
);
206 void mousePressEvent(QMouseEvent
*event
);
207 void mouseMoveEvent(QMouseEvent
*event
);
208 void mouseReleaseEvent(QMouseEvent
*event
);
209 void wheelEvent(QWheelEvent
*event
);
210 void moveEvent(QMoveEvent
*event
);
211 void showEvent(QShowEvent
*event
);
218 void draw_viewport(QPainter
*painter
);
219 void scale(double factor
);
220 void scale_point(int &x
, int &y
);
221 void unscale_point(int &x
, int &y
);
223 float w_ratio
, h_ratio
;
232 void mapview_freeze(void);
233 void mapview_thaw(void);
234 bool mapview_is_frozen(void);
235 void pixmap_put_overlay_tile(int canvas_x
, int canvas_y
,
236 struct sprite
*ssprite
);
238 #endif /* FC__MAPVIEW_H */