Browse Source

updated gradient drawning, change HitTest return types to LRESTULT

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@419 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 18 years ago
parent
commit
49e8ac9510
7 changed files with 19 additions and 35 deletions
  1. 13 29
      DittoWindow.cpp
  2. 1 1
      EditFrameWnd.cpp
  3. 1 1
      EditFrameWnd.h
  4. 1 1
      ToolTipEx.cpp
  5. 1 1
      ToolTipEx.h
  6. 1 1
      WndEx.cpp
  7. 1 1
      WndEx.h

+ 13 - 29
DittoWindow.cpp

@@ -227,38 +227,19 @@ void CDittoWindow::DoNcPaint(CWnd *pWnd)
 		m_crMinimizeBT.SetRectEmpty();
 	}
 
-	float gR = 0; 
-	float gG = 0; 
-	float gB = 0; 
+	int r1 = GetRValue(m_CaptionColorLeft);
+	int g1 = GetGValue(m_CaptionColorLeft);
+	int b1 = GetBValue(m_CaptionColorLeft);
 
-	float sR = GetRValue(m_CaptionColorLeft);
-	float sG = GetGValue(m_CaptionColorLeft);
-	float sB = GetBValue(m_CaptionColorLeft);
-
-	float eR = GetRValue(m_CaptionColorRight);
-	float eG = GetGValue(m_CaptionColorRight);
-	float eB = GetBValue(m_CaptionColorRight);
+	int r2 = GetRValue(m_CaptionColorRight);
+	int g2 = GetGValue(m_CaptionColorRight);
+	int b2 = GetBValue(m_CaptionColorRight);
 
 	bool bGradient = true;
 	if(m_CaptionColorLeft == m_CaptionColorRight)
 	{
-		gR = eR;
-		gG = eG;
-		gB = eB; 
 		bGradient = false;
 	}
-	else if(bVertical)
-	{
-		gR = (eR - sR) / rcBorder.Height();
-		gG = (eG - sG) / rcBorder.Height(); 
-		gB = (eB - sB) / rcBorder.Height(); 
-	}
-	else
-	{
-		gR = (eR - sR) / rcBorder.Width();
-		gG = (eG - sG) / rcBorder.Width(); 
-		gB = (eB - sB) / rcBorder.Width(); 
-	}
 
 	HBRUSH color;
 	long lHeight = rcBorder.Height();
@@ -268,7 +249,12 @@ void CDittoWindow::DoNcPaint(CWnd *pWnd)
 		lCount = lHeight;
 
 	for(int i = 0; i < lCount; i++) 
-	{ 
+	{
+		int r, g, b;
+		r = r1 + (i * (r2 - r1) / lCount);
+		g = g1 + (i * (g2 - g1) / lCount);
+		b = b1 + (i * (b2 - b1) / lCount);
+
 		if(bVertical)
 		{
 			cr.top = i;
@@ -282,9 +268,7 @@ void CDittoWindow::DoNcPaint(CWnd *pWnd)
 
 		if(bGradient || i == 0)
 		{
-			color = CreateSolidBrush(RGB(int(gR * (float) i + gR),
-				int(gG * (float) i + sG),
-				int(gB * (float) i + sB)));
+			color = CreateSolidBrush(RGB(r, g, b));
 		}
 
 		::FillRect(dc, &cr, color);

+ 1 - 1
EditFrameWnd.cpp

@@ -167,7 +167,7 @@ void CEditFrameWnd::OnNcPaint()
 	m_DittoWindow.DoNcPaint(this);	
 }
 
-UINT CEditFrameWnd::OnNcHitTest(CPoint point) 
+LRESULT CEditFrameWnd::OnNcHitTest(CPoint point) 
 {
 	UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
 	if(Ret == -1)

+ 1 - 1
EditFrameWnd.h

@@ -34,7 +34,7 @@ public:
 	afx_msg void OnDummy();
 	afx_msg void OnNcPaint();
 	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
-	afx_msg UINT OnNcHitTest(CPoint point);
+	afx_msg LRESULT OnNcHitTest(CPoint point);
 protected:
 	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 public:

+ 1 - 1
ToolTipEx.cpp

@@ -459,7 +459,7 @@ void CToolTipEx::SetToolTipText(const CString &csText)
 	m_RichEdit.SetText(csText);
 }
 
-UINT CToolTipEx::OnNcHitTest(CPoint point) 
+LRESULT CToolTipEx::OnNcHitTest(CPoint point) 
 {
 	CRect crWindow;
 	GetWindowRect(crWindow);

+ 1 - 1
ToolTipEx.h

@@ -73,7 +73,7 @@ protected:
 	//{{AFX_MSG(CToolTipEx)
 	afx_msg void OnPaint();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
-	afx_msg UINT OnNcHitTest(CPoint point);
+	afx_msg LRESULT OnNcHitTest(CPoint point);
 	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()

+ 1 - 1
WndEx.cpp

@@ -162,7 +162,7 @@ void CWndEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
 	m_DittoWindow.DoNcCalcSize(bCalcValidRects, lpncsp);
 }
 
-UINT CWndEx::OnNcHitTest(CPoint point) 
+LRESULT CWndEx::OnNcHitTest(CPoint point) 
 {
 	UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
 	if(Ret == -1)

+ 1 - 1
WndEx.h

@@ -61,7 +61,7 @@ protected:
 	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
 	afx_msg void OnNcPaint();
 	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
-	afx_msg UINT OnNcHitTest(CPoint point);
+	afx_msg LRESULT OnNcHitTest(CPoint point);
 	afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
 	afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
 	afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);