mail[Wesnoth-commits] r25166 - in /trunk/src/gui/widgets: window_builder.cpp window_builder.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on March 26, 2008 - 19:14:
Author: mordante
Date: Wed Mar 26 19:14:12 2008
New Revision: 25166

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25166&view=rev
Log:
Move a deeply nested structure out of it's parent. This also allows data not
interesting for the outside to be defined in the .cpp instead of the .hpp.

Modified:
    trunk/src/gui/widgets/window_builder.cpp
    trunk/src/gui/widgets/window_builder.hpp

Modified: trunk/src/gui/widgets/window_builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=25166&r1=25165&r2=25166&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Wed Mar 26 19:14:12 2008
@@ -48,6 +48,31 @@
 
 namespace gui2 {
 
+struct tbuilder_button : public tbuilder_widget
+{
+
+private:
+       tbuilder_button();
+public:
+       tbuilder_button(const config& cfg) : tbuilder_widget(cfg) {}
+
+       twidget* build () const;
+
+};
+
+struct tbuilder_text_box : public tbuilder_widget
+{
+
+private:
+       tbuilder_text_box();
+public:
+       tbuilder_text_box(const config& cfg) : tbuilder_widget(cfg) {}
+
+       twidget* build () const;
+
+};
+
+
 twindow build(CVideo& video, const std::string& type)
 {
        std::vector<twindow_builder::tresolution>::const_iterator 
@@ -190,7 +215,7 @@
                << rows << " rows and " << cols << " columns.\n";
 }
 
-twindow_builder::tresolution::tgrid::tbuilder_widget::tbuilder_widget(const 
config& cfg) :
+tbuilder_widget::tbuilder_widget(const config& cfg) :
        id(cfg["id"]),
        definition(cfg["button_definition"]),
        label(cfg["label"])
@@ -205,7 +230,7 @@
        
 }
 
-twidget* twindow_builder::tresolution::tgrid::tbuilder_button::build() const
+twidget* tbuilder_button::build() const
 {
        tbutton *button = new tbutton();
 
@@ -219,7 +244,7 @@
        return button;
 }
 
-twidget* twindow_builder::tresolution::tgrid::tbuilder_text_box::build() 
const
+twidget* tbuilder_text_box::build() const
 {
        ttext_box *text_box = new ttext_box();
 
@@ -233,6 +258,5 @@
        return text_box;
 }
 
-
 } // namespace gui2
 

Modified: trunk/src/gui/widgets/window_builder.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.hpp?rev=25166&r1=25165&r2=25166&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.hpp (original)
+++ trunk/src/gui/widgets/window_builder.hpp Wed Mar 26 19:14:12 2008
@@ -30,6 +30,27 @@
 class twindow;
 
 twindow build(CVideo& video, const std::string& type);
+
+
+//! Contains the info needed to instantiate a widget.
+struct tbuilder_widget : public reference_counted_object
+{
+private:
+       tbuilder_widget();
+
+public:
+       tbuilder_widget(const config& cfg);
+
+       std::string id;
+       std::string definition;
+       t_string label;
+
+       virtual twidget* build() const = 0;
+       virtual ~tbuilder_widget() {}
+};
+
+typedef boost::intrusive_ptr<tbuilder_widget> tbuilder_widget_ptr;
+typedef boost::intrusive_ptr<const tbuilder_widget> 
const_tbuilder_widget_ptr;
 
 class twindow_builder
 {
@@ -65,50 +86,6 @@
                        unsigned rows;
                        unsigned cols;
 
-                       struct tbuilder_widget : public 
reference_counted_object
-                       {
-                       // NOTE a widget is always a button atm.
-                       private:
-                               tbuilder_widget();
-
-                       public:
-                               tbuilder_widget(const config& cfg);
-
-                               std::string id;
-                               std::string definition;
-                               t_string label;
-
-                               virtual twidget* build() const = 0;
-                               virtual ~tbuilder_widget() {}
-                       };
-
-                       struct tbuilder_button : public tbuilder_widget
-                       {
-
-                       private:
-                               tbuilder_button();
-                       public:
-                               tbuilder_button(const config& cfg) : 
tbuilder_widget(cfg) {}
-
-                               twidget* build () const;
-
-                       };
-
-                       struct tbuilder_text_box : public tbuilder_widget
-                       {
-
-                       private:
-                               tbuilder_text_box();
-                       public:
-                               tbuilder_text_box(const config& cfg) : 
tbuilder_widget(cfg) {}
-
-                               twidget* build () const;
-
-                       };
-
-                       typedef boost::intrusive_ptr<tbuilder_widget> 
tbuilder_widget_ptr;
-                       typedef boost::intrusive_ptr<const tbuilder_widget> 
const_tbuilder_widget_ptr;
-
                        std::vector<tbuilder_widget_ptr> widgets;
                };
 




Related Messages


Powered by MHonArc, Updated Wed Mar 26 19:41:47 2008