示例#1
0
int cliHitTest(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, DWORD *flags)
{
	ClcContact *hitcontact = NULL;
	ClcGroup *hitgroup = NULL;
	int hit = -1;
	RECT clRect;
	if (CLUI_TestCursorOnBorders() != 0)
	{
		if (flags) *flags = CLCHT_NOWHERE;
		return -1;
	}
	if (flags) *flags = 0;
	GetClientRect(hwnd, &clRect);
	if (testx < 0 || testy < 0 || testy >= clRect.bottom || testx >= clRect.right) {
		if (flags) {
			if (testx < 0) *flags |= CLCHT_TOLEFT;
			else if (testx >= clRect.right) *flags |= CLCHT_TORIGHT;
			if (testy < 0) *flags |= CLCHT_ABOVE;
			else if (testy >= clRect.bottom) *flags |= CLCHT_BELOW;
		}
		return -1;
	}
	if (testx < dat->leftMargin) {
		if (flags) *flags |= CLCHT_INLEFTMARGIN | CLCHT_NOWHERE;
		return -1;
	}

	// Get hit item
	hit = cliRowHitTest(dat, dat->yScroll + testy);

	if (hit != -1)
		hit = cliGetRowByIndex(dat, hit, &hitcontact, &hitgroup);

	if (hit == -1) {
		if (flags) *flags |= CLCHT_NOWHERE | CLCHT_BELOWITEMS;
		return -1;
	}
	if (contact) *contact = hitcontact;
	if (group) *group = hitgroup;
	/////////

	if (((testx < hitcontact->pos_indent) && !dat->text_rtl) ||
		((testx>clRect.right - hitcontact->pos_indent) && dat->text_rtl))
	{
		if (flags) *flags |= CLCHT_ONITEMINDENT;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_check, testx, testy))
	{
		if (flags) *flags |= CLCHT_ONITEMCHECK;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_avatar, testx, testy))
	{
		if (flags) *flags |= CLCHT_ONITEMICON;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_icon, testx, testy))
	{
		if (flags) *flags |= CLCHT_ONITEMICON;
		return hit;
	}

	//	if (testx>hitcontact->pos_extra) {
	//		if (flags)
	{
		//			int c = -1;
		int i;
		for (i = 0; i < dat->extraColumnsCount; i++)
		{
			if (RectHitTest(&hitcontact->pos_extra[i], testx, testy))
			{
				if (flags) *flags |= CLCHT_ONITEMEXTRA | (i << 24);
				return hit;
			}
		}
	}

	if (dat->HiLightMode == 1)
	{
		if (flags) *flags |= CLCHT_ONITEMLABEL;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_label, testx, testy))
	{
		if (flags) *flags |= CLCHT_ONITEMLABEL;
		return hit;
	}

	if (flags) *flags |= CLCHT_NOWHERE;
	return hit;
}
示例#2
0
int HitTest(HWND hwnd,struct ClcData *dat,int testx,int testy,struct ClcContact **contact,struct ClcGroup **group,DWORD *flags)
{
	struct ClcContact *hitcontact;
	struct ClcGroup *hitgroup;
	int hit;
	RECT clRect;

	if(flags) *flags=0;
	GetClientRect(hwnd,&clRect);
	if(testx<0 || testy<0 || testy>=clRect.bottom || testx>=clRect.right) {
		if(flags) {
			if(testx<0) *flags|=CLCHT_TOLEFT;
			else if(testx>=clRect.right) *flags|=CLCHT_TORIGHT;
			if(testy<0) *flags|=CLCHT_ABOVE;
			else if(testy>=clRect.bottom) *flags|=CLCHT_BELOW;
		}
		return -1;
	}
	if(testx<dat->leftMargin) {
		if(flags) *flags|=CLCHT_INLEFTMARGIN|CLCHT_NOWHERE;
		return -1;
	}

	// Get hit item 
	hit = RowHeights_HitTest(dat, dat->yScroll + testy);

	if (hit != -1) 
		hit = GetRowByIndex(dat, hit, &hitcontact, &hitgroup);
	
	if(hit==-1) {
		if(flags) *flags|=CLCHT_NOWHERE|CLCHT_BELOWITEMS;
		return -1;
	}
	if(contact) *contact=hitcontact;
	if(group) *group=hitgroup;
	/////////

	if (testx<hitcontact->pos_indent) 
	{
		if(flags) *flags|=CLCHT_ONITEMINDENT;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_check, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMCHECK;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_avatar, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMICON;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_icon, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMICON;
		return hit;
	}
	
//	if (testx>hitcontact->pos_extra) {
//		if(flags)
		{
//			int c = -1;
			int i;
			for(i = 0; i < dat->extraColumnsCount; i++) 
			{  
			if (RectHitTest(&hitcontact->pos_extra[i], testx, testy)) 
					{
				if(flags) *flags|=CLCHT_ONITEMEXTRA|(i<<24);
						return hit;
					}
				}
			}
	
	if (DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==1) // || DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==2)
		{
		if(flags) *flags|=CLCHT_ONITEMLABEL;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_label, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMLABEL;
		return hit;
	}

	if(flags) *flags|=CLCHT_NOWHERE;
	return -1;
}