Example #1
0
void KGListCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_nToolTipFlag)
	{
		CString szTipText = _T("");
		CRect	rect;
		SIZE    size;
		int nSubItemCount = 0;
		int nItemPos	  = 0;
		int nCurSubItem	  = 0;
		LPKGLISTITEM lpItem = NULL;
		nItemPos = HitTest(point);
		KG_PROCESS_ERROR(nItemPos != -1);
		nSubItemCount = GetHeaderCtrl()->GetItemCount();
		lpItem = (LPKGLISTITEM)GetItemData(nItemPos);
		KG_PROCESS_ERROR(lpItem);

		ZeroMemory(&size ,sizeof(size));
		if (*(lpItem->szTipText) == '\0')
		{
			for (nCurSubItem = nSubItemCount - 1; nCurSubItem >= 0; nCurSubItem--)
			{
				GetSubItemRect(nItemPos, nCurSubItem, LVIR_BOUNDS, rect);
				if (rect.PtInRect(point))
				{
					szTipText = GetItemText(nItemPos, nCurSubItem);
					CDC* pDC = GetDC();
					if (pDC && pDC->m_hDC)
						GetTextExtentPoint(
						pDC->m_hDC, szTipText.GetBuffer(), szTipText.GetLength(),
						&size
						);
					if (nCurSubItem == nSubItemCount - 1)
					{
						CRect rectClient;
						GetWindowRect(rectClient);
						ScreenToClient(rectClient);
						rect.right = rectClient.right;
						if (size.cx < rect.Width())
						{
							szTipText = _T(""); 
						}
					}
					else
					{
						if (size.cx < GetColumnWidth(nCurSubItem))
						{
							szTipText = _T("");
						}
					}
					break;
				}
			}
		}
		else
		{
			szTipText = lpItem->szTipText;
		}
		m_toolTipCtrl.Activate(TRUE);
		m_toolTipCtrl.UpdateTipText(szTipText.GetBuffer(), this);
		KillTimer(1);
		SetTimer(1, 2000, NULL);
	}

Exit0:
	return CListCtrl::OnMouseMove(nFlags, point);
}
Example #2
0
bool CGUIRenderingControl::CanFocusFromPoint(const CPoint &point) const
{ // mouse is allowed to focus this control, but it doesn't actually receive focus
  return IsVisible() && HitTest(point);
}
Example #3
0
STDMETHODIMP CDrawMenu::OnWindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, BOOL bSubObj, LRESULT *plResult)
{
	switch (msg)
	{
	case WM_MOUSEMOVE:
		{
			POINT point;
			point.x = GET_X_LPARAM(lParam);
			point.y = GET_Y_LPARAM(lParam);
			BOOL bHit;
			HitTest(point, &bHit);
			if (bHit)
			{
				m_bMouseOn = TRUE;
				m_spDrawObjectSite->TrackMouseLeave();
				FireViewChange();
			}
			else
			{
				m_bMouseOn = FALSE;
				FireViewChange();
			}
			if (m_enumButtonState == ButtonStateDown)
			{
				if (!bHit)
				{
					m_enumButtonState = ButtonStateUp;
					FireViewChange();
				}
			}
		}
		break;
	case WM_LBUTTONDOWN:
		{
			POINT point;
			point.x = GET_X_LPARAM(lParam);
			point.y = GET_Y_LPARAM(lParam);
			BOOL bHit;
			HitTest(point, &bHit);
			
			if (bHit)
			{
				m_enumButtonState = ButtonStateDown;
				FireViewChange();
				
 				if (m_arrItems.GetSize() > 0)
				{
					CComVariant varX = m_rcPosition.left;
					CComVariant varY = m_rcPosition.bottom;
					Popup(varX, varY);

					m_enumButtonState = ButtonStateUp;
					FireViewChange();
					msg = WM_LBUTTONUP;
				}
				else
				{
					Fire_MenuClick(0, NULL);
//					return S_OK;
				}
			}
			
		}
		break;
	case WM_LBUTTONUP:
	case WM_KILLFOCUS:
		m_enumButtonState = ButtonStateUp;
		FireViewChange();
		break;
	}

	return ICxDrawObjectImpl<CDrawMenu>::OnWindowMessage(msg, wParam, lParam, bSubObj, plResult);
}
Example #4
0
void Title::OnMouseMove(UINT nFlags, CPoint point)
{
	lock_guard<mutex> lock(g_hwnd_lock);
	static int oldX, oldY;
    int newX = point.x, newY = point.y;

	if ((newX != oldX) || (newY != oldY))
    {
        oldX = newX;
        oldY = newY;
	}

	HTREEITEM hitem = HitTest(point, &nFlags);
	if(hitem != nullptr)
	{
		if (!g_TrackingMouse)
		{
			TRACKMOUSEEVENT tme = {sizeof(TRACKMOUSEEVENT)};
			tme.hwndTrack = m_hWnd;
			tme.dwFlags = TME_LEAVE;

			TrackMouseEvent(&tme);

			::SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&g_toolItem);
 
			g_TrackingMouse = TRUE; 
		}

		Node *new_node = reinterpret_cast<Node *>(GetItemData(hitem));
		if(new_node != nullptr)
		{
			if(new_node != old_node)
			{
				old_node = new_node;
				WCHAR coords[128];
				switch(new_node->node_type_)
				{
					case TITLE_NODE:
						swprintf_s(coords, ARRAYSIZE(coords), _T("大区ID: %d 人数: %u"), new_node->id_, new_node->usercount_);
						break;
					case TITLE_ROOM:
						swprintf_s(coords, ARRAYSIZE(coords), _T("房间ID: %d 人数: %u"), new_node->id_, new_node->usercount_);
						break;
					case TITLE_USER:
						swprintf_s(coords, ARRAYSIZE(coords), _T("音频通道: %u 视频通道: %u 麦序: %u"),
							reinterpret_cast<User *>(new_node)->audio_ssrc_,
							reinterpret_cast<User *>(new_node)->video_ssrc_,
							reinterpret_cast<User *>(new_node)->mic_id_);
						break;
					default:
						break;
				}

				g_toolItem.lpszText = coords;
				::SendMessage(g_hwndTrackingTT, TTM_SETTOOLINFO, 0, (LPARAM)&g_toolItem);

				POINT pt = {newX, newY};
				::ClientToScreen(m_hWnd, &pt);
				::SendMessage(g_hwndTrackingTT, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(pt.x + 10, pt.y - 20));
			}
		}
	}
	else
	{
		::SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)FALSE, (LPARAM)&g_toolItem);
		g_TrackingMouse = FALSE;
	}

	CTreeCtrl::OnMouseMove(nFlags, point); 
}
void COutlook2Ctrl::OnMouseMove(UINT nFlags, CPoint point)
{
	if (m_iDragging == 1)
	{
		CRect rc1(m_dragRect);
		m_dragRect.SetRect(point.x-5 + m_iDragoffset, rc1.top, point.x + m_iDragoffset, rc1.bottom);
		if (rc1 != m_dragRect)
		{
			OnInvertTracker(rc1);
			OnInvertTracker(m_dragRect);
		}
	}
	else
	{
		int f,i,s;
		int r = HitTest(f,i,s,point);
		if (r == 1)
		{
			CClientDC dc(this); 
			if (iHiFolder >= 0 && iHiFolder != f)
			{
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false);
			}
			if (iHiFolder != f)
			{
				iHiFolder = f;
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, true);
			}
		}
		if (r == 4)
		{
			COL2SubItem	* ps = GetSubItem(f,i,s);
			CClientDC dc(this); 
			if (pLastHilink && pLastHilink != ps)
			{
				DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false);
			}
			if (pLastHilink != ps)
			{
				pLastHilink = ps;
				DrawSubItem(&dc, GetFolder(f), GetItem(f,i), ps, true);
				iHilinkFolder = f;
				iHilinkItem = i;
			}
		}

		if (r == 0)
		{
			if (iHiFolder >= 0)
			{
				CClientDC dc(this); 
				DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false);
				iHiFolder = -1;
			}
			if (pLastHilink != NULL)
			{
				CClientDC dc(this); 
				DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false);
				pLastHilink = NULL;
			}
		}
	}

	OLCTRL2_BASE_CLASS::OnMouseMove(nFlags, point);
}
void CXTPPopupControl::OnMouseMove(UINT nFlags, CPoint point)
{
	if (!m_bSplashScreenMode)
	{
		CXTPClientRect rc(this);

		//test client rect if no-pressed
		BOOL bInRect = rc.PtInRect(point) || m_pPressed != NULL;

		//if test successfull and already not capture
		if (bInRect && !m_bCapture)
		{
			//set capture
			m_bCapture = TRUE;

			//opaque window
			SetLayeredWindowAttributes(255);

			//capture mouse leave event
			TRACKMOUSEEVENT tme =
			{
				sizeof(TRACKMOUSEEVENT), TME_LEAVE, m_hWnd, 0
			};
			_TrackMouseEvent(&tme);
		}
		//else if test fail and there is pressed and selected control
		if (!bInRect && m_bCapture && m_pPressed == NULL)
		{
			//free capture
			m_bCapture = FALSE;
			//set current transparent
			SetLayeredWindowAttributes(m_nTransparency);
		}

		//if collapsing state - expand popup window
		if (m_popupState == xtpPopupStateCollapsing)
		{
			//kill collapsing timer
			KillTimer(TID_COLLAPSING);

			if (m_popupAnimation == xtpPopupAnimationFade)
			{
				OnShow();
			}
			else
			{
				OnExpanding(FALSE);
			}
		}
	}

	//test point to controled items
	CXTPPopupItem* pSelected = HitTest(point);

	//if detect new selected item ore lose selection (NULL)
	if (pSelected != m_pSelected)
	{
		//select new item ore set NULL
		m_pSelected = (m_pPressed == 0 || m_pPressed == pSelected || pSelected == NULL) ? pSelected : NULL;

		//redraw all items
		RedrawControl();
	}

	CWnd::OnMouseMove(nFlags, point);
}
Example #7
0
// This shows a little tooltip with the current Game's emulation state
void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
{
	int flags;
	long subitem = 0;
	const long item = HitTest(event.GetPosition(), flags, &subitem);
	static int lastItem = -1;

	if (GetColumnCount() <= 1)
		return;

	if (item != wxNOT_FOUND)
	{
		wxRect Rect;
#ifdef __WXMSW__
		if (subitem == COLUMN_EMULATION_STATE)
#else
		// The subitem parameter of HitTest is only implemented for wxMSW.  On
		// all other platforms it will always be -1.  Check the x position
		// instead.
		GetItemRect(item, Rect);
		if (Rect.GetX() + Rect.GetWidth() - GetColumnWidth(COLUMN_EMULATION_STATE) < event.GetX())
#endif
		{
			if (toolTip || lastItem == item || this != FindFocus())
			{
				if (lastItem != item) lastItem = -1;
				event.Skip();
				return;
			}

			// Emulation status
			static const char* const emuState[] = { "Broken", "Intro", "In-Game", "Playable", "Perfect" };

			const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];

			const int emu_state = rISO.GetEmuState();
			const std::string& issues = rISO.GetIssues();

			// Show a tooltip containing the EmuState and the state description
			if (emu_state > 0 && emu_state < 6)
			{
				char temp[2048];
				sprintf(temp, "^ %s%s%s", emuState[emu_state - 1],
						issues.size() > 0 ? " :\n" : "", issues.c_str());
				toolTip = new wxEmuStateTip(this, StrToWxStr(temp), &toolTip);
			}
			else
			{
				toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip);
			}

			// Get item Coords
			GetItemRect(item, Rect);
			int mx = Rect.GetWidth();
			int my = Rect.GetY();
#ifndef __WXMSW__
			// For some reason the y position does not account for the header
			// row, so subtract the y position of the first visible item.
			GetItemRect(GetTopItem(), Rect);
			my -= Rect.GetY();
#endif
			// Convert to screen coordinates
			ClientToScreen(&mx, &my);
			toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(COLUMN_EMULATION_STATE),
						my, GetColumnWidth(COLUMN_EMULATION_STATE), Rect.GetHeight()));
			toolTip->SetPosition(wxPoint(mx - GetColumnWidth(COLUMN_EMULATION_STATE),
						my - 5 + Rect.GetHeight()));
			lastItem = item;
		}
	}
	if (!toolTip)
		lastItem = -1;

	event.Skip();
}
Example #8
0
LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	ClcContact *contact;
	ClcGroup *group;
	BOOL frameHasTitlebar = FALSE;

	if (wndFrameCLC)
		frameHasTitlebar = wndFrameCLC->TitleBar.ShowTitleBar;

	ClcData *dat = (struct ClcData *)GetWindowLongPtr(hwnd, 0);
	if (msg >= CLM_FIRST && msg < CLM_LAST)
		return ProcessExternalMessages(hwnd, dat, msg, wParam, lParam);

	switch (msg) {
	case WM_CREATE:
		dat = (struct ClcData *)mir_calloc(sizeof(struct ClcData));
		SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat);

		RowHeight::Init(dat);
		dat->forceScroll = 0;
		dat->lastRepaint = 0;
		dat->hwndParent = GetParent(hwnd);
		dat->lastSort = GetTickCount();
		dat->needsResort = FALSE;
		{
			CREATESTRUCT *cs = (CREATESTRUCT *)lParam;
			if (cs->lpCreateParams == (LPVOID)0xff00ff00) {
				dat->bisEmbedded = FALSE;
				dat->bHideSubcontacts = TRUE;
				cfg::clcdat = dat;
				if (cfg::dat.bShowLocalTime)
					SetTimer(hwnd, TIMERID_REFRESH, 65000, NULL);
			}
			else
				dat->bisEmbedded = TRUE;
		}
		break;

	case WM_SIZE:
		pcli->pfnEndRename(hwnd, dat, 1);
		KillTimer(hwnd, TIMERID_INFOTIP);
		KillTimer(hwnd, TIMERID_RENAME);
		pcli->pfnRecalcScrollBar(hwnd, dat);
