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 17 #include "gui/dialogs/modal_dialog.hpp" 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 */ selected_index() const36 int selected_index() const 37 { 38 return index_; 39 } 40 41 /** Sets the initially selected item index (-1 by default). */ set_selected_index(int index)42 void set_selected_index(int index) 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 63