The Battle for Wesnoth  1.15.0-dev
old_markup.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 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 = "", const std::string deprecation_msg = "");
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 
64  bool contained_markup() const
65  {
66  return contained_markup_;
67  }
68 
70  {
71  if(&rhs != this) {
72  icon_ = rhs.icon_;
73  label_ = rhs.label_;
74  desc_ = rhs.desc_;
75  default_ = rhs.default_;
76  }
77  return *this;
78  }
79 
80 private:
81  /** The icon for the menu item. */
82  std::string icon_;
83 
84  /** The first text item of the menu item, normally a short string. */
85  std::string label_;
86 
87  /** The second text item of the menu item, normally a longer string. */
88  std::string desc_;
89 
90  /**
91  * Is the item the default item and thus initially selected.
92  *
93  * It's unspecified what happens if multiple items in a menu are selected.
94  */
95  bool default_;
96 
97  /**
98  * Was any old markup actually parsed?
99  */
101 };
102 }
const std::string & icon() const
Definition: old_markup.hpp:44
std::string label_
The first text item of the menu item, normally a short string.
Definition: old_markup.hpp:85
legacy_menu_item(const std::string &str="", const std::string deprecation_msg="")
Definition: old_markup.cpp:22
bool contained_markup_
Was any old markup actually parsed?
Definition: old_markup.hpp:100
std::string desc_
The second text item of the menu item, normally a longer string.
Definition: old_markup.hpp:88
Generic file dialog.
Definition: field-fwd.hpp:22
std::string icon_
The icon for the menu item.
Definition: old_markup.hpp:82
legacy_menu_item & operator=(const legacy_menu_item &rhs)
Definition: old_markup.hpp:69
bool default_
Is the item the default item and thus initially selected.
Definition: old_markup.hpp:95
bool contained_markup() const
Definition: old_markup.hpp:64
bool is_default() const
Definition: old_markup.hpp:59
const std::string & label() const
Definition: old_markup.hpp:49
Implements simple parsing of legacy GUI1 item markup.
Definition: old_markup.hpp:25
const std::string & description() const
Definition: old_markup.hpp:54