The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
old_markup.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2017 by Mark de Wever <koraq@xs4all.nl>
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 #pragma once
16 
17 #include <string>
18 
19 namespace gui2
20 {
21 
22 /**
23  * Implements simple parsing of legacy GUI1 item markup.
24  */
26 {
27  /*
28  * Legacy options/menu items have some special markup:
29  * A line starting with a * is selected by default.
30  * A line starting with a & enables the following markup:
31  * - The part until the = is the name of an image.
32  * - The part until the second = is the first column.
33  * - The rest is the third column (the wiki only specifies two columns
34  * so only two of them are implemented).
35  */
36  /**
37  * @todo This syntax looks like a bad hack, it would be nice to write
38  * a new syntax which doesn't use those hacks (also avoids the problem
39  * with special meanings for certain characters.
40  */
41 public:
42  explicit legacy_menu_item(const std::string& str = std::string());
43 
44  const std::string& icon() const
45  {
46  return icon_;
47  }
48 
49  const std::string& label() const
50  {
51  return label_;
52  }
53 
54  const std::string& description() const
55  {
56  return desc_;
57  }
58 
59  bool is_default() const
60  {
61  return default_;
62  }
63 
65  {
66  if(&rhs != this) {
67  icon_ = rhs.icon_;
68  label_ = rhs.label_;
69  desc_ = rhs.desc_;
70  }
71  return *this;
72  }
73 
74 private:
75  /** The icon for the menu item. */
77 
78  /** The first text item of the menu item, normally a short string. */
80 
81  /** The second text item of the menu item, normally a longer string. */
83 
84  /**
85  * Is the item the default item and thus initially selected.
86  *
87  * It's unspecified what happens if multiple items in a menu are selected.
88  */
89  bool default_;
90 };
91 }
const std::string & description() const
Definition: old_markup.hpp:54
std::vector< char_t > string
std::string label_
The first text item of the menu item, normally a short string.
Definition: old_markup.hpp:79
std::string desc_
The second text item of the menu item, normally a longer string.
Definition: old_markup.hpp:82
Generic file dialog.
Definition: field-fwd.hpp:22
std::string icon_
The icon for the menu item.
Definition: old_markup.hpp:76
legacy_menu_item & operator=(const legacy_menu_item &rhs)
Definition: old_markup.hpp:64
legacy_menu_item(const std::string &str=std::string())
Definition: old_markup.cpp:20
bool default_
Is the item the default item and thus initially selected.
Definition: old_markup.hpp:89
bool is_default() const
Definition: old_markup.hpp:59
const std::string & icon() const
Definition: old_markup.hpp:44
Implements simple parsing of legacy GUI1 item markup.
Definition: old_markup.hpp:25
const std::string & label() const
Definition: old_markup.hpp:49