//****************************************************************************************
void CCxNDArrayDimGrid::DrawHeaderPart (CDC* pDC, const CBCGPGridHeaderParams& params)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pDC);

	CRect rcCell = params.m_rect;

//	if (!visualManager->DrawHeaderPart (pDC, params))
	{
		switch (params.m_nHeaderPart)
		{
			//表头区域
		case CBCGPGridHeaderParams::HeaderTop:
			//if (params.m_nColumn != -1)
			{
				CBCGPGridColors::ColorData colorData = 
					params.IsSelected () && m_ColorData.m_HeaderSelColors.m_clrBackground != -1 ? 
						m_ColorData.m_HeaderSelColors :
						m_ColorData.m_HeaderColors;

				if (!colorData.Draw (pDC, rcCell))
				{
					m_bHeaderItemHovered = params.IsHighlighted ();
					GetColumnsInfo ().m_bInvertPressedColumn = 
						visualManager->OnDrawGridHeaderItemBorder (this, pDC, rcCell, params.IsPressed ());
				}

				//rcCell.top -= 1;
				//rcCell.left -= 1;
				//pDC->Draw3dRect (rcCell, g_crNDArrayHeaderBorder, g_crNDArrayHeaderBorder);

				{
					CPen pen (PS_SOLID, 1, g_crNDArrayHeaderBorder);
					CPen* pOldPen = pDC->SelectObject (&pen);
					//下
					pDC->MoveTo ( rcCell.left, rcCell.bottom - 1 );
					pDC->LineTo ( rcCell.right, rcCell.bottom - 1 );
					//右
					pDC->MoveTo ( rcCell.right - 1, rcCell.top );
					pDC->LineTo ( rcCell.right - 1, rcCell.bottom );
					pDC->SelectObject (pOldPen);
				}
			}
			break;
			//左侧行编号区域
		case CBCGPGridHeaderParams::HeaderLeft:
			{
				CBCGPGridColors::ColorData colorData = 
					params.IsSelected () && m_ColorData.m_HeaderSelColors.m_clrBackground != -1 ? 
						m_ColorData.m_HeaderSelColors :
						m_ColorData.m_HeaderColors;
				
				rcCell.top += 1;
				if (!colorData.Draw (pDC, rcCell))
				{
					m_bHeaderItemHovered = params.IsHighlighted ();
					GetColumnsInfo ().m_bInvertPressedColumn = 
						visualManager->OnDrawGridRowHeaderItemBorder (this, pDC, rcCell, params.IsPressed ());
				}

				if (m_bLineNumbers && params.m_pRow != NULL)
				{
					m_bHeaderItemHovered = params.IsHighlighted ();
					OnDrawLineNumber (pDC, params.m_pRow, rcCell, params.IsSelected (), params.IsPressed ());
				}
			}
			break;
			//行编号矩形区域、表头矩形区域 交叉的 矩形区域。
		case CBCGPGridHeaderParams::HeaderTopLeft:
			//----------------------
			// Draw Select All area:
			//----------------------
			{
				CBCGPGridColors::ColorData colorData = 
					params.IsSelected () && m_ColorData.m_HeaderSelColors.m_clrBackground != -1 ? 
						m_ColorData.m_HeaderSelColors :
						m_ColorData.m_HeaderColors;

				if (!colorData.Draw (pDC, rcCell))
				{
					m_bHeaderItemHovered = params.IsHighlighted ();
					GetColumnsInfo ().m_bInvertPressedColumn = 
						visualManager->OnDrawGridSelectAllAreaBorder (this, pDC, rcCell, params.IsPressed ());
				}
			}
			break;
		}
	}
}
void CSynBCGPEditCtrl::OnDrawLineNumbersBar( CDC* pDC, CRect rect )
{
	ASSERT_VALID (pDC);

	pDC->FillSolidRect (rect, m_clrBackLineNumber);

	// Draw dividing line:
	rect.DeflateRect (0, 0, 1, 0);

	WORD wHatchBits1 [8] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00 };
	WORD wHatchBits2 [8] = { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF };

	CBitmap bmpPattern;
	bmpPattern.CreateBitmap (8, 8, 1, 1, 
		(rect.top % 2) ? wHatchBits1 : wHatchBits2);

	CBrush br;
	br.CreatePatternBrush (&bmpPattern);

	CRect rectLine = rect;
	rectLine.left = rectLine.right - 1;

	COLORREF clrTextOld = pDC->SetTextColor (m_clrBackSidebar);

	pDC->FillRect (rectLine, &br);
	pDC->SetTextColor (clrTextOld);

	rect.DeflateRect (0, 0, 1, 0);

	// Determine start and end offsets of the visible part of buffer
	CPoint ptTopLeft (m_rectText.left + 1, m_rectText.top);
	CPoint ptBottomRight (m_rectText.right - 1, m_rectText.bottom - 1);

	int nStartOffset = HitTest (ptTopLeft);
	int nEndOffset = HitTest (ptBottomRight);

	if (nStartOffset == -1)
	{
		nStartOffset = 0;
	}

	if (nEndOffset == -1)
	{
		nEndOffset = m_strBuffer.GetLength () - 1;
	}

	nEndOffset = min (nEndOffset, m_strBuffer.GetLength ());

	int nRowColumnTop = RowFromOffset (nStartOffset);
	int nRowColumnBottom = RowFromOffset (nEndOffset);

	// Draw line numbers:
	int nRow = nRowColumnTop;
	int nVirtualRow = GetVirtualRow (nRow);
	int nRowStartOffset = nStartOffset;

	while (nRow <= nRowColumnBottom && nRowStartOffset >= 0)
	{
		CRect rect (rect);
		rect.top = (nVirtualRow - m_nScrollOffsetVert) * m_nLineHeight;
		rect.bottom = rect.top + m_nLineHeight;
		OnDrawLineNumber (pDC, rect, nRow);

		NextRow (nRow, nVirtualRow, nRowStartOffset);
	}
}