mail[Wesnoth-commits] r24541 - in /trunk/src/gui/widgets: button.cpp button.hpp settings.cpp widget.cpp widget.hpp


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

Header


Content

Posted by koraq on March 11, 2008 - 20:47:
Author: mordante
Date: Tue Mar 11 20:47:15 2008
New Revision: 24541

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24541&view=rev
Log:
Move the button class into it's own file and remove some ancient commented out
stuff.

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

Added: trunk/src/gui/widgets/button.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.cpp?rev=24541&view=auto
==============================================================================
--- trunk/src/gui/widgets/button.cpp (added)
+++ trunk/src/gui/widgets/button.cpp Tue Mar 11 20:47:15 2008
@@ -1,0 +1,57 @@
+/* $Id$ */
+/*
+   copyright (c) 2007 - 2008 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.
+*/
+
+#include "gui/widgets/button.hpp"
+
+#define DBG_GUI LOG_STREAM(debug, widget)
+#define LOG_GUI LOG_STREAM(info, widget)
+#define WRN_GUI LOG_STREAM(warn, widget)
+#define ERR_GUI LOG_STREAM(err, widget)
+
+namespace gui2 {
+
+void tbutton::set_width(const int width)
+{ 
+       // resize canvasses
+       canvas_up_.set_width(width);
+       canvas_up_mouse_over_.set_width(width);
+       canvas_down_.set_width(width);
+
+       // inherited
+       tcontrol::set_width(width);
+}
+
+void tbutton::set_height(const int height) 
+{ 
+       // resize canvasses
+       canvas_up_.set_height(height);
+       canvas_up_mouse_over_.set_height(height);
+       canvas_down_.set_height(height);
+
+       // inherited
+       tcontrol::set_height(height);
+}
+
+void tbutton::draw(surface& canvas)
+{
+       DBG_GUI << "Drawing button\n";
+
+       canvas_up_.draw();
+
+       // now blit the cached image on the screen
+       SDL_Rect rect = get_rect();
+       SDL_BlitSurface(canvas_up_.surf(), 0, canvas, &rect);
+}
+
+} // namespace gui2

Propchange: trunk/src/gui/widgets/button.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/src/gui/widgets/button.cpp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: trunk/src/gui/widgets/button.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.hpp?rev=24541&view=auto
==============================================================================
--- trunk/src/gui/widgets/button.hpp (added)
+++ trunk/src/gui/widgets/button.hpp Tue Mar 11 20:47:15 2008
@@ -1,0 +1,78 @@
+/* $Id$ */
+/*
+   copyright (c) 2007 - 2008 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_BUTTON_HPP_INCLUDED__
+#define __GUI_WIDGETS_BUTTON_HPP_INCLUDED__
+
+#include "gui/widgets/widget.hpp"
+
+#include "gui/widgets/settings.hpp"
+#include "log.hpp"
+
+namespace gui2 {
+
+// Class for a simple push button
+class tbutton : public tcontrol
+{
+       friend void load_settings();
+public:
+       tbutton(const std::string& id) : 
+               tcontrol()
+               {
+                       canvas_up_.set_cfg(tbutton::default_enabled_draw_);
+               }
+
+       virtual void set_width(const int width);
+
+       virtual void set_height(const int height);
+
+       void mouse_down(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse down\n"; }
+       void mouse_up(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse up\n"; }
+       void mouse_click(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse click\n"; }
+       void mouse_double_click(const tevent_info& /*event*/, bool& 
/*handled*/) { std::cerr << "mouse double click\n"; }
+       void mouse_enter(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse enter\n"; }
+       void mouse_leave(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse leave\n"; }
+
+       void draw(surface& canvas);
+
+       // note we should check whether the label fits in the button
+       tpoint get_best_size() const { return tpoint(default_width_, 
default_height_); }
+
+       void set_best_size(const tpoint& origin) 
+       {
+               set_x(origin.x);
+               set_y(origin.y);
+               set_width(default_width_);
+               set_height(default_height_);
+       }
+
+protected:
+       
+private:
+
+       tcanvas 
+               canvas_up_,
+               canvas_up_mouse_over_,
+               canvas_down_;
+
+       static unsigned default_width_;
+       static unsigned default_height_;
+       static config default_enabled_draw_;
+};
+
+
+} // namespace gui2
+
+#endif
+

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

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

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=24541&r1=24540&r2=24541&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Tue Mar 11 20:47:15 2008
@@ -19,6 +19,7 @@
 
 #include "config.hpp"
 #include "filesystem.hpp"
+#include "gui/widgets/button.hpp"
 #include "gui/widgets/widget.hpp"
 #include "log.hpp"
 #include "serialization/parser.hpp"

