comparison win/dw.c @ 573:314abd650968

Fix for incorrect indexes on subsequent container inserts on windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 09 Feb 2005 17:53:26 +0000
parents 828e6a66c5c5
children e4c5b03c7ce8
comparison
equal deleted inserted replaced
572:1e3ab8adba90 573:314abd650968
6605 * rowcount: The number of items to be populated. 6605 * rowcount: The number of items to be populated.
6606 */ 6606 */
6607 void * API dw_container_alloc(HWND handle, int rowcount) 6607 void * API dw_container_alloc(HWND handle, int rowcount)
6608 { 6608 {
6609 LV_ITEM lvi; 6609 LV_ITEM lvi;
6610 int z; 6610 int z, item;
6611 6611
6612 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE; 6612 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE;
6613 lvi.iSubItem = 0; 6613 lvi.iSubItem = 0;
6614 /* Insert at the end */ 6614 /* Insert at the end */
6615 lvi.iItem = 1000000; 6615 lvi.iItem = 1000000;
6616 lvi.pszText = ""; 6616 lvi.pszText = "";
6617 lvi.cchTextMax = 1; 6617 lvi.cchTextMax = 1;
6618 lvi.iImage = -1; 6618 lvi.iImage = -1;
6619 6619
6620 ShowWindow(handle, SW_HIDE); 6620 ShowWindow(handle, SW_HIDE);
6621 for(z=0;z<rowcount;z++) 6621 item = ListView_InsertItem(handle, &lvi);
6622 for(z=1;z<rowcount;z++)
6622 ListView_InsertItem(handle, &lvi); 6623 ListView_InsertItem(handle, &lvi);
6624 dw_window_set_data(handle, "_dw_insertitem", (void *)item);
6623 return (void *)handle; 6625 return (void *)handle;
6624 } 6626 }
6625 6627
6626 /* Finds a icon in the table, otherwise it adds it to the table 6628 /* Finds a icon in the table, otherwise it adds it to the table
6627 * and returns the index in the table. 6629 * and returns the index in the table.
6727 { 6729 {
6728 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 6730 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
6729 ULONG *flags; 6731 ULONG *flags;
6730 LV_ITEM lvi; 6732 LV_ITEM lvi;
6731 char textbuffer[100], *destptr = textbuffer; 6733 char textbuffer[100], *destptr = textbuffer;
6734 int item = (int)dw_window_get_data(handle, "_dw_insertitem");
6732 6735
6733 if(!cinfo || !cinfo->flags || !data) 6736 if(!cinfo || !cinfo->flags || !data)
6734 return; 6737 return;
6735 6738
6736 flags = cinfo->flags; 6739 flags = cinfo->flags;
6737 6740
6738 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT; 6741 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
6739 lvi.iItem = row; 6742 lvi.iItem = row + item;
6740 lvi.iSubItem = column; 6743 lvi.iSubItem = column;
6741 6744
6742 if(flags[column] & DW_CFA_BITMAPORICON) 6745 if(flags[column] & DW_CFA_BITMAPORICON)
6743 { 6746 {
6744 HICON hicon = *((HICON *)data); 6747 HICON hicon = *((HICON *)data);
6905 */ 6908 */
6906 void API dw_container_set_row_title(void *pointer, int row, char *title) 6909 void API dw_container_set_row_title(void *pointer, int row, char *title)
6907 { 6910 {
6908 LV_ITEM lvi; 6911 LV_ITEM lvi;
6909 HWND container = (HWND)pointer; 6912 HWND container = (HWND)pointer;
6910 6913 int item = (int)dw_window_get_data(container, "_dw_insertitem");
6911 lvi.iItem = row; 6914
6915 lvi.iItem = row + item;
6912 lvi.iSubItem = 0; 6916 lvi.iSubItem = 0;
6913 lvi.mask = LVIF_PARAM; 6917 lvi.mask = LVIF_PARAM;
6914 lvi.lParam = (LPARAM)title; 6918 lvi.lParam = (LPARAM)title;
6915 6919
6916 if(!ListView_SetItem(container, &lvi) && lvi.lParam) 6920 if(!ListView_SetItem(container, &lvi) && lvi.lParam)