QPasteWnd.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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 GroupFont;
  101. CString m_Title;
  102. CGroupTree m_GroupTree;
  103. CGdipButton m_ShowGroupsFolderBottom;
  104. CGdipButton m_BackButton;
  105. CGdipButton m_searchOptionsButton;
  106. CString m_SQL;
  107. CString m_CountSQL;
  108. long m_lRecordCount;
  109. bool m_bStopQuery;
  110. bool m_bHandleSearchTextChange;
  111. bool m_bModifersMoveActive;
  112. CQPasteWndThread m_thread;
  113. std::vector<CMainTable> m_listItems;
  114. std::list<CPoint> m_loadItems;
  115. std::list<CClipFormatQListCtrl> m_ExtraDataLoadItems;
  116. CF_DibTypeMap m_cf_dibCache;
  117. CF_DibTypeMap m_cf_rtfCache;
  118. CCriticalSection m_CritSection;
  119. CAccels m_actions;
  120. bool m_showScrollBars;
  121. int m_leftSelectedCompareId;
  122. void RefreshNc();
  123. void UpdateStatus(bool bRepaintImmediately = false); // regenerates the status (caption) text
  124. BOOL FillList(CString csSQLSearch = "");
  125. BOOL HideQPasteWindow(bool releaseFocus, bool clearSearchData = true);
  126. BOOL ShowQPasteWindow(BOOL bFillList = TRUE);
  127. void MoveControls();
  128. void DeleteSelectedRows();
  129. BOOL OpenID(int id, CSpecialPasteOptions pasteOptions);
  130. BOOL OpenSelection(CSpecialPasteOptions pasteOptions);
  131. BOOL OpenIndex(int item);
  132. BOOL NewGroup(bool bGroupSelection = true, int parentId = -1);
  133. CString LoadDescription(int nItem);
  134. bool SaveDescription(int nItem, CString text);
  135. //Menu Items
  136. void SetLinesPerRow(int lines);
  137. void SetTransparency(int percent);
  138. void OnUpdateLinesPerRow(CCmdUI *pCmdUI, int nValue);
  139. void OnUpdateTransparency(CCmdUI *pCmdUI, int nValue);
  140. void SetMenuChecks(CMenu *pMenu);
  141. void SetSendToMenu(CMenu *pMenu, int nMenuID, int nArrayPos);
  142. BOOL SendToFriendbyPos(int nPos);
  143. bool InsertNextNRecords(int nEnd);
  144. CString GetDisplayText(int lDontAutoDelete, int lShortCut, bool bIsGroup, int lParentID, CString csText);
  145. void FillMainTable(CMainTable &table, CppSQLite3Query &q);
  146. void RunThread();
  147. void MoveSelection(bool down);
  148. void OnKeyStateUp();
  149. void SetKeyModiferState(bool bActive);
  150. void SaveWindowSize();
  151. void SelectFocusID();
  152. void HideMenuGroup(CMenu* menu, CString text);
  153. void SetSearchImages();
  154. DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  155. DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  156. BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
  157. void OnDragLeave();
  158. COleDropTarget *m_pDropTarget;
  159. bool DoAction(DWORD actionId);
  160. bool DoActionShowDescription();
  161. bool DoActionNextDescription();
  162. bool DoActionPrevDescription();
  163. bool DoActionShowMenu();
  164. bool DoActionNewGroup();
  165. bool DoActionNewGroupSelection();
  166. bool DoActionToggleFileLogging();
  167. bool DoActionToggleOutputDebugString();
  168. bool DoActionCloseWindow();
  169. bool DoActionNextTabControl();
  170. bool DoActionPrevTabControl();
  171. bool DoActionShowGroups();
  172. bool DoActionNewClip();
  173. bool DoActionEditClip();
  174. bool DoActionSelectionUp();
  175. bool DoActionSelectionDown();
  176. bool DoActionMoveFirst();
  177. bool DoActionMoveLast();
  178. bool DoActionCancelFilter();
  179. bool DoActionHomeList();
  180. bool DoActionBackGroup();
  181. bool DoActionToggleShowPersistant();
  182. bool DoActionDeleteSelected();
  183. bool DoActionPasteSelected();
  184. bool DoActionClipProperties();
  185. bool DoActionPasteSelectedPlainText();
  186. bool DoActionMoveClipToGroup();
  187. bool DoActionElevatePrivleges();
  188. bool DoShowInTaskBar();
  189. bool DoClipCompare();
  190. bool DoSelectLeftSideCompare();
  191. bool DoSelectRightSideAndDoCompare();
  192. bool DoExportToQRCode();
  193. bool DoExportToTextFile();
  194. bool DoExportToGoogleTranslate();
  195. bool DoExportToBitMapFile();
  196. void UpdateMenuShortCut(CCmdUI *pCmdUI, DWORD action);
  197. bool ShowProperties(int id, int row);
  198. bool DeleteClips(CClipIDs &IDs, ARRAY &Indexs);
  199. // Generated message map functions
  200. protected:
  201. //{{AFX_MSG(CQPasteWnd)
  202. DECLARE_MESSAGE_MAP()afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  203. afx_msg void OnSize(UINT nType, int cx, int cy);
  204. afx_msg void OnSetFocus(CWnd *pOldWnd);
  205. afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
  206. afx_msg void OnMenuLinesperrow1();
  207. afx_msg void OnMenuLinesperrow2();
  208. afx_msg void OnMenuLinesperrow3();
  209. afx_msg void OnMenuLinesperrow4();
  210. afx_msg void OnMenuLinesperrow5();
  211. afx_msg void OnMenuTransparency10();
  212. afx_msg void OnMenuTransparency15();
  213. afx_msg void OnMenuTransparency20();
  214. afx_msg void OnMenuTransparency25();
  215. afx_msg void OnMenuTransparency30();
  216. afx_msg void OnMenuTransparency40();
  217. afx_msg void OnMenuTransparency5();
  218. afx_msg void OnMenuTransparencyNone();
  219. afx_msg void OnRclickQuickPaste(NMHDR *pNMHDR, LRESULT *pResult);
  220. afx_msg void OnMenuDelete();
  221. afx_msg void OnMenuPositioningAtcaret();
  222. afx_msg void OnMenuPositioningAtcursor();
  223. afx_msg void OnMenuPositioningAtpreviousposition();
  224. afx_msg void OnMenuOptions();
  225. afx_msg LRESULT OnCancelFilter(WPARAM wParam, LPARAM lParam);
  226. afx_msg void OnMenuExitprogram();
  227. afx_msg void OnMenuToggleConnectCV();
  228. afx_msg void OnMenuProperties();
  229. afx_msg void OnClose();
  230. afx_msg void OnBegindrag(NMHDR *pNMHDR, LRESULT *pResult);
  231. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  232. afx_msg void GetDispInfo(NMHDR *pNMHDR, LRESULT *pResult);
  233. afx_msg void OnFindItem(NMHDR *pNMHDR, LRESULT *pResult);
  234. afx_msg void OnMenuFirsttenhotkeysUsectrlnum();
  235. afx_msg void OnMenuFirsttenhotkeysShowhotkeytext();
  236. afx_msg void OnMenuQuickoptionsAllwaysshowdescription();
  237. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionTogglesalwaysontop();
  238. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionRollupwindow();
  239. afx_msg void OnMenuQuickoptionsDoubleclickingoncaptionTogglesshowdescription();
  240. afx_msg void OnMenuQuickoptionsPromptfornewgroupnames();
  241. afx_msg void OnShowGroupsBottom();
  242. afx_msg void OnShowGroupsTop();
  243. afx_msg void OnMenuViewgroups();
  244. afx_msg void OnMenuQuickpropertiesSettoneverautodelete();
  245. afx_msg void OnMenuQuickpropertiesAutodelete();
  246. afx_msg void OnMenuQuickpropertiesRemovehotkey();
  247. afx_msg void OnMenuSenttoFriendEight();
  248. afx_msg void OnMenuSenttoFriendEleven();
  249. afx_msg void OnMenuSenttoFriendFifteen();
  250. afx_msg void OnMenuSenttoFriendFive();
  251. afx_msg void OnMenuSenttoFriendFore();
  252. afx_msg void OnMenuSenttoFriendForeteen();
  253. afx_msg void OnMenuSenttoFriendNine();
  254. afx_msg void OnMenuSenttoFriendSeven();
  255. afx_msg void OnMenuSenttoFriendSix();
  256. afx_msg void OnMenuSenttoFriendTen();
  257. afx_msg void OnMenuSenttoFriendThirteen();
  258. afx_msg void OnMenuSenttoFriendThree();
  259. afx_msg void OnMenuSenttoFriendTwelve();
  260. afx_msg void OnMenuSenttoFriendTwo();
  261. afx_msg void OnMenuSenttoFriendone();
  262. afx_msg void OnMenuSenttoPromptforip();
  263. afx_msg void OnMenuGroupsMovetogroup();
  264. afx_msg void OnMenuPasteplaintextonly();
  265. afx_msg void OnMenuHelp();
  266. afx_msg void OnMenuQuickoptionsFont();
  267. afx_msg void OnMenuQuickoptionsShowthumbnails();
  268. afx_msg void OnMenuQuickoptionsDrawrtftext();
  269. afx_msg void OnMenuQuickoptionsPasteclipafterselection();
  270. afx_msg void OnSearchEditChange();
  271. afx_msg void OnMenuQuickoptionsFindasyoutype();
  272. afx_msg void OnMenuQuickoptionsEnsureentirewindowisvisible();
  273. afx_msg void OnMenuQuickoptionsShowclipsthatareingroupsinmainlist();
  274. afx_msg void OnMenuPastehtmlasplaintext();
  275. afx_msg void OnPromptToDeleteClip();
  276. afx_msg void OnUpdateMenuNewgroup(CCmdUI *pCmdUI);
  277. afx_msg void OnUpdateMenuNewgroupselection(CCmdUI *pCmdUI);
  278. afx_msg void OnUpdateMenuAllwaysontop(CCmdUI *pCmdUI);
  279. afx_msg void OnUpdateMenuViewfulldescription(CCmdUI *pCmdUI);
  280. afx_msg void OnUpdateMenuViewgroups(CCmdUI *pCmdUI);
  281. afx_msg void OnUpdateMenuPasteplaintextonly(CCmdUI *pCmdUI);
  282. afx_msg void OnUpdateMenuDelete(CCmdUI *pCmdUI);
  283. afx_msg void OnUpdateMenuProperties(CCmdUI *pCmdUI);
  284. afx_msg void OnDestroy();
  285. afx_msg LRESULT OnListSelect(WPARAM wParam, LPARAM lParam);
  286. afx_msg LRESULT OnListEnd(WPARAM wParam, LPARAM lParam);
  287. afx_msg LRESULT OnSearch(WPARAM wParam, LPARAM lParam);
  288. afx_msg LRESULT OnDelete(WPARAM wParam, LPARAM lParam);
  289. afx_msg void OnGetToolTipText(NMHDR *pNMHDR, LRESULT *pResult);
  290. afx_msg LRESULT OnListSelect_DB_ID(WPARAM wParam, LPARAM lParam);
  291. afx_msg LRESULT OnListSelect_Index(WPARAM wParam, LPARAM lParam);
  292. afx_msg LRESULT OnRefreshView(WPARAM wParam, LPARAM lParam);
  293. afx_msg LRESULT OnReloadClipOrder(WPARAM wParam, LPARAM lParam);
  294. afx_msg LRESULT OnGroupTreeMessage(WPARAM wParam, LPARAM lParam);
  295. afx_msg LRESULT OnFillRestOfList(WPARAM wParam, LPARAM lParam);
  296. afx_msg LRESULT OnRefeshRow(WPARAM wParam, LPARAM lParam);
  297. afx_msg LRESULT OnSetListCount(WPARAM wParam, LPARAM lParam);
  298. afx_msg HBRUSH CtlColor(CDC *pDC, UINT nCtlColor);
  299. afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point);
  300. afx_msg void OnWindowPosChanging(WINDOWPOS *lpwndpos);
  301. afx_msg void OnViewcaptionbaronRight();
  302. afx_msg void OnViewcaptionbaronBottom();
  303. afx_msg void OnViewcaptionbaronLeft();
  304. afx_msg void OnViewcaptionbaronTop();
  305. afx_msg void OnMenuAutohide();
  306. afx_msg void OnMenuViewfulldescription();
  307. afx_msg void OnMenuAllwaysontop();
  308. afx_msg void OnMenuNewGroup();
  309. afx_msg void OnMenuNewGroupSelection();
  310. afx_msg void OnBackButton();
  311. afx_msg void OnSearchDescription();
  312. afx_msg LRESULT OnUpDown(WPARAM wParam, LPARAM lParam);
  313. afx_msg LRESULT OnItemDeleted(WPARAM wParam, LPARAM lParam);
  314. LRESULT OnToolTipWndInactive(WPARAM wParam, LPARAM lParam);
  315. afx_msg void OnTimer(UINT_PTR nIDEvent);
  316. afx_msg void OnMenuExport();
  317. afx_msg void OnMenuImport();
  318. afx_msg void OnQuickpropertiesRemovequickpaste();
  319. afx_msg void OnMenuEdititem();
  320. afx_msg void OnMenuNewclip();
  321. afx_msg void OnUpdateMenuEdititem(CCmdUI *pCmdUI);
  322. afx_msg void OnUpdateMenuNewclip(CCmdUI *pCmdUI);
  323. afx_msg void CQPasteWnd::OnAddinSelect(UINT id);
  324. afx_msg LRESULT OnSelectAll(WPARAM wParam, LPARAM lParam);
  325. afx_msg LRESULT OnShowHideScrollBar(WPARAM wParam, LPARAM lParam);
  326. afx_msg void OnMenuSearchDescription();
  327. afx_msg void OnMenuSearchFullText();
  328. afx_msg void OnMenuSearchQuickPaste();
  329. afx_msg void OnMenuSimpleTextSearch();
  330. afx_msg LRESULT OnPostOptions(WPARAM wParam, LPARAM lParam);
  331. afx_msg void OnMakeTopStickyClip();
  332. afx_msg void OnMakeLastStickyClip();
  333. afx_msg void OnRemoveStickySetting();
  334. afx_msg void OnElevateAppToPasteIntoElevatedApp();
  335. afx_msg void OnMoveClipUp();
  336. public:
  337. afx_msg void OnQuickoptionsShowintaskbar();
  338. afx_msg void OnMenuViewasqrcode();
  339. afx_msg void OnExportExporttotextfile();
  340. afx_msg void OnCompareCompare();
  341. afx_msg void OnCompareSelectleftcompare();
  342. afx_msg void OnCompareCompareagainst();
  343. afx_msg void OnUpdateCompareCompare(CCmdUI *pCmdUI);
  344. afx_msg LRESULT OnShowProperties(WPARAM wParam, LPARAM lParam);
  345. afx_msg LRESULT OnNewGroup(WPARAM wParam, LPARAM lParam);
  346. afx_msg LRESULT OnDeleteId(WPARAM wParam, LPARAM lParam);
  347. afx_msg void OnMenuRegularexpressionsearch();
  348. afx_msg void OnImportExporttogoogletranslate();
  349. afx_msg void OnUpdateImportExporttogoogletranslate(CCmdUI *pCmdUI);
  350. afx_msg void OnImportExportclipBitmap();
  351. afx_msg void OnUpdateImportExportclipBitmap(CCmdUI *pCmdUI);
  352. afx_msg void OnMenuWildcardsearch();
  353. };