Example #1
0
void GxEPD2_270::drawImagePart(const uint8_t* black, const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
                               int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
{
  if (black)
  {
    drawImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
  }
}
Example #2
0
// normally we would only draw stuff in subitem stages
// this broke when we tried drawing focus rects in postpaint; the drawing either kept getting wiped or overdrawn, mouse hovering had something to do with it, and none of the "solutions" to this or similar problems on the internet worked
// so now we do everything in the item prepaint stage
// TODO consider switching to full-on owner draw
// TODO only compute the background brushes once?
HRESULT uiprivTableHandleNM_CUSTOMDRAW(uiTable *t, NMLVCUSTOMDRAW *nm, LRESULT *lResult)
{
	struct drawState s;
	uiprivTableColumnParams *p;
	NMLVCUSTOMDRAW b;
	size_t i, n;
	RECT focus;
	bool focusFirst;
	HRESULT hr;

	switch (nm->nmcd.dwDrawStage) {
	case CDDS_PREPAINT:
		*lResult = CDRF_NOTIFYITEMDRAW;
		return S_OK;
	case CDDS_ITEMPREPAINT:
		break;
	default:
		*lResult = CDRF_DODEFAULT;
		return S_OK;
	}

	n = t->columns->size();
	b = *nm;
	focusFirst = true;
	for (i = 0; i < n; i++) {
		b.iSubItem = i;
		p = (*(t->columns))[i];
		hr = fillDrawState(&s, t, &b, p);
		if (hr != S_OK)
			return hr;
		hr = drawBackgrounds(S_OK, &s);
		hr = drawImagePart(hr, &s);
		hr = drawCheckboxPart(hr, &s);
		hr = drawTextPart(hr, &s);
		hr = drawProgressBarPart(hr, &s);
		hr = drawButtonPart(hr, &s);
		hr = updateAndDrawFocusRects(hr, s.t, s.dc, nm->nmcd.dwItemSpec, &(s.m->realTextBackground), &focus, &focusFirst);
		if (hr != S_OK)
			goto fail;
		hr = freeDrawState(&s);
		if (hr != S_OK)		// TODO really error out here?
			return hr;
	}
	// and draw the last focus rect
	hr = updateAndDrawFocusRects(hr, t, nm->nmcd.hdc, nm->nmcd.dwItemSpec, NULL, &focus, &focusFirst);
	if (hr != S_OK)
		return hr;
	*lResult = CDRF_SKIPDEFAULT;
	return S_OK;
fail:
	// ignore error here
	// TODO this is awkward cleanup placement for something that only really exists in a for loop
	freeDrawState(&s);
	return hr;
}