The Battle for Wesnoth  1.15.1+dev
depcheck_select_new.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2018 by Boldizs√°r Lipka <lipkab@zoho.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 
19 #include <vector>
20 
21 
22 namespace gui2
23 {
24 namespace dialogs
25 {
26 
28 {
29 public:
30  /**
31  * Constructor.
32  *
33  * @param name the type of which we want to select a new item
34  * @param options the names of the components which can be chosen
35  */
37  const std::vector<std::string>& options);
38 
39  /**
40  * Returns the selected item.
41  *
42  * @return the index of the selected item, or -1 if none was selected
43  * (the dialog was closed with the cancel button)
44  */
45  int result() const
46  {
47  return result_;
48  }
49 
50 protected:
51  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
52  virtual const std::string& window_id() const override;
53 
54  /** Inherited from modal_dialog */
55  virtual void pre_show(window& window) override;
56 
57  /** Inherited from modal_dialog */
58  virtual void post_show(window& window) override;
59 
60 private:
61  /** the options available */
62  std::vector<std::string> items_;
63 
64  /** the index of the selected item */
65  int result_;
66 };
67 } // namespace dialogs
68 } // namespace gui2
int result_
the index of the selected item
depcheck_select_new(ng::depcheck::component_type name, const std::vector< std::string > &options)
Constructor.
Generic file dialog.
Definition: field-fwd.hpp:22
static const char * name(const std::vector< SDL_Joystick *> &joysticks, const std::size_t index)
Definition: joystick.cpp:48
const config & options()
Definition: game.cpp:582
std::vector< std::string > items_
the options available
Various uncategorised dialogs.
int result() const
Returns the selected item.
virtual void post_show(window &window) override
Inherited from modal_dialog.
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Abstract base class for all modal dialogs.
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63