Mercurial > dwindows
comparison win/dw.c @ 496:33a266db534b
Don't use globals for keeping track of dw_container_query*() loops, allows
for concurrent loops from different threads.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 12 Dec 2003 05:19:36 +0000 |
parents | 477de19f14af |
children | 56ea525c1a24 |
comparison
equal
deleted
inserted
replaced
495:477de19f14af | 496:33a266db534b |
---|---|
80 void *data; | 80 void *data; |
81 | 81 |
82 } SignalHandler; | 82 } SignalHandler; |
83 | 83 |
84 SignalHandler *Root = NULL; | 84 SignalHandler *Root = NULL; |
85 int _index; | |
86 | 85 |
87 typedef struct | 86 typedef struct |
88 { | 87 { |
89 ULONG message; | 88 ULONG message; |
90 char name[30]; | 89 char name[30]; |
6757 * handle: Handle to the window (widget) to be deleted from. | 6756 * handle: Handle to the window (widget) to be deleted from. |
6758 * rowcount: The number of rows to be deleted. | 6757 * rowcount: The number of rows to be deleted. |
6759 */ | 6758 */ |
6760 void API dw_container_delete(HWND handle, int rowcount) | 6759 void API dw_container_delete(HWND handle, int rowcount) |
6761 { | 6760 { |
6762 int z; | 6761 int z, _index = (int)dw_window_get_data(handle, "_dw_index"); |
6763 | 6762 |
6764 for(z=0;z<rowcount;z++) | 6763 for(z=0;z<rowcount;z++) |
6765 { | 6764 { |
6766 ListView_DeleteItem(handle, 0); | 6765 ListView_DeleteItem(handle, 0); |
6767 } | 6766 } |
6768 if(rowcount > _index) | 6767 if(rowcount > _index) |
6769 _index = 0; | 6768 dw_window_set_data(handle, "_dw_index", 0); |
6770 else | 6769 else |
6771 _index -= rowcount; | 6770 dw_window_set_data(handle, "_dw_index", (void *)(_index - rowcount)); |
6772 } | 6771 } |
6773 | 6772 |
6774 /* | 6773 /* |
6775 * Scrolls container up or down. | 6774 * Scrolls container up or down. |
6776 * Parameters: | 6775 * Parameters: |
6801 * it will return all records in the container. | 6800 * it will return all records in the container. |
6802 */ | 6801 */ |
6803 char * API dw_container_query_start(HWND handle, unsigned long flags) | 6802 char * API dw_container_query_start(HWND handle, unsigned long flags) |
6804 { | 6803 { |
6805 LV_ITEM lvi; | 6804 LV_ITEM lvi; |
6806 | 6805 int _index = ListView_GetNextItem(handle, -1, flags); |
6807 _index = ListView_GetNextItem(handle, -1, flags); | |
6808 | 6806 |
6809 if(_index == -1) | 6807 if(_index == -1) |
6810 return NULL; | 6808 return NULL; |
6811 | 6809 |
6812 memset(&lvi, 0, sizeof(LV_ITEM)); | 6810 memset(&lvi, 0, sizeof(LV_ITEM)); |
6814 lvi.iItem = _index; | 6812 lvi.iItem = _index; |
6815 lvi.mask = LVIF_PARAM; | 6813 lvi.mask = LVIF_PARAM; |
6816 | 6814 |
6817 ListView_GetItem(handle, &lvi); | 6815 ListView_GetItem(handle, &lvi); |
6818 | 6816 |
6817 dw_window_set_data(handle, "_dw_index", (void *)_index); | |
6819 return (char *)lvi.lParam; | 6818 return (char *)lvi.lParam; |
6820 } | 6819 } |
6821 | 6820 |
6822 /* | 6821 /* |
6823 * Continues an existing query of a container. | 6822 * Continues an existing query of a container. |
6828 * it will return all records in the container. | 6827 * it will return all records in the container. |
6829 */ | 6828 */ |
6830 char * API dw_container_query_next(HWND handle, unsigned long flags) | 6829 char * API dw_container_query_next(HWND handle, unsigned long flags) |
6831 { | 6830 { |
6832 LV_ITEM lvi; | 6831 LV_ITEM lvi; |
6832 int _index = (int)dw_window_get_data(handle, "_dw_index"); | |
6833 | 6833 |
6834 _index = ListView_GetNextItem(handle, _index, flags); | 6834 _index = ListView_GetNextItem(handle, _index, flags); |
6835 | 6835 |
6836 if(_index == -1) | 6836 if(_index == -1) |
6837 return NULL; | 6837 return NULL; |
6841 lvi.iItem = _index; | 6841 lvi.iItem = _index; |
6842 lvi.mask = LVIF_PARAM; | 6842 lvi.mask = LVIF_PARAM; |
6843 | 6843 |
6844 ListView_GetItem(handle, &lvi); | 6844 ListView_GetItem(handle, &lvi); |
6845 | 6845 |
6846 dw_window_set_data(handle, "_dw_index", (void *)_index); | |
6846 return (char *)lvi.lParam; | 6847 return (char *)lvi.lParam; |
6847 } | 6848 } |
6848 | 6849 |
6849 /* | 6850 /* |
6850 * Cursors the item with the text speficied, and scrolls to that item. | 6851 * Cursors the item with the text speficied, and scrolls to that item. |
6901 | 6902 |
6902 ListView_GetItem(handle, &lvi); | 6903 ListView_GetItem(handle, &lvi); |
6903 | 6904 |
6904 if((char *)lvi.lParam == text) | 6905 if((char *)lvi.lParam == text) |
6905 { | 6906 { |
6907 int _index = (int)dw_window_get_data(handle, "_dw_index"); | |
6908 | |
6906 if(index < _index) | 6909 if(index < _index) |
6907 _index--; | 6910 dw_window_set_data(handle, "_dw_index", (void *)(_index - 1)); |
6908 | 6911 |
6909 ListView_DeleteItem(handle, index); | 6912 ListView_DeleteItem(handle, index); |
6910 return; | 6913 return; |
6911 } | 6914 } |
6912 | 6915 |