From badfb31888a6bd62e0a019b3f3dec517df4121ec Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 18 Sep 2010 22:11:27 +0000 Subject: trade updates --- src/ui/listitem.cc | 1 + src/ui/listitem.h | 10 ++++++++++ src/ui/listview.cc | 7 +++++++ src/ui/listview.h | 3 +++ src/ui/widget.cc | 9 +++++++++ src/ui/widget.h | 3 +++ 6 files changed, 33 insertions(+) (limited to 'src/ui') diff --git a/src/ui/listitem.cc b/src/ui/listitem.cc index dcd4e2a..601d5a8 100644 --- a/src/ui/listitem.cc +++ b/src/ui/listitem.cc @@ -15,6 +15,7 @@ ListItem::ListItem(ListView *parent, const char * text) : Label(parent, text) { set_label("listitem"); listitem_info = 0; + listitem_item = 0; } ListItem::~ListItem() { diff --git a/src/ui/listitem.h b/src/ui/listitem.h index cc03621..1d4cd33 100644 --- a/src/ui/listitem.h +++ b/src/ui/listitem.h @@ -10,6 +10,7 @@ #include #include "core/info.h" +#include "core/item.h" #include "ui/label.h" namespace ui @@ -30,9 +31,17 @@ public: return listitem_info; } + inline const core::Item *item() const { + return listitem_item; + } + inline void set_info(const core::Info *info) { listitem_info = info; } + + inline void set_item(const core::Item *item) { + listitem_item = item; + } protected: /// keypress event handler @@ -45,6 +54,7 @@ protected: private: const core::Info *listitem_info; + const core::Item *listitem_item; }; } // namespace ui diff --git a/src/ui/listview.cc b/src/ui/listview.cc index 646b168..e503807 100644 --- a/src/ui/listview.cc +++ b/src/ui/listview.cc @@ -73,6 +73,13 @@ void ListView::deselect() listview_selecteditem = 0; } +void ListView::select(ListItem *item) +{ + if (is_child(item)) { + listview_selecteditem = item; + } +} + void ListView::clear() { listview_selecteditem = 0; diff --git a/src/ui/listview.h b/src/ui/listview.h index a650348..a0c185b 100644 --- a/src/ui/listview.h +++ b/src/ui/listview.h @@ -53,6 +53,9 @@ public: /// clear all listitems void clear(); + /// set selection to specified ListItem + void select(ListItem *item); + /// set selection to nothing void deselect(); diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 5fe6f17..79281a1 100644 --- a/src/ui/widget.cc +++ b/src/ui/widget.cc @@ -47,6 +47,15 @@ void Widget::remove_children() widget_children.clear(); } +bool Widget::is_child(const Widget *widget) const +{ + for (Children::const_iterator it = widget_children.begin(); it != widget_children.end(); it++) { + if (widget == (*it)) + return true; + } + return false; +} + size_t Widget::list(const size_t indent, const bool visible_only) const { if (visible_only && !visible()) diff --git a/src/ui/widget.h b/src/ui/widget.h index 880b71c..3ae75d2 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -139,6 +139,9 @@ public: /// returns true if the widget has mouse focus bool has_mouse_focus() const; + + /// return true of the widget is a child widget + bool is_child(const Widget *widget) const; /* -- mutators --------------------------------------------- */ -- cgit v1.2.3