OSDN Git Service

Change Dir Structure to be same as TortoiseSVN'
[tortoisegit/TortoiseGitJp.git] / src / Utils / MiscUI / MenuButton.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2007 - 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 #include "XPTheme.h"\r
22 #include "OddButton.h"\r
23 \r
24 /**\r
25  * \ingroup Utils\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
31  */\r
32 class CMenuButton : public COddButton\r
33 {\r
34 public:\r
35         DECLARE_DYNCREATE(CMenuButton);\r
36 \r
37         CMenuButton(void);\r
38         virtual ~CMenuButton(void);\r
39 \r
40         /**\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
45          */\r
46         INT_PTR AddEntry(const CString& sEntry);\r
47 \r
48         /**\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
54          */\r
55         INT_PTR AddEntries(const CStringArray& sEntries);\r
56 \r
57         /**\r
58          * Returns the currently shown entry index of the button.\r
59          */\r
60         INT_PTR GetCurrentEntry() const {return m_currentEntry;}\r
61 \r
62         /**\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
66          */\r
67         bool    SetCurrentEntry(INT_PTR entry);\r
68 \r
69         /**\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
74          */\r
75         void    UseThemes(bool bUseThemes);\r
76 \r
77 public:\r
78         virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);\r
79 protected:\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
87 \r
88         void DrawArrow(CDC* pDC, RECT* pRect, COLORREF clrArrow = ::GetSysColor(COLOR_BTNTEXT));\r
89         bool ShowMenu();\r
90 \r
91         DECLARE_MESSAGE_MAP()\r
92 \r
93         bool    m_bMouseOver;\r
94         bool    m_bUseThemes;\r
95         CStringArray m_sEntries;\r
96         int             m_SeparatorX;\r
97         INT_PTR m_currentEntry;\r
98 \r
99         CXPTheme m_xpButton;\r
100 \r
101 private:\r
102         typedef COddButton _Inherited;\r
103 };\r
104 \r