Browse Source

changed tooltip description window to look like ditto window and allow moving

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@681 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 12 years ago
parent
commit
f91eb6a100
12 changed files with 137 additions and 132 deletions
  1. 13 14
      CP_Main.rc
  2. 7 7
      CP_Main.vcxproj
  3. 4 0
      CP_Main.vcxproj.filters
  4. 11 39
      DittoWindow.cpp
  5. 3 1
      DittoWindow.h
  6. 18 20
      Resource.h
  7. 74 51
      ToolTipEx.cpp
  8. 7 0
      ToolTipEx.h
  9. BIN
      res/maximize_10_10.png
  10. BIN
      res/maximize_12_12.png
  11. BIN
      res/maximize_16_16.png
  12. BIN
      res/maximize_8_8.png

+ 13 - 14
CP_Main.rc

@@ -966,30 +966,29 @@ IDB_LEFT_ARROW_20_20    PNG                     "res\\left_arrow_20_20.png"
 IDB_LEFT_ARROW_24_24    PNG                     "res\\left_arrow_24_24.png"
 IDB_LEFT_ARROW_32_32    PNG                     "res\\left_arrow_32_32.png"
 IDB_CLOSE_8_8           PNG                     "res\\close_8_8.png"
-
 IDB_CLOSE_10_10         PNG                     "res\\close_10_10.png"
 IDB_CLOSE_12_13         PNG                     "res\\close_12_12.png"
 IDB_CLOSE_16_16         PNG                     "res\\close_16_16.png"
-
 IDB_CHEVRON_RIGHT_8_8   PNG                     "res\\chevron_right_8_8.png"
 IDB_CHEVRON_RIGHT_10_10 PNG                     "res\\chevron_right_10_10.png"
 IDB_CHEVRON_RIGHT_12_12 PNG                     "res\\chevron_right_12_12.png"
 IDB_CHEVRON_RIGHT_16_16 PNG                     "res\\chevron_right_16_16.png"
-
-IDB_CHEVRON_LEFT_8_8   PNG                     "res\\chevron_left_8_8.png"
-IDB_CHEVRON_LEFT_10_10 PNG                     "res\\chevron_left_10_10.png"
-IDB_CHEVRON_LEFT_12_12 PNG                     "res\\chevron_left_12_12.png"
-IDB_CHEVRON_LEFT_16_16 PNG                     "res\\chevron_left_16_16.png"
-
-IDB_CHEVRON_TOP_8_8   PNG                     "res\\chevron_top_8_8.png"
-IDB_CHEVRON_TOP_10_10 PNG                     "res\\chevron_top_10_10.png"
-IDB_CHEVRON_TOP_12_12 PNG                     "res\\chevron_top_12_12.png"
-IDB_CHEVRON_TOP_16_16 PNG                     "res\\chevron_top_16_16.png"
-
-IDB_CHEVRON_BOTTOM_8_8   PNG                     "res\\chevron_bottom_8_8.png"
+IDB_CHEVRON_LEFT_8_8    PNG                     "res\\chevron_left_8_8.png"
+IDB_CHEVRON_LEFT_10_10  PNG                     "res\\chevron_left_10_10.png"
+IDB_CHEVRON_LEFT_12_12  PNG                     "res\\chevron_left_12_12.png"
+IDB_CHEVRON_LEFT_16_16  PNG                     "res\\chevron_left_16_16.png"
+IDB_CHEVRON_TOP_8_8     PNG                     "res\\chevron_top_8_8.png"
+IDB_CHEVRON_TOP_10_10   PNG                     "res\\chevron_top_10_10.png"
+IDB_CHEVRON_TOP_12_12   PNG                     "res\\chevron_top_12_12.png"
+IDB_CHEVRON_TOP_16_16   PNG                     "res\\chevron_top_16_16.png"
+IDB_CHEVRON_BOTTOM_8_8  PNG                     "res\\chevron_bottom_8_8.png"
 IDB_CHEVRON_BOTTOM_10_10 PNG                     "res\\chevron_bottom_10_10.png"
 IDB_CHEVRON_BOTTOM_12_12 PNG                     "res\\chevron_bottom_12_12.png"
 IDB_CHEVRON_BOTTOM_16_16 PNG                     "res\\chevron_bottom_16_16.png"
