# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1049824051 0 # Node ID e00aff2b899e4e8d99b146f8381e94a22892b426 # Parent 3204b978e07711a929d7480f180e45149d19f295 Tree item handles are now of the type HTREEITEM instead of HWND since they were rarely actually window handles. diff -r 3204b978e077 -r e00aff2b899e dw.h --- a/dw.h Tue Apr 08 09:36:02 2003 +0000 +++ b/dw.h Tue Apr 08 17:47:31 2003 +0000 @@ -205,6 +205,7 @@ HWND handle; } *HPIXMAP; +typedef void *HTREEITEM; typedef HWND HMENUI; typedef HMODULE HMOD; typedef unsigned short UWORD; @@ -622,6 +623,7 @@ } *HPIXMAP; typedef GtkWidget *HMENUI; +typedef void *HTREEITEM; #define DW_NOMENU NULL @@ -832,16 +834,16 @@ long API dw_spinbutton_query(HWND handle); int API dw_checkbox_query(HWND handle); void API dw_checkbox_set(HWND handle, int value); -HWND API dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata); -HWND API dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata); +HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata); +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata); void API dw_tree_clear(HWND handle); -void API dw_tree_delete(HWND handle, HWND item); -void API dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon); -void API dw_tree_expand(HWND handle, HWND item); -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); +void API dw_tree_delete(HWND handle, HTREEITEM item); +void API dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon); +void API dw_tree_expand(HWND handle, HTREEITEM item); +void API dw_tree_collapse(HWND handle, HTREEITEM item); +void API dw_tree_item_select(HWND handle, HTREEITEM item); +void API dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata); +void * API dw_tree_get_data(HWND handle, HTREEITEM 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); diff -r 3204b978e077 -r e00aff2b899e dwtest.c --- a/dwtest.c Tue Apr 08 09:36:02 2003 +0000 +++ b/dwtest.c Tue Apr 08 17:47:31 2003 +0000 @@ -376,7 +376,7 @@ return 0; } -int DWSIGNAL item_select_cb( HWND window, HWND item, char *text, void *data, void *itemdata ) +int DWSIGNAL item_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) { char buf[200]; HWND statline = (HWND)data; @@ -504,7 +504,7 @@ void tree_add(void) { - HWND t1,t2,t3,t4,t5,t6; + HTREEITEM t1,t2,t3,t4,t5,t6; /* create a box to pack into the notebook page */ treebox = dw_box_new(BOXHORZ, 2); diff -r 3204b978e077 -r e00aff2b899e gtk/dw.c --- a/gtk/dw.c Tue Apr 08 09:36:02 2003 +0000 +++ b/gtk/dw.c Tue Apr 08 17:47:31 2003 +0000 @@ -483,7 +483,7 @@ if(work) { - int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func; + int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work->func; GtkTreeIter iter; char *text = NULL; void *itemdata = NULL; @@ -493,7 +493,7 @@ { GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1); - retval = treeselectfunc(work->window, item, text, work->data, itemdata); + retval = treeselectfunc(work->window, (HTREEITEM)item, text, work->data, itemdata); } } return retval; @@ -515,10 +515,10 @@ if(work) { - int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func; + int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work->func; char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text"); void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "itemdata"); - retval = treeselectfunc(work->window, child, text, work->data, itemdata); + retval = treeselectfunc(work->window, (HTREEITEM)child, text, work->data, itemdata); } return retval; } @@ -3614,14 +3614,14 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) +HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HWND parent, void *itemdata) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; GtkTreeIter *iter; GtkTreeStore *store; GdkPixbuf *pixbuf; - HWND retval = 0; + HTREEITEM retval = 0; int _locked_by_me = FALSE; if(!handle) @@ -3640,7 +3640,7 @@ gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); if(pixbuf) g_object_unref(pixbuf); - retval = (HWND)iter; + retval = (HTREEITEM)iter; } DW_MUTEX_UNLOCK; @@ -3727,7 +3727,7 @@ gtk_tree_item_collapse(GTK_TREE_ITEM(newitem)); gtk_widget_show(newitem); DW_MUTEX_UNLOCK; - return newitem; + return (HTREEITEM)newitem; #endif } @@ -3740,14 +3740,14 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) +HTREEITEM dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; GtkTreeIter *iter; GtkTreeStore *store; GdkPixbuf *pixbuf; - HWND retval = 0; + HTREEITEM retval = 0; int _locked_by_me = FALSE; if(!handle) @@ -3766,7 +3766,7 @@ gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); if(pixbuf) g_object_unref(pixbuf); - retval = (HWND)iter; + retval = (HTREEITEM)iter; } DW_MUTEX_UNLOCK; @@ -3846,7 +3846,7 @@ gtk_tree_item_collapse(GTK_TREE_ITEM(item)); gtk_widget_show(item); DW_MUTEX_UNLOCK; - return item; + return (HTREEITEM)item; #endif } @@ -3858,7 +3858,7 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) +void dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -3923,7 +3923,7 @@ * item: Handle of the item to be modified. * itemdata: User defined data to be associated with item. */ -void dw_tree_set_data(HWND handle, HWND item, void *itemdata) +void dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -3957,7 +3957,7 @@ * 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 *dw_tree_get_data(HWND handle, HTREEITEM item) { void *ret = NULL; #if GTK_MAJOR_VERSION > 1 @@ -3993,7 +3993,7 @@ * handle: Handle to the tree window (widget) to be selected. * item: Handle to the item to be selected. */ -void dw_tree_item_select(HWND handle, HWND item) +void dw_tree_item_select(HWND handle, HTREEITEM item) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -4111,7 +4111,7 @@ * handle: Handle to the tree window (widget). * item: Handle to node to be expanded. */ -void dw_tree_expand(HWND handle, HWND item) +void dw_tree_expand(HWND handle, HTREEITEM item) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -4150,7 +4150,7 @@ * handle: Handle to the tree window (widget). * item: Handle to node to be collapsed. */ -void dw_tree_collapse(HWND handle, HWND item) +void dw_tree_collapse(HWND handle, HTREEITEM item) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; @@ -4189,7 +4189,7 @@ * handle: Handle to the window (widget) to be cleared. * item: Handle to node to be deleted. */ -void dw_tree_delete(HWND handle, HWND item) +void dw_tree_delete(HWND handle, HTREEITEM item) { #if GTK_MAJOR_VERSION > 1 GtkWidget *tree; diff -r 3204b978e077 -r e00aff2b899e os2/dw.c --- a/os2/dw.c Tue Apr 08 09:36:02 2003 +0000 +++ b/os2/dw.c Tue Apr 08 17:47:31 2003 +0000 @@ -2119,7 +2119,7 @@ { NOTIFYRECORDEMPHASIS pre; - dw_tree_item_select(tmp->window, (HWND)mp2); + dw_tree_item_select(tmp->window, (HTREEITEM)mp2); pre.pRecord = mp2; pre.fEmphasisMask = CRA_CURSORED; pre.hwndCnr = tmp->window; @@ -2157,7 +2157,7 @@ if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED)) { - int (* API treeselectfunc)(HWND, HWND, char *, void *, void *) = (int (* API)(HWND, HWND, char *, void *, void *))tmp->signalfunction; + int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))tmp->signalfunction; if(dw_window_get_data(tmp->window, "_dw_container")) result = treeselectfunc(tmp->window, 0, pci->rc.pszIcon, tmp->data, 0); @@ -2172,7 +2172,7 @@ { lasthcnr = tmp->window; lastitem = (HWND)pci; - result = treeselectfunc(tmp->window, (HWND)pci, pci->rc.pszIcon, tmp->data, pci->user); + result = treeselectfunc(tmp->window, (HTREEITEM)pci, pci->rc.pszIcon, tmp->data, pci->user); } } tmp = NULL; @@ -5610,14 +5610,14 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HWND API dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) { ULONG cbExtra; PCNRITEM pci; RECORDINSERT ri; if(!item) - item = CMA_FIRST; + item = (HTREEITEM)CMA_FIRST; /* Calculate extra bytes needed for each record besides that needed for the * MINIRECORDCORE structure @@ -5655,7 +5655,7 @@ /* Insert the record */ WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); - return (HWND)pci; + return (HTREEITEM)pci; } /* @@ -5667,9 +5667,9 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HWND API dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) -{ - return dw_tree_insert_after(handle, (HWND)CMA_END, title, icon, parent, itemdata); +HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) +{ + return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata); } /* @@ -5680,7 +5680,7 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void API dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) +void API dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon) { PCNRITEM pci = (PCNRITEM)item; @@ -5705,7 +5705,7 @@ * item: Handle of the item to be modified. * itemdata: User defined data to be associated with item. */ -void API dw_tree_set_data(HWND handle, HWND item, void *itemdata) +void API dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata) { PCNRITEM pci = (PCNRITEM)item; @@ -5721,7 +5721,7 @@ * 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) +void * API dw_tree_get_data(HWND handle, HTREEITEM item) { PCNRITEM pci = (PCNRITEM)item; @@ -5736,7 +5736,7 @@ * handle: Handle to the tree window (widget) to be selected. * item: Handle to the item to be selected. */ -void API dw_tree_item_select(HWND handle, HWND item) +void API dw_tree_item_select(HWND handle, HTREEITEM item) { PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); @@ -5767,7 +5767,7 @@ * handle: Handle to the tree window (widget). * item: Handle to node to be expanded. */ -void API dw_tree_expand(HWND handle, HWND item) +void API dw_tree_expand(HWND handle, HTREEITEM item) { WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0); } @@ -5778,7 +5778,7 @@ * handle: Handle to the tree window (widget). * item: Handle to node to be collapsed. */ -void API dw_tree_collapse(HWND handle, HWND item) +void API dw_tree_collapse(HWND handle, HTREEITEM item) { WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0); } @@ -5789,7 +5789,7 @@ * handle: Handle to the window (widget) to be cleared. * item: Handle to node to be deleted. */ -void API dw_tree_delete(HWND handle, HWND item) +void API dw_tree_delete(HWND handle, HTREEITEM item) { PCNRITEM pci = (PCNRITEM)item; @@ -6110,7 +6110,7 @@ dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); if(flags[column] & DW_CFA_BITMAPORICON) - memcpy(dest, data, sizeof(HPOINTER)); + memcpy(dest, data, sizeof(HPOINTER)); else if(flags[column] & DW_CFA_STRING) { char **newstr = (char **)data, **str = dest; @@ -6124,14 +6124,14 @@ *str = NULL; } else if(flags[column] & DW_CFA_ULONG) - memcpy(dest, data, sizeof(ULONG)); + memcpy(dest, data, sizeof(ULONG)); else if(flags[column] & DW_CFA_DATE) - memcpy(dest, data, sizeof(CDATE)); + memcpy(dest, data, sizeof(CDATE)); else if(flags[column] & DW_CFA_TIME) - memcpy(dest, data, sizeof(CTIME)); -} - -/* Internal function that does the work for set_item and change_item */ + memcpy(dest, data, sizeof(CTIME)); +} + +/* Internal function that free()s any strings allocated for a container item */ void _dw_container_free_strings(HWND handle, PRECORDCORE temp) { WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); diff -r 3204b978e077 -r e00aff2b899e win/dw.c --- a/win/dw.c Tue Apr 08 09:36:02 2003 +0000 +++ b/win/dw.c Tue Apr 08 17:47:31 2003 +0000 @@ -1531,7 +1531,7 @@ tvi.hItem = hti; TreeView_GetItem(tmp->window, &tvi); - dw_tree_item_select(tmp->window, (HWND)hti); + dw_tree_item_select(tmp->window, hti); ptrs = (void **)tvi.lParam; @@ -5725,7 +5725,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HWND API dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) +HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) { TVITEM tvi; TVINSERTSTRUCT tvins; @@ -5742,12 +5742,12 @@ tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); tvins.item = tvi; - tvins.hParent = (HTREEITEM)parent; - tvins.hInsertAfter = item ? (HTREEITEM)item : TVI_FIRST; + tvins.hParent = parent; + tvins.hInsertAfter = item ? item : TVI_FIRST; hti = TreeView_InsertItem(handle, &tvins); - return (HWND)hti; + return hti; } /* @@ -5759,7 +5759,7 @@ * parent: Parent handle or 0 if root. * itemdata: Item specific data. */ -HWND API dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) +HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) { TVITEM tvi; TVINSERTSTRUCT tvins; @@ -5776,12 +5776,12 @@ tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1); tvins.item = tvi; - tvins.hParent = (HTREEITEM)parent; + tvins.hParent = parent; tvins.hInsertAfter = TVI_LAST; hti = TreeView_InsertItem(handle, &tvins); - return (HWND)hti; + return hti; } /* @@ -5792,13 +5792,13 @@ * title: The text title of the entry. * icon: Handle to coresponding icon. */ -void API dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) +void API dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon) { TVITEM tvi; void **ptrs; tvi.mask = TVIF_HANDLE; - tvi.hItem = (HTREEITEM)item; + tvi.hItem = item; if(TreeView_GetItem(handle, &tvi)) { @@ -5823,13 +5823,13 @@ * item: Handle of the item to be modified. * itemdata: User defined data to be associated with item. */ -void API dw_tree_set_data(HWND handle, HWND item, void *itemdata) +void API dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata) { TVITEM tvi; void **ptrs; tvi.mask = TVIF_HANDLE; - tvi.hItem = (HTREEITEM)item; + tvi.hItem = item; if(TreeView_GetItem(handle, &tvi)) { @@ -5844,13 +5844,13 @@ * 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) +void * API dw_tree_get_data(HWND handle, HTREEITEM item) { TVITEM tvi; void **ptrs; tvi.mask = TVIF_HANDLE; - tvi.hItem = (HTREEITEM)item; + tvi.hItem = item; if(TreeView_GetItem(handle, &tvi)) { @@ -5866,10 +5866,10 @@ * handle: Handle to the tree window (widget) to be selected. * item: Handle to the item to be selected. */ -void API dw_tree_item_select(HWND handle, HWND item) +void API dw_tree_item_select(HWND handle, HTREEITEM item) { dw_window_set_data(handle, "_dw_select_item", (void *)1); - TreeView_SelectItem(handle, (HTREEITEM)item); + TreeView_SelectItem(handle, item); dw_window_set_data(handle, "_dw_select_item", (void *)0); } @@ -5885,7 +5885,7 @@ HTREEITEM lastitem = hti; hti = TreeView_GetNextSibling(handle, hti); - dw_tree_delete(handle, (HWND)lastitem); + dw_tree_delete(handle, lastitem); } } @@ -5904,7 +5904,7 @@ _dw_tree_delete_recursive(handle, hti); hti = TreeView_GetNextSibling(handle, hti); - dw_tree_delete(handle, (HWND)lastitem); + dw_tree_delete(handle, lastitem); } } @@ -5914,9 +5914,9 @@ * handle: Handle to the tree window (widget). * item: Handle to node to be expanded. */ -void API dw_tree_expand(HWND handle, HWND item) -{ - TreeView_Expand(handle, (HTREEITEM)item, TVE_EXPAND); +void API dw_tree_expand(HWND handle, HTREEITEM item) +{ + TreeView_Expand(handle, item, TVE_EXPAND); } /* @@ -5925,9 +5925,9 @@ * handle: Handle to the tree window (widget). * item: Handle to node to be collapsed. */ -void API dw_tree_collapse(HWND handle, HWND item) -{ - TreeView_Expand(handle, (HTREEITEM)item, TVE_COLLAPSE); +void API dw_tree_collapse(HWND handle, HTREEITEM item) +{ + TreeView_Expand(handle, item, TVE_COLLAPSE); } /* @@ -5936,22 +5936,22 @@ * handle: Handle to the window (widget) to be cleared. * item: Handle to node to be deleted. */ -void API dw_tree_delete(HWND handle, HWND item) +void API dw_tree_delete(HWND handle, HTREEITEM item) { TVITEM tvi; void **ptrs; - if((HTREEITEM)item == TVI_ROOT || !item) + if(item == TVI_ROOT || !item) return; tvi.mask = TVIF_HANDLE; - tvi.hItem = (HTREEITEM)item; + tvi.hItem = item; if(TreeView_GetItem(handle, &tvi)) ptrs = (void **)tvi.lParam; - _dw_tree_delete_recursive(handle, (HTREEITEM)item); - TreeView_DeleteItem(handle, (HTREEITEM)item); + _dw_tree_delete_recursive(handle, item); + TreeView_DeleteItem(handle, item); if(ptrs) free(ptrs); }