Mercurial > dwindows
comparison win/dw.c @ 1387:db27c6e139a3
Fixed dw_container_optimize() on Windows was not calculating things correctly.
The first column could be undersized due to an invalid check after adding icon padding.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 26 Nov 2011 00:09:07 +0000 |
parents | fd1de4e9e542 |
children | 0512fbb08abf |
comparison
equal
deleted
inserted
replaced
1386:fd1de4e9e542 | 1387:db27c6e139a3 |
---|---|
8728 /* Query all the item texts */ | 8728 /* Query all the item texts */ |
8729 while(index != -1) | 8729 while(index != -1) |
8730 { | 8730 { |
8731 for(z=0;z<cinfo->columns;z++) | 8731 for(z=0;z<cinfo->columns;z++) |
8732 { | 8732 { |
8733 LV_ITEM lvi; | 8733 int width; |
8734 | 8734 |
8735 memset(&lvi, 0, sizeof(LV_ITEM)); | 8735 ListView_GetItemText(handle, index, z, text, 1023); |
8736 | 8736 width = ListView_GetStringWidth(handle, text); |
8737 lvi.iItem = index; | 8737 |
8738 lvi.iSubItem = z; | 8738 /* Figure extra space for the icon for the first column */ |
8739 lvi.mask = LVIF_TEXT; | 8739 if(z == 0) |
8740 lvi.cchTextMax = 1023; | 8740 width += 20; |
8741 lvi.pszText = text; | 8741 |
8742 | 8742 if(width > columns[z]) |
8743 if(ListView_GetItem(handle, &lvi)) | 8743 columns[z] = width; |
8744 { | |
8745 int width = ListView_GetStringWidth(handle, lvi.pszText); | |
8746 if(width > columns[z]) | |
8747 { | |
8748 if(z == 0) | |
8749 columns[z] = width + 20; | |
8750 else | |
8751 columns[z] = width; | |
8752 } | |
8753 } | |
8754 } | 8744 } |
8755 | 8745 |
8756 index = ListView_GetNextItem(handle, index, LVNI_ALL); | 8746 index = ListView_GetNextItem(handle, index, LVNI_ALL); |
8757 } | 8747 } |
8758 | 8748 |
8759 /* Set the new sizes */ | 8749 /* Set the new sizes... Microsoft says we need to add |
8750 * padding to the calculated sized but does not give | |
8751 * a value. Trial and error shows that 16 works for us. | |
8752 */ | |
8760 for(z=0;z<cinfo->columns;z++) | 8753 for(z=0;z<cinfo->columns;z++) |
8761 ListView_SetColumnWidth(handle, z, columns[z] + 16); | 8754 ListView_SetColumnWidth(handle, z, columns[z] + 16); |
8762 | 8755 |
8763 free(columns); | 8756 free(columns); |
8764 free(text); | 8757 free(text); |