SymbolEdit.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // CSymbolEdit
  27. class CSymbolEdit : public CEdit
  28. {
  29. DECLARE_DYNAMIC(CSymbolEdit)
  30. CFont m_fontPrompt;
  31. HICON m_hSymbolIcon;
  32. bool m_bInternalIcon;
  33. CString m_strPromptText;
  34. COLORREF m_colorPromptText;
  35. void DestroyIcon();
  36. public:
  37. CSymbolEdit();
  38. virtual ~CSymbolEdit();
  39. virtual BOOL PreTranslateMessage(MSG* pMsg);
  40. void SetSymbolIcon(HICON hIcon, BOOL redraw = TRUE);
  41. void SetSymbolIcon(UINT id, BOOL redraw = TRUE);
  42. void SetPromptText(CString text, BOOL redraw = TRUE);
  43. void SetPromptText(LPCTSTR szText, BOOL redraw = TRUE);
  44. void SetPromptTextColor(COLORREF color, BOOL redraw = TRUE);
  45. void SetPromptFont(CFont& font, BOOL redraw = TRUE);
  46. void SetPromptFont(const LOGFONT* lpLogFont, BOOL redraw = TRUE);
  47. protected:
  48. //CGdiImageDrawer m_searchButton;
  49. CGdiImageDrawer m_closeButton;
  50. CRect m_closeButtonRect;
  51. bool m_mouseDownOnClose;
  52. bool m_mouseHoveringOverClose;
  53. void RecalcLayout();
  54. virtual void PreSubclassWindow();
  55. afx_msg void OnSize(UINT nType, int cx, int cy);
  56. afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam);
  57. afx_msg HBRUSH CtlColor(CDC* pDC, UINT n);
  58. afx_msg void OnSetFocus(CWnd* pOldWnd);
  59. afx_msg void OnKillFocus(CWnd* pNewWnd);
  60. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  61. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  62. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  63. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  64. DECLARE_MESSAGE_MAP()
  65. public:
  66. afx_msg void OnPaint();
  67. };