Ejemplo n.º 1
0
EGridCtrl::Column* EGridCtrl::GetColumn( CString sName , bool bCreateIfNotFound , int nNewColumnWidth )
{
	Column* pColumn = NULL;

	std::list<Column*>::iterator iter = m_vCols.begin();
	std::list<Column*>::iterator iend = m_vCols.end();

	while( iter != iend )
	{
		Column* pCur = *iter;
		if( sName == pCur->m_sName )
		{
			pColumn = pCur;
			break;
		}
		iter++;
	}

	if( pColumn == NULL )
	{
		if( bCreateIfNotFound )
		{
			pColumn = new Column( sName );
			pColumn->EnsureWidth( nNewColumnWidth );
			m_vCols.push_back(pColumn);
		}
	}

	return pColumn;
}
Ejemplo n.º 2
0
void EGridCtrl::OnLButtonDblClk( UINT nFlags, CPoint point )
{
	Column* pCol = GetColumn( point.x , true );

	if( pCol != NULL )
	{
		pCol->m_nWidth = 0;

		std::list<Row*>::iterator iter = m_vRows.begin();
		std::list<Row*>::iterator iend = m_vRows.end();

		CDC* pDC = GetDC();
		pDC->SelectObject(&m_Font);

		while( iter != iend )
		{
			Row* pRow = *iter;

			EProperty* pProperty = pRow->GetProperty( pCol->m_sName );

			if( pProperty != NULL )
			{
				pCol->EnsureWidth( pProperty->GetPreferedWidth(pDC) );
			}

			iter++;
		}

		ReleaseDC(pDC);
		RefreshColumnLefts( m_ViewportOrg.x );
		Invalidate();
		m_bWasDoubleClick = true;
	}
}
Ejemplo n.º 3
0
void EGridCtrl::AddRow( IGridRow* pRowHost )
{
	//
	// collect properties (columns) for the row
	//

	Row* pRow = new Row( pRowHost );
	pRowHost->GetGridColumns( *pRow );
	pRowHost->m_pGridCtrl = this;

	//
	//  prepare the dc for size calculations
	//

	CDC* pDC = GetDC();
	pDC->SelectObject( &m_Font );

	//
	//
	//
	
	pRow->m_nHeight = GetRowHeight( pRow , pDC );
	m_vRows.push_back( pRow );

	//
	// update column list
	//

	std::list<Row*>::iterator iter = m_vRows.begin();
	std::list<Row*>::iterator iend = m_vRows.end();

	while( iter != iend )	//for all rows...
	{
		Row* pRow = *iter;

		ASSERT( pRow->GetTabCount()==1 );
		ASSERT( pRow->GetActiveTab()==0 );

		int n = pRow->Size();

		for( int i=0 ; i<n ; i++ )
		{
			EProperty* pProperty = pRow->Get(i);

			int m = EIconTextButtonProperty::s_nMargin;

			CString sName   = pProperty->GetName();
			Column* pColumn = GetColumn( sName , true , m + pDC->GetTextExtent(sName).cx + m );
			pColumn->EnsureWidth( pProperty->GetPreferedWidth(pDC) );
		}

		iter++;
	}

	ReleaseDC(pDC);

	//
	// calculate left of each column
	//

	RefreshColumnLefts( m_ViewportOrg.x );
	RefreshRowTops( m_ViewportOrg.y );

	//
	//
	//

	BuildPropertyMap();

	//
	//
	//

	Invalidate();

}