Esempio n. 1
0
void CLVListItem::DrawItem(BView* owner, BRect itemRect, bool complete)
{
	BList* DisplayList = &((ColumnListView*)owner)->fColumnDisplayList;
	int32 NumberOfColumns = DisplayList->CountItems();
	//float PushMax = itemRect.right;
	CLVColumn* ThisColumn;
	BRect ThisColumnRect = itemRect;
	
	BRegion ClippingRegion;
	if(!complete)
		owner->GetClippingRegion(&ClippingRegion);
	else
		ClippingRegion.Set(itemRect);
	float LastColumnEnd = -1.0;

	//Draw the columns
	for(int32 Counter = 0; Counter < NumberOfColumns; Counter++)
	{
		ThisColumn = (CLVColumn*)DisplayList->ItemAt(Counter);
		if(!ThisColumn->IsShown())
			continue;
		ThisColumnRect.left = ThisColumn->fColumnBegin;
		ThisColumnRect.right = LastColumnEnd = ThisColumn->fColumnEnd;
		if(ThisColumnRect.right >= ThisColumnRect.left && ClippingRegion.Intersects(ThisColumnRect))
			DrawItemColumn(owner, ThisColumnRect, ((ColumnListView*)owner)->fColumnList.IndexOf(ThisColumn),complete);
	}
	//Fill the area after all the columns (so the select highlight goes all the way across)
	ThisColumnRect.left = LastColumnEnd + 1.0;
	ThisColumnRect.right = owner->Bounds().right;
	if(ThisColumnRect.left <= ThisColumnRect.right && ClippingRegion.Intersects(ThisColumnRect))
		DrawItemColumn(owner, ThisColumnRect,-1,complete);
}
Esempio n. 2
0
void DrawStuff(LPDRAWITEMSTRUCT lpDrawItem)
{
	PUSERKEYINFO pui;
	DRAWSTRUCT *ds;
	LISTSTRUCT *ls;
	int index;
	RECT rc;
	//HICON hIcon;
	HWND hDlg,hwndList;
	int max;
	BOOL focused;

	focused=TRUE;

	if(lpDrawItem->hwndItem!=0)
	{
		if(GetFocus()!=lpDrawItem->hwndItem)
			focused=FALSE;
	}

	hwndList=lpDrawItem->hwndItem;
	hDlg=GetParent(hwndList);
	
	ls=GetListStruct(hwndList);
	ds=GetDrawStruct(hDlg);

	pui=(PUSERKEYINFO)(lpDrawItem->itemData);
	CopyRect(&rc,&(lpDrawItem->rcItem));
#ifdef _WIN32
	ImageList_Draw(ds->hIml,pui->icon,
		lpDrawItem->hDC,
		rc.left+((CX_SMICON-16)/2),
		rc.top+((CY_SMICON-16)/2),
		ILD_TRANSPARENT);
#else
	hIcon=LoadIcon(gPGPsdkUILibInst,MAKEINTRESOURCE(pui->icon));
	
	DrawIcon(lpDrawItem->hDC,
		rc.left+((CX_SMICON-32)/2),
		rc.top+((CY_SMICON-32)/2),
		hIcon);
	
	DeleteObject(hIcon);
#endif
	rc.right=rc.left;
	rc.left=rc.left+16;

	max=0;

	for(index=0;index<NUMCOLUMNS;index++)
	{
#if LISTBOX
		max=max+ls->colwidth[index];
#else
		max=max+
			ListView_GetColumnWidth(lpDrawItem->hwndItem,index);
#endif
	}

	for(index=0;index<NUMCOLUMNS;index++)
	{
#if LISTBOX
		rc.right=rc.right+ls->colwidth[index];
#else
		rc.right=rc.right+
			ListView_GetColumnWidth(lpDrawItem->hwndItem,index);
#endif
		switch(index)
		{
			case 0:
			{
				HFONT oldFont;
				RECT origrc;

				// Save original rect
				CopyRect(&origrc,&rc);

				oldFont=SelectObject(lpDrawItem->hDC,
						ds->hFont);

				if(pui->pru->kind==kPGPRecipientUserKind_MissingRecipient)
					SelectObject(lpDrawItem->hDC,
						ds->hStrikeOut);

				// See if we need the lock icon
				if(pui->pru->lockRefCount!=0)
				{
					RECT temprc;

					CopyRect(&temprc,&rc);
					temprc.left=temprc.right-16;

					if(temprc.left>rc.left)
					{
						// Enough space. Draw Lock
						if((BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused)
						{
							FillRect (lpDrawItem->hDC, &temprc, ds->HighBrush);
						}
						else
						{
							FillRect (lpDrawItem->hDC, &temprc, ds->BackBrush);
						}

						ImageList_Draw(ds->hIml,IDX_CLOSEDLOCK,
							lpDrawItem->hDC,
							temprc.left+((CX_SMICON-16)/2),
							temprc.top+((CY_SMICON-16)/2),
							ILD_TRANSPARENT);

						// Make space for lock from text
						rc.right=rc.right-16;
					}
				}

				DrawItemColumn(lpDrawItem->hDC,pui->UserId,
					&rc);

				// Set rectangle back to original
				CopyRect(&rc,&origrc);

				SelectObject(lpDrawItem->hDC,oldFont);
				break;
			}

			case 1:
			{
				if(ds->DisplayMarginal)
					DrawBar(ds,lpDrawItem->hDC,&rc,pui->Validity,
						2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused);
				else
					DrawNoviceButton(ds,lpDrawItem->hDC,&rc,pui->Validity,
						2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused);
				break;
			}

/*			case 2: // we no longer display trust in rec dlg
			{
				DrawBar(ds,lpDrawItem->hDC,&rc,pui->Trust,
					2,(BOOL)(lpDrawItem->itemState & ODS_SELECTED)&&focused);
				break;
			}
*/
			case 2:
			{
				HFONT oldFont;

				oldFont=SelectObject(lpDrawItem->hDC,
						ds->hFont);

				DrawItemColumn(lpDrawItem->hDC,pui->szSize,
					&rc);

				SelectObject(lpDrawItem->hDC,oldFont);
				break;
			}
		}
		rc.left=rc.right;
	}
	lpDrawItem->rcItem.right=max;
}