00001 /* $Id: widget_definition.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2007 - 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_WIDGET_DEFINITION_HPP_INCLUDED 00017 #define GUI_AUXILIARY_WIDGET_DEFINITION_HPP_INCLUDED 00018 00019 #include "config.hpp" 00020 #include "foreach.hpp" 00021 #include "gui/auxiliary/canvas.hpp" 00022 00023 namespace gui2 { 00024 00025 /** 00026 * Contains the state info for a resolution. 00027 * 00028 * At the moment all states are the same so there is no need to use 00029 * inheritance. If that is needed at some point the containers should contain 00030 * pointers and we should inherit from reference_counted_object. 00031 */ 00032 struct tstate_definition 00033 { 00034 explicit tstate_definition(const config &cfg); 00035 00036 tcanvas canvas; 00037 }; 00038 00039 00040 /** Base class of a resolution, contains the common keys for a resolution. */ 00041 struct tresolution_definition_ 00042 : public reference_counted_object 00043 { 00044 explicit tresolution_definition_(const config& cfg); 00045 00046 unsigned window_width; 00047 unsigned window_height; 00048 00049 unsigned min_width; 00050 unsigned min_height; 00051 00052 unsigned default_width; 00053 unsigned default_height; 00054 00055 unsigned max_width; 00056 unsigned max_height; 00057 00058 unsigned text_extra_width; 00059 unsigned text_extra_height; 00060 unsigned text_font_size; 00061 int text_font_style; 00062 00063 std::vector<tstate_definition> state; 00064 }; 00065 00066 typedef 00067 boost::intrusive_ptr<tresolution_definition_> 00068 tresolution_definition_ptr; 00069 00070 typedef 00071 boost::intrusive_ptr<const tresolution_definition_> 00072 tresolution_definition_const_ptr; 00073 00074 /** 00075 * Casts a tresolution_definition_const_ptr to another type. 00076 * 00077 * @tparam T The type to cast to, the non const version. 00078 * 00079 * @param ptr The pointer to cast. 00080 * 00081 * @returns A reference to type casted to. 00082 */ 00083 template<class T> 00084 const T& cast(tresolution_definition_const_ptr ptr) 00085 { 00086 boost::intrusive_ptr<const T> conf = 00087 boost::dynamic_pointer_cast<const T>(ptr); 00088 assert(conf); 00089 return *conf; 00090 } 00091 00092 struct tcontrol_definition 00093 : public reference_counted_object 00094 { 00095 explicit tcontrol_definition(const config& cfg); 00096 00097 template<class T> 00098 void load_resolutions(const config &cfg) 00099 { 00100 config::const_child_itors itors = cfg.child_range("resolution"); 00101 foreach(const config &resolution, itors) { 00102 resolutions.push_back(new T(resolution)); 00103 } 00104 } 00105 00106 std::string id; 00107 t_string description; 00108 00109 std::vector<tresolution_definition_ptr> resolutions; 00110 }; 00111 00112 typedef boost::intrusive_ptr<tcontrol_definition> tcontrol_definition_ptr; 00113 00114 } // namespace gui2 00115 00116 #endif 00117
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:54 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |