The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
simple_item_selector.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2010 - 2025
3 by Iris Morelle <shadowm2006@gmail.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
19
20#include <vector>
21
22namespace gui2::dialogs
23{
24
26{
27public:
28 typedef std::vector<std::string> list_type;
29
30 simple_item_selector(const std::string& title,
31 const std::string& message,
32 const list_type& items,
33 bool title_uses_markup = false,
34 bool message_uses_markup = false);
35
36 /**
37 * Returns the selected item index after displaying.
38 * @return -1 if the dialog was canceled.
39 */
40 int selected_index() const
41 {
42 return index_;
43 }
44
45 /** Sets the initially selected item index (-1 by default). */
46 void set_selected_index(int index)
47 {
48 index_ = index;
49 }
50
51 /** Sets the caption for the OK button. */
52 void set_ok_label(const std::string& s)
53 {
54 ok_label_ = s;
55 }
56 const std::string& ok_label() const
57 {
58 return ok_label_;
59 }
60
61 /** Sets the caption for the Cancel button. */
62 void set_cancel_label(const std::string& s)
63 {
65 }
66 const std::string& cancel_label() const
67 {
68 return cancel_label_;
69 }
70
71 /** Sets whether the Cancel button should be hidden or not. */
73 {
75 }
76 bool single_button() const
77 {
78 return single_button_;
79 }
80
81private:
82 int index_;
83
86
88
89 virtual const std::string& window_id() const override;
90
91 virtual void pre_show() override;
92
93 virtual void post_show() override;
94};
95} // namespace dialogs
Main class to show messages to the user.
Definition message.hpp:36
Abstract base class for all modal dialogs.
void set_single_button(bool value)
Sets whether the Cancel button should be hidden or not.
const std::string & cancel_label() const
virtual void pre_show() override
Actions to be taken before showing the window.
virtual void post_show() override
Actions to be taken after the window has been shown.
void set_cancel_label(const std::string &s)
Sets the caption for the Cancel button.
void set_ok_label(const std::string &s)
Sets the caption for the OK button.
int selected_index() const
Returns the selected item index after displaying.
void set_selected_index(int index)
Sets the initially selected item index (-1 by default).
virtual const std::string & window_id() const override
The ID of the window to build.
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
Definition sound.cpp:139
static map_location::direction s