1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2016-2017, 2020, 2023 - TortoiseGit
4 // Copyright (C) 2011, 2016 - Sven Strickroth <email@cs-ware.de>
7 // Copyright (C) 2003-2007 - TortoiseSVN
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software Foundation,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include "ThemeControls.h"
29 * A button control with a menu to choose from different
30 * actions. Clicking on the left "button" part is the same
31 * as with a normal button, clicking on the right "arrow"
32 * part will bring up a menu where the user can choose what
33 * action the button should do.
35 class CMenuButton
: public CThemeMFCMenuButton
38 DECLARE_DYNCREATE(CMenuButton
);
41 virtual ~CMenuButton();
44 * Inserts a text to be shown in the button menu.
45 * The text is inserted at the end of the menu string list.
46 * \return the index of the inserted item. This index is
47 * returned in GetCurrentEntry().
49 INT_PTR
AddEntry(const CString
& sEntry
, UINT uIcon
= 0U);
52 * Inserts an array of strings to be shown in the
53 * button menu. The strings are inserted at the end
54 * of the menu string list.
55 * \return the index of the first inserted item. This index
56 * is returned in GetCurrentEntry().
58 INT_PTR
AddEntries(const CStringArray
& sEntries
);
61 * Returns the currently shown entry index of the button.
63 INT_PTR
GetCurrentEntry() const { return (m_nMenuResult
== 0) ? m_nDefault
- 1 : m_nMenuResult
- 1; }
66 * Sets which of the menu strings should be shown in the
67 * button and be active.
68 * \return true if successful
70 bool SetCurrentEntry(INT_PTR entry
);
73 * Determines if the button control is drawn with the XP
74 * themes or without. The default is \a true, which means
75 * the control is drawn with theming support if the underlying
76 * OS has it enabled and supports it.
80 bool m_bMarkDefault
= true;
82 /** Don't show text on Button */
83 bool m_bShowCurrentItem
= true;
85 bool m_bAlwaysShowArrow
= false;
88 BOOL
PreTranslateMessage(MSG
* pMsg
) override
;
90 BOOL
IsPressed() const override
;
92 afx_msg
void OnDraw(CDC
* pDC
, const CRect
& rect
, UINT uiState
) override
;
93 afx_msg
void OnLButtonDown(UINT nFlags
, CPoint point
);
94 afx_msg
void OnSysColorChange();
95 afx_msg LRESULT
OnThemeChanged();
97 afx_msg BOOL
OnClicked();
98 afx_msg
void OnDestroy();
101 INT_PTR m_nDefault
= 0;
103 DECLARE_MESSAGE_MAP()
105 CStringArray m_sEntries
;