void CXTPSyntaxEditTipWnd::OnTimer(UINT_PTR nIDEvent)
{
	ASSERT_VALID(this);

	if (nIDEvent == m_uIDEvent1)
	{
		HideTip();
	}

	if (nIDEvent == m_uIDEvent2)
	{
		CPoint point;
		::GetCursorPos(&point);
		ScreenToClient(&point);

		BOOL bOutside = FALSE;
		m_pListBox->ItemFromPoint(point, bOutside);

		if (bOutside)
		{
			HideTip();
		}
	}

	CWnd::OnTimer(nIDEvent);
}
BOOL CXTPSyntaxEditTipWnd::ShowTip(int iIndex)
{
	ASSERT_VALID(this);

	if ((iIndex < 0) || (iIndex >= m_pListBox->GetCount()))
		return HideTip();

	CPoint ptCursor;
	::GetCursorPos(&ptCursor);

	if (m_iIndex == iIndex)
	{
		if (ptCursor == m_ptCursor)
		{
			RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
			return TRUE;
		}
	}

	m_ptCursor = ptCursor;

	// stop existing timer.
	KillTipTimer();

	CRect rItem;
	if (CalcItemRect(iIndex, rItem))
	{
		if ((m_rWindow == rItem) || m_rWindow.IsRectEmpty())
			return HideTip();

		m_rWindow.InflateRect(0, 2);

		if (m_iIndex != iIndex)
		{
			m_iIndex = iIndex;
			RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
		}

		ShowWindow(SW_SHOWNA);
		MoveWindow(&m_rWindow);

		// set timer.
		SetTipTimer();

		return TRUE;
	}

	return FALSE;
}
Exemple #3
0
// hack to hide tip when clist hides from timeout
int SettingChanged(WPARAM, LPARAM lParam)
{
	DBCONTACTWRITESETTING *dcws = (DBCONTACTWRITESETTING *)lParam;
	if (strcmp(dcws->szModule, "CList") != 0 || strcmp(dcws->szSetting, "State") != 0)
		return 0;

	// clist hiding
	if (dcws->value.type == DBVT_BYTE && dcws->value.bVal == 0)
		HideTip(0, 0);

	return 0;
}
Exemple #4
0
void CGraphListCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
	do
	{
		CRect rc;
		GetClientRect(rc);
		if (!rc.PtInRect(point))
		{
			break;
		}

		m_nMouseItem = GetItemByPoint(point);
		if (m_nMouseItem == m_nOldMouseItem)
		{
			break;
		}

		if (m_nOldMouseItem > -1)
		{
			HideTip();
// 			::SetCapture(NULL);
		}

		if (m_nMouseItem < 0)
		{
			m_nOldMouseItem = m_nMouseItem;
			break;
		}

		if(m_bShowCaption && (m_nMouseItem >= 0))
		{
			int nVertScroll = GetScrollPos(SB_VERT), 
				nHorzScroll = GetScrollPos(SB_HORZ);

			CString str;
			CRect rt = GetItemRect(m_nMouseItem);
			rt.OffsetRect(-nHorzScroll, -nVertScroll);
			CRect rtCaption = rt;
			int iWide = m_nCaptionHeight;
			//if( rtCaption.Height()>iWide)rtCaption.top += iWide;		
			rtCaption.top = rtCaption.bottom-iWide;
			CString strName = GetItem(m_nMouseItem)->GetName(); 
			ShowTip(rtCaption, strName, rt);
		}

		m_nOldMouseItem = m_nMouseItem;
	} while (false);

	CWnd::OnMouseMove(nFlags, point);
}
void
ToolTipView::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	if (fToolTip->IsSticky()) {
		ResetWindowFrame(ConvertToScreen(where));
	} else if (transit == B_ENTERED_VIEW) {
		// close instantly if the user managed to enter
		Window()->Quit();
	} else {
		// close with the preferred delay in case the mouse just moved
		HideTip();
	}
}
Exemple #6
0
bool CToolTip::HandleMessage(CMessage* pMessage)
{
	bool bHandled = false;

	if (pMessage)
	{
		switch(pMessage->MessageType())
		{
			case CMessage::CTRL_TIMER:
			{
				wGui::TIntMessage* pTimerMessage = dynamic_cast<wGui::TIntMessage*>(pMessage);
				if (pTimerMessage && pMessage->Destination() == this)
				{
					// Timer has expired, so it's time to show the tooltip
					ShowTip(m_LastMousePosition + CPoint(-6, 18));
					bHandled = true;
				}
				break;
			}
		case CMessage::MOUSE_MOVE:
		{
			// We don't want to mess with the underlying control, so don't trap any MOUSE_MOVE messages
			CMouseMessage* pMouseMessage = dynamic_cast<CMouseMessage*>(pMessage);
			if (pMouseMessage)
			{
				m_LastMousePosition = pMouseMessage->Point;
				m_pTimer->StopTimer();
				if (IsVisible())
				{
					HideTip();
				}
				CView* pView = GetView();
				bool bHitFloating = pView && pView->GetFloatingWindow() && pView->GetFloatingWindow()->HitTest(pMouseMessage->Point) &&
					pView->GetFloatingWindow() != m_pParentWindow;
				if (m_pParentWindow->GetWindowRect().SizeRect().HitTest(
					m_pParentWindow->ViewToWindow(m_LastMousePosition)) == CRect::RELPOS_INSIDE && !bHitFloating)
				{
					m_pTimer->StartTimer(1000);
				}
			}
		}
		default :
			bHandled = CWindow::HandleMessage(pMessage);
			break;
		}
	}

	return bHandled;
}
Exemple #7
0
void
DTipWatcherView::Pulse(void)
{
	// Check to see if there has been any activity. If so, just reset.
	BPoint pt;
	uint32 buttons;
	GetMouse(&pt,&buttons);
	ConvertToScreen(&pt);
	
	if (pt != fLastPoint || buttons)
	{
		fDelayCounter = 0;
		fLastPoint = pt;
		HideTip();
		return;
	}
	fLastPoint = pt;
	
	if (!Window()->IsHidden())
		return;
	
	fDelayCounter += Window()->PulseRate();
	if (fDelayCounter < fDelayMax)
		return;
	
	// We got this far, so it's time to show a tip
	BView *view = ViewForPoint(pt);
	if (!view)
		return;
	
	BString text = GetTip(view);
	if (text.CountChars() < 1)
		return;
	
	ShowTip(pt, text.String());
}
Exemple #8
0
void CToolTip::ShowTip(HWND ahOwner, HWND ahControl, LPCWSTR asText, BOOL abBalloon, POINT pt, HINSTANCE hInstance)
{
	HideTip();

	if (!asText || !*asText)
		return;


	int nTipLen = lstrlen(asText);
	if (!mpsz_LastTip || (nTipLen >= mn_LastTipCchMax))
	{
		if (mpsz_LastTip)
			free(mpsz_LastTip);
		mn_LastTipCchMax = nTipLen + 1;
		mpsz_LastTip = (wchar_t*)malloc(mn_LastTipCchMax*sizeof(wchar_t));
	}
	_wcscpy_c(mpsz_LastTip, mn_LastTipCchMax, asText);

	TOOLINFO *pti = abBalloon ? (&mti_Ball) : (&mti_Tip);

	if (abBalloon)
	{
		if (!mh_Ball || !IsWindow(mh_Ball))
		{
			mh_Ball = CreateWindowEx ( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
			                           WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON | TTS_NOPREFIX,
			                           CW_USEDEFAULT, CW_USEDEFAULT,
			                           CW_USEDEFAULT, CW_USEDEFAULT,
			                           ahOwner, NULL,
			                           hInstance/*g_hInstance*/, NULL);
			SetWindowPos(mh_Ball, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
			// Set up tool information.
			// In this case, the "tool" is the entire parent window.
			pti->cbSize = 44; // был sizeof(TOOLINFO);
			pti->uFlags = TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE;
			pti->hwnd = ahControl;
			pti->hinst = hInstance;
			static wchar_t szAsterisk[] = L"*"; // eliminate GCC warning
			pti->lpszText = szAsterisk;
			pti->uId = (UINT_PTR)ahControl;
			GetClientRect(ahControl, &(pti->rect));
			// Associate the ToolTip with the tool window.
			SendMessage(mh_Ball, TTM_ADDTOOL, 0, (LPARAM)pti);
			// Allow multiline
			SendMessage(mh_Ball, TTM_SETMAXTIPWIDTH, 0, (LPARAM)300);
		}
	}
	else
	{
		if (!mh_Tip || !IsWindow(mh_Tip))
		{
			mh_Tip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
			                         WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON | TTS_NOPREFIX,
			                         CW_USEDEFAULT, CW_USEDEFAULT,
			                         CW_USEDEFAULT, CW_USEDEFAULT,
			                         ahOwner, NULL,
			                         hInstance, NULL);
			SetWindowPos(mh_Tip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
			SendMessage(mh_Tip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 30000);
		}
	}

	mb_LastTipBalloon = abBalloon;

	HWND hTip = abBalloon ? (mh_Ball) : (mh_Tip);
	if (!hTip)
	{
		_ASSERTE(hTip != NULL);
		return;
	}

	pti->lpszText = mpsz_LastTip;

	SendMessage(hTip, TTM_UPDATETIPTEXT, 0, (LPARAM)pti);
	//RECT rcControl; GetWindowRect(GetDlgItem(hDlg, nCtrlID), &rcControl);
	//int ptx = rcControl.right - 10;
	//int pty = (rcControl.top + rcControl.bottom) / 2;
	SendMessage(hTip, TTM_TRACKPOSITION, 0, MAKELONG(pt.x,pt.y));
	SendMessage(hTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)pti);

	//SetTimer(hDlg, FAILED_FONT_TIMERID, nTimeout/*FAILED_FONT_TIMEOUT*/, 0);
}
Exemple #9
0
void CGraphListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// 	::SetCapture(NULL);
	HideTip();
	int nItemCount = GetItemCount();
	if( nItemCount <= 0)
	{
		CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
		return;
	}
	if(m_nCurSel < 0)
	{
		OnSetCurSel(0);  
		CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
		return;
	}
	int nRow = GetTopRowNum();
	int nCol = GetTopColumnNum();
	int nCurSel = m_nCurSel;
	switch (nChar)
	{
	case VK_RIGHT:
		{
			nCurSel ++;
			if(nCurSel >= nItemCount)
				break;
			if(nCurSel / m_nFixedColNum == nRow )
			{
				OnSetCurSel(nCurSel);  
			}
		}
		break;
	case VK_DOWN:
		nCurSel += m_nFixedColNum;
		if(nCurSel >= nItemCount)
		{
			SendMessage(WM_VSCROLL, SB_BOTTOM, 0);
			break;
		}
		OnSetCurSel(nCurSel);  
		break;
	case VK_LEFT:   
		nCurSel --;
		if(nCurSel < 0)
			break;
		if(nCurSel / m_nFixedColNum == nRow )
		{
			OnSetCurSel(nCurSel);  
		}
		break;
	case VK_UP:     
		nCurSel -= m_nFixedColNum;
		if(nCurSel < 0)
			break;  
		OnSetCurSel(nCurSel);  
		break;  
	case VK_NEXT:   
		SendMessage(WM_VSCROLL, SB_PAGEDOWN, 0);
		break;
	case VK_PRIOR:  
		SendMessage(WM_VSCROLL, SB_PAGEUP, 0);
		break;
	case VK_HOME:
		SendMessage(WM_VSCROLL, SB_TOP, 0);
		break;
	case VK_END:    
		SendMessage(WM_VSCROLL, SB_BOTTOM, 0);
		break;
	}
	CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}
int HideTipHook(WPARAM wParam, LPARAM lParam) {
    HideTip(wParam, lParam);
    return 0;
}
void
ToolTipView::KeyDown(const char* bytes, int32 numBytes)
{
	if (!fToolTip->IsSticky())
		HideTip();
}