Mercurial > dwindows
comparison os2/dw.c @ 328:e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
were rarely actually window handles.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 08 Apr 2003 17:47:31 +0000 |
parents | 1c961a4d0f43 |
children | a2f72b5d5d0a |
comparison
equal
deleted
inserted
replaced
327:3204b978e077 | 328:e00aff2b899e |
---|---|
2117 { | 2117 { |
2118 if(!container) | 2118 if(!container) |
2119 { | 2119 { |
2120 NOTIFYRECORDEMPHASIS pre; | 2120 NOTIFYRECORDEMPHASIS pre; |
2121 | 2121 |
2122 dw_tree_item_select(tmp->window, (HWND)mp2); | 2122 dw_tree_item_select(tmp->window, (HTREEITEM)mp2); |
2123 pre.pRecord = mp2; | 2123 pre.pRecord = mp2; |
2124 pre.fEmphasisMask = CRA_CURSORED; | 2124 pre.fEmphasisMask = CRA_CURSORED; |
2125 pre.hwndCnr = tmp->window; | 2125 pre.hwndCnr = tmp->window; |
2126 _run_event(hWnd, WM_CONTROL, MPFROM2SHORT(0, CN_EMPHASIS), (MPARAM)&pre); | 2126 _run_event(hWnd, WM_CONTROL, MPFROM2SHORT(0, CN_EMPHASIS), (MPARAM)&pre); |
2127 pre.pRecord->flRecordAttr |= CRA_CURSORED; | 2127 pre.pRecord->flRecordAttr |= CRA_CURSORED; |
2155 { | 2155 { |
2156 PCNRITEM pci = (PCNRITEM)pre->pRecord; | 2156 PCNRITEM pci = (PCNRITEM)pre->pRecord; |
2157 | 2157 |
2158 if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED)) | 2158 if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED)) |
2159 { | 2159 { |
2160 int (* API treeselectfunc)(HWND, HWND, char *, void *, void *) = (int (* API)(HWND, HWND, char *, void *, void *))tmp->signalfunction; | 2160 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))tmp->signalfunction; |
2161 | 2161 |
2162 if(dw_window_get_data(tmp->window, "_dw_container")) | 2162 if(dw_window_get_data(tmp->window, "_dw_container")) |
2163 result = treeselectfunc(tmp->window, 0, pci->rc.pszIcon, tmp->data, 0); | 2163 result = treeselectfunc(tmp->window, 0, pci->rc.pszIcon, tmp->data, 0); |
2164 else | 2164 else |
2165 { | 2165 { |
2170 } | 2170 } |
2171 else | 2171 else |
2172 { | 2172 { |
2173 lasthcnr = tmp->window; | 2173 lasthcnr = tmp->window; |
2174 lastitem = (HWND)pci; | 2174 lastitem = (HWND)pci; |
2175 result = treeselectfunc(tmp->window, (HWND)pci, pci->rc.pszIcon, tmp->data, pci->user); | 2175 result = treeselectfunc(tmp->window, (HTREEITEM)pci, pci->rc.pszIcon, tmp->data, pci->user); |
2176 } | 2176 } |
2177 } | 2177 } |
2178 tmp = NULL; | 2178 tmp = NULL; |
2179 } | 2179 } |
2180 } | 2180 } |
5608 * title: The text title of the entry. | 5608 * title: The text title of the entry. |
5609 * icon: Handle to coresponding icon. | 5609 * icon: Handle to coresponding icon. |
5610 * parent: Parent handle or 0 if root. | 5610 * parent: Parent handle or 0 if root. |
5611 * itemdata: Item specific data. | 5611 * itemdata: Item specific data. |
5612 */ | 5612 */ |
5613 HWND API dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata) | 5613 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) |
5614 { | 5614 { |
5615 ULONG cbExtra; | 5615 ULONG cbExtra; |
5616 PCNRITEM pci; | 5616 PCNRITEM pci; |
5617 RECORDINSERT ri; | 5617 RECORDINSERT ri; |
5618 | 5618 |
5619 if(!item) | 5619 if(!item) |
5620 item = CMA_FIRST; | 5620 item = (HTREEITEM)CMA_FIRST; |
5621 | 5621 |
5622 /* Calculate extra bytes needed for each record besides that needed for the | 5622 /* Calculate extra bytes needed for each record besides that needed for the |
5623 * MINIRECORDCORE structure | 5623 * MINIRECORDCORE structure |
5624 */ | 5624 */ |
5625 | 5625 |
5653 ri.pRecordParent = (PRECORDCORE)parent; | 5653 ri.pRecordParent = (PRECORDCORE)parent; |
5654 | 5654 |
5655 /* Insert the record */ | 5655 /* Insert the record */ |
5656 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); | 5656 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); |
5657 | 5657 |
5658 return (HWND)pci; | 5658 return (HTREEITEM)pci; |
5659 } | 5659 } |
5660 | 5660 |
5661 /* | 5661 /* |
5662 * Inserts an item into a tree window (widget). | 5662 * Inserts an item into a tree window (widget). |
5663 * Parameters: | 5663 * Parameters: |
5665 * title: The text title of the entry. | 5665 * title: The text title of the entry. |
5666 * icon: Handle to coresponding icon. | 5666 * icon: Handle to coresponding icon. |
5667 * parent: Parent handle or 0 if root. | 5667 * parent: Parent handle or 0 if root. |
5668 * itemdata: Item specific data. | 5668 * itemdata: Item specific data. |
5669 */ | 5669 */ |
5670 HWND API dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) | 5670 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata) |
5671 { | 5671 { |
5672 return dw_tree_insert_after(handle, (HWND)CMA_END, title, icon, parent, itemdata); | 5672 return dw_tree_insert_after(handle, (HTREEITEM)CMA_END, title, icon, parent, itemdata); |
5673 } | 5673 } |
5674 | 5674 |
5675 /* | 5675 /* |
5676 * Sets the text and icon of an item in a tree window (widget). | 5676 * Sets the text and icon of an item in a tree window (widget). |
5677 * Parameters: | 5677 * Parameters: |
5678 * handle: Handle to the tree containing the item. | 5678 * handle: Handle to the tree containing the item. |
5679 * item: Handle of the item to be modified. | 5679 * item: Handle of the item to be modified. |
5680 * title: The text title of the entry. | 5680 * title: The text title of the entry. |
5681 * icon: Handle to coresponding icon. | 5681 * icon: Handle to coresponding icon. |
5682 */ | 5682 */ |
5683 void API dw_tree_set(HWND handle, HWND item, char *title, unsigned long icon) | 5683 void API dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon) |
5684 { | 5684 { |
5685 PCNRITEM pci = (PCNRITEM)item; | 5685 PCNRITEM pci = (PCNRITEM)item; |
5686 | 5686 |
5687 if(!pci) | 5687 if(!pci) |
5688 return; | 5688 return; |
5703 * Parameters: | 5703 * Parameters: |
5704 * handle: Handle to the tree containing the item. | 5704 * handle: Handle to the tree containing the item. |
5705 * item: Handle of the item to be modified. | 5705 * item: Handle of the item to be modified. |
5706 * itemdata: User defined data to be associated with item. | 5706 * itemdata: User defined data to be associated with item. |
5707 */ | 5707 */ |
5708 void API dw_tree_set_data(HWND handle, HWND item, void *itemdata) | 5708 void API dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata) |
5709 { | 5709 { |
5710 PCNRITEM pci = (PCNRITEM)item; | 5710 PCNRITEM pci = (PCNRITEM)item; |
5711 | 5711 |
5712 if(!pci) | 5712 if(!pci) |
5713 return; | 5713 return; |
5719 * Gets the item data of a tree item. | 5719 * Gets the item data of a tree item. |
5720 * Parameters: | 5720 * Parameters: |
5721 * handle: Handle to the tree containing the item. | 5721 * handle: Handle to the tree containing the item. |
5722 * item: Handle of the item to be modified. | 5722 * item: Handle of the item to be modified. |
5723 */ | 5723 */ |
5724 void * API dw_tree_get_data(HWND handle, HWND item) | 5724 void * API dw_tree_get_data(HWND handle, HTREEITEM item) |
5725 { | 5725 { |
5726 PCNRITEM pci = (PCNRITEM)item; | 5726 PCNRITEM pci = (PCNRITEM)item; |
5727 | 5727 |
5728 if(!pci) | 5728 if(!pci) |
5729 return NULL; | 5729 return NULL; |
5734 * Sets this item as the active selection. | 5734 * Sets this item as the active selection. |
5735 * Parameters: | 5735 * Parameters: |
5736 * handle: Handle to the tree window (widget) to be selected. | 5736 * handle: Handle to the tree window (widget) to be selected. |
5737 * item: Handle to the item to be selected. | 5737 * item: Handle to the item to be selected. |
5738 */ | 5738 */ |
5739 void API dw_tree_item_select(HWND handle, HWND item) | 5739 void API dw_tree_item_select(HWND handle, HTREEITEM item) |
5740 { | 5740 { |
5741 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | 5741 PRECORDCORE pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); |
5742 | 5742 |
5743 while(pCore) | 5743 while(pCore) |
5744 { | 5744 { |
5765 * Expands a node on a tree. | 5765 * Expands a node on a tree. |
5766 * Parameters: | 5766 * Parameters: |
5767 * handle: Handle to the tree window (widget). | 5767 * handle: Handle to the tree window (widget). |
5768 * item: Handle to node to be expanded. | 5768 * item: Handle to node to be expanded. |
5769 */ | 5769 */ |
5770 void API dw_tree_expand(HWND handle, HWND item) | 5770 void API dw_tree_expand(HWND handle, HTREEITEM item) |
5771 { | 5771 { |
5772 WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0); | 5772 WinSendMsg(handle, CM_EXPANDTREE, MPFROMP(item), 0); |
5773 } | 5773 } |
5774 | 5774 |
5775 /* | 5775 /* |
5776 * Collapses a node on a tree. | 5776 * Collapses a node on a tree. |
5777 * Parameters: | 5777 * Parameters: |
5778 * handle: Handle to the tree window (widget). | 5778 * handle: Handle to the tree window (widget). |
5779 * item: Handle to node to be collapsed. | 5779 * item: Handle to node to be collapsed. |
5780 */ | 5780 */ |
5781 void API dw_tree_collapse(HWND handle, HWND item) | 5781 void API dw_tree_collapse(HWND handle, HTREEITEM item) |
5782 { | 5782 { |
5783 WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0); | 5783 WinSendMsg(handle, CM_COLLAPSETREE, MPFROMP(item), 0); |
5784 } | 5784 } |
5785 | 5785 |
5786 /* | 5786 /* |
5787 * Removes a node from a tree. | 5787 * Removes a node from a tree. |
5788 * Parameters: | 5788 * Parameters: |
5789 * handle: Handle to the window (widget) to be cleared. | 5789 * handle: Handle to the window (widget) to be cleared. |
5790 * item: Handle to node to be deleted. | 5790 * item: Handle to node to be deleted. |
5791 */ | 5791 */ |
5792 void API dw_tree_delete(HWND handle, HWND item) | 5792 void API dw_tree_delete(HWND handle, HTREEITEM item) |
5793 { | 5793 { |
5794 PCNRITEM pci = (PCNRITEM)item; | 5794 PCNRITEM pci = (PCNRITEM)item; |
5795 | 5795 |
5796 if(!item) | 5796 if(!item) |
5797 return; | 5797 return; |
6108 temp = temp->preccNextRecord; | 6108 temp = temp->preccNextRecord; |
6109 | 6109 |
6110 dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); | 6110 dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); |
6111 | 6111 |
6112 if(flags[column] & DW_CFA_BITMAPORICON) | 6112 if(flags[column] & DW_CFA_BITMAPORICON) |
6113 memcpy(dest, data, sizeof(HPOINTER)); | 6113 memcpy(dest, data, sizeof(HPOINTER)); |
6114 else if(flags[column] & DW_CFA_STRING) | 6114 else if(flags[column] & DW_CFA_STRING) |
6115 { | 6115 { |
6116 char **newstr = (char **)data, **str = dest; | 6116 char **newstr = (char **)data, **str = dest; |
6117 | 6117 |
6118 if(*str) | 6118 if(*str) |
6122 *str = strdup(*newstr); | 6122 *str = strdup(*newstr); |
6123 else | 6123 else |
6124 *str = NULL; | 6124 *str = NULL; |
6125 } | 6125 } |
6126 else if(flags[column] & DW_CFA_ULONG) | 6126 else if(flags[column] & DW_CFA_ULONG) |
6127 memcpy(dest, data, sizeof(ULONG)); | 6127 memcpy(dest, data, sizeof(ULONG)); |
6128 else if(flags[column] & DW_CFA_DATE) | 6128 else if(flags[column] & DW_CFA_DATE) |
6129 memcpy(dest, data, sizeof(CDATE)); | 6129 memcpy(dest, data, sizeof(CDATE)); |
6130 else if(flags[column] & DW_CFA_TIME) | 6130 else if(flags[column] & DW_CFA_TIME) |
6131 memcpy(dest, data, sizeof(CTIME)); | 6131 memcpy(dest, data, sizeof(CTIME)); |
6132 } | 6132 } |
6133 | 6133 |
6134 /* Internal function that does the work for set_item and change_item */ | 6134 /* Internal function that free()s any strings allocated for a container item */ |
6135 void _dw_container_free_strings(HWND handle, PRECORDCORE temp) | 6135 void _dw_container_free_strings(HWND handle, PRECORDCORE temp) |
6136 { | 6136 { |
6137 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); | 6137 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); |
6138 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0; | 6138 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0; |
6139 int z, count = 0; | 6139 int z, count = 0; |