Example #1
0
int Cmp( const Row & r1, const Row & r2, const FieldList & fl ) {
	if ( r1.Size() <= r2.Size()  ) {
		for ( unsigned int i = 0; i < r1.Size() ; i++ ) {
			if ( fl.Size() == 0 || fl.Contains( i ) ) {
				if ( r1.At( i ) < r2.At(i) ) {
					return -1;
				}
				else if ( r1.At( i ) > r2.At(i) ) {
					return 1;
				}
			}
		}
		return r1.Size() < r2.Size() ? -1 : 0;
	}
	else {
		for ( unsigned int i = 0; i < r2.Size() ; i++ ) {
			if ( fl.Size() == 0 || fl.Contains( i ) ) {
				if ( r1.At( i ) < r2.At(i) ) {
					return -1;
				}
				else if ( r1.At( i ) > r2.At(i) ) {
					return 1;
				}
			}
		}
		return 1;
	}
}
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();

}
Example #3
0
void Generator :: DebugRow( const Row & row, std::ostream & os ) {
	for ( unsigned int i = 0; i < row.Size() ; i++ ) {
		os << "[" << (i + 1) << ":" << row.At(i) << "]";
	}
	os << std::endl;
}