Author: mordante
Date: Fri Jul 18 23:31:55 2008
New Revision: 28083

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28083&view=rev
Log:
Make set_active work for container classes (not much tested yet).

Modified:
    trunk/src/gui/widgets/container.cpp
    trunk/src/gui/widgets/container.hpp
    trunk/src/gui/widgets/listbox.hpp
    trunk/src/gui/widgets/menubar.hpp
    trunk/src/gui/widgets/panel.hpp
    trunk/src/gui/widgets/window.hpp

Modified: trunk/src/gui/widgets/container.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.cpp?rev=28083&r1=28082&r2=28083&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.cpp (original)
+++ trunk/src/gui/widgets/container.cpp Fri Jul 18 23:31:55 2008
@@ -83,5 +83,20 @@
        grid_.draw(surface, force, redraw_background);
 }
 
+void tcontainer_::set_active(const bool active)
+{
+       // Not all our children might have the proper state so let them run
+       // unconditionally.
+       grid_.set_active(active);
+
+       if(active == get_active()) {
+               return;
+       }
+
+       set_dirty();
+
+       set_self_active(active);
+}
+
 } // namespace gui2
 

Modified: trunk/src/gui/widgets/container.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.hpp?rev=28083&r1=28082&r2=28083&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.hpp (original)
+++ trunk/src/gui/widgets/container.hpp Fri Jul 18 23:31:55 2008
@@ -98,6 +98,9 @@
                set_client_size(get_client_rect());
        }
 
+       /** Inherited from tcontrol. */
+       void set_active(const bool active);
+
        /***** **** ***** ***** wrappers to the grid **** ********* *****/
 
        tgrid::iterator begin() { return grid_.begin(); }
@@ -147,6 +150,15 @@
        /** Returns the space used by the border. */
        virtual tpoint border_space() const { return tpoint(0, 0); }
 
+       /**
+        * Helper for set_active.
+        *
+        * This function should set the control itself active. It's called by
+        * set_active if the state needs to change. The widget is set to 
dirty() by
+        * set_active so we only need to change the state.
+        */
+       virtual void set_self_active(const bool active) = 0;
+
        /** 
         * If the background has been changed the next draw cycle needs to do a 
full
         * redraw and also tell the child items to invalidate their background. 
This

Modified: trunk/src/gui/widgets/listbox.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.hpp?rev=28083&r1=28082&r2=28083&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.hpp (original)
+++ trunk/src/gui/widgets/listbox.hpp Fri Jul 18 23:31:55 2008
@@ -37,8 +37,6 @@
        
        tlistbox();
 
-       // FIXME this might not the right thing to do.
-       void set_active(const bool active) { set_state(active ? ENABLED : 
DISABLED); };
        bool get_active() const { return state_ != DISABLED; }
        unsigned get_state() const { return state_; }
 
@@ -263,6 +261,10 @@
        const std::string& get_control_type() const 
                { static const std::string type = "listbox"; return type; }
 
+       /** Inherited from tcontainer_. */
+       void set_self_active(const bool active) 
+               { state_ = active ? ENABLED : DISABLED; }
+
        /** The (lastly) selected row */
        unsigned selected_row_;
 

Modified: trunk/src/gui/widgets/menubar.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/menubar.hpp?rev=28083&r1=28082&r2=28083&view=diff
==============================================================================
--- trunk/src/gui/widgets/menubar.hpp (original)
+++ trunk/src/gui/widgets/menubar.hpp Fri Jul 18 23:31:55 2008
@@ -47,9 +47,6 @@
        size_t get_item_count() const;
 
        /***** ***** ***** ***** Inherited ***** ***** ***** *****/
-
-       /** Inherited from tcontrol. */
-       void set_active(const bool active) {} ; // FIXME implement
 
        /** Inherited from tcontrol. */
        bool get_active() const { return state_ != DISABLED; }
@@ -114,6 +111,10 @@
        /** The builder needs to call us so we can wire in the proper 
callbacks. */
        void finalize_setup();
 
+       /** Inherited from tcontainer_. */
+       void set_self_active(const bool active) 
+               { state_ = active ? ENABLED : DISABLED; }
+
        /** Inherited from tcontrol. */
        const std::string& get_control_type() const 
                { static const std::string type = "menubar"; return type; }

Modified: trunk/src/gui/widgets/panel.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/panel.hpp?rev=28083&r1=28082&r2=28083&view=diff
==============================================================================
--- trunk/src/gui/widgets/panel.hpp (original)
+++ trunk/src/gui/widgets/panel.hpp Fri Jul 18 23:31:55 2008
@@ -51,9 +51,6 @@
        virtual SDL_Rect get_client_rect() const;
 
        /** Inherited from tcontrol. */
-       void set_active(const bool /*active*/) {}
-
-       /** Inherited from tcontrol. */
        bool get_active() const { return true; }
 
        /** Inherited from tcontrol. */
@@ -75,6 +72,9 @@
        /** Inherited from tcontainer_. */
        tpoint border_space() const;
 
+       /** Inherited from tcontainer_. */
+       void set_self_active(const bool /*active*/) {}
+
 }; 
 
 } // namespace gui2

Modified: trunk/src/gui/widgets/window.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=28083&r1=28082&r2=28083&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Fri Jul 18 23:31:55 2008
@@ -117,8 +117,7 @@
        void window_resize(tevent_handler&, 
                const unsigned new_width, const unsigned new_height);
 
-       //! A window is always active atm so ignore the request.
-       void set_active(const bool /*active*/) {}
+       //! At the moment a window is always active.
        bool get_active() const { return true; }
        unsigned get_state() const { return 0; }
        bool needs_full_redraw() const { return false; /* FIXME IMPLEMENT */ }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to