mail[Wesnoth-commits] r27093 - in /trunk/src/gui/widgets: widget.cpp widget.hpp window.cpp window.hpp


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

Header


Content

Posted by koraq on June 10, 2008 - 23:43:
Author: mordante
Date: Tue Jun 10 23:27:15 2008
New Revision: 27093

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27093&view=rev
Log:
Add a dialog() function so a widget can find the dialog that owns it. This is
needed to allow callbacks call dialog methods.

Modified:
    trunk/src/gui/widgets/widget.cpp
    trunk/src/gui/widgets/widget.hpp
    trunk/src/gui/widgets/window.cpp
    trunk/src/gui/widgets/window.hpp

Modified: trunk/src/gui/widgets/widget.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.cpp?rev=27093&r1=27092&r2=27093&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.cpp (original)
+++ trunk/src/gui/widgets/widget.cpp Tue Jun 10 23:27:15 2008
@@ -58,4 +58,10 @@
        return dynamic_cast<twindow*>(result);
 }
 
+tdialog* twidget::dialog()
+{
+       twindow* window = get_window();
+       return window ? window->dialog() : 0;
+}
+
 } // namespace gui2

Modified: trunk/src/gui/widgets/widget.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=27093&r1=27092&r2=27093&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Tue Jun 10 23:27:15 2008
@@ -24,7 +24,9 @@
 
 namespace gui2 {
 
+class tdialog;
 class tevent_handler;
+class twindow;
 
 //! Base class with all possible events, most widgets can ignore most of
 //! these, but they are available.
@@ -109,8 +111,6 @@
        bool wants_mouse_middle_double_click_;
        bool wants_mouse_right_double_click_;
 };
-
-class twindow;
 
 //! Base class for all widgets.
 //! This is a non visible widget but it does have dimentions and size hints.
@@ -237,6 +237,18 @@
        //! The toplevel item should always be a window if not null is 
returned
        twindow* get_window();
 
+       /** 
+        * Returns the toplevel dialog.
+        *
+        * A window is most of the time created by a dialog, this function 
returns
+        * that dialog.
+        *
+        * @returns                   The toplevel dialog.
+        * @retval 0                  No toplevel window or the toplevel 
window is
+        *                            not owned by a dialog.
+        */
+       tdialog* dialog();
+
        //! loads the configuration of the widget, mainly used for controls.
        virtual void load_config() {} 
 

Modified: trunk/src/gui/widgets/window.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=27093&r1=27092&r2=27093&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Tue Jun 10 23:27:15 2008
@@ -60,6 +60,7 @@
        video_(video),
        status_(NEW),
        retval_(0),
+       owner_(0),
        need_layout_(true),
        tooltip_(),
        help_popup_(),

Modified: trunk/src/gui/widgets/window.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=27093&r1=27092&r2=27093&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Tue Jun 10 23:27:15 2008
@@ -40,6 +40,9 @@
 #include <map>
 
 namespace gui2{
+
+class tdialog;
+
 /**
  * base class of top level items, the only item 
  * which needs to store the final canvase to draw on
@@ -75,6 +78,11 @@
        //! Inherited from tevent_handler.
        twindow& get_window() { return *this; }
        const twindow& get_window() const { return *this; }
+
+       void set_owner(tdialog* owner) { owner_ = owner; }
+
+       /** Inherited from twidget. */
+       tdialog* dialog() { return owner_; }
 
        /** Inherited from tevent_handler. */
        twidget* find_widget(const tpoint& coordinate, const bool 
must_be_active) 
@@ -140,9 +148,11 @@
        // return value of the window, 0 default.
        int retval_;
 
+       /** The dialog that owns the window. */
+       tdialog* owner_;
+
        //! When set the form needs a full layout redraw cycle.
        bool need_layout_;
-
 
        //! Inherited from tevent_handler.
        void do_show_tooltip(const tpoint& location, const t_string& tooltip);




Related Messages


Powered by MHonArc, Updated Wed Jun 11 00:01:54 2008