The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
filter_options.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2016 by Ignacio Riquelme Morelle <[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 GUI_DIALOGS_ADDON_FILTER_OPTIONS_HPP_INCLUDED
16 #define GUI_DIALOGS_ADDON_FILTER_OPTIONS_HPP_INCLUDED
17 
18 #include "gui/dialogs/dialog.hpp"
19 #include "gui/widgets/group.hpp"
20 
21 #include "addon/validation.hpp"
22 #include "addon/state.hpp"
23 
24 #include <boost/array.hpp>
25 
26 namespace gui2
27 {
28 
29 class ttoggle_button;
30 
32 {
33 public:
35 
36  std::vector<bool> displayed_types() const
37  {
38  return std::vector<bool>(displayed_types_.begin(),
39  displayed_types_.end());
40  }
41 
42  void set_displayed_types(const std::vector<bool>& types)
43  {
44  read_types_vector(types);
45  }
46 
48  {
49  return displayed_status_;
50  }
51 
53  {
54  displayed_status_ = status;
55  }
56 
57  ADDON_SORT sort() const
58  {
59  return sort_;
60  }
61 
63  {
64  sort_ = sort;
65  }
66 
68  {
69  return dir_;
70  }
71 
73  {
74  dir_ = direction;
75  }
76 
77 private:
79  boost::array<bool, ADDON_TYPES_COUNT> displayed_types_;
80  std::vector<tfield_bool*> displayed_types_fields_;
81 
84 
85  typedef std::pair<ttoggle_button*, ADDON_SORT> sort_toggle;
86  typedef std::pair<ttoggle_button*, ADDON_SORT_DIRECTION> dir_toggle;
87 
88  // Dialog display state variables.
91 
92  void register_displayed_type_field(const std::string& field_id,
93  ADDON_TYPE addon_type);
94 
95  void read_types_vector(const std::vector<bool>& v);
96 
98 
99  void register_sort_toggle(twindow& window,
100  const std::string& toggle_id,
101  ADDON_SORT value);
102  void register_dir_toggle(twindow& window,
103  const std::string& toggle_id,
105 
106  void toggle_sort_callback();
107  void toggle_dir_callback();
108 
109  /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
110  virtual const std::string& window_id() const;
111 
112  /** Inherited from tdialog. */
113  void pre_show(twindow& window);
114 
115  /** Inherited from tdialog. */
116  void post_show(twindow& window);
117 
119 };
120 
121 
122 } // end namespace gui2
123 
124 #endif
ADDON_SORT_DIRECTION dir_
tgroup< ADDON_SORT > sort_tgroup_
void register_sort_toggle(twindow &window, const std::string &toggle_id, ADDON_SORT value)
boost::array< bool, ADDON_TYPES_COUNT > displayed_types_
ADDON_TYPE
Values used for add-on classification; UI-only at the moment, in the future it could be used for dire...
Definition: validation.hpp:41
ADDON_SORT
Add-on fallback/default sorting criteria for the user interface.
Definition: state.hpp:93
ADDON_STATUS_FILTER displayed_status_
tgroup< ADDON_SORT_DIRECTION > dir_tgroup_
ADDON_SORT sort() const
GLsizei GLenum GLenum * types
Definition: glew.h:3155
void set_displayed_status(ADDON_STATUS_FILTER status)
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
static std::string status_label(ADDON_STATUS_FILTER s)
ADDON_SORT_DIRECTION
Add-on fallback/default sorting direction.
Definition: state.hpp:102
Abstract base class for all dialogs.
Definition: dialog.hpp:121
ADDON_STATUS_FILTER
Add-on installation status filters for the user interface.
Definition: state.hpp:82
const GLdouble * v
Definition: glew.h:1359
GLsizei const GLfloat * value
Definition: glew.h:1817
std::pair< ttoggle_button *, ADDON_SORT > sort_toggle
ADDON_SORT_DIRECTION direction() const
void post_show(twindow &window)
Inherited from tdialog.
void set_direction(ADDON_SORT_DIRECTION direction)
std::vector< tfield_bool * > displayed_types_fields_
std::pair< ttoggle_button *, ADDON_SORT_DIRECTION > dir_toggle
void set_sort(ADDON_SORT sort)
virtual const std::string & window_id() const
Inherited from tdialog, implemented by REGISTER_DIALOG.
void register_dir_toggle(twindow &window, const std::string &toggle_id, ADDON_SORT_DIRECTION value)
void register_displayed_type_field(const std::string &field_id, ADDON_TYPE addon_type)
std::vector< bool > displayed_types() const
void pre_show(twindow &window)
Inherited from tdialog.
GLdouble s
Definition: glew.h:1358
void toggle_all_displayed_types_button_callback(twindow &window)
void read_types_vector(const std::vector< bool > &v)
GLsizei const GLcharARB ** string
Definition: glew.h:4503
void set_displayed_types(const std::vector< bool > &types)
ADDON_STATUS_FILTER displayed_status() const