void CPlayerSeekBar::SetRange(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) { if (rtStart < rtStop) { if (m_rtStart != rtStart || m_rtStop != rtStop) { m_rtStart = rtStart; m_rtStop = rtStop; auto hasChapters = [&]() { CAutoLock lock(&m_csChapterBag); return m_pChapterBag && m_pChapterBag->ChapGetCount(); }; if (!m_bHasDuration || hasChapters()) { Invalidate(); } m_bHasDuration = true; } } else { m_rtStart = 0; m_rtStop = 0; if (m_bHasDuration) { m_bHasDuration = false; HideToolTip(); if (DraggingThumb()) { ReleaseCapture(); KillTimer(TIMER_HOVER_CAPTURED); } Invalidate(); } } }
void CPlayerSeekBar::OnTimer(UINT_PTR nIDEvent) { CPoint point; VERIFY(GetCursorPos(&point)); ScreenToClient(&point); switch (nIDEvent) { case TIMER_SHOWHIDE_TOOLTIP: if (m_tooltipState == TOOLTIP_TRIGGERED && m_bHasDuration) { m_tooltipPoint = point; UpdateToolTipText(); m_tooltip.SendMessage(TTM_TRACKACTIVATE, TRUE, (LPARAM)&m_ti); UpdateToolTipPosition(); m_tooltipState = TOOLTIP_VISIBLE; VERIFY(SetTimer(TIMER_SHOWHIDE_TOOLTIP, TOOLTIP_HIDE_TIMEOUT, nullptr)); } else if (m_tooltipState == TOOLTIP_VISIBLE) { HideToolTip(); ASSERT(!m_bIgnoreLastTooltipPoint); KillTimer(TIMER_SHOWHIDE_TOOLTIP); } else { KillTimer(TIMER_SHOWHIDE_TOOLTIP); } break; case TIMER_HOVER_CAPTURED: if (GetCapture() == this && (!m_bHovered || m_rtHoverPos != m_rtPos)) { m_bHovered = true; m_rtHoverPos = m_rtPos; m_hoverPoint = point; SyncVideoToThumb(); } KillTimer(TIMER_HOVER_CAPTURED); break; default: ASSERT(FALSE); } }
void CodeEdit::ShowToolTip(int position, const wxString& text) { bool showToolTip = true; // There doesn't seem to be a way to determine the window that the mouse is inside // in wxWidgets. If we port to another platform, we'll need to handle this. #ifdef __WXMSW__ POINT cursorPos; GetCursorPos(&cursorPos); HWND hActiveWindow = WindowFromPoint(cursorPos); showToolTip = hActiveWindow == GetHandle(); #else wxCOMPILE_TIME_ASSERT(0, "Unportable code"); #endif HideToolTip(); if (showToolTip) { m_tipWindow = new ToolTipWindow(this, text); } }
LRESULT CMyListCtrl::OnMouseLeave(WPARAM wparam, LPARAM lparam) { m_bTrackMouseEvent = FALSE; if( m_iCurrentCursorItem != -1 ) { CRect r; GetItemRect(m_iCurrentCursorItem, &r,LVIR_BOUNDS); InvalidateRect(&r, true); } m_iCurrentCursorItem = -1; m_iCurrentCursorSubItem = -1; m_iOverImageItem = -1; m_iOverImageSubItem = -1; HideToolTip(); return DefWindowProc(WM_MOUSELEAVE, wparam, lparam); }
void CPlayerSeekBar::UpdateTooltip(const CPoint& point) { CRect clientRect; GetClientRect(&clientRect); if (!m_bHasDuration || !clientRect.PtInRect(point)) { HideToolTip(); return; } switch (m_tooltipState) { case TOOLTIP_HIDDEN: { // If mouse moved or the tooltip wasn't hidden by timeout if (point != m_tooltipPoint || m_bIgnoreLastTooltipPoint) { m_bIgnoreLastTooltipPoint = false; // Start show tooltip countdown m_tooltipState = TOOLTIP_TRIGGERED; VERIFY(SetTimer(TIMER_SHOWHIDE_TOOLTIP, TOOLTIP_SHOW_DELAY, nullptr)); // Track mouse leave TRACKMOUSEEVENT tme = { sizeof(tme), TME_LEAVE, m_hWnd }; VERIFY(TrackMouseEvent(&tme)); } } break; case TOOLTIP_TRIGGERED: // Do nothing until tooltip is shown break; case TOOLTIP_VISIBLE: // Update the tooltip if needed ASSERT(!m_bIgnoreLastTooltipPoint); if (point != m_tooltipPoint) { m_tooltipPoint = point; UpdateToolTipPosition(); UpdateToolTipText(); VERIFY(SetTimer(TIMER_SHOWHIDE_TOOLTIP, TOOLTIP_HIDE_TIMEOUT, nullptr)); } break; default: ASSERT(FALSE); } }
void CPlayerSeekBar::SetRange(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) { if (rtStart < rtStop) { m_rtStart = rtStart; m_rtStop = rtStop; if (!m_bHasDuration) { m_bHasDuration = true; Invalidate(); } } else { m_rtStart = 0; m_rtStop = 0; if (m_bHasDuration) { m_bHasDuration = false; HideToolTip(); if (GetCapture() == this) { ReleaseCapture(); KillTimer(TIMER_HOVER_CAPTURED); } Invalidate(); } } }
void CPlayerSeekBar::OnMouseLeave() { HideToolTip(); m_bIgnoreLastTooltipPoint = true; }
void CMyListCtrl::OnMouseMove(UINT nFlags, CPoint point) { static CPoint s_pt(0,0); // TRACE("%d,%d",point.x,point.y); if( s_pt == point ) { // __super::OnMouseMove( nFlags,point ); return; } s_pt = point; HideToolTip(); LVHITTESTINFO lvhti; lvhti.pt = point; int ret = SubItemHitTest(&lvhti); if( ret == -1 ) { if( m_iCurrentCursorItem != -1 ) { CRect r; GetItemRect(m_iCurrentCursorItem, &r,LVIR_BOUNDS); InvalidateRect(&r, true); } m_iCurrentCursorItem = m_iCurrentCursorSubItem = -1; m_iOverImageItem = -1; m_iOverImageSubItem = -1; __super::OnMouseMove( nFlags,point ); return; } if( m_iCurrentCursorItem != -1 ) { CRect r; GetItemRect(m_iCurrentCursorItem, &r,LVIR_BOUNDS); InvalidateRect(&r, true); } m_iCurrentCursorItem = lvhti.iItem; m_iCurrentCursorSubItem = lvhti.iSubItem; if( m_iCurrentCursorItem != -1 ) { CRect r; GetItemRect(m_iCurrentCursorItem, &r,LVIR_BOUNDS); InvalidateRect(&r, true); } CRect rectSubItem; GetSubItemRect( m_iCurrentCursorItem,m_iCurrentCursorSubItem,LVIR_BOUNDS,rectSubItem); if( NeedChangeCursor( point ) ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(32649))); if( m_iOverImageItem == -1 && m_iOverImageSubItem == -1 ) { if( m_iCurrentCursorSubItem == 0 ) { rectSubItem.right = rectSubItem.left + GetColumnWidth(0); } InvalidateRect( rectSubItem ); m_iOverImageItem = lvhti.iItem; m_iOverImageSubItem = lvhti.iSubItem; } ShowSubItemToolTip( m_iOverImageItem,m_iOverImageSubItem); } else { if( m_iOverImageItem != -1 && m_iOverImageSubItem != -1 ) { GetSubItemRect( m_iOverImageItem,m_iOverImageSubItem,LVIR_BOUNDS,rectSubItem); if( m_iCurrentCursorSubItem == 0 ) { rectSubItem.right = rectSubItem.left + GetColumnWidth(0); } InvalidateRect( rectSubItem ); m_iOverImageItem = -1; m_iOverImageSubItem = -1; ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); } ShowItemToolTip( m_iCurrentCursorItem,m_iCurrentCursorSubItem); } if(!m_bTrackMouseEvent) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.hwndTrack = m_hWnd; tme.dwFlags = TME_LEAVE; tme.dwHoverTime = 1; m_bTrackMouseEvent = _TrackMouseEvent(&tme); } __super::OnMouseMove( nFlags,point ); }
void CodeEdit::OnKillFocus(wxFocusEvent& event) { AutoCompCancel(); HideToolTip(); event.Skip(); }
void CodeEdit::OnMouseLeave(wxMouseEvent& event) { HideToolTip(); event.Skip(); }