Freeciv21
Develop your civilization from humble roots to a global empire
unitselect.h
Go to the documentation of this file.
1 /**************************************************************************
2  /\ ___ /\ Copyright (c) 1996-2020 FREECIV 21 and Freeciv
3  ( o o ) contributors. This file is part of Freeciv21.
4  \ >#< / Freeciv21 is free software: you can redistribute it
5  / \ and/or modify it under the terms of the GNU
6  / \ ^ General Public License as published by the Free
7 | | // Software Foundation, either version 3 of the License,
8  \ / // or (at your option) any later version.
10  GNU General Public License along with Freeciv21.
11  If not, see https://www.gnu.org/licenses/.
12 **************************************************************************/
13 #pragma once
14 
15 #include <QMenu>
16 
17 #include <vector>
18 
19 class QPixmap;
20 class QSize;
21 class QFont;
22 
23 struct unit;
24 
25 /***************************************************************************
26  Transparent widget for selecting units
27 ***************************************************************************/
28 class units_select : public QMenu {
29  Q_OBJECT
31  QPixmap *pix;
32  QPixmap *h_pix;
33  QSize item_size;
34  std::vector<unit *> unit_list;
35  QFont ufont;
36  QFont info_font;
38 
39 public:
40  units_select(struct tile *ptile, QWidget *parent = 0);
41  ~units_select() override;
42  void update_units();
43  void create_pixmap();
45 
46 protected:
47  void paint(QPainter *painter, QPaintEvent *event);
48  void paintEvent(QPaintEvent *event) override;
49  void mousePressEvent(QMouseEvent *event) override;
50  void mouseMoveEvent(QMouseEvent *event) override;
51  void wheelEvent(QWheelEvent *event) override;
52  void closeEvent(QCloseEvent *event) override;
53 
54 private:
55  bool more;
56  int show_line;
59 };
60 
61 void toggle_unit_sel_widget(struct tile *ptile);
62 void update_unit_sel();
63 void popdown_unit_sel();
Q_DISABLE_COPY(units_select)
QPixmap * h_pix
Definition: unitselect.h:32
QFont ufont
Definition: unitselect.h:35
QFont info_font
Definition: unitselect.h:36
std::vector< unit * > unit_list
size of each pixmap of unit
Definition: unitselect.h:34
void mousePressEvent(QMouseEvent *event) override
Mouse pressed event for units_select.
Definition: unitselect.cpp:213
~units_select() override
Destructor for unit select.
Definition: unitselect.cpp:56
int highligh_num
Definition: unitselect.h:57
int column_count
Definition: unitselect.h:37
void paint(QPainter *painter, QPaintEvent *event)
Redirected paint event.
Definition: unitselect.cpp:228
QPixmap * pix
Definition: unitselect.h:31
void closeEvent(QCloseEvent *event) override
Close event for units_select, restores focus to map.
Definition: unitselect.cpp:350
void update_units()
Updates unit list on tile.
Definition: unitselect.cpp:314
tile * utile
Definition: unitselect.h:44
void wheelEvent(QWheelEvent *event) override
Mouse wheel event for units_select.
Definition: unitselect.cpp:359
int unit_count
Definition: unitselect.h:58
QSize item_size
pixmap for highlighting
Definition: unitselect.h:33
units_select(struct tile *ptile, QWidget *parent=0)
Contructor for units_select.
Definition: unitselect.cpp:36
void create_pixmap()
Create pixmap of whole widget except borders (pix)
Definition: unitselect.cpp:65
void paintEvent(QPaintEvent *event) override
Paint event, redirects to paint(...)
Definition: unitselect.cpp:301
void mouseMoveEvent(QMouseEvent *event) override
Event for mouse moving around units_select.
Definition: unitselect.cpp:186
enum event_type event
Definition: events.cpp:68
Definition: tile.h:42
Definition: unit.h:134
void toggle_unit_sel_widget(struct tile *ptile)
Shows/closes unit selection widget.
Definition: unitselect.cpp:389
void update_unit_sel()
Update unit selection widget if open.
Definition: unitselect.cpp:406
void popdown_unit_sel()
Closes unit selection widget.
Definition: unitselect.cpp:419