The Battle for Wesnoth  1.15.1+dev
theme_list.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2018 by Iris Morelle <shadowm2006@gmail.com>
3  Part of the Battle for Wesnoth Project https://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 
18 
19 struct theme_info;
20 
21 namespace gui2
22 {
23 namespace dialogs
24 {
25 
26 class theme_list : public modal_dialog
27 {
28 public:
29  explicit theme_list(const std::vector<theme_info>& themes,
30  int selection = -1);
31 
32  /**
33  * Returns the selected item index after displaying.
34  * @return -1 if the dialog was canceled.
35  */
36  int selected_index() const
37  {
38  return index_;
39  }
40 
41  /** Sets the initially selected item index (-1 by default). */
43  {
44  index_ = index;
45  }
46 
47 private:
48  int index_;
49 
50  std::vector<theme_info> themes_;
51 
52  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
53  virtual const std::string& window_id() const override;
54 
55  /** Inherited from modal_dialog. */
56  virtual void pre_show(window& window) override;
57 
58  /** Inherited from modal_dialog. */
59  virtual void post_show(window& window) override;
60 };
61 } // namespace dialogs
62 } // namespace gui2
virtual void post_show(window &window) override
Inherited from modal_dialog.
Definition: theme_list.cpp:87
std::vector< theme_info > themes_
Definition: theme_list.hpp:50
Generic file dialog.
Definition: field-fwd.hpp:22
void set_selected_index(int index)
Sets the initially selected item index (-1 by default).
Definition: theme_list.hpp:42
int selected_index() const
Returns the selected item index after displaying.
Definition: theme_list.hpp:36
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: theme_list.cpp:57
Various uncategorised dialogs.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:71
Abstract base class for all modal dialogs.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
theme_list(const std::vector< theme_info > &themes, int selection=-1)
Definition: theme_list.cpp:52