Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-18 22:11:27 +0000
committerStijn Buys <ingar@osirion.org>2010-09-18 22:11:27 +0000
commitbadfb31888a6bd62e0a019b3f3dec517df4121ec (patch)
tree94cb95e405c05f013c8ae4f66a0b973aa5e59b3a /src/ui
parent9c91a9767b570fdc3c3e19e1f452f9a8257f9999 (diff)
trade updates
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/listitem.cc1
-rw-r--r--src/ui/listitem.h10
-rw-r--r--src/ui/listview.cc7
-rw-r--r--src/ui/listview.h3
-rw-r--r--src/ui/widget.cc9
-rw-r--r--src/ui/widget.h3
6 files changed, 33 insertions, 0 deletions
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 <string>
#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 --------------------------------------------- */