int COXMaskedEdit::GetPreviousInputLocation(int nSelectionStart) { // One of the functions of this edit control is that it skips over literals. // We need a function to help skip to the next position. int nNextInputLocation=nSelectionStart; if(nNextInputLocation < 0) nNextInputLocation=0; // Need to determine if we moved to a previous location. // There will need to be some correction. int nInitialInputLocation=nNextInputLocation; CMaskData* pobjData=NULL; for(POSITION pos=m_listData.FindIndex(nNextInputLocation); pos; nNextInputLocation--) { pobjData=m_listData.GetPrev(pos); if(pobjData->IsInputData()) { if(nInitialInputLocation != nNextInputLocation) { // If we find a valid previous location, then move to the right of it. // This backup, then move forward is typical when seeking backward. nNextInputLocation++; } break; } } // If there is no input data to the left of the selection, // then seek forward to the next location. if(nNextInputLocation < 0) return GetNextInputLocation(nSelectionStart); return nNextInputLocation; }
int wxMaskController::GetPreviousInputLocation(int nSelectionStart) { // One of the functions of this edit control is that it skips over literals. // We need a function to help skip to the next position. int nNextInputLocation=nSelectionStart; if(nNextInputLocation < 0) nNextInputLocation = 0; // Need to determine if we moved to a previous location. // There will need to be some correction. int nInitialInputLocation=nNextInputLocation; wxFieldMaskData* pobjData = NULL; for(wxNode* node = m_listData.Item(nNextInputLocation);node;nNextInputLocation--) { pobjData = (wxFieldMaskData *) node->GetData(); if(pobjData->IsInputData()) { if(nInitialInputLocation != nNextInputLocation) { // If we find a valid previous location, then move to the right of it. // This backup, then move forward is typical when seeking backward. if(m_bBackwardLocationRight) nNextInputLocation++; } break; } node = node->GetPrevious(); } // If there is no input data to the left of the selection, // then seek forward to the next location. if(nNextInputLocation < 0) return GetNextInputLocation(nSelectionStart); return nNextInputLocation; }
void COXMaskedEdit::UpdateInsertionPointForward(int nSelectionStart) { int nNewInsertionPoint=GetNextInputLocation(nSelectionStart); if(m_bAutoTab && nNewInsertionPoint==m_listData.GetCount()) { CWnd* pParentWnd=GetParent(); ASSERT(pParentWnd); CWnd* pNextTabCtrl=pParentWnd->GetNextDlgTabItem(this); if(pNextTabCtrl && pNextTabCtrl!=this) { pNextTabCtrl->SetFocus(); } } else { SetSel(nNewInsertionPoint, nNewInsertionPoint); } }