1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011 - Sven Strickroth <email@cs-ware.de>
6 // Copyright (C) 2003-2007 - TortoiseSVN
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software Foundation,
20 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * A button control with a menu to choose from different
28 * actions. Clicking on the left "button" part is the same
29 * as with a normal button, clicking on the right "arrow"
30 * part will bring up a menu where the user can choose what
31 * action the button should do.
33 class CMenuButton
: public CMFCMenuButton
36 DECLARE_DYNCREATE(CMenuButton
);
39 virtual ~CMenuButton(void);
42 * Inserts a text to be shown in the button menu.
43 * The text is inserted at the end of the menu string list.
44 * \return the index of the inserted item. This index is
45 * returned in GetCurrentEntry().
47 INT_PTR
AddEntry(const CString
& sEntry
);
48 INT_PTR
AddEntry(UINT iconId
, const CString
& sEntry
);
51 * Inserts an array of strings to be shown in the
52 * button menu. The strings are inserted at the end
53 * of the menu string list.
54 * \return the index of the first inserted item. This index
55 * is returned in GetCurrentEntry().
57 INT_PTR
AddEntries(const CStringArray
& sEntries
);
60 * Returns the currently shown entry index of the button.
62 INT_PTR
GetCurrentEntry() const { return (m_nMenuResult
== 0) ? m_nDefault
- 1 : m_nMenuResult
- 1; }
65 * Sets which of the menu strings should be shown in the
66 * button and be active.
67 * \return true if successful
69 bool SetCurrentEntry(INT_PTR entry
);
72 * Determines if the button control is drawn with the XP
73 * themes or without. The default is \a true, which means
74 * the control is drawn with theming support if the underlying
75 * OS has it enabled and supports it.
82 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
84 bool m_bRealMenuIsActive
;
85 virtual void OnShowMenu();
86 afx_msg
void OnDraw(CDC
* pDC
, const CRect
& rect
, UINT uiState
);
88 afx_msg BOOL
OnClicked();
89 afx_msg
void OnDestroy();
96 CStringArray m_sEntries
;