Author: mordante
Date: Tue Apr 29 19:18:33 2008
New Revision: 26232
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26232&view=rev
Log:
load_config() should be called in the constructor.
Modified:
trunk/src/gui/widgets/button.hpp
trunk/src/gui/widgets/control.cpp
trunk/src/gui/widgets/grid.cpp
trunk/src/gui/widgets/grid.hpp
trunk/src/gui/widgets/label.hpp
trunk/src/gui/widgets/panel.hpp
trunk/src/gui/widgets/spacer.hpp
trunk/src/gui/widgets/text.hpp
trunk/src/gui/widgets/text_box.cpp
trunk/src/gui/widgets/text_box.hpp
trunk/src/gui/widgets/tooltip.hpp
trunk/src/gui/widgets/window.cpp
Modified: trunk/src/gui/widgets/button.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/button.hpp (original)
+++ trunk/src/gui/widgets/button.hpp Tue Apr 29 19:18:33 2008
@@ -29,8 +29,9 @@
tcontrol(COUNT),
state_(ENABLED),
retval_(0)
- {
- }
+ {
+ load_config();
+ }
void mouse_enter(tevent_handler&);
void mouse_leave(tevent_handler&);
Modified: trunk/src/gui/widgets/control.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.cpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.cpp (original)
+++ trunk/src/gui/widgets/control.cpp Tue Apr 29 19:18:33 2008
@@ -351,6 +351,11 @@
}
}
+//! Inherited from twidget.
+//!
+//! All classes which use this class as base should call this function in
+//! their constructor. Abstract classes shouldn't call this routine. The
+//! classes which call this routine should also define get_control_type().
void tcontrol::load_config()
{
if(!config()) {
Modified: trunk/src/gui/widgets/grid.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Tue Apr 29 19:18:33 2008
@@ -363,17 +363,6 @@
set_dirty(false);
}
-void tgrid::load_config()
-{
- for(std::vector<tchild>::iterator itor = children_.begin();
- itor != children_.end(); ++itor) {
-
- if(itor->widget()) {
- itor->widget()->load_config();
- }
- }
-}
-
void tgrid::clear_cache()
{
best_row_height_.clear();
Modified: trunk/src/gui/widgets/grid.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.hpp (original)
+++ trunk/src/gui/widgets/grid.hpp Tue Apr 29 19:18:33 2008
@@ -104,9 +104,6 @@
//! Inherited from twidget.
void draw(surface& surface);
- //! Inherited from twidget.
- void load_config();
-
private:
class tchild
{
Modified: trunk/src/gui/widgets/label.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/label.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/label.hpp (original)
+++ trunk/src/gui/widgets/label.hpp Tue Apr 29 19:18:33 2008
@@ -28,7 +28,9 @@
tlabel() :
tcontrol(COUNT),
state_(ENABLED)
- {}
+ {
+ load_config();
+ }
void set_active(const bool active) { set_state(active ? ENABLED :
DISABLED); };
bool get_active() const { return state_ == ENABLED; }
Modified: trunk/src/gui/widgets/panel.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/panel.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/panel.hpp (original)
+++ trunk/src/gui/widgets/panel.hpp Tue Apr 29 19:18:33 2008
@@ -27,10 +27,10 @@
tpanel() :
tcontrol(0),
grid_(0, 0, 0, 0)
- {
- grid_.set_parent(this);
- }
-
+ {
+ //load_config();
+ grid_.set_parent(this);
+ }
// Inherited from twidget.
twidget* get_widget(const tpoint& coordinate) { return
grid_.get_widget(coordinate); }
@@ -78,10 +78,6 @@
//FIXME we also need to load our own config
void draw(surface& surface) { grid_.draw(surface); }
- //! Inherited from twidget.
- //FIXME we also need to load our own config
- void load_config() { grid_.load_config(); }
-
private:
tgrid grid_;
Modified: trunk/src/gui/widgets/spacer.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/spacer.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/spacer.hpp (original)
+++ trunk/src/gui/widgets/spacer.hpp Tue Apr 29 19:18:33 2008
@@ -27,8 +27,9 @@
public:
tspacer() :
tcontrol(0)
- {
- }
+ {
+ load_config();
+ }
//! Inherited from tcontrol.
// We are always active, might not be visible but always active.
Modified: trunk/src/gui/widgets/text.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/text.hpp (original)
+++ trunk/src/gui/widgets/text.hpp Tue Apr 29 19:18:33 2008
@@ -36,7 +36,8 @@
sel_len_(0),
max_length_(std::string::npos),
dragging_(false)
- {}
+ {
+ }
void set_active(const bool /*active*/) { /*FIXME IMPLEMENT*/ };
bool get_active() const { return true; /* FIXME IMPLEMENT */ }
Modified: trunk/src/gui/widgets/text_box.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text_box.cpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/text_box.cpp (original)
+++ trunk/src/gui/widgets/text_box.cpp Tue Apr 29 19:18:33 2008
@@ -241,11 +241,6 @@
//! Calculates the offsets of all chars.
void ttext_box::calculate_char_offset()
{
- // If the text is set before the config is loaded do it ourselves.
- // This isn't really clean solution, maybe fix it later.
- if(!config()) {
- load_config();
- }
assert(config());
character_offset_.clear();
Modified: trunk/src/gui/widgets/text_box.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text_box.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/text_box.hpp (original)
+++ trunk/src/gui/widgets/text_box.hpp Tue Apr 29 19:18:33 2008
@@ -32,7 +32,8 @@
history_(0),
pos_(0),
enabled_(false)
- {}
+ {
+ }
//! Push string into the history if it is non-empty and is not the same
as the last item
//! updates position to end of history.
@@ -76,7 +77,10 @@
text_y_offset_(0),
text_height_(0),
dragging_(false)
- { set_wants_mouse_left_double_click(); }
+ {
+ load_config();
+ set_wants_mouse_left_double_click();
+ }
void set_history(const std::string& id)
{ history_ = ttext_history::get_history(id, true); }
Modified: trunk/src/gui/widgets/tooltip.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/tooltip.hpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/tooltip.hpp (original)
+++ trunk/src/gui/widgets/tooltip.hpp Tue Apr 29 19:18:33 2008
@@ -25,7 +25,10 @@
ttooltip() :
tcontrol(1)
- { set_multiline_label(); }
+ {
+ load_config();
+ set_multiline_label();
+ }
//! Inherited from tcontrol.
// We are always active, might not be visible but always active.
Modified: trunk/src/gui/widgets/window.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=26232&r1=26231&r2=26232&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Tue Apr 29 19:18:33 2008
@@ -71,30 +71,14 @@
set_height(h);
tooltip_.set_definition("default");
- tooltip_.load_config();
tooltip_.set_visible(false);
help_popup_.set_definition("default");
- help_popup_.load_config();
help_popup_.set_visible(false);
-}
-
-int twindow::show(const bool restore, void* /*flip_function*/)
-{
- log_scope2(gui_draw, "Window: show.");
-
- // Sanity
- if(status_ != NEW) {
- // FIXME throw an exception
-
- }
-
- // Update all configs.
+
load_config();
// FIXME hack to load config stuff here
- tcontrol::load_config();
-
const twindow_definition::tresolution* conf = dynamic_cast<const
twindow_definition::tresolution*>(config());
assert(conf);
canvas_background_ = conf->background.canvas;
@@ -105,6 +89,18 @@
canvas_foreground_.set_width(get_width());
canvas_foreground_.set_height(get_height());
// End of hack
+
+}
+
+int twindow::show(const bool restore, void* /*flip_function*/)
+{
+ log_scope2(gui_draw, "Window: show.");
+
+ // Sanity
+ if(status_ != NEW) {
+ // FIXME throw an exception
+
+ }
// We cut a piece of the screen and use that, that way all coordinates
// are relative to the window.
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits