1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
22 #define WM_FILTEREDIT_INFOCLICKED (WM_USER + 100)
\r
23 #define WM_FILTEREDIT_CANCELCLICKED (WM_USER + 101)
\r
27 * Validator interface for the Filter edit control CFilterEdit
\r
29 class IFilterEditValidator
\r
32 virtual bool Validate(LPCTSTR string) = 0;
\r
37 * Filter edit control.
\r
38 * An edit control with a 'close' button on the right which clears the text
\r
39 * in the control, and an info button on the left (optional) where a context
\r
40 * menu or other selection window can be shown.
\r
41 * \image html "filterEdit.jpg"
\r
43 * Example on how to show a context menu for the info button:
\r
45 * LRESULT CFilterEditTestDlg::OnFilterContext(WPARAM wParam, LPARAM lParam)
\r
47 * RECT * rect = (LPRECT)lParam;
\r
49 * point.x = rect->left;
\r
50 * point.y = rect->bottom;
\r
52 * if (popup.CreatePopupMenu())
\r
54 * popup.AppendMenu(MF_STRING | MF_ENABLED, 1, _T("string 1"));
\r
55 * popup.AppendMenu(MF_SEPARATOR, NULL);
\r
56 * popup.AppendMenu(MF_STRING | MF_ENABLED, 2, _T("string 2"));
\r
57 * popup.AppendMenu(MF_STRING | MF_ENABLED, 3, _T("string 3"));
\r
58 * popup.AppendMenu(MF_STRING | MF_ENABLED, 4, _T("string 4"));
\r
59 * popup.AppendMenu(MF_STRING | MF_ENABLED, 5, _T("string 5"));
\r
60 * popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
\r
66 class CFilterEdit : public CEdit
\r
68 DECLARE_DYNAMIC(CFilterEdit)
\r
71 virtual ~CFilterEdit();
\r
74 * Sets the icons to show for the cancel button. The first icon represents
\r
75 * the normal state, the second one when the button is pressed.
\r
76 * if \c bShowAlways is true, then the cancel button is shown even if there
\r
77 * is no text in the control.
\r
78 * \note To catch the WM_FILTEREDIT_CANCELCLICKED notification, handle the message directly (or use the
\r
79 * WM_MESSAGE() macro). The LPARAM parameter of the message contains the
\r
80 * rectangle (pointer to RECT) of the info icon in screen coordinates.
\r
82 BOOL SetCancelBitmaps(UINT uCancelNormal, UINT uCancelPressed, BOOL bShowAlways = FALSE);
\r
85 * Sets the info icon shown on the left.
\r
86 * A notification is sent when the user clicks on that icon.
\r
87 * The notification is either WM_FILTEREDIT_INFOCLICKED or the one
\r
88 * set with SetButtonClickedMessageId().
\r
90 * To catch the notification, handle the message directly (or use the
\r
91 * WM_MESSAGE() macro). The LPARAM parameter of the message contains the
\r
92 * rectangle (pointer to RECT) of the info icon in screen coordinates.
\r
94 BOOL SetInfoIcon(UINT uInfo);
\r
97 * Sets the message Id which is sent when the user clicks on the info
\r
100 void SetButtonClickedMessageId(UINT iButtonClickedMessageId, UINT iCancelClickedMessageId);
\r
103 * To provide a cue banner even though we require the edit control to be multi line
\r
105 BOOL SetCueBanner(LPCWSTR lpcwText);
\r
107 void SetValidator(IFilterEditValidator * pValidator) {m_pValidator = pValidator;}
\r
109 virtual void PreSubclassWindow( );
\r
110 virtual BOOL PreTranslateMessage( MSG* pMsg );
\r
112 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
\r
113 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
\r
114 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
\r
115 afx_msg void OnSize(UINT nType, int cx, int cy);
\r
116 afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM lParam);
\r
117 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
118 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
\r
119 afx_msg BOOL OnEnChange();
\r
120 afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
\r
121 afx_msg void OnPaint();
\r
122 afx_msg void OnEnKillfocus();
\r
123 afx_msg void OnEnSetfocus();
\r
124 DECLARE_MESSAGE_MAP()
\r
127 void ResizeWindow();
\r
128 CSize GetIconSize(HICON hIcon);
\r
130 void DrawDimText();
\r
133 HICON m_hIconCancelNormal;
\r
134 HICON m_hIconCancelPressed;
\r
136 CSize m_sizeCancelIcon;
\r
137 CSize m_sizeInfoIcon;
\r
138 CRect m_rcEditArea;
\r
139 CRect m_rcButtonArea;
\r
140 CRect m_rcInfoArea;
\r
141 BOOL m_bShowCancelButtonAlways;
\r
143 UINT m_iButtonClickedMessageId;
\r
144 UINT m_iCancelClickedMessageId;
\r
145 COLORREF m_backColor;
\r
147 IFilterEditValidator * m_pValidator;
\r
148 TCHAR * m_pCueBanner;
\r