SymbolEdit.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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 = (int)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 = (int)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((int)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(m_windowDpi->Scale(4), m_windowDpi->Scale(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. CBrush borderBrush(g_Opt.m_Theme.SearchTextBoxFocusBorder());
  407. dc.FrameRect(rect, &borderBrush);
  408. rect.DeflateRect(1, 1, 1, 1);
  409. textRect.DeflateRect(0, 1, 1, 1);
  410. oldFont = dc.SelectObject(GetFont());
  411. COLORREF oldColor = dc.GetTextColor();
  412. dc.SetTextColor(g_Opt.m_Theme.SearchTextBoxFocusText());
  413. dc.DrawText(text, textRect, DT_SINGLELINE | DT_INTERNAL | DT_EDITCONTROL | DT_NOPREFIX | DT_VCENTER);
  414. dc.SelectObject(oldFont);
  415. dc.SetTextColor(oldColor);
  416. }
  417. else
  418. {
  419. dc.FillSolidRect(rect, g_Opt.m_Theme.MainWindowBG());
  420. }
  421. if (text.GetLength() == 0 && m_strPromptText.GetLength() > 0)
  422. {
  423. //if we aren't showing the close icon, then use the full space
  424. textRect.right += m_windowDpi->Scale(16);
  425. //textRect.right -= LOWORD(margins);
  426. oldFont = dc.SelectObject(&m_fontPrompt);
  427. COLORREF color = dc.GetTextColor();
  428. dc.SetTextColor(m_colorPromptText);
  429. dc.DrawText(m_strPromptText, textRect, DT_LEFT | DT_SINGLELINE | DT_EDITCONTROL | DT_VCENTER | DT_NOPREFIX);
  430. dc.SetTextColor(color);
  431. dc.SelectObject(oldFont);
  432. }
  433. int right = rect.right;
  434. if ((text.GetLength() > 0 || this == GetFocus()))
  435. {
  436. m_searchesButtonRect.SetRect(rect.right - m_windowDpi->Scale(18), 0, rect.right, rect.bottom);
  437. right = rect.right - m_windowDpi->Scale(18);
  438. m_searchesButton.Draw(&dc, *m_windowDpi, this, m_searchesButtonRect.left, 4, m_mouseHoveringOverSearches, m_mouseDownOnSearches);
  439. }
  440. else
  441. {
  442. m_searchesButtonRect.SetRect(0, 0, 0, 0);
  443. //m_searchButton.Draw(&dc, this, rect.right - 22, 4, false, false);
  444. }
  445. if (text.GetLength() > 0)
  446. {
  447. OutputDebugString(_T("showing close button\n"));
  448. m_closeButtonRect.SetRect(right - m_windowDpi->Scale(16), 0, right, rect.bottom);
  449. m_closeButton.Draw(&dc, *m_windowDpi, this, m_closeButtonRect.left, 4, m_mouseHoveringOverClose, m_mouseDownOnClose);
  450. }
  451. else
  452. {
  453. OutputDebugString(_T("not showing close button\n"));
  454. m_closeButtonRect.SetRect(0, 0, 0, 0);
  455. //m_searchButton.Draw(&dc, this, rect.right - 22, 4, false, false);
  456. }
  457. //OutputDebugString(_T("OnPaint"));
  458. }
  459. void CSymbolEdit::OnSize(UINT nType, int cx, int cy)
  460. {
  461. CEdit::OnSize(nType, cx, cy);
  462. RecalcLayout();
  463. }
  464. LRESULT CSymbolEdit::OnSetFont(WPARAM wParam, LPARAM lParam)
  465. {
  466. DefWindowProc(WM_SETFONT, wParam, lParam);
  467. RecalcLayout();
  468. return 0;
  469. }
  470. HBRUSH CSymbolEdit::CtlColor(CDC* pDC, UINT n)
  471. {
  472. if (::GetFocus() == m_hWnd)
  473. {
  474. pDC->SetTextColor(g_Opt.m_Theme.SearchTextBoxFocusText());
  475. pDC->SetBkColor(g_Opt.m_Theme.SearchTextBoxFocusBG());
  476. return CreateSolidBrush(g_Opt.m_Theme.SearchTextBoxFocusBG());
  477. }
  478. else
  479. {
  480. pDC->SetBkColor(g_Opt.m_Theme.MainWindowBG());
  481. return CreateSolidBrush(g_Opt.m_Theme.MainWindowBG());
  482. }
  483. }
  484. void CSymbolEdit::OnSetFocus(CWnd* pOldWnd)
  485. {
  486. Invalidate(FALSE);
  487. CEdit::OnSetFocus(pOldWnd);
  488. CWnd *pWnd = GetParent();
  489. if (pWnd)
  490. {
  491. if (g_Opt.m_bFindAsYouType)
  492. {
  493. pWnd->SendMessage(NM_FOCUS_ON_SEARCH, 0, 0);
  494. }
  495. }
  496. }
  497. void CSymbolEdit::OnKillFocus(CWnd* pNewWnd)
  498. {
  499. AddToSearchHistory();
  500. Invalidate(FALSE);
  501. CEdit::OnKillFocus(pNewWnd);
  502. }
  503. BOOL CSymbolEdit::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  504. {
  505. CPoint pntCursor;
  506. GetCursorPos(&pntCursor);
  507. ScreenToClient(&pntCursor);
  508. if(m_closeButtonRect.PtInRect(pntCursor))
  509. {
  510. HCURSOR h = ::LoadCursor(NULL, IDC_ARROW);
  511. ::SetCursor(h);
  512. return TRUE;
  513. }
  514. if (m_searchesButtonRect.PtInRect(pntCursor))
  515. {
  516. HCURSOR h = ::LoadCursor(NULL, IDC_ARROW);
  517. ::SetCursor(h);
  518. return TRUE;
  519. }
  520. return CEdit::OnSetCursor(pWnd, nHitTest, message);
  521. }
  522. void CSymbolEdit::OnLButtonUp(UINT nFlags, CPoint point)
  523. {
  524. if (m_mouseDownOnClose)
  525. {
  526. ReleaseCapture();
  527. InvalidateRect(m_closeButtonRect);
  528. }
  529. if (m_mouseDownOnSearches)
  530. {
  531. ReleaseCapture();
  532. InvalidateRect(m_searchesButtonRect);
  533. }
  534. m_mouseDownOnClose = false;
  535. m_mouseDownOnSearches = false;
  536. if (m_closeButtonRect.PtInRect(point))
  537. {
  538. if ((GetWindowTextLength() > 0))
  539. {
  540. CWnd *pOwner = GetOwner();
  541. if (pOwner)
  542. {
  543. pOwner->SendMessage(NM_CANCEL_SEARCH, 0, 0);
  544. }
  545. }
  546. }
  547. if (m_searchesButtonRect.PtInRect(point))
  548. {
  549. this->ShowSearchHistoryMenu();
  550. }
  551. CEdit::OnLButtonUp(nFlags, point);
  552. }
  553. void CSymbolEdit::OnLButtonDown(UINT nFlags, CPoint point)
  554. {
  555. if (m_closeButtonRect.PtInRect(point))
  556. {
  557. m_mouseDownOnClose = true;
  558. SetCapture();
  559. InvalidateRect(m_closeButtonRect);
  560. }
  561. else
  562. {
  563. m_mouseDownOnClose = false;
  564. }
  565. if (m_searchesButtonRect.PtInRect(point))
  566. {
  567. m_mouseDownOnSearches = true;
  568. SetCapture();
  569. InvalidateRect(m_searchesButtonRect);
  570. }
  571. else
  572. {
  573. m_mouseDownOnSearches = false;
  574. }
  575. CEdit::OnLButtonDown(nFlags, point);
  576. }
  577. void CSymbolEdit::OnMouseMove(UINT nFlags, CPoint point)
  578. {
  579. if (m_closeButtonRect.PtInRect(point))
  580. {
  581. if (m_mouseHoveringOverClose == false)
  582. {
  583. m_mouseHoveringOverClose = true;
  584. InvalidateRect(m_closeButtonRect);
  585. }
  586. }
  587. else if(m_mouseHoveringOverClose)
  588. {
  589. m_mouseHoveringOverClose = false;
  590. InvalidateRect(m_closeButtonRect);
  591. }
  592. if (m_searchesButtonRect.PtInRect(point))
  593. {
  594. if (m_mouseHoveringOverSearches == false)
  595. {
  596. m_mouseHoveringOverSearches = true;
  597. InvalidateRect(m_searchesButtonRect);
  598. }
  599. }
  600. else if (m_mouseHoveringOverSearches)
  601. {
  602. m_mouseHoveringOverSearches = false;
  603. InvalidateRect(m_searchesButtonRect);
  604. }
  605. CEdit::OnMouseMove(nFlags, point);
  606. }
  607. void CSymbolEdit::OnSelectSearchString(UINT idIn)
  608. {
  609. int index = idIn - RANGE_START;
  610. if (idIn == CLEAR_LIST)
  611. {
  612. m_searches.RemoveAll();
  613. }
  614. else if (index >= 0 &&
  615. index < m_searches.GetCount())
  616. {
  617. CString cs = m_searches[index];
  618. this->SetWindowTextW(cs);
  619. this->SetFocus();
  620. this->SetSel(-1);
  621. this->Invalidate();
  622. m_searches.RemoveAt(index);
  623. m_searches.Add(cs);
  624. }
  625. }
  626. bool CSymbolEdit::ApplyLastSearch()
  627. {
  628. bool ret = false;
  629. if (m_searches.GetCount() > 0)
  630. {
  631. CString cs = m_searches[m_searches.GetCount()-1];
  632. this->SetWindowTextW(cs);
  633. this->SetFocus();
  634. this->SetSel(-1);
  635. this->Invalidate();
  636. ret = true;
  637. }
  638. return ret;
  639. }
  640. void CSymbolEdit::OnDpiChanged()
  641. {
  642. SetDpiInfo(m_windowDpi);
  643. }
  644. void CSymbolEdit::SetDpiInfo(CDPI *dpi)
  645. {
  646. m_windowDpi = dpi;
  647. m_closeButton.Reset();
  648. m_closeButton.LoadStdImageDPI(m_windowDpi->GetDPI(), search_close_16, Search_20, Search_24, Search_28, Search_32, _T("PNG"));
  649. m_searchesButton.Reset();
  650. m_searchesButton.LoadStdImageDPI(m_windowDpi->GetDPI(), down_16, down_20, down_24, down_28, down_32, _T("PNG"));
  651. RecalcLayout();
  652. }