OpenTTD
textfile_gui.h
Go to the documentation of this file.
1 /*
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/>.
6  */
7 
10 #ifndef TEXTFILE_GUI_H
11 #define TEXTFILE_GUI_H
12 
13 #include "fileio_type.h"
14 #include "strings_func.h"
15 #include "textfile_type.h"
16 #include "window_gui.h"
17 
18 const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename);
19 
25  char *text;
26  std::vector<const char *> lines;
28 
29  static const int TOP_SPACING = WD_FRAMETEXT_TOP;
30  static const int BOTTOM_SPACING = WD_FRAMETEXT_BOTTOM;
31 
32  TextfileWindow(TextfileType file_type);
33  ~TextfileWindow();
34 
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;
39 
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;
45 
46  virtual void LoadTextfile(const char *textfile, Subdirectory dir);
47 
48 private:
49  uint GetContentHeight();
50  void SetupScrollbars();
51 };
52 
53 #endif /* TEXTFILE_GUI_H */
bool Monospace() override
Whether to search for a monospace font or not.
Functions related to OTTD&#39;s strings.
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:108
char * text
Lines of text from the NewGRF&#39;s textfile.
Definition: textfile_gui.h:25
Scrollbar data structure.
Definition: widget_type.h:587
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
fluid_settings_t * settings
FluidSynth settings handle.
Definition: fluidsynth.cpp:20
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Functions, definitions and such used only by the GUI.
Settings for the freetype fonts.
Definition: fontcache.h:224
Types for Standard In/Out file operations.
Data structure for an opened window.
Definition: window_gui.h:276
Bottom offset of the text of the frame.
Definition: window_gui.h:73
uint GetContentHeight()
Get the total height of the content displayed in this window, if wrapping is disabled.
FontSize DefaultSize() override
Get the default (font) size of the string.
uint search_iterator
Iterator for the font check search.
Definition: textfile_gui.h:27
const char * NextString() override
Get the next string to search through.
void SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) override
Set the right font names.
A searcher for missing glyphs.
Definition: strings_func.h:244
static const int BOTTOM_SPACING
Additional spacing at the bottom of the WID_TF_BACKGROUND widget.
Definition: textfile_gui.h:30
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
Top offset of the text of the frame.
Definition: window_gui.h:72
static const int TOP_SPACING
Additional spacing at the top of the WID_TF_BACKGROUND widget.
Definition: textfile_gui.h:29
Scrollbar * hscroll
Horizontal scrollbar.
Definition: textfile_gui.h:24
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
void SetupScrollbars()
Set scrollbars to the right lengths.
Window for displaying a textfile.
Definition: textfile_gui.h:21
void Reset() override
Reset the search, i.e.
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:22
FontSize
Available font sizes.
Definition: gfx_type.h:201
Scrollbar * vscroll
Vertical scrollbar.
Definition: textfile_gui.h:23
Coordinates of a point in 2D.
std::vector< const char * > lines
text, split into lines in a table with lines.
Definition: textfile_gui.h:26
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Specification of a rectangle with absolute coordinates of all edges.
Types related to textfiles.
Dimensions (a width and height) of a rectangle in 2D.
void OnResize() override
Called after the window got resized.