📄 tlpaint.c
字号:
if (pWD->bTreeFocused && (p->state & TLIS_FOCUSED)) {
LineDDA (p->hiliteRect.left, p->hiliteRect.top,
p->hiliteRect.right-1, p->hiliteRect.top,
(LINEDDAPROC)DottedLineProc, (LPARAM)&DottedStruct);
LineDDA (p->hiliteRect.right-1, p->hiliteRect.top,
p->hiliteRect.right-1, p->hiliteRect.bottom-1,
(LINEDDAPROC)DottedLineProc, (LPARAM)&DottedStruct);
LineDDA (p->hiliteRect.right-1, p->hiliteRect.bottom-1,
p->hiliteRect.left, p->hiliteRect.bottom-1,
(LINEDDAPROC)DottedLineProc, (LPARAM)&DottedStruct);
LineDDA (p->hiliteRect.left, p->hiliteRect.bottom-1,
p->hiliteRect.left, p->hiliteRect.top,
(LINEDDAPROC)DottedLineProc, (LPARAM)&DottedStruct);
}
// draw tree item text
iy = p->hiliteRect.top + TEXTVERTOFF;
SetTextAlign (hdc, TA_LEFT);
TextOut (hdc, p->hiliteRect.left+2, iy, sz256, lstrlen(sz256));
// draw tree item bitmap, if there is space
if (pWD->iFirstColumnWidth >= (p->buttonRect.right+BITMAPWIDTH)) {
ImageList_Draw (pWD->hImageList, p->iImage, hdc,
p->buttonRect.right, p->hiliteRect.top+iBMPos,
ILD_TRANSPARENT);
}
// paint list items based on their data type
SelectObject (hdc, pWD->hFont);
pli = p->listItem;
pci = pWD->columnItem;
ix = pWD->iFirstColumnWidth - pWD->iHorizontalPos;
while (pci && pli) {
if (pli->state & TLIS_VISIBLE) {
switch (pci->iDataType) {
case TLC_DATANONE :
break;
case TLC_DATASTRING :
if (TruncateText (hdc, pli->pszText, pci->cx, sz256))
pli->state |= TLIS_TRUNCATED;
else
pli->state &= ~TLIS_TRUNCATED;
SetBkColor (hdc, pWD->textbgcolor);
switch (pci->iDataFmt) {
case TLCFMT_LEFT :
SetTextAlign (hdc, TA_LEFT);
TextOut (hdc, ix+6, iy, sz256, lstrlen(sz256));
break;
case TLCFMT_CENTER :
SetTextAlign (hdc, TA_CENTER);
TextOut (hdc, ix + (pci->cx>>1), iy,
sz256, lstrlen(sz256));
break;
case TLCFMT_RIGHT :
SetTextAlign (hdc, TA_RIGHT);
TextOut (hdc, ix + pci->cx - 6, iy,
sz256, lstrlen(sz256));
break;
}
break;
case TLC_DATALONG :
switch (pci->iDataFmt) {
case TLCFMT_LINBAR :
cx = pci->cx - BARCOLUMNDIFF;
if (cx <= 0) break;
rc.left = ix + HBARSHIFT;
rc.top = iy + VBARSHIFT +1;
rc.right = ix + pci->cx - HBARSHIFT -1;
rc.bottom = iy+pWD->iRowHeight-(VBARSHIFT+2) -1;
oldbrush = SelectObject (hdc, pWD->barbgbrush);
oldpen = SelectObject (hdc, pWD->buttonpen);
Rectangle (hdc, rc.left - 1, rc.top - 1,
rc.right + 2, rc.bottom + 2);
SelectObject (hdc, pWD->shadowpen);
MoveToEx (hdc, rc.left, rc.bottom, NULL);
LineTo (hdc, rc.left, rc.top);
LineTo (hdc, rc.right, rc.top);
SelectObject (hdc, pWD->hilightpen);
LineTo (hdc, rc.right, rc.bottom);
LineTo (hdc, rc.left, rc.bottom);
if (pci->lMaxValue != 0) {
if (pli->lDataValue > pci->lMaxValue) {
barbrush = pWD->spcbarbrush;
rc.right = rc.left + cx;
}
else {
barbrush = pWD->stdbarbrush;
rc.right = rc.left +
(int)(((float)pli->lDataValue /
(float)pci->lMaxValue)
* (float)cx);
}
}
else
rc.right = rc.left;
rc.top++;
rc.left++;
if (rc.right > rc.left) {
SetBkColor (hdc, pWD->barcolor);
FillRect (hdc, &rc, barbrush);
rc.top--;
rc.left--;
// hilight pen already selected
MoveToEx (hdc, rc.right, rc.top, NULL);
LineTo (hdc, rc.left, rc.top);
LineTo (hdc, rc.left,rc.bottom);
SelectObject (hdc, pWD->shadowpen);
LineTo (hdc, rc.right, rc.bottom);
LineTo (hdc, rc.right, rc.top);
}
SelectObject (hdc, oldbrush);
SelectObject (hdc, oldpen);
break;
case TLCFMT_LOGBAR :
rc.left = ix + HBARSHIFT;
rc.top = iy + VBARSHIFT +1;
rc.right = ix + pci->cx - HBARSHIFT -1;
rc.bottom = iy+pWD->iRowHeight-(VBARSHIFT+2) -1;
oldbrush = SelectObject (hdc, pWD->barbgbrush);
oldpen = SelectObject (hdc, pWD->buttonpen);
Rectangle (hdc, rc.left - 1, rc.top - 1,
rc.right + 2, rc.bottom + 2);
SelectObject (hdc, pWD->shadowpen);
MoveToEx (hdc, rc.left, rc.bottom, NULL);
LineTo (hdc, rc.left, rc.top);
LineTo (hdc, rc.right, rc.top);
SelectObject (hdc, pWD->hilightpen);
LineTo (hdc, rc.right, rc.bottom);
LineTo (hdc, rc.left, rc.bottom);
if (pci->lMaxValue != 0) {
if (pli->lDataValue > pci->lMaxValue) {
barbrush = pWD->spcbarbrush;
rc.right = rc.left + cx;
}
else {
barbrush = pWD->stdbarbrush;
f = (float)pli->lDataValue /
(float)pci->lMaxValue;
f += 1.0;
f = log (f) / log (2.0);
rc.right = rc.left + (int)(f * (float)cx);
}
}
else
rc.right = rc.left;
rc.top++;
rc.left++;
if (rc.right > rc.left) {
SetBkColor (hdc, pWD->barcolor);
FillRect (hdc, &rc, barbrush);
rc.top--;
rc.left--;
// hilight pen already selected
MoveToEx (hdc, rc.right, rc.top, NULL);
LineTo (hdc, rc.left, rc.top);
LineTo (hdc, rc.left,rc.bottom);
SelectObject (hdc, pWD->shadowpen);
LineTo (hdc, rc.right, rc.bottom);
LineTo (hdc, rc.right, rc.top);
}
SelectObject (hdc, oldbrush);
SelectObject (hdc, oldpen);
break;
case TLCFMT_IMAGE :
// use text if available
if (pli->pszText) {
if (TruncateText (hdc, pli->pszText,
pci->cx, sz256))
pli->state |= TLIS_TRUNCATED;
else
pli->state &= ~TLIS_TRUNCATED;
SetBkColor (hdc, pWD->textbgcolor);
SetTextAlign (hdc, TA_CENTER);
TextOut (hdc, ix + (pci->cx>>1), iy,
sz256, lstrlen(sz256));
}
// otherwise paint image
else {
if (pci->cx >= (BITMAPWIDTH)) {
int i = 0;
if (pli->state & TLIS_CLICKED) i = 1;
ImageList_Draw (pWD->hImageList,
(pli->lDataValue + i), hdc,
ix + pci->cxImageOffset,
p->hiliteRect.top+iBMPos,
ILD_TRANSPARENT);
}
}
break;
case TLCFMT_IMAGELIST :
// use text if available
if (pli->pszText) {
if (TruncateText (hdc, pli->pszText,
pci->cx, sz256))
pli->state |= TLIS_TRUNCATED;
else
pli->state &= ~TLIS_TRUNCATED;
SetBkColor (hdc, pWD->textbgcolor);
SetTextAlign (hdc, TA_LEFT);
TextOut (hdc, ix + (pci->cx>>1), iy,
sz256, lstrlen(sz256));
}
// otherwise paint images
else {
int iImage = 0;
int iXpos = 0;
ULONG uImageMask = 1;
while (!(uImageMask & 0x80000000)) {
if (pli->lDataValue & uImageMask) {
if ((iXpos+BITMAPWIDTH) <= pci->cx)
{
ImageList_Draw (pWD->hImageList,
iImage, hdc,
ix + iXpos,
p->hiliteRect.top+iBMPos,
ILD_TRANSPARENT);
iXpos +=
(BITMAPWIDTH + BITMAPSPACE);
}
else {
TruncateText (hdc, "...",
pci->cx, sz256);
SetBkColor (hdc,
pWD->textbgcolor);
SetTextAlign (hdc, TA_LEFT);
TextOut (hdc, ix + iXpos,
iy, sz256, lstrlen(sz256));
}
}
uImageMask <<= 1;
iImage++;
}
}
break;
default :
wsprintf (sz256, "%i", pli->lDataValue);
SetBkColor (hdc, pWD->textbgcolor);
SetTextAlign (hdc, TA_LEFT);
TextOut (hdc, ix+6, iy, sz256, lstrlen(sz256));
break;
}
break;
}
}
ix += pci->cx;
pci = pci->nextItem;
pli = pli->nextItem;
}
// increment y coordinate to next row
*y += pWD->iRowHeight;
// if there is space, paint button and lines
if (pWD->iFirstColumnWidth >= p->buttonRect.right) {
if (p->cChildren) {
oldpen = SelectObject (hdc, pWD->buttonpen);
MoveToEx (hdc, p->buttonRect.left+HBCENT-BBOX,
p->buttonRect.top+iBCent-BBOX, NULL);
LineTo (hdc, p->buttonRect.left+HBCENT+BBOX,
p->buttonRect.top+iBCent-BBOX);
LineTo (hdc, p->buttonRect.left+HBCENT+BBOX,
p->buttonRect.top+iBCent+BBOX);
LineTo (hdc, p->buttonRect.left+HBCENT-BBOX,
p->buttonRect.top+iBCent+BBOX);
LineTo (hdc, p->buttonRect.left+HBCENT-BBOX,
p->buttonRect.top+iBCent-BBOX);
SelectObject (hdc, oldpen);
if (p->state & TLIS_EXPANDED) {
oldpen = SelectObject (hdc, pWD->unseltextpen);
MoveToEx (hdc, p->buttonRect.left+HBCENT-BBAR,
p->buttonRect.top+iBCent, NULL);
LineTo (hdc, p->buttonRect.left+HBCENT+BBAR+1,
p->buttonRect.top+iBCent);
SelectObject (hdc, oldpen);
// paint children
PaintItems (hdc, pWD, item, y,
indent+INCREMENTINDENT, p->childItem);
}
else {
oldpen = SelectObject (hdc, pWD->unseltextpen);
MoveToEx (hdc, p->buttonRect.left+HBCENT-BBAR,
p->buttonRect.top+iBCent, NULL);
LineTo (hdc, p->buttonRect.left+HBCENT+BBAR+1,
p->buttonRect.top+iBCent);
MoveToEx (hdc, p->buttonRect.left+HBCENT,
p->buttonRect.top+iBCent-BBAR, NULL);
LineTo (hdc, p->buttonRect.left+HBCENT,
p->buttonRect.top+iBCent+BBAR+1);
SelectObject (hdc, oldpen);
}
if ((pWD->style & TLS_HASLINES) && (p->parentItem ||
(!p->parentItem && (pWD->style & TLS_LINESATROOT)))) {
DottedStruct.dwDottedColor = pWD->linecolor;
if (p->prevItem || p->parentItem) {
if (p->prevItem)
LineDDA (xoffset+HBCENT,
p->prevItem->selectRect.bottom,
xoffset+HBCENT,
p->buttonRect.top+iBCent-BBOX,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
else
LineDDA (xoffset+HBCENT, p->buttonRect.top,
xoffset+HBCENT,
p->buttonRect.top+iBCent-BBOX,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
}
if (p->nextItem) {
LineDDA (xoffset+HBCENT,
p->buttonRect.top+iBCent+BBOX,
xoffset+HBCENT, *y +1,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
}
LineDDA (xoffset+HBCENT+BBOX,
p->buttonRect.top+iBCent,
xoffset+BUTTONWIDTH,
p->buttonRect.top+iBCent,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
}
}
// if item has no children, only paint lines
else {
if ((pWD->style & TLS_HASLINES) && (p->parentItem ||
(!p->parentItem && (pWD->style & TLS_LINESATROOT)))) {
DottedStruct.dwDottedColor = pWD->linecolor;
if (p->prevItem) {
ix = xoffset+HBCENT;
iy = p->prevItem->selectRect.bottom;
}
else {
ix = xoffset+HBCENT;
iy = p->buttonRect.top;
}
if (p->nextItem) {
LineDDA (ix, iy, xoffset+HBCENT, *y +1,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
}
else LineDDA (ix, iy, xoffset+HBCENT,
p->buttonRect.top+iBCent,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
LineDDA (xoffset+HBCENT, p->buttonRect.top+iBCent,
xoffset+BUTTONWIDTH,
p->buttonRect.top+iBCent,
(LINEDDAPROC)DottedLineProc,
(LPARAM)&DottedStruct);
}
}
}
// if no space, we still need to paint children
else {
if (p->cChildren) {
if (p->state & TLIS_EXPANDED) {
PaintItems (hdc, pWD, item, y,
indent+INCREMENTINDENT, p->childItem);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -