⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlpaint.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 4 页
字号:
							// first paint images
							if (pli->lDataValue)
							{
								if (BITMAPWIDTH <= pci->cx)
								{
									ImageList_Draw (
											(HIMAGELIST)(pli->lDataValue),
											0, hdc, ix,
											p->hiliteRect.top+iBMPos,
											ILD_TRANSPARENT);
									iXpos +=
											(BITMAPWIDTH + BITMAPSPACE);
								}
								else 
								{
									lstrcpyW (wsz, L"...");
									sTruncateText (hdc, wsz, pci->cx);
									SetBkColor (hdc,
											pWD->textbgcolor);
									SetTextAlign (hdc, TA_LEFT);
									TextOutW (hdc, ix + iXpos,
											iy, wsz, lstrlenW(wsz));
								}
							}

							// then draw text if available
							if (pli->pszText) 
							{
								sGetWideText (pli->pszText, wsz, sizeof(wsz));
								if (sTruncateText (hdc, 
										wsz, (pci->cx - iXpos)))
								{
									pli->state |= TLIS_TRUNCATED;
								}
								else
									pli->state &= ~TLIS_TRUNCATED;

								SetBkColor (hdc, pWD->textbgcolor);
								SetTextAlign (hdc, TA_LEFT);
								TextOutW (hdc, ix + iXpos, iy,
										wsz, lstrlenW(wsz));
							}
							break;
						}

						case TLCFMT_HICON :
						{
							int iXpos = 0;

							// first paint images
							if (pli->lDataValue)
							{
								if (BITMAPWIDTH <= pci->cx)
								{
									DrawIconEx (hdc, 
											ix, p->hiliteRect.top+iBMPos,
											(HICON)(pli->lDataValue),
											BITMAPWIDTH, BITMAPHEIGHT,
											0, NULL, DI_NORMAL);
									iXpos +=
											(BITMAPWIDTH + BITMAPSPACE);
								}
								else 
								{
									lstrcpyW (wsz, L"...");
									sTruncateText (hdc, wsz, pci->cx);
									SetBkColor (hdc,
											pWD->textbgcolor);
									SetTextAlign (hdc, TA_LEFT);
									TextOutW (hdc, ix + iXpos,
											iy, wsz, lstrlenW(wsz));
								}
							}

							// then draw text if available
							if (pli->pszText) 
							{
								sGetWideText (pli->pszText, wsz, sizeof(wsz));
								if (sTruncateText (hdc, 
										wsz, (pci->cx - iXpos)))
								{
									pli->state |= TLIS_TRUNCATED;
								}
								else
									pli->state &= ~TLIS_TRUNCATED;

								SetBkColor (hdc, pWD->textbgcolor);
								SetTextAlign (hdc, TA_LEFT);
								TextOutW (hdc, ix + iXpos, iy,
										wsz, lstrlenW(wsz));
							}
							break;
						}

						default :
							wsprintf ((LPSTR)wsz, "%i", pli->lDataValue);
							SetBkColor (hdc, pWD->textbgcolor);
							SetTextAlign (hdc, TA_LEFT);
							TextOut (hdc, ix+6, iy, 
									(LPSTR)wsz, lstrlen((LPSTR)wsz));
							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
						sPaintItems (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)sDottedLineProc,
										(LPARAM)&DottedStruct);
							}
							else
							{
								LineDDA (xoffset+HBCENT, p->buttonRect.top,
										xoffset+HBCENT,
										p->buttonRect.top+iBCent-BBOX,
										(LINEDDAPROC)sDottedLineProc,
										(LPARAM)&DottedStruct);
							}
						}

						if (p->nextItem) 
						{
							LineDDA (xoffset+HBCENT,
									p->buttonRect.top+iBCent+BBOX,
									xoffset+HBCENT, *y +1,
									(LINEDDAPROC)sDottedLineProc,
									(LPARAM)&DottedStruct);
						}

						LineDDA (xoffset+HBCENT+BBOX,
								p->buttonRect.top+iBCent,
								xoffset+BUTTONWIDTH,
								p->buttonRect.top+iBCent,
								(LINEDDAPROC)sDottedLineProc,
								(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)sDottedLineProc,
									(LPARAM)&DottedStruct);
						}
						else 
						{
							LineDDA (ix, iy, xoffset+HBCENT,
									p->buttonRect.top+iBCent,
									(LINEDDAPROC)sDottedLineProc,
									(LPARAM)&DottedStruct);
						}

						LineDDA (xoffset+HBCENT, p->buttonRect.top+iBCent,
								xoffset+BUTTONWIDTH,
								p->buttonRect.top+iBCent,
								(LINEDDAPROC)sDottedLineProc,
								(LPARAM)&DottedStruct);
					}
				}
			}

			//  if no space, we still need to paint children
			else 
			{
				if (p->cChildren) 
				{
					if (p->state & TLIS_EXPANDED) 
					{
						sPaintItems (hdc, pWD, item, y,
							indent+INCREMENTINDENT, p->childItem);
					}
				}
			}

		}
		else 
		{		// ((*item) <= pWD->iFirstRow) {
			p->selectRect.left = 0;
			p->selectRect.right = 0;
			p->selectRect.top = 0;
			p->selectRect.bottom = 0;

			p->buttonRect.left = 0;
			p->buttonRect.right = 0;
			p->buttonRect.top = 0;
			p->buttonRect.bottom = 0;

			if (p->cChildren) 
			{
				if (p->state & TLIS_EXPANDED) 
				{
					sPaintItems (hdc, pWD, item, y,
						indent+INCREMENTINDENT, p->childItem);
				}
			}
		}
		//  step to next tree item
		p = p->nextItem;
	}

	//	set next item to unusual value to flag end of list
	if (p) 
	{
		p->selectRect.left = 0;
		p->selectRect.right = -1;
		p->selectRect.top = 0;
		p->selectRect.bottom = -1;

		p->buttonRect.left = 0;
		p->buttonRect.right = -1;
		p->buttonRect.top = 0;
		p->buttonRect.bottom = -1;
	}
}


//	_______________________________________________
//
//  Paint one level of list (selected items only)

static void 
sPaintItemsDragBitmap (
		HDC				hdc, 
		TLWndData*		pWD, 
		ULONG			ulFlags, 
		int*			item, 
		int*			y,
		int				iLevel,
		TLTreeItem*		p, 
		BOOL*			pbStarted)
{
	SIZE			s;
	INT				iy;
	WCHAR			wsz[TRUNCBUFSIZE];
	RECT			rcBound;

	SetTextColor (hdc, GetSysColor (COLOR_WINDOWTEXT));
	SetBkColor (hdc, GetSysColor (COLOR_WINDOW));

	while (p) 
	{
		//  increment item count
		(*item)++;

		//  check if items are visible in window
		if ((*item) > (pWD->iFirstRow + pWD->iMaxRows + 2)) 
			break;

		if ((*item) > pWD->iFirstRow)
		{
			//  first paint the tree items  ...
			//  select colors based on state of tree item
			if (pWD->bTreeFocused &&
				(p->state & TLIS_SELECTED) &&
				((iLevel == 0) || !(ulFlags & TLRB_TOPLEVELONLY)))
			{
				*pbStarted = TRUE;

				//  bounding rectangle for this item
				rcBound.left = iLevel * INCREMENTINDENT;
				rcBound.top = *y+1;
				rcBound.bottom = p->selectRect.top + pWD->iRowHeight;

				if (p->state & TLIS_BOLD) 
					SelectObject (hdc, pWD->hFontBold);
				else if (p->state & TLIS_ITALICS)
					SelectObject (hdc, pWD->hFontItalic);
				else 
					SelectObject (hdc, pWD->hFont);

				sGetWideText (p->pszText, wsz, sizeof(wsz));
				sTruncateText (hdc, wsz,
						pWD->iFirstColumnWidth-
						(BUTTONWIDTH+BITMAPWIDTH+HTEXTSHIFT));
				GetTextExtentPoint32W (hdc, wsz, lstrlenW (wsz), &s);
				rcBound.right = rcBound.left + s.cx + HTEXTSHIFT;

				//  draw tree item text
				iy = rcBound.top + TEXTVERTOFF;
				SetTextAlign (hdc, TA_LEFT);
				TextOutW (hdc, rcBound.left+HTEXTSHIFT+BUTTONWIDTH, iy,
						wsz, lstrlenW(wsz));

				//  draw tree item bitmap, if there is space
				if (pWD->iFirstColumnWidth >= (BUTTONWIDTH+BITMAPWIDTH))
				{
					ImageList_Draw (pWD->hImageList, p->iImage, hdc,
							rcBound.left, rcBound.top+pWD->iBMPos,
							ILD_TRANSPARENT);
				}

				//  paint list items based on their data type
				SelectObject (hdc, pWD->hFont);

			}

			//  increment y coordinate to next row
			if (*pbStarted)
				*y += pWD->iRowHeight;

			// if there are expanded children, we need to add rows
			if (p->cChildren) 
			{
				if (p->state & TLIS_EXPANDED) 
				{
					sPaintItemsDragBitmap (hdc, pWD, ulFlags, item, y,
						iLevel+1, p->childItem, pbStarted);
				}
			}
		}
		else 
		{		// ((*item) <= pWD->iFirstRow) {
			if (p->cChildren)
			{
				if (p->state & TLIS_EXPANDED) 
				{
					sPaintItemsDragBitmap (hdc, pWD, ulFlags, item, y,
						iLevel+1, p->childItem, pbStarted);
				}
			}
		}
		//  step to next tree item
		p = p->nextItem;
	}
}


