SymbolEdit.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. CBrush m_brush;
  38. COLORREF m_lastBrushColor;
  39. void DestroyIcon();
  40. public:
  41. CSymbolEdit();
  42. virtual ~CSymbolEdit();
  43. virtual BOOL PreTranslateMessage(MSG* pMsg);
  44. void AddToSearchHistory();
  45. bool ShowSearchHistoryMenu();
  46. void SetSymbolIcon(HICON hIcon, BOOL redraw = TRUE);
  47. void SetSymbolIcon(UINT id, BOOL redraw = TRUE);
  48. void SetPromptText(CString text, BOOL redraw = TRUE);
  49. void SetPromptText(LPCTSTR szText, BOOL redraw = TRUE);
  50. void SetPromptTextColor(COLORREF color, BOOL redraw = TRUE);
  51. void SetPromptFont(CFont& font, BOOL redraw = TRUE);
  52. void SetPromptFont(const LOGFONT* lpLogFont, BOOL redraw = TRUE);
  53. bool ApplyLastSearch();
  54. void SetLastSearchAccel(CAccel a) { m_lastSearchShortCut = a; }
  55. CString SavePastSearches();
  56. void LoadPastSearches(CString values);
  57. void SetDpiInfo(CDPI *dpi);
  58. void OnDpiChanged();
  59. //void SetWindowTextEx(LPCSTR)
  60. protected:
  61. //CGdiImageDrawer m_searchButton;
  62. CGdiImageDrawer m_closeButton;
  63. CRect m_closeButtonRect;
  64. bool m_mouseDownOnClose;
  65. bool m_mouseHoveringOverClose;
  66. CGdiImageDrawer m_searchesButton;
  67. CRect m_searchesButtonRect;
  68. bool m_mouseDownOnSearches;
  69. bool m_mouseHoveringOverSearches;
  70. CAccel m_lastSearchShortCut;
  71. CStringArray m_searches;
  72. void RecalcLayout();
  73. virtual void PreSubclassWindow();
  74. CDPI *m_windowDpi;
  75. int m_centerTextDiff;
  76. CString m_lastTextOnPaint;
  77. afx_msg void OnSize(UINT nType, int cx, int cy);
  78. afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam);
  79. //afx_msg LRESULT OnMenuExit(WPARAM wParam, LPARAM lParam);
  80. afx_msg HBRUSH CtlColor(CDC* pDC, UINT n);
  81. afx_msg void OnSetFocus(CWnd* pOldWnd);
  82. afx_msg void OnKillFocus(CWnd* pNewWnd);
  83. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  84. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  85. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  86. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  87. afx_msg void OnSelectSearchString(UINT idIn);
  88. DECLARE_MESSAGE_MAP()
  89. public:
  90. afx_msg void OnPaint();
  91. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  92. afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  93. afx_msg void OnNcPaint();
  94. afx_msg void OnTimer(UINT_PTR nIDEvent);
  95. };