1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2007 - 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
21 #include "XPTheme.h"
\r
22 #include "OddButton.h"
\r
26 * A button control with a menu to choose from different
\r
27 * actions. Clicking on the left "button" part is the same
\r
28 * as with a normal button, clicking on the right "arrow"
\r
29 * part will bring up a menu where the user can choose what
\r
30 * action the button should do.
\r
32 class CMenuButton : public COddButton
\r
35 DECLARE_DYNCREATE(CMenuButton);
\r
38 virtual ~CMenuButton(void);
\r
41 * Inserts a text to be shown in the button menu.
\r
42 * The text is inserted at the end of the menu string list.
\r
43 * \return the index of the inserted item. This index is
\r
44 * returned in GetCurrentEntry().
\r
46 INT_PTR AddEntry(const CString& sEntry);
\r
49 * Inserts an array of strings to be shown in the
\r
50 * button menu. The strings are inserted at the end
\r
51 * of the menu string list.
\r
52 * \return the index of the first inserted item. This index
\r
53 * is returned in GetCurrentEntry().
\r
55 INT_PTR AddEntries(const CStringArray& sEntries);
\r
58 * Returns the currently shown entry index of the button.
\r
60 INT_PTR GetCurrentEntry() const {return m_currentEntry;}
\r
63 * Sets which of the menu strings should be shown in the
\r
64 * button and be active.
\r
65 * \return true if successful
\r
67 bool SetCurrentEntry(INT_PTR entry);
\r
70 * Determines if the button control is drawn with the XP
\r
71 * themes or without. The default is \a true, which means
\r
72 * the control is drawn with theming support if the underlying
\r
73 * OS has it enabled and supports it.
\r
75 void UseThemes(bool bUseThemes);
\r
78 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
\r
80 virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
81 afx_msg BOOL OnClicked();
\r
82 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
\r
83 afx_msg void OnNMThemeChanged(NMHDR *pNMHDR, LRESULT *pResult);
\r
84 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
\r
85 afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
\r
86 afx_msg void OnDestroy();
\r
88 void DrawArrow(CDC* pDC, RECT* pRect, COLORREF clrArrow = ::GetSysColor(COLOR_BTNTEXT));
\r
91 DECLARE_MESSAGE_MAP()
\r
95 CStringArray m_sEntries;
\r
97 INT_PTR m_currentEntry;
\r
99 CXPTheme m_xpButton;
\r
102 typedef COddButton _Inherited;
\r