本文整理汇总了C++中CBuffer::GetLineCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CBuffer::GetLineCount方法的具体用法?C++ CBuffer::GetLineCount怎么用?C++ CBuffer::GetLineCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBuffer
的用法示例。
在下文中一共展示了CBuffer::GetLineCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例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: EnforceSelBounds
BOOL CSelection::EnforceSelBounds()
{
CBuffer *pBuffer = m_pCtrl->GetBuffer();
BOOL bFixup = FALSE;
if ( m_nEndRow < pBuffer->GetLineCount() )
{
int nLastChar = pBuffer->GetLineLength( m_nEndRow );
if ( m_nEndCol > nLastChar )
{
m_nEndCol = nLastChar;
bFixup = TRUE;
}
}
else
{
m_nEndCol = 0;
bFixup = TRUE;
}
return bFixup;
}
示例5: EnforceSelBounds
BOOL CSelection::EnforceSelBounds()
{
ASSERT( BoundSelection() ); // don't call this unless it's neccessary
CBuffer *pBuffer = m_pCtrl->GetBuffer();
BOOL bFixup = FALSE;
if ( m_nEndRow < pBuffer->GetLineCount() )
{
int nLastChar = pBuffer->GetLineLength( m_nEndRow );
if ( m_nEndCol > nLastChar )
{
m_nEndCol = nLastChar;
bFixup = TRUE;
}
}
else
{
m_nEndCol = 0;
bFixup = TRUE;
}
return bFixup;
}
示例6: Extend
void CSelection::Extend( Direction eDirection, Amount eAmount, BOOL bScrollIfNeccessary, BOOL bDamage, BOOL bAllowPastEndOfLine )
{
CBuffer *pBuffer = m_pCtrl->GetBuffer();
int nLineCount = pBuffer->GetLineCount();
BOOL bEnforceSelBounds = BoundSelection();
int nSaveEndRow = m_nEndRow;
int nSaveEndCol = m_nEndCol;
BOOL bUsePreferredCol = FALSE;
if ( nLineCount )
{
int nOldEndRow = m_nEndRow;
int nOldStartRow = m_nStartRow;
LPCTSTR pszEndLineStart = pBuffer->GetLineText( m_nEndRow );
int nEndLineLen = pBuffer->GetLineLength( m_nEndRow );
BOOL bStartRowChanged = FALSE;
switch ( eDirection )
{
case eUp:
{
switch ( eAmount )
{
case eChar:
{
m_nEndRow--;
bUsePreferredCol = TRUE;
break;
}
case ePage:
{
m_nEndRow -= ( m_pView->GetBottomIndex( FALSE ) - m_pView->GetTopIndex() );
break;
}
case eSmartAll:
case eAll:
{
m_nEndRow = 0;
break;
}
}
break;
}
case eDown:
{
switch ( eAmount )
{
case eChar:
{
m_nEndRow++;
bUsePreferredCol = TRUE;
break;
}
case ePage:
{
int nTemp = m_nEndRow + ( m_pView->GetBottomIndex( FALSE ) - m_pView->GetTopIndex() );
m_nEndRow = min( nLineCount, nTemp );
break;
}
case eAll:
case eSmartAll:
{
m_nEndRow = nLineCount - 1;
break;
}
}
break;
}
case eLeft:
{
switch ( eAmount )
{
case eChar:
{
if ( m_nEndCol == 0 || m_nEndCol > nEndLineLen )
m_nEndCol--;
else
m_nEndCol -= _tclen_prev( pszEndLineStart, pszEndLineStart + m_nEndCol );
if ( m_nEndCol < 0 )
{
if ( bAllowPastEndOfLine && m_nEndRow > 0 )
{
m_nEndRow--;
m_nEndCol = pBuffer->GetLineLength( m_nEndRow );
bEnforceSelBounds = FALSE; // already enforced by previous statement!
}
else
{
m_nEndCol = 0;
}
}
break;
}
case ePage:
{
m_nEndCol -= ( m_pView->GetRightIndex( FALSE ) - m_pView->GetLeftIndex() );
break;
}
case eAll:
//.........这里部分代码省略.........
示例7: 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 );
}
}
}