forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui_image_list.h
107 lines (86 loc) · 2.64 KB
/
gui_image_list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* This file is part of the Simutrans project under the Artistic License.
* (see LICENSE.txt)
*/
#ifndef GUI_COMPONENTS_GUI_IMAGE_LIST_H
#define GUI_COMPONENTS_GUI_IMAGE_LIST_H
#include "gui_action_creator.h"
#include "gui_component.h"
#include "../../tpl/vector_tpl.h"
#include "../../display/simimg.h"
#include "../../simcolor.h"
#define EMPTY_IMAGE_BAR (255)
/**
* A component that represents a list of images.
*
* Updated! class is used only for the vehicle dialog. SO I changed some things
* for the new one::
* - cannot select no-image fields any more
* - numbers can be drawn ontop an images
* - color bar can be added to the images
*/
class gui_image_list_t :
public gui_action_creator_t,
public gui_component_t
{
public:
struct image_data_t {
const char *text; ///< can be NULL, used to store external data
image_id image; ///< the image
sint16 count; ///< display this number as overlay
PIXVAL lcolor; ///< color of left half of color bar, use EMPTY_IMAGE_BAR to display no bar
PIXVAL rcolor; ///< color of right half of color bar, use EMPTY_IMAGE_BAR to display no bar
image_data_t(const char *text_, image_id image_, sint16 count_=0, PIXVAL lcolor_=EMPTY_IMAGE_BAR, PIXVAL rcolor_=EMPTY_IMAGE_BAR)
: text(text_), image(image_), count(count_), lcolor(lcolor_), rcolor(rcolor_) {}
};
/**
* Graphic layout:
* size of borders around the whole area (there are no borders around
* individual images)
*/
enum {
BORDER = 4
};
private:
vector_tpl<image_data_t*> *images;
scr_coord grid;
scr_coord placement;
/**
* Rows or columns?
*/
int use_rows;
/**
* Player number to obtain player color used to display the images.
*/
sint8 player_nr;
public:
/**
* Constructor: takes pointer to vector with image_data_t
* @param images pointer to vector of pointers to image_data_t
*/
gui_image_list_t(vector_tpl<image_data_t*> *images);
/**
* This set horizontal and vertical spacing for the images.
*/
void set_grid(scr_coord grid) { this->grid = grid; }
/**
* This set the offset for the images.
*/
void set_placement(scr_coord placement) { this->placement = placement; }
void set_player_nr(sint8 player_nr) { this->player_nr = player_nr; }
bool infowin_event(event_t const*) OVERRIDE;
/**
* Draw/record the picture
*/
void draw(scr_coord offset) OVERRIDE;
/**
* Looks for the image at given position.
* xpos and ypos relative to parent window.
*/
int index_at(scr_coord parent_pos, int xpos, int ypos) const;
void recalc_size();
// FIXME
scr_size get_min_size() const OVERRIDE { return get_size(); }
scr_size get_max_size() const OVERRIDE { return get_size(); }
};
#endif