当前位置: 首页>>代码示例>>C++>>正文


C++ CBuffer::GetLineCount方法代码示例

本文整理汇总了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;
}
开发者ID:ForbiddenEra,项目名称:kx-audio-driver,代码行数:25,代码来源:EDITSEL.CPP

示例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();
	}
}
开发者ID:ForbiddenEra,项目名称:kx-audio-driver,代码行数:54,代码来源:EDITSEL.CPP

示例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();
}
开发者ID:GaoHongchen,项目名称:chromatic,代码行数:42,代码来源:EDITSEL.CPP

示例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;
}
开发者ID:GaoHongchen,项目名称:chromatic,代码行数:23,代码来源:EDITSEL.CPP

示例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;
}
开发者ID:ForbiddenEra,项目名称:kx-audio-driver,代码行数:24,代码来源:EDITSEL.CPP

示例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:
//.........这里部分代码省略.........
开发者ID:GaoHongchen,项目名称:chromatic,代码行数:101,代码来源:EDITSEL.CPP

示例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 );
        }
    }
}
开发者ID:GaoHongchen,项目名称:chromatic,代码行数:73,代码来源:EDITSEL.CPP


注:本文中的CBuffer::GetLineCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。