Repository navigation
Expand file tree
/
Copy pathTextList.h
More file actions
107 lines (102 loc) · 3.47 KB
/
Copy pathTextList.h
File metadata and controls
107 lines (102 loc) · 3.47 KB
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
/*
* Copyright 2010 Daniel Albano
*
* This file is part of OpenXcom.
*
* OpenXcom is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenXcom is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENXCOM_TEXTLIST_H
#define OPENXCOM_TEXTLIST_H
#include <vector>
#include "../Engine/InteractiveSurface.h"
#include "Text.h"
class Font;
class ArrowButton;
/**
* List of Text's split into columns.
* Contains a set of Text's that are automatically lined up by
* rows and columns, like a big table, making it easy to manage
* them together. Can also store related values for each row.
*/
class TextList : public InteractiveSurface
{
private:
vector< vector<Text*> > _texts;
vector<int> _columns;
vector<intptr_t> _values;
Font *_big, *_small;
unsigned int _scroll, _visibleRows;
Uint8 _color;
TextHAlign _align;
bool _dot, _selectable;
unsigned int _selRow;
Surface *_bg, *_selector;
ArrowButton *_up, *_down;
/// Updates the arrow buttons.
void updateArrows();
public:
/// Creates a text list with the specified size and position.
TextList(Font *big, Font *small, int width, int height, int x = 0, int y = 0);
/// Cleans up the text list.
~TextList();
/// Gets a certain cell in the text list.
Text* getCell(int row, int col);
/// Adds a new row to the text list.
void addRow(intptr_t value, int cols, ...);
/// Sets the columns in the text list.
void setColumns(int cols, ...);
/// Sets the palette of the text list.
void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256);
/// Sets the text color of the text list.
void setColor(Uint8 color);
/// Sets the text horizontal alignment of the text list.
void setAlign(TextHAlign align);
/// Sets whether to separate columns with dots.
void setDot(bool dot);
/// Sets whether the list is selectable.
void setSelectable(bool selectable);
/// Sets the background for the selector.
void setBackground(Surface *bg);
/// Gets the selected row in the list.
int getSelectedRow();
/// Gets a certain value in the text list.
intptr_t getValue(int row);
/// Gets the selected value in the text list.
intptr_t getSelectedValue();
/// Clears the list.
void clearList();
/// Scrolls the list up.
void scrollUp();
/// Scrolls the list down.
void scrollDown();
/// Draws the text onto the text list.
void draw();
/// Blits the text list onto another surface.
void blit(Surface *surface);
/// Thinks arrow buttons.
void think();
/// Handles arrow buttons.
void handle(SDL_Event *ev, int scale, State *state);
/// Special handling for mouse presses.
void mousePress(SDL_Event *ev, int scale, State *state);
/// Special handling for mouse releases.
void mouseRelease(SDL_Event *ev, int scale, State *state);
/// Special handling for mouse clicks.
void mouseClick(SDL_Event *ev, int scale, State *state);
/// Special handling for mouse hovering.
void mouseOver(SDL_Event *ev, int scale, State *state);
/// Special handling for mouse hovering out.
void mouseOut(SDL_Event *ev, int scale, State *state);
};
#endif