summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDmitriy Shilin <dshil@fastmail.com>2019-01-08 03:39:16 -0800
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-09 11:06:02 +0100
commit8addcffd4c4b1ce8d7e4c8dee01c312b68f1de71 (patch)
tree2ab0e083e7c6d7a1741614cd7daa293517dfd46f /vcl
parent3c97782c7e1ea437511249d750bf882bff17ef09 (diff)
tdf#107792 vcl/win: replace ScopedHDC with type alias
Change-Id: I2d12ebc2a7e353ce685ec5132b0a65b393c36212 Reviewed-on: https://gerrit.libreoffice.org/65962 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/win/ScopedHDC.hxx45
-rw-r--r--vcl/win/gdi/scoped_gdi.hxx7
-rw-r--r--vcl/win/gdi/winlayout.cxx2
3 files changed, 8 insertions, 46 deletions
diff --git a/vcl/inc/win/ScopedHDC.hxx b/vcl/inc/win/ScopedHDC.hxx
deleted file mode 100644
index bd4642ee6642..000000000000
--- a/vcl/inc/win/ScopedHDC.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-#define INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-
-class ScopedHDC
-{
-private:
- HDC m_hDC;
-
-public:
- explicit ScopedHDC(HDC hDC)
- : m_hDC(hDC)
- {}
-
- ScopedHDC(const ScopedHDC&) = delete;
- ScopedHDC& operator=(const ScopedHDC&) = delete;
-
- ~ScopedHDC()
- {
- if (m_hDC)
- DeleteDC(m_hDC);
- }
-
- HDC get() const
- {
- return m_hDC;
- }
-
- explicit operator bool() const
- {
- return m_hDC != nullptr;
- }
-};
-
-#endif // INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/scoped_gdi.hxx b/vcl/win/gdi/scoped_gdi.hxx
index 90af7340f06a..b5a66d9d3698 100644
--- a/vcl/win/gdi/scoped_gdi.hxx
+++ b/vcl/win/gdi/scoped_gdi.hxx
@@ -27,8 +27,15 @@ struct HRGNDeleter
void operator()(HRGN hRgn) { DeleteRegion(hRgn); }
};
+struct HDCDeleter
+{
+ using pointer = HDC;
+ void operator()(HDC hDC) { DeleteDC(hDC); }
+};
+
using ScopedHBRUSH = std::unique_ptr<HBRUSH, HBRUSHDeleter>;
using ScopedHRGN = std::unique_ptr<HRGN, HRGNDeleter>;
+using ScopedHDC = std::unique_ptr<HDC, HDCDeleter>;
#endif // INCLUDED_VCL_WIN_GDI_SCOPED_GDI_HXX
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 91e82e8ba40e..f5e2c025e965 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -38,7 +38,7 @@
#include <sft.hxx>
#include <sallayout.hxx>
-#include <win/ScopedHDC.hxx>
+#include "scoped_gdi.hxx"
#include <cstdio>
#include <cstdlib>