コード例 #1
0
ファイル: modern_clcutils.cpp プロジェクト: kxepal/miranda-ng
void cliBeginRenameSelection(HWND hwnd, ClcData *dat)
{
	ClcContact *contact;
	ClcGroup *group;
	int indent, x, y, subident, h, w;
	RECT clRect;
	RECT r;


	KillTimer(hwnd, TIMERID_RENAME);
	ReleaseCapture();
	dat->iHotTrack = -1;
	dat->selection = cliGetRowByIndex(dat, dat->selection, &contact, &group);
	if (dat->selection == -1) return;
	if (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP) return;

	if (contact->type == CLCIT_CONTACT && contact->isSubcontact)
		subident = dat->subIndent;
	else
		subident = 0;

	for (indent = 0; group->parent; indent++, group = group->parent);
	GetClientRect(hwnd, &clRect);
	x = indent*dat->groupIndent + dat->iconXSpace - 2 + subident;
	w = clRect.right - x;
	y = cliGetRowTopY(dat, dat->selection) - dat->yScroll;
	h = dat->row_heights[dat->selection];
	{
		int i;
		for (i = 0; i <= FONTID_MODERN_MAX; i++)
			if (h < dat->fontModernInfo[i].fontHeight + 4) h = dat->fontModernInfo[i].fontHeight + 4;
	}
	//TODO contact->pos_label


	{

		RECT rectW;
		int h2;
		GetWindowRect(hwnd, &rectW);
		//       w = contact->pos_full_first_row.right-contact->pos_full_first_row.left;
		//       h = contact->pos_full_first_row.bottom-contact->pos_full_first_row.top;
		//w = clRect.right-x;
		//w = clRect.right-x;
		//x += rectW.left;//+contact->pos_full_first_row.left;
		//y += rectW.top;//+contact->pos_full_first_row.top;
		x = contact->pos_rename_rect.left + rectW.left;
		y = contact->pos_label.top + rectW.top;
		w = contact->pos_rename_rect.right - contact->pos_rename_rect.left;
		h2 = contact->pos_label.bottom - contact->pos_label.top + 4;
		h = h2;//max(h,h2);

	}

	{
		int a = 0;
		if (contact->type == CLCIT_GROUP)
		{
			if (dat->row_align_group_mode == 1) a |= ES_CENTER;
			else if (dat->row_align_group_mode == 2) a |= ES_RIGHT;
		}
		if (dat->text_rtl) a |= EN_ALIGN_RTL_EC;
		if (contact->type == CLCIT_GROUP)
			dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL);
		else
			dat->hwndRenameEdit = CreateWindow(_T("EDIT"), pcli->pfnGetContactDisplayName(contact->hContact, 0), WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL);
	}
	SetWindowLongPtr(dat->hwndRenameEdit, GWL_STYLE, GetWindowLongPtr(dat->hwndRenameEdit, GWL_STYLE)&(~WS_CAPTION) | WS_BORDER);
	SetWindowLongPtr(dat->hwndRenameEdit, GWLP_USERDATA, (LONG_PTR)dat);
	mir_subclassWindow(dat->hwndRenameEdit, RenameEditSubclassProc);
	SendMessage(dat->hwndRenameEdit, WM_SETFONT, (WPARAM)(contact->type == CLCIT_GROUP ? dat->fontModernInfo[FONTID_OPENGROUPS].hFont : dat->fontModernInfo[FONTID_CONTACTS].hFont), 0);
	SendMessage(dat->hwndRenameEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0);
	SendMessage(dat->hwndRenameEdit, EM_SETSEL, 0, -1);

	r.top = 1;
	r.bottom = h - 1;
	r.left = 0;
	r.right = w;

	//ES_MULTILINE

	SendMessage(dat->hwndRenameEdit, EM_SETRECT, 0, (LPARAM)&r);

	CLUI_ShowWindowMod(dat->hwndRenameEdit, SW_SHOW);
	SetWindowPos(dat->hwndRenameEdit, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	SetFocus(dat->hwndRenameEdit);
}
コード例 #2
0
ファイル: modern_clcutils.cpp プロジェクト: kxepal/miranda-ng
int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt)
{
	RECT clRect;
	int hit;
	ClcContact *contact = NULL, *movecontact = NULL;
	ClcGroup *group, *movegroup;
	DWORD hitFlags;
	int nSetSelection = -1;

	GetClientRect(hwnd, &clRect);
	dat->selection = dat->iDragItem;
	dat->iInsertionMark = -1;
	dat->nInsertionLevel = 0;
	if (!PtInRect(&clRect, pt)) return DROPTARGET_OUTSIDE;

	hit = cliHitTest(hwnd, dat, pt.x, pt.y, &contact, &group, &hitFlags);
	cliGetRowByIndex(dat, dat->iDragItem, &movecontact, &movegroup);
	if (hit == dat->iDragItem) return DROPTARGET_ONSELF;
	if (hit == -1 || hitFlags&CLCHT_ONITEMEXTRA || !movecontact) return DROPTARGET_ONNOTHING;

	if (movecontact->type == CLCIT_GROUP) {
		ClcContact *bottomcontact = NULL, *topcontact = NULL;
		ClcGroup *topgroup = NULL, *bottomgroup = NULL;
		int topItem = -1, bottomItem = -1;
		int ok = 0;
		if (pt.y + dat->yScroll < cliGetRowTopY(dat, hit) + dat->insertionMarkHitHeight || contact->type != CLCIT_GROUP) {
			//could be insertion mark (above)
			topItem = hit - 1; bottomItem = hit;
			bottomcontact = contact;
			bottomgroup = group;
			topItem = cliGetRowByIndex(dat, topItem, &topcontact, &topgroup);
			ok = 1;
		}
		else if ((pt.y + dat->yScroll >= cliGetRowTopY(dat, hit + 1) - dat->insertionMarkHitHeight)
			|| (contact->type == CLCIT_GROUP && contact->group->expanded && contact->group->cl.count > 0))
		{
			//could be insertion mark (below)
			topItem = hit; bottomItem = hit + 1;
			topcontact = contact; topgroup = group;
			bottomItem = cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup);
			ok = 1;
		}
		if (ok)
		{
			if (bottomItem == -1 && contact->type == CLCIT_GROUP)
			{
				bottomItem = topItem + 1;
			}
			else
			{
				if (bottomItem == -1 && contact->type != CLCIT_GROUP && contact->groupId == 0)
				{
					bottomItem = topItem;
					cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup);
				}
				if (bottomItem != -1 && bottomcontact->type != CLCIT_GROUP)
				{
					ClcGroup *gr = bottomgroup;
					do
					{
						bottomItem = cliGetRowByIndex(dat, bottomItem - 1, &bottomcontact, &bottomgroup);
					} while (bottomItem >= 0 && bottomcontact->type != CLCIT_GROUP && bottomgroup == gr);
					nSetSelection = bottomItem;
					bottomItem = cliGetRowByIndex(dat, bottomItem + 1, &bottomcontact, &bottomgroup);
				}
			}

			if (bottomItem == -1)	bottomItem = topItem + 1;
			{
				int bi = cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup);
				if (bi != -1)
				{
					group = bottomgroup;
					if (bottomcontact == movecontact || group == movecontact->group)	return DROPTARGET_ONSELF;
					dat->nInsertionLevel = -1; // decreasing here
					for (; group; group = group->parent)
					{
						dat->nInsertionLevel++;
						if (group == movecontact->group) return DROPTARGET_ONSELF;
					}
				}
			}
			dat->iInsertionMark = bottomItem;
			dat->selection = nSetSelection;
			return DROPTARGET_INSERTION;
		}
	}
	if (contact->type == CLCIT_GROUP)
	{
		if (dat->iInsertionMark == -1)
		{
			if (movecontact->type == CLCIT_GROUP)
			{	 //check not moving onto its own subgroup
				dat->iInsertionMark = hit + 1;
				for (; group; group = group->parent)
				{
					dat->nInsertionLevel++;
					if (group == movecontact->group) return DROPTARGET_ONSELF;
				}
			}
			dat->selection = hit;
			return DROPTARGET_ONGROUP;
		}
	}
	dat->selection = hit;

	if (!mir_strcmp(contact->proto, META_PROTO))
		return DROPTARGET_ONMETACONTACT;
	if (contact->isSubcontact)
		return DROPTARGET_ONSUBCONTACT;
	return DROPTARGET_ONCONTACT;
}
コード例 #3
0
int FindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, BOOL isIgnoreSubcontacts)
{
	int index = 0, i;
	int nowVisible = 1;

	ClcGroup *group = &dat->list;
	group->scanIndex = 0;
	group = &dat->list;

	for (;;) {
		if (group->scanIndex == group->cl.count) {
			ClcGroup *tgroup;
			group = group->parent;
			if (group == NULL)
				break;
			
			nowVisible = 1;
			for (tgroup = group; tgroup; tgroup = tgroup->parent) {
				if (!tgroup->expanded) {
					nowVisible = 0;
					break;
				}
			}
			group->scanIndex++;
			continue;
		}
		if (nowVisible) index++;
		if ((IsHContactGroup(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_GROUP && (dwItem & ~HCONTACT_ISGROUP) == group->cl.items[group->scanIndex]->groupId)  ||
			 (IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->hContact == dwItem) ||
			 (IsHContactInfo(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->hContact == (dwItem & ~HCONTACT_ISINFO)))
		{
			if (isVisible) {
				if (!nowVisible) *isVisible = 0;
				else {
					int posy = cliGetRowTopY(dat,index+1);
					if (posy < dat->yScroll)
						*isVisible = 0;
					else {
						RECT clRect;
						GetClientRect(hwnd,&clRect);
						if (posy >= dat->yScroll+clRect.bottom) *isVisible = 0;
						else *isVisible = 1;
					}
				}
			}
			if (contact) *contact = group->cl.items[group->scanIndex];
			if (subgroup) *subgroup = group;

			return 1;
		}

		if (!isIgnoreSubcontacts && IsHContactContact(dwItem) && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->SubAllocated > 0) {
			for (i = 0; i < group->cl.items[group->scanIndex]->SubAllocated; i++) {
				if (group->cl.items[group->scanIndex]->subcontacts[i].hContact == dwItem) {
					if (contact) *contact = &group->cl.items[group->scanIndex]->subcontacts[i];
					if (subgroup) *subgroup = group;
					return 1;
				}
			}
		}

		if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
			group = group->cl.items[group->scanIndex]->group;
			group->scanIndex = 0;
			nowVisible &= group->expanded;
			continue;
		}
		group->scanIndex++;
	}

	if (isVisible) *isVisible = FALSE;
	if (contact)   *contact = NULL;
	if (subgroup)  *subgroup = NULL;
	return 0;
}