changeset 317:83edbd751da9

Added dw_tree_get_data() to get a tree item's data.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 03 Apr 2003 00:29:46 +0000
parents a07e08f708d6
children f452ef00e193
files dw.def dw.h dww.def gtk/dw.c os2/dw.c win/dw.c
diffstat 6 files changed, 78 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dw.def	Wed Apr 02 11:31:38 2003 +0000
+++ b/dw.def	Thu Apr 03 00:29:46 2003 +0000
@@ -217,8 +217,9 @@
   dw_tree_item_select                    @377
   dw_tree_set_data                       @378
   dw_tree_insert_after                   @379
+  dw_tree_get_data                       @380
 
-  dw_font_text_extents                   @380
+  dw_font_text_extents                   @385
 
   dw_slider_new                          @390
   dw_slider_query_pos                    @391
--- a/dw.h	Wed Apr 02 11:31:38 2003 +0000
+++ b/dw.h	Thu Apr 03 00:29:46 2003 +0000
@@ -839,6 +839,7 @@
 void API dw_tree_collapse(HWND handle, HWND item);
 void API dw_tree_item_select(HWND handle, HWND item);
 void API dw_tree_set_data(HWND handle, HWND item, void *itemdata);
+void * API dw_tree_get_data(HWND handle, HWND item);
 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator);
 unsigned long API dw_icon_load(unsigned long module, unsigned long id);
 unsigned long API dw_icon_load_from_file(char *filename);
--- a/dww.def	Wed Apr 02 11:31:38 2003 +0000
+++ b/dww.def	Thu Apr 03 00:29:46 2003 +0000
@@ -214,8 +214,9 @@
   dw_tree_item_select                    @377
   dw_tree_set_data                       @378
   dw_tree_insert_after                   @379
+  dw_tree_get_data                       @380
 
-  dw_font_text_extents                   @380
+  dw_font_text_extents                   @385
 
   dw_slider_new                          @390
   dw_slider_query_pos                    @391
--- a/gtk/dw.c	Wed Apr 02 11:31:38 2003 +0000
+++ b/gtk/dw.c	Thu Apr 03 00:29:46 2003 +0000
@@ -3946,6 +3946,42 @@
 }
 
 /*
+ * Gets the item data of a tree item.
+ * Parameters:
+ *          handle: Handle to the tree containing the item.
+ *          item: Handle of the item to be modified.
+ */
+void *dw_tree_get_data(HWND handle, HWND item)
+{
+	void *ret = NULL;
+#if GTK_MAJOR_VERSION > 1
+	GtkWidget *tree;
+	GtkTreeStore *store;
+	int _locked_by_me = FALSE;
+
+	if(!handle || !item)
+		return;
+
+	DW_MUTEX_LOCK;
+	if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
+		&& GTK_IS_TREE_VIEW(tree) &&
+		(store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
+			gtk_tree_model_get(store, (GtkTreeIter *)item, 2, &ret, -1);
+	DW_MUTEX_UNLOCK;
+#else
+	int _locked_by_me = FALSE;
+
+	if(!handle || !item)
+		return;
+
+	DW_MUTEX_LOCK;
+	ret = (void *)gtk_object_get_data(GTK_OBJECT(item), "itemdata");
+	DW_MUTEX_UNLOCK;
+#endif
+	return ret;
+}
+
+/*
  * Sets this item as the active selection.
  * Parameters:
  *       handle: Handle to the tree window (widget) to be selected.
--- a/os2/dw.c	Wed Apr 02 11:31:38 2003 +0000
+++ b/os2/dw.c	Thu Apr 03 00:29:46 2003 +0000
@@ -5716,6 +5716,21 @@
 }
 
 /*
+ * Gets the item data of a tree item.
+ * Parameters:
+ *          handle: Handle to the tree containing the item.
+ *          item: Handle of the item to be modified.
+ */
+void * API dw_tree_get_data(HWND handle, HWND item)
+{
+	PCNRITEM pci = (PCNRITEM)item;
+
+	if(!pci)
+		return NULL;
+	return pci->user;
+}
+
+/*
  * Sets this item as the active selection.
  * Parameters:
  *       handle: Handle to the tree window (widget) to be selected.
--- a/win/dw.c	Wed Apr 02 11:31:38 2003 +0000
+++ b/win/dw.c	Thu Apr 03 00:29:46 2003 +0000
@@ -5839,6 +5839,28 @@
 }
 
 /*
+ * Gets the item data of a tree item.
+ * Parameters:
+ *          handle: Handle to the tree containing the item.
+ *          item: Handle of the item to be modified.
+ */
+void * API dw_tree_set_data(HWND handle, HWND item)
+{
+	TVITEM tvi;
+	void **ptrs;
+
+	tvi.mask = TVIF_HANDLE;
+	tvi.hItem = (HTREEITEM)item;
+
+	if(TreeView_GetItem(handle, &tvi))
+	{
+		ptrs = (void **)tvi.lParam;
+		return ptrs[1];
+	}
+	return NULL;
+}
+
+/*
  * Sets this item as the active selection.
  * Parameters:
  *       handle: Handle to the tree window (widget) to be selected.