本文整理汇总了C++中CBuffer::ConvertBufferColToViewCol方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::ConvertBufferColToViewCol方法的具体用法?C++ CBuffer::ConvertBufferColToViewCol怎么用?C++ CBuffer::ConvertBufferColToViewCol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::ConvertBufferColToViewCol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetExtendedSelection
void CSelection::SetExtendedSelection( int nStartCol, int nStartRow, int nEndCol, int nEndRow, BOOL bEnsureVisible, BOOL bAllowDamage )
{
ASSERT( nStartRow >= 0 );
int nOldStartRow = m_nStartRow;
int nOldEndRow = m_nEndRow;
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nMaxLine = pBuffer->GetLineCount() - 1;
nMaxLine = max( 0, nMaxLine );
m_nStartRow = min( nMaxLine, nStartRow );
m_nEndRow = min( nMaxLine, nEndRow );
m_nStartCol = nStartCol;
m_nEndCol = nEndCol;
// keep selection over text, if requested to
if ( BoundSelection() )
{
BOOL bKeepEmpty = ( nStartCol == nEndCol && nStartRow == nEndRow );
EnforceSelBounds();
if ( bKeepEmpty )
{
m_nStartCol = m_nEndCol;
}
}
m_nEndViewCol = pBuffer->ConvertBufferColToViewCol( m_nEndRow, m_nEndCol );
m_nStartViewCol = pBuffer->ConvertBufferColToViewCol( m_nStartRow, m_nStartCol );
m_nEndViewColPreferred = m_nEndViewCol;
// damage old selection and new selection to clear it
if ( bAllowDamage )
{
int nStartDamage = min( nOldStartRow, nOldEndRow );
nStartDamage = min( nStartDamage, nStartRow );
nStartDamage = min( nStartDamage, nEndRow );
int nEndDamage = max( nOldStartRow, nOldEndRow );
nEndDamage = max( nEndDamage, nStartRow );
nEndDamage = max( nEndDamage, nEndRow );
m_pView->DamageView( nStartDamage, nEndDamage );
}
if ( bEnsureVisible )
{
EnsureVisible( TRUE );
}
if ( ::IsWindow( m_hWnd ) && GetFocus() == m_hWnd )
{
UpdateCaretPosition();
}
}
示例2: GetCaretRect
void CSelection::GetCaretRect( CEditView *pView, int nBuffCol, int nRow, RECT &rcCaret )
{
ASSERT( pView );
RECT rcView;
pView->GetRect( &rcView );
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nLastLine = pBuffer->GetLineCount() - 1;
int nViewCol = nBuffCol;
nRow = min( nLastLine, nRow );
if ( nRow < 0 )
{
nRow = 0;
}
else
{
nViewCol = pBuffer->ConvertBufferColToViewCol( nRow, nBuffCol );
}
rcCaret.left = rcView.left + pView->GetLeftMargin( TRUE, TRUE ) + ( ( nViewCol - pView->GetLeftIndex() ) * pView->GetCharWidth() );
rcCaret.right = rcCaret.left + m_cxCaretIns;
rcCaret.top = rcView.top + ( ( nRow - pView->GetTopIndex() ) * pView->GetLineHeight() );
rcCaret.bottom = rcCaret.top + m_cyCaret;
}
示例3: ExtendTo
void CSelection::ExtendTo( int nCol, int nRow )
{
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nOldRow = m_nEndRow;
int nTemp = pBuffer->GetLineCount() - 1;
nTemp = min( nRow, nTemp );
m_nEndRow = max( 0, nTemp );
int nMinRow = min( nOldRow, m_nEndRow );
int nMaxRow = max( nOldRow, m_nEndRow );
int nOldViewCol = m_nEndViewCol;
m_nEndCol = max( 0, nCol );
// keep selection over text is requested to
if ( BoundSelection() )
{
EnforceSelBounds();
}
m_nStartViewCol = pBuffer->ConvertBufferColToViewCol( m_nStartRow, m_nStartCol );
m_nEndViewCol = pBuffer->ConvertBufferColToViewCol( m_nEndRow, m_nEndCol );
if ( m_bColumnSel && ( m_nEndViewCol != nOldViewCol ) )
{
// column sel width changed
nMinRow = min( nMinRow, m_nStartRow );
nMaxRow = max( nMaxRow, m_nStartRow );
}
// if user changed lines, notify the control so it can normalize the text case in the
// line that was just left.
if ( nOldRow != nRow )
{
m_pCtrl->OnChangeLineSelection();
}
m_pView->DamageView( nMinRow, nMaxRow );
UpdateCaretPosition();
}
示例4: 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();
}
}
示例5: Extend
//.........这里部分代码省略.........
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 )
{
m_nStartViewCol = pBuffer->ConvertBufferColToViewCol( m_nStartRow, m_nStartCol );
}
if ( bDamage )
{
int nDamageStart = min( nOldEndRow, m_nEndRow );
int nDamageEnd = max( nOldEndRow, m_nEndRow );
if ( m_bColumnSel )
{
nDamageStart = min( nDamageStart, nOldStartRow );
nDamageStart = min( nDamageStart, m_nStartRow );
nDamageEnd = max( nDamageEnd, nOldStartRow );
nDamageEnd = max( nDamageEnd, m_nStartRow );
}
if ( bStartRowChanged )
{
nDamageStart = min( nDamageStart, nOldStartRow );
nDamageStart = min( nDamageStart, m_nStartRow );
nDamageEnd = max( nDamageEnd, nOldEndRow );
nDamageEnd = max( nDamageEnd, m_nEndRow );
}
m_pView->DamageView( nDamageStart, nDamageEnd );
}
// if user changed lines, notify the control so it can normalize the text case in the
// line that was just left.
if ( eDirection == eUp || eDirection == eDown )
{
m_pCtrl->OnChangeLineSelection();
}
}
else
{
m_nEndCol = m_nEndRow = m_nEndViewCol = m_nStartViewCol = m_nStartCol = m_nStartRow = 0;
}
if ( bScrollIfNeccessary )
{
EnsureVisible( TRUE );
}
}