Modified: trunk/src/gui/widgets/widget.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.cpp?rev=24541&r1=24540&r2=24541&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.cpp (original)
+++ trunk/src/gui/widgets/widget.cpp Tue Mar 11 20:47:15 2008
@@ -28,7 +28,7 @@
 #define WRN_GUI LOG_STREAM(warn, widget)
 #define ERR_GUI LOG_STREAM(err, widget)
 
-namespace gui2{
+namespace gui2 {
 
 namespace {
        static bool initialized_ = false;
@@ -348,75 +348,4 @@
 {
 }
 
-void tbutton::set_width(const int width)
-{ 
-       // resize canvasses
-       canvas_up_.set_width(width);
-       canvas_up_mouse_over_.set_width(width);
-       canvas_down_.set_width(width);
-
-       // inherited
-       tcontrol::set_width(width);
-}
-
-void tbutton::set_height(const int height) 
-{ 
-       // resize canvasses
-       canvas_up_.set_height(height);
-       canvas_up_mouse_over_.set_height(height);
-       canvas_down_.set_height(height);
-
-       // inherited
-       tcontrol::set_height(height);
-}
-
-void tbutton::draw(surface& canvas)
-{
-       // create a dummy config with some objects to draw
-
-       DBG_GUI << "Drawing button\n";
-#if 0  
-       std::string dummy = 
-               "[line]\n"
-               "    x1, y1 = 0, 0\n"
-               "    x2, y2 = -1, 0\n"
-               "    colour = 255, 255, 255, 255\n"
-               "    thickness = 1\n"
-               "[/line]\n"
-
-               "[line]\n"
-               "    x1, y1 = -1, 0\n"
-               "    x2, y2 = -1, -1\n"
-               "    colour = 255, 255, 255, 255\n"
-               "    thickness = 1\n"
-               "[/line]\n"
-
-               "[line]\n"
-               "    x1, y1 = -1, -1\n"
-               "    x2, y2 = 0, -1\n"
-               "    colour = 0, 0, 0, 255\n"
-               "    thickness = 1\n"
-               "[/line]\n"
-
-               "[line]\n"
-               "    x1, y1 = 0, -1\n"
-               "    x2, y2 = 0, 0\n"
-               "    colour = 0, 0, 0, 255\n"
-               "    thickness = 1\n"
-               "[/line]\n";
-
-       config cfg; 
-       read(cfg, dummy);
-#endif
-//     const config* cfg = button_enabled();
-
-//     canvas_up_.draw(*cfg);
-
-       canvas_up_.draw();
-
-       // now blit the cached image on the screen
-       SDL_Rect rect = get_rect();
-       SDL_BlitSurface(canvas_up_.surf(), 0, canvas, &rect);
-}
-
-}
+} // namespace gui2

Modified: trunk/src/gui/widgets/widget.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=24541&r1=24540&r2=24541&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Tue Mar 11 20:47:15 2008
@@ -524,55 +524,6 @@
 */
 
 
-// Class for a simple push button
-class tbutton : public tcontrol
-{
-       friend void load_settings();
-public:
-       tbutton(const std::string& id) : 
-               tcontrol()
-               {
-                       canvas_up_.set_cfg(tbutton::default_enabled_draw_);
-               }
-
-       virtual void set_width(const int width);
-
-       virtual void set_height(const int height);
-
-       void mouse_down(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse down\n"; }
-       void mouse_up(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse up\n"; }
-       void mouse_click(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse click\n"; }
-       void mouse_double_click(const tevent_info& /*event*/, bool& 
/*handled*/) { std::cerr << "mouse double click\n"; }
-       void mouse_enter(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse enter\n"; }
-       void mouse_leave(const tevent_info& /*event*/, bool& /*handled*/) { 
std::cerr << "mouse leave\n"; }
-
-       void draw(surface& canvas);
-
-       // note we should check whether the label fits in the button
-       tpoint get_best_size() const { return tpoint(default_width_, 
default_height_); }
-
-       void set_best_size(const tpoint& origin) 
-       {
-               set_x(origin.x);
-               set_y(origin.y);
-               set_width(default_width_);
-               set_height(default_height_);
-       }
-
-protected:
-       
-private:
-
-       tcanvas 
-               canvas_up_,
-               canvas_up_mouse_over_,
-               canvas_down_;
-
-       static unsigned default_width_;
-       static unsigned default_height_;
-       static config default_enabled_draw_;
-};
-
 /**
  * A widget has a mouse over which can either popup directly or after a 
fixed delay (this is a flag)
  * A widget has a help after pressing F1 it shows a larger tooltip with more 
info
@@ -694,6 +645,7 @@
 [/image]
 
 #endif
-}
+
+} // namespace gui2
 
 #endif




Related Messages


Powered by MHonArc, Updated Tue Mar 11 21:21:11 2008