SymbolEdit.cpp 15 KB

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