2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 /** @file textfile_gui.h GUI functions related to textfiles. */
10 #ifndef TEXTFILE_GUI_H
11 #define TEXTFILE_GUI_H
13 #include "fileio_type.h"
14 #include "strings_func.h"
15 #include "textfile_type.h"
16 #include "window_gui.h"
18 const char *GetTextfile(TextfileType type
, Subdirectory dir
, const char *filename
);
20 /** Window for displaying a textfile */
21 struct TextfileWindow
: public Window
, MissingGlyphSearcher
{
22 TextfileType file_type
; ///< Type of textfile to view.
23 Scrollbar
*vscroll
; ///< Vertical scrollbar.
24 Scrollbar
*hscroll
; ///< Horizontal scrollbar.
25 char *text
; ///< Lines of text from the NewGRF's textfile.
26 std::vector
<const char *> lines
; ///< #text, split into lines in a table with lines.
27 uint search_iterator
; ///< Iterator for the font check search.
29 static const int TOP_SPACING
= WD_FRAMETEXT_TOP
; ///< Additional spacing at the top of the #WID_TF_BACKGROUND widget.
30 static const int BOTTOM_SPACING
= WD_FRAMETEXT_BOTTOM
; ///< Additional spacing at the bottom of the #WID_TF_BACKGROUND widget.
32 TextfileWindow(TextfileType file_type
);
35 void UpdateWidgetSize(int widget
, Dimension
*size
, const Dimension
&padding
, Dimension
*fill
, Dimension
*resize
) override
;
36 void OnClick(Point pt
, int widget
, int click_count
) override
;
37 void DrawWidget(const Rect
&r
, int widget
) const override
;
38 void OnResize() override
;
40 void Reset() override
;
41 FontSize
DefaultSize() override
;
42 const char *NextString() override
;
43 bool Monospace() override
;
44 void SetFontNames(FreeTypeSettings
*settings
, const char *font_name
, const void *os_data
) override
;
46 virtual void LoadTextfile(const char *textfile
, Subdirectory dir
);
49 uint
GetContentHeight();
50 void SetupScrollbars();
53 #endif /* TEXTFILE_GUI_H */