📄 hlinkmgr.cpp
字号:
case HXDownFocus: case HXRightFocus: case HXNextFocus: { GetNextLinkWithDefault(); } break; case HXLastFocus: { GetLastLinkWithDefault(); } break; }}BOOL PXHyperlinkManager::GetLinkWithKeyboardFocus(REF(HXxRect) rRect, REF(IHXBuffer*) rpBuffer){ BOOL bRet = FALSE; if (m_bSomeLinkHasKeyboardFocus) { if (m_bDefaultLinkHasKeyboardFocus) { // Sanity check to make sure we actually // HAVE a default link if (m_bHaveDefault) { // The rect is the full window rRect.left = 0; rRect.top = 0; rRect.right = (INT32) m_ulWidth; rRect.bottom = (INT32) m_ulHeight; // Set the link string HX_RELEASE(rpBuffer); rpBuffer = m_pDefaultLinkStr; rpBuffer->AddRef(); // Set the return value bRet = TRUE; } } else { // Sanity check to make sure we have set // the keyboard focus link pointer if (m_pKeyboardFocusLink) { // Set the rect rRect = m_pKeyboardFocusLink->m_Rect; // Set the string buffer HX_RELEASE(rpBuffer); rpBuffer = m_pKeyboardFocusLink->m_pLinkStr; rpBuffer->AddRef(); // Set the return value bRet = TRUE; } } } return bRet;}void PXHyperlinkManager::ClearKeyboardFocus(){ m_bSomeLinkHasKeyboardFocus = FALSE; m_bDefaultLinkHasKeyboardFocus = FALSE; m_pKeyboardFocusLink = NULL;}void PXHyperlinkManager::ClearLinkPairList(){ if (m_pLinkPairList) { LISTPOSITION pos = m_pLinkPairList->GetHeadPosition(); while (pos) { PXHyperlink* pLink = (PXHyperlink*) m_pLinkPairList->GetNext(pos); HX_DELETE(pLink); } m_pLinkPairList->RemoveAll(); }}BOOL PXHyperlinkManager::GetFirstLink(REF(PXHyperlink*) rpLink){ return GetNextLink(NULL, rpLink);}BOOL PXHyperlinkManager::GetLastLink(REF(PXHyperlink*) rpLink){ return GetPrevLink(NULL, rpLink);}BOOL PXHyperlinkManager::GetNextLink(PXHyperlink* pCurLink, REF(PXHyperlink*) rpNextLink){ BOOL bRet = FALSE; // Do we have a current link? if (pCurLink) { // Run through the list to find the "next" link - // one with the same tab index and higher lexical order // or if there are none of those, the one with the // higher tabindex if (m_pLinkPairList) { PXHyperlink* pNextLink = NULL; LISTPOSITION pos = m_pLinkPairList->GetHeadPosition(); while (pos) { PXHyperlink* pLink = (PXHyperlink*) m_pLinkPairList->GetNext(pos); if (pLink && (pLink->m_ulTabIndex != pCurLink->m_ulTabIndex || pLink->m_ulLexicalOrder != pCurLink->m_ulLexicalOrder)) { // Is this link a candidate? if (pLink->m_ulTabIndex > pCurLink->m_ulTabIndex || (pLink->m_ulTabIndex == pCurLink->m_ulTabIndex && pLink->m_ulLexicalOrder > pCurLink->m_ulLexicalOrder)) { // Yes, this might be one. Is it sooner than // the current "next" link? if (!pNextLink || (pLink->m_ulTabIndex < pNextLink->m_ulTabIndex || (pLink->m_ulTabIndex == pNextLink->m_ulTabIndex && pLink->m_ulLexicalOrder < pNextLink->m_ulLexicalOrder))) { pNextLink = pLink; } } } } // Did we get one? if (pNextLink) { // Assign the out parameter rpNextLink = pNextLink; // Set the return value bRet = TRUE; } } } else { // No, no current link, so take the // first link (i.e - min tab index, and min // lexical order within that tab index) if (m_pLinkPairList) { UINT32 ulMinTab = 0xFFFFFFFF; UINT32 ulMinLex = 0xFFFFFFFF; PXHyperlink* pMinLink = NULL; LISTPOSITION pos = m_pLinkPairList->GetHeadPosition(); while (pos) { PXHyperlink* pLink = (PXHyperlink*) m_pLinkPairList->GetNext(pos); if (pLink && (pLink->m_ulTabIndex < ulMinTab || (pLink->m_ulTabIndex == ulMinTab && pLink->m_ulLexicalOrder < ulMinLex))) { ulMinTab = pLink->m_ulTabIndex; ulMinLex = pLink->m_ulLexicalOrder; pMinLink = pLink; } } // Did we get one? if (pMinLink) { // Assign the out parameter rpNextLink = pMinLink; // Set the return value bRet = TRUE; } } } return bRet;}BOOL PXHyperlinkManager::GetPrevLink(PXHyperlink* pCurLink, REF(PXHyperlink*) rpPrevLink){ BOOL bRet = FALSE; // Do we have a current link? if (pCurLink) { // Run through the list to find the "prev" link - // one with the same tab index and smaller lexical order // or if there are none of those, the one with the // smaller tabindex if (m_pLinkPairList) { PXHyperlink* pPrevLink = NULL; LISTPOSITION pos = m_pLinkPairList->GetHeadPosition(); while (pos) { PXHyperlink* pLink = (PXHyperlink*) m_pLinkPairList->GetNext(pos); if (pLink && (pLink->m_ulTabIndex != pCurLink->m_ulTabIndex || pLink->m_ulLexicalOrder != pCurLink->m_ulLexicalOrder)) { // Is this link a candidate? if (pLink->m_ulTabIndex < pCurLink->m_ulTabIndex || (pLink->m_ulTabIndex == pCurLink->m_ulTabIndex && pLink->m_ulLexicalOrder < pCurLink->m_ulLexicalOrder)) { // Yes, this might be one. Is it later than // the current "prev" link? if (!pPrevLink || (pLink->m_ulTabIndex > pPrevLink->m_ulTabIndex || (pLink->m_ulTabIndex == pPrevLink->m_ulTabIndex && pLink->m_ulLexicalOrder > pPrevLink->m_ulLexicalOrder))) { pPrevLink = pLink; } } } } // Did we get one? if (pPrevLink) { // Assign the out parameter rpPrevLink = pPrevLink; // Set the return value bRet = TRUE; } } } else { // No, no current link, so take the // last link (i.e - max tab index, and max // lexical order within that tab index) if (m_pLinkPairList) { INT32 lMaxTab = -1; INT32 lMaxLex = -1; PXHyperlink* pMaxLink = NULL; LISTPOSITION pos = m_pLinkPairList->GetHeadPosition(); while (pos) { PXHyperlink* pLink = (PXHyperlink*) m_pLinkPairList->GetNext(pos); if (pLink) { INT32 lTab = (INT32) pLink->m_ulTabIndex; INT32 lLex = (INT32) pLink->m_ulLexicalOrder; if (lTab > lMaxTab || (lTab == lMaxTab && lLex > lMaxLex)) { lMaxTab = (INT32) pLink->m_ulTabIndex; lMaxLex = (INT32) pLink->m_ulLexicalOrder; pMaxLink = pLink; } } } // Did we get one? if (pMaxLink) { // Assign the out parameter rpPrevLink = pMaxLink; // Set the return value bRet = TRUE; } } } return bRet;}void PXHyperlinkManager::GetFirstLinkWithDefault(){ // First is always default if present, // and first link if no default PXHyperlink* pLink = NULL; if (m_bHaveDefault) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = TRUE; m_pKeyboardFocusLink = NULL; } else if (GetFirstLink(pLink)) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = FALSE; m_pKeyboardFocusLink = pLink; } else { ClearKeyboardFocus(); }}void PXHyperlinkManager::GetLastLinkWithDefault(){ // Last is GetLastLink() if it returns TRUE // and default link if GetLastLink is FALSE PXHyperlink* pLink = NULL; if (GetLastLink(pLink)) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = FALSE; m_pKeyboardFocusLink = pLink; } else if (m_bHaveDefault) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = TRUE; m_pKeyboardFocusLink = NULL; } else { ClearKeyboardFocus(); }}void PXHyperlinkManager::GetNextLinkWithDefault(){ // Do we already have a focus link? if (m_bSomeLinkHasKeyboardFocus) { // We already have a focus link // // Is it the default link? if (m_bDefaultLinkHasKeyboardFocus) { // Get the first link PXHyperlink* pLink = NULL; if (GetFirstLink(pLink)) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = FALSE; m_pKeyboardFocusLink = pLink; } else { ClearKeyboardFocus(); } } else { // Get the next link PXHyperlink* pLink = NULL; if (GetNextLink(m_pKeyboardFocusLink, pLink)) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = FALSE; m_pKeyboardFocusLink = pLink; } else { ClearKeyboardFocus(); } } } else { // We don't currently have a focus link, so this is // the same as GetFirstLinkWithDefault() GetFirstLinkWithDefault(); }}void PXHyperlinkManager::GetPrevLinkWithDefault(){ // Do we already have a focus link? if (m_bSomeLinkHasKeyboardFocus) { // We already have a focus link // // Is it the default link? if (m_bDefaultLinkHasKeyboardFocus) { // Yes, the default link has focus, // so now we don't have any focus ClearKeyboardFocus(); } else { // Some other link has focus // // Get the prev link PXHyperlink* pLink = NULL; if (GetPrevLink(m_pKeyboardFocusLink, pLink)) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = FALSE; m_pKeyboardFocusLink = pLink; } else if (m_bHaveDefault) { m_bSomeLinkHasKeyboardFocus = TRUE; m_bDefaultLinkHasKeyboardFocus = TRUE; m_pKeyboardFocusLink = NULL; } else { ClearKeyboardFocus(); } } } else { // We don't currently have a focus link, so this is // the same as GetLastLinkWithDefault() GetLastLinkWithDefault(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -