Пример #1
0
/***************************************************
GetJoinRange
	function returns join information related to the cell specified
	in the col and row parameters.  These parameters might be changed
	to represent starting col, row position of the join.
Params:
	col, row	- identify the cell to retrieve join information on,
				  these parameters will represent the starting pos
				  of the join.
	endCol,		- will be set to the end col, row position of the
	endRow		  join.
Returns:
	UG_SUCCESS	- on success
	UG_ERROR	- if joins are disabled, or cell specified is not part of a join
*****************************************************/
int CUGTopHdg::GetJoinRange(int *col,int *row,int *endCol,int *endRow)
{
	if(m_GI->m_enableJoins == FALSE)
		return UG_ERROR;

	int startCol;
	long startRow, joinRow;
	BOOL origin;
	CUGCell cell;

	m_ctrl->GetCellIndirect(*col,*row,&cell);
	if(cell.IsPropertySet(UGCELL_JOIN_SET) == FALSE)
		return UG_ERROR;

	cell.GetJoinInfo(&origin,&startCol,&startRow);
	if(!origin)
	{
		*col += startCol;
		*row += (int)startRow;
		m_ctrl->GetCellIndirect(*col,*row,&cell);
	}

	cell.GetJoinInfo(&origin,endCol,&joinRow);
	*endCol +=*col;
	*endRow = joinRow + *row;

	return UG_SUCCESS;
}
Пример #2
0
/***************************************************
OnPaint
	This routine is responsible for gathering the
	information to draw, get the selected state
	plus draw in an optomized fashion
Params:
	<none>
Returns:
	<none>
*****************************************************/
void CUGGrid::OnPaint() 
{
	if ( m_GI->m_paintMode == FALSE )
		return;

	CClientDC dc(this);
	//redraw the cells in any invalid region
	CRect clipRect;

	if ( GetUpdateRect( clipRect ) == 0 )
		return;

	ValidateRect( NULL );

	//if( dc.GetClipBox( clipRect ) != NULLREGION )
	if ( clipRect.left == 0 && clipRect.right == 0 &&
		 clipRect.top == 0 && clipRect.bottom == 0 )
	{
		// redraw all cells in the grid.
		m_drawHint.AddHint(0,0,m_GI->m_numberCols,m_GI->m_numberRows);
	}
	else
	{
		int startCol	= 0,
			endCol		= m_GI->m_numberCols;
		long startRow	= 0,
			 endRow		= m_GI->m_numberRows;
		// determine the top-left and bottom-right cells of the clip rectangle
		m_ctrl->GetCellFromPoint( clipRect.left, clipRect.top, &startCol, &startRow );
		m_ctrl->GetCellFromPoint( clipRect.right, clipRect.bottom, &endCol, &endRow );
		// if the bottom right cell in the range is part of a join,
		// than get information on 'join end' cell.
		CUGCell cell;
		m_ctrl->GetCell( endCol, endRow, &cell );
		BOOL bOrigin;
		int stCol;
		long stRow;
		if ( cell.GetJoinInfo( &bOrigin, &stCol, &stRow ) == UG_SUCCESS )
		{
			endCol = endCol + stCol;
			endRow = endRow + stRow;
		}

		// redraw the region of cells that are affected by the invalid rect
		m_drawHint.AddHint( startCol, startRow, endCol, endRow );

		// if the current cell is not part of the clip region,
		// add the current cell to the draw hints
		if (!(startCol >= m_ctrl->GetCurrentCol() && endCol <= m_ctrl->GetCurrentCol() &&
			 startRow >= m_ctrl->GetCurrentRow() && endRow <= m_ctrl->GetCurrentRow()))
		{	
			if ( m_GI->m_highlightRowFlag == FALSE )
				m_drawHint.AddHint( m_ctrl->GetCurrentCol(), m_ctrl->GetCurrentRow());
			else
				m_drawHint.AddHint( 0, m_ctrl->GetCurrentRow(), m_GI->m_numberCols, m_ctrl->GetCurrentRow());
		}
	}

	//double buffering
	CDC * db_dc = NULL;
	if(m_doubleBufferMode)
	{
		db_dc = new CDC;
		db_dc->CreateCompatibleDC(NULL);
		db_dc->SelectObject(m_bitmap);
	}
	
	DrawCellsIntern(&dc,db_dc);
	m_drawHint.ClearHints();

	if(db_dc!= NULL)
		delete db_dc;
}