OSDN Git Service

Show Ignore Sub Menu
[tortoisegit/TortoiseGitJp.git] / src / Utils / MiscUI / IconMenu.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2008 - 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 typedef HRESULT (WINAPI *FN_GetBufferedPaintBits) (HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer, int *pcxRow);\r
22 typedef HPAINTBUFFER (WINAPI *FN_BeginBufferedPaint) (HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc);\r
23 typedef HRESULT (WINAPI *FN_EndBufferedPaint) (HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget);\r
24 \r
25 \r
26 /**\r
27  * \ingroup utils\r
28  * Extends the CMenu class with a convenience method to insert a menu\r
29  * entry with an icon.\r
30  *\r
31  * The icons are loaded from the resources and converted to a bitmap.\r
32  * The bitmaps are destroyed together with the CIconMenu object.\r
33  */\r
34 class CIconMenu : public CMenu\r
35 {\r
36 public:\r
37         CIconMenu(void);\r
38         ~CIconMenu(void);\r
39 \r
40         BOOL AppendMenuIcon(UINT_PTR nIDNewItem, LPCTSTR lpszNewItem, UINT uIcon = 0);\r
41         BOOL AppendMenuIcon(UINT_PTR nIDNewItem, UINT_PTR nNewItem, UINT uIcon = 0);\r
42         void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);\r
43         void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);\r
44 \r
45 private:\r
46         HBITMAP IconToBitmapPARGB32(UINT uIcon);\r
47         HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp);\r
48         HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon);\r
49         bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow);\r
50         HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow);\r
51 \r
52 private:\r
53         std::map<UINT, HBITMAP>         bitmaps;\r
54         std::map<UINT_PTR, UINT>        icons;\r
55         WORD winVersion;\r
56 \r
57         FN_GetBufferedPaintBits pfnGetBufferedPaintBits;\r
58         FN_BeginBufferedPaint pfnBeginBufferedPaint;\r
59         FN_EndBufferedPaint pfnEndBufferedPaint;\r
60 };\r