void CTreeViewListControl::GetGridElementBounds( int iColumn, int iRow, int &left, int &top, int &right, int &bottom )
{
	left = m_Columns[iColumn].m_Left;
	right = m_Columns[iColumn].m_Right;
	
	// vgui doesn't seem to be drawing things exactly right. Like it you draw a line at (0,0) to (100,0),
	// then a rectangle from (1,1) to (100,100), it'll overwrite the line at the top.
	int treeTopBorder = 0;
	IBorder *treeBorder = m_pTree->GetBorder();
	if ( treeBorder )
	{
		int l, t, r, b;
		treeBorder->GetInset( l, t, r, b );
		treeTopBorder = t;
	}
	if ( iRow == -1 )
	{
		top = 1;
		bottom = m_TitleBarHeight - 2;
	}
	else if ( m_pTree )
	{
		int x, y;
		m_pTree->GetPos( x, y );

		top = treeTopBorder + m_TitleBarHeight + ( iRow * m_pTree->GetRowHeight() );
		bottom = top + m_pTree->GetRowHeight();
	}
	else
	{
		left = top = right = bottom = 0;
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBitmapImagePanel::PaintBorder()
{
	int x, y, w, h;
	ComputeImagePosition(x, y, w, h);

	IBorder *pBorder = GetBorder();
	if ( pBorder )
		pBorder->Paint( x, y, x+w, y+h, -1, 0, 0 );
}
void CSchemeVisualizer::AddBordersToList()
{
	const int nBorderCount = m_pViewScheme->GetBorderCount();
	for ( int i = 0; i < nBorderCount; ++i )
	{
		IBorder *pCurBorder = m_pViewScheme->GetBorderAtIndex( i );
		CFmtStr fmtName( "BorderPanel_%s", pCurBorder->GetName() );
		CBorderVisualizerPanel *pNewBorderPanel = new CBorderVisualizerPanel( m_pList, fmtName.Access(), pCurBorder );
		pNewBorderPanel->SetSize( m_pList->GetWide(), YRES( 45 ) );
		m_pList->AddItem( new Label( NULL, "Label", pCurBorder->GetName() ), pNewBorderPanel );
	}
}
void CBorderVisualizerPanel::Paint()
{
	BaseClass::Paint();

	surface()->PushMakeCurrent( GetVPanel(), false );
	m_pBorder->Paint( GetVPanel() );
	surface()->PopMakeCurrent( GetVPanel() );
}
//-----------------------------------------------------------------------------
// Purpose: Paint our border specially, with the tabs in mind
//-----------------------------------------------------------------------------
void PropertySheet::PaintBorder()
{
	IBorder *border = GetBorder();
	if (!border)
		return;

	// draw the border, but with a break at the active tab
	int px = 0, py = 0, pwide = 0, ptall = 0;
	if (_activeTab)
	{
		_activeTab->GetBounds(px, py, pwide, ptall);
		ptall -= 1;
	}

	// draw the border underneath the buttons, with a break
	int wide, tall;
	GetSize(wide, tall);
	border->Paint(0, py + ptall, wide, tall, IBorder::SIDE_TOP, px + 1, px + pwide - 1);
}
//-----------------------------------------------------------------------------
// Purpose: Paints the border, but with the required breaks for the page tab
//-----------------------------------------------------------------------------
void PropertyPage::PaintBorder()
{
	IBorder *border = GetBorder();

	// setup border break
	if (_paintRaised==true && border && _pageTab.Get())
	{
		int px, py, pwide, ptall;
		_pageTab->GetBounds(px, py, pwide, ptall);
	
		int wide, tall;
		GetSize(wide, tall);
		border->Paint(0, 0, wide, tall, IBorder::SIDE_TOP, px+1, px + pwide -1);
	}
	else
	{
		// Paint the border
		BaseClass::PaintBorder();
	}
}