The Battle for Wesnoth  1.13.11+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
help_text_area.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "help/help_text_area.hpp"
16 
17 #include "config.hpp" // for config, etc
18 #include "game_config.hpp" // for debug
19 #include "help/help_impl.hpp" // for parse_error, box_width, etc
20 #include "image.hpp" // for get_image
21 #include "log.hpp" // for LOG_STREAM, log_domain, etc
22 #include "preferences/general.hpp" // for font_scaled
23 #include "sdl/rect.hpp" // for draw_rectangle, etc
24 #include "serialization/parser.hpp" // for read, write
25 #include "video.hpp" // for CVideo
26 
27 #include <algorithm> // for max, min, find_if
28 #include <ostream> // for operator<<, stringstream, etc
29 #include <vector> // for vector, etc
30 
31 static lg::log_domain log_display("display");
32 #define WRN_DP LOG_STREAM(warn, log_display)
33 
34 namespace help {
35 
36 help_text_area::help_text_area(CVideo &video, const section &toplevel) :
37  gui::scrollarea(video),
38  items_(),
39  last_row_(),
40  toplevel_(toplevel),
41  shown_topic_(nullptr),
42  title_spacing_(16),
43  curr_loc_(0, 0),
44  min_row_height_(font::get_max_height(normal_font_size)),
45  curr_row_height_(min_row_height_),
46  contents_height_(0)
47 {
48  set_scroll_rate(40);
49 }
50 
51 void help_text_area::set_inner_location(const SDL_Rect& rect)
52 {
53  bg_register(rect);
54  if (shown_topic_)
55  set_items();
56 }
57 
59 {
60  shown_topic_ = &t;
61  set_items();
62  set_dirty(true);
63 }
64 
65 
67  const std::string& reference_to, bool _floating,
68  bool _box, ALIGNMENT alignment) :
69  rect(),
70  surf(surface),
71  text(_text),
72  ref_to(reference_to),
73  floating(_floating), box(_box),
74  align(alignment)
75 {
76  rect.x = x;
77  rect.y = y;
78  rect.w = box ? surface->w + box_width * 2 : surface->w;
79  rect.h = box ? surface->h + box_width * 2 : surface->h;
80 }
81 
82 help_text_area::item::item(surface surface, int x, int y, bool _floating,
83  bool _box, ALIGNMENT alignment) :
84  rect(),
85  surf(surface),
86  text(""),
87  ref_to(""),
88  floating(_floating),
89  box(_box), align(alignment)
90 {
91  rect.x = x;
92  rect.y = y;
93  rect.w = box ? surface->w + box_width * 2 : surface->w;
94  rect.h = box ? surface->h + box_width * 2 : surface->h;
95 }
96 
98 {
99  last_row_.clear();
100  items_.clear();
101  curr_loc_.first = 0;
102  curr_loc_.second = 0;
104  // Add the title item.
105  const std::string show_title =
107  surface surf(font::get_rendered_text(show_title, title_size,
108  font::NORMAL_COLOR, TTF_STYLE_BOLD));
109  if (surf != nullptr) {
110  add_item(item(surf, 0, 0, show_title));
111  curr_loc_.second = title_spacing_;
113  down_one_line();
114  }
115  // Parse and add the text.
116  const std::vector<std::string>& parsed_items = shown_topic_->text.parsed_text();
117  std::vector<std::string>::const_iterator it;
118  for (it = parsed_items.begin(); it != parsed_items.end(); ++it) {
119  if (!(*it).empty() && (*it)[0] == '[') {
120  // Should be parsed as WML.
121  try {
122  config cfg;
123  std::istringstream stream(*it);
124  read(cfg, stream);
125 
126 #define TRY(name) do { \
127  if (config &child = cfg.child(#name)) \
128  handle_##name##_cfg(child); \
129  } while (0)
130 
131  TRY(ref);
132  TRY(img);
133  TRY(bold);
134  TRY(italic);
135  TRY(header);
136  TRY(jump);
137  TRY(format);
138 
139 #undef TRY
140 
141  }
142  catch (config::error& e) {
143  std::stringstream msg;
144  msg << "Error when parsing help markup as WML: '" << e.message << "'";
145  throw parse_error(msg.str());
146  }
147  }
148  else {
149  add_text_item(*it);
150  }
151  }
152  down_one_line(); // End the last line.
153  int h = height();
154  set_position(0);
156  set_shown_size(h);
157 }
158 
160 {
161  const std::string dst = cfg["dst"];
162  const std::string text = cfg["text"];
163  bool force = cfg["force"].to_bool();
164 
165  if (dst.empty()) {
166  std::stringstream msg;
167  msg << "Ref markup must have dst attribute. Please submit a bug"
168  " report if you have not modified the game files yourself. Erroneous config: ";
169  write(msg, cfg);
170  throw parse_error(msg.str());
171  }
172 
173  if (find_topic(toplevel_, dst) == nullptr && !force) {
174  // detect the broken link but quietly silence the hyperlink for normal user
175  add_text_item(text, game_config::debug ? dst : "", true);
176 
177  // FIXME: workaround: if different campaigns define different
178  // terrains, some terrains available in one campaign will
179  // appear in the list of seen terrains, and be displayed in the
180  // help, even if the current campaign does not handle such
181  // terrains. This will lead to the unit page generator creating
182  // invalid references.
183  //
184  // Disabling this is a kludgey workaround until the
185  // encountered_terrains system is fixed
186  //
187  // -- Ayin apr 8 2005
188 #if 0
189  if (game_config::debug) {
190  std::stringstream msg;
191  msg << "Reference to non-existent topic '" << dst
192  << "'. Please submit a bug report if you have not"
193  "modified the game files yourself. Erroneous config: ";
194  write(msg, cfg);
195  throw parse_error(msg.str());
196  }
197 #endif
198  } else {
199  add_text_item(text, dst);
200  }
201 }
202 
204 {
205  const std::string src = cfg["src"];
206  const std::string align = cfg["align"];
207  bool floating = cfg["float"].to_bool();
208  bool box = cfg["box"].to_bool(true);
209  if (src.empty()) {
210  throw parse_error("Img markup must have src attribute.");
211  }
212  add_img_item(src, align, floating, box);
213 }
214 
216 {
217  const std::string text = cfg["text"];
218  if (text.empty()) {
219  throw parse_error("Bold markup must have text attribute.");
220  }
221  add_text_item(text, "", false, -1, true);
222 }
223 
225 {
226  const std::string text = cfg["text"];
227  if (text.empty()) {
228  throw parse_error("Italic markup must have text attribute.");
229  }
230  add_text_item(text, "", false, -1, false, true);
231 }
232 
234 {
235  const std::string text = cfg["text"];
236  if (text.empty()) {
237  throw parse_error("Header markup must have text attribute.");
238  }
239  add_text_item(text, "", false, title2_size, true);
240 }
241 
243 {
244  const std::string amount_str = cfg["amount"];
245  const std::string to_str = cfg["to"];
246  if (amount_str.empty() && to_str.empty()) {
247  throw parse_error("Jump markup must have either a to or an amount attribute.");
248  }
249  unsigned jump_to = curr_loc_.first;
250  if (!amount_str.empty()) {
251  unsigned amount;
252  try {
253  amount = lexical_cast<unsigned, std::string>(amount_str);
254  }
255  catch (bad_lexical_cast&) {
256  throw parse_error("Invalid amount the amount attribute in jump markup.");
257  }
258  jump_to += amount;
259  }
260  if (!to_str.empty()) {
261  unsigned to;
262  try {
263  to = lexical_cast<unsigned, std::string>(to_str);
264  }
265  catch (bad_lexical_cast&) {
266  throw parse_error("Invalid amount in the to attribute in jump markup.");
267  }
268  if (to < jump_to) {
269  down_one_line();
270  }
271  jump_to = to;
272  }
273  if (jump_to != 0 && static_cast<int>(jump_to) <
275 
276  curr_loc_.first = jump_to;
277  }
278 }
279 
281 {
282  const std::string text = cfg["text"];
283  if (text.empty()) {
284  throw parse_error("Format markup must have text attribute.");
285  }
286  bool bold = cfg["bold"].to_bool();
287  bool italic = cfg["italic"].to_bool();
288  int font_size = cfg["font_size"].to_int(normal_font_size);
289  color_t color = help::string_to_color(cfg["color"]);
290  add_text_item(text, "", false, font_size, bold, italic, color);
291 }
292 
293 void help_text_area::add_text_item(const std::string& text, const std::string& ref_dst,
294  bool broken_link, int _font_size, bool bold, bool italic,
295  color_t text_color
296 )
297 {
298  const int font_size = _font_size < 0 ? normal_font_size : _font_size;
299  // font::line_width(), font::get_rendered_text() are not use scaled font inside
300  const int scaled_font_size = preferences::font_scaled(font_size);
301  if (text.empty())
302  return;
303  const int remaining_width = get_remaining_width();
304  size_t first_word_start = text.find_first_not_of(" ");
305  if (first_word_start == std::string::npos) {
306  first_word_start = 0;
307  }
308  if (text[first_word_start] == '\n') {
309  down_one_line();
310  std::string rest_text = text;
311  rest_text.erase(0, first_word_start + 1);
312  add_text_item(rest_text, ref_dst, broken_link, _font_size, bold, italic, text_color);
313  return;
314  }
315  const std::string first_word = get_first_word(text);
316  int state = 0;
317  state |= bold ? TTF_STYLE_BOLD : 0;
318  state |= italic ? TTF_STYLE_ITALIC : 0;
319  if (curr_loc_.first != get_min_x(curr_loc_.second, curr_row_height_)
320  && remaining_width < font::line_width(first_word, scaled_font_size, state)) {
321  // The first word does not fit, and we are not at the start of
322  // the line. Move down.
323  down_one_line();
325  add_text_item(s, ref_dst, broken_link, _font_size, bold, italic, text_color);
326  }
327  else {
328  std::vector<std::string> parts = split_in_width(text, font_size, remaining_width);
329  std::string first_part = parts.front();
330  // Always override the color if we have a cross reference.
331  color_t color;
332  if(ref_dst.empty())
333  color = text_color;
334  else if(broken_link)
335  color = font::BAD_COLOR;
336  else
337  color = font::YELLOW_COLOR;
338 
339  // In split_in_width(), no_break_after() and no_break_before() are used(see marked-up_text.cpp).
340  // Thus, even if there is enough remaining_width for the next word,
341  // sometimes empty string is returned from split_in_width().
342  if (first_part.empty()) {
343  down_one_line();
344  }
345  else {
346  surface surf(font::get_rendered_text(first_part, scaled_font_size, color, state));
347  if (!surf.null())
348  add_item(item(surf, curr_loc_.first, curr_loc_.second, first_part, ref_dst));
349  }
350  if (parts.size() > 1) {
351 
352  std::string& s = parts.back();
353 
354  const std::string first_word_before = get_first_word(s);
355  const std::string first_word_after = get_first_word(remove_first_space(s));
356  if (get_remaining_width() >= font::line_width(first_word_after, scaled_font_size, state)
358  < font::line_width(first_word_before, scaled_font_size, state)) {
359  // If the removal of the space made this word fit, we
360  // must move down a line, otherwise it will be drawn
361  // without a space at the end of the line.
362  s = remove_first_space(s);
363  down_one_line();
364  }
365  else if (!(font::line_width(first_word_before, scaled_font_size, state)
366  < get_remaining_width())) {
367  s = remove_first_space(s);
368  }
369  add_text_item(s, ref_dst, broken_link, _font_size, bold, italic, text_color);
370 
371  }
372  }
373 }
374 
376  const bool floating, const bool box)
377 {
378  surface surf(image::get_image(path));
379  if (surf.null())
380  return;
381  ALIGNMENT align = str_to_align(alignment);
382  if (align == HERE && floating) {
383  WRN_DP << "Floating image with align HERE, aligning left." << std::endl;
384  align = LEFT;
385  }
386  const int width = surf->w + (box ? box_width * 2 : 0);
387  int xpos;
388  int ypos = curr_loc_.second;
389  int text_width = inner_location().w;
390  switch (align) {
391  case HERE:
392  xpos = curr_loc_.first;
393  break;
394  case LEFT:
395  default:
396  xpos = 0;
397  break;
398  case MIDDLE:
399  xpos = text_width / 2 - width / 2 - (box ? box_width : 0);
400  break;
401  case RIGHT:
402  xpos = text_width - width - (box ? box_width * 2 : 0);
403  break;
404  }
405  if (curr_loc_.first != get_min_x(curr_loc_.second, curr_row_height_)
406  && (xpos < curr_loc_.first || xpos + width > text_width)) {
407  down_one_line();
408  add_img_item(path, alignment, floating, box);
409  }
410  else {
411  if (!floating) {
412  curr_loc_.first = xpos;
413  }
414  else {
415  ypos = get_y_for_floating_img(width, xpos, ypos);
416  }
417  add_item(item(surf, xpos, ypos, floating, box, align));
418  }
419 }
420 
421 int help_text_area::get_y_for_floating_img(const int width, const int x, const int desired_y)
422 {
423  int min_y = desired_y;
424  for (std::list<item>::const_iterator it = items_.begin(); it != items_.end(); ++it) {
425  const item& itm = *it;
426  if (itm.floating) {
427  if ((itm.rect.x + itm.rect.w > x && itm.rect.x < x + width)
428  || (itm.rect.x > x && itm.rect.x < x + width)) {
429  min_y = std::max<int>(min_y, itm.rect.y + itm.rect.h);
430  }
431  }
432  }
433  return min_y;
434 }
435 
436 int help_text_area::get_min_x(const int y, const int height)
437 {
438  int min_x = 0;
439  for (std::list<item>::const_iterator it = items_.begin(); it != items_.end(); ++it) {
440  const item& itm = *it;
441  if (itm.floating) {
442  if (itm.rect.y < y + height && itm.rect.y + itm.rect.h > y && itm.align == LEFT) {
443  min_x = std::max<int>(min_x, itm.rect.w + 5);
444  }
445  }
446  }
447  return min_x;
448 }
449 
450 int help_text_area::get_max_x(const int y, const int height)
451 {
452  int text_width = inner_location().w;
453  int max_x = text_width;
454  for (std::list<item>::const_iterator it = items_.begin(); it != items_.end(); ++it) {
455  const item& itm = *it;
456  if (itm.floating) {
457  if (itm.rect.y < y + height && itm.rect.y + itm.rect.h > y) {
458  if (itm.align == RIGHT) {
459  max_x = std::min<int>(max_x, text_width - itm.rect.w - 5);
460  } else if (itm.align == MIDDLE) {
461  max_x = std::min<int>(max_x, text_width / 2 - itm.rect.w / 2 - 5);
462  }
463  }
464  }
465  }
466  return max_x;
467 }
468 
470 {
471  items_.push_back(itm);
472  if (!itm.floating) {
473  curr_loc_.first += itm.rect.w;
474  curr_row_height_ = std::max<int>(itm.rect.h, curr_row_height_);
475  contents_height_ = std::max<int>(contents_height_, curr_loc_.second + curr_row_height_);
476  last_row_.push_back(&items_.back());
477  }
478  else {
479  if (itm.align == LEFT) {
480  curr_loc_.first = itm.rect.w + 5;
481  }
482  contents_height_ = std::max<int>(contents_height_, itm.rect.y + itm.rect.h);
483  }
484 }
485 
486 
488 {
489  if (cmp_str == "left") {
490  return LEFT;
491  } else if (cmp_str == "middle") {
492  return MIDDLE;
493  } else if (cmp_str == "right") {
494  return RIGHT;
495  } else if (cmp_str == "here" || cmp_str.empty()) { // Make the empty string be "here" alignment.
496  return HERE;
497  }
498  std::stringstream msg;
499  msg << "Invalid alignment string: '" << cmp_str << "'";
500  throw parse_error(msg.str());
501 }
502 
504 {
505  adjust_last_row();
506  last_row_.clear();
508  curr_row_height_ = min_row_height_;
509  contents_height_ = std::max<int>(curr_loc_.second + curr_row_height_, contents_height_);
510  curr_loc_.first = get_min_x(curr_loc_.second, curr_row_height_);
511 }
512 
514 {
515  for (std::list<item *>::iterator it = last_row_.begin(); it != last_row_.end(); ++it) {
516  item &itm = *(*it);
517  const int gap = curr_row_height_ - itm.rect.h;
518  itm.rect.y += gap / 2;
519  }
520 }
521 
523 {
524  const int total_w = get_max_x(curr_loc_.second, curr_row_height_);
525  return total_w - curr_loc_.first;
526 }
527 
529 {
530  const SDL_Rect& loc = inner_location();
531  bg_restore();
532  surface& screen = video().getSurface();
533  clip_rect_setter clip_rect_set(screen, &loc);
534  for(std::list<item>::const_iterator it = items_.begin(), end = items_.end(); it != end; ++it) {
535  SDL_Rect dst = it->rect;
536  dst.y -= get_position();
537  if (dst.y < static_cast<int>(loc.h) && dst.y + it->rect.h > 0) {
538  dst.x += loc.x;
539  dst.y += loc.y;
540  if (it->box) {
541  for (int i = 0; i < box_width; ++i) {
542  SDL_Rect draw_rect {
543  dst.x,
544  dst.y,
545  it->rect.w - i * 2,
546  it->rect.h - i * 2
547  };
548 
549  sdl::draw_rectangle(draw_rect, {0, 0, 0, 0});
550  ++dst.x;
551  ++dst.y;
552  }
553  }
554  sdl_blit(it->surf, nullptr, screen, &dst);
555  }
556  }
557 }
558 
559 void help_text_area::scroll(unsigned int)
560 {
561  // Nothing will be done on the actual scroll event. The scroll
562  // position is checked when drawing instead and things drawn
563  // accordingly.
564  set_dirty(true);
565 }
566 
568  return sdl::point_in_rect(x_, y_, item.rect);
569 }
570 
571 std::string help_text_area::ref_at(const int x, const int y)
572 {
573  const int local_x = x - location().x;
574  const int local_y = y - location().y;
575  if (local_y < height() && local_y > 0) {
576  const int cmp_y = local_y + get_position();
577  const std::list<item>::const_iterator it =
578  std::find_if(items_.begin(), items_.end(), item_at(local_x, cmp_y));
579  if (it != items_.end()) {
580  if (!(*it).ref_to.empty()) {
581  return ((*it).ref_to);
582  }
583  }
584  }
585  return "";
586 }
587 
588 } // end namespace help
std::string jump_to(const unsigned pos)
Definition: help_impl.hpp:382
int get_max_x(const int y, const int height=0)
Analogous with get_min_x but return the maximum X.
surface get_image(const image::locator &i_locator, TYPE type)
function to get the surface corresponding to an image.
Definition: image.cpp:920
help_text_area(CVideo &video, const section &toplevel)
std::vector< char_t > string
void set_shown_size(unsigned h)
Definition: scrollarea.cpp:108
virtual void set_inner_location(const SDL_Rect &rect)
const int title_size
Definition: help_impl.cpp:78
const std::vector< std::string > & parsed_text() const
Definition: help_impl.cpp:350
Note: Specific to sdl_ttf.
void add_img_item(const std::string &path, const std::string &alignment, const bool floating, const bool box)
Add an image item with the specified attributes.
std::string remove_first_space(const std::string &text)
Definition: help_impl.cpp:1351
bool null() const
Definition: surface.hpp:79
A section contains topics and sections along with title and ID.
Definition: help_impl.hpp:142
int get_remaining_width()
Return the width that remain on the line the current input point is at.
int get_y_for_floating_img(const int width, const int x, const int desired_y)
Find the lowest y coordinate where a floating img of the specified width and at the specified x coord...
Definition: video.hpp:31
Thrown when the help system fails to parse something.
Definition: help_impl.hpp:220
CVideo & video() const
Definition: widget.hpp:84
General purpose widgets.
std::list< item * > last_row_
#define h
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
void set_scroll_rate(unsigned r)
Definition: scrollarea.cpp:122
const int normal_font_size
Definition: help_impl.cpp:81
void set_items()
Update the vector with the items of the shown topic, creating surfaces for everything and putting thi...
To lexical_cast(From value)
Lexical cast converts one type to another.
color_t string_to_color(const std::string &cmp_str)
Return the color the string represents.
Definition: help_impl.cpp:1308
#define TRY(name)
-file util.hpp
Definitions for the interface to Wesnoth Markup Language (WML).
surface & getSurface()
Returns a reference to the framebuffer.
Definition: video.cpp:468
std::string bold(const std::string &s)
Definition: help_impl.hpp:396
topic const * shown_topic_
void set_full_size(unsigned h)
Definition: scrollarea.cpp:115
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
Definition: parser.cpp:749
void set_dirty(bool dirty=true)
Definition: widget.cpp:215
void set_position(unsigned pos)
Definition: scrollarea.cpp:93
SDL_Rect inner_location() const
Definition: scrollarea.cpp:136
void read(config &cfg, std::istream &in, abstract_validator *validator)
Definition: parser.cpp:612
void add_item(const item &itm)
Add an item to the internal list, update the locations and row height.
std::string ref_at(const int x, const int y)
Return the ID that is cross-referenced at the (screen) coordinates x, y.
void draw_rectangle(const SDL_Rect &rect, const color_t &color)
Draw a rectangle outline.
Definition: rect.cpp:57
int font_scaled(int size)
Definition: general.cpp:452
virtual void scroll(unsigned int pos)
std::list< item > items_
const section & toplevel_
void bg_register(const SDL_Rect &rect)
Definition: widget.cpp:107
std::string path
Definition: game_config.cpp:56
void handle_ref_cfg(const config &cfg)
const unsigned min_row_height_
const color_t YELLOW_COLOR
void handle_img_cfg(const config &cfg)
int get_max_height(int size)
Definition: sdl_ttf.cpp:407
const color_t NORMAL_COLOR
#define WRN_DP
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
Definition: rect.cpp:22
void handle_header_cfg(const config &cfg)
An item that is displayed in the text area.
const int box_width
Definition: help_impl.cpp:80
void handle_italic_cfg(const config &cfg)
void handle_bold_cfg(const config &cfg)
unsigned get_position() const
Definition: scrollarea.cpp:83
void show_topic(const topic &t)
Display the topic.
void adjust_last_row()
Adjust the heights of the items in the last row to make it look good .
void add_text_item(const std::string &text, const std::string &ref_dst="", bool broken_link=false, int font_size=-1, bool bold=false, bool italic=false, color_t color=font::NORMAL_COLOR)
Add an item with text.
static map_location::DIRECTION s
std::pair< int, int > curr_loc_
item(surface surface, int x, int y, const std::string &text="", const std::string &reference_to="", bool floating=false, bool box=false, ALIGNMENT alignment=HERE)
size_t i
Definition: function.cpp:933
surface get_rendered_text(const std::string &str, int size, const color_t &color, int style)
Definition: sdl_ttf.cpp:333
int w
int get_min_x(const int y, const int height=0)
Return the least x coordinate at which something of the specified height can be drawn at the specifie...
void down_one_line()
Move the current input point to the next line.
std::string make_text_ellipsis(const std::string &text, int font_size, int max_width, int style)
If the text exceeds the specified max width, end it with an ellipsis (...)
Definition: sdl_ttf.cpp:443
std::string jump(const unsigned amount)
Definition: help_impl.hpp:389
Contains the SDL_Rect helper code.
void bg_restore() const
Definition: widget.cpp:249
void handle_format_cfg(const config &cfg)
double t
Definition: astarsearch.cpp:64
const topic * find_topic(const section &sec, const std::string &id)
Search for the topic with the specified identifier in the section and its subsections.
Definition: help_impl.cpp:1151
Standard logging facilities (interface).
bool operator()(const item &) const
std::string message
Definition: exceptions.hpp:31
const int title2_size
Definition: help_impl.cpp:79
A topic contains a title, an id and some text.
Definition: help_impl.hpp:110
ALIGNMENT str_to_align(const std::string &s)
Convert a string to an alignment.
#define e
Definition: help.cpp:56
int width() const
Definition: widget.cpp:132
SDL_Rect rect
Relative coordinates of this item.
const SDL_Rect & location() const
Definition: widget.cpp:142
std::string title
Definition: help_impl.hpp:135
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
Definition: utils.hpp:33
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
static lg::log_domain log_display("display")
std::string get_first_word(const std::string &s)
Return the first word in s, not removing any spaces in the start of it.
Definition: help_impl.cpp:1359
const int font_size
int contents_height_
The height of all items in total.
Thrown when a lexical_cast fails.
int line_width(const std::string &line, int font_size, int style)
Determine the width of a line of text given a certain font size.
Definition: sdl_ttf.cpp:416
std::string::const_iterator iterator
Definition: tokenizer.hpp:24
void handle_jump_cfg(const config &cfg)
std::vector< std::string > split_in_width(const std::string &s, const int font_size, const unsigned width)
Make a best effort to word wrap s. All parts are less than width.
Definition: help_impl.cpp:1332
topic_text text
Definition: help_impl.hpp:136
const color_t BAD_COLOR
int height() const
Definition: widget.cpp:137
Function object to find an item at the specified coordinates.