The Battle for Wesnoth  1.19.7+dev
depcheck_select_new.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2024
3  by Boldizsár Lipka <lipkab@zoho.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
20 #include <vector>
21 
22 
23 namespace gui2::dialogs
24 {
25 
27 {
28 public:
29  /**
30  * Constructor.
31  *
32  * @param name the type of which we want to select a new item
33  * @param options the names of the components which can be chosen
34  */
36  const std::vector<std::string>& options);
37 
38  /**
39  * Returns the selected item.
40  *
41  * @return the index of the selected item, or -1 if none was selected
42  * (the dialog was closed with the cancel button)
43  */
44  int result() const
45  {
46  return result_;
47  }
48 
49 protected:
50  virtual const std::string& window_id() const override;
51 
52  virtual void pre_show() override;
53 
54  virtual void post_show() override;
55 
56 private:
57  /** the options available */
58  std::vector<std::string> items_;
59 
60  /** the index of the selected item */
61  int result_;
62 };
63 } // namespace dialogs
virtual const std::string & window_id() const override
The ID of the window to build.
int result() const
Returns the selected item.
virtual void pre_show() override
Actions to be taken before showing the window.
int result_
the index of the selected item
virtual void post_show() override
Actions to be taken after the window has been shown.
std::vector< std::string > items_
the options available
depcheck_select_new(ng::depcheck::component_type name, const std::vector< std::string > &options)
Constructor.
Abstract base class for all modal dialogs.