+IDB_MAXIMIZE_8_8        PNG                     "res\\maximize_8_8.png"
+IDB_MAXIMIZE_10_10      PNG                     "res\\maximize_10_10.png"
+IDB_MAXIMIZE_12_12      PNG                     "res\\maximize_12_12.png"
+IDB_MAXIMIZE_16_16      PNG                     "res\\maximize_16_16.png"
 
 /////////////////////////////////////////////////////////////////////////////
 //

+ 7 - 7
CP_Main.vcxproj

@@ -1895,22 +1895,18 @@
     <None Include="res\chevron_right_10_10.png" />
     <None Include="res\chevron_right_12_12.png" />
     <None Include="res\chevron_right_8_8.png" />
-	
-	<None Include="res\chevron_left_16_16.png" />
+    <None Include="res\chevron_left_16_16.png" />
     <None Include="res\chevron_left_10_10.png" />
     <None Include="res\chevron_left_12_12.png" />
     <None Include="res\chevron_left_8_8.png" />
-	
-	<None Include="res\chevron_top_16_16.png" />
+    <None Include="res\chevron_top_16_16.png" />
     <None Include="res\chevron_top_10_10.png" />
     <None Include="res\chevron_top_12_12.png" />
     <None Include="res\chevron_top_8_8.png" />
-	
-	<None Include="res\chevron_bottom_16_16.png" />
+    <None Include="res\chevron_bottom_16_16.png" />
     <None Include="res\chevron_bottom_10_10.png" />
     <None Include="res\chevron_bottom_12_12.png" />
     <None Include="res\chevron_bottom_8_8.png" />
-	
     <None Include="res\closed_f.bmp" />
     <None Include="res\close_10_10.png" />
     <None Include="res\close_12_12.png" />
@@ -1935,6 +1931,10 @@
     <None Include="res\left_arrow_24_24.png" />
     <None Include="res\left_arrow_32_32.png" />
     <None Include="res\mainfram.bmp" />
+    <None Include="res\maximize_10_10.png" />
+    <None Include="res\maximize_12_12.png" />
+    <None Include="res\maximize_16_16.png" />
+    <None Include="res\maximize_8_8.png" />
     <None Include="res\opened_folder_16_16.png" />
     <None Include="res\opened_folder_20_20.png" />
     <None Include="res\opened_folder_24_24.png" />

+ 4 - 0
CP_Main.vcxproj.filters

@@ -930,6 +930,10 @@
     <None Include="res\opened_folder_32_32.png">
       <Filter>res</Filter>
     </None>
+    <None Include="res\maximize_8_8.png" />
+    <None Include="res\maximize_10_10.png" />
+    <None Include="res\maximize_12_12.png" />
+    <None Include="res\maximize_16_16.png" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="sqlite">

+ 11 - 39
DittoWindow.cpp

@@ -31,6 +31,7 @@ CDittoWindow::CDittoWindow(void)
 	m_CaptionColorLeft = RGB(0, 84, 230);
 	m_CaptionColorRight = RGB(61, 149, 255);
 	m_CaptionTextColor = RGB(255, 255, 255);
+	m_sendWMClose = true;
 }
 
 CDittoWindow::~CDittoWindow(void)
@@ -52,6 +53,7 @@ void CDittoWindow::DoCreate(CWnd *pWnd)
 	m_chevronLeftButton.LoadStdImageDPI(IDB_CHEVRON_LEFT_8_8, IDB_CHEVRON_LEFT_10_10, IDB_CHEVRON_LEFT_12_12, IDB_CHEVRON_LEFT_16_16, _T("PNG"));
 	m_chevronTopButton.LoadStdImageDPI(IDB_CHEVRON_TOP_8_8, IDB_CHEVRON_TOP_10_10, IDB_CHEVRON_TOP_12_12, IDB_CHEVRON_TOP_16_16, _T("PNG"));
 	m_chevronBottomButton.LoadStdImageDPI(IDB_CHEVRON_BOTTOM_8_8, IDB_CHEVRON_BOTTOM_10_10, IDB_CHEVRON_BOTTOM_12_12, IDB_CHEVRON_BOTTOM_16_16, _T("PNG"));
+	m_maximizeButton.LoadStdImageDPI(IDB_MAXIMIZE_8_8, IDB_MAXIMIZE_10_10, IDB_MAXIMIZE_12_12, IDB_MAXIMIZE_16_16, _T("PNG"));
 }
 
 void CDittoWindow::DoNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
@@ -344,7 +346,7 @@ void CDittoWindow::DoNcPaint(CWnd *pWnd)
 
 	DrawCloseBtn(dc, pWnd);
 	DrawChevronBtn(dc, pWnd);
-	DrawMaximizeBtn(dc);
+	DrawMaximizeBtn(dc, pWnd);
 	DrawMinimizeBtn(dc);
 
 	dc.SelectObject(pOldFont);
@@ -491,47 +493,14 @@ void CDittoWindow::DrawMinimizeBtn(CWindowDC &dc)
 	}
 }
 
-void CDittoWindow::DrawMaximizeBtn(CWindowDC &dc)
+void CDittoWindow::DrawMaximizeBtn(CWindowDC &dc, CWnd *pWnd)
 {
 	if(m_bDrawMaximize == false)
 	{
 		return;
 	}
 
-	//rows first then columns
-	int Points[6][7] =
-	{
-			0,0,1,1,1,1,1,
-			1,1,1,1,1,1,1,
-			1,0,0,0,0,1,1,
-			1,0,0,0,0,1,1,
-			1,0,0,0,0,1,0,
-			1,1,1,1,1,1,0,
-	};
-
-	CPoint ptShift = m_crMaximizeBT.TopLeft();
-	ptShift.Offset(3, 3);
-
-	if(m_bMouseDownOnMaximize)
-	{
-		dc.Draw3dRect(m_crMaximizeBT, RGB(255, 255, 255), RGB(255, 255, 255));
-		CRect cr(m_crMaximizeBT);
-		cr.DeflateRect(1, 1, 1, 1);
-		dc.Draw3dRect(cr, RGB(255, 255, 255), RGB(255, 255, 255));
-	}
-	else if(m_bMouseOverMaximize)
-	{
-		dc.Draw3dRect(m_crMaximizeBT, RGB(255, 255, 255), RGB(255, 255, 255));
-	}
-
-	for (int iRow = 0; iRow < 6; iRow++)
-	{
-		for (int iCol = 0; iCol < 7; iCol++)
-		{
-			if (Points[iRow][iCol] == 1)
-				dc.SetPixel(ptShift+CPoint(iCol, iRow), RGB(255, 255, 255));
-		}
-	}
+	m_maximizeButton.Draw(&dc, pWnd, m_crMaximizeBT.left, m_crMaximizeBT.top, m_bMouseOverMaximize, m_bMouseDownOnMaximize);
 }
 
 void CDittoWindow::DoNcLButtonDown(CWnd *pWnd, UINT nHitTest, CPoint point) 
@@ -569,7 +538,7 @@ void CDittoWindow::DoNcLButtonDown(CWnd *pWnd, UINT nHitTest, CPoint point)
 		pWnd->SetCapture();
 		m_bMouseDownOnMaximize = true;
 		CWindowDC dc(pWnd);
