gui/auxiliary/old_markup.hpp

Go to the documentation of this file.
00001 /* $Id: old_markup.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Mark de Wever <koraq@xs4all.nl>
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_AUXILIARY_OLD_MARKUP_INCLUDED
00017 #define GUI_AUXILIARY_OLD_MARKUP_INCLUDED
00018 
00019 #include <string>
00020 
00021 namespace gui2
00022 {
00023 
00024 /**
00025  * Implements simple parsing of legacy GUI1 item markup.
00026  */
00027 class tlegacy_menu_item
00028 {
00029     /*
00030      * Legacy options/menu items have some special markup:
00031      * A line starting with a * is selected by default.
00032      * A line starting with a & enables the following markup:
00033      * - The part until the = is the name of an image.
00034      * - The part until the second = is the first column.
00035      * - The rest is the third column (the wiki only specifies two columns
00036      *   so only two of them are implemented).
00037      */
00038     /**
00039      * @todo This syntax looks like a bad hack, it would be nice to write
00040      * a new syntax which doesn't use those hacks (also avoids the problem
00041      * with special meanings for certain characters.
00042      */
00043 public:
00044     explicit tlegacy_menu_item(const std::string& str = std::string());
00045 
00046     const std::string& icon() const {
00047         return icon_;
00048     }
00049 
00050     const std::string& label() const {
00051         return label_;
00052     }
00053 
00054     const std::string& description() const {
00055         return desc_;
00056     }
00057 
00058     bool is_default() const {
00059         return default_;
00060     }
00061 
00062     tlegacy_menu_item& operator=(const tlegacy_menu_item& rhs) {
00063         if(&rhs != this) {
00064             icon_ = rhs.icon_;
00065             label_ = rhs.label_;
00066             desc_ = rhs.desc_;
00067         }
00068         return *this;
00069     }
00070 
00071 private:
00072     /** The icon for the menu item. */
00073     std::string icon_;
00074 
00075     /** The first text item of the menu item, normally a short string. */
00076     std::string label_;
00077 
00078     /** The second text item of the menu item, normally a longer string. */
00079     std::string desc_;
00080 
00081     /**
00082      * Is the item the default item and thus initially selected.
00083      *
00084      * It's unspecified what happens if multiple items in a menu are selected.
00085      */
00086     bool default_;
00087 };
00088 
00089 }
00090 
00091 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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