Changeset 6e5456755ad9…
Parent a7dd6f210c8b…
by
Changes to 9 files · Browse files at 6e5456755ad9 Showing diff from parent a7dd6f210c8b Diff from another changeset...
|
|
@@ -1,284 +1,284 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2009 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-// Adapted for use in TortoiseHg by Veniamin Albaev
-//
-#include "stdafx.h"
-#include "IconBitmapUtils.h"
-#include "SysInfo.h"
-#include "registry.h"
-
-IconBitmapUtils::IconBitmapUtils()
- : hUxTheme(NULL)
-{
- if (SysInfo::Instance().IsVistaOrLater())
- {
- hUxTheme = LoadLibrary(_T("UXTHEME.DLL"));
-
- if (hUxTheme)
- {
- pfnGetBufferedPaintBits = (FN_GetBufferedPaintBits)::GetProcAddress(hUxTheme, "GetBufferedPaintBits");
- pfnBeginBufferedPaint = (FN_BeginBufferedPaint)::GetProcAddress(hUxTheme, "BeginBufferedPaint");
- pfnEndBufferedPaint = (FN_EndBufferedPaint)::GetProcAddress(hUxTheme, "EndBufferedPaint");
- }
- }
-}
-
-IconBitmapUtils::~IconBitmapUtils()
-{
- if (hUxTheme)
- FreeLibrary(hUxTheme);
-}
-
-HBITMAP IconBitmapUtils::IconToBitmap(HICON hIcon)
-{
- if (!hIcon)
- return NULL;
-
- RECT rect;
-
- rect.right = ::GetSystemMetrics(SM_CXMENUCHECK);
- rect.bottom = ::GetSystemMetrics(SM_CYMENUCHECK);
-
- rect.left = rect.top = 0;
-
- HWND desktop = ::GetDesktopWindow();
- if (desktop == NULL)
- return NULL;
-
- HDC screen_dev = ::GetDC(desktop);
- if (screen_dev == NULL)
- return NULL;
-
- // Create a compatible DC
- HDC dst_hdc = ::CreateCompatibleDC(screen_dev);
- if (dst_hdc == NULL)
- {
- ::ReleaseDC(desktop, screen_dev);
- return NULL;
- }
-
- // Create a new bitmap of icon size
- HBITMAP bmp = ::CreateCompatibleBitmap(screen_dev, rect.right, rect.bottom);
- if (bmp == NULL)
- {
- ::DeleteDC(dst_hdc);
- ::ReleaseDC(desktop, screen_dev);
- return NULL;
- }
-
- // Select it into the compatible DC
- HBITMAP old_dst_bmp = (HBITMAP)::SelectObject(dst_hdc, bmp);
- if (old_dst_bmp == NULL)
- return NULL;
-
- // Fill the background of the compatible DC with the white color
- // that is taken by menu routines as transparent
- ::SetBkColor(dst_hdc, RGB(255, 255, 255));
- ::ExtTextOut(dst_hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
-
- // Draw the icon into the compatible DC
- ::DrawIconEx(dst_hdc, 0, 0, hIcon, rect.right, rect.bottom, 0, NULL, DI_NORMAL);
-
- // Restore settings
- ::SelectObject(dst_hdc, old_dst_bmp);
- ::DeleteDC(dst_hdc);
- ::ReleaseDC(desktop, screen_dev);
-
- return bmp;
-}
-
-HBITMAP IconBitmapUtils::IconToBitmapPARGB32(HICON hIcon)
-{
- if (!hIcon)
- return NULL;
-
- if (pfnBeginBufferedPaint == NULL || pfnEndBufferedPaint == NULL || pfnGetBufferedPaintBits == NULL)
- {
- TDEBUG_TRACE(" IconBitmapUtils::IconToBitmapPARGB32: Theme functions not found, returns NULL");
- return NULL;
- }
-
- SIZE sizIcon;
- sizIcon.cx = GetSystemMetrics(SM_CXSMICON);
- sizIcon.cy = GetSystemMetrics(SM_CYSMICON);
-
- RECT rcIcon;
- SetRect(&rcIcon, 0, 0, sizIcon.cx, sizIcon.cy);
- HBITMAP hBmp = NULL;
-
- HDC hdcDest = CreateCompatibleDC(NULL);
- if (hdcDest)
- {
- if (SUCCEEDED(Create32BitHBITMAP(hdcDest, &sizIcon, NULL, &hBmp)))
- {
- HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDest, hBmp);
- if (hbmpOld)
- {
- BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
- BP_PAINTPARAMS paintParams = {0};
- paintParams.cbSize = sizeof(paintParams);
- paintParams.dwFlags = BPPF_ERASE;
- paintParams.pBlendFunction = &bfAlpha;
-
- HDC hdcBuffer;
- HPAINTBUFFER hPaintBuffer = pfnBeginBufferedPaint(hdcDest, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
- if (hPaintBuffer)
- {
- if (DrawIconEx(hdcBuffer, 0, 0, hIcon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL))
- //if (FillRect(hdcBuffer, &rcIcon, (HBRUSH) (0x000000FF)) != 0)
- {
- // If icon did not have an alpha channel we need to convert buffer to PARGB
- ConvertBufferToPARGB32(hPaintBuffer, hdcDest, hIcon, sizIcon);
- }
- // This will write the buffer contents to the destination bitmap
- pfnEndBufferedPaint(hPaintBuffer, TRUE);
- }
-
- SelectObject(hdcDest, hbmpOld);
- }
- }
-
- DeleteDC(hdcDest);
- }
-
- return hBmp;
-}
-
-HRESULT IconBitmapUtils::Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp)
-{
- *phBmp = NULL;
-
- BITMAPINFO bmi;
- SecureZeroMemory(&bmi, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- bmi.bmiHeader.biWidth = psize->cx;
- bmi.bmiHeader.biHeight = psize->cy;
- bmi.bmiHeader.biBitCount = 32;
-
- HDC hdcUsed = hdc ? hdc : GetDC(NULL);
- if (hdcUsed)
- {
- *phBmp = CreateDIBSection(hdcUsed, &bmi, DIB_RGB_COLORS, ppvBits, NULL, 0);
- if (hdc != hdcUsed)
- {
- ReleaseDC(NULL, hdcUsed);
- }
- }
- return (NULL == *phBmp) ? E_OUTOFMEMORY : S_OK;
-}
-
-HRESULT IconBitmapUtils::ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon)
-{
- RGBQUAD *prgbQuad;
- int cxRow;
- HRESULT hr = pfnGetBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow);
- if (SUCCEEDED(hr))
- {
- Gdiplus::ARGB *pargb = reinterpret_cast<Gdiplus::ARGB *>(prgbQuad);
- if (!HasAlpha(pargb, sizIcon, cxRow))
- {
- ICONINFO info;
- if (GetIconInfo(hicon, &info))
- {
- if (info.hbmMask)
- {
- hr = ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow);
- }
-
- DeleteObject(info.hbmColor);
- DeleteObject(info.hbmMask);
- }
- }
- }
-
- return hr;
-}
-
-bool IconBitmapUtils::HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow)
-{
- ULONG cxDelta = cxRow - sizImage.cx;
- for (ULONG y = sizImage.cy; y; --y)
- {
- for (ULONG x = sizImage.cx; x; --x)
- {
- if (*pargb++ & 0xFF000000)
- {
- return true;
- }
- }
-
- pargb += cxDelta;
- }
-
- return false;
-}
-
-HRESULT IconBitmapUtils::ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow)
-{
- BITMAPINFO bmi;
- SecureZeroMemory(&bmi, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- bmi.bmiHeader.biWidth = sizImage.cx;
- bmi.bmiHeader.biHeight = sizImage.cy;
- bmi.bmiHeader.biBitCount = 32;
-
- HRESULT hr = E_OUTOFMEMORY;
- HANDLE hHeap = GetProcessHeap();
- void *pvBits = HeapAlloc(hHeap, 0, bmi.bmiHeader.biWidth * 4 * bmi.bmiHeader.biHeight);
- if (pvBits)
- {
- hr = E_UNEXPECTED;
- if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight)
- {
- ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth;
- Gdiplus::ARGB *pargbMask = static_cast<Gdiplus::ARGB *>(pvBits);
-
- for (ULONG y = bmi.bmiHeader.biHeight; y; --y)
- {
- for (ULONG x = bmi.bmiHeader.biWidth; x; --x)
- {
- if (*pargbMask++)
- {
- // transparent pixel
- *pargb++ = 0;
- }
- else
- {
- // opaque pixel
- *pargb++ |= 0xFF000000;
- }
- }
-
- pargb += cxDelta;
- }
-
- hr = S_OK;
- }
-
- HeapFree(hHeap, 0, pvBits);
- }
-
- return hr;
-}
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2009 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+// Adapted for use in TortoiseHg by Veniamin Albaev
+//
+#include "stdafx.h"
+#include "IconBitmapUtils.h"
+#include "SysInfo.h"
+#include "registry.h"
+
+IconBitmapUtils::IconBitmapUtils()
+ : hUxTheme(NULL)
+{
+ if (SysInfo::Instance().IsVistaOrLater())
+ {
+ hUxTheme = LoadLibrary(_T("UXTHEME.DLL"));
+
+ if (hUxTheme)
+ {
+ pfnGetBufferedPaintBits = (FN_GetBufferedPaintBits)::GetProcAddress(hUxTheme, "GetBufferedPaintBits");
+ pfnBeginBufferedPaint = (FN_BeginBufferedPaint)::GetProcAddress(hUxTheme, "BeginBufferedPaint");
+ pfnEndBufferedPaint = (FN_EndBufferedPaint)::GetProcAddress(hUxTheme, "EndBufferedPaint");
+ }
+ }
+}
+
+IconBitmapUtils::~IconBitmapUtils()
+{
+ if (hUxTheme)
+ FreeLibrary(hUxTheme);
+}
+
+HBITMAP IconBitmapUtils::IconToBitmap(HICON hIcon)
+{
+ if (!hIcon)
+ return NULL;
+
+ RECT rect;
+
+ rect.right = ::GetSystemMetrics(SM_CXMENUCHECK);
+ rect.bottom = ::GetSystemMetrics(SM_CYMENUCHECK);
+
+ rect.left = rect.top = 0;
+
+ HWND desktop = ::GetDesktopWindow();
+ if (desktop == NULL)
+ return NULL;
+
+ HDC screen_dev = ::GetDC(desktop);
+ if (screen_dev == NULL)
+ return NULL;
+
+ // Create a compatible DC
+ HDC dst_hdc = ::CreateCompatibleDC(screen_dev);
+ if (dst_hdc == NULL)
+ {
+ ::ReleaseDC(desktop, screen_dev);
+ return NULL;
+ }
+
+ // Create a new bitmap of icon size
+ HBITMAP bmp = ::CreateCompatibleBitmap(screen_dev, rect.right, rect.bottom);
+ if (bmp == NULL)
+ {
+ ::DeleteDC(dst_hdc);
+ ::ReleaseDC(desktop, screen_dev);
+ return NULL;
+ }
+
+ // Select it into the compatible DC
+ HBITMAP old_dst_bmp = (HBITMAP)::SelectObject(dst_hdc, bmp);
+ if (old_dst_bmp == NULL)
+ return NULL;
+
+ // Fill the background of the compatible DC with the white color
+ // that is taken by menu routines as transparent
+ ::SetBkColor(dst_hdc, RGB(255, 255, 255));
+ ::ExtTextOut(dst_hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
+
+ // Draw the icon into the compatible DC
+ ::DrawIconEx(dst_hdc, 0, 0, hIcon, rect.right, rect.bottom, 0, NULL, DI_NORMAL);
+
+ // Restore settings
+ ::SelectObject(dst_hdc, old_dst_bmp);
+ ::DeleteDC(dst_hdc);
+ ::ReleaseDC(desktop, screen_dev);
+
+ return bmp;
+}
+
+HBITMAP IconBitmapUtils::IconToBitmapPARGB32(HICON hIcon)
+{
+ if (!hIcon)
+ return NULL;
+
+ if (pfnBeginBufferedPaint == NULL || pfnEndBufferedPaint == NULL || pfnGetBufferedPaintBits == NULL)
+ {
+ TDEBUG_TRACE(" IconBitmapUtils::IconToBitmapPARGB32: Theme functions not found, returns NULL");
+ return NULL;
+ }
+
+ SIZE sizIcon;
+ sizIcon.cx = GetSystemMetrics(SM_CXSMICON);
+ sizIcon.cy = GetSystemMetrics(SM_CYSMICON);
+
+ RECT rcIcon;
+ SetRect(&rcIcon, 0, 0, sizIcon.cx, sizIcon.cy);
+ HBITMAP hBmp = NULL;
+
+ HDC hdcDest = CreateCompatibleDC(NULL);
+ if (hdcDest)
+ {
+ if (SUCCEEDED(Create32BitHBITMAP(hdcDest, &sizIcon, NULL, &hBmp)))
+ {
+ HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDest, hBmp);
+ if (hbmpOld)
+ {
+ BLENDFUNCTION bfAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
+ BP_PAINTPARAMS paintParams = {0};
+ paintParams.cbSize = sizeof(paintParams);
+ paintParams.dwFlags = BPPF_ERASE;
+ paintParams.pBlendFunction = &bfAlpha;
+
+ HDC hdcBuffer;
+ HPAINTBUFFER hPaintBuffer = pfnBeginBufferedPaint(hdcDest, &rcIcon, BPBF_DIB, &paintParams, &hdcBuffer);
+ if (hPaintBuffer)
+ {
+ if (DrawIconEx(hdcBuffer, 0, 0, hIcon, sizIcon.cx, sizIcon.cy, 0, NULL, DI_NORMAL))
+ //if (FillRect(hdcBuffer, &rcIcon, (HBRUSH) (0x000000FF)) != 0)
+ {
+ // If icon did not have an alpha channel we need to convert buffer to PARGB
+ ConvertBufferToPARGB32(hPaintBuffer, hdcDest, hIcon, sizIcon);
+ }
+ // This will write the buffer contents to the destination bitmap
+ pfnEndBufferedPaint(hPaintBuffer, TRUE);
+ }
+
+ SelectObject(hdcDest, hbmpOld);
+ }
+ }
+
+ DeleteDC(hdcDest);
+ }
+
+ return hBmp;
+}
+
+HRESULT IconBitmapUtils::Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp)
+{
+ *phBmp = NULL;
+
+ BITMAPINFO bmi;
+ SecureZeroMemory(&bmi, sizeof(bmi));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ bmi.bmiHeader.biWidth = psize->cx;
+ bmi.bmiHeader.biHeight = psize->cy;
+ bmi.bmiHeader.biBitCount = 32;
+
+ HDC hdcUsed = hdc ? hdc : GetDC(NULL);
+ if (hdcUsed)
+ {
+ *phBmp = CreateDIBSection(hdcUsed, &bmi, DIB_RGB_COLORS, ppvBits, NULL, 0);
+ if (hdc != hdcUsed)
+ {
+ ReleaseDC(NULL, hdcUsed);
+ }
+ }
+ return (NULL == *phBmp) ? E_OUTOFMEMORY : S_OK;
+}
+
+HRESULT IconBitmapUtils::ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon)
+{
+ RGBQUAD *prgbQuad;
+ int cxRow;
+ HRESULT hr = pfnGetBufferedPaintBits(hPaintBuffer, &prgbQuad, &cxRow);
+ if (SUCCEEDED(hr))
+ {
+ Gdiplus::ARGB *pargb = reinterpret_cast<Gdiplus::ARGB *>(prgbQuad);
+ if (!HasAlpha(pargb, sizIcon, cxRow))
+ {
+ ICONINFO info;
+ if (GetIconInfo(hicon, &info))
+ {
+ if (info.hbmMask)
+ {
+ hr = ConvertToPARGB32(hdc, pargb, info.hbmMask, sizIcon, cxRow);
+ }
+
+ DeleteObject(info.hbmColor);
+ DeleteObject(info.hbmMask);
+ }
+ }
+ }
+
+ return hr;
+}
+
+bool IconBitmapUtils::HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow)
+{
+ ULONG cxDelta = cxRow - sizImage.cx;
+ for (ULONG y = sizImage.cy; y; --y)
+ {
+ for (ULONG x = sizImage.cx; x; --x)
+ {
+ if (*pargb++ & 0xFF000000)
+ {
+ return true;
+ }
+ }
+
+ pargb += cxDelta;
+ }
+
+ return false;
+}
+
+HRESULT IconBitmapUtils::ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow)
+{
+ BITMAPINFO bmi;
+ SecureZeroMemory(&bmi, sizeof(bmi));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ bmi.bmiHeader.biWidth = sizImage.cx;
+ bmi.bmiHeader.biHeight = sizImage.cy;
+ bmi.bmiHeader.biBitCount = 32;
+
+ HRESULT hr = E_OUTOFMEMORY;
+ HANDLE hHeap = GetProcessHeap();
+ void *pvBits = HeapAlloc(hHeap, 0, bmi.bmiHeader.biWidth * 4 * bmi.bmiHeader.biHeight);
+ if (pvBits)
+ {
+ hr = E_UNEXPECTED;
+ if (GetDIBits(hdc, hbmp, 0, bmi.bmiHeader.biHeight, pvBits, &bmi, DIB_RGB_COLORS) == bmi.bmiHeader.biHeight)
+ {
+ ULONG cxDelta = cxRow - bmi.bmiHeader.biWidth;
+ Gdiplus::ARGB *pargbMask = static_cast<Gdiplus::ARGB *>(pvBits);
+
+ for (ULONG y = bmi.bmiHeader.biHeight; y; --y)
+ {
+ for (ULONG x = bmi.bmiHeader.biWidth; x; --x)
+ {
+ if (*pargbMask++)
+ {
+ // transparent pixel
+ *pargb++ = 0;
+ }
+ else
+ {
+ // opaque pixel
+ *pargb++ |= 0xFF000000;
+ }
+ }
+
+ pargb += cxDelta;
+ }
+
+ hr = S_OK;
+ }
+
+ HeapFree(hHeap, 0, pvBits);
+ }
+
+ return hr;
+}
|
@@ -1,56 +1,56 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2009 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-
-// Adapted for use in TortoiseHg by Veniamin Albaev
-//
-#pragma once
-#include <Uxtheme.h>
-#include <GdiPlus.h>
-#include <map>
-
-typedef HRESULT (WINAPI *FN_GetBufferedPaintBits) (HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer, int *pcxRow);
-typedef HPAINTBUFFER (WINAPI *FN_BeginBufferedPaint) (HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc);
-typedef HRESULT (WINAPI *FN_EndBufferedPaint) (HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget);
-
-
-/**
- * \ingroup utils
- * provides helper functions for converting icons to bitmaps
- */
-class IconBitmapUtils
-{
-public:
- IconBitmapUtils(void);
- ~IconBitmapUtils(void);
-
- HBITMAP IconToBitmap(HICON hIcon);
- HBITMAP IconToBitmapPARGB32(HICON hIcon);
- HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp);
- HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon);
- bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow);
- HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow);
-
-
-private:
- HMODULE hUxTheme;
-
- FN_GetBufferedPaintBits pfnGetBufferedPaintBits;
- FN_BeginBufferedPaint pfnBeginBufferedPaint;
- FN_EndBufferedPaint pfnEndBufferedPaint;
-};
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2009 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+
+// Adapted for use in TortoiseHg by Veniamin Albaev
+//
+#pragma once
+#include <Uxtheme.h>
+#include <GdiPlus.h>
+#include <map>
+
+typedef HRESULT (WINAPI *FN_GetBufferedPaintBits) (HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer, int *pcxRow);
+typedef HPAINTBUFFER (WINAPI *FN_BeginBufferedPaint) (HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc);
+typedef HRESULT (WINAPI *FN_EndBufferedPaint) (HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget);
+
+
+/**
+ * \ingroup utils
+ * provides helper functions for converting icons to bitmaps
+ */
+class IconBitmapUtils
+{
+public:
+ IconBitmapUtils(void);
+ ~IconBitmapUtils(void);
+
+ HBITMAP IconToBitmap(HICON hIcon);
+ HBITMAP IconToBitmapPARGB32(HICON hIcon);
+ HRESULT Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp);
+ HRESULT ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon);
+ bool HasAlpha(__in Gdiplus::ARGB *pargb, SIZE& sizImage, int cxRow);
+ HRESULT ConvertToPARGB32(HDC hdc, __inout Gdiplus::ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow);
+
+
+private:
+ HMODULE hUxTheme;
+
+ FN_GetBufferedPaintBits pfnGetBufferedPaintBits;
+ FN_BeginBufferedPaint pfnBeginBufferedPaint;
+ FN_EndBufferedPaint pfnEndBufferedPaint;
+};
|
|
|
@@ -1,205 +1,205 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2003-2006,2008-2009 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-#include "stdafx.h"
-#include "registry.h"
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef __CSTRINGT_H__
-CRegBase::CRegBase()
-{
-}
-
-CRegBase::CRegBase (const CString& key, bool force, HKEY base, REGSAM sam)
- : CRegBaseCommon<CString> (key, force, base, sam)
-{
- m_key.TrimLeft(_T("\\"));
- int backslashpos = m_key.ReverseFind('\\');
- m_path = m_key.Left(backslashpos);
- m_path.TrimRight(_T("\\"));
- m_key = m_key.Mid(backslashpos);
- m_key.Trim(_T("\\"));
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-CRegStdBase::CRegStdBase()
-{
-}
-
-CRegStdBase::CRegStdBase (const tstring& key, bool force, HKEY base, REGSAM sam)
- : CRegBaseCommon<tstring> (key, force, base, sam)
-{
- tstring::size_type pos = key.find_last_of(_T('\\'));
- if (pos != tstring::npos)
- {
- m_path = key.substr(0, pos);
- m_key = key.substr(pos + 1);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef __ATLTYPES_H__ // defines CRect
-CRegRect::CRegRect(void)
- : CRegTypedBase<CRect, CRegBase>(CRect(0,0,0,0))
-{
-}
-
-CRegRect::CRegRect(const CString& key, const CRect& def, bool force, HKEY base, REGSAM sam)
- : CRegTypedBase<CRect, CRegBase> (key, def, force, base, sam)
-{
- read();
-}
-
-void CRegRect::InternalRead (HKEY hKey, CRect& value)
-{
- DWORD size = 0;
- DWORD type = 0;
- RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size);
-
- auto_buffer<char> buffer (size);
- if ((LastError = RegQueryValueEx(hKey, m_key, NULL, &type, (BYTE*) buffer.get(), &size))==ERROR_SUCCESS)
- {
- ASSERT(type==REG_BINARY);
- value = CRect((LPRECT)buffer.get());
- }
-}
-
-void CRegRect::InternalWrite (HKEY hKey, const CRect& value)
-{
- LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)(LPCRECT)value, sizeof(value));
-}
-
-#endif
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef __ATLTYPES_H__ // defines CPoint
-CRegPoint::CRegPoint(void)
- : CRegTypedBase<CPoint, CRegBase>(CPoint(0,0))
-{
-}
-
-CRegPoint::CRegPoint(const CString& key, const CPoint& def, bool force, HKEY base, REGSAM sam)
- : CRegTypedBase<CPoint, CRegBase> (key, def, force, base, sam)
-{
- read();
-}
-
-void CRegPoint::InternalRead (HKEY hKey, CPoint& value)
-{
- DWORD size = 0;
- DWORD type = 0;
- RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size);
-
- auto_buffer<char> buffer(size);
- if ((LastError = RegQueryValueEx(hKey, m_key, NULL, &type, (BYTE*) buffer.get(), &size))==ERROR_SUCCESS)
- {
- ASSERT(type==REG_BINARY);
- value = CPoint(*(POINT*)buffer.get());
- }
-}
-
-void CRegPoint::InternalWrite (HKEY hKey, const CPoint& value)
-{
- LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)&value, sizeof(value));
-}
-#endif
-
-/////////////////////////////////////////////////////////////////////
-
-#ifdef __AFXCOLL_H__ // defines CStringList
-CRegistryKey::CRegistryKey(const CString& key, HKEY base, REGSAM sam)
-{
- m_base = base;
- m_hKey = NULL;
- m_sam = sam;
- m_path = key;
- m_path.TrimLeft(_T("\\"));
-}
-
-CRegistryKey::~CRegistryKey()
-{
- if (m_hKey)
- RegCloseKey(m_hKey);
-}
-
-DWORD CRegistryKey::createKey()
-{
- DWORD disp;
- DWORD rc = RegCreateKeyEx(m_base, m_path, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE|m_sam, NULL, &m_hKey, &disp);
- if (rc != ERROR_SUCCESS)
- {
- return rc;
- }
- return RegCloseKey(m_hKey);
-}
-
-DWORD CRegistryKey::removeKey()
-{
- RegOpenKeyEx(m_base, m_path, 0, KEY_WRITE|m_sam, &m_hKey);
- return SHDeleteKey(m_base, (LPCTSTR)m_path);
-}
-
-bool CRegistryKey::getValues(CStringList& values)
-{
- values.RemoveAll();
-
- if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS)
- {
- for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++)
- {
- TCHAR value[255];
- DWORD size = sizeof value / sizeof TCHAR;
- rc = RegEnumValue(m_hKey, i, value, &size, NULL, NULL, NULL, NULL);
- if (rc == ERROR_SUCCESS)
- {
- values.AddTail(value);
- }
- }
- }
-
- return values.GetCount() > 0;
-}
-
-bool CRegistryKey::getSubKeys(CStringList& subkeys)
-{
- subkeys.RemoveAll();
-
- if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS)
- {
- for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++)
- {
- TCHAR value[1024];
- DWORD size = sizeof value / sizeof TCHAR;
- FILETIME last_write_time;
- rc = RegEnumKeyEx(m_hKey, i, value, &size, NULL, NULL, NULL, &last_write_time);
- if (rc == ERROR_SUCCESS)
- {
- subkeys.AddTail(value);
- }
- }
- }
-
- return subkeys.GetCount() > 0;
-}
-#endif
-
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2003-2006,2008-2009 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+#include "stdafx.h"
+#include "registry.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __CSTRINGT_H__
+CRegBase::CRegBase()
+{
+}
+
+CRegBase::CRegBase (const CString& key, bool force, HKEY base, REGSAM sam)
+ : CRegBaseCommon<CString> (key, force, base, sam)
+{
+ m_key.TrimLeft(_T("\\"));
+ int backslashpos = m_key.ReverseFind('\\');
+ m_path = m_key.Left(backslashpos);
+ m_path.TrimRight(_T("\\"));
+ m_key = m_key.Mid(backslashpos);
+ m_key.Trim(_T("\\"));
+}
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+CRegStdBase::CRegStdBase()
+{
+}
+
+CRegStdBase::CRegStdBase (const tstring& key, bool force, HKEY base, REGSAM sam)
+ : CRegBaseCommon<tstring> (key, force, base, sam)
+{
+ tstring::size_type pos = key.find_last_of(_T('\\'));
+ if (pos != tstring::npos)
+ {
+ m_path = key.substr(0, pos);
+ m_key = key.substr(pos + 1);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __ATLTYPES_H__ // defines CRect
+CRegRect::CRegRect(void)
+ : CRegTypedBase<CRect, CRegBase>(CRect(0,0,0,0))
+{
+}
+
+CRegRect::CRegRect(const CString& key, const CRect& def, bool force, HKEY base, REGSAM sam)
+ : CRegTypedBase<CRect, CRegBase> (key, def, force, base, sam)
+{
+ read();
+}
+
+void CRegRect::InternalRead (HKEY hKey, CRect& value)
+{
+ DWORD size = 0;
+ DWORD type = 0;
+ RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size);
+
+ auto_buffer<char> buffer (size);
+ if ((LastError = RegQueryValueEx(hKey, m_key, NULL, &type, (BYTE*) buffer.get(), &size))==ERROR_SUCCESS)
+ {
+ ASSERT(type==REG_BINARY);
+ value = CRect((LPRECT)buffer.get());
+ }
+}
+
+void CRegRect::InternalWrite (HKEY hKey, const CRect& value)
+{
+ LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)(LPCRECT)value, sizeof(value));
+}
+
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef __ATLTYPES_H__ // defines CPoint
+CRegPoint::CRegPoint(void)
+ : CRegTypedBase<CPoint, CRegBase>(CPoint(0,0))
+{
+}
+
+CRegPoint::CRegPoint(const CString& key, const CPoint& def, bool force, HKEY base, REGSAM sam)
+ : CRegTypedBase<CPoint, CRegBase> (key, def, force, base, sam)
+{
+ read();
+}
+
+void CRegPoint::InternalRead (HKEY hKey, CPoint& value)
+{
+ DWORD size = 0;
+ DWORD type = 0;
+ RegQueryValueEx(hKey, m_key, NULL, &type, NULL, (LPDWORD) &size);
+
+ auto_buffer<char> buffer(size);
+ if ((LastError = RegQueryValueEx(hKey, m_key, NULL, &type, (BYTE*) buffer.get(), &size))==ERROR_SUCCESS)
+ {
+ ASSERT(type==REG_BINARY);
+ value = CPoint(*(POINT*)buffer.get());
+ }
+}
+
+void CRegPoint::InternalWrite (HKEY hKey, const CPoint& value)
+{
+ LastError = RegSetValueEx(hKey, m_key, 0, REG_BINARY, (BYTE *)&value, sizeof(value));
+}
+#endif
+
+/////////////////////////////////////////////////////////////////////
+
+#ifdef __AFXCOLL_H__ // defines CStringList
+CRegistryKey::CRegistryKey(const CString& key, HKEY base, REGSAM sam)
+{
+ m_base = base;
+ m_hKey = NULL;
+ m_sam = sam;
+ m_path = key;
+ m_path.TrimLeft(_T("\\"));
+}
+
+CRegistryKey::~CRegistryKey()
+{
+ if (m_hKey)
+ RegCloseKey(m_hKey);
+}
+
+DWORD CRegistryKey::createKey()
+{
+ DWORD disp;
+ DWORD rc = RegCreateKeyEx(m_base, m_path, 0, _T(""), REG_OPTION_NON_VOLATILE, KEY_WRITE|m_sam, NULL, &m_hKey, &disp);
+ if (rc != ERROR_SUCCESS)
+ {
+ return rc;
+ }
+ return RegCloseKey(m_hKey);
+}
+
+DWORD CRegistryKey::removeKey()
+{
+ RegOpenKeyEx(m_base, m_path, 0, KEY_WRITE|m_sam, &m_hKey);
+ return SHDeleteKey(m_base, (LPCTSTR)m_path);
+}
+
+bool CRegistryKey::getValues(CStringList& values)
+{
+ values.RemoveAll();
+
+ if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS)
+ {
+ for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++)
+ {
+ TCHAR value[255];
+ DWORD size = sizeof value / sizeof TCHAR;
+ rc = RegEnumValue(m_hKey, i, value, &size, NULL, NULL, NULL, NULL);
+ if (rc == ERROR_SUCCESS)
+ {
+ values.AddTail(value);
+ }
+ }
+ }
+
+ return values.GetCount() > 0;
+}
+
+bool CRegistryKey::getSubKeys(CStringList& subkeys)
+{
+ subkeys.RemoveAll();
+
+ if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS)
+ {
+ for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++)
+ {
+ TCHAR value[1024];
+ DWORD size = sizeof value / sizeof TCHAR;
+ FILETIME last_write_time;
+ rc = RegEnumKeyEx(m_hKey, i, value, &size, NULL, NULL, NULL, &last_write_time);
+ if (rc == ERROR_SUCCESS)
+ {
+ subkeys.AddTail(value);
+ }
+ }
+ }
+
+ return subkeys.GetCount() > 0;
+}
+#endif
+
|
@@ -1,40 +1,40 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2008 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-#include "StdAfx.h"
-#include "SysInfo.h"
-
-SysInfo::SysInfo(void)
-{
- SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
- inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- GetVersionEx((OSVERSIONINFO *)&inf);
-}
-
-SysInfo::~SysInfo(void)
-{
-}
-
-const SysInfo& SysInfo::Instance()
-{
- static SysInfo instance;
- return instance;
-}
-
-
-
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2008 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+#include "StdAfx.h"
+#include "SysInfo.h"
+
+SysInfo::SysInfo(void)
+{
+ SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));
+ inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ GetVersionEx((OSVERSIONINFO *)&inf);
+}
+
+SysInfo::~SysInfo(void)
+{
+}
+
+const SysInfo& SysInfo::Instance()
+{
+ static SysInfo instance;
+ return instance;
+}
+
+
+
|
@@ -1,42 +1,42 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2008 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-#pragma once
-
-
-/**
- * \ingroup Utils
- * This singleton class handles system information
- */
-class SysInfo
-{
-private:
- SysInfo(void);
- ~SysInfo(void);
-public:
- static const SysInfo& Instance();
-
- DWORD GetFullVersion() const {return MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);}
- bool IsXP() const {return (GetFullVersion() < 0x0600);} // cover Win5.1 and 5.2 alike
- bool IsVista() const {return (GetFullVersion() == 0x0600);}
- bool IsVistaOrLater() const {return (GetFullVersion() >= 0x0600);}
- bool IsWin7() const {return (GetFullVersion() == 0x0601);}
- bool IsWin7OrLater() const {return (GetFullVersion() >= 0x0601);}
-private:
- OSVERSIONINFOEX inf;
-};
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2008 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+#pragma once
+
+
+/**
+ * \ingroup Utils
+ * This singleton class handles system information
+ */
+class SysInfo
+{
+private:
+ SysInfo(void);
+ ~SysInfo(void);
+public:
+ static const SysInfo& Instance();
+
+ DWORD GetFullVersion() const {return MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);}
+ bool IsXP() const {return (GetFullVersion() < 0x0600);} // cover Win5.1 and 5.2 alike
+ bool IsVista() const {return (GetFullVersion() == 0x0600);}
+ bool IsVistaOrLater() const {return (GetFullVersion() >= 0x0600);}
+ bool IsWin7() const {return (GetFullVersion() == 0x0601);}
+ bool IsWin7OrLater() const {return (GetFullVersion() >= 0x0601);}
+private:
+ OSVERSIONINFOEX inf;
+};
|
@@ -1,91 +1,91 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2009 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-#pragma once
-
-/**
- * A simplified analog to std::auto_ptr<> that encapsulates
- * an array allocated dynamically via new[].
- *
- * Use this where you could not use a std::auto_ptr<> (works
- * for single elements only) nor a std::vector<> (no guarantees
- * w.r.t. to internal organization, i.e. no access to mem buffer).
- */
-
-template<class T>
-class auto_buffer
-{
-private:
-
- T* buffer;
-
- /// no copy nor assignment
-
- auto_buffer(const auto_buffer&);
- auto_buffer& operator=(const auto_buffer&);
-
-public:
-
- explicit auto_buffer (size_t size = 0) throw()
- : buffer (size == 0 ? NULL : new T[size])
- {
- }
-
- ~auto_buffer()
- {
- delete[] buffer;
- }
-
- operator T*() const throw()
- {
- return buffer;
- }
-
- operator void*() const throw()
- {
- return buffer;
- }
-
- operator bool() const throw()
- {
- return buffer != NULL;
- }
-
- T* operator->() const throw()
- {
- return buffer;
- }
-
- T *get() const throw()
- {
- return buffer;
- }
-
- T* release() throw()
- {
- T* temp = buffer;
- buffer = NULL;
- return temp;
- }
-
- void reset (size_t newSize = 0)
- {
- delete[] buffer;
- buffer = (newSize == 0 ? NULL : new T[newSize]);
- }
-};
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2009 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+#pragma once
+
+/**
+ * A simplified analog to std::auto_ptr<> that encapsulates
+ * an array allocated dynamically via new[].
+ *
+ * Use this where you could not use a std::auto_ptr<> (works
+ * for single elements only) nor a std::vector<> (no guarantees
+ * w.r.t. to internal organization, i.e. no access to mem buffer).
+ */
+
+template<class T>
+class auto_buffer
+{
+private:
+
+ T* buffer;
+
+ /// no copy nor assignment
+
+ auto_buffer(const auto_buffer&);
+ auto_buffer& operator=(const auto_buffer&);
+
+public:
+
+ explicit auto_buffer (size_t size = 0) throw()
+ : buffer (size == 0 ? NULL : new T[size])
+ {
+ }
+
+ ~auto_buffer()
+ {
+ delete[] buffer;
+ }
+
+ operator T*() const throw()
+ {
+ return buffer;
+ }
+
+ operator void*() const throw()
+ {
+ return buffer;
+ }
+
+ operator bool() const throw()
+ {
+ return buffer != NULL;
+ }
+
+ T* operator->() const throw()
+ {
+ return buffer;
+ }
+
+ T *get() const throw()
+ {
+ return buffer;
+ }
+
+ T* release() throw()
+ {
+ T* temp = buffer;
+ buffer = NULL;
+ return temp;
+ }
+
+ void reset (size_t newSize = 0)
+ {
+ delete[] buffer;
+ buffer = (newSize == 0 ? NULL : new T[newSize]);
+ }
+};
|
This file's diff was not loaded because this changeset is very large. Load changes Loading... |
@@ -1,31 +1,31 @@ - //{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by shellext.rc
-//
-
-#define IDS_APP_TITLE 103
-
-#define IDR_MAINFRAME 128
-#define IDD_SHELLEXT_DIALOG 102
-#define IDD_ABOUTBOX 103
-#define IDM_ABOUT 104
-#define IDM_EXIT 105
-#define IDI_SHELLEXT 107
-#define IDI_SMALL 108
-#define IDC_SHELLEXT 109
-#define IDC_MYICON 2
-#ifndef IDC_STATIC
-#define IDC_STATIC -1
-#endif
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-
-#define _APS_NO_MFC 130
-#define _APS_NEXT_RESOURCE_VALUE 129
-#define _APS_NEXT_COMMAND_VALUE 32771
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 110
-#endif
-#endif
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by shellext.rc
+//
+
+#define IDS_APP_TITLE 103
+
+#define IDR_MAINFRAME 128
+#define IDD_SHELLEXT_DIALOG 102
+#define IDD_ABOUTBOX 103
+#define IDM_ABOUT 104
+#define IDM_EXIT 105
+#define IDI_SHELLEXT 107
+#define IDI_SMALL 108
+#define IDC_SHELLEXT 109
+#define IDC_MYICON 2
+#ifndef IDC_STATIC
+#define IDC_STATIC -1
+#endif
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NO_MFC 130
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
|
@@ -1,25 +1,25 @@ - // TortoiseSVN - a Windows shell extension for easy version control
-
-// Copyright (C) 2009 - TortoiseSVN
-
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software Foundation,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-#pragma once
-
-#include <string>
-#include <tchar.h>
-
-typedef std::basic_string<TCHAR> tstring;
-
+// TortoiseSVN - a Windows shell extension for easy version control
+
+// Copyright (C) 2009 - TortoiseSVN
+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+#pragma once
+
+#include <string>
+#include <tchar.h>
+
+typedef std::basic_string<TCHAR> tstring;
+
|
Loading...