diff win/dw.c @ 30:b1d7e8a28dfa

Added tree view functions and signal.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 25 Aug 2001 05:39:33 +0000
parents 6a246b3bb14f
children f3bf96c2786d
line wrap: on
line diff
--- a/win/dw.c	Fri Aug 17 12:25:52 2001 +0000
+++ b/win/dw.c	Sat Aug 25 05:39:33 2001 +0000
@@ -98,7 +98,7 @@
 } SignalList;
 
 /* List of signals and their equivilent Win32 message */
-#define SIGNALMAX 12
+#define SIGNALMAX 13
 
 SignalList SignalTranslate[SIGNALMAX] = {
 	{ WM_SIZE, "configure_event" },
@@ -112,6 +112,7 @@
 	{ NM_DBLCLK, "container-select" },
 	{ NM_RCLICK, "container-context" },
 	{ LBN_SELCHANGE, "item-select" },
+	{ TVN_SELCHANGED, "tree-select" },
 	{ WM_SETFOCUS, "set-focus" }
 };
 
@@ -983,7 +984,7 @@
 		/* Find any callbacks for this function */
 		while(tmp)
 		{
-			if(tmp->message == msg || msg == WM_COMMAND)
+			if(tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY)
 			{
 				switch(msg)
 				{
@@ -1122,6 +1123,38 @@
 						}
 					}
 					break;
+				case WM_NOTIFY:
+					{
+						if(tmp->message == TVN_SELCHANGED)
+						{
+							NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
+							char tmpbuf[100];
+
+							GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
+
+							if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0)
+							{
+								if(tem->hdr.code == TVN_SELCHANGED)
+								{
+									if(tmp->window == tem->hdr.hwndFrom)
+									{
+										int (*treeselectfunc)(HWND, HWND, char *, void *) = tmp->signalfunction;
+                                        TVITEM tvi;
+
+										tvi.mask = TVIF_HANDLE;
+										tvi.hItem = tem->itemNew.hItem;
+
+										TreeView_GetItem(tmp->window, &tvi);
+
+										result = treeselectfunc(tmp->window, (HWND)tem->itemNew.hItem, (char *)tvi.lParam, tmp->data);
+
+										tmp = NULL;
+									}
+								}
+							}
+						}
+					}
+					break;
 				case WM_COMMAND:
 					{
 						int (*clickfunc)(HWND, void *) = tmp->signalfunction;
@@ -4465,8 +4498,9 @@
 	TVINSERTSTRUCT tvins;
 	HTREEITEM hti;
 
-	tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
+	tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
 	tvi.pszText = title;
+	tvi.lParam = (LONG)title;
 	tvi.cchTextMax = strlen(title);
 	tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
 
@@ -4480,6 +4514,27 @@
 }
 
 /*
+ * Removes all nodes from a tree.
+ * Parameters:
+ *       handle: Handle to the window (widget) to be cleared.
+ */
+void dw_tree_clear(HWND handle)
+{
+	TreeView_DeleteAllItems(handle);
+}
+
+/*
+ * Removes a node from a tree.
+ * Parameters:
+ *       handle: Handle to the window (widget) to be cleared.
+ *       item: Handle to node to be deleted.
+ */
+void dw_tree_delete(HWND handle, HWND item)
+{
+	TreeView_DeleteItem(handle, (HTREEITEM)item);
+}
+
+/*
  * Sets up the container columns.
  * Parameters:
  *          handle: Handle to the container to be configured.