QPasteWnd.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. double d2StickyOrder = d2.m_stickyClipOrder;
  48. if (d1StickyOrder != d2StickyOrder)
  49. return d1StickyOrder > d2StickyOrder;
  50. if (d1.m_bIsGroup != d2.m_bIsGroup)
  51. return d1.m_bIsGroup < d2.m_bIsGroup;
  52. return d1.m_clipOrder > d2.m_clipOrder;
  53. }
  54. static bool GroupSortDesc(const CMainTable& d1, const CMainTable& d2)
  55. {
  56. double d1StickyOrder = d1.m_stickyClipGroupOrder;
  57. double d2StickyOrder = d2.m_stickyClipGroupOrder;
  58. if (d1StickyOrder != d2StickyOrder)
  59. return d1StickyOrder > d2StickyOrder;
  60. if (d1.m_bIsGroup != d2.m_bIsGroup)
  61. return d1.m_bIsGroup < d2.m_bIsGroup;
  62. return d1.m_clipGroupOrder > d2.m_clipGroupOrder;
  63. }
  64. };
  65. typedef std::map < int, CMainTable > MainTypeMap;
  66. typedef std::map < int, CClipFormatQListCtrl > CF_DibTypeMap;
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CQPasteWnd window
  69. class CQPasteWnd: public CWndEx
  70. {
  71. // Construction
  72. public:
  73. CQPasteWnd();
  74. // Attributes
  75. public:
  76. // Operations
  77. public:
  78. // Overrides
  79. // ClassWizard generated virtual function overrides
  80. //{{AFX_VIRTUAL(CQPasteWnd)
  81. public:
  82. virtual BOOL Create(CRect rect, CWnd *pParentWnd);
  83. virtual BOOL PreTranslateMessage(MSG *pMsg);
  84. bool CheckActions(MSG * pMsg);
  85. //}}AFX_VIRTUAL
  86. // Implementation
  87. public:
  88. bool Add(const CString &csHeader, const CString &csText, int nID);
  89. virtual ~CQPasteWnd();
  90. void UpdateFont();
  91. //protected:
  92. CQListCtrl m_lstHeader;
  93. CAlphaBlend m_Alpha;
  94. CFont m_TitleFont;
  95. CEditWithButton m_search;
  96. CFont m_SearchFont;
  97. bool m_bHideWnd;
  98. CString m_strSQLSearch;
  99. CGroupStatic m_stGroup;
  100. CFont m_groupFont;
  101. CString m_Title;
  102. CGroupTree m_GroupTree;
  103. CGdipButton m_ShowGroupsFolderBottom;
  104. CGdipButton m_BackButton;
  105. CGdipButton m_searchOptionsButton;
  106. CGroupStatic m_alwaysOnToWarningStatic;
  107. CGdipButton m_systemMenu;
  108. CString m_SQL;
  109. CString m_CountSQL;
  110. long m_lRecordCount;
  111. bool m_bStopQuery;
  112. bool m_bHandleSearchTextChange;
  113. bool m_bModifersMoveActive;
  114. CQPasteWndThread m_thread;
  115. std::vector<CMainTable> m_listItems;
  116. std::list<CPoint> m_loadItems;
  117. std::list<CClipFormatQListCtrl> m_ExtraDataLoadItems;
  118. CF_DibTypeMap m_cf_dibCache;
  119. CF_DibTypeMap m_cf_rtfCache;
  120. CCriticalSection m_CritSection;
  121. CAccels m_actions;
  122. bool m_showScrollBars;
  123. int m_leftSelectedCompareId;
  124. void RefreshNc();
  125. void UpdateStatus(bool bRepaintImmediately = false); // regenerates the status (caption) text
  126. BOOL FillList(CString csSQLSearch = "");
  127. BOOL HideQPasteWindow(bool releaseFocus, bool clearSearchData = true);
  128. BOOL ShowQPasteWindow(BOOL bFillList = TRUE);
  129. void MoveControls();
  130. void DeleteSelectedRows();
  131. BOOL OpenID(int id, CSpecialPasteOptions pasteOptions);
  132. BOOL OpenSelection(CSpecialPasteOptions pasteOptions);
  133. BOOL OpenIndex(int item);
  134. BOOL NewGroup(bool bGroupSelection = true, int parentId = -1);
  135. CString LoadDescription(int nItem);
  136. bool SaveDescription(int nItem, CString text);
  137. //Menu Items
  138. void SetLinesPerRow(int lines);
  139. void SetTransparency(int percent);
  140. void OnUpdateLinesPerRow(CCmdUI *pCmdUI, int nValue);
  141. void OnUpdateTransparency(CCmdUI *pCmdUI, int nValue);
  142. void SetMenuChecks(CMenu *pMenu);
  143. void SetSendToMenu(CMenu *pMenu, int nMenuID, int nArrayPos);
  144. void SetFriendChecks(CMenu *pMenu);
  145. BOOL SendToFriendbyPos(int nPos);
  146. bool InsertNextNRecords(int nEnd);
  147. CString GetDisplayText(int lDontAutoDelete, int lShortCut, bool bIsGroup, int lParentID, CString csText);
  148. void FillMainTable(CMainTable &table, CppSQLite3Query &q);
  149. void RunThread();
  150. void MoveSelection(bool down);
  151. void OnKeyStateUp();
  152. void SetKeyModiferState(bool bActive);
  153. void SaveWindowSize();
  154. void SelectFocusID();
  155. void HideMenuGroup(CMenu* menu, CString text);
  156. void SetSearchImages();
  157. DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  158. DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  159. BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
  160. void OnDragLeave();
  161. COleDropTarget *m_pDropTarget;
  162. bool DoAction(DWORD actionId);
  163. bool DoActionShowDescription();
  164. bool DoActionNextDescription();
  165. bool DoActionPrevDescription();
  166. bool DoActionShowMenu();
  167. bool DoActionNewGroup();
  168. bool DoActionNewGroupSelection();
  169. bool DoActionToggleFileLogging();
  170. bool DoActionToggleOutputDebugString();
  171. bool DoActionCloseWindow();
  172. bool DoActionNextTabControl();
  173. bool DoActionPrevTabControl();
  174. bool DoActionShowGroups();
  175. bool DoActionNewClip();
  176. bool DoActionEditClip();
  177. bool DoActionSelectionUp();
  178. bool DoActionSelectionDown();
  179. bool DoActionMoveFirst();
  180. bool DoActionMoveLast();
  181. bool DoActionCancelFilter();
  182. bool DoActionHomeList();
  183. bool DoActionBackGroup();
  184. bool DoActionToggleShowPersistant();
  185. bool DoActionDeleteSelected();
  186. bool DoActionPasteSelected();
  187. bool DoActionClipProperties();
  188. bool DoActionPasteSelectedPlainText();
  189. bool DoActionMoveClipToGroup();
  190. bool DoActionElevatePrivleges();
  191. bool DoShowInTaskBar();
  192. bool DoClipCompare();
  193. bool DoSelectLeftSideCompare();
  194. bool DoSelectRightSideAndDoCompare();
  195. bool DoExportToQRCode();
  196. bool DoExportToTextFile();
  197. bool DoExportToGoogleTranslate();
  198. bool DoExportToBitMapFile();
  199. bool DoSaveCurrentClipboard();
  200. bool DoMoveClipDown();
  201. bool DoMoveClipUp();
  202. bool DoMoveClipTOP();
  203. bool DoFilterOnSelectedClip();
  204. bool DoPasteUpperCase();
  205. bool DoPasteLowerCase();
  206. bool DoPasteCapitalize();
  207. bool DoPasteSentenceCase();
  208. bool DoPasteRemoveLineFeeds();
  209. bool DoPastePlusAddLineFeed();
  210. bool DoPasteAddTwoLineFeeds();
  211. bool DoPasteTypoglycemia();
  212. void UpdateMenuShortCut(CCmdUI *pCmdUI, DWORD action);
  213. bool ShowProperties(int id, int row);
  214. bool DeleteClips(CClipIDs &IDs, ARRAY &Indexs);
  215. bool SyncClipDataToArrayData(CClip &clip);
  216. bool SelectIds(ARRAY &ids);
  217. void LoadShortcuts();
  218. void ShowRightClickMenu();;
  219. // Generated message map functions
  220. protected:
  221. //{{AFX_MSG(CQPasteWnd)
  222. DECLARE_MESSAGE_MAP()
  223. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  224. afx_msg void OnSize(UINT nType, int cx, int cy);
  225. afx_msg void OnSetFocus(CWnd *pOldWnd);
  226. afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
  227. afx_msg void OnMenuLinesperrow1();
  228. afx_msg void OnMenuLinesperrow2();
  229. afx_msg void OnMenuLinesperrow3();
  230. afx_msg void OnMenuLinesperrow4();
  231. afx_msg void OnMenuLinesperrow5();
  232. afx_msg void OnMenuTransparency10();
  233. afx_msg void OnMenuTransparency15();
  234. afx_msg void OnMenuTransparency20();
  235. afx_msg void OnMenuTransparency25();
  236. afx_msg void OnMenuTransparency30();
  237. afx_msg void OnMenuTransparency40();
  238. afx_msg void OnMenuTransparency5();
  239. afx_msg void OnMenuTransparencyNone();
  240. afx_msg void OnMenuDelete();
  241. afx_msg void OnMenuPositioningAtcaret();
  242. afx_msg void OnMenuPositioningAtcursor();
  243. afx_msg void OnMenuPositioningAtpreviousposition();
  244. afx_msg void OnMenuOptions();
  245. afx_msg LRESULT OnCancelFilter(WPARAM wParam, LPARAM lParam);
  246. afx_msg void OnMenuExitprogram();
  247. afx_msg void OnMenuToggleConnectCV();
  248. afx_msg void OnMenuProperties();
  249. afx_msg void OnClose();
  250. afx_msg void OnBegindrag(NMHDR *pNMHDR, LRESULT *pResult);
  251. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  252. afx_msg void GetDispInfo(NMHDR *pNMHDR, LRESULT *pResult);
  253. afx_msg void OnFindItem(NMHDR *pNMHDR, LRESULT *pResult);
  254. afx_msg void OnMenuFirsttenhotkeysUsectrlnum();
  255. afx_msg void OnMenuFirsttenhotkeysShowhotkeytext();
  256. afx_msg void OnMenuQuickoptionsAllwaysshowdescription();
  257. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionTogglesalwaysontop();
  258. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionRollupwindow();
  259. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionTogglesshowdescription();
  260. afx_msg void OnMenuQuickoptionsPromptfornewgroupnames();
  261. afx_msg void OnShowGroupsBottom();
  262. afx_msg void OnShowGroupsTop();
  263. afx_msg void OnMenuViewgroups();
  264. afx_msg void OnMenuQuickpropertiesSettoneverautodelete();
  265. afx_msg void OnMenuQuickpropertiesAutodelete();
  266. afx_msg void OnMenuQuickpropertiesRemovehotkey();
  267. afx_msg void OnMenuSenttoFriendEight();
  268. afx_msg void OnMenuSenttoFriendEleven();
  269. afx_msg void OnMenuSenttoFriendFifteen();
  270. afx_msg void OnMenuSenttoFriendFive();
  271. afx_msg void OnMenuSenttoFriendFore();
  272. afx_msg void OnMenuSenttoFriendForeteen();
  273. afx_msg void OnMenuSenttoFriendNine();
  274. afx_msg void OnMenuSenttoFriendSeven();
  275. afx_msg void OnMenuSenttoFriendSix();
  276. afx_msg void OnMenuSenttoFriendTen();
  277. afx_msg void OnMenuSenttoFriendThirteen();
  278. afx_msg void OnMenuSenttoFriendThree();
  279. afx_msg void OnMenuSenttoFriendTwelve();
  280. afx_msg void OnMenuSenttoFriendTwo();
  281. afx_msg void OnMenuSenttoFriendone();
  282. afx_msg void OnMenuSenttoPromptforip();
  283. afx_msg void OnMenuGroupsMovetogroup();
  284. afx_msg void OnMenuPasteplaintextonly();
  285. afx_msg void OnMenuHelp();
  286. afx_msg void OnMenuQuickoptionsFont();
  287. afx_msg void OnMenuQuickoptionsShowthumbnails();
  288. afx_msg void OnMenuQuickoptionsDrawrtftext();
  289. afx_msg void OnMenuQuickoptionsPasteclipafterselection();
  290. afx_msg void OnSearchEditChange();
  291. afx_msg void OnMenuQuickoptionsFindasyoutype();
  292. afx_msg void OnMenuQuickoptionsEnsureentirewindowisvisible();
  293. afx_msg void OnMenuQuickoptionsShowclipsthatareingroupsinmainlist();
  294. afx_msg void OnMenuPastehtmlasplaintext();
  295. afx_msg void OnPromptToDeleteClip();
  296. afx_msg void OnUpdateMenuNewgroup(CCmdUI *pCmdUI);
  297. afx_msg void OnUpdateMenuNewgroupselection(CCmdUI *pCmdUI);
  298. afx_msg void OnUpdateMenuAllwaysontop(CCmdUI *pCmdUI);
  299. afx_msg void OnUpdateMenuViewfulldescription(CCmdUI *pCmdUI);
  300. afx_msg void OnUpdateMenuViewgroups(CCmdUI *pCmdUI);
  301. afx_msg void OnUpdateMenuPasteplaintextonly(CCmdUI *pCmdUI);
  302. afx_msg void OnUpdateMenuDelete(CCmdUI *pCmdUI);
  303. afx_msg void OnUpdateMenuProperties(CCmdUI *pCmdUI);
  304. afx_msg void OnDestroy();
  305. afx_msg LRESULT OnSearchEnterKeyPressed(WPARAM wParam, LPARAM lParam);
  306. afx_msg LRESULT OnListEnd(WPARAM wParam, LPARAM lParam);
  307. afx_msg LRESULT OnSearch(WPARAM wParam, LPARAM lParam);
  308. afx_msg LRESULT OnDelete(WPARAM wParam, LPARAM lParam);
  309. afx_msg void OnGetToolTipText(NMHDR *pNMHDR, LRESULT *pResult);
  310. afx_msg LRESULT OnListSelect_DB_ID(WPARAM wParam, LPARAM lParam);
  311. afx_msg LRESULT OnListMoveSelectionToGroup(WPARAM wParam, LPARAM lParam);
  312. afx_msg LRESULT OnRefreshView(WPARAM wParam, LPARAM lParam);
  313. afx_msg LRESULT OnReloadClipOrder(WPARAM wParam, LPARAM lParam);
  314. afx_msg LRESULT OnGroupTreeMessage(WPARAM wParam, LPARAM lParam);
  315. afx_msg LRESULT OnFillRestOfList(WPARAM wParam, LPARAM lParam);
  316. afx_msg LRESULT OnRefeshRow(WPARAM wParam, LPARAM lParam);
  317. afx_msg LRESULT OnSetListCount(WPARAM wParam, LPARAM lParam);
  318. afx_msg HBRUSH CtlColor(CDC *pDC, UINT nCtlColor);
  319. afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  320. afx_msg void OnWindowPosChanging(WINDOWPOS *lpwndpos);
  321. afx_msg void OnViewcaptionbaronRight();
  322. afx_msg void OnViewcaptionbaronBottom();
  323. afx_msg void OnViewcaptionbaronLeft();
  324. afx_msg void OnViewcaptionbaronTop();
  325. afx_msg void OnMenuAutohide();
  326. afx_msg void OnMenuViewfulldescription();
  327. afx_msg void OnMenuAllwaysontop();
  328. afx_msg void OnMenuNewGroup();
  329. afx_msg void OnMenuNewGroupSelection();
  330. afx_msg void OnBackButton();
  331. afx_msg void OnSystemButton();
  332. afx_msg void OnSearchDescription();
  333. afx_msg LRESULT OnUpDown(WPARAM wParam, LPARAM lParam);
  334. afx_msg LRESULT OnItemDeleted(WPARAM wParam, LPARAM lParam);
  335. LRESULT OnToolTipWndInactive(WPARAM wParam, LPARAM lParam);
  336. afx_msg void OnTimer(UINT_PTR nIDEvent);
  337. afx_msg void OnMenuExport();
  338. afx_msg void OnMenuImport();
  339. afx_msg void OnQuickpropertiesRemovequickpaste();
  340. afx_msg void OnMenuEdititem();
  341. afx_msg void OnMenuNewclip();
  342. afx_msg void OnUpdateMenuEdititem(CCmdUI *pCmdUI);
  343. afx_msg void OnUpdateMenuNewclip(CCmdUI *pCmdUI);
  344. afx_msg void CQPasteWnd::OnAddinSelect(UINT id);
  345. afx_msg LRESULT OnSelectAll(WPARAM wParam, LPARAM lParam);
  346. afx_msg LRESULT OnShowHideScrollBar(WPARAM wParam, LPARAM lParam);
  347. afx_msg void OnMenuSearchDescription();
  348. afx_msg void OnMenuSearchFullText();
  349. afx_msg void OnMenuSearchQuickPaste();
  350. afx_msg void OnMenuSimpleTextSearch();
  351. afx_msg LRESULT OnPostOptions(WPARAM wParam, LPARAM lParam);
  352. afx_msg void OnMakeTopStickyClip();
  353. afx_msg void OnMakeLastStickyClip();
  354. afx_msg void OnRemoveStickySetting();
  355. afx_msg void OnElevateAppToPasteIntoElevatedApp();
  356. public:
  357. afx_msg void OnQuickoptionsShowintaskbar();
  358. afx_msg void OnMenuViewasqrcode();
  359. afx_msg void OnExportExporttotextfile();
  360. afx_msg void OnCompareCompare();
  361. afx_msg void OnCompareSelectleftcompare();
  362. afx_msg void OnCompareCompareagainst();
  363. afx_msg void OnUpdateCompareCompare(CCmdUI *pCmdUI);
  364. afx_msg LRESULT OnShowProperties(WPARAM wParam, LPARAM lParam);
  365. afx_msg LRESULT OnNewGroup(WPARAM wParam, LPARAM lParam);
  366. afx_msg LRESULT OnDeleteId(WPARAM wParam, LPARAM lParam);
  367. afx_msg void OnMenuRegularexpressionsearch();
  368. afx_msg void OnImportExporttogoogletranslate();
  369. afx_msg void OnUpdateImportExporttogoogletranslate(CCmdUI *pCmdUI);
  370. afx_msg void OnImportExportclipBitmap();
  371. afx_msg void OnUpdateImportExportclipBitmap(CCmdUI *pCmdUI);
  372. afx_msg void OnMenuWildcardsearch();
  373. afx_msg void OnMenuSavecurrentclipboard();
  374. afx_msg void OnUpdateMenuSavecurrentclipboard(CCmdUI *pCmdUI);
  375. afx_msg void OnCliporderMoveup();
  376. afx_msg void OnUpdateCliporderMoveup(CCmdUI *pCmdUI);
  377. afx_msg void OnCliporderMovedown();
  378. afx_msg void OnUpdateCliporderMovedown(CCmdUI *pCmdUI);
  379. afx_msg void OnCliporderMovetotop();
  380. afx_msg void OnUpdateCliporderMovetotop(CCmdUI *pCmdUI);
  381. afx_msg void OnMenuFilteron();
  382. afx_msg void OnUpdateMenuFilteron(CCmdUI *pCmdUI);
  383. afx_msg void OnAlwaysOnTopClicked();
  384. //afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  385. afx_msg void OnSpecialpasteUppercase();
  386. afx_msg void OnUpdateSpecialpasteUppercase(CCmdUI *pCmdUI);
  387. afx_msg void OnSpecialpasteLowercase();
  388. afx_msg void OnUpdateSpecialpasteLowercase(CCmdUI *pCmdUI);
  389. afx_msg void OnSpecialpasteCapitalize();
  390. afx_msg void OnUpdateSpecialpasteCapitalize(CCmdUI *pCmdUI);
  391. afx_msg void OnSpecialpasteSentence();
  392. afx_msg void OnUpdateSpecialpasteSentence(CCmdUI *pCmdUI);
  393. afx_msg void OnSpecialpasteRemovelinefeeds();
  394. afx_msg void OnUpdateSpecialpasteRemovelinefeeds(CCmdUI *pCmdUI);
  395. afx_msg void OnSpecialpastePaste();
  396. afx_msg void OnUpdateSpecialpastePaste(CCmdUI *pCmdUI);
  397. afx_msg void OnSpecialpastePaste32919();
  398. afx_msg void OnUpdateSpecialpastePaste32919(CCmdUI *pCmdUI);
  399. afx_msg void OnSpecialpasteTypoglycemia();
  400. afx_msg void OnUpdateSpecialpasteTypoglycemia(CCmdUI *pCmdUI);
  401. afx_msg void OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult);
  402. afx_msg void OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult);
  403. afx_msg void OnNMRClickList1(NMHDR *pNMHDR, LRESULT *pResult);
  404. afx_msg void OnNMRDblclkList1(NMHDR *pNMHDR, LRESULT *pResult);
  405. };