-		DrawMaximizeBtn(dc);
+		DrawMaximizeBtn(dc, pWnd);
 	}
 	else if(m_bMinimized)
 	{
@@ -593,7 +562,10 @@ long CDittoWindow::DoNcLButtonUp(CWnd *pWnd, UINT nHitTest, CPoint point)
 		clPoint.y += m_lTopBorder;
 		if(m_crCloseBT.PtInRect(clPoint))
 		{
-			pWnd->SendMessage(WM_CLOSE, 0, 0);
+			if(m_sendWMClose)
+			{
+				pWnd->SendMessage(WM_CLOSE, 0, 0);
+			}
 			lRet = BUTTON_CLOSE;
 		}
 	}
@@ -704,7 +676,7 @@ void CDittoWindow::DoNcMouseMove(CWnd *pWnd, UINT nHitTest, CPoint point)
 	{
 		m_bMouseOverMaximize = true;
 		CWindowDC dc(pWnd);
-		DrawMaximizeBtn(dc);
+		DrawMaximizeBtn(dc, pWnd);
 	}
 	else if(m_bMouseOverMaximize)
 	{

+ 3 - 1
DittoWindow.h

@@ -18,7 +18,7 @@ public:
 	void DoNcPaint(CWnd *pWnd);
 	void DrawChevronBtn(CWindowDC &dc, CWnd *pWnd);
 	void DrawCloseBtn(CWindowDC &dc, CWnd *pWnd);
-	void DrawMaximizeBtn(CWindowDC &dc);
+	void DrawMaximizeBtn(CWindowDC &dc, CWnd *pWnd);
 	void DrawMinimizeBtn(CWindowDC &dc);
 
 	void DoCreate(CWnd *pWnd);
@@ -39,6 +39,7 @@ public:
 	long m_lLeftBorder;
 
 	bool m_bDrawClose;
+	bool m_sendWMClose;
 	bool m_bDrawChevron;
 	bool m_bDrawMaximize;
 	bool m_bDrawMinimize;
@@ -72,4 +73,5 @@ public:
 	CGdiImageDrawer m_chevronLeftButton;
 	CGdiImageDrawer m_chevronTopButton;
 	CGdiImageDrawer m_chevronBottomButton;
+	CGdiImageDrawer m_maximizeButton;
 };

+ 18 - 20
Resource.h

@@ -61,34 +61,32 @@
 #define IDB_LEFT_ARROW_32_32            196
 #define IDB_CLOSE_12_12                 197
 #define IDB_CLOSE_8_8                   197
-
+#define IDB_CHEVRON_RIGHT_8_8           198
 #define IDB_CLOSE_10_10                 199
 #define IDB_CLOSE_12_13                 200
 #define IDB_PNG3                        201
 #define IDB_CLOSE_16_16                 201
-
-#define IDB_CHEVRON_RIGHT_8_8            198
-#define IDB_CHEVRON_RIGHT_10_10          202
-#define IDB_CHEVRON_RIGHT_12_12          203
-#define IDB_CHEVRON_RIGHT_16_16          204
-
+#define IDB_CHEVRON_RIGHT_10_10         202
+#define IDB_CHEVRON_RIGHT_12_12         203
+#define IDB_CHEVRON_RIGHT_16_16         204
 #define IDB_CHEVRON_LEFT_8_8            205
 #define IDB_CHEVRON_LEFT_10_10          206
 #define IDB_CHEVRON_LEFT_12_12          207
 #define IDB_CHEVRON_LEFT_16_16          208
-
-#define IDB_CHEVRON_TOP_8_8            209
-#define IDB_CHEVRON_TOP_10_10          210
-#define IDB_CHEVRON_TOP_12_12          211
-#define IDB_CHEVRON_TOP_16_16          212
-
-#define IDB_CHEVRON_BOTTOM_8_8            213
-#define IDB_CHEVRON_BOTTOM_10_10          214
-#define IDB_CHEVRON_BOTTOM_12_12          215
-#define IDB_CHEVRON_BOTTOM_16_16          216
-
+#define IDB_CHEVRON_TOP_8_8             209
+#define IDB_CHEVRON_TOP_10_10           210
+#define IDB_CHEVRON_TOP_12_12           211
+#define IDB_CHEVRON_TOP_16_16           212
+#define IDB_CHEVRON_BOTTOM_8_8          213
+#define IDB_CHEVRON_BOTTOM_10_10        214
+#define IDB_CHEVRON_BOTTOM_12_12        215
+#define IDB_CHEVRON_BOTTOM_16_16        216
 #define IDB_PNG5                        217
