00001 /* $Id: window_builder.hpp 26371 2008-05-04 11:55:03Z mordante $ */ 00002 /* 00003 Copyright (C) 2008 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 version 2 00008 or at your option any later version. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details. 00013 */ 00014 00015 #ifndef __GUI_WIDGETS_WINDOW_BUILDER_HPP_INCLUDED__ 00016 #define __GUI_WIDGETS_WINDOW_BUILDER_HPP_INCLUDED__ 00017 00018 #include "reference_counted_object.hpp" 00019 #include "tstring.hpp" 00020 00021 #include <string> 00022 #include <vector> 00023 00024 class config; 00025 class CVideo; 00026 00027 namespace gui2 { 00028 00029 class twidget; 00030 class twindow; 00031 00032 twindow build(CVideo& video, const std::string& type); 00033 00034 00035 //! Contains the info needed to instantiate a widget. 00036 struct tbuilder_widget : public reference_counted_object 00037 { 00038 private: 00039 tbuilder_widget(); 00040 00041 public: 00042 tbuilder_widget(const config& /*cfg*/) {} 00043 00044 00045 virtual twidget* build() const = 0; 00046 virtual ~tbuilder_widget() {} 00047 }; 00048 00049 typedef boost::intrusive_ptr<tbuilder_widget> tbuilder_widget_ptr; 00050 typedef boost::intrusive_ptr<const tbuilder_widget> const_tbuilder_widget_ptr; 00051 00052 //! 00053 struct tbuilder_grid : public tbuilder_widget 00054 { 00055 private: 00056 tbuilder_grid(); 00057 00058 public: 00059 tbuilder_grid(const config& cfg); 00060 unsigned rows; 00061 unsigned cols; 00062 00063 //! The grow factor for the rows / columns. 00064 std::vector<unsigned> row_grow_factor; 00065 std::vector<unsigned> col_grow_factor; 00066 00067 //! The flags per grid cell. 00068 std::vector<unsigned> flags; 00069 00070 //! The border size per grid cell. 00071 std::vector<unsigned> border_size; 00072 00073 //! The widgets per grid cell. 00074 std::vector<tbuilder_widget_ptr> widgets; 00075 00076 twidget* build () const; 00077 00078 private: 00079 //! After reading the general part in the constructor read extra data. 00080 void read_extra(const config& cfg); 00081 }; 00082 00083 class twindow_builder 00084 { 00085 public: 00086 const std::string& read(const config& cfg); 00087 00088 struct tresolution 00089 { 00090 private: 00091 tresolution(); 00092 00093 public: 00094 tresolution(const config& cfg); 00095 00096 unsigned window_width; 00097 unsigned window_height; 00098 00099 bool automatic_placement; 00100 00101 unsigned x; 00102 unsigned y; 00103 unsigned width; 00104 unsigned height; 00105 00106 unsigned vertical_placement; 00107 unsigned horizontal_placement; 00108 00109 std::string definition; 00110 00111 tbuilder_grid* grid; 00112 }; 00113 00114 std::vector<tresolution> resolutions; 00115 00116 private: 00117 std::string id_; 00118 std::string description_; 00119 00120 }; 00121 00122 } // namespace gui2 00123 00124 00125 #endif 00126 00127 00128
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |