void wxRibbonPanel::OnChildKillFocus(wxFocusEvent& evt) { if(m_child_with_focus == NULL) return; // Should never happen, but a check can't hurt m_child_with_focus->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(wxRibbonPanel::OnChildKillFocus), NULL, this); m_child_with_focus = NULL; wxWindow *receiver = evt.GetWindow(); if(receiver == this || IsAncestorOf(this, receiver)) { m_child_with_focus = receiver; receiver->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(wxRibbonPanel::OnChildKillFocus), NULL, this); evt.Skip(); } else if(receiver == NULL || receiver != m_expanded_dummy) { HideExpanded(); // Do not skip event, as the panel has been de-expanded, causing the // child with focus to be reparented (and hidden). If the event // continues propagation then bad things happen. } else { evt.Skip(); } }
BOOL KMovableObject::HasFollowRelationWith(const KMovableObject* pOther) const { BOOL bResult = false; KG_PROCESS_ERROR(pOther); bResult = IsAncestorOf(pOther) || pOther->IsAncestorOf(this); Exit0: return bResult; }
void KMovableObject::AddFollower(KMovableObject* pFollower) { assert(pFollower); assert(!IsAncestorOf(pFollower) && !pFollower->IsAncestorOf(this)); pFollower->RemoveGuide();// 先删除之前的follower pFollower->SetPosition(GetTopCenter()); m_vecFollower.push_back(pFollower->m_dwID); pFollower->m_dwGuide = m_dwID; pFollower->m_dwObstacleID = ERROR_ID; }
bool TBWindow::EnsureFocus() { // If we already have focus, we're done. if (focused_widget && IsAncestorOf(focused_widget)) return true; // Focus last focused widget (if we have one) bool success = false; if (m_last_focus.Get()) success = m_last_focus.Get()->SetFocus(WIDGET_FOCUS_REASON_UNKNOWN); // We didn't have one or failed, so try focus any child. if (!success) success = SetFocusRecursive(WIDGET_FOCUS_REASON_UNKNOWN); return success; }
void wxRibbonPanel::OnKillFocus(wxFocusEvent& evt) { if(m_expanded_dummy) { wxWindow *receiver = evt.GetWindow(); if(IsAncestorOf(this, receiver)) { m_child_with_focus = receiver; receiver->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(wxRibbonPanel::OnChildKillFocus), NULL, this); } else if(receiver == NULL || receiver != m_expanded_dummy) { HideExpanded(); } } }
void DirectoryTree::RemoveItem(const wxString& sPath) { // Find the item wxTreeItemId tidToWastebin = GetItemFromPath(sPath, false); if(!tidToWastebin.IsOk()) { wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tNothing to remove.")); return; } wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s') returned %u"), sPath.c_str(), (int) tidToWastebin); // Sort out the new selection wxTreeItemId tidSelection = GetSelection(); if(!tidSelection.IsOk()) // FIXME: Should throw exception return; wxTreeItemId tidNewSelection; if(tidSelection == tidToWastebin) tidNewSelection = GetItemParent(tidSelection); else { // If we are in or below the path, climb up to directory above bool bIsParent = IsAncestorOf(tidToWastebin, tidSelection); wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tIsAncestorOf() returned %u"), bIsParent); if(bIsParent) tidNewSelection = GetItemParent(tidSelection); } // Remove item Delete(tidToWastebin); // Re select if necessary if(tidNewSelection.IsOk()) DoSelection(tidNewSelection); }
// D: returns true if sDescendantAgent is a descendant of sAgent bool CDTTManagerAgent::IsDescendantOf(string sDescendantAgentPath, string sAgentPath) { return IsAncestorOf(sAgentPath, sDescendantAgentPath); }