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


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

Header


Content

Posted by koraq on March 01, 2009 - 17:24:
Author: mordante
Date: Sun Mar  1 17:24:29 2009
New Revision: 33242

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33242&view=rev
Log:
Reimplement the value changed callback.

It seems the callback got lost in the rewrite. Added a hacky version
will need more testing later.

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

Modified: trunk/src/gui/widgets/listbox.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.cpp?rev=33242&r1=33241&r2=33242&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.cpp (original)
+++ trunk/src/gui/widgets/listbox.cpp Sun Mar  1 17:24:29 2009
@@ -34,6 +34,7 @@
        : tscrollbar_container(2) // FIXME magic number
        , generator_(NULL)
        , list_builder_(NULL)
+       , callback_value_changed_(NULL)
 {
        generator_ = tgenerator_::build(
                        has_minimum, has_maximum, placement, select);
@@ -139,6 +140,9 @@
 
                if(generator_->get_item(i).has_widget(caller)) {
                        generator_->toggle_item(i);
+                       if(callback_value_changed_) { 
+                               callback_value_changed_(this);
+                       }
                        return;
                }
        }
@@ -174,6 +178,9 @@
 
                show_content_rect(rect);
 
+               if(callback_value_changed_) { 
+                       callback_value_changed_(this);
+               }
        } else {
                // Inherited.
                tscrollbar_container::handle_key_up_arrow(modifier, handled);
@@ -198,6 +205,9 @@
 
                show_content_rect(rect);
 
+               if(callback_value_changed_) { 
+                       callback_value_changed_(this);
+               }
        } else {
                // Inherited.
                tscrollbar_container::handle_key_up_arrow(modifier, handled);

Modified: trunk/src/gui/widgets/listbox.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.hpp?rev=33242&r1=33241&r2=33242&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.hpp (original)
+++ trunk/src/gui/widgets/listbox.hpp Sun Mar  1 17:24:29 2009
@@ -129,8 +129,8 @@
 
        /***** ***** ***** setters / getters for members ***** ****** *****/
 
-       // FIXME implement
-       void set_callback_value_change(void (*) (twidget* caller)) {}
+       void set_callback_value_change(void (*callback) (twidget* caller)) 
+               { callback_value_changed_ = callback; }
 
        void set_list_builder(tbuilder_grid_ptr list_builder)
                { list_builder_ = list_builder; }
@@ -217,6 +217,15 @@
        /** Contains the builder for the new items. */
        tbuilder_grid_const_ptr list_builder_;
 
+       /** 
+        * This callback is called when the value in the listbox changes.
+        *
+        * @todo the implementation of the callback hasn't been tested a lot 
and
+        * there might be too many calls. That might happen if an arrow up 
didn't
+        * change the selected item.
+        */
+       void (*callback_value_changed_) (twidget*);
+
        /** Inherited from tcontrol. */
        const std::string& get_control_type() const
                { static const std::string type = "listbox"; return type; }




Related Messages


Powered by MHonArc, Updated Sun Mar 01 17:40:06 2009