void wxTopLevelWindowMSW::DoSaveLastFocus() { if ( m_iconized ) return; // remember the last focused child if it is our child wxWindow* const winFocus = FindFocus(); m_winLastFocused = IsDescendant(winFocus) ? winFocus : NULL; }
BOOL StaticObject::Recycle(Entity* obj) { if (obj == NULL) { return false; } if (IsDescendant(obj)) { _totalCount--; return RemoveDescendant(obj); } return false; }
bool HookGui::HGWidget::IsDescendant(HGWidget* _widget) { // Compare the widgets if(_widget == this) { return true; } // For each child for(auto child : m_Childs) { // Check if is descendant if(IsDescendant(child)) { return true; } } return false; }
void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) { if ( event.GetActive() ) { // We get WM_ACTIVATE before being restored from iconized state, so we // can be still iconized here. In this case, avoid restoring the focus // as it doesn't work anyhow and we will do when we're really restored. if ( m_iconized ) { event.Skip(); return; } // restore focus to the child which was last focused unless one of our // children already has it (the frame having focus on itself does not // count, if only because this would be always the case for an MDI // child frame as the MDI parent sets focus to it before it's // activated) wxLogTrace(wxT("focus"), wxT("wxTLW %p activated."), m_hWnd); wxWindow* const winFocus = FindFocus(); if ( winFocus == this || !IsDescendant(winFocus) ) DoRestoreLastFocus(); } else // deactivating { DoSaveLastFocus(); wxLogTrace(wxT("focus"), wxT("wxTLW %p deactivated, last focused: %p."), m_hWnd, m_winLastFocused ? GetHwndOf(m_winLastFocused) : NULL); event.Skip(); } }
static nsIFrame* GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame, const nsRect& aTargetRect, const EventRadiusPrefs* aPrefs, nsIFrame* aRestrictToDescendants, nsIContent* aClickableAncestor, nsTArray<nsIFrame*>& aCandidates, int32_t* aElementsInCluster) { std::vector<nsIContent*> mContentsInCluster; // List of content elements in the cluster without duplicate nsIFrame* bestTarget = nullptr; // Lower is better; distance is in appunits float bestDistance = 1e6f; nsRegion exposedRegion(aTargetRect); for (uint32_t i = 0; i < aCandidates.Length(); ++i) { nsIFrame* f = aCandidates[i]; PET_LOG("Checking candidate %p\n", f); bool preservesAxisAlignedRectangles = false; nsRect borderBox = nsLayoutUtils::TransformFrameRectToAncestor(f, nsRect(nsPoint(0, 0), f->GetSize()), aRoot, &preservesAxisAlignedRectangles); nsRegion region; region.And(exposedRegion, borderBox); if (region.IsEmpty()) { PET_LOG(" candidate %p had empty hit region\n", f); continue; } if (preservesAxisAlignedRectangles) { // Subtract from the exposed region if we have a transform that won't make // the bounds include a bunch of area that we don't actually cover. SubtractFromExposedRegion(&exposedRegion, region); } nsAutoString labelTargetId; if (aClickableAncestor && !IsDescendant(f, aClickableAncestor, &labelTargetId)) { PET_LOG(" candidate %p is not a descendant of required ancestor\n", f); continue; } nsIContent* clickableContent = GetClickableAncestor(f, nsGkAtoms::body, &labelTargetId); if (!aClickableAncestor && !clickableContent) { PET_LOG(" candidate %p was not clickable\n", f); continue; } // If our current closest frame is a descendant of 'f', skip 'f' (prefer // the nested frame). if (bestTarget && nsLayoutUtils::IsProperAncestorFrameCrossDoc(f, bestTarget, aRoot)) { PET_LOG(" candidate %p was ancestor for bestTarget %p\n", f, bestTarget); continue; } if (!aClickableAncestor && !nsLayoutUtils::IsAncestorFrameCrossDoc(aRestrictToDescendants, f, aRoot)) { PET_LOG(" candidate %p was not descendant of restrictroot %p\n", f, aRestrictToDescendants); continue; } // If the first clickable ancestor of f is a label element // and "for" attribute is present in label element, search the frame list for the "for" element // If this element is present in the current list, do not count the frame in // the cluster elements counter if ((labelTargetId.IsEmpty() || !IsElementPresent(aCandidates, labelTargetId)) && !IsLargeElement(f, aPrefs)) { if (std::find(mContentsInCluster.begin(), mContentsInCluster.end(), clickableContent) == mContentsInCluster.end()) { mContentsInCluster.push_back(clickableContent); } } // distance is in appunits float distance = ComputeDistanceFromRegion(aPointRelativeToRootFrame, region); nsIContent* content = f->GetContent(); if (content && content->IsElement() && content->AsElement()->State().HasState( EventStates(NS_EVENT_STATE_VISITED))) { distance *= aPrefs->mVisitedWeight / 100.0f; } if (distance < bestDistance) { PET_LOG(" candidate %p is the new best\n", f); bestDistance = distance; bestTarget = f; } } *aElementsInCluster = mContentsInCluster.size(); return bestTarget; }
void COXItemTipWnd::Display(CRect& rect, CString sText, int nOffset, int nAlignment, CFont* pFont, COLORREF clrText, COLORREF clrBackground) { ASSERT_VALID(m_pParentWnd); ASSERT(::IsWindow(m_pParentWnd->GetSafeHwnd())); ASSERT(::IsWindow(m_hWnd)); CWnd* pWnd=GetActiveWindow(); if(pWnd==NULL || (!IsDescendant(pWnd,m_pParentWnd) && (m_pParentWnd->GetExStyle()&WS_EX_TOPMOST)!=WS_EX_TOPMOST)) { return; } CClientDC dc(this); // device context for drawing CFont* pOldFont=NULL; if(pFont) { pOldFont=dc.SelectObject(pFont); } COLORREF clrOld=ID_OX_COLOR_NONE; if(clrText!=ID_OX_COLOR_NONE) { clrOld=dc.SetTextColor(clrText); } int nOldBkMode=dc.SetBkMode(TRANSPARENT); CRect rectDraw=rect; dc.DrawText(sText,&rectDraw,DT_CALCRECT|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX); rectDraw.right+=2*nOffset; if(rectDraw.Width()>rect.Width()) { rect.right=rect.left+rectDraw.Width(); } if(rectDraw.Height()>rect.Height()) { rect.bottom=rect.top+rectDraw.Height(); } // it's show time! m_pParentWnd->ClientToScreen(&rect); // adjust rectangle to fit the screen // CWnd* pParentWnd=m_pParentWnd; BOOL bTopMostParent=FALSE; while(pParentWnd!=NULL) { if(pParentWnd->GetExStyle() & WS_EX_TOPMOST) { bTopMostParent=TRUE; break; } pParentWnd=pParentWnd->GetParent(); } DWORD dwMessagePos=::GetMessagePos(); CPoint point(GET_X_LPARAM(dwMessagePos),GET_Y_LPARAM(dwMessagePos)); CRect rectDisplay=GetMonitorRectFromPoint(point,!bTopMostParent); if(rect.right>rectDisplay.right) { rect.OffsetRect(rectDisplay.right-rect.right,0); } if(rect.left<rectDisplay.left) { rect.OffsetRect(rectDisplay.left-rect.left,0); } // ///////////////////////////////////////////////////////////// if(bTopMostParent) { SetWindowPos(&wndTopMost,rect.left,rect.top,rect.Width(), rect.Height(),SWP_NOACTIVATE); } else { SetWindowPos(NULL,rect.left,rect.top,rect.Width(), rect.Height(),SWP_NOZORDER|SWP_NOACTIVATE); } ShowWindow(SW_SHOWNA); if(clrBackground!=ID_OX_COLOR_NONE) { CBrush brush; brush.CreateSolidBrush(clrBackground); CRect rectClient; GetClientRect(rectClient); dc.FillRect(&rectClient,&brush); } else { SendMessage(WM_ERASEBKGND,(WPARAM)(HDC)dc); } rectDraw=rect; rectDraw.DeflateRect(nOffset,0); ScreenToClient(&rectDraw); dc.DrawText(sText,&rectDraw,nAlignment|DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX); if(pOldFont) { dc.SelectObject(pOldFont); } if(clrOld!=ID_OX_COLOR_NONE) { dc.SetTextColor(clrOld); } dc.SetBkMode(nOldBkMode); m_nTimerID=SetTimer(ID_OXITEMTIP_TIMER,ID_OXITEMTIP_TIMER_DELAY,NULL); if(m_nTimerID==0) { TRACE(_T("COXItemTipWnd::Display: failed to set timer to check item tip state\n")); } }