Example #1
0
bool C4IDList::ConsolidateValids(C4DefList &rDefs, int32_t dwCategory)
{
	bool fIDsRemoved=false;
	C4IDListChunk *pQueryChunk=this;
	size_t cnt=Count,cntl=0;
	C4Def* pDef;
	while (cnt--)
	{
		// ID does not resolve to a valid def or category is specified and def does not match category
		if (!(pDef = rDefs.ID2Def(pQueryChunk->id[cntl])) || (dwCategory && !(pDef->Category & dwCategory)))
		{
			// delete it
			DeleteItem(Count-cnt-1);
			// handle this list index again!
			--cntl;
			// something was done
			fIDsRemoved=true;
		}
		if (++cntl==C4IDListChunkSize)
		{
			pQueryChunk=pQueryChunk->pNext;
			cntl=0;
		}
	}
	return fIDsRemoved;
}
Example #2
0
StdStrBuf C4ObjectList::GetNameList(C4DefList &rDefs) const
{
	int cpos,idcount;
	C4ID c_id;
	C4Def *cdef;
	StdStrBuf Buf;
	for (cpos=0; (c_id=GetListID(C4D_All,cpos)); cpos++)
		if ((cdef=rDefs.ID2Def(c_id)))
		{
			idcount=ObjectCount(c_id);
			if (cpos>0) Buf.Append(", ");
			Buf.AppendFormat("%dx %s",idcount,cdef->GetName());
		}
	return Buf;
}
Example #3
0
int32_t C4IDList::GetNumberOfIDs(C4DefList &rDefs, int32_t dwCategory) const
{
	int32_t idnum=0;
	C4Def *cDef;
	const C4IDListChunk *pQueryChunk=this;
	size_t cnt=Count,cntl=0;
	while (cnt--)
	{
		if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
			idnum++;
		if (++cntl==C4IDListChunkSize)
		{
			pQueryChunk=pQueryChunk->pNext;
			cntl=0;
		}
	}
	return idnum;
}
Example #4
0
void C4IDList::Draw(C4Facet &cgo, int32_t iSelection,
                    C4DefList &rDefs, DWORD dwCategory,
                    bool fCounts, int32_t iAlign) const
{

	int32_t sections = cgo.GetSectionCount();
	int32_t idnum = GetNumberOfIDs(rDefs,dwCategory);
	int32_t firstid = Clamp<int32_t>(iSelection-sections/2,0,std::max<int32_t>(idnum-sections,0));
	int32_t idcount;
	C4ID c_id;
	C4Facet cgo2;
	char buf[10];
	for (int32_t cnt=0; (cnt<sections) && (c_id=GetID(rDefs,dwCategory,firstid+cnt,&idcount)); cnt++)
	{
		cgo2 = cgo.TruncateSection(iAlign);
		rDefs.Draw(c_id,cgo2,(firstid+cnt==iSelection),0);
		sprintf(buf,"%dx",idcount);
		if (fCounts) pDraw->TextOut(buf, ::GraphicsResource.FontRegular, 1.0, cgo2.Surface,cgo2.X+cgo2.Wdt-1, cgo2.Y + cgo2.Hgt - 1 - ::GraphicsResource.FontRegular.GetLineHeight(),C4Draw::DEFAULT_MESSAGE_COLOR,ARight);
	}

}
Example #5
0
bool C4IDList::SetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t iCount)
{
	int32_t cindex=-1;
	C4Def *cDef;
	C4IDListChunk *pQueryChunk=this;
	size_t cnt=Count,cntl=0;
	while (cnt--)
	{
		if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
		{
			cindex++;
			if (cindex==index) { pQueryChunk->Count[cntl]=iCount; return true; }
		}
		if (++cntl==C4IDListChunkSize)
		{
			pQueryChunk=pQueryChunk->pNext;
			cntl=0;
		}
	}
	return false;
}
Example #6
0
int32_t C4IDList::GetCount(C4DefList &rDefs, int32_t dwCategory, int32_t index) const
{
	int32_t cindex=-1;
	C4Def *cDef;
	const C4IDListChunk *pQueryChunk=this;
	size_t cnt=Count,cntl=0;
	while (cnt--)
	{
		if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
		{
			cindex++;
			if (cindex==index) return pQueryChunk->Count[cntl];
		}
		if (++cntl==C4IDListChunkSize)
		{
			pQueryChunk=pQueryChunk->pNext;
			cntl=0;
		}
	}
	return 0;
}
Example #7
0
// Access by category-sorted index
C4ID C4IDList::GetID(C4DefList &rDefs, int32_t dwCategory, int32_t index, int32_t *ipCount) const
{
	int32_t cindex=-1;
	C4Def *cDef;
	if (ipCount) *ipCount=0;
	// find id
	const C4IDListChunk *pQueryChunk=this;
	size_t cnt=Count,cntl=0;
	while (cnt--)
	{
		if ((dwCategory==C4D_All) || ( (cDef=rDefs.ID2Def(pQueryChunk->id[cntl])) && (cDef->Category & dwCategory) ) )
		{
			cindex++;
			if (cindex==index) { if (ipCount) *ipCount=pQueryChunk->Count[cntl]; return pQueryChunk->id[cntl]; }
		}
		if (++cntl==C4IDListChunkSize)
		{
			pQueryChunk=pQueryChunk->pNext;
			cntl=0;
		}
	}
	return C4ID::None;
}