comparison 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
comparison
equal deleted inserted replaced
29:a33dfdc5b40a 30:b1d7e8a28dfa
96 char name[30]; 96 char name[30];
97 97
98 } SignalList; 98 } SignalList;
99 99
100 /* List of signals and their equivilent Win32 message */ 100 /* List of signals and their equivilent Win32 message */
101 #define SIGNALMAX 12 101 #define SIGNALMAX 13
102 102
103 SignalList SignalTranslate[SIGNALMAX] = { 103 SignalList SignalTranslate[SIGNALMAX] = {
104 { WM_SIZE, "configure_event" }, 104 { WM_SIZE, "configure_event" },
105 { WM_CHAR, "key_press_event" }, 105 { WM_CHAR, "key_press_event" },
106 { WM_LBUTTONDOWN, "button_press_event" }, 106 { WM_LBUTTONDOWN, "button_press_event" },
110 { WM_PAINT, "expose_event" }, 110 { WM_PAINT, "expose_event" },
111 { WM_COMMAND, "clicked" }, 111 { WM_COMMAND, "clicked" },
112 { NM_DBLCLK, "container-select" }, 112 { NM_DBLCLK, "container-select" },
113 { NM_RCLICK, "container-context" }, 113 { NM_RCLICK, "container-context" },
114 { LBN_SELCHANGE, "item-select" }, 114 { LBN_SELCHANGE, "item-select" },
115 { TVN_SELCHANGED, "tree-select" },
115 { WM_SETFOCUS, "set-focus" } 116 { WM_SETFOCUS, "set-focus" }
116 }; 117 };
117 118
118 #ifdef BUILD_DLL 119 #ifdef BUILD_DLL
119 void Win32_Set_Instance(HINSTANCE hInstance) 120 void Win32_Set_Instance(HINSTANCE hInstance)
981 command_active = 1; 982 command_active = 1;
982 983
983 /* Find any callbacks for this function */ 984 /* Find any callbacks for this function */
984 while(tmp) 985 while(tmp)
985 { 986 {
986 if(tmp->message == msg || msg == WM_COMMAND) 987 if(tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY)
987 { 988 {
988 switch(msg) 989 switch(msg)
989 { 990 {
990 case WM_SETFOCUS: 991 case WM_SETFOCUS:
991 { 992 {
1117 exp.y = ps.rcPaint.top; 1118 exp.y = ps.rcPaint.top;
1118 exp.width = ps.rcPaint.right - ps.rcPaint.left; 1119 exp.width = ps.rcPaint.right - ps.rcPaint.left;
1119 exp.height = ps.rcPaint.bottom - ps.rcPaint.top; 1120 exp.height = ps.rcPaint.bottom - ps.rcPaint.top;
1120 result = exposefunc(hWnd, &exp, tmp->data); 1121 result = exposefunc(hWnd, &exp, tmp->data);
1121 EndPaint(hWnd, &ps); 1122 EndPaint(hWnd, &ps);
1123 }
1124 }
1125 break;
1126 case WM_NOTIFY:
1127 {
1128 if(tmp->message == TVN_SELCHANGED)
1129 {
1130 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
1131 char tmpbuf[100];
1132
1133 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
1134
1135 if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0)
1136 {
1137 if(tem->hdr.code == TVN_SELCHANGED)
1138 {
1139 if(tmp->window == tem->hdr.hwndFrom)
1140 {
1141 int (*treeselectfunc)(HWND, HWND, char *, void *) = tmp->signalfunction;
1142 TVITEM tvi;
1143
1144 tvi.mask = TVIF_HANDLE;
1145 tvi.hItem = tem->itemNew.hItem;
1146
1147 TreeView_GetItem(tmp->window, &tvi);
1148
1149 result = treeselectfunc(tmp->window, (HWND)tem->itemNew.hItem, (char *)tvi.lParam, tmp->data);
1150
1151 tmp = NULL;
1152 }
1153 }
1154 }
1122 } 1155 }
1123 } 1156 }
1124 break; 1157 break;
1125 case WM_COMMAND: 1158 case WM_COMMAND:
1126 { 1159 {
4463 { 4496 {
4464 TVITEM tvi; 4497 TVITEM tvi;
4465 TVINSERTSTRUCT tvins; 4498 TVINSERTSTRUCT tvins;
4466 HTREEITEM hti; 4499 HTREEITEM hti;
4467 4500
4468 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE ; 4501 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
4469 tvi.pszText = title; 4502 tvi.pszText = title;
4503 tvi.lParam = (LONG)title;
4470 tvi.cchTextMax = strlen(title); 4504 tvi.cchTextMax = strlen(title);
4471 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); 4505 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
4472 4506
4473 tvins.item = tvi; 4507 tvins.item = tvi;
4474 tvins.hParent = (HTREEITEM)parent; 4508 tvins.hParent = (HTREEITEM)parent;
4475 tvins.hInsertAfter = TVI_LAST; 4509 tvins.hInsertAfter = TVI_LAST;
4476 4510
4477 hti = TreeView_InsertItem(handle, &tvins); 4511 hti = TreeView_InsertItem(handle, &tvins);
4478 4512
4479 return (HWND)hti; 4513 return (HWND)hti;
4514 }
4515
4516 /*
4517 * Removes all nodes from a tree.
4518 * Parameters:
4519 * handle: Handle to the window (widget) to be cleared.
4520 */
4521 void dw_tree_clear(HWND handle)
4522 {
4523 TreeView_DeleteAllItems(handle);
4524 }
4525
4526 /*
4527 * Removes a node from a tree.
4528 * Parameters:
4529 * handle: Handle to the window (widget) to be cleared.
4530 * item: Handle to node to be deleted.
4531 */
4532 void dw_tree_delete(HWND handle, HWND item)
4533 {
4534 TreeView_DeleteItem(handle, (HTREEITEM)item);
4480 } 4535 }
4481 4536
4482 /* 4537 /*
4483 * Sets up the container columns. 4538 * Sets up the container columns.
4484 * Parameters: 4539 * Parameters: