/************************************************
OnPaint
	Paints the corner button object. The corner button object uses a CUGCell
	located at position -1,-1 from the default datasource then uses the cell
	type associated with this cell to draw itself with.
Params:
	<none>
Return:
	<none>
*************************************************/
void CUGCnrBtn::OnPaint() 
{
	if ( m_GI->m_paintMode == FALSE )
		return;

	CPaintDC dc(this); // device context for painting

	m_ctrl->OnScreenDCSetup(&dc,NULL,UG_TOPHEADING);
	
	RECT rect;
	GetClientRect(&rect);

	CUGCellType * cellType;
	CUGCell cell;
	m_ctrl->GetCellIndirect(-1,-1,&cell);

	//get the cell type to draw the cell
	if(cell.IsPropertySet(UGCELL_CELLTYPE_SET))
		cellType = m_ctrl->GetCellType(cell.GetCellType());
	else
		cellType = m_ctrl->GetCellType(-1);
	
	CFont * pOldFont = NULL;

	// get the default font if there is one
	if( m_GI->m_defFont != NULL )
	{
		pOldFont = dc.SelectObject( ( CFont* )m_GI->m_defFont );
	}
	
	cellType->OnDraw(&dc,&rect,-1,-1,&cell,0,0);

	if( m_GI->m_defFont != NULL && pOldFont != NULL )
		dc.SelectObject( pOldFont );
}
// v7.2 - update 04 - added as a pared down version of OnPaint to handle 
//        WM_PRINT message - called from WindowProc below. TD
void CUGCnrBtn::OnPrint(CDC *dc) 
{
	
	RECT rect;
	GetClientRect(&rect);

	CUGCellType * cellType;
	CUGCell cell;
	m_ctrl->GetCellIndirect(-1,-1,&cell);

	//get the cell type to draw the cell
	if(cell.IsPropertySet(UGCELL_CELLTYPE_SET))
		cellType = m_ctrl->GetCellType(cell.GetCellType());
	else
		cellType = m_ctrl->GetCellType(-1);
	
	CFont * pOldFont = NULL;

	// get the default font if there is one
	if( m_GI->m_defFont != NULL )
	{
		pOldFont = dc->SelectObject( ( CFont* )m_GI->m_defFont );
	}
	
	cellType->OnDraw(dc,&rect,-1,-1,&cell,0,0);

	if( m_GI->m_defFont != NULL && pOldFont != NULL )
		dc->SelectObject( pOldFont );
}
Beispiel #3
0
/***************************************************
OnSetFocus
	event handler is user to initially size the edit control, and to setup
	user's selection.
Params:
	pOldWnd		- pointer to window that lost focus.
Returns:
	<none>
*****************************************************/
void CUGEdit::OnSetFocus(CWnd* pOldWnd) 
{
	//setup the autosize ability
	m_tempAutoSize = m_autoSize;
	CUGCellType* ct = m_ctrl->GetCellType(
		m_ctrl->m_editCell.GetCellType() );
	if(ct->CanOverLap(&m_ctrl->m_editCell) == FALSE)
		m_tempAutoSize = FALSE;

	//get the original height
	RECT rect;
	GetClientRect(&rect);
	m_origHeight = rect.bottom +4;
	m_currentHeight = m_origHeight;

	CalcEditRect();

	m_cancel = FALSE;
	m_continueFlag = FALSE;

	SetSel(0,-1);
	//HKL hKl = GetKeyboardLayout(0); //这里0表示当前线程,要查指定线程的话可以用指定线程的标识符代替
	//if (ImmIsIME(hKl))
	//{
	//	//ImmSimulateHotKey(this->m_hWnd,IME_CHOTKEY_IME_NONIME_TOGGLE);

	//	AfxMessageBox(_T("当前是中文输入法。"));
	//	//ActivateKeyboardLayout((HKL)HKL_NEXT,KLF_SETFORPROCESS|KLF_UNLOADPREVLOUS);//HKL_PREV
	//}
	CEdit::OnSetFocus(pOldWnd);
}
Beispiel #4
0
/***************************************************
InternPrintCell - private
	This function is called by the PrintPage function
	to setup the drawing for an individual cell.
	Once setup then the cells specified celltype is
	called to perform the actual drawing
Params
	dc - device context to draw to
	rect - rectangle to draw the cell within
	col - column of the cell to draw
	row - row of the cell to draw
****************************************************/
void CUGPrint::InternPrintCell(CDC *dc,RECT * rect,int col,long row)
{
	CUGCellType * cellType;
	CUGCell cell,cell2;
	int leftMargin = m_printLeftMarginPX;
	int topMargin =  m_printTopMarginPX;

	//TEST
	CRgn rgn;
	if(m_bIsPreview == FALSE){
		rgn.CreateRectRgn((rect->left-0) * m_virPixWidth,
			(rect->top-0) * m_virPixWidth,
			(rect->right-0) * m_virPixWidth,
			(rect->bottom-0) * m_virPixWidth);

		dc->SelectClipRgn(NULL);
		dc->SelectClipRgn(&rgn);
	}

	if ( col < 0 && row < 0 )
	{
		rect->top = topMargin;
		rect->left = leftMargin;
		rect->right = (int)(leftMargin + (m_GI->m_sideHdgWidth * m_printHScale));
		rect->bottom = (int)(topMargin + (m_GI->m_topHdgHeight * m_printVScale)) - 1;

		col = -1;
		row = -1;
	}

	//get the cell information
	m_ctrl->GetCellIndirect(col,row,&cell);

	//get the cell type to draw the cell
	if(cell.IsPropertySet(UGCELL_CELLTYPE_SET))
		cellType = m_ctrl->GetCellType(cell.GetCellType());
	else
		cellType = m_ctrl->GetCellType(-1);

	//paint the cell
	int saveID = dc->SaveDC();
	cellType->OnPrint(dc,rect,col,row,&cell);
	dc->RestoreDC(saveID);

	//TEST
	if(m_bIsPreview == FALSE){
		dc->SelectClipRgn(NULL);
	}
}
Beispiel #5
0
/***************************************************
DrawCellsIntern
	function is the key to the fast redraw functionality in the Ultimate Grid.
	This function is responsible for drawing cells within the grid area, it
	makes sure that only the cells that are marked as invalid
	(by calling CUGDrawHint::IsInvalid function) are redrawn.
Params:
	dc		- screen DC
	db_dc	- off-screen DC, used when double buffering is enabled.
Returns:
	<none>
*****************************************************/
void CUGGrid::DrawCellsIntern(CDC *dc,CDC *db_dc)
{
	RECT		rect = {0,0,0,0};
	RECT		cellRect;
	RECT		tempRect;
	
	CUGCell		cell,tempCell;
	CString		string;
	CSize		size;

	RECT		focusRect = {-1,-1,-1,-1};
	CUGCellType * cellType;

	int			rightBlank	= -1;
	int			bottomBlank = -1;

	int			col,x;
	long		row,y;

	int			selectBlock;

	int			dcID;
	CDC*		origDC = dc;

	//double buffering
	if(m_doubleBufferMode)
	{
		origDC = dc;
		dc =  db_dc;
		//get the default font to use
		if(m_GI->m_defFont != NULL){
			origDC->SelectObject(m_GI->m_defFont);
			dc->SelectObject(m_GI->m_defFont);
		}
	}
	else{
		//get the default font to use
		if(m_GI->m_defFont != NULL){
			dc->SelectObject(m_GI->m_defFont);
		}
	}
	
	m_ctrl->OnScreenDCSetup(origDC,db_dc,UG_GRID);
	
	//set the right and bottom vars to point to
	//the extremes, if the right or bottom is
	//sooner then they will be updated in the
	//main drawing loop
	m_GI->m_rightCol = m_GI->m_numberCols;
	m_GI->m_bottomRow = m_GI->m_numberRows;
	
	//main draw loop, this loop goes through all visible
	//cells and checks to see if they need redrawing
	//if they do then the cell is retrieved and drawn
	for(y = 0; y < m_GI->m_numberRows;y++)
	{
		//skip rows hidden under locked rows
		if(y == m_GI->m_numLockRows)
			y = m_GI->m_topRow;

		row = y;

		//calc the top bottom and right side of the rect 
		//for the current cell to be drawn
		rect.top = rect.bottom;

		if(m_GI->m_uniformRowHeightFlag)
			rect.bottom += m_GI->m_defRowHeight;
		else
			rect.bottom += m_GI->m_rowHeights[row];

		if(rect.top == rect.bottom)
			continue;

		rect.right = 0;

		//check all visible cells in the current row to 
		//see if they need drawing
		for(x = 0;x < m_GI->m_numberCols;x++){

			//skip cols hidden under locked cols
			if(x == m_GI->m_numLockCols)
				x = m_GI->m_leftCol;

			row = y;
			col = x;

			//calc the left and right side of the rect
			rect.left = rect.right;
			rect.right  += m_GI->m_colInfo[col].width;

			if(rect.left == rect.right)
				continue;

			//check to see if the cell need to be redrawn
			if(m_drawHint.IsInvalid(col,row) != FALSE){
	
				//copy the rect, then use the cellRect from here
				//this is done since the cellRect may be modified
				CopyRect(&cellRect,&rect);

				//get the cell to draw
				m_ctrl->GetCellIndirect(col,row,&cell);

				//check to see if the cell is joined
				if(cell.IsPropertySet(UGCELL_JOIN_SET)){
					m_ctrl->GetCellRect(col,row,&cellRect);
					m_ctrl->GetJoinStartCell(&col,&row,&cell);
					if(m_drawHint.IsValid(col,row))
						continue;
					m_drawHint.SetAsValid(col,row);
				}

				//get the cell type to draw the cell
				if(cell.IsPropertySet(UGCELL_CELLTYPE_SET)){
					cellType = m_ctrl->GetCellType(cell.GetCellType());
				}
				else
				{
					cellType = m_ctrl->GetCellType(-1);
				}


				dcID = dc->SaveDC();

				//draw the cell, check to see if it is 'current' and/or selected
				CopyRect(&tempRect,&cellRect);
				if(row == m_GI->m_currentRow && ( col == m_GI->m_currentCol || m_GI->m_highlightRowFlag))
					cellType->OnDraw(dc,&cellRect,col,row,&cell,0,1);
				else{
					if(m_GI->m_multiSelect->IsSelected(col,row,&selectBlock))
						cellType->OnDraw(dc,&cellRect,col,row,&cell,selectBlock+1,0);
					else
						cellType->OnDraw(dc,&cellRect,col,row,&cell,0,0);
				}
				CopyRect(&cellRect,&tempRect);

				//draw a black line at the right edge of the locked columns
				if(m_GI->m_numLockCols >0){
					if(col == m_GI->m_leftCol){
						dc->SelectObject(GetStockObject(BLACK_PEN));
						dc->MoveTo(cellRect.left-1,cellRect.top);
						dc->LineTo(cellRect.left-1,cellRect.bottom+1);
					}
					else if(col == m_GI->m_numLockCols-1){
						dc->SelectObject(GetStockObject(BLACK_PEN));
						dc->MoveTo(cellRect.right-1,cellRect.top);
						dc->LineTo(cellRect.right-1,cellRect.bottom+1);
					}
				}
				//draw a black line at the bottom of the locked rows
				if(m_GI->m_numLockRows >0){
					if(row == m_GI->m_topRow ){
						dc->SelectObject(GetStockObject(BLACK_PEN));
						dc->MoveTo(cellRect.left,cellRect.top-1);
						dc->LineTo(cellRect.right+1,cellRect.top-1);
					}
					else if(row == m_GI->m_numLockRows-1){
						dc->SelectObject(GetStockObject(BLACK_PEN));
						dc->MoveTo(cellRect.left,cellRect.bottom-1);
						dc->LineTo(cellRect.right+1,cellRect.bottom-1);
					}
				}

				dc->RestoreDC(dcID);
			}

			//check to see if the focus rect should be drawn
			//this function should be called all the time
			//even if it is off screen
			if(row == m_GI->m_currentRow && (col == m_GI->m_currentCol || 
				m_GI->m_highlightRowFlag)){
				CopyRect(&focusRect,&cellRect);
			}

			//check to see if the right side of the rect is past the edge
			//of the grid drawing area, if so then break
			if(rect.right > m_GI->m_gridWidth){
				m_GI->m_rightCol = col;
				break;
			}
		
		}

		//check to see if there is blank space on the right side of the grid
		//drawing area
		if(rect.right < m_GI->m_gridWidth && m_GI->m_rightCol == m_GI->m_numberCols){
			rightBlank = rect.right;
		}

		//check to see if the bottom of the rect is past the bottom of the 
		//grid drawing area, if so then break
		if(rect.bottom > m_GI->m_gridHeight){
			m_GI->m_bottomRow = row;
			break;
		}

		//check for extra rows
		if(y >= (m_GI->m_numberRows-1)){
			long origNumRows = m_GI->m_numberRows;
			long newRow = y+1;
			m_ctrl->VerifyCurrentRow(&newRow);
			if(m_GI->m_numberRows > origNumRows){
				m_drawHint.AddHint(0,y+1,m_GI->m_numberCols-1,y+1);
			}
		}
	}

	//clear the draw hints
	m_drawHint.ClearHints();

	//check to see if there is blank space on the bottom of the grid
	//drawing area
	if(rect.bottom < m_GI->m_gridHeight && m_GI->m_bottomRow == m_GI->m_numberRows)
		bottomBlank = rect.bottom;
	
	//fill in the blank grid drawing areas
	if(rightBlank >=0 || bottomBlank >=0){
		CBrush brush(m_ctrl->OnGetDefBackColor(UG_GRID));
		GetClientRect(&rect);
		if(rightBlank >=0){
			rect.left = rightBlank;
			dc->FillRect(&rect,&brush);
		}
		if(bottomBlank >=0){
			rect.left = 0;
			rect.top = bottomBlank;
			dc->FillRect(&rect,&brush);
		}
	}

	//double buffering
	if(m_doubleBufferMode){
		dc = origDC;
		dc->BitBlt(0,0,m_GI->m_gridWidth,m_GI->m_gridHeight,db_dc,0,0,SRCCOPY);
	}	
	
	//draw the focus rect, if the flag was set above
	if(!m_tempDisableFocusRect){
		if((m_hasFocus || m_ctrl->m_findDialogRunning) && !m_ctrl->m_editInProgress)		
		{
			if(m_GI->m_highlightRowFlag)
			{
				focusRect.left = 0;

				if(rect.right < m_GI->m_gridWidth)
					focusRect.right = rect.right;
				else
				{
					if( m_GI->m_bExtend )
						focusRect.right = m_GI->m_gridWidth;
					else
					{
						int iStartCol = m_ctrl->GetLeftCol(), iEndCol = m_ctrl->GetNumberCols() - 1;
						int iWidth = 0;
						for( int iLoop = iStartCol ; iLoop <= iEndCol ; iLoop++ )
							iWidth += m_ctrl->GetColWidth( iLoop );

						focusRect.right = iWidth;
					}
				}
			}
			m_ctrl->OnDrawFocusRect(dc,&focusRect);
		}
	}

	//reset temporary flags
	m_tempDisableFocusRect = FALSE;
}
Beispiel #6
0
/***************************************************
DrawCellsIntern
	function is the key to the fast redraw functionality in the Ultimate Grid.
	This function is responsible for drawing cells within the grid area, it
	makes sure that only the cells that are marked as invalid
	(by calling CUGDrawHint::IsInvalid function) are redrawn.
Params:
	dc		- pointer DC to draw on
Returns:
	<none>
*****************************************************/
void CUGTopHdg::DrawCellsIntern(CDC *dc)
{	
	CRect rect(0,0,0,0), cellRect;
  	CUGCell cell;
	CUGCellType * cellType;
	int dcID;
	int xIndex,col;
	long yIndex,row;
	
	m_ctrl->OnScreenDCSetup(dc,NULL,UG_TOPHEADING);
	
	//set the default font
	if(m_GI->m_defFont != NULL)
		dc->SelectObject((CFont *) m_GI->m_defFont);

	int blankRight = 0;

	for(yIndex = (m_GI->m_numberTopHdgRows * -1); yIndex < 0 ; yIndex++)
	{
		row = yIndex;
	
		for(xIndex = 0;xIndex < m_GI->m_numberCols;xIndex++)
		{
			if(xIndex == m_GI->m_numLockCols)
				xIndex = m_GI->m_leftCol;
			col = xIndex;
			row = yIndex;
	
			//draw if invalid
			if(m_drawHint.IsInvalid(col,row) != FALSE)
			{
				GetCellRect(col,row,&rect);
				CopyRect(&cellRect,&rect);

				m_ctrl->GetCellIndirect(col,row,&cell);

				if(cell.IsPropertySet(UGCELL_JOIN_SET))
				{
					GetCellRect(col,row,&cellRect);
					m_ctrl->GetJoinStartCell(&col,&row,&cell);
					if(m_drawHint.IsValid(col,row))
						continue;
					m_drawHint.SetAsValid(col,row);
				}
					
				if(cellRect.left < cellRect.right)
				{
					cellType = m_ctrl->GetCellType(cell.GetCellType());

					dcID = dc->SaveDC();
					
					if(m_swapEndCol >=0 && col == m_swapStartCol)
						cellType->OnDraw(dc,&cellRect,col,row,&cell,1,0);
					else
						cellType->OnDraw(dc,&cellRect,col,row,&cell,0,0);

					dc->RestoreDC(dcID);
				}
			}
			if(rect.right > m_GI->m_gridWidth)
				break;
		}
		if(blankRight < rect.right)
			blankRight = rect.right;
	}
	if(blankRight < m_GI->m_gridWidth)
	{
		rect.top = 0;
		rect.bottom = m_GI->m_topHdgHeight;
		rect.left = blankRight;
		rect.right = m_GI->m_gridWidth;
		// fill-in the area that is not covered by cells
		CBrush brush( m_ctrl->OnGetDefBackColor( UG_TOPHEADING ));
		dc->FillRect( rect, &brush );
	}
}