mail[Wesnoth-commits] r40215 - in /trunk: changelog src/gui/widgets/button.cpp src/gui/widgets/button.hpp src/gui/widgets/clickable.hpp


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

Header


Content

Posted by koraq on December 13, 2009 - 14:55:
Author: mordante
Date: Sun Dec 13 14:55:57 2009
New Revision: 40215

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40215&view=rev
Log:
Add a extra generic button class.

This base class is used by tbutton and will also be used by a repeating button
variant. (That button will be added once finished.)

Added:
    trunk/src/gui/widgets/clickable.hpp   (with props)
Modified:
    trunk/changelog
    trunk/src/gui/widgets/button.cpp
    trunk/src/gui/widgets/button.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=40215&r1=40214&r2=40215&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Dec 13 14:55:57 2009
@@ -23,6 +23,7 @@
    * MP lobby refresh to the new timer engine
    * Change Drake Flare and Flameheart weapon names to match new weapons
    * Add a minimap cache for gui2
+   * Add a new super class for the button
 
 Version 1.7.9-beta2:
  * AI:

Modified: trunk/src/gui/widgets/button.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.cpp?rev=40215&r1=40214&r2=40215&view=diff
==============================================================================
--- trunk/src/gui/widgets/button.cpp (original)
+++ trunk/src/gui/widgets/button.cpp Sun Dec 13 14:55:57 2009
@@ -29,6 +29,7 @@
 
 tbutton::tbutton()
        : tcontrol(COUNT)
+       , tclickable_()
        , state_(ENABLED)
        , retval_(0)
        , callback_mouse_left_click_(0)

Modified: trunk/src/gui/widgets/button.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.hpp?rev=40215&r1=40214&r2=40215&view=diff
==============================================================================
--- trunk/src/gui/widgets/button.hpp (original)
+++ trunk/src/gui/widgets/button.hpp Sun Dec 13 14:55:57 2009
@@ -16,13 +16,16 @@
 #define GUI_WIDGETS_BUTTON_HPP_INCLUDED
 
 #include "gui/widgets/control.hpp"
+#include "gui/widgets/clickable.hpp"
 
 namespace gui2 {
 
 /**
  * Simple push button.
  */
-class tbutton : public tcontrol
+class tbutton
+       : public tcontrol
+       , public tclickable_
 {
 public:
        tbutton();
@@ -63,6 +66,18 @@
 
        /** Inherited from tcontrol. */
        unsigned get_state() const { return state_; }
+
+       /** Inherited from tclickable. */
+       void connect_click_handler(const event::tsignal_function& signal)
+       {
+               connect_signal_mouse_left_click(signal);
+       }
+
+       /** Inherited from tclickable. */
+       void disconnect_click_handler(const event::tsignal_function& signal)
+       {
+               disconnect_signal_mouse_left_click(signal);
+       }
 
        /***** ***** ***** setters / getters for members ***** ****** *****/
 

Added: trunk/src/gui/widgets/clickable.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/clickable.hpp?rev=40215&view=auto
==============================================================================
--- trunk/src/gui/widgets/clickable.hpp (added)
+++ trunk/src/gui/widgets/clickable.hpp Sun Dec 13 14:55:57 2009
@@ -1,0 +1,54 @@
+/* $Id$ */
+/*
+   Copyright (C) 2009 by Mark de Wever <koraq@xxxxxxxxx>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License version 2
+   or at your option any later version.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
+#ifndef GUI_WIDGETS_CLICKABLE_HPP_INCLUDED
+#define GUI_WIDGETS_CLICKABLE_HPP_INCLUDED
+
+namespace gui2 {
+
+/**
+ * Small abstract helper class.
+ *
+ * Parts of the engine inherit this class so we can have generic
+ * clickable items. This is mainly for the button and the repeating button
+ * classes.
+ */
+class tclickable_
+{
+public:
+       virtual ~tclickable_() {}
+
+       /**
+        * Connects a signal handler for a 'click' event.
+        *
+        * What the click is depends on the subclass.
+        *
+        * @param signal              The signal to connect.
+        */
+       virtual void connect_click_handler(const event::tsignal_function& 
signal) = 0;
+
+       /**
+        * Disconnects a signal handler for a 'click' event.
+        *
+        * What the click is depends on the subclass.
+        *
+        * @param signal              The signal to disconnect (should be the 
same
+        *                            as send to the connect call.
+        */
+       virtual void disconnect_click_handler(const event::tsignal_function& 
signal) = 0;
+};
+
+} // namespace gui2
+
+#endif

Propchange: trunk/src/gui/widgets/clickable.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/widgets/clickable.hpp
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"




Related Messages


Powered by MHonArc, Updated Sun Dec 13 15:00:08 2009