comparison win/dw.c @ 1213:22cedf18db25

Fixed a slight miscalculation and simplified the Windows container row code. Also added alternating row colors to the test program and updated readme.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 09 Oct 2011 10:13:16 +0000
parents 5271d5cb27ac
children e16e7c51b6c7
comparison
equal deleted inserted replaced
1212:5271d5cb27ac 1213:22cedf18db25
2700 break; 2700 break;
2701 case WM_PAINT: 2701 case WM_PAINT:
2702 if(cinfo->cinfo.pOldProc && (cinfo->even != DW_RGB_TRANSPARENT || cinfo->odd != DW_RGB_TRANSPARENT)) 2702 if(cinfo->cinfo.pOldProc && (cinfo->even != DW_RGB_TRANSPARENT || cinfo->odd != DW_RGB_TRANSPARENT))
2703 { 2703 {
2704 RECT rectUpd, rectDestin, rect; 2704 RECT rectUpd, rectDestin, rect;
2705 POINT pt;
2706 int iItems, iTop, i; 2705 int iItems, iTop, i;
2707 COLORREF c; 2706 COLORREF c;
2708 2707
2709 /* Load the default background color for the first pass */ 2708 /* Load the default background color for the first pass */
2710 ListView_SetTextBkColor(hWnd, cinfo->cinfo.back != -1 ? cinfo->cinfo.back : ListView_GetBkColor(hWnd)); 2709 ListView_SetTextBkColor(hWnd, cinfo->cinfo.back != -1 ? cinfo->cinfo.back : ListView_GetBkColor(hWnd));
2717 /* number of displayed rows */ 2716 /* number of displayed rows */
2718 iItems = ListView_GetCountPerPage(hWnd); 2717 iItems = ListView_GetCountPerPage(hWnd);
2719 /* first visible row */ 2718 /* first visible row */
2720 iTop = ListView_GetTopIndex(hWnd); 2719 iTop = ListView_GetTopIndex(hWnd);
2721 2720
2722 ListView_GetItemPosition(hWnd, iTop, &pt); 2721 for(i=iTop; i<=iTop+iItems; i++)
2723 for(i=iTop; i<=(iTop+iItems)+1; i++)
2724 { 2722 {
2725 /* set row vertical dimensions */ 2723 /* Get the row's rect */
2726 rect.top = pt.y; 2724 ListView_GetItemRect(hWnd, i, &rect, LVIR_BOUNDS);
2727 ListView_GetItemPosition(hWnd, i, &pt);
2728 rect.bottom = pt.y;
2729 /* if row rectangle intersects update rectangle then it requires re-drawing */ 2725 /* if row rectangle intersects update rectangle then it requires re-drawing */
2730 if(IntersectRect(&rectDestin, &rectUpd, &rect)) 2726 if(IntersectRect(&rectDestin, &rectUpd, &rect))
2731 { 2727 {
2732 /* change text background colour accordingly */ 2728 /* change text background colour accordingly */
2733 c = (i % 2) ? cinfo->even : cinfo->odd; 2729 c = (i % 2) ? cinfo->odd : cinfo->even;
2734 2730
2735 if(c != DW_RGB_TRANSPARENT) 2731 if(c != DW_RGB_TRANSPARENT)
2736 { 2732 {
2737 ListView_SetTextBkColor(hWnd, c); 2733 ListView_SetTextBkColor(hWnd, c);
2738 /* invalidate the row rectangle then... */ 2734 /* invalidate the row rectangle then... */