浏览代码

- Added next and previous commands for showing description
- Moved commands out to shortcut key class

git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@682 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 12 年之前
父节点
当前提交
c80f4eb2a0
共有 12 个文件被更改,包括 640 次插入315 次删除
  1. 5 0
      Accels.cpp
  2. 1 0
      Accels.h
  3. 12 0
      ActionEnums.cpp
  4. 33 0
      ActionEnums.h
  5. 2 0
      CP_Main.vcxproj
  6. 2 0
      CP_Main.vcxproj.filters
  7. 17 22
      QListCtrl.cpp
  8. 3 0
      QListCtrl.h
  9. 404 183
      QPasteWnd.cpp
  10. 27 7
      QPasteWnd.h
  11. 44 11
      ToolTipEx.cpp
  12. 90 92
      ToolTipEx.h

+ 5 - 0
Accels.cpp

@@ -10,6 +10,11 @@ void CAccels::AddAccel(CAccel &a)
     m_Map.SetAt(a.Key, a.Cmd);
     m_Map.SetAt(a.Key, a.Cmd);
 }
 }
 
 
+void CAccels::AddAccel(DWORD cmd, DWORD key)
+{
+	m_Map.SetAt(key, cmd);
+}
+
 bool CAccels::OnMsg(MSG *pMsg, DWORD &dID)
 bool CAccels::OnMsg(MSG *pMsg, DWORD &dID)
 {
 {
     // bit 30 (0x40000000) is 1 if this is NOT the first msg of the key
     // bit 30 (0x40000000) is 1 if this is NOT the first msg of the key

+ 1 - 0
Accels.h

@@ -27,6 +27,7 @@ public:
     CMap < DWORD, DWORD, DWORD, DWORD > m_Map;
     CMap < DWORD, DWORD, DWORD, DWORD > m_Map;
 
 
     void AddAccel(CAccel &a);
     void AddAccel(CAccel &a);
+	void AddAccel(DWORD cmd, DWORD key);
 
 
     // handles a key's first WM_KEYDOWN or WM_SYSKEYDOWN message.
     // handles a key's first WM_KEYDOWN or WM_SYSKEYDOWN message.
     // it uses GetKeyState to test for modifiers.
     // it uses GetKeyState to test for modifiers.

+ 12 - 0
ActionEnums.cpp

@@ -0,0 +1,12 @@
+#include "stdafx.h"
+#include "ActionEnums.h"
+
+
+ActionEnums::ActionEnums()
+{
+}
+
+
+ActionEnums::~ActionEnums()
+{
+}

+ 33 - 0
ActionEnums.h

@@ -0,0 +1,33 @@
+#pragma once
+class ActionEnums
+{
+public:
+	ActionEnums();
+	~ActionEnums();
+
+	enum ActionEnumValues{ 
+		SHOWDESCRIPTION,
+		NEXTDESCRIPTION,
+		PREVDESCRIPTION,
+		SHOWMENU,
+		NEWGROUP,
+		NEWGROUPSELECTION,
+		TOGGLEFILELOGGING,
+		TOGGLEOUTPUTDEBUGSTRING,
+		CLOSEWINDOW,
+		NEXTTABCONTROL,
+		PREVTABCONTROL,
+		SHOWGROUPS,
+		NEWCLIP,
+		EDITCLIP,
+		SELECTIONUP,
+		SELECTIONDOWN,
+		MOVEFIRST,
+		MOVELAST,
+		CANCELFILTER,
+		HOMELIST,
+		BACKGRROUP,
+		TOGGLESHOWPERSISTANT,
+	};
+};
+

+ 2 - 0
CP_Main.vcxproj

@@ -369,6 +369,7 @@
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="ActionEnums.cpp" />
     <ClCompile Include="AddType.cpp">
     <ClCompile Include="AddType.cpp">
       <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
       <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -1756,6 +1757,7 @@
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Accels.h" />
     <ClInclude Include="Accels.h" />
+    <ClInclude Include="ActionEnums.h" />
     <ClInclude Include="AlphaBlend.h" />
     <ClInclude Include="AlphaBlend.h" />
     <ClInclude Include="ArrayEx.h" />
     <ClInclude Include="ArrayEx.h" />
     <ClInclude Include="AutoSendToClientThread.h" />
     <ClInclude Include="AutoSendToClientThread.h" />

+ 2 - 0
CP_Main.vcxproj.filters

@@ -337,6 +337,7 @@
     <ClCompile Include="MyDropTarget.cpp">
     <ClCompile Include="MyDropTarget.cpp">
       <Filter>source</Filter>
       <Filter>source</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="ActionEnums.cpp" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="sqlite\CppSQLite3.h">
     <ClInclude Include="sqlite\CppSQLite3.h">
@@ -720,6 +721,7 @@
     <ClInclude Include="MyDropTarget.h">
     <ClInclude Include="MyDropTarget.h">
       <Filter>header</Filter>
       <Filter>header</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="ActionEnums.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="CP_Main.rc">
     <ResourceCompile Include="CP_Main.rc">

+ 17 - 22
QListCtrl.cpp

@@ -894,21 +894,6 @@ BOOL CQListCtrl::HandleKeyDown(WPARAM wParam, LPARAM lParam)
 		}
 		}
 		break;
 		break;
 		
 		
-	case VK_F3:
-		{
-			ShowFullDescription();
-			return TRUE;
-		}
-	case VK_BACK:
-		theApp.EnterGroupID( theApp.m_GroupParentID );
-		return TRUE;
-	case VK_SPACE:
-		if(GetKeyState(VK_CONTROL) & 0x8000)
-		{
-			theApp.ShowPersistent( !g_Opt.m_bShowPersistent );
-			return TRUE;
-		}
-		break;
 	} // end switch(vk)
 	} // end switch(vk)
 	
 	
 	return FALSE;
 	return FALSE;
@@ -960,12 +945,23 @@ void CQListCtrl::ShowFullDescription(bool bFromAuto)
 
 
 	CString csDescription;
 	CString csDescription;
 	GetToolTipText(nItem, csDescription);
 	GetToolTipText(nItem, csDescription);
+		
+	//if (bFromAuto == false ||
+	//	::IsWindow(m_toolTipHwnd) == FALSE)
+	{
+		m_pToolTip->DestroyWindow();
 
 
-	m_pToolTip->DestroyWindow();
-
-	m_pToolTip = new CToolTipEx;
-	m_pToolTip->Create(this);
-	m_pToolTip->SetNotifyWnd(GetParent());
+		m_pToolTip = new CToolTipEx;
+		m_pToolTip->Create(this);
+		m_toolTipHwnd = m_pToolTip->GetSafeHwnd();
+		m_pToolTip->SetNotifyWnd(GetParent());
+	}
+	//else
+	//{
+	//	CRect r;
+	//	m_pToolTip->GetWindowRect(r);
+	//	pt = r.TopLeft();
+	//}
 	
 	
 	if(m_pToolTip)
 	if(m_pToolTip)
 	{
 	{
@@ -1055,8 +1051,7 @@ void CQListCtrl::ShowFullDescription(bool bFromAuto)
 
 
 			Clip.Free();
 			Clip.Free();
 			Clip.Clear();
 			Clip.Clear();
-		}
-			
+		}			
 		
 		
 		m_pToolTip->Show(pt);
 		m_pToolTip->Show(pt);
 	}
 	}

+ 3 - 0
QListCtrl.h

@@ -138,6 +138,8 @@ public:
 
 
 	BOOL OnItemDeleted(long lID);
 	BOOL OnItemDeleted(long lID);
 
 
+	BOOL IsToolTipWindowVisible() { return ::IsWindowVisible(m_toolTipHwnd); }
+
 protected:
 protected:
 	void SendSelection(int nItem);;
 	void SendSelection(int nItem);;
 	void LoadCopyOrCutToClipboard();
 	void LoadCopyOrCutToClipboard();
@@ -155,6 +157,7 @@ protected:
 	CAccels	m_Accels;
 	CAccels	m_Accels;
 	CMapIDtoCF m_RTFData;
 	CMapIDtoCF m_RTFData;
 	CToolTipEx *m_pToolTip;
 	CToolTipEx *m_pToolTip;
+	HWND m_toolTipHwnd;
 	CFont m_Font;
 	CFont m_Font;
 	IFormattedTextDraw *m_pFormatter;
 	IFormattedTextDraw *m_pFormatter;
 	bool m_allSelected;
 	bool m_allSelected;

+ 404 - 183
QPasteWnd.cpp

@@ -13,6 +13,7 @@
 #include "FormatSQL.h"
 #include "FormatSQL.h"
 #include "MainTableFunctions.h"
 #include "MainTableFunctions.h"
 #include "Path.h"
 #include "Path.h"
+#include "ActionEnums.h"
 #include <algorithm>
 #include <algorithm>
 //#include "MyDropTarget.h"
 //#include "MyDropTarget.h"
 
 
@@ -313,6 +314,29 @@ int CQPasteWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	
 	
     m_thread.Start(this);
     m_thread.Start(this);
 
 
+	m_actions.AddAccel(ActionEnums::SHOWDESCRIPTION, VK_F3);
+	m_actions.AddAccel(ActionEnums::NEXTDESCRIPTION, 'N');
+	m_actions.AddAccel(ActionEnums::PREVDESCRIPTION, 'P');
+	m_actions.AddAccel(ActionEnums::SHOWMENU, VK_APPS);
+	m_actions.AddAccel(ActionEnums::NEWGROUP, ACCEL_MAKEKEY(VK_F7, HOTKEYF_CONTROL));
+	m_actions.AddAccel(ActionEnums::NEWGROUPSELECTION, VK_F7);
+	m_actions.AddAccel(ActionEnums::TOGGLEFILELOGGING, ACCEL_MAKEKEY(VK_F5, HOTKEYF_CONTROL));
+	m_actions.AddAccel(ActionEnums::TOGGLEOUTPUTDEBUGSTRING, VK_F5);
+	m_actions.AddAccel(ActionEnums::CLOSEWINDOW, VK_ESCAPE);
+	m_actions.AddAccel(ActionEnums::NEXTTABCONTROL, VK_TAB);
+	m_actions.AddAccel(ActionEnums::PREVTABCONTROL, ACCEL_MAKEKEY(VK_TAB, HOTKEYF_CONTROL));
+	m_actions.AddAccel(ActionEnums::SHOWGROUPS, ACCEL_MAKEKEY('G', HOTKEYF_CONTROL));
+	m_actions.AddAccel(ActionEnums::NEWCLIP, ACCEL_MAKEKEY('N', HOTKEYF_CONTROL));
+	m_actions.AddAccel(ActionEnums::EDITCLIP, ACCEL_MAKEKEY('E', HOTKEYF_CONTROL));
+	m_actions.AddAccel(ActionEnums::SELECTIONUP, VK_UP);
+	m_actions.AddAccel(ActionEnums::SELECTIONDOWN, VK_DOWN);
+	m_actions.AddAccel(ActionEnums::MOVEFIRST, VK_HOME);
+	m_actions.AddAccel(ActionEnums::MOVELAST, VK_END);
+	m_actions.AddAccel(ActionEnums::CANCELFILTER, ACCEL_MAKEKEY('C', HOTKEYF_ALT));
+	m_actions.AddAccel(ActionEnums::HOMELIST, VK_HOME);
+	m_actions.AddAccel(ActionEnums::BACKGRROUP, VK_BACK);
+	m_actions.AddAccel(ActionEnums::TOGGLESHOWPERSISTANT, ACCEL_MAKEKEY(VK_SPACE, HOTKEYF_CONTROL));
+	
     return 0;
     return 0;
 }
 }
 
 
@@ -2569,207 +2593,404 @@ void CQPasteWnd::SetKeyModiferState(bool bActive)
 
 
 BOOL CQPasteWnd::PreTranslateMessage(MSG *pMsg)
 BOOL CQPasteWnd::PreTranslateMessage(MSG *pMsg)
 {
 {
-    switch(pMsg->message)
-    {
-        case WM_KEYDOWN:
+	DWORD dID;
+	if (m_actions.OnMsg(pMsg, dID))
+	{
+		bool ret = DoAction(dID);
 
 
-            switch(pMsg->wParam)
-            {
-            case VK_APPS:
-                {
-                    LRESULT lRet;
-                    OnRclickQuickPaste(NULL, &lRet);
-                    return 0;
-                }
-            case VK_F7:
-                if(pMsg->hwnd == m_lstHeader.m_hWnd)
-                {
-                    if(GetKeyState(VK_CONTROL) &0x8000)
-                    {
-                        NewGroup(false);
-                    }
-                    else
-                    {
-                        NewGroup(true);
-                    }
-                    return TRUE;
-                }
-                break;
+		if (ret)
+		{
+			return TRUE;
+		}
+	}    
 
 
-            case VK_F5:
-                //toggle outputing text to outputdebugstring
-                if(GetKeyState(VK_CONTROL) &0x8000)
-                {
-                    if(CGetSetOptions::m_bEnableDebugLogging)
-                    {
-                        Log(_T("turning file logging OFF"));
-                    }
+    return CWndEx::PreTranslateMessage(pMsg);
+}
 
 
-                    CGetSetOptions::m_bEnableDebugLogging = !CGetSetOptions::m_bEnableDebugLogging;
+bool CQPasteWnd::DoAction(DWORD actionId)
+{
+	bool ret = false;
 
 
-                    if(CGetSetOptions::m_bEnableDebugLogging)
-                    {
-                        Log(_T("turning file logging ON"));
-                    }
-                }
-                else
-                {
-                    if(CGetSetOptions::m_bEnableDebugLogging)
-                    {
-                        Log(_T("turning DebugString logging OFF"));
-                    }
+	switch (actionId)
+	{
+	case ActionEnums::SHOWDESCRIPTION:
+		ret = DoActionShowDescription();
+		break;
+	case ActionEnums::NEXTDESCRIPTION:
+		ret = DoActionNextDescription();
+		break;
+	case ActionEnums::PREVDESCRIPTION:
+		ret = DoActionPrevDescription();
+		break;
+	case ActionEnums::SHOWMENU:
+		ret = DoActionShowMenu();
+		break;
+	case ActionEnums::NEWGROUP:
+		ret = DoActionNewGroup();
+		break;
+	case ActionEnums::NEWGROUPSELECTION:
+		ret = DoActionNewGroupSelection();
+		break;
+	case ActionEnums::TOGGLEFILELOGGING:
+		ret = DoActionToggleFileLogging();
+		break;
+	case ActionEnums::TOGGLEOUTPUTDEBUGSTRING:
+		ret = DoActionToggleOutputDebugString();
+		break;
+	case ActionEnums::CLOSEWINDOW:
+		ret = DoActionCloseWindow();
+		break;
+	case ActionEnums::NEXTTABCONTROL:
+		ret = DoActionNextTabControl();
+		break;
+	case ActionEnums::PREVTABCONTROL:
+		ret = DoActionPrevTabControl();
+		break;
+	case ActionEnums::SHOWGROUPS:
+		ret = DoActionShowGroups();
+		break;
+	case ActionEnums::NEWCLIP:
+		ret = DoActionNewClip();
+		break;
+	case ActionEnums::EDITCLIP:
+		ret = DoActionEditClip();
+		break;
+	case ActionEnums::SELECTIONUP:
+		ret = DoActionSelectionUp();
+		break;
+	case ActionEnums::SELECTIONDOWN:
+		ret = DoActionSelectionDown();
+		break;
+	case ActionEnums::MOVEFIRST:
+		ret = DoActionMoveFirst();
+		break;
+	case ActionEnums::MOVELAST:
+		ret = DoActionMoveLast();
+		break;
+	case ActionEnums::CANCELFILTER:
+		ret = DoActionCancelFilter();
+		break;
+	case ActionEnums::HOMELIST:
+		ret = DoActionHomeList();
+		break;
+	case ActionEnums::BACKGRROUP:
+		ret = DoActionBackGroup();
+		break;
+	case ActionEnums::TOGGLESHOWPERSISTANT:
+		ret = DoActionToggleShowPersistant();
+		break;
+	}
 
 
-                    CGetSetOptions::m_bOutputDebugString = !CGetSetOptions::m_bOutputDebugString;
+	return ret;
+}
 
 
-                    if(CGetSetOptions::m_bEnableDebugLogging)
-                    {
-                        Log(_T("turning DebugString logging ON"));
-                    }
-                }
-                return TRUE;
+bool CQPasteWnd::DoActionShowDescription()
+{
+	m_lstHeader.ShowFullDescription();
+	return true;
+}
 
 
-            case VK_ESCAPE:
-                {
-                    if(m_bModifersMoveActive)
-                    {
-                        Log(_T("Escape key hit setting modifers to NOT active"));
-                        m_bModifersMoveActive = false;
-                        return TRUE;
-                    }
-                    else
-                    {
-                        if(m_lstHeader.HandleKeyDown(pMsg->wParam, pMsg->lParam) == FALSE)
-                        {
-                            if(m_strSQLSearch.IsEmpty() == FALSE)
-                            {
-                                OnCancelFilter(0, 0);
-                                return TRUE;
-                            }
-                            else
-                            {
-								if(g_Opt.GetShowPersistent() && this->GetMinimized() == false)
-								{
-									MinMaxWindow(FORCE_MIN);
-									theApp.m_activeWnd.ReleaseFocus();
-								}
-								else
-								{
-									if(m_GroupTree.IsWindowVisible() == FALSE)
-									{
-										HideQPasteWindow(true);
-										return TRUE;
-									}
-								}
-                            }
-                        }
-                    }
-                    break;
-                }
-            case VK_TAB:
-                {
-                    BOOL bPrev = FALSE;
+bool CQPasteWnd::DoActionNextDescription()
+{	
+	if (m_lstHeader.IsToolTipWindowVisible() == FALSE)
+		return false;
 
 
-                    if(GetKeyState(VK_SHIFT) &0x8000)
-                    {
-                        bPrev = TRUE;
-                    }
+	ARRAY Indexes;
+	m_lstHeader.GetSelectionIndexes(Indexes);
 
 
-                    CWnd *pFocus = GetFocus();
-                    if(pFocus)
-                    {
-                        CWnd *pNextWnd = GetNextDlgTabItem(pFocus, bPrev);
-                        if(pNextWnd)
-                        {
-                            pNextWnd->SetFocus();
-                        }
-                    }
-                    return TRUE;
-                }
-            case 'G':
-                if(GetKeyState(VK_CONTROL) &0x8000)
-                {
-                    OnShowGroupsTop();
-                    return TRUE;
-                }
-                break;
-            case 'N':
-                if(GetKeyState(VK_CONTROL) &0x8000)
-                {
-                    OnMenuNewclip();
-                    return TRUE;
-                }
-                break;
-            case 'E':
-                if(GetKeyState(VK_CONTROL) &0x8000)
-                {
-                    OnMenuEdititem();
-                    return TRUE;
-                }
-                break;
+	long caret = m_lstHeader.GetCaret();
 
 
-            case VK_UP:
-                if(m_bModifersMoveActive)
-                {
-                    MoveSelection(false);
-                    return TRUE;
-                }
-                break;
+	if(Indexes.GetCount() > 1)
+	{
+		for (int i = 0; i < Indexes.GetCount(); i++)
+		{
+			int index = Indexes[i];
+			if(index == caret)
+			{
+				if(i < Indexes.GetCount()-1)
+				{
+					caret = Indexes[i + 1];
+					break;
+				}
+				else
+				{
+					caret = Indexes[0];
+				}
+			}
+		}
 
 
-            case VK_DOWN:
-                if(m_bModifersMoveActive)
-                {
-                    MoveSelection(true);
-                    return TRUE;
-                }
-                break;
+		m_lstHeader.SetCaret(caret);
+	}
+	else
+	{
+		caret++;
+		m_lstHeader.SetListPos(caret);
+	}
+	
+	m_lstHeader.ShowFullDescription();
 
 
-            case VK_HOME:
-                if(m_bModifersMoveActive)
-                {
-                    m_lstHeader.SetListPos(0);
-                    return TRUE;
-                }
-                break;
-            case VK_END:
-                if(m_bModifersMoveActive)
-                {
-                    if(m_lstHeader.GetItemCount() > 0)
-                    {
-                        m_lstHeader.SetListPos(m_lstHeader.GetItemCount() - 1);
-                    }
-                    return TRUE;
-                }
-                break;
-            }
-            // end switch( pMsg->wParam )
+	return true;
+}
 
 
-            break; // end case WM_KEYDOWN 
+bool CQPasteWnd::DoActionPrevDescription()
+{
+	if (m_lstHeader.IsToolTipWindowVisible() == FALSE)
+		return false;
 
 
-        case WM_SYSKEYDOWN:
-            // ALT key is held down
+	ARRAY Indexes;
+	m_lstHeader.GetSelectionIndexes(Indexes);
 
 
-            switch(pMsg->wParam)
-            {
-            case 'C':
-                // switch to the filter combobox
-                BYTE key[256];
-                GetKeyboardState((LPBYTE)(&key));
-                if(key[VK_MENU] &128)
-                {
-                    OnCancelFilter(0, 0);
-                }
-                return TRUE;
+	long caret = m_lstHeader.GetCaret();
+	
+	if (Indexes.GetCount() > 1)
+	{
+		for (int i = Indexes.GetCount()-1; i >= 0; i--)
+		{
+			int index = Indexes[i];
+			if (index == caret)
+			{
+				if (i > 0)
+				{
+					caret = Indexes[i - 1];
+					break;
+				}
+				else
+				{
+					caret = Indexes[Indexes.GetCount() - 1];
+				}
+			}
+		}
 
 
-            case VK_HOME:
-                theApp.EnterGroupID(-1); // History
-                return TRUE;
-            }
-            // end switch( pMsg->wParam )
+		m_lstHeader.SetCaret(caret);
+	}
+	else
+	{
+		caret--;
+		m_lstHeader.SetListPos(caret);
+	}
 
 
-            break; // end case WM_SYSKEYDOWN
-    }
+	m_lstHeader.ShowFullDescription();
 
 
-    return CWndEx::PreTranslateMessage(pMsg);
+	return true;
+}
+
+bool CQPasteWnd::DoActionShowMenu()
+{
+	LRESULT lRet;
+	OnRclickQuickPaste(NULL, &lRet);
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionNewGroup()
+{
+	NewGroup(false);
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionNewGroupSelection()
+{
+	NewGroup(true);
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionToggleFileLogging()
+{
+	if (CGetSetOptions::m_bEnableDebugLogging)
+	{
+		Log(_T("turning file logging OFF"));
+	}
+
+	CGetSetOptions::m_bEnableDebugLogging = !CGetSetOptions::m_bEnableDebugLogging;
+
+	if (CGetSetOptions::m_bEnableDebugLogging)
+	{
+		Log(_T("turning file logging ON"));
+	}
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionToggleOutputDebugString()
+{
+	if (CGetSetOptions::m_bEnableDebugLogging)
+	{
+		Log(_T("turning DebugString logging OFF"));
+	}
+
+	CGetSetOptions::m_bOutputDebugString = !CGetSetOptions::m_bOutputDebugString;
+
+	if (CGetSetOptions::m_bEnableDebugLogging)
+	{
+		Log(_T("turning DebugString logging ON"));
+	}
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionCloseWindow()
+{
+	bool ret = false;
+	if (m_bModifersMoveActive)
+	{
+		Log(_T("Escape key hit setting modifers to NOT active"));
+		m_bModifersMoveActive = false;
+		ret = true;
+	}
+	else
+	{
+		if (m_strSQLSearch.IsEmpty() == FALSE)
+		{
+			OnCancelFilter(0, 0);
+			ret = true;
+		}
+		else
+		{
+			if (g_Opt.GetShowPersistent() && this->GetMinimized() == false)
+			{
+				MinMaxWindow(FORCE_MIN);
+				theApp.m_activeWnd.ReleaseFocus();
+			}
+			else
+			{
+				if (m_GroupTree.IsWindowVisible() == FALSE)
+				{
+					HideQPasteWindow(true);
+					ret = true;
+				}
+			}
+		}
+	}
+
+	return ret;
+}
+
+bool CQPasteWnd::DoActionNextTabControl()
+{
+	BOOL bPrev = FALSE;
+
+	CWnd *pFocus = GetFocus();
+	if (pFocus)
+	{
+		CWnd *pNextWnd = GetNextDlgTabItem(pFocus, bPrev);
+		if (pNextWnd)
+		{
+			pNextWnd->SetFocus();
+		}
+	}
+	return true;
+}
+
+bool CQPasteWnd::DoActionPrevTabControl()
+{
+	BOOL bPrev = TRUE;
+
+	CWnd *pFocus = GetFocus();
+	if (pFocus)
+	{
+		CWnd *pNextWnd = GetNextDlgTabItem(pFocus, bPrev);
+		if (pNextWnd)
+		{
+			pNextWnd->SetFocus();
+		}
+	}
+	return true;
+}
+
+bool CQPasteWnd::DoActionShowGroups()
+{
+	OnShowGroupsTop();
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionNewClip()
+{
+	OnMenuNewclip();
+	return true;
+}
+
+bool CQPasteWnd::DoActionEditClip()
+{
+	OnMenuEdititem();
+	return true;
+}
+
+bool CQPasteWnd::DoActionSelectionUp()
+{
+	if (m_bModifersMoveActive)
+	{
+		MoveSelection(false);
+		return true;
+	}
+
+	return false;
+}
+
+bool CQPasteWnd::DoActionSelectionDown()
+{
+	if (m_bModifersMoveActive)
+	{
+		MoveSelection(true);
+		return true;
+	}
+
+	return false;
+}
+
+bool CQPasteWnd::DoActionMoveFirst()
+{
+	if (m_bModifersMoveActive)
+	{
+		m_lstHeader.SetListPos(0);
+		return true;
+	}
+
+	return false;
+}
+
+bool CQPasteWnd::DoActionMoveLast()
+{
+	if (m_bModifersMoveActive)
+	{
+		if (m_lstHeader.GetItemCount() > 0)
+		{
+			m_lstHeader.SetListPos(m_lstHeader.GetItemCount() - 1);
+		}
+		return true;
+	}
+
+	return false;
+}
+
+bool CQPasteWnd::DoActionCancelFilter()
+{
+	OnCancelFilter(0, 0);
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionHomeList()
+{
+	theApp.EnterGroupID(-1); // History
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionBackGroup()
+{
+	theApp.EnterGroupID(theApp.m_GroupParentID);
+
+	return true;
+}
+
+bool CQPasteWnd::DoActionToggleShowPersistant()
+{
+	theApp.ShowPersistent(!g_Opt.m_bShowPersistent);
+
+	return true;
 }
 }
 
 
 LRESULT CQPasteWnd::OnCancelFilter(WPARAM wParam, LPARAM lParam)
 LRESULT CQPasteWnd::OnCancelFilter(WPARAM wParam, LPARAM lParam)

+ 27 - 7
QPasteWnd.h

@@ -153,7 +153,7 @@ public:
     CF_DibTypeMap m_cf_dibCache;
     CF_DibTypeMap m_cf_dibCache;
     CF_DibTypeMap m_cf_rtfCache;
     CF_DibTypeMap m_cf_rtfCache;
     CCriticalSection m_CritSection;
     CCriticalSection m_CritSection;
-    CAccels m_MainAccels;
+    CAccels m_actions;
 	bool m_showScrollBars;
 	bool m_showScrollBars;
 
 
     void RefreshNc();
     void RefreshNc();
@@ -203,6 +203,30 @@ public:
 	void OnDragLeave();
 	void OnDragLeave();
 	COleDropTarget *m_pDropTarget;
 	COleDropTarget *m_pDropTarget;
 
 
+	bool DoAction(DWORD actionId);
+	bool DoActionShowDescription();
+	bool DoActionNextDescription(); 
+	bool DoActionPrevDescription();
+	bool DoActionShowMenu();
+	bool DoActionNewGroup();
+	bool DoActionNewGroupSelection();
+	bool DoActionToggleFileLogging();
+	bool DoActionToggleOutputDebugString();
+	bool DoActionCloseWindow();
+	bool DoActionNextTabControl();
+	bool DoActionPrevTabControl();
+	bool DoActionShowGroups();
+	bool DoActionNewClip();
+	bool DoActionEditClip();
+	bool DoActionSelectionUp();
+	bool DoActionSelectionDown();
+	bool DoActionMoveFirst();
+	bool DoActionMoveLast();
+	bool DoActionCancelFilter();
+	bool DoActionHomeList();
+	bool DoActionBackGroup();
+	bool DoActionToggleShowPersistant();
+
     // Generated message map functions
     // Generated message map functions
 protected:
 protected:
     //{{AFX_MSG(CQPasteWnd)
     //{{AFX_MSG(CQPasteWnd)
@@ -335,13 +359,9 @@ protected:
 	afx_msg void OnMenuSearchFullText();
 	afx_msg void OnMenuSearchFullText();
 	afx_msg void OnMenuSearchQuickPaste();
 	afx_msg void OnMenuSearchQuickPaste();
 	afx_msg void OnMenuSimpleTextSearch();
 	afx_msg void OnMenuSimpleTextSearch();
-	//afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
-	//afx_msg BOOL OnEraseBkgnd(CDC* pDC);
-	//afx_msg void OnPaint();
-    //}}AFX_MSG
 	afx_msg LRESULT OnPostOptions(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnPostOptions(WPARAM wParam, LPARAM lParam);
 	afx_msg void OnMakeTopStickyClip();
 	afx_msg void OnMakeTopStickyClip();
 	afx_msg void OnMakeLastStickyClip();
 	afx_msg void OnMakeLastStickyClip();
 	afx_msg void OnRemoveStickySetting();
 	afx_msg void OnRemoveStickySetting();
-
-};
+	
+};

+ 44 - 11
ToolTipEx.cpp

@@ -89,6 +89,7 @@ BOOL CToolTipEx::Create(CWnd *pParentWnd)
 
 
 BOOL CToolTipEx::Show(CPoint point)
 BOOL CToolTipEx::Show(CPoint point)
 {
 {
+	m_reducedWindowSize = false;
     if(m_pBitmap)
     if(m_pBitmap)
     {
     {
         m_RichEdit.ShowWindow(SW_HIDE);
         m_RichEdit.ShowWindow(SW_HIDE);
@@ -104,10 +105,18 @@ BOOL CToolTipEx::Show(CPoint point)
     rect.right += 20;
     rect.right += 20;
     rect.bottom += 20;
     rect.bottom += 20;
 
 
-    //if showing rtf then increase the size because
-    //rtf will probably draw bigger
-    if(m_csRTF != "")
+	if (m_pBitmap)
+	{
+		int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
+		int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
+
+		rect.right = rect.left + nWidth;
+		rect.bottom = rect.top + nHeight;
+	}
+    else if(m_csRTF != "")
     {
     {
+		//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() *.3);
         rect.right = rect.left + lNewWidth;
         rect.right = rect.left + lNewWidth;
 
 
@@ -115,6 +124,9 @@ BOOL CToolTipEx::Show(CPoint point)
         rect.bottom = rect.top + lNewHeight;
         rect.bottom = rect.top + lNewHeight;
     }
     }
 
 
+	rect.right += CAPTION_BORDER * 2;
+	rect.bottom += CAPTION_BORDER * 2;
+
     CRect rcScreen;
     CRect rcScreen;
 
 
     ClientToScreen(rect);
     ClientToScreen(rect);
@@ -128,10 +140,12 @@ BOOL CToolTipEx::Show(CPoint point)
     if(point.x < 0)
     if(point.x < 0)
     {
     {
         point.x = 5;
         point.x = 5;
+		m_reducedWindowSize = true;
     }
     }
     if(point.y < 0)
     if(point.y < 0)
     {
     {
         point.y = 5;
         point.y = 5;
+		m_reducedWindowSize = true;
     }
     }
 
 
     rcScreen.DeflateRect(0, 0, 5, 5);
     rcScreen.DeflateRect(0, 0, 5, 5);
@@ -147,10 +161,12 @@ BOOL CToolTipEx::Show(CPoint point)
     if(rect.right > rcScreen.right)
     if(rect.right > rcScreen.right)
     {
     {
         rect.right = rcScreen.right;
         rect.right = rcScreen.right;
+		m_reducedWindowSize = true;
     }
     }
     if(rect.bottom > rcScreen.bottom)
     if(rect.bottom > rcScreen.bottom)
     {
     {
         rect.bottom = rcScreen.bottom;
         rect.bottom = rcScreen.bottom;
+		m_reducedWindowSize = true;
     }
     }
 
 
     SetWindowPos(&CWnd::wndTopMost, point.x, point.y, rect.Width(), rect.Height
     SetWindowPos(&CWnd::wndTopMost, point.x, point.y, rect.Width(), rect.Height
@@ -179,13 +195,7 @@ void CToolTipEx::OnPaint()
     CRect rect;
     CRect rect;
     GetClientRect(rect);
     GetClientRect(rect);
 
 
-    //	CBrush  Brush, *pOldBrush;
-    //	Brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
-
-    //	pOldBrush = dc.SelectObject(&Brush);
-    //	CFont *pOldFont = dc.SelectObject(&m_Font);
-
-    //  dc.FillRect(&rect, &Brush);
+    
 
 
     // Draw Text
     // Draw Text
     //    dc.SetBkMode(TRANSPARENT);
     //    dc.SetBkMode(TRANSPARENT);
@@ -193,6 +203,14 @@ void CToolTipEx::OnPaint()
 
 
     if(m_pBitmap)
     if(m_pBitmap)
     {
     {
+		CBrush  Brush, *pOldBrush;
+		Brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
+
+		pOldBrush = dc.SelectObject(&Brush);
+		CFont *pOldFont = dc.SelectObject(&m_Font);
+
+		dc.FillRect(&rect, &Brush);
+
         CDC MemDc;
         CDC MemDc;
         MemDc.CreateCompatibleDC(&dc);
         MemDc.CreateCompatibleDC(&dc);
 
 
@@ -201,7 +219,14 @@ void CToolTipEx::OnPaint()
         int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
         int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
         int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
         int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
 
 
-        dc.BitBlt(rect.left, rect.top, nWidth, nHeight, &MemDc, 0, 0, SRCCOPY);
+		if(m_reducedWindowSize)
+		{
+			dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nWidth, SRCCOPY);
+		}
+		else
+		{
+			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);
 		//dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nHeight, SRCCOPY);
 
 
@@ -280,6 +305,14 @@ BOOL CToolTipEx::OnMsg(MSG *pMsg)
                     m_RichEdit.SetFocus();
                     m_RichEdit.SetFocus();
                     return TRUE;
                     return TRUE;
                 }
                 }
+				else if(vk == 'N')
+				{
+					return FALSE;
+				}
+				else if (vk == 'P')
+				{
+					return FALSE;
+				}
 
 
                 Hide();
                 Hide();
 
 

+ 90 - 92
ToolTipEx.h

@@ -1,96 +1,94 @@
-#if !defined(AFX_ToolTipEx_H__5796127D_8817_493F_ACA7_8741A6759DD3__INCLUDED_)
-#define AFX_ToolTipEx_H__5796127D_8817_493F_ACA7_8741A6759DD3__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-// ToolTipEx.h : header file
-//
-#include "RichEditCtrlEx.h"
-#include "WndEx.h"
-#include "DittoWindow.h"
-/////////////////////////////////////////////////////////////////////////////
-// CToolTipEx window
-
-#define HIDE_WINDOW_TIMER 1
-
-class CToolTipEx : public CWnd
-{
-// Construction
-public:
-	CToolTipEx();
-
-// Attributes
-public:
-
-// Operations
-public:
-	BOOL OnMsg(MSG* pMsg);
-	BOOL Create(CWnd* pParentWnd);
-	BOOL Show(CPoint point);
-	BOOL Hide();
-	void SetToolTipText(const CString &csText);
-//	void SetRTFText(const CString &csRTF);
-	void SetRTFText(const char *pRTF);
-	void SetBitmap(CBitmap *pBitmap);
-	void SetNotifyWnd(CWnd *pNotify)		{ m_pNotifyWnd = pNotify;	}
-	void HideWindowInXMilliSeconds(long lms)	{ SetTimer(HIDE_WINDOW_TIMER, lms, NULL); }
-	CRect GetBoundsRect();
-
-// Overrides
-	// ClassWizard generated virtual function overrides
-	//{{AFX_VIRTUAL(CToolTipEx)
-	protected:
-	virtual void PostNcDestroy();
-	virtual BOOL PreTranslateMessage(MSG* pMsg);
-	//}}AFX_VIRTUAL
-
-// Implementation
-public:
-	virtual ~CToolTipEx();
-	
-protected:
-	DWORD m_dwTextStyle;
-	CRect m_rectMargin;
-	CString m_csText;
-	CFont m_Font;
-	CBitmap *m_pBitmap;
-	CString m_csRTF;
-
-	CRichEditCtrlEx m_RichEdit;
-
-	CWnd *m_pNotifyWnd;
-
-	CDittoWindow m_DittoWindow;
-	
-
-protected:
-	CString GetFieldFromString(CString ref, int nIndex, TCHAR ch);
-	BOOL SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw /*=TRUE*/);
-	LPLOGFONT GetSystemToolTipFont();
-	BOOL IsCursorInToolTip();
-
-	// Generated message map functions
-protected:
-	//{{AFX_MSG(CToolTipEx)
-	afx_msg void OnPaint();
-	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);
+#if !defined(AFX_ToolTipEx_H__5796127D_8817_493F_ACA7_8741A6759DD3__INCLUDED_)
+#define AFX_ToolTipEx_H__5796127D_8817_493F_ACA7_8741A6759DD3__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// ToolTipEx.h : header file
+//
+#include "RichEditCtrlEx.h"
+#include "WndEx.h"
+#include "DittoWindow.h"
+/////////////////////////////////////////////////////////////////////////////
+// CToolTipEx window
+
+#define HIDE_WINDOW_TIMER 1
+
+class CToolTipEx : public CWnd
+{
+// Construction
+public:
+	CToolTipEx();
+
+// Attributes
+public:
+
+// Operations
+public:
+	BOOL OnMsg(MSG* pMsg);
+	BOOL Create(CWnd* pParentWnd);
+	BOOL Show(CPoint point);
+	BOOL Hide();
+	void SetToolTipText(const CString &csText);
+//	void SetRTFText(const CString &csRTF);
+	void SetRTFText(const char *pRTF);
+	void SetBitmap(CBitmap *pBitmap);
+	void SetNotifyWnd(CWnd *pNotify)		{ m_pNotifyWnd = pNotify;	}
+	void HideWindowInXMilliSeconds(long lms)	{ SetTimer(HIDE_WINDOW_TIMER, lms, NULL); }
+	CRect GetBoundsRect();
+
+// Overrides
+	// ClassWizard generated virtual function overrides
+	//{{AFX_VIRTUAL(CToolTipEx)
+	protected:
+	virtual void PostNcDestroy();
+	virtual BOOL PreTranslateMessage(MSG* pMsg);
+	//}}AFX_VIRTUAL
+
+// Implementation
+public:
+	virtual ~CToolTipEx();
+	
+protected:
+	DWORD m_dwTextStyle;
+	CRect m_rectMargin;
+	CString m_csText;
+	CFont m_Font;
+	CBitmap *m_pBitmap;
+	CString m_csRTF;
+	CRichEditCtrlEx m_RichEdit;
+	CWnd *m_pNotifyWnd;
+	bool m_reducedWindowSize;
+
+	CDittoWindow m_DittoWindow;
+
+protected:
+	CString GetFieldFromString(CString ref, int nIndex, TCHAR ch);
+	BOOL SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw /*=TRUE*/);
+	LPLOGFONT GetSystemToolTipFont();
+	BOOL IsCursorInToolTip();
+
+	// Generated message map functions
+protected:
+	//{{AFX_MSG(CToolTipEx)
+	afx_msg void OnPaint();
+	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 OnNcMouseMove(UINT nHitTest, CPoint point);
 	afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); 
 	afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); 
 	afx_msg void OnNcLButtonDown(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 OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); 
-	afx_msg void OnNcPaint();
-	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP()
-public:
-	afx_msg void OnTimer(UINT_PTR nIDEvent);
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_ToolTipEx_H__5796127D_8817_493F_ACA7_8741A6759DD3__INCLUDED_)
+	afx_msg void OnNcPaint();
+	//}}AFX_MSG
+	DECLARE_MESSAGE_MAP()
+public:
+	afx_msg void OnTimer(UINT_PTR nIDEvent);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_ToolTipEx_H__5796127D_8817_493F_ACA7_8741A6759DD3__INCLUDED_)