Update libgit to Git for Windows 2.15
[TortoiseGit.git] / src / TortoiseMerge / CustomMFCRibbonButton.h
blob0ab468d89949c89c47bed5315ef0cab9f6ce80c3
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2013 - 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.
19 #pragma once
21 /**
22 * \ingroup TortoiseMerge
23 * a custom MFC Ribbon Button to avoid the click delay
26 class CCustomMFCRibbonButton : public CMFCRibbonButton
28 public:
29 CCustomMFCRibbonButton() : CMFCRibbonButton() {}
30 CCustomMFCRibbonButton(UINT nID, LPCTSTR lpszText, int nSmallImageIndex = -1, int nLargeImageIndex = -1, BOOL bAlwaysShowDescription = FALSE)
31 : CMFCRibbonButton(nID, lpszText, nSmallImageIndex, nLargeImageIndex, bAlwaysShowDescription) {}
32 CCustomMFCRibbonButton(UINT nID, LPCTSTR lpszText, HICON hIcon, BOOL bAlwaysShowDescription = FALSE, HICON hIconSmall = nullptr, BOOL bAutoDestroyIcon = FALSE, BOOL bAlphaBlendIcon = FALSE)
33 : CMFCRibbonButton(nID, lpszText, hIcon, bAlwaysShowDescription, hIconSmall, bAutoDestroyIcon, bAlphaBlendIcon) {}
35 protected:
36 // override the OnLButtonUp method because the original one
37 // does nothing if the button is still marked as pressed or highlighted:
38 // that behavior prevents fast clicks because after each click
39 // the window first needs to process various messages until it clears
40 // those pressed and highlighted flags.
41 virtual void OnLButtonUp(CPoint point)
43 ASSERT_VALID(this);
45 CMFCRibbonBaseElement::OnLButtonUp(point);
47 if (m_bIsDisabled)
49 return;
52 if (m_bIsDroppedDown)
54 if (!m_rectCommand.IsRectEmpty () && m_rectCommand.PtInRect (point) && IsMenuMode ())
56 OnClick (point);
58 return;
61 if (!m_rectCommand.IsRectEmpty() && !m_rectCommand.PtInRect(point))
63 return;
66 OnClick(point);