本文整理汇总了C++中CBuffer::ConvertViewColToBufferCol方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::ConvertViewColToBufferCol方法的具体用法?C++ CBuffer::ConvertViewColToBufferCol怎么用?C++ CBuffer::ConvertViewColToBufferCol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::ConvertViewColToBufferCol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetView
void CSelection::SetView( CEditView *pView, BOOL bSilent )
{
if ( m_pView != pView )
{
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nRow = pView->GetTopIndex();
int nCol = pBuffer->ConvertViewColToBufferCol( nRow, pView->GetLeftIndex() );
nCol = pBuffer->ConvertBufferColToViewCol( nRow, nCol );
if ( !bSilent )
{
SetEmptySelection( nCol, nRow );
}
m_pView = pView;
UpdateCaretPosition();
}
}
示例2: Extend
//.........这里部分代码省略.........
bStartRowChanged = ( m_nStartRow != nOldStartRow );
break;
}
}
break;
}
}
int nTemp = nLineCount - 1;
m_nEndRow = min( m_nEndRow, nTemp );
m_nEndRow = max( 0, m_nEndRow );
m_nEndCol = ( nLineCount == 0 ) ? 0 : max( 0, m_nEndCol );
BOOL bEndViewColUpToDate = FALSE;
// keep cursor within the line's bounds if requested to
if ( bEnforceSelBounds )
{
// special case: if moving left one char and beyond the end of the line,
// do the fixup now or else the one-char move will be nullified by
// EnforceSelBounds()
if ( nLineCount && eDirection == eLeft && eAmount == eChar )
{
int nEndRowLen = pBuffer->GetLineLength( m_nEndRow );
if ( m_nEndCol >= nEndRowLen )
{
m_nEndCol = nEndRowLen - 1;
m_nEndCol = max( 0, m_nEndCol );
}
}
if ( bUsePreferredCol && nSaveEndRow != m_nEndRow )
{
m_nEndCol = pBuffer->ConvertViewColToBufferCol( m_nEndRow, m_nEndViewColPreferred );
}
BOOL bFixup = EnforceSelBounds();
// if we didn't have to fix-up the selection, remember this new col position
// as the preferred position.
if ( !bFixup )
{
if ( bUsePreferredCol && nSaveEndRow != m_nEndRow )
{
// moved vertically -- need to translate view col from one row to another
int nBuffCol = pBuffer->ConvertViewColToBufferCol( m_nEndRow, m_nEndViewColPreferred );
m_nEndViewCol = pBuffer->ConvertBufferColToViewCol( m_nEndRow, nBuffCol );
m_nEndCol = pBuffer->ConvertViewColToBufferCol( m_nEndRow, m_nEndViewCol );
}
else if ( nSaveEndCol != m_nEndCol )
{
m_nEndViewCol = pBuffer->ConvertBufferColToViewCol( m_nEndRow, m_nEndCol );
m_nEndViewColPreferred = m_nEndViewCol;
}
bEndViewColUpToDate = TRUE;
}
}
// since m_nEndCol may have changed, we need to recalc the view position and re-snap m_nEndCol to the current row
if ( !bEndViewColUpToDate )
{
m_nEndViewCol = pBuffer->ConvertBufferColToViewCol( m_nEndRow, m_nEndCol );
m_nEndCol = pBuffer->ConvertViewColToBufferCol( m_nEndRow, m_nEndViewCol );
}
if ( eDirection == eOutward )
示例3: SetSelectionFromPoint
void CSelection::SetSelectionFromPoint( CEditView *pView, int x, int y, BOOL bEmpty, BOOL bAllowLineSel )
{
if ( m_pView != pView )
{
CEditView *pLastView = m_pView;
m_pView = pView;
if ( !IsEmpty() )
{
// switching views -- erase the selection in the other view
pLastView->DamageView( min( m_nEndRow, m_nStartRow ), max( m_nEndRow, m_nStartRow ) );
}
}
int nCol, nRow;
RECT rcChar;
m_pView->GetCharPosFromPoint( x, y, nCol, nRow, &rcChar );
RECT rcView;
m_pView->GetViewRect( &rcView );
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nLineCount = pBuffer->GetLineCount();
if ( !bEmpty && bAllowLineSel && ( x > rcView.left && x < ( rcView.left + m_pView->GetLeftMargin( TRUE ) ) ) )
{
// line selecting
nCol = 0;
if ( nRow < m_nStartRow )
{
m_nStartCol = CEditView::MAXCOL;
}
else
{
m_nStartCol = 0;
nRow++;
}
nRow = min( nRow, nLineCount - 1 );
nRow = max( 0, nRow );
// selecting the last line should just go to the end of the line since
// there is no line below nRow.
if ( nLineCount && ( nRow == nLineCount - 1 ) )
{
nCol = pBuffer->GetLineLength( nRow );
}
}
else
{
nRow = min( nRow, nLineCount - 1 );
nRow = max( 0, nRow );
nCol = pBuffer->ConvertViewColToBufferCol( nRow, nCol );
}
// since the column might have changed above, let's refetch the
// char rect.
m_pView->GetCharBoundingRect( nCol, nRow, &rcChar );
if ( !IsRectEmpty( &rcChar ) && ( x > ( ( rcChar.left + rcChar.right ) / 2 ) ) )
{
// cursor is closer to the next char
nCol += pBuffer->GetCharSize( nRow, nCol );
}
if ( bEmpty )
{
SetEmptySelection( nCol, nRow );
}
else
{
if ( nCol != m_nEndCol || nRow != m_nEndRow )
{
ExtendTo( nCol, nRow );
}
}
}