OSDN Git Service

86008f6c30f784ca996030138c647ee1b52c7c1e
[tortoisegit/TortoiseGitJp.git] / src / Utils / MiscUI / FilterEdit.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 \r
22 #define WM_FILTEREDIT_INFOCLICKED       (WM_USER + 100)\r
23 #define WM_FILTEREDIT_CANCELCLICKED     (WM_USER + 101)\r
24 \r
25 /**\r
26  * \ingroup Utils\r
27  * Validator interface for the Filter edit control CFilterEdit\r
28  */\r
29 class IFilterEditValidator\r
30 {\r
31 public:\r
32         virtual bool    Validate(LPCTSTR string) = 0;\r
33 };\r
34 \r
35 /**\r
36  * \ingroup Utils\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
42  *\r
43  * Example on how to show a context menu for the info button:\r
44  * \code\r
45  * LRESULT CFilterEditTestDlg::OnFilterContext(WPARAM wParam, LPARAM lParam)\r
46  * {\r
47  *   RECT * rect = (LPRECT)lParam;\r
48  *   POINT point;\r
49  *   point.x = rect->left;\r
50  *   point.y = rect->bottom;\r
51  *   CMenu popup;\r
52  *   if (popup.CreatePopupMenu())\r
53  *   {\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
61  *   }\r
62  *   return 0;\r
63  * }\r
64  * \endcode\r
65  */\r
66 class CFilterEdit : public CEdit\r
67 {\r
68         DECLARE_DYNAMIC(CFilterEdit)\r
69 public:\r
70         CFilterEdit();\r
71         virtual ~CFilterEdit();\r
72 \r
73         /**\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
81          */\r
82         BOOL SetCancelBitmaps(UINT uCancelNormal, UINT uCancelPressed, BOOL bShowAlways = FALSE);\r
83 \r
84         /**\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
89          *\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
93          */\r
94         BOOL SetInfoIcon(UINT uInfo);\r
95 \r
96         /**\r
97          * Sets the message Id which is sent when the user clicks on the info\r
98          * button.\r
99          */\r
100         void SetButtonClickedMessageId(UINT iButtonClickedMessageId, UINT iCancelClickedMessageId);\r
101 \r
102         /**\r
103          * To provide a cue banner even though we require the edit control to be multi line\r
104          */\r
105         BOOL SetCueBanner(LPCWSTR lpcwText);\r
106 \r
107         void SetValidator(IFilterEditValidator * pValidator) {m_pValidator = pValidator;}\r
108 protected:\r
109         virtual void    PreSubclassWindow( );\r
110         virtual BOOL    PreTranslateMessage( MSG* pMsg );\r
111 \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
125 \r
126 \r
127         void                    ResizeWindow();\r
128         CSize                   GetIconSize(HICON hIcon);\r
129         void                    Validate();\r
130         void                    DrawDimText();\r
131 \r
132 protected:\r
133         HICON                                   m_hIconCancelNormal;\r
134         HICON                                   m_hIconCancelPressed;\r
135         HICON                                   m_hIconInfo;\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
142         BOOL                                    m_bPressed;\r
143         UINT                                    m_iButtonClickedMessageId;\r
144         UINT                                    m_iCancelClickedMessageId;\r
145         COLORREF                                m_backColor;\r
146         HBRUSH                                  m_brBack;\r
147         IFilterEditValidator *  m_pValidator;\r
148         TCHAR *                                 m_pCueBanner;\r
149 };\r
150 \r
151 \r