gui/auxiliary/old_markup.cpp

Go to the documentation of this file.
00001 /* $Id: old_markup.cpp 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 #include "gui/auxiliary/old_markup.hpp"
00017 
00018 namespace gui2 {
00019 
00020 tlegacy_menu_item::tlegacy_menu_item(const std::string& str)
00021     : icon_(), label_(str), desc_(), default_(false)
00022 {
00023     if(label_.empty()) {
00024         return;
00025     }
00026 
00027     // Handle selection.
00028     if(label_[0] == '*') {
00029         default_ = true;
00030         label_.erase(0, 1);
00031     }
00032 
00033     // Handle the special case with an image.
00034     std::string::size_type pos = label_.find('=');
00035     if (pos != std::string::npos && (label_[0] == '&' || pos == 0)) {
00036         if (pos) icon_ = label_.substr(1, pos - 1);
00037         label_.erase(0, pos + 1);
00038     }
00039 
00040     // Search for an '=' symbol that is not inside markup.
00041     std::string::size_type prev = 0;
00042     bool open = false;
00043     while ((pos = label_.find('=', prev)) != std::string::npos) {
00044         for (std::string::size_type i = prev; i != pos; ++i) {
00045             switch (label_[i]) {
00046             case '<': open = true; break;
00047             case '>': open = false; break;
00048             }
00049         }
00050         if (!open) break;
00051         prev = pos + 1;
00052     }
00053     if (pos != std::string::npos) {
00054         desc_ = label_.substr(pos + 1);
00055         label_.erase(pos);
00056     }
00057 
00058 }
00059 
00060 }
00061 
 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