LBL_Def:
		return DefWindowProc(hwnd, msg, wParam, lParam);

	case WM_NCCALCSIZE:
		return FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, frameHasTitlebar);

		/*
		* scroll bar handling
		*/
	case WM_NCPAINT:
		return FrameNCPaint(hwnd, DefWindowProc, wParam, lParam, frameHasTitlebar);

	case INTM_GROUPCHANGED:
		{
			WORD iExtraImage[EXTRA_ICON_COUNT];
			BYTE flags = 0;
			if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
				memset(iExtraImage, 0xFF, sizeof(iExtraImage));
			else {
				memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage));
				flags = contact->flags;
			}
			pcli->pfnDeleteItemFromTree(hwnd, wParam);
			if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(wParam, NULL, dat)) {
				pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1);
				if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
					memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage));
					if (flags & CONTACTF_CHECKED)
						contact->flags |= CONTACTF_CHECKED;
				}

				NMCLISTCONTROL nm;
				nm.hdr.code = CLN_CONTACTMOVED;
				nm.hdr.hwndFrom = hwnd;
				nm.hdr.idFrom = GetDlgCtrlID(hwnd);
				nm.flags = 0;
				nm.hItem = (HANDLE)wParam;
				SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm);
			}
			dat->needsResort = TRUE;
			PostMessage(hwnd, INTM_SORTCLC, 0, 1);
		}
		goto LBL_Def;

	case INTM_ICONCHANGED:
		{
			int recalcScrollBar = 0;
			MCONTACT hContact = wParam;
			WORD status = ID_STATUS_OFFLINE;
			int  contactRemoved = 0;
			MCONTACT hSelItem = NULL;
			ClcContact *selcontact = NULL;

			char *szProto = GetContactProto(hContact);
			if (szProto == NULL)
				status = ID_STATUS_OFFLINE;
			else
				status = cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE);

			int shouldShow = (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN ||
				!CLVM_GetContactHiddenStatus(hContact, szProto, dat)) && ((cfg::dat.bFilterEffective ? TRUE : !pcli->pfnIsHiddenMode(dat, status)) ||
				pcli->pfnGetContactIcon(hContact) != lParam); // XXX CLVM changed - this means an offline msg is flashing, so the contact should be shown

			if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, &group, NULL)) {
				if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
					if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
						hSelItem = (MCONTACT)pcli->pfnContactToHItem(selcontact);
					pcli->pfnAddContactToTree(hwnd, dat, hContact, 0, 0);
					recalcScrollBar = 1;
					FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL);
					if (contact) {
						contact->iImage = (WORD)lParam;
						pcli->pfnNotifyNewContact(hwnd, hContact);
					}
				}
			}
			else {
				//item in list already
				DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
				if (contact->iImage == (WORD)lParam)
					break;
				if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline || cfg::dat.bFilterEffective)) {        // CLVM changed
					if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1)
						hSelItem = (MCONTACT)pcli->pfnContactToHItem(selcontact);
					pcli->pfnRemoveItemFromGroup(hwnd, group, contact, 0);
					contactRemoved = TRUE;
					recalcScrollBar = 1;
				}
				else {
					contact->iImage = (WORD)lParam;
					if (!pcli->pfnIsHiddenMode(dat, status))
						contact->flags |= CONTACTF_ONLINE;
					else
						contact->flags &= ~CONTACTF_ONLINE;
				}
			}
			if (hSelItem) {
				ClcGroup *selgroup;
				if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
					dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)& selgroup->cl, selcontact));
				else
					dat->selection = -1;
			}
			dat->needsResort = TRUE;
			PostMessage(hwnd, INTM_SORTCLC, 0, recalcScrollBar);
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contactRemoved ? 0 : wParam));
			if (recalcScrollBar)
				pcli->pfnRecalcScrollBar(hwnd, dat);
		}
		goto LBL_Def;

	case INTM_METACHANGED:
		if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL))
			break;

		if (contact->bIsMeta && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
			contact->hSubContact = db_mc_getMostOnline(contact->hContact);
			contact->metaProto = GetContactProto(contact->hSubContact);
			contact->iImage = pcli->pfnGetContactIcon(contact->hSubContact);
			if (contact->pExtra) {
				TExtraCache *pSub = cfg::getCache(contact->hSubContact, contact->metaProto);
				ClcContact *subContact;
				if (!pcli->pfnFindItem(hwnd, dat, contact->hSubContact, &subContact, NULL, NULL))
					break;

				contact->pExtra->proto_status_item = GetProtocolStatusItem(contact->metaProto);
				if (pSub) {
					contact->pExtra->status_item = pSub->status_item;
					memcpy(contact->iExtraImage, subContact->iExtraImage, sizeof(contact->iExtraImage));
				}
			}
		}
		SendMessage(hwnd, INTM_NAMEORDERCHANGED, wParam, lParam);
		goto LBL_Def;

	case INTM_METACHANGEDEVENT:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;
		if (lParam == 0)
			pcli->pfnInitAutoRebuild(hwnd);
		goto LBL_Def;

	case INTM_NAMECHANGED:
		ClcContact *contact;
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;
		mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText));

		RTL_DetectAndSet(contact, 0);

		dat->needsResort = TRUE;
		PostMessage(hwnd, INTM_SORTCLC, 0, 0);
		goto LBL_Def;

	case INTM_CODEPAGECHANGED:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;
		contact->codePage = cfg::getDword(wParam, "Tab_SRMsg", "ANSIcodepage", cfg::getDword(wParam, "UserInfo", "ANSIcodepage", CP_ACP));
		PostMessage(hwnd, INTM_INVALIDATE, 0, 0);
		goto LBL_Def;

	case INTM_AVATARCHANGED:
		contact = NULL;
		{
			avatarCacheEntry *cEntry = (struct avatarCacheEntry *)lParam;

			if (wParam == 0) {
				//RemoveFromImgCache(0, cEntry);
				cfg::dat.bForceRefetchOnPaint = TRUE;
				RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
				cfg::dat.bForceRefetchOnPaint = FALSE;
				goto LBL_Def;
			}

			if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
				return 0;
			contact->ace = cEntry;
			if (cEntry == NULL)
				contact->cFlags &= ~ECF_AVATAR;
			else {
				DWORD dwFlags;

				if (contact->pExtra)
					dwFlags = contact->pExtra->dwDFlags;
				else
					dwFlags = cfg::getDword(contact->hContact, "CList", "CLN_Flags", 0);
				if (cfg::dat.dwFlags & CLUI_FRAME_AVATARS)
					contact->cFlags = (dwFlags & ECF_HIDEAVATAR ? contact->cFlags & ~ECF_AVATAR : contact->cFlags | ECF_AVATAR);
				else
					contact->cFlags = (dwFlags & ECF_FORCEAVATAR ? contact->cFlags | ECF_AVATAR : contact->cFlags & ~ECF_AVATAR);
			}
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)contact->hContact);
		}
		goto LBL_Def;

	case INTM_STATUSMSGCHANGED:
		{
			TExtraCache *p;
			char *szProto = NULL;

			if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
				p = cfg::getCache(wParam, NULL);
			else {
				p = contact->pExtra;
				szProto = contact->proto;
			}
			GetCachedStatusMsg(p, szProto);
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0));
		}
		goto LBL_Def;

	case INTM_STATUSCHANGED:
		if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
			WORD wStatus = cfg::getWord(wParam, contact->proto, "Status", ID_STATUS_OFFLINE);
			if (cfg::dat.bNoOfflineAvatars && wStatus != ID_STATUS_OFFLINE && contact->wStatus == ID_STATUS_OFFLINE) {
				contact->wStatus = wStatus;
				if (cfg::dat.bAvatarServiceAvail && contact->ace == NULL)
					LoadAvatarForContact(contact);
			}
			contact->wStatus = wStatus;
			goto LBL_Def;
		}
		break;

	case INTM_PROTOCHANGED:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL))
			break;

		contact->proto = GetContactProto(wParam);
		CallService(MS_CLIST_INVALIDATEDISPLAYNAME, wParam, 0);
		mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText));

		RTL_DetectAndSet(contact, 0);

		dat->needsResort = TRUE;
		PostMessage(hwnd, INTM_SORTCLC, 0, 0);
		goto LBL_Def;

	case INTM_INVALIDATE:
		if (!dat->bNeedPaint) {
			KillTimer(hwnd, TIMERID_PAINT);
			SetTimer(hwnd, TIMERID_PAINT, 100, NULL);
			dat->bNeedPaint = TRUE;
		}
		goto LBL_Def;

	case INTM_INVALIDATECONTACT:
		if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, &group, NULL))
			break;

		if (contact && group) {
			int iItem = pcli->pfnGetRowsPriorTo(&dat->list, group, List_IndexOf((SortedList*) & group->cl, contact));
			pcli->pfnInvalidateItem(hwnd, dat, iItem);
			goto LBL_Def;
		}
		break;

	case INTM_FORCESORT:
		dat->needsResort = TRUE;
		return SendMessage(hwnd, INTM_SORTCLC, wParam, lParam);

	case INTM_SORTCLC:
		if (dat->needsResort) {
			pcli->pfnSortCLC(hwnd, dat, TRUE);
			dat->needsResort = FALSE;
		}
		if (lParam)
			pcli->pfnRecalcScrollBar(hwnd, dat);
		goto LBL_Def;

	case INTM_IDLECHANGED:
		if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) {
			DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
			char *szProto = (char*)cws->szModule;
			if (szProto == NULL)
				break;

			contact->flags &= ~CONTACTF_IDLE;
			if (cfg::getDword(wParam, szProto, "IdleTS", 0)) {
				contact->flags |= CONTACTF_IDLE;
			}
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)contact->hContact);
			goto LBL_Def;
		}
		break;

	case INTM_XSTATUSCHANGED:
		{
			DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
			char *szProto = (char *)cws->szModule;
			MCONTACT hContact = wParam;
			TExtraCache *p;

			if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL)) {
				p = cfg::getCache(hContact, szProto);
				if (!dat->bisEmbedded && szProto) {				// may be a subcontact, forward the xstatus
					MCONTACT hMasterContact = db_mc_tryMeta(hContact);
					if (hMasterContact != hContact)				// avoid recursive call of settings handler
						cfg::writeByte(hMasterContact, META_PROTO, "XStatusId", (BYTE)cfg::getByte(hContact, szProto, "XStatusId", 0));
					break;
				}
			}
			else {
				contact->xStatus = cfg::getByte(hContact, szProto, "XStatusId", 0);
				p = contact->pExtra;
			}

			if (szProto == NULL)
				break;

			if (contact) {
				if (ProtoServiceExists(szProto, PS_GETADVANCEDSTATUSICON)) {
					int iconId = ProtoCallService(szProto, PS_GETADVANCEDSTATUSICON, hContact, 0);
					if (iconId != -1)
						contact->xStatusIcon = iconId >> 16;
				}
			}

			GetCachedStatusMsg(p, szProto);
			PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0));
		}
		goto LBL_Def;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint(hwnd, &ps);
			if (IsWindowVisible(hwnd) && !during_sizing && !cfg::shutDown) {
				PaintClc(hwnd, dat, hdc, &ps.rcPaint);
				dat->bNeedPaint = FALSE;
				dat->lastRepaint = GetTickCount();
			}
			EndPaint(hwnd, &ps);
			if (dat->selection != dat->oldSelection && !dat->bisEmbedded && g_ButtonItems != NULL) {
				SetDBButtonStates(0);
				dat->oldSelection = dat->selection;
			}
		}
		goto LBL_Def;

	case WM_MOUSEWHEEL:
		dat->forceScroll = TRUE;
		break;

	case WM_TIMER:
		if (wParam == TIMERID_PAINT) {
			KillTimer(hwnd, TIMERID_PAINT);
			InvalidateRect(hwnd, NULL, FALSE);
			goto LBL_Def;
		}

		if (wParam == TIMERID_REFRESH) {
			InvalidateRect(hwnd, NULL, FALSE);
			goto LBL_Def;
		}
		break;

	case WM_LBUTTONDBLCLK:
		ReleaseCapture();
		dat->iHotTrack = -1;
		pcli->pfnHideInfoTip(hwnd, dat);
		KillTimer(hwnd, TIMERID_RENAME);
		KillTimer(hwnd, TIMERID_INFOTIP);
		dat->szQuickSearch[0] = 0;
		{
			DWORD hitFlags;
			dat->selection = HitTest(hwnd, dat, (short) LOWORD(lParam), (short) HIWORD(lParam), &contact, NULL, &hitFlags);
			if (hitFlags & CLCHT_ONITEMEXTRA)
				break;

			InvalidateRect(hwnd, NULL, FALSE);
			if (dat->selection != -1)
				pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
			if (hitFlags & CLCHT_ONAVATAR && cfg::dat.bDblClkAvatars) {
				CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)contact->hContact, 0);
				return TRUE;
			}
			if (hitFlags & (CLCHT_ONITEMICON | CLCHT_ONITEMLABEL | CLCHT_ONITEMSPACE)) {
				UpdateWindow(hwnd);
				pcli->pfnDoSelectionDefaultAction(hwnd, dat);
			}
		}
		return TRUE;

	case WM_CONTEXTMENU:
		{
			HMENU hMenu = NULL;
			POINT pt;
			DWORD hitFlags;

			pcli->pfnEndRename(hwnd, dat, 1);
			pcli->pfnHideInfoTip(hwnd, dat);
			KillTimer(hwnd, TIMERID_RENAME);
			KillTimer(hwnd, TIMERID_INFOTIP);
			if (GetFocus() != hwnd)
				SetFocus(hwnd);
			dat->iHotTrack = -1;
			dat->szQuickSearch[0] = 0;
			pt.x = (short) LOWORD(lParam);
			pt.y = (short) HIWORD(lParam);
			if (pt.x == -1 && pt.y == -1) {
				dat->selection = pcli->pfnGetRowByIndex(dat, dat->selection, &contact, NULL);
				if (dat->selection != -1)
					pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
				pt.x = dat->iconXSpace + 15;
				pt.y = RowHeight::getItemTopY(dat, dat->selection) - dat->yScroll + (int)(dat->row_heights[dat->selection] * .7);
				hitFlags = dat->selection == -1 ? CLCHT_NOWHERE : CLCHT_ONITEMLABEL;
			}
			else {
				ScreenToClient(hwnd, &pt);
				dat->selection = HitTest(hwnd, dat, pt.x, pt.y, &contact, NULL, &hitFlags);
			}
			InvalidateRect(hwnd, NULL, FALSE);
			if (dat->selection != -1)
				pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0);
			UpdateWindow(hwnd);

			if (dat->selection != -1 && hitFlags & (CLCHT_ONITEMICON | CLCHT_ONITEMCHECK | CLCHT_ONITEMLABEL)) {
				if (contact->type == CLCIT_GROUP) {
					hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDSUBGROUP, (WPARAM)contact->group, 0);
					ClientToScreen(hwnd, &pt);
					TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, pcli->hwndContactList, NULL);
					CheckMenuItem(hMenu, POPUP_GROUPHIDEOFFLINE, contact->group->hideOffline ? MF_CHECKED : MF_UNCHECKED);
					DestroyMenu(hMenu);
					return 0;
				} else if (contact->type == CLCIT_CONTACT)
					hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) contact->hContact, 0);
			} else {
				//call parent for new group/hide offline menu
				PostMessage(GetParent(hwnd), WM_CONTEXTMENU, wParam, lParam);
				return 0;
			}
			if (hMenu != NULL) {
				ClientToScreen(hwnd, &pt);
				TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
				DestroyMenu(hMenu);
			}
		}
		return 0;

	case WM_COMMAND:
		if (LOWORD(wParam) == POPUP_NEWGROUP)
			SendMessage(GetParent(hwnd), msg, wParam, lParam);
		break;

	case WM_NCHITTEST:
		{
			LRESULT lr = SendMessage(GetParent(hwnd), WM_NCHITTEST, wParam, lParam);
			if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT
				|| lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT)
				return HTTRANSPARENT;
		}
		break;

	case WM_DESTROY:
		RowHeight::Free(dat);
		break;
	}

	return coreCli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam);
}
Example #9
0
//***************************************************************************************
void CBCGPShellList::OnContextMenu(CWnd* /*pWnd*/, CPoint point) 
{
	ASSERT_VALID (this);
	ASSERT_VALID (g_pShellManager);
	ASSERT (g_pShellManager->m_pBCGMalloc != NULL);

	if (m_pContextMenu2 != NULL)
	{
		return;
	}

	if (!m_bContextMenu)
	{
		Default ();
		return;
	}

	if (m_psfCurFolder == NULL)
	{
		return;
	}

	UINT	nSelItems = GetSelectedCount ();
	int		nClickedItem = -1;

	if (point.x == -1 && point.y == -1)
	{
		//--------------------------------------------------------
		// Keyboard, show menu for the currently selected item(s):
		//--------------------------------------------------------
		if (nSelItems == 0)
		{
			return;
		}

		int nCurItem = -1;
		int nLastSelItem = -1;

		for (UINT i = 0; i < nSelItems; i++)
		{
			nCurItem = GetNextItem (nCurItem, LVNI_SELECTED);
			nLastSelItem = nCurItem;
		}

		CRect rectItem;
		if (GetItemRect (nLastSelItem, rectItem, LVIR_BOUNDS))
		{
			point.x = rectItem.left;
			point.y = rectItem.bottom + 1;

			ClientToScreen (&point);
		}
	}
	else
	{
		//--------------------------
		// Clicked on specifed item:
		//--------------------------
		LVHITTESTINFO lvhti;
		lvhti.pt = point;
		ScreenToClient(&lvhti.pt);
		
		lvhti.flags = LVHT_NOWHERE;
		
		HitTest (&lvhti);
		
		if ((lvhti.flags & LVHT_ONITEM) == 0)
		{
			//-----------------------------------
			// Click ouside of items, do nothing
			//-----------------------------------
			return;
		}

		nClickedItem = lvhti.iItem;
	}

	LPITEMIDLIST* pPidls = (LPITEMIDLIST*) 
						g_pShellManager->m_pBCGMalloc->Alloc (sizeof(LPITEMIDLIST) * nSelItems);
	ASSERT (pPidls != NULL);

	//------------------------
	// Get the selected items:
	//------------------------
	LVITEM lvItem;
	ZeroMemory(&lvItem, sizeof(lvItem));
	lvItem.mask = LVIF_PARAM;

	LPBCGCBITEMINFO pClickedInfo = (LPBCGCBITEMINFO)lvItem.lParam;

	if (nClickedItem >= 0)
	{
		//-------------------------------------------
		// Put the item clicked on first in the list:
		//-------------------------------------------
		lvItem.iItem = nClickedItem;

		if (GetItem (&lvItem))
		{
			pClickedInfo = (LPBCGCBITEMINFO)lvItem.lParam;
			pPidls [0] = pClickedInfo->pidlRel;
		}
	}
	
	int nCurItem = -1;
	for (UINT i = nClickedItem >= 0 ? 1 : 0; i < nSelItems; i++)
	{
		nCurItem = GetNextItem (nCurItem, LVNI_SELECTED);
		if (nCurItem != nClickedItem)
		{
			lvItem.iItem = nCurItem;

			if (GetItem (&lvItem))
			{
				LPBCGCBITEMINFO pInfo = (LPBCGCBITEMINFO)lvItem.lParam;
				pPidls [i] = pInfo->pidlRel;

				if (pClickedInfo == NULL)
				{
					pClickedInfo = pInfo;
				}
			}
		}
		else
		{
			i--;
		}
	}
	
	if (pPidls [0] == NULL)
	{
		g_pShellManager->m_pBCGMalloc->Free (pPidls);
		return;
	}

	IContextMenu* pcm;
	HRESULT hr = m_psfCurFolder->GetUIObjectOf (GetSafeHwnd (),
		nSelItems, 
		(LPCITEMIDLIST*)pPidls, 
		IID_IContextMenu, 
		NULL, 
		(LPVOID*)&pcm);
	
	if (SUCCEEDED (hr))
	{
		hr = pcm->QueryInterface (IID_IContextMenu2, (LPVOID*)&m_pContextMenu2);

		if (SUCCEEDED (hr))
		{
			HMENU hPopup = CreatePopupMenu ();
			if (hPopup != NULL)
			{
				hr = m_pContextMenu2->QueryContextMenu(hPopup, 0, 1, 0x7fff, CMF_NORMAL | CMF_EXPLORE);
				
				if (SUCCEEDED(hr))
				{
					UINT idCmd = TrackPopupMenu (hPopup,
							TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, 
							point.x,
							point.y,
							0,
							GetSafeHwnd (),
							NULL);

					if (idCmd != 0)
					{
						BOOL bIsFolder = FALSE;

						if (nSelItems == 1 &&
							idCmd == ::GetMenuDefaultItem (hPopup, FALSE, 0))
						{
							//-----------------------------------------------------
							// If specified element is a folder, try to display it:
							//-----------------------------------------------------
							ULONG ulAttrs = SFGAO_FOLDER;
							m_psfCurFolder->GetAttributesOf (1, 
								(const struct _ITEMIDLIST **) &pClickedInfo->pidlRel, &ulAttrs);

							if (ulAttrs & SFGAO_FOLDER)
							{
								bIsFolder = TRUE;
								DisplayFolder (pClickedInfo);
							}
						}

						if (!bIsFolder)
						{
							CMINVOKECOMMANDINFO cmi;
							cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
							cmi.fMask = 0;
							cmi.hwnd = GetParent ()->GetSafeHwnd ();
							cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1);
							cmi.lpParameters = NULL;
							cmi.lpDirectory = NULL;
							cmi.nShow = SW_SHOWNORMAL;
							cmi.dwHotKey = 0;
							cmi.hIcon = NULL;

							hr = pcm->InvokeCommand (&cmi);

							if (SUCCEEDED (hr) && GetParent () != NULL)
							{
								GetParent ()->SendMessage (BCGPM_ON_AFTER_SHELL_COMMAND,
									(WPARAM) idCmd);
							}
						}
					}
				}
			}

			if (m_pContextMenu2 != NULL)
			{
				m_pContextMenu2->Release();
				m_pContextMenu2 = NULL;
			}
		}
		
		pcm->Release();
	}
	
	g_pShellManager->m_pBCGMalloc->Free (pPidls);
}
Example #10
0
bool Unit::CollidePoint(int x_rel, int y_rel, int* xf, int* yf){
	bool Collided=false;
	int x0,x1,y0,y1; //new coord.
	x0=X+x_rel; x1=x0+vX;
	y0=Y+y_rel; y1=y0+vY;

	int dx, dy;
	dx=x1-x0;
	dy=y1-y0;
	
	/*Using variables for testing we will be able to set the final position
	 *to the last available coordinates*/
	int xt, yt;

	/*(not so) simple linedrawing algorithm parses the path ahead
	 *and stops when HitTest is true for the actual point*/
	float t = (float) 0.5;                      // offset for rounding
	xt=x0;
	yt=y0;

      if ((dx>0?dx:-dx) > (dy>0?dy:-dy)) {          // slope < 1
      float m = (float) dy / (float) dx;			// compute slope
            t += y0;
            dx = (dx < 0) ? -1 : 1;
            m *= dx;
            while (xt != x1) {
                xt += dx;                           // step to next x value
                t += m;                             // add slope to y value
                if(HitTest(xt,(int)t)){
					Collided = true;
					break;
				}else{
					x0=xt;
					y0=(int)t;
				}
			}
		} else {                                    // slope >= 1
            float m = (float) dx / (float) dy;      // compute slope
            t += x0;
            dy = (dy < 0) ? -1 : 1;
            m *= dy;
            while (yt != y1) {
                yt += dy;                           // step to next y value
                t += m;                             // add slope to x value
                if(HitTest((int)t,yt)){
					Collided = true;
					break;
				}else{
					x0=int(t);
					y0=yt;
				}
			}
		}



		if(x0==x1 && y0==y1)
			Collided = false;	//if it reached the destination, there was no collision
		*xf = x0;
		*yf = y0;

		return Collided;
}
Example #11
0
int clFindResultsStyler::HitTest(wxStyledTextEvent& e, int& line) {
    return HitTest(m_stc, e, line);
}
Example #12
0
void CDxDatePickerMonth::OnLButtonDown(UINT nFlags, CPoint point)
{
    if (!m_pControl)
        return;

    // check left scroll item
    if (m_bShowLeftScroll && !m_rcLeftScroll.IsRectEmpty() && m_rcLeftScroll.PtInRect(point))
    {
        m_pControl->m_mouseMode = CDxMonthPicker::mouseScrollingLeft;
        if (m_pControl->m_bYearsTriangle)
        {
            if (point.x < m_rcLeftScroll.left + 9)
            {
                if (m_dtMonth.GetYear() >= 100 || (m_dtMonth.GetYear() == 100 && m_dtMonth.GetMonth() >= 3))
                    m_pControl->ScrollLeft(m_pControl->GetMonthDelta());
            }
            else if (point.x > m_rcLeftScroll.right - 9)
            {
                if (m_dtMonth.GetYear() >= 101 || (m_dtMonth.GetYear() == 101 && m_dtMonth.GetMonth() >= 3))
                    m_pControl->ScrollLeft(12 * m_pControl->GetMonthDelta());
            }
        }
        else
        {
            m_pControl->ScrollLeft(m_pControl->GetMonthDelta());
        }
        return;
    }

    // check right scroll item
    if (m_bShowRightScroll && !m_rcRightScroll.IsRectEmpty() && m_rcRightScroll.PtInRect(point))
    {
        m_pControl->m_mouseMode = CDxMonthPicker::mouseScrollingRight;

        if (m_pControl->m_bYearsTriangle)
        {
            if (point.x < m_rcRightScroll.left + 9)
                m_pControl->ScrollRight(12 * m_pControl->GetMonthDelta());
            else if (point.x > m_rcLeftScroll.right - 9)
                m_pControl->ScrollRight(m_pControl->GetMonthDelta());
        }
        else
        {
            m_pControl->ScrollRight(m_pControl->GetMonthDelta());
        }
        return;
    }

    //  check header click
    if (!m_rcHeader.IsRectEmpty() && CRect(m_rcHeader.left + 20, m_rcHeader.top, m_rcHeader.right - 20, m_rcHeader.bottom).PtInRect(point))
    {
        // call month popup list
        //m_pControl->ShowListHeader(m_rcHeader, m_dtMonth);
        return;
    }

    // check week numbers click
    m_pControl->m_bSelectWeek = !m_rcWeekNumbers.IsRectEmpty() && m_rcWeekNumbers.PtInRect(point);

    CPoint ptFirstWeekDay(point);
    ptFirstWeekDay.x = m_rcWeekNumbers.right + 3;

    //  check day item
    CDxDatePickerDay* pDay = HitTest(m_pControl->m_bSelectWeek ? ptFirstWeekDay : point, FALSE);
    if (pDay)
    {
        COleDateTime dtDay(pDay->GetDate());
        BOOL bSelected = m_pControl->IsSelected(dtDay);
        if (m_pControl->m_bSelectWeek)
        {
            //  week is selected only when all week days are selected
            for (int i = 0; i < 7; i++)
            {
                COleDateTime dtDay_i = dtDay + COleDateTimeSpan(i, 0, 0, 0);
                bSelected &= m_pControl->IsSelected(dtDay_i);
            }
        }

        m_pControl->m_mouseMode = CDxMonthPicker::mouseSelecting;

        m_pControl->m_dtFSelBase = dtDay;

        m_pControl->NotifyInvalidate();
    }
}
Example #13
0
void CDragDropTreeCtrl::OnTimer(UINT_PTR nIDEvent)
{
    CTreeCtrl::OnTimer(nIDEvent);

    // Reset the timer.
    SetTimer(1, m_nScrollInterval, NULL);

    // Get the current cursor position and window height.
    DWORD dwPos = ::GetMessagePos();
    CPoint point(LOWORD(dwPos), HIWORD(dwPos));
    ScreenToClient(&point);

    CRect rect;
    GetClientRect(rect);
    int cy = rect.Height();

    // Scroll the window if the cursor is near the top or bottom.
    if (point.y >= 0 && point.y <= m_nScrollMargin)
    {
        HTREEITEM hFirstVisible = GetFirstVisibleItem();
        m_pImageList->DragShowNolock(FALSE);
        SendMessage(WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), NULL);
        m_pImageList->DragShowNolock(TRUE);

        // Kill the timer if the window did not scroll, or redraw the
        // drop target highlight if the window did scroll.
        if (GetFirstVisibleItem() == hFirstVisible)
            KillTimer(1);
        else
        {
            HighlightDropTarget(point);
            return;
        }
    }
    else if (point.y >= cy - m_nScrollMargin && point.y <= cy)
    {
        HTREEITEM hFirstVisible = GetFirstVisibleItem();
        m_pImageList->DragShowNolock(FALSE);
        SendMessage(WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), NULL);
        m_pImageList->DragShowNolock(TRUE);

        // Kill the timer if the window did not scroll, or redraw the
        // drop target highlight if the window did scroll.
        if (GetFirstVisibleItem() == hFirstVisible)
            KillTimer(1);
        else
        {
            HighlightDropTarget(point);
            return;
        }
    }

    // If the cursor is hovering over a collapsed item, expand the tree.
    UINT nFlags;
    HTREEITEM hItem = HitTest(point, &nFlags);

    if (hItem != NULL && ItemHasChildren(hItem) && !IsItemExpanded(hItem))
    {
        m_pImageList->DragShowNolock(FALSE);
        Expand(hItem, TVE_EXPAND);
        m_pImageList->DragShowNolock(TRUE);
        KillTimer(1);
        return;
    }
}
Example #14
0
void CHistoryPane::OnLButtonDown(UINT nFlags, CPoint point) 
{
	m_uClickItem = HitTest(point);	
	CStatic::OnLButtonDown(nFlags, point);
}
Example #15
0
void CGameListCtrl::OnRightClick(wxMouseEvent& event)
{
	// Focus the clicked item.
	int flags;
	long item = HitTest(event.GetPosition(), flags);
	if (item != wxNOT_FOUND)
	{
		if (GetItemState(item, wxLIST_STATE_SELECTED) != wxLIST_STATE_SELECTED)
		{
			UnselectAll();
			SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
		}
		SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
	}
	if (GetSelectedItemCount() == 1)
	{
		const GameListItem* selected_iso = GetSelectedISO();
		if (selected_iso)
		{
			wxMenu popupMenu;
			DiscIO::IVolume::EPlatform platform = selected_iso->GetPlatform();

			if (platform != DiscIO::IVolume::ELF_DOL)
			{
				popupMenu.Append(IDM_PROPERTIES, _("&Properties"));
				popupMenu.Append(IDM_GAME_WIKI, _("&Wiki"));
				popupMenu.AppendSeparator();
			}
			if (platform == DiscIO::IVolume::WII_DISC || platform == DiscIO::IVolume::WII_WAD)
			{
				popupMenu.Append(IDM_OPEN_SAVE_FOLDER, _("Open Wii &save folder"));
				popupMenu.Append(IDM_EXPORT_SAVE, _("Export Wii save (Experimental)"));
			}
			popupMenu.Append(IDM_OPEN_CONTAINING_FOLDER, _("Open &containing folder"));

			if (platform != DiscIO::IVolume::ELF_DOL)
				popupMenu.AppendCheckItem(IDM_SET_DEFAULT_ISO, _("Set as &default ISO"));

			// First we have to decide a starting value when we append it
			if (platform == SConfig::GetInstance().m_strDefaultISO)
				popupMenu.FindItem(IDM_SET_DEFAULT_ISO)->Check();

			popupMenu.AppendSeparator();
			popupMenu.Append(IDM_DELETE_ISO, _("&Delete File..."));

			if (platform == DiscIO::IVolume::GAMECUBE_DISC || platform == DiscIO::IVolume::WII_DISC)
			{
				if (selected_iso->GetBlobType() == DiscIO::BlobType::GCZ)
					popupMenu.Append(IDM_COMPRESS_ISO, _("Decompress ISO..."));
				else if (selected_iso->GetBlobType() == DiscIO::BlobType::PLAIN)
					popupMenu.Append(IDM_COMPRESS_ISO, _("Compress ISO..."));

				wxMenuItem* changeDiscItem = popupMenu.Append(IDM_LIST_CHANGE_DISC, _("Change &Disc"));
				changeDiscItem->Enable(Core::IsRunning());
			}

			if (platform == DiscIO::IVolume::WII_WAD)
				popupMenu.Append(IDM_LIST_INSTALL_WAD, _("Install to Wii Menu"));

			PopupMenu(&popupMenu);
		}
	}
	else if (GetSelectedItemCount() > 1)
	{
		wxMenu popupMenu;
		popupMenu.Append(IDM_DELETE_ISO, _("&Delete selected ISOs..."));
		popupMenu.AppendSeparator();
		popupMenu.Append(IDM_MULTI_COMPRESS_ISO, _("Compress selected ISOs..."));
		popupMenu.Append(IDM_MULTI_DECOMPRESS_ISO, _("Decompress selected ISOs..."));
		PopupMenu(&popupMenu);
	}
}
Example #16
0
  GXBOOL TranslationAxis::Track( GXCanvas3D* pCanvas, GXLPCPOINT ptHit )
  {
    if(HitTest(pCanvas, TRUE, ptHit))
    {
      m_bTracking = TRUE;
      class CDragAxis : public CDrag
      {
        friend class TranslationAxis;
      private:
        GXCanvas3D* m_pCanvas;
        TranslationAxis* m_pAxis;
        float3 m_vLimit;
        float3 m_vStartPos;
        float4x4 m_matInvParent;

      public:
        float3 m_vHitStart;
        Plane m_plane;
        float4x4 m_matInvAbs;
        float4x4 m_matAbs;
      public:
        CDragAxis(GXCanvas3D* pCanvas, TranslationAxis* pAxis, GXLPCPOINT point) 
          : m_pCanvas(pCanvas)
          , m_pAxis(pAxis)
          , m_vHitStart(0.0f)
          , m_vLimit(1.0f)
        {
          GVNode* pParent = m_pAxis->m_pBind->GetParent();
          m_matInvParent = pParent ? float4x4::inverse(pParent->GetTransform().GlobalMatrix) : float4x4::Identity;
          m_vStartPos = m_pAxis->m_pBind->GetPosition(GVNode::S_ABSOLUTE);
        }

        GXBOOL OnDrag(GXLPCPOINT ptAbsoluteDelta, GXLPCPOINT ptOrigin)
        {
          GXPOINT pt = {ptOrigin->x + ptAbsoluteDelta->x, ptOrigin->y + ptAbsoluteDelta->y};
          float3 vDist;
          Ray ray;

          m_pCanvas->RayFromScreen(&pt, &ray);
          NormalizedRay RayLocal(ray.vOrigin * m_matInvAbs, ray.vDirection.MulAsMatrix3x3(m_matInvAbs));

          float3 v2;
          if(clstd::RayIntersectPlane2S(RayLocal, m_plane, &v2))
          {
            vDist = v2 - m_vHitStart;
            vDist *= m_vLimit;
            vDist = vDist.MulAsMatrix3x3(m_matAbs);

            m_pAxis->InvokeTranslation((vDist + m_vStartPos) * m_matInvParent);
          }
          return TRUE;
        }
      } DragAxis(pCanvas, this, ptHit);

      Ray ray;
      float3 v1;
      pCanvas->RayFromScreen(ptHit, &ray);

      float4x4 matInvAbs = float4x4::inverse(m_Transformation.GlobalMatrix);
      NormalizedRay RayLocal(ray.vOrigin * matInvAbs, ray.vDirection.MulAsMatrix3x3(matInvAbs));
      DragAxis.m_matInvAbs = matInvAbs;

      switch(m_eHit)
      {
      case HT_AXIS_X:
        // SEL_PLANE 用来选择一个ViewDir和Plane比较垂直的平面,这样求出的交点比较精确
        SEL_PLANE(float3::AxisY, float3::AxisZ);
        DragAxis.m_vLimit.set(1, 0, 0);
        break;

      case HT_AXIS_Y:
        SEL_PLANE(float3::AxisZ, float3::AxisX);
        DragAxis.m_vLimit.set(0, 1, 0);
        break;

      case HT_AXIS_Z:
        SEL_PLANE(float3::AxisX, float3::AxisY);
        DragAxis.m_vLimit.set(0, 0, 1);
        break;

      case HT_PLANE_XY:
        DragAxis.m_plane.set(float3::AxisZ, 0);
        DragAxis.m_vLimit.set(1, 1, 0);
        break;

      case HT_PLANE_YZ:
        DragAxis.m_plane.set(float3::AxisX, 0);
        DragAxis.m_vLimit.set(0, 1, 1);
        break;

      case HT_PLANE_ZX:
        DragAxis.m_plane.set(float3::AxisY, 0);
        DragAxis.m_vLimit.set(1, 0, 1);
        break;
      }

      if( ! clstd::RayIntersectPlane2S(RayLocal, DragAxis.m_plane, &v1)) {
        m_bTracking = FALSE;
        return FALSE;
      }

      v1 *= DragAxis.m_vLimit;
      DragAxis.m_matAbs = m_Transformation.GlobalMatrix;

      DragAxis.m_vHitStart = v1;
      DragAxis.Track(ptHit, ptHit);
      m_bTracking = FALSE;
      return TRUE;
    }

    m_bTracking = FALSE;
    return FALSE;
  }
