The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
help_topic_generators.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2016 by David White <[email protected]>
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 #ifndef HELP_TOPIC_GENERATORS_HPP
16 #define HELP_TOPIC_GENERATORS_HPP
17 
18 #include "font.hpp" // for line_width
19 #include "help_impl.hpp"
20 
21 #include <string> // for string
22 #include <utility> // for pair
23 #include <vector> // for vector
24 #include <SDL.h> // for TTF_STYLE_BOLD
25 class terrain_type; // lines 20-20
26 class unit_type;
27 
28 namespace help {
29 
31 {
33 
34 
35 public:
36  terrain_topic_generator(const terrain_type& type) : type_(type) {}
37 
38  virtual std::string operator()() const;
39 };
40 
41 
42 
44 {
45  const unit_type& type_;
47  typedef std::pair< std::string, unsigned > item;
48  void push_header(std::vector< item > &row, const std::string& name) const {
49  row.push_back(item(bold(name), font::line_width(name, normal_font_size, TTF_STYLE_BOLD)));
50  }
51 public:
52  unit_topic_generator(const unit_type &t, std::string variation="") : type_(t), variation_(variation) {}
53  virtual std::string operator()() const;
54 };
55 
56 } // end namespace help/
57 
58 #endif
virtual std::string operator()() const
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
void push_header(std::vector< item > &row, const std::string &name) const
const int normal_font_size
Definition: help_impl.cpp:80
GLdouble GLdouble t
Definition: glew.h:1366
terrain_topic_generator(const terrain_type &type)
std::string bold(const std::string &s)
Definition: help_impl.hpp:395
std::pair< std::string, unsigned > item
virtual std::string operator()() const
GLuint const GLchar * name
Definition: glew.h:1782
GLenum GLenum GLvoid * row
Definition: glew.h:3805
Generate a topic text on the fly.
Definition: help_impl.hpp:62
unit_topic_generator(const unit_type &t, std::string variation="")
Definition: help.cpp:57
GLsizei const GLcharARB ** string
Definition: glew.h:4503
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: font.cpp:969