Browse Source

F3 finds inside the description window

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@732 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden 11 years ago
parent
commit
77fb1b573e
5 changed files with 147 additions and 22 deletions
  1. 23 1
      QListCtrl.cpp
  2. 4 1
      QListCtrl.h
  3. 34 13
      QPasteWnd.cpp
  4. 80 7
      ToolTipEx.cpp
  5. 6 0
      ToolTipEx.h

+ 23 - 1
QListCtrl.cpp

@@ -904,8 +904,24 @@ void CQListCtrl::LoadCopyOrCutToClipboard()
 	g_Opt.m_bUpdateTimeOnPaste = bItWas;
 }
 
-void CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
+bool CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
 {
+	if (this->GetSelectedCount() == 0)
+	{
+		return false;
+	}
+
+	CClipIDs IDs;
+	this->GetSelectionItemData(IDs);
+	int clipId = IDs[0];
+
+	if(m_pToolTip != NULL && 
+		m_pToolTip->GetClipId() == clipId &&
+		::IsWindow(m_toolTipHwnd))
+	{
+		return false;
+	}
+
 	int nItem = GetCaret();
 	CRect rc, crWindow;
 	GetWindowRect(&crWindow);
@@ -950,10 +966,14 @@ void CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
 		m_pToolTip->SetBitmap(NULL);
 		m_pToolTip->SetRTFText("");
 		m_pToolTip->SetToolTipText(_T(""));
+		
 	}
 	
 	if(m_pToolTip)
 	{
+		m_pToolTip->SetClipId(clipId);
+		m_pToolTip->SetSearchText(m_searchText);
+
 		m_pToolTip->SetToolTipText(_T(""));  
 		m_pToolTip->SetRTFText("    ");
 		bool bSetPlainText = false;
@@ -1044,6 +1064,8 @@ void CQListCtrl::ShowFullDescription(bool bFromAuto, bool fromNextPrev)
 		
 		m_pToolTip->Show(pt);
 	}
+
+	return true;
 }
 
 void CQListCtrl::GetToolTipText(int nItem, CString &csText)

+ 4 - 1
QListCtrl.h

@@ -125,7 +125,7 @@ public:
 
 	void DestroyAndCreateAccelerator(BOOL bCreate, CppSQLite3DB &db);
 
-	void ShowFullDescription(bool bFromAuto = false, bool fromNextPrev = false);
+	bool ShowFullDescription(bool bFromAuto = false, bool fromNextPrev = false);
 	BOOL SetItemCountEx(int iCount, DWORD dwFlags = 0);
 
 	void HidePopup()	{ if(m_pToolTip) m_pToolTip->Hide();	}
@@ -142,6 +142,8 @@ public:
 
 	int GetRowHeight() { return m_rowHeight; }
 
+	void SetSearchText(CString text) { m_searchText = text;  }
+
 protected:
 	void SendSelection(int nItem);;
 	void LoadCopyOrCutToClipboard();
@@ -172,6 +174,7 @@ protected:
 	CGdiImageDrawer m_shortCutImage;
 	CGdiImageDrawer m_stickyImage;
 	int m_rowHeight;
+	CString m_searchText;
 
 
 	// Generated message map functions

+ 34 - 13
QPasteWnd.cpp

@@ -983,9 +983,12 @@ void CQPasteWnd::UpdateStatus(bool bRepaintImmediately)
 BOOL CQPasteWnd::FillList(CString csSQLSearch /*=""*/)
 {
     KillTimer(TIMER_DO_SEARCH);
+	m_lstHeader.HidePopup();
 
     Log(StrF(_T("Start Fill List - %s"), csSQLSearch));
 
+	m_lstHeader.SetSearchText(csSQLSearch);
+
 	{
 	    ATL::CCritSecLock csLock(m_CritSection.m_sect);
 	    m_bStopQuery = true;
@@ -1466,8 +1469,6 @@ void CQPasteWnd::SetSendToMenu(CMenu *pMenu, int nMenuID, int nArrayPos)
 
 LRESULT CQPasteWnd::OnSearch(WPARAM wParam, LPARAM lParam)
 {
-	m_lstHeader.HidePopup();
-
     CString csText;
     m_search.GetWindowText(csText);
 
@@ -2709,8 +2710,8 @@ bool CQPasteWnd::DoAction(DWORD actionId)
 
 bool CQPasteWnd::DoActionShowDescription()
 {
-	m_lstHeader.ShowFullDescription();
-	return true;
+	bool ret = m_lstHeader.ShowFullDescription(false, false);
+	return (ret == true);
 }
 
 bool CQPasteWnd::DoActionNextDescription()
@@ -2870,7 +2871,11 @@ bool CQPasteWnd::DoActionCloseWindow()
 	}
 	else
 	{
-		if (m_strSQLSearch.IsEmpty() == FALSE)
+		if (m_lstHeader.IsToolTipWindowVisible())
+		{
+			m_lstHeader.HidePopup();
+		}
+		else if (m_strSQLSearch.IsEmpty() == FALSE)
 		{
 			OnCancelFilter(0, 0);
 			ret = true;
@@ -3836,9 +3841,7 @@ void CQPasteWnd::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
 void CQPasteWnd::OnWindowPosChanging(WINDOWPOS *lpwndpos)
 {
     CWndEx::OnWindowPosChanging(lpwndpos);
-
-    //	m_lstHeader.HidePopup();
-
+	
     CRect rcScreen;
 
     CRect cr(lpwndpos->x, lpwndpos->y, lpwndpos->x + lpwndpos->cx, lpwndpos->y + lpwndpos->cy);
@@ -4067,12 +4070,30 @@ void CQPasteWnd::OnSearchEditChange()
 
 LRESULT CQPasteWnd::OnUpDown(WPARAM wParam, LPARAM lParam)
 {
-    m_lstHeader.HidePopup();
+	if(wParam == VK_F3)
+	{
+		MSG msg;
+		//Workaround for allow holding down arrow keys while in the search control
+		msg.lParam = lParam & (~0x40000000);
+		msg.wParam = wParam;
+		msg.message = WM_KEYDOWN;
+		if(CheckActions(&msg) == false)
+		{
+			if (m_lstHeader.HandleKeyDown(wParam, lParam) == FALSE)
+			{
+				LRESULT res = m_lstHeader.SendMessage(WM_KEYDOWN, wParam, lParam);
+			}
+		}
+	}
+	else
+	{
+		m_lstHeader.HidePopup();
 
-    if(m_lstHeader.HandleKeyDown(wParam, lParam) == FALSE)
-    {
-		m_lstHeader.SendMessage(WM_KEYDOWN, wParam, lParam);
-    }
+		if (m_lstHeader.HandleKeyDown(wParam, lParam) == FALSE)
+		{
+			LRESULT res = m_lstHeader.SendMessage(WM_KEYDOWN, wParam, lParam);
+		}
+	}
 
     return TRUE;
 }

+ 80 - 7
ToolTipEx.cpp

@@ -3,6 +3,7 @@
 #include "ToolTipEx.h"
 #include "BitmapHelper.h"
 #include "Options.h"
+#include <Richedit.h>
 
 #ifdef _DEBUG
     #define new DEBUG_NEW
@@ -23,7 +24,7 @@ m_pBitmap = NULL;		\
 
 CToolTipEx::CToolTipEx(): m_dwTextStyle(DT_EXPANDTABS | DT_EXTERNALLEADING |
                        DT_NOPREFIX | DT_WORDBREAK), m_rectMargin(2, 2, 3, 3),
-                       m_pBitmap(NULL), m_pNotifyWnd(NULL){}
+                       m_pBitmap(NULL), m_pNotifyWnd(NULL), m_clipId(0){}
 
 CToolTipEx::~CToolTipEx()
 {
@@ -82,7 +83,7 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
 	m_DittoWindow.m_sendWMClose = false;
 
     m_RichEdit.Create(_T(""), _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL |
-                      WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL |
+		WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_NOHIDESEL |
                       ES_AUTOHSCROLL, CRect(10, 10, 100, 200), this, 1);
 
     m_RichEdit.SetReadOnly();
@@ -108,7 +109,6 @@ BOOL CToolTipEx::Show(CPoint point)
     else
     {
         m_RichEdit.ShowWindow(SW_SHOW);
-		//m_RichEdit.SetFocus();
     }
 
 	CRect rect;
@@ -144,10 +144,10 @@ BOOL CToolTipEx::Show(CPoint point)
 		{
 			//if showing rtf then increase the size because
 			//rtf will probably draw bigger
-			long lNewWidth = (long)rect.Width() + (long)(rect.Width() *.3);
+			long lNewWidth = (long)rect.Width() + (long)(rect.Width() *1.5);
 			rect.right = rect.left + lNewWidth;
 
-			long lNewHeight = rect.Height() + (rect.Height() *1);
+			long lNewHeight = rect.Height() + (rect.Height() *1.5);
 			rect.bottom = rect.top + lNewHeight;
 		}
 
@@ -234,6 +234,7 @@ BOOL CToolTipEx::Hide()
 
     m_csRTF = "";
     m_csText = "";
+	m_clipId = 0;
 
 	CRect rect;
 	this->GetWindowRect(&rect);
@@ -325,6 +326,39 @@ BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
                     m_RichEdit.Copy();
                 }
                 break;
+			case VK_F3:
+			{
+				FINDTEXTEX ft;
+				long n = -1;
+
+				ft.lpstrText = m_searchText;
+
+
+				long start;
+				long end;
+				m_RichEdit.GetSel(start, end);
+
+				ft.chrg.cpMin = end;
+				ft.chrg.cpMax = -1;
+
+				n = m_RichEdit.FindText(FR_DOWN, &ft);
+				if (n != -1)
+				{
+					m_RichEdit.SetSel(ft.chrgText);
+				}
+				else 
+				{
+					ft.chrg.cpMin = 0;
+					ft.chrg.cpMax = -1;
+
+					n = m_RichEdit.FindText(FR_DOWN, &ft);
+					if (n != -1)
+					{
+						m_RichEdit.SetSel(ft.chrgText);
+					}
+				}
+			}
+			break;
             }
 			break;
 		case WM_RBUTTONDOWN:
@@ -380,6 +414,40 @@ BOOL CToolTipEx::OnMsg(MSG *pMsg)
 				{
 					return FALSE;
 				}
+				else if(vk == VK_F3)
+				{
+					FINDTEXTEX ft;
+					long n = -1;
+
+					ft.lpstrText = m_searchText;
+
+
+					long start;
+					long end;
+					m_RichEdit.GetSel(start, end);
+
+					ft.chrg.cpMin = end;
+					ft.chrg.cpMax = -1;
+
+					n = m_RichEdit.FindText(FR_DOWN, &ft);
+					if (n != -1)
+					{
+						m_RichEdit.SetSel(ft.chrgText);
+					}
+					else
+					{
+						ft.chrg.cpMin = 0;
+						ft.chrg.cpMax = -1;
+
+						n = m_RichEdit.FindText(FR_DOWN, &ft);
+						if (n != -1)
+						{
+							m_RichEdit.SetSel(ft.chrgText);
+						}
+					}
+
+					return FALSE;
+				}
 
                 Hide();
 
@@ -552,8 +620,11 @@ void CToolTipEx::SetBitmap(CBitmap *pBitmap)
 
     m_pBitmap = pBitmap;
 
-	int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
-	int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
+	if (m_pBitmap != NULL)
+	{
+		int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
+		int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
+	}
 }
 
 void CToolTipEx::OnSize(UINT nType, int cx, int cy)
@@ -591,6 +662,7 @@ void CToolTipEx::SetRTFText(const char *pRTF)
 {
     m_RichEdit.SetRTF(pRTF);
     m_csRTF = pRTF;
+	m_RichEdit.SetSel(0, 0);
 }
 
 //void CToolTipEx::SetRTFText(const CString &csRTF)
@@ -604,6 +676,7 @@ void CToolTipEx::SetToolTipText(const CString &csText)
     m_csText = csText;
     m_RichEdit.SetFont(&m_Font);
     m_RichEdit.SetText(csText);
+	m_RichEdit.SetSel(0, 0);
 }
 
 void CToolTipEx::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)

+ 6 - 0
ToolTipEx.h

@@ -38,6 +38,10 @@ public:
 	void HideWindowInXMilliSeconds(long lms)	{ SetTimer(HIDE_WINDOW_TIMER, lms, NULL); }
 	CRect GetBoundsRect();
 
+	void SetClipId(int clipId) { m_clipId = clipId; }
+	int GetClipId() { return m_clipId; }
+	void SetSearchText(CString text) { m_searchText = text; }
+
 // Overrides
 	// ClassWizard generated virtual function overrides
 	//{{AFX_VIRTUAL(CToolTipEx)
@@ -61,6 +65,8 @@ protected:
 	CWnd *m_pNotifyWnd;
 	bool m_reducedWindowSize;
 	CGdipButton m_optionsButton;
+	int m_clipId;
+	CString m_searchText;
 
 	CDittoWindow m_DittoWindow;