src/gui/menu_item.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
00018 #define HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
00019 
00020 #include <list>
00021 #include <memory>
00022 #include <SDL.h>
00023 
00024 #include "gui/menu.hpp"
00025 
00026 /* Kinds of menu items */
00027 enum MenuItemKind {
00028   MN_ACTION,
00029   MN_GOTO,
00030   MN_TOGGLE,
00031   MN_BACK,
00032   MN_INACTIVE,
00033   MN_TEXTFIELD,
00034   MN_NUMFIELD,
00035   MN_CONTROLFIELD,
00036   MN_STRINGSELECT,
00037   MN_LABEL,
00038   MN_HL /* horizontal line */
00039 };
00040 
00041 class MenuItem
00042 {
00043 public:
00044   static MenuItem* create(MenuItemKind kind, const std::string& text,
00045                           int init_toggle, Menu* target_menu, int id, int key);
00046 
00047 public:
00048   MenuItem(MenuItemKind kind, int id = -1);
00049 
00050   void set_help(const std::string& help_text);
00051 
00052   void change_text (const std::string& text);
00053   void change_input(const std::string& text);
00054 
00055   std::string get_input_with_symbol(bool active_item);   // returns the text with an input symbol
00056 
00057 public:
00058   MenuItemKind kind;
00059   int id;   // item id
00060   bool toggled;
00061   std::string text;
00062   std::string input;
00063   std::string help;
00064 
00065   std::vector<std::string> list; // list of values for a STRINGSELECT item
00066   size_t selected; // currently selected item
00067 
00068   Menu* target_menu;
00069 
00070 private:
00072   bool input_flickering;
00073 
00074 private:
00075   MenuItem(const MenuItem&);
00076   MenuItem& operator=(const MenuItem&);
00077 };
00078 
00079 #endif
00080 
00081 /* EOF */

Generated on Mon Jun 9 03:38:18 2014 for SuperTux by  doxygen 1.5.1