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