gui/dialogs/simple_item_selector.hpp

Go to the documentation of this file.
00001 /* $Id: simple_item_selector.hpp 53595 2012-03-21 09:04:55Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2010 - 2012 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef GUI_DIALOGS_SIMPLE_ITEM_SELECTOR_HPP_INCLUDED
00017 #define GUI_DIALOGS_SIMPLE_ITEM_SELECTOR_HPP_INCLUDED
00018 
00019 #include "gui/dialogs/dialog.hpp"
00020 
00021 #include <vector>
00022 
00023 namespace gui2 {
00024 
00025 class tsimple_item_selector : public tdialog
00026 {
00027 public:
00028     typedef std::vector< std::string > list_type;
00029     typedef std::string                item_type;
00030 
00031     tsimple_item_selector(
00032         const std::string& title,
00033         const std::string& message,
00034         list_type const& items,
00035         bool title_uses_markup = false,
00036         bool message_uses_markup = false);
00037 
00038     /**
00039      * Returns the selected item index after displaying.
00040      * @return -1 if the dialog was cancelled.
00041      */
00042     int selected_index() const         { return index_;  }
00043 
00044     /** Sets the initially selected item index (-1 by default). */
00045     void set_selected_index(int index) { index_ = index; }
00046 
00047     /** Sets the caption for the OK button. */
00048     void set_ok_label(const std::string& s) { ok_label_ = s; }
00049     const std::string& ok_label() const     { return ok_label_; }
00050 
00051     /** Sets the caption for the Cancel button. */
00052     void set_cancel_label(const std::string& s) { cancel_label_ = s; }
00053     const std::string& cancel_label() const     { return cancel_label_; }
00054 
00055     /** Sets whether the Cancel button should be hidden or not. */
00056     void set_single_button(bool value) { single_button_ = value; }
00057     bool single_button() const         { return single_button_; }
00058 
00059 private:
00060     int index_;
00061 
00062     bool single_button_;
00063     list_type items_;
00064 
00065     std::string ok_label_, cancel_label_;
00066 
00067     /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
00068     virtual const std::string& window_id() const;
00069 
00070     /** Inherited from tdialog. */
00071     void pre_show(CVideo& video, twindow& window);
00072 
00073     /** Inherited from tdialog. */
00074     void post_show(twindow& window);
00075 };
00076 
00077 }
00078 
00079 #endif /* ! GUI_DIALOGS_SIMPLE_ITEM_SELECTOR_HPP_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs