SymbolEdit.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. // AeroEdit.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "SymbolEdit.h"
  5. #include "cp_main.h"
  6. #include "QListCtrl.h"
  7. #include "Shared\TextConvert.h"
  8. // CSymbolEdit
  9. #define RANGE_START 3000
  10. #define CLEAR_LIST 3050
  11. #define LIST_MAX_COUNT 50
  12. IMPLEMENT_DYNAMIC(CSymbolEdit, CEdit)
  13. CSymbolEdit::CSymbolEdit() :
  14. m_hSymbolIcon(NULL),
  15. m_bInternalIcon(false),
  16. m_colorPromptText(RGB(127, 127, 127))
  17. {
  18. m_fontPrompt.CreateFont(
  19. 16, // nHeight
  20. 0, // nWidth
  21. 0, // nEscapement
  22. 0, // nOrientation
  23. FW_NORMAL, // nWeight
  24. TRUE, // bItalic
  25. FALSE, // bUnderline
  26. 0, // cStrikeOut
  27. DEFAULT_CHARSET, // nCharSet
  28. OUT_DEFAULT_PRECIS, // nOutPrecision
  29. CLIP_DEFAULT_PRECIS, // nClipPrecision
  30. DEFAULT_QUALITY, // nQuality
  31. DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
  32. _T("Calibri"));
  33. m_mouseDownOnSearches = false;
  34. m_mouseHoveringOverSearches = false;
  35. m_mouseDownOnClose = false;
  36. m_mouseHoveringOverClose = false;
  37. m_windowDpi = NULL;
  38. //m_searchButton.LoadStdImageDPI(Search_16, Search_20, Search_24, Search_32, _T("PNG"));
  39. }
  40. CSymbolEdit::~CSymbolEdit()
  41. {
  42. DestroyIcon();
  43. }
  44. BEGIN_MESSAGE_MAP(CSymbolEdit, CEdit)
  45. ON_WM_PAINT()
  46. ON_MESSAGE(WM_SETFONT, OnSetFont)
  47. //ON_MESSAGE(WM_EXITMENULOOP, OnMenuExit)
  48. ON_WM_CTLCOLOR_REFLECT()
  49. ON_WM_SETFOCUS()
  50. ON_WM_KILLFOCUS()
  51. ON_WM_SETCURSOR()
  52. ON_WM_LBUTTONUP()
  53. ON_WM_LBUTTONDOWN()
  54. ON_WM_MOUSEMOVE()
  55. ON_COMMAND_RANGE(RANGE_START, (RANGE_START+ LIST_MAX_COUNT), OnSelectSearchString)
  56. ON_WM_EXITSIZEMOVE()
  57. END_MESSAGE_MAP()
  58. BOOL CSymbolEdit::PreTranslateMessage(MSG* pMsg)
  59. {
  60. // TODO: Add your specialized code here and/or call the base class
  61. // Intercept Ctrl + Z (Undo), Ctrl + X (Cut), Ctrl + C (Copy), Ctrl + V (Paste) and Ctrl + A (Select All)
  62. // before CEdit base class gets a hold of them.
  63. if (pMsg->message == WM_KEYDOWN &&
  64. CONTROL_PRESSED)
  65. {
  66. switch (pMsg->wParam)
  67. {
  68. case 'Z':
  69. Undo();
  70. return TRUE;
  71. case 'X':
  72. Cut();
  73. return TRUE;
  74. case 'C':
  75. {
  76. int startChar;
  77. int endChar;
  78. this->GetSel(startChar, endChar);
  79. if (startChar == endChar)
  80. {
  81. CWnd *pWnd = GetParent();
  82. if (pWnd)
  83. {
  84. pWnd->SendMessage(NM_COPY_CLIP, pMsg->wParam, pMsg->lParam);
  85. }
  86. }
  87. else
  88. {
  89. Copy();
  90. }
  91. }
  92. return TRUE;
  93. case 'V':
  94. Paste();
  95. return TRUE;
  96. case 'A':
  97. SetSel(0, -1);
  98. return TRUE;
  99. }
  100. }
  101. switch (pMsg->message)
  102. {
  103. case WM_KEYDOWN:
  104. {
  105. if (pMsg->wParam == VK_RETURN)
  106. {
  107. CWnd *pWnd = GetParent();
  108. if (pWnd)
  109. {
  110. if (g_Opt.m_bFindAsYouType)
  111. {
  112. pWnd->SendMessage(NM_SEARCH_ENTER_PRESSED, 0, 0);
  113. }
  114. else
  115. {
  116. //Send a message to the parent to refill the lb from the search
  117. pWnd->PostMessage(CB_SEARCH, 0, 0);
  118. }
  119. AddToSearchHistory();
  120. }
  121. return TRUE;
  122. }
  123. else if (pMsg->wParam == VK_DOWN &&
  124. ((GetKeyState(VK_CONTROL) & 0x8000) || ((GetKeyState(VK_CONTROL) & 0x8000) && (GetKeyState(VK_SHIFT) & 0x8000))))
  125. {
  126. if (ShowSearchHistoryMenu())
  127. {
  128. return TRUE;
  129. }
  130. }
  131. else if (pMsg->wParam == VK_DOWN ||
  132. pMsg->wParam == VK_UP ||
  133. pMsg->wParam == VK_PRIOR ||
  134. pMsg->wParam == VK_NEXT)
  135. {
  136. CWnd *pWnd = GetParent();
  137. if (pWnd)
  138. {
  139. pWnd->SendMessage(CB_UPDOWN, pMsg->wParam, pMsg->lParam);
  140. return TRUE;
  141. }
  142. }
  143. else if (pMsg->wParam == VK_DELETE)
  144. {
  145. int startChar;
  146. int endChar;
  147. this->GetSel(startChar, endChar);
  148. CString cs;
  149. this->GetWindowText(cs);
  150. //if selection is at the end then forward this on to the parent to delete the selected clip
  151. if(startChar == cs.GetLength() &&
  152. endChar == cs.GetLength())
  153. {
  154. CWnd *pWnd = GetParent();
  155. if (pWnd)
  156. {
  157. pWnd->SendMessage(NM_DELETE, pMsg->wParam, pMsg->lParam);
  158. return TRUE;
  159. }
  160. }
  161. }
  162. break;
  163. }
  164. }
  165. return CEdit::PreTranslateMessage(pMsg);
  166. }
  167. CString CSymbolEdit::SavePastSearches()
  168. {
  169. TiXmlDocument doc;
  170. TiXmlElement* outer = new TiXmlElement("PastSearches");
  171. doc.LinkEndChild(outer);
  172. int count = m_searches.GetCount();
  173. for (int i = 0; i < count; i++)
  174. {
  175. TiXmlElement* searchElement = new TiXmlElement("Search");
  176. CStringA t;
  177. CTextConvert::ConvertToUTF8(m_searches[i], t);
  178. searchElement->SetAttribute("text", t);
  179. outer->LinkEndChild(searchElement);
  180. }
  181. TiXmlPrinter printer;
  182. printer.SetLineBreak("");
  183. doc.Accept(&printer);
  184. CString cs = printer.CStr();
  185. return cs;
  186. }
  187. void CSymbolEdit::LoadPastSearches(CString values)
  188. {
  189. m_searches.RemoveAll();
  190. TiXmlDocument doc;
  191. CStringA xmlA;
  192. CTextConvert::ConvertToUTF8(values, xmlA);
  193. doc.Parse(xmlA);
  194. TiXmlElement *ItemHeader = doc.FirstChildElement("PastSearches");
  195. if (ItemHeader != NULL)
  196. {
  197. TiXmlElement *ItemElement = ItemHeader->FirstChildElement();
  198. while (ItemElement)
  199. {
  200. CString item = ItemElement->Attribute("text");
  201. m_searches.Add(item);
  202. ItemElement = ItemElement->NextSiblingElement();
  203. }
  204. }
  205. }
  206. void CSymbolEdit::AddToSearchHistory()
  207. {
  208. CString cs;
  209. this->GetWindowText(cs);
  210. if (cs != _T(""))
  211. {
  212. if (m_searches.GetCount() >= LIST_MAX_COUNT)
  213. {
  214. m_searches.RemoveAt(0);
  215. }
  216. bool existing = false;
  217. int count = m_searches.GetCount();
  218. for (int i = 0; i < count; i++)
  219. {
  220. if (m_searches[i] == cs)
  221. {
  222. m_searches.RemoveAt(i);
  223. m_searches.Add(cs);
  224. existing = true;
  225. break;
  226. }
  227. }
  228. if (existing == false)
  229. {
  230. m_searches.Add(cs);
  231. }
  232. }
  233. }
  234. bool CSymbolEdit::ShowSearchHistoryMenu()
  235. {
  236. if (m_searches.GetCount() == 0)
  237. {
  238. return false;
  239. }
  240. CMenu cmPopUp;
  241. cmPopUp.CreatePopupMenu();
  242. int count = min(m_searches.GetCount(), LIST_MAX_COUNT);
  243. for (int i = count-1; i >= 0; i--)
  244. {
  245. CString text = m_searches[i];
  246. if (i == count - 1 &&
  247. m_lastSearchShortCut.Key > 0)
  248. {
  249. CString cmdShortcutText = CHotKey::GetHotKeyDisplayStatic(m_lastSearchShortCut.Key);
  250. if (m_lastSearchShortCut.Key2 != 0)
  251. {
  252. CString cmdShortcutText2 = CHotKey::GetHotKeyDisplayStatic(m_lastSearchShortCut.Key2);
  253. if (cmdShortcutText2.GetLength() > 0)
  254. {
  255. cmdShortcutText += _T(" - ");
  256. cmdShortcutText += cmdShortcutText2;
  257. }
  258. }
  259. text += "\t";
  260. text += cmdShortcutText;
  261. }
  262. cmPopUp.AppendMenuW(MF_STRING, (RANGE_START + i), text);
  263. }
  264. cmPopUp.AppendMenu(MF_SEPARATOR);
  265. cmPopUp.AppendMenuW(MF_STRING, CLEAR_LIST, _T("Clear List"));
  266. CRect windowRect;
  267. this->GetWindowRect(&windowRect);
  268. POINT pp;
  269. GetCursorPos(&pp);
  270. POINT x = this->GetCaretPos();
  271. ClientToScreen(&x);
  272. x.y += windowRect.Height();
  273. cmPopUp.TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, x.x, x.y, this, NULL);
  274. Invalidate();
  275. return true;
  276. }
  277. void CSymbolEdit::DestroyIcon()
  278. {
  279. // if icon was loaded internally, destroy it
  280. if (m_bInternalIcon || m_hSymbolIcon != NULL)
  281. ::DestroyIcon(m_hSymbolIcon);
  282. }
  283. void CSymbolEdit::PreSubclassWindow()
  284. {
  285. RecalcLayout();
  286. }
  287. void CSymbolEdit::SetSymbolIcon(HICON hIcon, BOOL redraw)
  288. {
  289. DestroyIcon();
  290. m_hSymbolIcon = hIcon;
  291. // icon was not loaded internally
  292. m_bInternalIcon = false;
  293. RecalcLayout();
  294. if (redraw)
  295. Invalidate(TRUE);
  296. }
  297. void CSymbolEdit::SetSymbolIcon(UINT id, BOOL redraw)
  298. {
  299. DestroyIcon();
  300. m_hSymbolIcon = (HICON)::LoadImage(
  301. AfxGetResourceHandle(),
  302. MAKEINTRESOURCE(id),
  303. IMAGE_ICON,
  304. 16,
  305. 16,
  306. LR_DEFAULTCOLOR | LR_LOADTRANSPARENT);
  307. ASSERT(m_hSymbolIcon != NULL);
  308. // icon was loaded internally
  309. m_bInternalIcon = true;
  310. RecalcLayout();
  311. if (redraw)
  312. Invalidate(TRUE);
  313. }
  314. void CSymbolEdit::SetPromptText(CString text, BOOL redraw)
  315. {
  316. m_strPromptText = text;
  317. if (redraw)
  318. Invalidate(TRUE);
  319. }
  320. void CSymbolEdit::SetPromptText(LPCTSTR szText, BOOL redraw)
  321. {
  322. m_strPromptText = szText;
  323. if (redraw)
  324. Invalidate(TRUE);
  325. }
  326. void CSymbolEdit::SetPromptTextColor(COLORREF color, BOOL redraw)
  327. {
  328. m_colorPromptText = color;
  329. if (redraw)
  330. Invalidate(TRUE);
  331. }
  332. void CSymbolEdit::SetPromptFont(CFont& font, BOOL redraw)
  333. {
  334. LOGFONT lf;
  335. memset(&lf, 0, sizeof(LOGFONT));
  336. font.GetLogFont(&lf);
  337. SetPromptFont(&lf);
  338. if (redraw)
  339. Invalidate(TRUE);
  340. }
  341. void CSymbolEdit::SetPromptFont(const LOGFONT* lpLogFont, BOOL redraw)
  342. {
  343. m_fontPrompt.DeleteObject();
  344. m_fontPrompt.CreateFontIndirect(lpLogFont);
  345. if (redraw)
  346. Invalidate(TRUE);
  347. }
  348. void CSymbolEdit::RecalcLayout()
  349. {
  350. int width = GetSystemMetrics(SM_CXSMICON);
  351. if (m_hSymbolIcon)
  352. {
  353. DWORD dwMargins = GetMargins();
  354. SetMargins(LOWORD(dwMargins), width + 6);
  355. }
  356. else
  357. {
  358. if (m_windowDpi != NULL)
  359. {
  360. SetMargins(4, m_windowDpi->ScaleX(34));
  361. }
  362. }
  363. }
  364. // CSymbolEdit message handlers
  365. void CSymbolEdit::OnPaint()
  366. {
  367. CPaintDC dc(this);
  368. CRect rect;
  369. GetClientRect(&rect);
  370. DWORD margins = GetMargins();
  371. CRect textRect(rect);
  372. textRect.left += LOWORD(margins);
  373. textRect.right -= HIWORD(margins);
  374. // Clearing the background
  375. dc.FillSolidRect(rect, GetSysColor(COLOR_WINDOW));
  376. if (m_hSymbolIcon)
  377. {
  378. // Drawing the icon
  379. int width = GetSystemMetrics(SM_CXSMICON);
  380. int height = GetSystemMetrics(SM_CYSMICON);
  381. ::DrawIconEx(
  382. dc.m_hDC,
  383. rect.right - width - 1,
  384. 1,
  385. m_hSymbolIcon,
  386. width,
  387. height,
  388. 0,
  389. NULL,
  390. DI_NORMAL);
  391. rect.left += LOWORD(margins) + 1;
  392. rect.right -= (width + 7);
  393. }
  394. else
  395. {
  396. //rect.left += (LOWORD(dwMargins) + 1);
  397. //rect.right -= (HIWORD(dwMargins) + 1);
  398. }
  399. CString text;
  400. GetWindowText(text);
  401. CFont* oldFont = NULL;
  402. //rect.top += 1;
  403. if(this == GetFocus() || text.GetLength() > 0)
  404. {
  405. dc.FillSolidRect(rect, g_Opt.m_Theme.SearchTextBoxFocusBG());
  406. oldFont = dc.SelectObject(GetFont());
  407. COLORREF oldColor = dc.GetTextColor();
  408. dc.SetTextColor(g_Opt.m_Theme.SearchTextBoxFocusText());
  409. dc.DrawText(text, textRect, DT_SINGLELINE | DT_INTERNAL | DT_EDITCONTROL | DT_NOPREFIX);
  410. dc.SelectObject(oldFont);
  411. dc.SetTextColor(oldColor);
  412. }
  413. else
  414. {
  415. dc.FillSolidRect(rect, g_Opt.m_Theme.MainWindowBG());
  416. }
  417. if (text.GetLength() == 0 && m_strPromptText.GetLength() > 0)
  418. {
  419. //if we aren't showing the close icon, then use the full space
  420. textRect.right += m_windowDpi->ScaleX(16);
  421. //textRect.right -= LOWORD(margins);
  422. oldFont = dc.SelectObject(&m_fontPrompt);
  423. COLORREF color = dc.GetTextColor();
  424. dc.SetTextColor(m_colorPromptText);
  425. dc.DrawText(m_strPromptText, textRect, DT_LEFT | DT_SINGLELINE | DT_EDITCONTROL | DT_VCENTER | DT_NOPREFIX);
  426. dc.SetTextColor(color);
  427. dc.SelectObject(oldFont);
  428. }
  429. int right = rect.right;
  430. if ((text.GetLength() > 0 || this == GetFocus()))
  431. {
  432. m_searchesButtonRect.SetRect(rect.right - m_windowDpi->ScaleX(18), 0, rect.right, rect.bottom);
  433. right = rect.right - m_windowDpi->ScaleX(18);
  434. m_searchesButton.Draw(&dc, *m_windowDpi, this, m_searchesButtonRect.left, 4, m_mouseHoveringOverSearches, m_mouseDownOnSearches);
  435. }
  436. else
  437. {
  438. m_searchesButtonRect.SetRect(0, 0, 0, 0);
  439. //m_searchButton.Draw(&dc, this, rect.right - 22, 4, false, false);
  440. }
  441. if (text.GetLength() > 0)
  442. {
  443. OutputDebugString(_T("showing close button\n"));
  444. m_closeButtonRect.SetRect(right - m_windowDpi->ScaleX(16), 0, right, rect.bottom);
  445. m_closeButton.Draw(&dc, *m_windowDpi, this, m_closeButtonRect.left, 4, m_mouseHoveringOverClose, m_mouseDownOnClose);
  446. }
  447. else
  448. {
  449. OutputDebugString(_T("not showing close button\n"));
  450. m_closeButtonRect.SetRect(0, 0, 0, 0);
  451. //m_searchButton.Draw(&dc, this, rect.right - 22, 4, false, false);
  452. }
  453. //OutputDebugString(_T("OnPaint"));
  454. }
  455. void CSymbolEdit::OnSize(UINT nType, int cx, int cy)
  456. {
  457. CEdit::OnSize(nType, cx, cy);
  458. RecalcLayout();
  459. }
  460. LRESULT CSymbolEdit::OnSetFont(WPARAM wParam, LPARAM lParam)
  461. {
  462. DefWindowProc(WM_SETFONT, wParam, lParam);
  463. RecalcLayout();
  464. return 0;
  465. }
  466. HBRUSH CSymbolEdit::CtlColor(CDC* pDC, UINT n)
  467. {
  468. if (::GetFocus() == m_hWnd)
  469. {
  470. pDC->SetTextColor(g_Opt.m_Theme.SearchTextBoxFocusText());
  471. pDC->SetBkColor(g_Opt.m_Theme.SearchTextBoxFocusBG());
  472. return CreateSolidBrush(g_Opt.m_Theme.SearchTextBoxFocusBG());
  473. }
  474. else
  475. {
  476. pDC->SetBkColor(g_Opt.m_Theme.MainWindowBG());
  477. return CreateSolidBrush(g_Opt.m_Theme.MainWindowBG());
  478. }
  479. }
  480. void CSymbolEdit::OnSetFocus(CWnd* pOldWnd)
  481. {
  482. Invalidate(FALSE);
  483. CEdit::OnSetFocus(pOldWnd);
  484. CWnd *pWnd = GetParent();
  485. if (pWnd)
  486. {
  487. if (g_Opt.m_bFindAsYouType)
  488. {
  489. pWnd->SendMessage(NM_FOCUS_ON_SEARCH, 0, 0);
  490. }
  491. }
  492. }
  493. void CSymbolEdit::OnKillFocus(CWnd* pNewWnd)
  494. {
  495. AddToSearchHistory();
  496. Invalidate(FALSE);
  497. CEdit::OnKillFocus(pNewWnd);
  498. }
  499. BOOL CSymbolEdit::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  500. {
  501. CPoint pntCursor;
  502. GetCursorPos(&pntCursor);
  503. ScreenToClient(&pntCursor);
  504. if(m_closeButtonRect.PtInRect(pntCursor))
  505. {
  506. HCURSOR h = ::LoadCursor(NULL, IDC_ARROW);
  507. ::SetCursor(h);
  508. return TRUE;
  509. }
  510. if (m_searchesButtonRect.PtInRect(pntCursor))
  511. {
  512. HCURSOR h = ::LoadCursor(NULL, IDC_ARROW);
  513. ::SetCursor(h);
  514. return TRUE;
  515. }
  516. return CEdit::OnSetCursor(pWnd, nHitTest, message);
  517. }
  518. void CSymbolEdit::OnLButtonUp(UINT nFlags, CPoint point)
  519. {
  520. if (m_mouseDownOnClose)
  521. {
  522. ReleaseCapture();
  523. InvalidateRect(m_closeButtonRect);
  524. }
  525. if (m_mouseDownOnSearches)
  526. {
  527. ReleaseCapture();
  528. InvalidateRect(m_searchesButtonRect);
  529. }
  530. m_mouseDownOnClose = false;
  531. m_mouseDownOnSearches = false;
  532. if (m_closeButtonRect.PtInRect(point))
  533. {
  534. if ((GetWindowTextLength() > 0))
  535. {
  536. CWnd *pOwner = GetOwner();
  537. if (pOwner)
  538. {
  539. pOwner->SendMessage(NM_CANCEL_SEARCH, 0, 0);
  540. }
  541. }
  542. }
  543. if (m_searchesButtonRect.PtInRect(point))
  544. {
  545. this->ShowSearchHistoryMenu();
  546. }
  547. CEdit::OnLButtonUp(nFlags, point);
  548. }
  549. void CSymbolEdit::OnLButtonDown(UINT nFlags, CPoint point)
  550. {
  551. if (m_closeButtonRect.PtInRect(point))
  552. {
  553. m_mouseDownOnClose = true;
  554. SetCapture();
  555. InvalidateRect(m_closeButtonRect);
  556. }
  557. else
  558. {
  559. m_mouseDownOnClose = false;
  560. }
  561. if (m_searchesButtonRect.PtInRect(point))
  562. {
  563. m_mouseDownOnSearches = true;
  564. SetCapture();
  565. InvalidateRect(m_searchesButtonRect);
  566. }
  567. else
  568. {
  569. m_mouseDownOnSearches = false;
  570. }
  571. CEdit::OnLButtonDown(nFlags, point);
  572. }
  573. void CSymbolEdit::OnMouseMove(UINT nFlags, CPoint point)
  574. {
  575. if (m_closeButtonRect.PtInRect(point))
  576. {
  577. if (m_mouseHoveringOverClose == false)
  578. {
  579. m_mouseHoveringOverClose = true;
  580. InvalidateRect(m_closeButtonRect);
  581. }
  582. }
  583. else if(m_mouseHoveringOverClose)
  584. {
  585. m_mouseHoveringOverClose = false;
  586. InvalidateRect(m_closeButtonRect);
  587. }
  588. if (m_searchesButtonRect.PtInRect(point))
  589. {
  590. if (m_mouseHoveringOverSearches == false)
  591. {
  592. m_mouseHoveringOverSearches = true;
  593. InvalidateRect(m_searchesButtonRect);
  594. }
  595. }
  596. else if (m_mouseHoveringOverSearches)
  597. {
  598. m_mouseHoveringOverSearches = false;
  599. InvalidateRect(m_searchesButtonRect);
  600. }
  601. CEdit::OnMouseMove(nFlags, point);
  602. }
  603. void CSymbolEdit::OnSelectSearchString(UINT idIn)
  604. {
  605. int index = idIn - RANGE_START;
  606. if (idIn == CLEAR_LIST)
  607. {
  608. m_searches.RemoveAll();
  609. }
  610. else if (index >= 0 &&
  611. index < m_searches.GetCount())
  612. {
  613. CString cs = m_searches[index];
  614. this->SetWindowTextW(cs);
  615. this->SetFocus();
  616. this->SetSel(-1);
  617. this->Invalidate();
  618. m_searches.RemoveAt(index);
  619. m_searches.Add(cs);
  620. }
  621. }
  622. bool CSymbolEdit::ApplyLastSearch()
  623. {
  624. bool ret = false;
  625. if (m_searches.GetCount() > 0)
  626. {
  627. CString cs = m_searches[m_searches.GetCount()-1];
  628. this->SetWindowTextW(cs);
  629. this->SetFocus();
  630. this->SetSel(-1);
  631. this->Invalidate();
  632. ret = true;
  633. }
  634. return ret;
  635. }
  636. void CSymbolEdit::OnDpiChanged()
  637. {
  638. SetDpiInfo(m_windowDpi);
  639. }
  640. void CSymbolEdit::SetDpiInfo(CDPI *dpi)
  641. {
  642. m_windowDpi = dpi;
  643. m_closeButton.Reset();
  644. m_closeButton.LoadStdImageDPI(m_windowDpi->GetDPIX(), search_close_16, Search_20, Search_24, Search_28, Search_32, _T("PNG"));
  645. m_searchesButton.Reset();
  646. m_searchesButton.LoadStdImageDPI(m_windowDpi->GetDPIX(), down_16, down_20, down_24, down_28, down_32, _T("PNG"));
  647. RecalcLayout();
  648. }