SymbolEdit.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /************************************************************************/
  2. /* Created by MARIUS BANCILA
  3. /* www.mariusbancila.ro
  4. /* Copyright (C) 2008 MARIUS BANCILA. All rights reserved.
  5. /*
  6. /* Permission is given by the author to freely redistribute and
  7. /* include this code in any program as long as this credit is
  8. /* given where due.
  9. /*
  10. /* CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
  11. /* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  12. /* INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE CODE
  13. /* IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
  14. /* OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
  15. /* PERFORMANCE OF THE CODE IS WITH YOU. SHOULD ANY
  16. /* CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL
  17. /* DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
  18. /* NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
  19. /* WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE
  20. /* OF ANY CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
  21. /* THIS DISCLAIMER.
  22. /*
  23. /************************************************************************/
  24. #pragma once
  25. #include "GdiImageDrawer.h"
  26. #include "Accels.h"
  27. #include "DPI.h"
  28. // CSymbolEdit
  29. class CSymbolEdit : public CEdit
  30. {
  31. DECLARE_DYNAMIC(CSymbolEdit)
  32. CFont m_fontPrompt;
  33. HICON m_hSymbolIcon;
  34. bool m_bInternalIcon;
  35. CString m_strPromptText;
  36. COLORREF m_colorPromptText;
  37. void DestroyIcon();
  38. public:
  39. CSymbolEdit();
  40. virtual ~CSymbolEdit();
  41. virtual BOOL PreTranslateMessage(MSG* pMsg);
  42. void AddToSearchHistory();
  43. bool ShowSearchHistoryMenu();
  44. void SetSymbolIcon(HICON hIcon, BOOL redraw = TRUE);
  45. void SetSymbolIcon(UINT id, BOOL redraw = TRUE);
  46. void SetPromptText(CString text, BOOL redraw = TRUE);
  47. void SetPromptText(LPCTSTR szText, BOOL redraw = TRUE);
  48. void SetPromptTextColor(COLORREF color, BOOL redraw = TRUE);
  49. void SetPromptFont(CFont& font, BOOL redraw = TRUE);
  50. void SetPromptFont(const LOGFONT* lpLogFont, BOOL redraw = TRUE);
  51. bool ApplyLastSearch();
  52. void SetLastSearchAccel(CAccel a) { m_lastSearchShortCut = a; }
  53. CString SavePastSearches();
  54. void LoadPastSearches(CString values);
  55. void SetDpiInfo(CDPI *dpi);
  56. void OnDpiChanged();
  57. protected:
  58. //CGdiImageDrawer m_searchButton;
  59. CGdiImageDrawer m_closeButton;
  60. CRect m_closeButtonRect;
  61. bool m_mouseDownOnClose;
  62. bool m_mouseHoveringOverClose;
  63. CGdiImageDrawer m_searchesButton;
  64. CRect m_searchesButtonRect;
  65. bool m_mouseDownOnSearches;
  66. bool m_mouseHoveringOverSearches;
  67. CAccel m_lastSearchShortCut;
  68. CStringArray m_searches;
  69. void RecalcLayout();
  70. virtual void PreSubclassWindow();
  71. CDPI *m_windowDpi;
  72. afx_msg void OnSize(UINT nType, int cx, int cy);
  73. afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam);
  74. //afx_msg LRESULT OnMenuExit(WPARAM wParam, LPARAM lParam);
  75. afx_msg HBRUSH CtlColor(CDC* pDC, UINT n);
  76. afx_msg void OnSetFocus(CWnd* pOldWnd);
  77. afx_msg void OnKillFocus(CWnd* pNewWnd);
  78. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  79. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  80. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  81. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  82. afx_msg void OnSelectSearchString(UINT idIn);
  83. DECLARE_MESSAGE_MAP()
  84. public:
  85. afx_msg void OnPaint();
  86. };