OpenTTD Source  1.11.0-beta2
textfile_gui.cpp
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 #include "stdafx.h"
11 #include "fileio_func.h"
12 #include "fontcache.h"
13 #include "gfx_type.h"
14 #include "gfx_func.h"
15 #include "string_func.h"
16 #include "textfile_gui.h"
17 
18 #include "widgets/misc_widget.h"
19 
20 #include "table/strings.h"
21 
22 #if defined(WITH_ZLIB)
23 #include <zlib.h>
24 #endif
25 
26 #if defined(WITH_LIBLZMA)
27 #include <lzma.h>
28 #endif
29 
30 #include "safeguards.h"
31 
35  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
36  NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_TF_CAPTION), SetDataTip(STR_NULL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
37  NWidget(WWT_TEXTBTN, COLOUR_MAUVE, WID_TF_WRAPTEXT), SetDataTip(STR_TEXTFILE_WRAP_TEXT, STR_TEXTFILE_WRAP_TEXT_TOOLTIP),
38  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
39  EndContainer(),
42  EndContainer(),
45  EndContainer(),
46  EndContainer(),
49  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
50  EndContainer(),
51 };
52 
55  WDP_CENTER, "textfile", 630, 460,
57  0,
59 );
60 
61 TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc), file_type(file_type)
62 {
63  this->CreateNestedTree();
64  this->vscroll = this->GetScrollbar(WID_TF_VSCROLLBAR);
65  this->hscroll = this->GetScrollbar(WID_TF_HSCROLLBAR);
66  this->FinishInitNested(file_type);
67  this->GetWidget<NWidgetCore>(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
68 
69  this->hscroll->SetStepSize(10); // Speed up horizontal scrollbar
70  this->vscroll->SetStepSize(FONT_HEIGHT_MONO);
71 }
72 
73 /* virtual */ TextfileWindow::~TextfileWindow()
74 {
75  free(this->text);
76 }
77 
83 {
84  int max_width = this->GetWidget<NWidgetCore>(WID_TF_BACKGROUND)->current_x - WD_FRAMETEXT_LEFT - WD_FRAMERECT_RIGHT;
85 
86  uint height = 0;
87  for (uint i = 0; i < this->lines.size(); i++) {
88  height += GetStringHeight(this->lines[i], max_width, FS_MONO);
89  }
90 
91  return height;
92 }
93 
94 /* virtual */ void TextfileWindow::UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
95 {
96  switch (widget) {
97  case WID_TF_BACKGROUND:
98  resize->height = 1;
99 
100  size->height = 4 * resize->height + TOP_SPACING + BOTTOM_SPACING; // At least 4 lines are visible.
101  size->width = std::max(200u, size->width); // At least 200 pixels wide.
102  break;
103  }
104 }
105 
108 {
110  this->vscroll->SetCount(this->GetContentHeight());
111  this->hscroll->SetCount(0);
112  } else {
113  uint max_length = 0;
114  for (uint i = 0; i < this->lines.size(); i++) {
115  max_length = std::max(max_length, GetStringBoundingBox(this->lines[i], FS_MONO).width);
116  }
117  this->vscroll->SetCount((uint)this->lines.size() * FONT_HEIGHT_MONO);
118  this->hscroll->SetCount(max_length + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
119  }
120 
122 }
123 
124 /* virtual */ void TextfileWindow::OnClick(Point pt, int widget, int click_count)
125 {
126  switch (widget) {
127  case WID_TF_WRAPTEXT:
129  this->SetupScrollbars();
130  this->InvalidateData();
131  break;
132  }
133 }
134 
135 /* virtual */ void TextfileWindow::DrawWidget(const Rect &r, int widget) const
136 {
137  if (widget != WID_TF_BACKGROUND) return;
138 
139  const int x = r.left + WD_FRAMETEXT_LEFT;
140  const int y = r.top + WD_FRAMETEXT_TOP;
141  const int right = r.right - WD_FRAMETEXT_RIGHT;
142  const int bottom = r.bottom - WD_FRAMETEXT_BOTTOM;
143 
144  DrawPixelInfo new_dpi;
145  if (!FillDrawPixelInfo(&new_dpi, x, y, right - x + 1, bottom - y + 1)) return;
146  DrawPixelInfo *old_dpi = _cur_dpi;
147  _cur_dpi = &new_dpi;
148 
149  /* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
150  int line_height = FONT_HEIGHT_MONO;
151  int y_offset = -this->vscroll->GetPosition();
152 
153  for (uint i = 0; i < this->lines.size(); i++) {
155  y_offset = DrawStringMultiLine(0, right - x, y_offset, bottom - y, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
156  } else {
157  DrawString(-this->hscroll->GetPosition(), right - x, y_offset, this->lines[i], TC_WHITE, SA_TOP | SA_LEFT, false, FS_MONO);
158  y_offset += line_height; // margin to previous element
159  }
160  }
161 
162  _cur_dpi = old_dpi;
163 }
164 
165 /* virtual */ void TextfileWindow::OnResize()
166 {
169 
170  this->SetupScrollbars();
171 }
172 
173 /* virtual */ void TextfileWindow::Reset()
174 {
175  this->search_iterator = 0;
176 }
177 
179 {
180  return FS_MONO;
181 }
182 
183 /* virtual */ const char *TextfileWindow::NextString()
184 {
185  if (this->search_iterator >= this->lines.size()) return nullptr;
186 
187  return this->lines[this->search_iterator++];
188 }
189 
190 /* virtual */ bool TextfileWindow::Monospace()
191 {
192  return true;
193 }
194 
195 /* virtual */ void TextfileWindow::SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data)
196 {
197 #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
198  strecpy(settings->mono.font, font_name, lastof(settings->mono.font));
199  settings->mono.os_handle = os_data;
200 #endif
201 }
202 
203 #if defined(WITH_ZLIB)
204 
219 static void Gunzip(byte **bufp, size_t *sizep)
220 {
221  static const int BLOCKSIZE = 8192;
222  byte *buf = nullptr;
223  size_t alloc_size = 0;
224  z_stream z;
225  int res;
226 
227  memset(&z, 0, sizeof(z));
228  z.next_in = *bufp;
229  z.avail_in = (uInt)*sizep;
230 
231  /* window size = 15, add 32 to enable gzip or zlib header processing */
232  res = inflateInit2(&z, 15 + 32);
233  /* Z_BUF_ERROR just means we need more space */
234  while (res == Z_OK || (res == Z_BUF_ERROR && z.avail_out == 0)) {
235  /* When we get here, we're either just starting, or
236  * inflate is out of output space - allocate more */
237  alloc_size += BLOCKSIZE;
238  z.avail_out += BLOCKSIZE;
239  buf = ReallocT(buf, alloc_size);
240  z.next_out = buf + alloc_size - z.avail_out;
241  res = inflate(&z, Z_FINISH);
242  }
243 
244  free(*bufp);
245  inflateEnd(&z);
246 
247  if (res == Z_STREAM_END) {
248  *bufp = buf;
249  *sizep = alloc_size - z.avail_out;
250  } else {
251  /* Something went wrong */
252  *bufp = nullptr;
253  *sizep = 0;
254  free(buf);
255  }
256 }
257 #endif
258 
259 #if defined(WITH_LIBLZMA)
260 
275 static void Xunzip(byte **bufp, size_t *sizep)
276 {
277  static const int BLOCKSIZE = 8192;
278  byte *buf = nullptr;
279  size_t alloc_size = 0;
280  lzma_stream z = LZMA_STREAM_INIT;
281  int res;
282 
283  z.next_in = *bufp;
284  z.avail_in = *sizep;
285 
286  res = lzma_auto_decoder(&z, UINT64_MAX, LZMA_CONCATENATED);
287  /* Z_BUF_ERROR just means we need more space */
288  while (res == LZMA_OK || (res == LZMA_BUF_ERROR && z.avail_out == 0)) {
289  /* When we get here, we're either just starting, or
290  * inflate is out of output space - allocate more */
291  alloc_size += BLOCKSIZE;
292  z.avail_out += BLOCKSIZE;
293  buf = ReallocT(buf, alloc_size);
294  z.next_out = buf + alloc_size - z.avail_out;
295  res = lzma_code(&z, LZMA_FINISH);
296  }
297 
298  free(*bufp);
299  lzma_end(&z);
300 
301  if (res == LZMA_STREAM_END) {
302  *bufp = buf;
303  *sizep = alloc_size - z.avail_out;
304  } else {
305  /* Something went wrong */
306  *bufp = nullptr;
307  *sizep = 0;
308  free(buf);
309  }
310 }
311 #endif
312 
313 
317 /* virtual */ void TextfileWindow::LoadTextfile(const char *textfile, Subdirectory dir)
318 {
319  if (textfile == nullptr) return;
320 
321  this->lines.clear();
322 
323  /* Get text from file */
324  size_t filesize;
325  FILE *handle = FioFOpenFile(textfile, "rb", dir, &filesize);
326  if (handle == nullptr) return;
327 
328  this->text = ReallocT(this->text, filesize);
329  size_t read = fread(this->text, 1, filesize, handle);
330  fclose(handle);
331 
332  if (read != filesize) return;
333 
334 #if defined(WITH_ZLIB) || defined(WITH_LIBLZMA)
335  const char *suffix = strrchr(textfile, '.');
336  if (suffix == nullptr) return;
337 #endif
338 
339 #if defined(WITH_ZLIB)
340  /* In-place gunzip */
341  if (strcmp(suffix, ".gz") == 0) Gunzip((byte**)&this->text, &filesize);
342 #endif
343 
344 #if defined(WITH_LIBLZMA)
345  /* In-place xunzip */
346  if (strcmp(suffix, ".xz") == 0) Xunzip((byte**)&this->text, &filesize);
347 #endif
348 
349  if (!this->text) return;
350 
351  /* Add space for trailing \0 */
352  this->text = ReallocT(this->text, filesize + 1);
353  this->text[filesize] = '\0';
354 
355  /* Replace tabs and line feeds with a space since str_validate removes those. */
356  for (char *p = this->text; *p != '\0'; p++) {
357  if (*p == '\t' || *p == '\r') *p = ' ';
358  }
359 
360  /* Check for the byte-order-mark, and skip it if needed. */
361  char *p = this->text + (strncmp(u8"\ufeff", this->text, 3) == 0 ? 3 : 0);
362 
363  /* Make sure the string is a valid UTF-8 sequence. */
365 
366  /* Split the string on newlines. */
367  this->lines.push_back(p);
368  for (; *p != '\0'; p++) {
369  if (*p == '\n') {
370  *p = '\0';
371  this->lines.push_back(p + 1);
372  }
373  }
374 
375  CheckForMissingGlyphs(true, this);
376 }
377 
385 const char *GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
386 {
387  static const char * const prefixes[] = {
388  "readme",
389  "changelog",
390  "license",
391  };
392  static_assert(lengthof(prefixes) == TFT_END);
393 
394  const char *prefix = prefixes[type];
395 
396  if (filename == nullptr) return nullptr;
397 
398  static char file_path[MAX_PATH];
399  strecpy(file_path, filename, lastof(file_path));
400 
401  char *slash = strrchr(file_path, PATHSEPCHAR);
402  if (slash == nullptr) return nullptr;
403 
404  static const char * const exts[] = {
405  "txt",
406 #if defined(WITH_ZLIB)
407  "txt.gz",
408 #endif
409 #if defined(WITH_LIBLZMA)
410  "txt.xz",
411 #endif
412  };
413 
414  for (size_t i = 0; i < lengthof(exts); i++) {
415  seprintf(slash + 1, lastof(file_path), "%s_%s.%s", prefix, GetCurrentLanguageIsoCode(), exts[i]);
416  if (FioCheckFileExists(file_path, dir)) return file_path;
417 
418  seprintf(slash + 1, lastof(file_path), "%s_%.2s.%s", prefix, GetCurrentLanguageIsoCode(), exts[i]);
419  if (FioCheckFileExists(file_path, dir)) return file_path;
420 
421  seprintf(slash + 1, lastof(file_path), "%s.%s", prefix, exts[i]);
422  if (FioCheckFileExists(file_path, dir)) return file_path;
423  }
424  return nullptr;
425 }
TextfileWindow::DefaultSize
FontSize DefaultSize() override
Get the default (font) size of the string.
Definition: textfile_gui.cpp:178
WID_TF_HSCROLLBAR
@ WID_TF_HSCROLLBAR
Horizontal scrollbar to scroll through the textfile left-to-right.
Definition: misc_widget.h:55
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:317
SVS_ALLOW_NEWLINE
@ SVS_ALLOW_NEWLINE
Allow newlines.
Definition: string_type.h:51
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
GetCurrentLanguageIsoCode
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition: strings.cpp:1994
TextfileWindow::UpdateWidgetSize
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.
Definition: textfile_gui.cpp:94
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
str_validate
void str_validate(char *str, const char *last, StringValidationSettings settings)
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mar...
Definition: string.cpp:237
Xunzip
static void Xunzip(byte **bufp, size_t *sizep)
Do an in-memory xunzip operation.
Definition: textfile_gui.cpp:275
NWID_HSCROLLBAR
@ NWID_HSCROLLBAR
Horizontal scrollbar.
Definition: widget_type.h:81
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
Gunzip
static void Gunzip(byte **bufp, size_t *sizep)
Do an in-memory gunzip operation.
Definition: textfile_gui.cpp:219
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
TextfileWindow::SetupScrollbars
void SetupScrollbars()
Set scrollbars to the right lengths.
Definition: textfile_gui.cpp:107
SA_LEFT
@ SA_LEFT
Left align the text.
Definition: gfx_func.h:96
TextfileWindow::lines
std::vector< const char * > lines
text, split into lines in a table with lines.
Definition: textfile_gui.h:26
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
TextfileWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: textfile_gui.cpp:165
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:669
TextfileWindow::BOTTOM_SPACING
static const int BOTTOM_SPACING
Additional spacing at the bottom of the WID_TF_BACKGROUND widget.
Definition: textfile_gui.h:30
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
fileio_func.h
WD_FRAMETEXT_TOP
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:72
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:640
_nested_textfile_widgets
static const NWidgetPart _nested_textfile_widgets[]
Widgets for the textfile window.
Definition: textfile_gui.cpp:33
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:70
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
textfile_gui.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:763
WID_TF_BACKGROUND
@ WID_TF_BACKGROUND
Panel to draw the textfile on.
Definition: misc_widget.h:53
gfx_func.h
WindowDesc
High level window description.
Definition: window_gui.h:166
SA_TOP
@ SA_TOP
Top align the text.
Definition: gfx_func.h:101
TextfileWindow::SetFontNames
void SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) override
Set the right font names.
Definition: textfile_gui.cpp:195
WID_TF_WRAPTEXT
@ WID_TF_WRAPTEXT
Whether or not to wrap the text.
Definition: misc_widget.h:52
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
TextfileWindow::TOP_SPACING
static const int TOP_SPACING
Additional spacing at the top of the WID_TF_BACKGROUND widget.
Definition: textfile_gui.h:29
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:320
FioFOpenFile
FILE * FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize)
Opens a OpenTTD file somewhere in a personal or global directory.
Definition: fileio.cpp:406
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
WD_FRAMETEXT_BOTTOM
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:73
FONT_HEIGHT_MONO
#define FONT_HEIGHT_MONO
Height of characters in the large (FS_MONO) font.
Definition: gfx_func.h:185
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
safeguards.h
TextfileWindow::NextString
const char * NextString() override
Get the next string to search through.
Definition: textfile_gui.cpp:183
settings
fluid_settings_t * settings
FluidSynth settings handle.
Definition: fluidsynth.cpp:21
TextfileWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: textfile_gui.cpp:124
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:71
stdafx.h
TextfileWindow::text
char * text
Lines of text from the NewGRF's textfile.
Definition: textfile_gui.h:25
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3261
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition: gfx.cpp:1638
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:689
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
string_func.h
TextfileWindow::hscroll
Scrollbar * hscroll
Horizontal scrollbar.
Definition: textfile_gui.h:24
TextfileWindow::Reset
void Reset() override
Reset the search, i.e.
Definition: textfile_gui.cpp:173
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
TextfileWindow::search_iterator
uint search_iterator
Iterator for the font check search.
Definition: textfile_gui.h:27
GetTextfile
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Definition: textfile_gui.cpp:385
FioCheckFileExists
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
Definition: fileio.cpp:266
WID_TF_VSCROLLBAR
@ WID_TF_VSCROLLBAR
Vertical scrollbar to scroll through the textfile up-and-down.
Definition: misc_widget.h:54
TextfileWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: textfile_gui.cpp:135
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:493
TextfileWindow::Monospace
bool Monospace() override
Whether to search for a monospace font or not.
Definition: textfile_gui.cpp:190
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:630
seprintf
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
Definition: string.cpp:442
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:108
ReallocT
static T * ReallocT(T *t_ptr, size_t num_elements)
Simplified reallocation function that allocates the specified number of elements of the given type.
Definition: alloc_func.hpp:111
CheckForMissingGlyphs
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
Definition: strings.cpp:2101
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:463
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:1980
FS_MONO
@ FS_MONO
Index of the monospaced font in the font tables.
Definition: gfx_type.h:210
fontcache.h
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:206
Window
Data structure for an opened window.
Definition: window_gui.h:276
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
TextfileWindow::GetContentHeight
uint GetContentHeight()
Get the total height of the content displayed in this window, if wrapping is disabled.
Definition: textfile_gui.cpp:82
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:454
gfx_type.h
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:180
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:383
SVS_REPLACE_WITH_QUESTION_MARK
@ SVS_REPLACE_WITH_QUESTION_MARK
Replace the unknown/bad bits with question marks.
Definition: string_type.h:50
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:155
misc_widget.h
_textfile_desc
static WindowDesc _textfile_desc(WDP_CENTER, "textfile", 630, 460, WC_TEXTFILE, WC_NONE, 0, _nested_textfile_widgets, lengthof(_nested_textfile_widgets))
Window definition for the textfile window.
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
FreeTypeSettings
Settings for the freetype fonts.
Definition: fontcache.h:225
TextfileWindow::vscroll
Scrollbar * vscroll
Vertical scrollbar.
Definition: textfile_gui.h:23
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:155