void TSensorView::ColumnViewer(TDC& dc,PSHORTREAL pData)
{
  m_xSize = m_nDimSize[0];
  m_ySize = m_nDimSize[1];
  m_yAdd = (int) (500L * m_ySize / m_xSize / 2);
  dc.SetWindowExt(TSize(m_xSize * 2 +  m_ySize,500 + m_yAdd));
  Grid3D(dc);
  TBrush brGray(SYSCOLOR(COLOR_BTNFACE)),
			brWhite(SYSCOLOR(COLOR_BTNHIGHLIGHT)),
			brDark(SYSCOLOR(COLOR_BTNSHADOW));
  for (int y = 0; y < m_nDimSize[1]; y++)
    for (int x = 0; x < m_nDimSize[0]; x++)
    {
      SHORTREAL r = pData[x + (LONGINT) m_nDimSize[0] * y];
      TPoint pt[4] =
      {
        Project2D(x,y+1,r),
        Project2D(x+1,y+1,r),
        Project2D(x+1,y,r),
        Project2D(x,y,r)
      };
      dc.SelectObject(brWhite);
      POLY(dc,pt,4);
      SHORTREAL r2 = y == m_nDimSize[1]-1
                     ? 0
                     : pData[x + (LONGINT) m_nDimSize[0] * (y+1)];
      if(r2 < r)
      {
        pt[2] = Project2D(x+1,y+1,r2);
        pt[3] = Project2D(x,y+1,r2);
        dc.SelectObject(brGray);
        POLY(dc,pt,4);
      }
      r2 = x == m_nDimSize[0]-1 ? 0
                  : pData[x+1 + (LONGINT) m_nDimSize[0] * y];
      if (r2 < r)
      {
        pt[0] = Project2D(x+1,y,r);
        pt[2] = Project2D(x+1,y+1,r2);
        pt[3] = Project2D(x+1,y,r2);
        dc.SelectObject(brDark);
        POLY(dc,pt,4);
      }
    }
  dc.RestoreBrush();
}
Example #2
0
void CDockingBar::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	COLORREF rgb_background= ::GetSysColor(COLOR_APPWORKSPACE);

	CMemoryDC mem_dc(dc, this, rgb_background);
	mem_dc.SelectStockObject(DEFAULT_GUI_FONT);

	CRect rect;
	GetClientRect(rect);

	mem_dc.Draw3dRect(rect, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DHILIGHT));
	rect.DeflateRect(1, 1);
	mem_dc.Draw3dRect(rect, ::GetSysColor(COLOR_3DDKSHADOW), rgb_background);
	rect.DeflateRect(1, 0);
	rect.top++;

	const int GAP= rect.Height() / 2;
	const int ICON= 18;
	COLORREF rgb_black= ::GetSysColor(COLOR_BTNTEXT);
	COLORREF rgb_dark= ::GetSysColor(COLOR_3DDKSHADOW);
	COLORREF rgb_light= ::GetSysColor(COLOR_3DHILIGHT);
	COLORREF rgb_gray= GetLighterColor(rgb_background, 13.0); // 13.0% brighter

	CPen penBlack(PS_SOLID, 0, rgb_black);
	CPen penDark(PS_SOLID, 0, rgb_dark);
	CPen penLight(PS_SOLID, 0, rgb_light);
	CPen penGray(PS_SOLID, 0, rgb_gray);
	CBrush brGray(::GetSysColor(COLOR_3DFACE));
	CBrush* brush= mem_dc.SelectObject(&brGray);
	mem_dc.SetBkMode(OPAQUE);

	CalcWidth(tabs_, mem_dc, rect);

	for (int index= 0; index < tabs_.size(); ++index)
	{
		CTab& tab= tabs_[index];
		CRect text_rect= tab.location_rect_;
		text_rect.left += ICON;

		COLORREF rgb_tab= tab.active_ ? ::GetSysColor(COLOR_3DFACE) : rgb_background;

		if (tab.active_)		// active tab--taller, gray backgnd
		{
			CRect rect= tab.location_rect_;
			rect.top++;
			rect.right++;
			rect.bottom = rect.top + 1;
			// draw two lines on the top
			mem_dc.FillSolidRect(rect, rgb_dark);
			rect.OffsetRect(0, 1);
			mem_dc.FillSolidRect(rect, rgb_light);
			rect.top++;
			rect.bottom = tab.location_rect_.bottom + 1;
			mem_dc.FillSolidRect(rect, rgb_tab);

			text_rect.top = rect.top;

			rect.top--;
			int bottom= tab.location_rect_.bottom - 1;
			int gap= (bottom - rect.top) / 2;

			POINT vptLeftTriangle[]=
			{
				{ rect.left, rect.top }, { rect.left, bottom + 2 },
				{ rect.left - gap - 1, bottom + 2 }, { rect.left, rect.top }
			};
			mem_dc.SelectStockObject(NULL_PEN);
			mem_dc.Polygon(vptLeftTriangle, array_count(vptLeftTriangle));

			POINT vptRightTriangle[]=
			{
				{ rect.right, rect.top }, { rect.right, bottom + 2 },
				{ rect.right + gap, bottom + 2 },  { rect.right + gap, bottom },
				{ rect.right, rect.top }
			};
			mem_dc.Polygon(vptRightTriangle, array_count(vptRightTriangle));

			// draw slanted line on the right side
			CPen* pen= mem_dc.SelectObject(&penBlack);
			mem_dc.MoveTo(rect.right, rect.top);
			mem_dc.LineTo(rect.right + gap, bottom);
			mem_dc.LineTo(rect.right + gap + 1, bottom);

			// draw slanted line on the left side
			mem_dc.SelectObject(&penDark);
			int left= rect.left - 1;
			mem_dc.MoveTo(left, rect.top);
			mem_dc.LineTo(left - gap, bottom);
			mem_dc.LineTo(left - gap + 1, bottom);

			// draw light slanted line on the left side
			mem_dc.SelectObject(&penLight);
			left++;
			mem_dc.MoveTo(left, rect.top);
			mem_dc.LineTo(left - gap, bottom);
			mem_dc.LineTo(left - gap, bottom + 2);
		}
		else		// inactive tab (smaller, dark background)
		{
			CRect rect= tab.location_rect_;
			rect.left++;
			rect.right++;
			rect.top += 2;
			rect.bottom = rect.top + 1;
			// draw two lines on the top
			mem_dc.FillSolidRect(rect, rgb_dark);
			rect.OffsetRect(0, 1);
			mem_dc.FillSolidRect(rect, rgb_gray);

			// draw slanted line on the right side
			CPen* pen= mem_dc.SelectObject(&penBlack);
			int right= rect.right - 0;
			mem_dc.MoveTo(right, rect.top);
			int bottom= tab.location_rect_.bottom - 1;
			int gap= (bottom - rect.top) / 2;
			mem_dc.LineTo(right + gap, bottom + 1);

			// draw short slanted line on the left side
			mem_dc.SelectObject(&penDark);
			int left= rect.left - 1;
			mem_dc.MoveTo(left, rect.top);
			if (index == 0)	// first tab?
			{
				mem_dc.LineTo(left - gap, bottom);	// in the first tab whole edge is visible
				mem_dc.LineTo(left - gap, bottom + 1);
				// draw light slanted line on the left side
				mem_dc.SelectObject(&penGray);
				mem_dc.MoveTo(left + 1, rect.top);
				mem_dc.LineTo(left - gap + 1, bottom);
				mem_dc.LineTo(left - gap + 1, bottom + 1);
			}
			else
			{
				int left_half= left - gap / 2;
				int bottom_half= (rect.top + bottom) / 2;
				mem_dc.LineTo(left_half, bottom_half);
				mem_dc.LineTo(left_half, bottom_half + 1);
				// draw light slanted line on the left side
				mem_dc.SelectObject(&penGray);
				mem_dc.MoveTo(left + 1, rect.top);
				mem_dc.LineTo(left_half, bottom_half + 2);
				// previous tab is not active?
//				if (index > 0 && !tabs_[index - 1].active_)
//					mem_dc.LineTo(left_half, bottom_half + 3);
			}


			mem_dc.SelectObject(pen);

			text_rect.top = rect.top + 1;
		}

		mem_dc.SetBkColor(rgb_tab);
		mem_dc.DrawText(tab.name_, text_rect, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_NOPREFIX | DT_EXPANDTABS | DT_END_ELLIPSIS);

		int offset= tab.active_ ? 0 : 12;
		CPoint icon(tab.location_rect_.left + 1, text_rect.top);

		if (tab.icon_ >= 0)
			image_list_.Draw(&mem_dc, offset + tab.icon_, icon, ILD_NORMAL);
	}

	mem_dc.SelectObject(brush);

	mem_dc.BitBlt();
}