File: gui_flowtext.h

package info (click to toggle)
simutrans 100.0%2Bds1-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,776 kB
  • ctags: 9,485
  • sloc: cpp: 72,459; ansic: 5,646; makefile: 450
file content (87 lines) | stat: -rw-r--r-- 1,737 bytes parent folder | download
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
#ifndef GUI_COMPONENTS_FLOWTEXT_H
#define GUI_COMPONENTS_FLOWTEXT_H

#include "../../ifc/gui_action_creator.h"
#include "../../tpl/slist_tpl.h"
#include "../../utils/cstring_t.h"
#include "action_listener.h"


/**
 * A component for floating text. It does not use any templates on purpose!
 * @author Hj. Malthaner
 */
class gui_flowtext_t : public gui_komponente_action_creator_t
{
	public:
		gui_flowtext_t();

		/**
		 * Sets the text to display.
		 * @author Hj. Malthaner
		 */
		void set_text(const char* text);

		const char* get_title() const;

		koord get_preferred_size();

		/**
		 * Paints the component
		 * @author Hj. Malthaner
		 */
		void zeichnen(koord offset);

		/**
		 * Events werden hiermit an die GUI-Komponenten gemeldet
		 * @author Hj. Malthaner
		 */
		void infowin_event(const event_t*);

		bool dirty;
		koord last_offset;

	private:
		koord output(koord pos, bool doit);

		enum attributes
		{
			ATT_NONE,
			ATT_NEWLINE,
			ATT_A_START,      ATT_A_END,
			ATT_H1_START,     ATT_H1_END,
			ATT_EM_START,     ATT_EM_END,
			ATT_IT_START,     ATT_IT_END,
			ATT_STRONG_START, ATT_STRONG_END,
			ATT_UNKNOWN
		};

		struct node_t
		{
			node_t(const cstring_t& text_, attributes att_) : text(text_), att(att_), next(0) {}

			cstring_t  text;
			attributes att;
			node_t*    next;
		};

		/**
		 * Hyperlink position container
		 * @author Hj. Malthaner
		 */
		struct hyperlink_t
		{
			hyperlink_t(const cstring_t& param_) : param(param_), next(0) {}

			koord        tl;    // top left display position
			koord        br;    // bottom right display position
			cstring_t    param;
			hyperlink_t* next;
		};

		slist_tpl<node_t>      nodes;
		slist_tpl<hyperlink_t> links;
		char title[128];
};

#endif