OpenTTD

textfile_gui.h
Go to the documentation of this file.
1 /* $Id: textfile_gui.h 25816 2013-10-06 11:29:14Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD 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, version 2.
6 * OpenTTD 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.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #ifndef TEXTFILE_GUI_H
13 #define TEXTFILE_GUI_H
14
15 #include "fileio_type.h"
16 #include "strings_func.h"
17 #include "textfile_type.h"
18 #include "window_gui.h"
19
20 const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename);
21
23 struct TextfileWindow : public Window, MissingGlyphSearcher {
24 TextfileType file_type;
25 Scrollbar *vscroll;
26 Scrollbar *hscroll;
27 char *text;
28 SmallVector<const char *, 64> lines;
29 uint search_iterator;
30
31 static const int TOP_SPACING = WD_FRAMETEXT_TOP;
32 static const int BOTTOM_SPACING = WD_FRAMETEXT_BOTTOM;
33
34 TextfileWindow(TextfileType file_type);
35 virtual ~TextfileWindow();
36 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize);
37 virtual void OnClick(Point pt, int widget, int click_count);
38 virtual void DrawWidget(const Rect &r, int widget) const;
39 virtual void OnResize();
40 virtual void Reset();
41 virtual FontSize DefaultSize();
42 virtual const char *NextString();
43 virtual bool Monospace();
44 virtual void SetFontNames(FreeTypeSettings *settings, const char *font_name);
45 virtual void LoadTextfile(const char *textfile, Subdirectory dir);
46 private:
47 uint GetContentHeight();
48 void SetupScrollbars();
49 };
50
51 #endif /* TEXTFILE_GUI_H */
strings_func.h
Functions related to OTTD&#39;s strings.
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
TextfileWindow::UpdateWidgetSize
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: textfile_gui.cpp:96
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:110
TextfileWindow::text
char * text
Lines of text from the NewGRF&#39;s textfile.
Definition: textfile_gui.h:27
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:589
TextfileWindow::Reset
virtual void Reset()
Reset the search, i.e.
Definition: textfile_gui.cpp:175
TextfileWindow::DefaultSize
virtual FontSize DefaultSize()
Get the default (font) size of the string.
Definition: textfile_gui.cpp:180
SmallVector< const char *, 64 >
window_gui.h
Functions, definitions and such used only by the GUI.
FreeTypeSettings
Settings for the freetype fonts.
Definition: fontcache.h:204
fileio_type.h
Types for Standard In/Out file operations.
Window
Data structure for an opened window.
Definition: window_gui.h:271
TextfileWindow::DrawWidget
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: textfile_gui.cpp:137
WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:75
TextfileWindow::GetContentHeight
uint GetContentHeight()
Get the total height of the content displayed in this window, if wrapping is disabled.
Definition: textfile_gui.cpp:84
TextfileWindow::search_iterator
uint search_iterator
Iterator for the font check search.
Definition: textfile_gui.h:29
TextfileWindow::Monospace
virtual bool Monospace()
Whether to search for a monospace font or not.
Definition: textfile_gui.cpp:192
MissingGlyphSearcher
A searcher for missing glyphs.
Definition: strings_func.h:246
TextfileWindow::BOTTOM_SPACING
static const int BOTTOM_SPACING
Additional spacing at the bottom of the WID_TF_BACKGROUND widget.
Definition: textfile_gui.h:32
TextfileWindow::OnClick
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: textfile_gui.cpp:126
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:318
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:16
WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:74
TextfileWindow::TOP_SPACING
static const int TOP_SPACING
Additional spacing at the top of the WID_TF_BACKGROUND widget.
Definition: textfile_gui.h:31
TextfileWindow::hscroll
Scrollbar * hscroll
Horizontal scrollbar.
Definition: textfile_gui.h:26
TextfileWindow::SetupScrollbars
void SetupScrollbars()
Set scrollbars to the right lengths.
Definition: textfile_gui.cpp:109
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:23
TextfileWindow::SetFontNames
virtual void SetFontNames(FreeTypeSettings *settings, const char *font_name)
Set the right font names.
Definition: textfile_gui.cpp:197
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:24
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:203
TextfileWindow::vscroll
Scrollbar * vscroll
Vertical scrollbar.
Definition: textfile_gui.h:25
TextfileWindow::OnResize
virtual void OnResize()
Called after the window got resized.
Definition: textfile_gui.cpp:167
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:28
GetTextfile
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Definition: textfile_gui.cpp:386
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:40
TextfileWindow::NextString
virtual const char * NextString()
Get the next string to search through.
Definition: textfile_gui.cpp:185
textfile_type.h
Types related to textfiles.
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:34
TextfileWindow::lines
SmallVector< const char *, 64 > lines
text, split into lines in a table with lines.
Definition: textfile_gui.h:28