void CXTPDatePickerItemMonth::OnLButtonDown(UINT nFlags, CPoint point)
{
	if (!m_pControl)
		return;

	BOOL bMultiselect = !!(nFlags & MK_CONTROL) || m_pControl->IsMultiSelectionMode();

	// check left scroll item
	if (m_bShowLeftScroll
		&& !m_rcLeftScroll.IsRectEmpty()
		&& m_rcLeftScroll.PtInRect(point))
	{
		m_pControl->m_mouseMode = CXTPDatePickerControl::mouseScrollingLeft;
		m_pControl->m_nTimerID = (UINT)m_pControl->SetTimer(XTP_DATEPICKER_TIMERID, XTP_DATEPICKER_TIMER_INTERVAL, NULL);
		if (m_pControl->m_bYearsTriangle)
		{
			if (point.x < m_rcLeftScroll.left + 9)
			{
				if (m_dtMonth.GetYear() >= 100 ||
					(m_dtMonth.GetYear() == 100 && m_dtMonth.GetMonth() >= 3))
					m_pControl->ScrollLeft(m_pControl->GetMonthDelta());
			}
			else if (point.x > m_rcLeftScroll.right - 9)
			{
				if (m_dtMonth.GetYear() >= 101 ||
					(m_dtMonth.GetYear() == 101 && m_dtMonth.GetMonth() >= 3))
					m_pControl->ScrollLeft(12 * m_pControl->GetMonthDelta());
			}
		}
		else
		{
			m_pControl->ScrollLeft(m_pControl->GetMonthDelta());
		}
		return;
	}
	// check right scroll item
	if (m_bShowRightScroll
		&& !m_rcRightScroll.IsRectEmpty()
		&& m_rcRightScroll.PtInRect(point))
	{
		m_pControl->m_mouseMode = CXTPDatePickerControl::mouseScrollingRight;
		m_pControl->m_nTimerID = (UINT)m_pControl->SetTimer(XTP_DATEPICKER_TIMERID, XTP_DATEPICKER_TIMER_INTERVAL, NULL);

		if (m_pControl->m_bYearsTriangle)
		{
			if (point.x < m_rcRightScroll.left + 9)
				m_pControl->ScrollRight(12 * m_pControl->GetMonthDelta());
			else if (point.x > m_rcLeftScroll.right - 9)
				m_pControl->ScrollRight(m_pControl->GetMonthDelta());
		}
		else
		{
			m_pControl->ScrollRight(m_pControl->GetMonthDelta());
		}
		return;
	}
	// check header click
	if (!m_rcHeader.IsRectEmpty()
		&& CRect(m_rcHeader.left + 20, m_rcHeader.top, m_rcHeader.right - 20, m_rcHeader.bottom).PtInRect(point))
		//m_rcHeader.PtInRect(point))
	{
		// call month popup list
		m_pControl->ShowListHeader(m_rcHeader, m_dtMonth);
		return;
	}
	// check week numbers click
	m_pControl->m_bSelectWeek = !m_rcWeekNumbers.IsRectEmpty() && m_rcWeekNumbers.PtInRect(point);
	CPoint ptFirstWeekDay(point);
	ptFirstWeekDay.x = m_rcWeekNumbers.right + 3;

	// check day item
	CXTPDatePickerItemDay* pDay = HitTest(m_pControl->m_bSelectWeek ? ptFirstWeekDay : point, FALSE);
	if (pDay)
	{
		m_pControl->ClearFocus();

		BOOL bAllowNoncontinuousSelection = m_pControl->IsAllowNoncontinuousSelection();

		COleDateTime dtDay(pDay->GetDate());
		BOOL bSelected = m_pControl->IsSelected(dtDay);
		if (m_pControl->m_bSelectWeek)
		{
//week is selected only when all week days are selected
			for (int i = 0; i < 7; i++)
			{
				COleDateTime dtDay_i = dtDay + COleDateTimeSpan(i, 0, 0, 0);
				bSelected &= m_pControl->IsSelected(dtDay_i);
			}
		}
		if (bSelected && bMultiselect && bAllowNoncontinuousSelection)
			m_pControl->m_mouseMode = CXTPDatePickerControl::mouseDeselecting;
		else
			m_pControl->m_mouseMode = CXTPDatePickerControl::mouseSelecting;

		if (!bMultiselect || !bAllowNoncontinuousSelection)
			m_pControl->m_pSelectedDays->Clear();

		if (nFlags & MK_SHIFT)
		{
			if (m_pControl->m_dtFirstClicked.GetStatus() == COleDateTime::valid)
			{
				m_pControl->m_dtLastClicked = dtDay;
			}
			else if (m_pControl->m_dtLastClicked.GetStatus() == COleDateTime::valid)
			{
				m_pControl->m_dtFirstClicked = m_pControl->m_dtLastClicked;
				m_pControl->m_dtLastClicked = dtDay;
			}
			else if (m_pControl->GetSelRange(m_pControl->m_dtFirstClicked, m_pControl->m_dtLastClicked))
			{
				if (m_pControl->m_dtFirstClicked < dtDay)
					m_pControl->m_dtLastClicked = dtDay;
				else
					m_pControl->m_dtFirstClicked = dtDay;
			}
			else
			{
				m_pControl->m_dtFirstClicked = dtDay;
				m_pControl->m_dtLastClicked = dtDay;
			}
		}
		else
		{
			m_pControl->m_dtFirstClicked = dtDay;
			m_pControl->m_dtLastClicked = m_pControl->m_bSelectWeek ?
				dtDay + COleDateTimeSpan(6, 0, 0, 0) : dtDay;
		}

		m_pControl->_RedrawControl(FALSE);
	}
}
void CLibraryFolderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	UINT nItemFlags = 0;
	HTREEITEM hItem = HitTest( point, &nItemFlags );

	if ( nItemFlags == TVHT_ONITEMBUTTON )
	{
		CTreeCtrl::OnLButtonDown( nFlags, point );
		return;
	}

	if ( ( nFlags & MK_CONTROL ) && m_bMultiSelect )
	{
		if ( hItem )
		{
			UINT nNewState = GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED ?
				0 : TVIS_SELECTED;

			SetItemState( hItem, nNewState,  TVIS_SELECTED );
			m_hFirstSelected = NULL;
			NotifySelectionChanged();
		}
	}
	else if ( ( nFlags & MK_SHIFT ) && m_bMultiSelect )
	{
		HTREEITEM hItem = HitTest( point );

		if ( ! m_hFirstSelected ) m_hFirstSelected = GetFirstSelectedItem();

		if ( hItem ) SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED );

		if ( m_hFirstSelected ) SelectItems( m_hFirstSelected, hItem );

		NotifySelectionChanged();
	}
	else
	{
		BOOL bChanged = FALSE;

		BOOL bSelected = hItem && ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED );

		if ( ! bSelected || ( nFlags & MK_RBUTTON ) == 0 )
		{
			if ( m_bFirstClick && hItem != GetRootItem() )
			{
				Select( hItem, TVGN_CARET );
			}

			bChanged = ClearSelection( hItem );
			m_hFirstSelected = NULL;
		}

		if ( hItem )
		{
			if ( ! bSelected )
			{
				SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED );
				bChanged = TRUE;
			}
		}

		if ( bChanged ) NotifySelectionChanged();
	}

	m_bFirstClick = FALSE;

	SetFocus();
}
Example #19
0
void KGTreeCtrl::OnTimer(UINT nIDEvent)
{
	if (nIDEvent == m_nHoverTimerID)
	{
		KillTimer(m_nHoverTimerID);
		m_nHoverTimerID = 0;
		HTREEITEM  trItem = 0;
		UINT  uFlag = 0;
		trItem = HitTest(m_HoverPoint, &uFlag);
		if (trItem && m_bDragging)
		{
			//SelectItem(trItem);
			Expand(trItem, TVE_EXPAND);
			Invalidate();

			CRect rect;
			GetItemRect(trItem, &rect, true);
			rect.left -= 35;
			m_curPointLeft.x = rect.left;
			m_curPointLeft.y = rect.bottom;
			m_curPointRigh.x = rect.right;
			m_curPointRigh.y = rect.bottom;
		}
	}
	else if(nIDEvent == m_nScrollTimerID)
	{
		m_TimerTicks++;
		CPoint  pt;
		GetCursorPos(&pt);
		CRect  rect;
		GetClientRect(&rect);
		ClientToScreen(&rect);

		HTREEITEM  hItem = GetFirstVisibleItem();

		if ( pt.y < rect.top +10)
		{
			int  slowscroll = 6 - (rect.top + 10 - pt.y )/20;
			if( 0 == (m_TimerTicks % ((slowscroll > 0) ? slowscroll : 1)) )
			{
				CImageList::DragShowNolock ( false );
				SendMessage( WM_VSCROLL,SB_LINEUP );
				SelectDropTarget( hItem );
				m_hItemDragD = hItem;
				CImageList::DragShowNolock ( true );
			}
		}
		else if( pt.y > rect.bottom - 10 )
		{
			int  slowscroll = 6 - (pt.y - rect.bottom + 10)/20;
			if( 0 == (m_TimerTicks % ((slowscroll > 0) ? slowscroll : 1)) )
			{
				CImageList::DragShowNolock ( false );
				SendMessage( WM_VSCROLL,SB_LINEDOWN );
				int  nCount = GetVisibleCount();
				for( int i=0 ; i<nCount-1 ; i++ )
					hItem = GetNextVisibleItem( hItem );
				if( hItem )
					SelectDropTarget( hItem );
				m_hItemDragD = hItem;
				CImageList::DragShowNolock ( true );
			}
		}
	}
	else if (nIDEvent == m_nDrawLineTimerID)
	{
		CClientDC dc(this);

		CPen penP(PS_SOLID, 2, GetBkColor());
		dc.SelectObject(&penP);
		dc.MoveTo(m_pointLeft);
		dc.LineTo(m_pointRigh);
		dc.MoveTo(m_pointLeft.x, m_pointLeft.y - 5);
		dc.LineTo(m_pointLeft.x, m_pointLeft.y + 5);

		CPen penN(PS_SOLID, 2, RGB(122, 178, 255));
		dc.SelectObject(&penN);
		dc.MoveTo(m_curPointLeft);
		dc.LineTo(m_curPointRigh);
		dc.MoveTo(m_curPointLeft.x, m_curPointLeft.y - 5);
		dc.LineTo(m_curPointLeft.x, m_curPointLeft.y + 5);

		m_pointLeft.x = m_curPointLeft.x;
		m_pointLeft.y = m_curPointLeft.y;
		m_pointRigh.x = m_curPointRigh.x;
		m_pointRigh.y = m_curPointRigh.y;
	}
	else
		CTreeCtrl::OnTimer(nIDEvent);
}
Example #20
0
LONG CViewerWnd::HitTest(const OgdcPoint2D& pntHitTest, OgdcDatasetVector* pDatasetV)
{
	if(!pDatasetV->IsOpen())
	{
		pDatasetV->Open();
	}

	double dTolerance = 3.0*m_drawing.m_dCoordRatio;

	OgdcQueryDef queryDef;
	queryDef.m_nType = OgdcQueryDef::Bounds;
	queryDef.m_nOptions = OgdcQueryDef::Geometry;
	queryDef.m_nCursorType = OgdcQueryDef::OpenStatic;
	queryDef.m_nCursorLocation = OgdcQueryDef::UseClient;
	queryDef.m_rc2Bounds = OgdcRect2D(pntHitTest.x-dTolerance,	
									pntHitTest.y+dTolerance,
									pntHitTest.x+dTolerance,
									pntHitTest.y-dTolerance);

	LONG nSelectID = -1;
	OgdcRecordset* pRecordset = pDatasetV->Query(queryDef);
	if(pRecordset != NULL)
	{
		pRecordset->Move(OgdcRecordset::End, 0);
		if (pDatasetV->GetType() == OgdcDataset::PointEPS ||
			pDatasetV->GetType() == OgdcDataset::LineEPS ||
			pDatasetV->GetType() == OgdcDataset::RegionEPS ||
			pDatasetV->GetType() == OgdcDataset::TextEPS)
		{
			UGC::UGGeometry* pGeometry = NULL;
			while(!pRecordset->IsBOF())
			{
				if(pRecordset->GetElement(pGeometry) && pGeometry != NULL)
				{
					if (pGeometry->HitTest(pntHitTest, dTolerance))
					{
						nSelectID = pGeometry->GetID();
					}

					if(nSelectID >= 0)
					{
						delete pGeometry;
						pGeometry = NULL;
						break;
					}
				}
				pRecordset->Move(OgdcRecordset::Current, -1);

				if(pGeometry != NULL)
				{
					delete pGeometry;
					pGeometry = NULL;
				}
			}
		}
		else
		{
			OgdcElement* pElement = NULL;
			while(!pRecordset->IsBOF())
			{
				if(pRecordset->GetElement(pElement) && pElement != NULL)
				{
					if(pElement->GetType() == OgdcElement::ElemLine)
					{
						if(HitTest(pntHitTest, (OgdcElemLine*)pElement, dTolerance))
						{
							nSelectID = pElement->m_nID;
						}
					}
					else if(pElement->GetType() == OgdcElement::ElemRegion)
					{
						if(HitTest(pntHitTest, (OgdcElemRegion*)pElement, dTolerance))
						{
							nSelectID = pElement->m_nID;
						}
					}
					else if (pElement->GetType() == OgdcElement::ElemLine3D)
					{
						if(HitTest(pntHitTest, (OgdcElemLine3D*)pElement, dTolerance))
						{
							nSelectID = pElement->m_nID;
						}
					}
					else if (pElement->GetType() == OgdcElement::ElemRegion3D)
					{
						if(HitTest(pntHitTest, (OgdcElemRegion3D*)pElement, dTolerance))
						{
							nSelectID = pElement->m_nID;
						}
					}
					else
					{
						nSelectID = pElement->m_nID;
					}

					if(nSelectID >= 0)
					{
						delete pElement;
						pElement = NULL;
						break;
					}
				}
				pRecordset->Move(OgdcRecordset::Current, -1);

				if(pElement != NULL)
				{
					delete pElement;
					pElement = NULL;
				}
			}
		}

		pDatasetV->ReleaseRecordset(pRecordset);
		pRecordset = NULL;
	}
	return nSelectID;
}
Example #21
0
bool LIB_TEXT::HitTest( const wxPoint& aPosition )
{
    return HitTest( aPosition, 0, DefaultTransform );
}