-
+#define IDB_MAXIMIZE_8_8                218
+#define IDB_MAXIMIZE_10_10              219
+#define IDB_MAXIMIZE_12_12              220
+#define IDB_PNG7                        221
+#define IDB_MAXIMIZE_16_16              221
 #define IDC_PATH                        1000
 #define IDC_GET_PATH                    1001
 #define IDC_SELECT_SOUND                1002
@@ -423,7 +421,7 @@
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        218
+#define _APS_NEXT_RESOURCE_VALUE        222
 #define _APS_NEXT_COMMAND_VALUE         32881
 #define _APS_NEXT_CONTROL_VALUE         2101
 #define _APS_NEXT_SYMED_VALUE           101

+ 74 - 51
ToolTipEx.cpp

@@ -39,6 +39,14 @@ ON_WM_SIZE()
 ON_WM_NCHITTEST()
 ON_WM_ACTIVATE()
 ON_WM_TIMER()
+
+ON_WM_NCPAINT()
+ON_WM_NCCALCSIZE()
+ON_WM_NCLBUTTONDOWN()
+ON_WM_NCMOUSEMOVE()
+ON_WM_NCLBUTTONUP()
+ON_WM_ERASEBKGND()
+
 END_MESSAGE_MAP() 
 
 
@@ -59,6 +67,14 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
         return FALSE;
     }
 
+	m_DittoWindow.DoCreate(this);
+	m_DittoWindow.SetCaptionColors(g_Opt.m_Theme.CaptionLeft(), g_Opt.m_Theme.CaptionRight());
+	m_DittoWindow.SetCaptionOn(this, CGetSetOptions::GetCaptionPos(), true);
+	m_DittoWindow.m_bDrawMinimize = false;
+	m_DittoWindow.m_bDrawMinimize = false;
+	m_DittoWindow.m_bDrawChevron = false;
+	m_DittoWindow.m_sendWMClose = false;
+
     m_RichEdit.Create(_T(""), _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL |
                       WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL |
                       ES_AUTOHSCROLL, CRect(10, 10, 100, 200), this, 1);
@@ -187,6 +203,8 @@ void CToolTipEx::OnPaint()
 
         dc.BitBlt(rect.left, rect.top, nWidth, nHeight, &MemDc, 0, 0, SRCCOPY);
 
+		//dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nHeight, SRCCOPY);
+
         MemDc.SelectObject(oldBitmap);
 
         rect.top += nHeight;
@@ -208,6 +226,8 @@ void CToolTipEx::PostNcDestroy()
 
 BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
 {
+	m_DittoWindow.DoPreTranslateMessage(pMsg);
+
     switch(pMsg->message)
     {
         case WM_KEYDOWN:
@@ -442,10 +462,14 @@ void CToolTipEx::OnSize(UINT nType, int cx, int cy)
         return ;
     }
 
+	m_DittoWindow.DoSetRegion(this);
+
     CRect cr;
     GetClientRect(cr);
     //	cr.DeflateRect(0, 0, 15, 0);
     m_RichEdit.MoveWindow(cr);
+
+	this->Invalidate();
 }
 
 BOOL CToolTipEx::IsCursorInToolTip()
@@ -478,57 +502,6 @@ void CToolTipEx::SetToolTipText(const CString &csText)
     m_RichEdit.SetText(csText);
 }
 
-HITTEST_RET CToolTipEx::OnNcHitTest(CPoint point)
-{
-    CRect crWindow;
-    GetWindowRect(crWindow);
-
-    const static int nBorder = 10;
-
-    if((point.y < crWindow.top + nBorder) && (point.x < crWindow.left + nBorder)
-       )
-    {
-        return HTTOPLEFT;
-    }
-    else if((point.y < crWindow.top + nBorder) && (point.x > crWindow.right -
-            nBorder))
-    {
-        return HTTOPRIGHT;
-    }
-    else if((point.y > crWindow.bottom - nBorder) && (point.x > crWindow.right 
-            - nBorder))
-    {
-        return HTBOTTOMRIGHT;
-    }
-    else if((point.y > crWindow.bottom - nBorder) && (point.x < crWindow.left +
-            nBorder))
-    {
-        return HTBOTTOMLEFT;
-    }
-
-    if(point.y < crWindow.top + nBorder)
-    {
-        return HTTOP;
-    }
-    else if(point.y > crWindow.bottom - nBorder)
-    {
-        return HTBOTTOM;
-    }
-    else if(point.x > crWindow.right - nBorder)
-    {
-        return HTRIGHT;
-    }
-    else if(point.x < crWindow.left + nBorder)
-    {
-        return HTLEFT;
-    }
-
-    //	if(point.x > crWindow.right - 15)
-    //		return HTCAPTION;
-
-    return CWnd::OnNcHitTest(point);
-}
-
 void CToolTipEx::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
 {
     CWnd::OnActivate(nState, pWndOther, bMinimized);
@@ -556,3 +529,53 @@ void CToolTipEx::OnTimer(UINT_PTR nIDEvent)
 
     CWnd::OnTimer(nIDEvent);
 }
+
+
+void CToolTipEx::OnNcPaint()
+{
+	m_DittoWindow.DoNcPaint(this);
+}
+
+void CToolTipEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) 
+{
+	CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
+
+	m_DittoWindow.DoNcCalcSize(bCalcValidRects, lpncsp);
+}
+
+HITTEST_RET CToolTipEx::OnNcHitTest(CPoint point) 
+{
+	UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
+	if(Ret == -1)
+		return CWnd::OnNcHitTest(point);
+
+	return Ret;
+}
+
+void CToolTipEx::OnNcLButtonDown(UINT nHitTest, CPoint point) 
+{
+	m_DittoWindow.DoNcLButtonDown(this, nHitTest, point);
+
+	CWnd::OnNcLButtonDown(nHitTest, point);
+}
+
+void CToolTipEx::OnNcLButtonUp(UINT nHitTest, CPoint point) 
+{
+	long lRet = m_DittoWindow.DoNcLButtonUp(this, nHitTest, point);
+
+	switch(lRet)
+	{
+	case BUTTON_CLOSE:
+		Hide();
+		break;
+	}
+
+	CWnd::OnNcLButtonUp(nHitTest, point);
+}
+
+void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point) 
+{
+	m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
+
+	CWnd::OnNcMouseMove(nHitTest, point);
+}

+ 7 - 0
ToolTipEx.h

@@ -8,6 +8,7 @@
 //
 #include "RichEditCtrlEx.h"
 #include "WndEx.h"
+#include "DittoWindow.h"
 /////////////////////////////////////////////////////////////////////////////
 // CToolTipEx window
 
@@ -60,6 +61,7 @@ protected:
 
 	CWnd *m_pNotifyWnd;
 
+	CDittoWindow m_DittoWindow;
 	
 
 protected:
@@ -75,6 +77,11 @@ protected:
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg HITTEST_RET OnNcHitTest(CPoint point);
 	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
+	afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point);
+	afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); 
+	afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); 
+	afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); 
+	afx_msg void OnNcPaint();
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 public:

BIN
res/maximize_10_10.png


BIN
res/maximize_12_12.png


BIN
res/maximize_16_16.png


BIN
res/maximize_8_8.png