void SectorViewLabelSet::UpdateTooltip() { if (!m_tooltipEnabled || Pi::MouseButtonState(SDL_BUTTON_LEFT) || Pi::MouseButtonState(SDL_BUTTON_RIGHT)) { HideTooltip(); return; } int mouse_pos[2]; float mouse_coords[2]; SDL_GetMouseState(&mouse_pos[0], &mouse_pos[1]); Screen::SDLEventCoordToScreenCoord(mouse_pos[0], mouse_pos[1], &mouse_coords[0], &mouse_coords[1]); bool tooltip_shown = false; for(unsigned int i = 0; i < m_items.size(); ++i) { if (!m_items[i].name.empty() && (fabs(mouse_coords[0] - m_items[i].screenx) < 10.0f) && (fabs(mouse_coords[1] - m_items[i].screeny) < 10.0f)) { ShowTooltip(m_items[i].name, m_items[i].type, m_items[i].desc, m_items[i].screenx, m_items[i].screeny); tooltip_shown = true; break; } } if (m_tooltipDesc && !tooltip_shown) { HideTooltip(); } }
NS_IMETHODIMP nsXULTooltipListener::MouseUp(nsIDOMEvent* aMouseEvent) { HideTooltip(); return NS_OK; }
IGraphicsCarbon::~IGraphicsCarbon() { if (mTextEntryView) { RemoveEventHandler(mTextEntryHandler); mTextEntryHandler = 0; #if USE_MLTE TXNFocus(mTextEntryView, false); TXNClear(mTextEntryView); TXNDeleteObject(mTextEntryView); #else HIViewRemoveFromSuperview(mTextEntryView); #endif mTextEntryView = 0; mEdControl = 0; mEdParam = 0; } HideTooltip(); RemoveEventLoopTimer(mTimer); RemoveEventHandler(mControlHandler); RemoveEventHandler(mWindowHandler); mTimer = 0; mView = 0; }
void SectorViewLabelSet::ShowTooltip(std::string& name, std::string& type, std::string& desc, int x, int y) { if (m_tooltipDesc) { if (m_tooltipDesc->GetText() == name) { return; } else { HideTooltip(); } } std::string str_tooltip = name + "\n" + type + "\n" + desc; m_tooltipDesc = new ToolTip(this, str_tooltip); float size[2]; m_tooltipDesc->GetSize(size); x = std::max(x - size[0], 0.0f); y = std::max(y - size[1], 0.0f); if (size[0] + x > Screen::GetWidth()) { x = Screen::GetWidth() - size[0]; } if (size[1] + y > Screen::GetHeight()) { y = Screen::GetHeight() - size[1]; } Screen::AddBaseWidget(m_tooltipDesc, x, y); m_tooltipDesc->SetOutlineColor(Color(Color::PARAGON_BLUE)); m_tooltipDesc->SetBackgroundColor(Color(8, 8, 16)); m_tooltipDesc->SetTextColor(Color(Color::PARAGON_GREEN)); m_tooltipDesc->AddTextLine(type, Color(Color::PARAGON_BLUE)); m_tooltipDesc->AddTextLine(desc, Color(Color::PARAGON_BLUE)); m_tooltipDesc->SetText(name); m_tooltipDesc->Show(); }
NS_IMETHODIMP nsXULTooltipListener::HandleEvent(nsIDOMEvent* aEvent) { nsAutoString type; aEvent->GetType(type); if (type.EqualsLiteral("DOMMouseScroll")) HideTooltip(); return NS_OK; }
void nsXULTooltipListener::CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent) { nsCOMPtr<nsIContent> sourceNode = do_QueryReferent(mSourceNode); if (!sourceNode) return; // get the boxObject of the documentElement of the document the tree is in nsCOMPtr<nsIBoxObject> bx; nsCOMPtr<nsIDOMDocument> doc(do_QueryInterface(sourceNode->GetDocument())); if (doc) { nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(doc)); nsCOMPtr<nsIDOMElement> docElement; doc->GetDocumentElement(getter_AddRefs(docElement)); if (nsDoc && docElement) { nsDoc->GetBoxObjectFor(docElement, getter_AddRefs(bx)); } } nsCOMPtr<nsITreeBoxObject> obx; GetSourceTreeBoxObject(getter_AddRefs(obx)); if (bx && obx) { PRInt32 x, y; aMouseEvent->GetScreenX(&x); aMouseEvent->GetScreenY(&y); PRInt32 row; nsCOMPtr<nsITreeColumn> col; nsCAutoString obj; // subtract off the documentElement's boxObject PRInt32 boxX, boxY; bx->GetScreenX(&boxX); bx->GetScreenY(&boxY); x -= boxX; y -= boxY; obx->GetCellAt(x, y, &row, getter_AddRefs(col), obj); // determine if we are going to need a titletip // XXX check the disabletitletips attribute on the tree content mNeedTitletip = PR_FALSE; if (row >= 0 && obj.EqualsLiteral("text")) { obx->IsCellCropped(row, col, &mNeedTitletip); } nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip); if (currentTooltip && (row != mLastTreeRow || col != mLastTreeCol)) { HideTooltip(); } mLastTreeRow = row; mLastTreeCol = col; } }
NS_IMETHODIMP nsXULTooltipListener::MouseOut(nsIDOMEvent* aMouseEvent) { // Clear the cached mouse event as it might hold a window alive too long, see // bug 420803. mCachedMouseEvent = nsnull; // if the timer is running and no tooltip is shown, we // have to cancel the timer here so that it doesn't // show the tooltip if we move the mouse out of the window nsCOMPtr<nsIContent> currentTooltip = do_QueryReferent(mCurrentTooltip); if (mTooltipTimer && !currentTooltip) { mTooltipTimer->Cancel(); mTooltipTimer = nsnull; return NS_OK; } #ifdef DEBUG_crap if (mNeedTitletip) return NS_OK; #endif // check to see if the mouse left the targetNode, and if so, // hide the tooltip if (currentTooltip) { // which node did the mouse leave? nsCOMPtr<nsIDOMEventTarget> eventTarget; aMouseEvent->GetTarget(getter_AddRefs(eventTarget)); nsCOMPtr<nsIDOMNode> targetNode(do_QueryInterface(eventTarget)); // which node is our tooltip on? nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(currentTooltip->GetDocument())); if (!xulDoc) // remotely possible someone could have return NS_OK; // removed tooltip from dom while it was open nsCOMPtr<nsIDOMNode> tooltipNode; xulDoc->TrustedGetTooltipNode (getter_AddRefs(tooltipNode)); // if they're the same, the mouse left the node the tooltip appeared on, // close the tooltip. if (tooltipNode == targetNode) { HideTooltip(); #ifdef MOZ_XUL // reset special tree tracking if (mIsSourceTree) { mLastTreeRow = -1; mLastTreeCol = nsnull; } #endif } } return NS_OK; }
nsXULTooltipListener::~nsXULTooltipListener() { if (nsXULTooltipListener::mInstance == this) { ClearTooltipCache(); } HideTooltip(); if (--sTooltipListenerCount == 0) { // Unregister our pref observer nsContentUtils::UnregisterPrefCallback("browser.chrome.toolbar_tips", ToolbarTipsPrefChanged, nsnull); } }
bool ctrlImage::Msg_MouseMove(const MouseCoords& mc) { // gültiges Bild? if(GetImage()) { // Jeweils Tooltip ein- und ausblenden, wenn die Maus über dem Bild ist if(IsPointInRect(mc.GetPos(), Rect::move(GetImageRect(), GetDrawPos()))) ShowTooltip(); else HideTooltip(); } return false; }
LRESULT OnKillFocus( HWND hWnd, WPARAM wParam, LPARAM lParam, LPCLASSDATA lpcd ) { /* * Hide tooltip. */ HideTooltip( lpcd ); /* * We no longer have the focus. */ lpcd->bHasFocus = lpcd->bCaretVisible = FALSE; lpcd->cQualifier = 0; DestroyCaret(); if ( HasMark( lpcd )) InvalidateRect( hWnd, NULL, FALSE ); /* * Is the search or replace window active? */ if ( lpcd->hReplaceWnd && ! IsChild( lpcd->hReplaceWnd, GetFocus())) ShowWindow( lpcd->hReplaceWnd, SW_HIDE ); if ( lpcd->hFindWnd && ! IsChild( lpcd->hFindWnd, GetFocus())) ShowWindow( lpcd->hFindWnd, SW_HIDE ); return 0; }
ctrlBaseTooltip::~ctrlBaseTooltip() { HideTooltip(); }
NS_IMETHODIMP nsXULTooltipListener::KeyDown(nsIDOMEvent* aKeyEvent) { HideTooltip(); return NS_OK; }
void GUITooltip::Update(IGUIObject* Nearest, CPos MousePos, CGUI* GUI) { // Called once per frame, so efficiency isn't vital double now = timer_Time(); CStr style; int nextstate = -1; switch (m_State) { case ST_IN_MOTION: if (MousePos == m_PreviousMousePos) { if (GetTooltip(Nearest, style)) nextstate = ST_STATIONARY_TOOLTIP; else nextstate = ST_STATIONARY_NO_TOOLTIP; } else { // Check for movement onto a zero-delayed tooltip if (GetTooltip(Nearest, style) && GetTooltipDelay(style, GUI)==0) { // Reset any previous tooltips completely //m_Time = now + (double)GetTooltipDelay(style, GUI) / 1000.; HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_SHOWING; } } break; case ST_STATIONARY_NO_TOOLTIP: if (MousePos != m_PreviousMousePos) nextstate = ST_IN_MOTION; break; case ST_STATIONARY_TOOLTIP: if (MousePos != m_PreviousMousePos) nextstate = ST_IN_MOTION; else if (now >= m_Time) { // Make sure the tooltip still exists if (GetTooltip(Nearest, style)) nextstate = ST_SHOWING; else { // Failed to retrieve style - the object has probably been // altered, so just restart the process nextstate = ST_IN_MOTION; } } break; case ST_SHOWING: // Handle special case of icon tooltips if (Nearest == m_PreviousObject && (!m_IsIconTooltip || Nearest->MouseOverIcon())) { // Still showing the same object's tooltip, but the text might have changed if (GetTooltip(Nearest, style)) ShowTooltip(Nearest, MousePos, style, GUI); } else { // Mouse moved onto a new object if (GetTooltip(Nearest, style)) { CStr style_old; // If we're displaying a tooltip with no delay, then we want to // reset so that other object that should have delay can't // "ride this tail", it have to wait. // Notice that this doesn't apply to when you go from one delay=0 // to another delay=0 if (GetTooltip(m_PreviousObject, style_old) && GetTooltipDelay(style_old, GUI)==0 && GetTooltipDelay(style, GUI)!=0) { HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_IN_MOTION; } else { // Hide old scrollbar HideTooltip(m_PreviousTooltipName, GUI); nextstate = ST_SHOWING; } } else { nextstate = ST_COOLING; } } break; case ST_COOLING: if (GetTooltip(Nearest, style)) nextstate = ST_SHOWING; else if (now >= m_Time) nextstate = ST_IN_MOTION; break; } // Handle state-entry code: if (nextstate != -1) { switch (nextstate) { case ST_STATIONARY_TOOLTIP: m_Time = now + (double)GetTooltipDelay(style, GUI) / 1000.; break; case ST_SHOWING: ShowTooltip(Nearest, MousePos, style, GUI); m_PreviousTooltipName = style; break; case ST_COOLING: HideTooltip(m_PreviousTooltipName, GUI); m_Time = now + CooldownTime; break; } m_State = nextstate; } m_PreviousMousePos = MousePos; m_PreviousObject = Nearest; }