//	_______________________________________________
//
//  Paint one level of list (selected items only)

static void 
sCalcItemsDragBitmap (
		TLWndData*		pWD, 
		ULONG			ulFlags, 
		int*			item, 
		int*			y,
		int				iLevel, 
		TLTreeItem*		p, 
		BOOL*			pbStarted, 
		RECT*			prc)
{
	while (p) 
	{
		//  increment item count
		(*item)++;

		//  check if items are visible in window
		if ((*item) > (pWD->iFirstRow + pWD->iMaxRows + 2)) 
			break;

		if ((*item) > pWD->iFirstRow) 
		{
			//  first paint the tree items  ...
			//  select colors based on state of tree item
			if (pWD->bTreeFocused &&
				(p->state & TLIS_SELECTED) &&
				((iLevel == 0) || !(ulFlags & TLRB_TOPLEVELONLY)))
			{
				if (*pbStarted)
					prc->bottom = *y + pWD->iRowHeight;
				else 
				{
					prc->top = *y;
					prc->bottom = *y + pWD->iRowHeight;
					*pbStarted = TRUE;
				}
			}

			//  increment y coordinate to next row
			*y += pWD->iRowHeight;

			// if there are expanded children, we need to add empty rows
			if (p->cChildren) 
			{
				if (p->state & TLIS_EXPANDED) 
				{
					sCalcItemsDragBitmap (pWD, ulFlags, item, y,
							iLevel+1, p->childItem, pbStarted, prc);
				}
			}
		}
		else 
		{		// ((*item) <= pWD->iFirstRow) {
			if (p->cChildren) 
			{
				if (p->state & TLIS_EXPANDED)
				{
					sCalcItemsDragBitmap (pWD, ulFlags, item, y,
							iLevel+1, p->childItem, pbStarted, prc);
				}
			}
		}
		//  step to next tree item
		p = p->nextItem;
	}
}


//	_______________________________________________
//
//  Compute length of string terminated either by null
//	character or newline

static int
sTextLength (WCHAR* pwsz)
{
	int	i	= 0;

	if (pwsz)
	{
		while (*pwsz && (*pwsz != '\n'))
		{
			pwsz++;
			i++;
		}
	}

	return i;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -