void		GUI_SimpleTableGeometry::SetCellWidth (int n, int w)
{
	if (w < 5) w = 5;
	ExtendTo(n);
	int delta = w - GetCellWidth(n);
	for (int i = n; i < mCols.size(); ++i)
		mCols[i] += delta;
//	BroadcastMessage(GUI_TABLE_SHAPE_RESIZED, 0);
}
int			GUI_SimpleTableGeometry::GetCellWidth(int n)
{
	ExtendTo(n);
	return (n == 0) ? mCols[0] : (mCols[n] - mCols[n-1]);
}
int			GUI_SimpleTableGeometry::GetCellRight(int n)
{
	ExtendTo(n);
	return mCols[n];
}
int			GUI_SimpleTableGeometry::GetCellLeft (int n)
{
	if(n > 0) ExtendTo(n-1);
	return (n == 0) ? 0 : mCols[n-1];
}
示例#5
0
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 );
        }
    }
}