From f852359acbee65e49427632d2eb94a09e50e55e6 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 15 Jun 2018 23:00:39 -0400 Subject: [PATCH] Fixed build errors. The image list selection part works, at least!! Let's figure out why nothing else does. --- windows/image.cpp | 4 +--- windows/table.hpp | 10 ++-------- windows/tabledraw.cpp | 16 ++++++++-------- windows/tableimages.cpp | 8 +++++++- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/windows/image.cpp b/windows/image.cpp index 3beedb0e..d94de789 100644 --- a/windows/image.cpp +++ b/windows/image.cpp @@ -125,10 +125,8 @@ HRESULT uiprivWICToGDI(IWICBitmap *b, HDC dc, int width, int height, HBITMAP *hb { UINT ux, uy; int x, y; - IWICImageSource *src; + IWICBitmapSource *src; BITMAPINFO bmi; - UINT width, height; - HBITMAP hb; VOID *bits; BITMAP bmp; HRESULT hr; diff --git a/windows/table.hpp b/windows/table.hpp index 056cb884..4e33d70c 100644 --- a/windows/table.hpp +++ b/windows/table.hpp @@ -29,14 +29,8 @@ struct uiTable { std::vector *columns; WPARAM nColumns; int backgroundColumn; - - // tableimages.cpp - // TODO make sure what we're doing is even allowed - HIMAGELIST smallImages; - int smallIndex; - - // custom draw state - COLORREF clrItemText; + // TODO make sure replacing images while selected in the listview is even allowed + HIMAGELIST imagelist; }; typedef struct uiprivSubitemDrawParams uiprivSubitemDrawParams; struct uiprivSubitemDrawParams { diff --git a/windows/tabledraw.cpp b/windows/tabledraw.cpp index cb4a9fce..62cd3123 100644 --- a/windows/tabledraw.cpp +++ b/windows/tabledraw.cpp @@ -88,22 +88,22 @@ static HRESULT drawImagePart(struct drawState *s) if (s->p->imageModelColumn == -1) return S_OK; - data = (*(t->model->mh->CellValue))(t->model->mh, t->model, nm->item.iItem, p->imageModelColumn); + data = (*(s->m->mh->CellValue))(s->m->mh, s->m, s->iItem, s->p->imageModelColumn); wb = uiprivImageAppropriateForDC(uiTableDataImage(data), s->dc); uiFreeTableData(data); - hr = uiprivWICToGDI(wb, s->cxIcon, s->cyIcon, &b); + hr = uiprivWICToGDI(wb, s->dc, s->cxIcon, s->cyIcon, &b); if (hr != S_OK) return hr; // TODO rewrite this condition to make more sense; possibly swap the if and else blocks too // TODO proper cleanup - if (ImageList_GetImageCount(t->imagelist) > 1) { - if (ImageList_Replace(t->imagelist, 0, b, NULL) == 0) { + if (ImageList_GetImageCount(s->t->imagelist) > 1) { + if (ImageList_Replace(s->t->imagelist, 0, b, NULL) == 0) { logLastError(L"ImageList_Replace()"); return E_FAIL; } } else - if (ImageList_Add(t->imagelist, b, NULL) == -1) { + if (ImageList_Add(s->t->imagelist, b, NULL) == -1) { logLastError(L"ImageList_Add()"); return E_FAIL; } @@ -114,7 +114,7 @@ static HRESULT drawImagePart(struct drawState *s) if (s->selected) fStyle = ILD_SELECTED; // TODO copy the centering code from tableimage.cpp - if (ImageList_Draw(t->imagelist, 0, + if (ImageList_Draw(s->t->imagelist, 0, s->dc, s->subitemIcon.left, s->subitemIcon.top, fStyle) == 0) { logLastError(L"ImageList_Draw()"); @@ -420,12 +420,12 @@ HRESULT uiprivUpdateImageListSize(uiTable *t) t->imagelist = ImageList_Create(cxList, cyList, ILC_COLOR32, 1, 1); - if (t->smallImages == NULL) { + if (t->imagelist == NULL) { logLastError(L"ImageList_Create()"); return E_FAIL; } // TODO will this return NULL here because it's an initial state? - SendMessageW(t->hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM) (t->smallImages)); + SendMessageW(t->hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM) (t->imagelist)); hr = CloseThemeData(theme); if (hr != S_OK) { diff --git a/windows/tableimages.cpp b/windows/tableimages.cpp index fb97b596..b7fed3bd 100644 --- a/windows/tableimages.cpp +++ b/windows/tableimages.cpp @@ -69,7 +69,9 @@ HRESULT uiprivLVN_GETDISPINFOImagesCheckboxes(uiTable *t, NMLVDISPINFOW *nm, uip return S_OK; // nothing to do here // TODO - nm->item.iImage = 0; + nm->item.iImage = -1; + if (p->imageModelColumn != -1 || p->checkboxModelColumn != -1) + nm->item.iImage = 0; return S_OK; if (p->imageModelColumn != -1) { @@ -100,6 +102,8 @@ HRESULT uiprivLVN_GETDISPINFOImagesCheckboxes(uiTable *t, NMLVDISPINFOW *nm, uip return S_OK; } +#if 0 + // in order to properly look like checkboxes, we need to exclude them from being colored in by the selection rect // however, there seems to be no way to do this natively, so we have to draw the icons ourselves // see also https://www.codeproject.com/Articles/79/Neat-Stuff-to-Do-in-List-Controls-Using-Custom-Dra (and while this uses postpaint to draw over the existing icon, we are drawing everything ourselves, so we only draw once) @@ -264,3 +268,5 @@ static HRESULT mkCheckboxes(uiTable *t, HTHEME theme, HDC dc, int cxList, int cy DeleteObject(b); return S_OK; } + +#endif