1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <win/svsys.h>
13 #include <win/wincomp.hxx>
14 #include <win/saldata.hxx>
18 template <typename H
, auto DeleterFunc
> struct GDIDeleter
21 void operator()(H h
) { DeleterFunc(h
); }
24 template <typename H
, auto DeleterFunc
>
25 using ScopedGDI
= std::unique_ptr
<H
, GDIDeleter
<H
, DeleterFunc
>>;
27 using ScopedHBRUSH
= ScopedGDI
<HBRUSH
, DeleteBrush
>;
28 using ScopedHRGN
= ScopedGDI
<HRGN
, DeleteRegion
>;
29 using ScopedHDC
= ScopedGDI
<HDC
, DeleteDC
>;
30 using ScopedHPEN
= ScopedGDI
<HPEN
, DeletePen
>;
31 using ScopedHFONT
= ScopedGDI
<HFONT
, DeleteFont
>;
32 using ScopedHBITMAP
= ScopedGDI
<HBITMAP
, DeleteBitmap
>;
34 template <typename ScopedH
, auto SelectorFunc
> class ScopedSelectedGDI
37 ScopedSelectedGDI(HDC hDC
, typename
ScopedH::pointer h
)
40 , m_hOrigH(SelectorFunc(hDC
, h
))
44 ~ScopedSelectedGDI() { SelectorFunc(m_hDC
, m_hOrigH
); }
49 typename
ScopedH::pointer m_hOrigH
;
52 using ScopedSelectedHPEN
= ScopedSelectedGDI
<ScopedHPEN
, SelectPen
>;
53 using ScopedSelectedHFONT
= ScopedSelectedGDI
<ScopedHFONT
, SelectFont
>;
54 using ScopedSelectedHBRUSH
= ScopedSelectedGDI
<ScopedHBRUSH
, SelectBrush
>;
56 template <sal_uLong ID
> class ScopedCachedHDC
59 explicit ScopedCachedHDC(HBITMAP hBitmap
)
60 : m_hDC(ImplGetCachedDC(ID
, hBitmap
))
64 ~ScopedCachedHDC() { ImplReleaseCachedDC(ID
); }
66 HDC
get() const { return m_hDC
; }
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */