QPasteWnd.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. #pragma once
  2. #include "QListCtrl.h"
  3. #include "SearchEditBox.h"
  4. #include "WndEx.h"
  5. #include "GroupStatic.h"
  6. #include "GroupTree.h"
  7. #include "AlphaBlend.h"
  8. #include "Sqlite\CppSQLite3.h"
  9. #include <vector>
  10. #include <list>
  11. #include <map>
  12. #include <afxmt.h>
  13. #include "ClipFormatQListCtrl.h"
  14. #include "QPasteWndThread.h"
  15. #include "editwithbutton.h"
  16. #include "GdipButton.h"
  17. #include "SpecialPasteOptions.h"
  18. #include "ClipIds.h"
  19. class CMainTable
  20. {
  21. public:
  22. CMainTable():
  23. m_lID( - 1),
  24. m_bDontAutoDelete(false),
  25. m_bIsGroup(false),
  26. m_bHasShortCut(false),
  27. m_bHasParent(false)
  28. {
  29. }
  30. ~CMainTable()
  31. {
  32. }
  33. long m_lID;
  34. CString m_Desc;
  35. bool m_bDontAutoDelete;
  36. bool m_bIsGroup;
  37. bool m_bHasShortCut;
  38. bool m_bHasParent;
  39. CString m_QuickPaste;
  40. double m_clipOrder;
  41. double m_clipGroupOrder;
  42. double m_stickyClipOrder;
  43. double m_stickyClipGroupOrder;
  44. static bool SortDesc(const CMainTable& d1, const CMainTable& d2)
  45. {
  46. double d1StickyOrder = d1.m_stickyClipOrder;
  47. if (d1StickyOrder == 0)
  48. d1StickyOrder = -9999999.0;
  49. double d2StickyOrder = d2.m_stickyClipOrder;
  50. if (d2StickyOrder == 0)
  51. d2StickyOrder = -9999999.0;
  52. if (d1StickyOrder != d2StickyOrder)
  53. return d1StickyOrder > d2StickyOrder;
  54. if (d1.m_bIsGroup != d2.m_bIsGroup)
  55. return d1.m_bIsGroup < d2.m_bIsGroup;
  56. return d1.m_clipOrder > d2.m_clipOrder;
  57. }
  58. static bool GroupSortDesc(const CMainTable& d1, const CMainTable& d2)
  59. {
  60. double d1StickyOrder = d1.m_stickyClipGroupOrder;
  61. if (d1StickyOrder == 0)
  62. d1StickyOrder = -9999999.0;
  63. double d2StickyOrder = d2.m_stickyClipGroupOrder;
  64. if (d2StickyOrder == 0)
  65. d2StickyOrder = -9999999.0;
  66. if (d1StickyOrder != d2StickyOrder)
  67. return d1StickyOrder > d2StickyOrder;
  68. if (d1.m_bIsGroup != d2.m_bIsGroup)
  69. return d1.m_bIsGroup < d2.m_bIsGroup;
  70. return d1.m_clipGroupOrder > d2.m_clipGroupOrder;
  71. }
  72. };
  73. typedef std::map < int, CMainTable > MainTypeMap;
  74. typedef std::map < int, CClipFormatQListCtrl > CF_DibTypeMap;
  75. /////////////////////////////////////////////////////////////////////////////
  76. // CQPasteWnd window
  77. class CQPasteWnd: public CWndEx
  78. {
  79. // Construction
  80. public:
  81. CQPasteWnd();
  82. // Attributes
  83. public:
  84. // Operations
  85. public:
  86. // Overrides
  87. // ClassWizard generated virtual function overrides
  88. //{{AFX_VIRTUAL(CQPasteWnd)
  89. public:
  90. virtual BOOL Create(CRect rect, CWnd *pParentWnd);
  91. virtual BOOL PreTranslateMessage(MSG *pMsg);
  92. bool CheckActions(MSG * pMsg);
  93. //}}AFX_VIRTUAL
  94. // Implementation
  95. public:
  96. bool Add(const CString &csHeader, const CString &csText, int nID);
  97. virtual ~CQPasteWnd();
  98. void UpdateFont();
  99. //protected:
  100. CQListCtrl m_lstHeader;
  101. CAlphaBlend m_Alpha;
  102. CFont m_TitleFont;
  103. CEditWithButton m_search;
  104. CFont m_SearchFont;
  105. bool m_bHideWnd;
  106. CString m_strSQLSearch;
  107. CGroupStatic m_stGroup;
  108. CFont GroupFont;
  109. CString m_Title;
  110. CGroupTree m_GroupTree;
  111. CGdipButton m_ShowGroupsFolderBottom;
  112. CGdipButton m_BackButton;
  113. CGdipButton m_searchOptionsButton;
  114. CString m_SQL;
  115. CString m_CountSQL;
  116. long m_lRecordCount;
  117. bool m_bStopQuery;
  118. bool m_bHandleSearchTextChange;
  119. bool m_bModifersMoveActive;
  120. CQPasteWndThread m_thread;
  121. std::vector<CMainTable> m_listItems;
  122. std::list<CPoint> m_loadItems;
  123. std::list<CClipFormatQListCtrl> m_ExtraDataLoadItems;
  124. CF_DibTypeMap m_cf_dibCache;
  125. CF_DibTypeMap m_cf_rtfCache;
  126. CCriticalSection m_CritSection;
  127. CAccels m_actions;
  128. bool m_showScrollBars;
  129. int m_leftSelectedCompareId;
  130. void RefreshNc();
  131. void UpdateStatus(bool bRepaintImmediately = false); // regenerates the status (caption) text
  132. BOOL FillList(CString csSQLSearch = "");
  133. BOOL HideQPasteWindow(bool releaseFocus);
  134. BOOL ShowQPasteWindow(BOOL bFillList = TRUE);
  135. void MoveControls();
  136. void DeleteSelectedRows();
  137. BOOL OpenID(int id, CSpecialPasteOptions pasteOptions);
  138. BOOL OpenSelection(CSpecialPasteOptions pasteOptions);
  139. BOOL OpenIndex(int item);
  140. BOOL NewGroup(bool bGroupSelection = true, int parentId = -1);
  141. CString LoadDescription(int nItem);
  142. bool SaveDescription(int nItem, CString text);
  143. //Menu Items
  144. void SetLinesPerRow(int lines);
  145. void SetTransparency(int percent);
  146. void OnUpdateLinesPerRow(CCmdUI *pCmdUI, int nValue);
  147. void OnUpdateTransparency(CCmdUI *pCmdUI, int nValue);
  148. void SetMenuChecks(CMenu *pMenu);
  149. void SetSendToMenu(CMenu *pMenu, int nMenuID, int nArrayPos);
  150. BOOL SendToFriendbyPos(int nPos);
  151. bool InsertNextNRecords(int nEnd);
  152. CString GetDisplayText(int lDontAutoDelete, int lShortCut, bool bIsGroup, int lParentID, CString csText);
  153. void FillMainTable(CMainTable &table, CppSQLite3Query &q);
  154. void RunThread();
  155. void MoveSelection(bool down);
  156. void OnKeyStateUp();
  157. void SetKeyModiferState(bool bActive);
  158. void SaveWindowSize();
  159. void SelectFocusID();
  160. void HideMenuGroup(CMenu* menu, CString text);
  161. void SetSearchImages();
  162. DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  163. DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  164. BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
  165. void OnDragLeave();
  166. COleDropTarget *m_pDropTarget;
  167. bool DoAction(DWORD actionId);
  168. bool DoActionShowDescription();
  169. bool DoActionNextDescription();
  170. bool DoActionPrevDescription();
  171. bool DoActionShowMenu();
  172. bool DoActionNewGroup();
  173. bool DoActionNewGroupSelection();
  174. bool DoActionToggleFileLogging();
  175. bool DoActionToggleOutputDebugString();
  176. bool DoActionCloseWindow();
  177. bool DoActionNextTabControl();
  178. bool DoActionPrevTabControl();
  179. bool DoActionShowGroups();
  180. bool DoActionNewClip();
  181. bool DoActionEditClip();
  182. bool DoActionSelectionUp();
  183. bool DoActionSelectionDown();
  184. bool DoActionMoveFirst();
  185. bool DoActionMoveLast();
  186. bool DoActionCancelFilter();
  187. bool DoActionHomeList();
  188. bool DoActionBackGroup();
  189. bool DoActionToggleShowPersistant();
  190. bool DoActionDeleteSelected();
  191. bool DoActionPasteSelected();
  192. bool DoActionClipProperties();
  193. bool DoActionPasteSelectedPlainText();
  194. bool DoActionMoveClipToGroup();
  195. bool DoActionElevatePrivleges();
  196. bool DoShowInTaskBar();
  197. bool DoClipCompare();
  198. bool DoSelectLeftSideCompare();
  199. bool DoSelectRightSideAndDoCompare();
  200. bool DoExportToQRCode();
  201. bool DoExportToTextFile();
  202. void UpdateMenuShortCut(CCmdUI *pCmdUI, DWORD action);
  203. bool ShowProperties(int id, int row);
  204. bool DeleteClips(CClipIDs &IDs, ARRAY &Indexs);
  205. // Generated message map functions
  206. protected:
  207. //{{AFX_MSG(CQPasteWnd)
  208. DECLARE_MESSAGE_MAP()afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  209. afx_msg void OnSize(UINT nType, int cx, int cy);
  210. afx_msg void OnSetFocus(CWnd *pOldWnd);
  211. afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
  212. afx_msg void OnMenuLinesperrow1();
  213. afx_msg void OnMenuLinesperrow2();
  214. afx_msg void OnMenuLinesperrow3();
  215. afx_msg void OnMenuLinesperrow4();
  216. afx_msg void OnMenuLinesperrow5();
  217. afx_msg void OnMenuTransparency10();
  218. afx_msg void OnMenuTransparency15();
  219. afx_msg void OnMenuTransparency20();
  220. afx_msg void OnMenuTransparency25();
  221. afx_msg void OnMenuTransparency30();
  222. afx_msg void OnMenuTransparency40();
  223. afx_msg void OnMenuTransparency5();
  224. afx_msg void OnMenuTransparencyNone();
  225. afx_msg void OnRclickQuickPaste(NMHDR *pNMHDR, LRESULT *pResult);
  226. afx_msg void OnMenuDelete();
  227. afx_msg void OnMenuPositioningAtcaret();
  228. afx_msg void OnMenuPositioningAtcursor();
  229. afx_msg void OnMenuPositioningAtpreviousposition();
  230. afx_msg void OnMenuOptions();
  231. afx_msg LRESULT OnCancelFilter(WPARAM wParam, LPARAM lParam);
  232. afx_msg void OnMenuExitprogram();
  233. afx_msg void OnMenuToggleConnectCV();
  234. afx_msg void OnMenuProperties();
  235. afx_msg void OnClose();
  236. afx_msg void OnBegindrag(NMHDR *pNMHDR, LRESULT *pResult);
  237. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  238. afx_msg void GetDispInfo(NMHDR *pNMHDR, LRESULT *pResult);
  239. afx_msg void OnFindItem(NMHDR *pNMHDR, LRESULT *pResult);
  240. afx_msg void OnMenuFirsttenhotkeysUsectrlnum();
  241. afx_msg void OnMenuFirsttenhotkeysShowhotkeytext();
  242. afx_msg void OnMenuQuickoptionsAllwaysshowdescription();
  243. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionTogglesalwaysontop();
  244. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionRollupwindow();
  245. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionTogglesshowdescription();
  246. afx_msg void OnMenuQuickoptionsPromptfornewgroupnames();
  247. afx_msg void OnShowGroupsBottom();
  248. afx_msg void OnShowGroupsTop();
  249. afx_msg void OnMenuViewgroups();
  250. afx_msg void OnMenuQuickpropertiesSettoneverautodelete();
  251. afx_msg void OnMenuQuickpropertiesAutodelete();
  252. afx_msg void OnMenuQuickpropertiesRemovehotkey();
  253. afx_msg void OnMenuSenttoFriendEight();
  254. afx_msg void OnMenuSenttoFriendEleven();
  255. afx_msg void OnMenuSenttoFriendFifteen();
  256. afx_msg void OnMenuSenttoFriendFive();
  257. afx_msg void OnMenuSenttoFriendFore();
  258. afx_msg void OnMenuSenttoFriendForeteen();
  259. afx_msg void OnMenuSenttoFriendNine();
  260. afx_msg void OnMenuSenttoFriendSeven();
  261. afx_msg void OnMenuSenttoFriendSix();
  262. afx_msg void OnMenuSenttoFriendTen();
  263. afx_msg void OnMenuSenttoFriendThirteen();
  264. afx_msg void OnMenuSenttoFriendThree();
  265. afx_msg void OnMenuSenttoFriendTwelve();
  266. afx_msg void OnMenuSenttoFriendTwo();
  267. afx_msg void OnMenuSenttoFriendone();
  268. afx_msg void OnMenuSenttoPromptforip();
  269. afx_msg void OnMenuGroupsMovetogroup();
  270. afx_msg void OnMenuPasteplaintextonly();
  271. afx_msg void OnMenuHelp();
  272. afx_msg void OnMenuQuickoptionsFont();
  273. afx_msg void OnMenuQuickoptionsShowthumbnails();
  274. afx_msg void OnMenuQuickoptionsDrawrtftext();
  275. afx_msg void OnMenuQuickoptionsPasteclipafterselection();
  276. afx_msg void OnSearchEditChange();
  277. afx_msg void OnMenuQuickoptionsFindasyoutype();
  278. afx_msg void OnMenuQuickoptionsEnsureentirewindowisvisible();
  279. afx_msg void OnMenuQuickoptionsShowclipsthatareingroupsinmainlist();
  280. afx_msg void OnMenuPastehtmlasplaintext();
  281. afx_msg void OnPromptToDeleteClip();
  282. afx_msg void OnUpdateMenuNewgroup(CCmdUI *pCmdUI);
  283. afx_msg void OnUpdateMenuNewgroupselection(CCmdUI *pCmdUI);
  284. afx_msg void OnUpdateMenuAllwaysontop(CCmdUI *pCmdUI);
  285. afx_msg void OnUpdateMenuViewfulldescription(CCmdUI *pCmdUI);
  286. afx_msg void OnUpdateMenuViewgroups(CCmdUI *pCmdUI);
  287. afx_msg void OnUpdateMenuPasteplaintextonly(CCmdUI *pCmdUI);
  288. afx_msg void OnUpdateMenuDelete(CCmdUI *pCmdUI);
  289. afx_msg void OnUpdateMenuProperties(CCmdUI *pCmdUI);
  290. afx_msg void OnDestroy();
  291. afx_msg LRESULT OnListSelect(WPARAM wParam, LPARAM lParam);
  292. afx_msg LRESULT OnListEnd(WPARAM wParam, LPARAM lParam);
  293. afx_msg LRESULT OnSearch(WPARAM wParam, LPARAM lParam);
  294. afx_msg LRESULT OnDelete(WPARAM wParam, LPARAM lParam);
  295. afx_msg void OnGetToolTipText(NMHDR *pNMHDR, LRESULT *pResult);
  296. afx_msg LRESULT OnListSelect_DB_ID(WPARAM wParam, LPARAM lParam);
  297. afx_msg LRESULT OnListSelect_Index(WPARAM wParam, LPARAM lParam);
  298. afx_msg LRESULT OnRefreshView(WPARAM wParam, LPARAM lParam);
  299. afx_msg LRESULT OnReloadClipOrder(WPARAM wParam, LPARAM lParam);
  300. afx_msg LRESULT OnGroupTreeMessage(WPARAM wParam, LPARAM lParam);
  301. afx_msg LRESULT OnFillRestOfList(WPARAM wParam, LPARAM lParam);
  302. afx_msg LRESULT OnRefeshRow(WPARAM wParam, LPARAM lParam);
  303. afx_msg LRESULT OnSetListCount(WPARAM wParam, LPARAM lParam);
  304. afx_msg HBRUSH CtlColor(CDC *pDC, UINT nCtlColor);
  305. afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  306. afx_msg void OnWindowPosChanging(WINDOWPOS *lpwndpos);
  307. afx_msg void OnViewcaptionbaronRight();
  308. afx_msg void OnViewcaptionbaronBottom();
  309. afx_msg void OnViewcaptionbaronLeft();
  310. afx_msg void OnViewcaptionbaronTop();
  311. afx_msg void OnMenuAutohide();
  312. afx_msg void OnMenuViewfulldescription();
  313. afx_msg void OnMenuAllwaysontop();
  314. afx_msg void OnMenuNewGroup();
  315. afx_msg void OnMenuNewGroupSelection();
  316. afx_msg void OnBackButton();
  317. afx_msg void OnSearchDescription();
  318. afx_msg LRESULT OnUpDown(WPARAM wParam, LPARAM lParam);
  319. afx_msg LRESULT OnItemDeleted(WPARAM wParam, LPARAM lParam);
  320. LRESULT OnToolTipWndInactive(WPARAM wParam, LPARAM lParam);
  321. afx_msg void OnTimer(UINT_PTR nIDEvent);
  322. afx_msg void OnMenuExport();
  323. afx_msg void OnMenuImport();
  324. afx_msg void OnQuickpropertiesRemovequickpaste();
  325. afx_msg void OnMenuEdititem();
  326. afx_msg void OnMenuNewclip();
  327. afx_msg void OnUpdateMenuEdititem(CCmdUI *pCmdUI);
  328. afx_msg void OnUpdateMenuNewclip(CCmdUI *pCmdUI);
  329. afx_msg void CQPasteWnd::OnAddinSelect(UINT id);
  330. afx_msg LRESULT OnSelectAll(WPARAM wParam, LPARAM lParam);
  331. afx_msg LRESULT OnShowHideScrollBar(WPARAM wParam, LPARAM lParam);
  332. afx_msg void OnMenuSearchDescription();
  333. afx_msg void OnMenuSearchFullText();
  334. afx_msg void OnMenuSearchQuickPaste();
  335. afx_msg void OnMenuSimpleTextSearch();
  336. afx_msg LRESULT OnPostOptions(WPARAM wParam, LPARAM lParam);
  337. afx_msg void OnMakeTopStickyClip();
  338. afx_msg void OnMakeLastStickyClip();
  339. afx_msg void OnRemoveStickySetting();
  340. afx_msg void OnElevateAppToPasteIntoElevatedApp();
  341. afx_msg void OnMoveClipUp();
  342. public:
  343. afx_msg void OnQuickoptionsShowintaskbar();
  344. afx_msg void OnMenuViewasqrcode();
  345. afx_msg void OnExportExporttotextfile();
  346. afx_msg void OnCompareCompare();
  347. afx_msg void OnCompareSelectleftcompare();
  348. afx_msg void OnCompareCompareagainst();
  349. afx_msg void OnUpdateCompareCompare(CCmdUI *pCmdUI);
  350. afx_msg LRESULT OnShowProperties(WPARAM wParam, LPARAM lParam);
  351. afx_msg LRESULT OnNewGroup(WPARAM wParam, LPARAM lParam);
  352. afx_msg LRESULT OnDeleteId(WPARAM wParam, LPARAM lParam);
  353. afx_msg void OnMenuRegularexpressionsearch();
  354. };