(svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet) cpp_gui
authorKUDr
Sun, 18 Feb 2007 19:55:35 +0000
branchcpp_gui
changeset 6260 740c702f6871
parent 6259 0f36789984b1
child 6261 5fd6b1cfa424
(svn r8804) [cpp_gui] -Codechange: BaseWindow now inherits from CompositeWidget (with no benefits yet)
-CompositeWidget is no longer abstract (added OnLeftClick() to it)
src/widget/widget_composite.cpp
src/window.h
--- a/src/widget/widget_composite.cpp	Sun Feb 18 19:45:00 2007 +0000
+++ b/src/widget/widget_composite.cpp	Sun Feb 18 19:55:35 2007 +0000
@@ -77,3 +77,13 @@
 	/* mark self as closed */
 	super::Close();
 }
+
+/*virtual*/ bool CompositeWidget::OnLeftClick(WindowEvent *ev)
+{
+	//Point16 pt(ev->we.click.pt.x, ev->we.click.pt.y);
+	Widget *wd_child = WidgetFromPt(ev->we.click.pt);
+	if (wd_child != NULL) {
+		return wd_child->OnLeftClick(ev);
+	}
+	return false;
+}
--- a/src/window.h	Sun Feb 18 19:45:00 2007 +0000
+++ b/src/window.h	Sun Feb 18 19:55:35 2007 +0000
@@ -338,6 +338,11 @@
 	bool m_dont_clip : 1;               ///< should not be clipped by parent (container)
 	StringID m_tooltips;                ///< Tooltips that are shown when rightclicking on a widget
 
+	Widget()
+		: m_container(NULL), m_id(0), m_rect(), m_data(0), m_display_flags(0), m_color(0)
+		, m_is_closing(false), m_tooltips(0)
+	{}
+
 	Widget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
 		: m_container(container)
 		, m_id(id)
@@ -388,6 +393,10 @@
 	Widgets m_widgets;
 
 public:
+	CompositeWidget()
+		: Widget()
+	{}
+
 	CompositeWidget(CompositeWidget *container, WidgetId id, byte display_flags, byte color, const Rect16 &rect, StringID tooltips)
 		: Widget(container, id, display_flags, color, rect, tooltips)
 	{}
@@ -399,6 +408,8 @@
 	/*virtual*/ Widget* WidgetFromPt(const Point16 &pt);
 
 	virtual void Close();
+
+	/*virtual*/ bool OnLeftClick(WindowEvent *ev);
 };
 
 
@@ -480,7 +491,7 @@
 
 };
 
-struct BaseWindow : public SimpleCountedObject {
+struct BaseWindow : public CompositeWidget {
 public:
 	static WindowList s_list;