LibreOffice Module vcl (master)
1
vcl
inc
quartz
CGHelpers.hxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This file is part of the LibreOffice project.
4
*
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/.
8
*
9
*/
10
11
#ifndef INCLUDED_VCL_INC_QUARTZ_CGHELPER_HXX
12
#define INCLUDED_VCL_INC_QUARTZ_CGHELPER_HXX
13
14
#include <premac.h>
15
#include <CoreGraphics/CoreGraphics.h>
16
#include <postmac.h>
17
18
#include <
quartz/utils.h
>
19
20
class
CGLayerHolder
21
{
22
private
:
23
CGLayerRef
mpLayer
;
24
25
// Layer's scaling factor
26
float
mfScale
;
27
28
public
:
29
CGLayerHolder
()
30
:
mpLayer
(nullptr)
31
,
mfScale
(1.0)
32
{
33
}
34
35
CGLayerHolder
(CGLayerRef pLayer,
float
fScale = 1.0)
36
:
mpLayer
(pLayer)
37
,
mfScale
(fScale)
38
{
39
}
40
41
// Just the size of the layer in pixels
42
CGSize
getSizePixels
()
const
43
{
44
CGSize aSize;
45
if
(
mpLayer
)
46
{
47
aSize = CGLayerGetSize(
mpLayer
);
48
}
49
return
aSize;
50
}
51
52
// Size in points is size in pixels divided by the scaling factor
53
CGSize
getSizePoints
()
const
54
{
55
CGSize aSize;
56
if
(
mpLayer
)
57
{
58
const
CGSize aLayerSize =
getSizePixels
();
59
aSize.width = aLayerSize.width /
mfScale
;
60
aSize.height = aLayerSize.height /
mfScale
;
61
}
62
return
aSize;
63
}
64
65
CGLayerRef
get
()
const
{
return
mpLayer
; }
66
67
bool
isSet
()
const
{
return
mpLayer
!=
nullptr
; }
68
69
void
set
(CGLayerRef
const
& pLayer) {
mpLayer
= pLayer; }
70
71
float
getScale
()
const
{
return
mfScale
; }
72
73
void
setScale
(
float
fScale) {
mfScale
= fScale; }
74
};
75
76
class
CGContextHolder
77
{
78
private
:
79
CGContextRef
mpContext
;
80
81
public
:
82
CGContextHolder
()
83
:
mpContext
(nullptr)
84
{
85
}
86
87
CGContextHolder
(CGContextRef pContext)
88
:
mpContext
(pContext)
89
{
90
}
91
92
CGContextRef
get
()
const
{
return
mpContext
; }
93
94
bool
isSet
()
const
{
return
mpContext
!=
nullptr
; }
95
96
void
set
(CGContextRef
const
& pContext) {
mpContext
= pContext; }
97
98
void
saveState
() { CGContextSaveGState(
mpContext
); }
99
100
void
restoreState
() { CGContextRestoreGState(
mpContext
); }
101
};
102
103
#endif
// INCLUDED_VCL_INC_QUARTZ_CGHELPER_HXX
104
105
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CGContextHolder
Definition:
CGHelpers.hxx:77
CGContextHolder::set
void set(CGContextRef const &pContext)
Definition:
CGHelpers.hxx:96
CGContextHolder::saveState
void saveState()
Definition:
CGHelpers.hxx:98
CGContextHolder::isSet
bool isSet() const
Definition:
CGHelpers.hxx:94
CGContextHolder::CGContextHolder
CGContextHolder(CGContextRef pContext)
Definition:
CGHelpers.hxx:87
CGContextHolder::get
CGContextRef get() const
Definition:
CGHelpers.hxx:92
CGContextHolder::CGContextHolder
CGContextHolder()
Definition:
CGHelpers.hxx:82
CGContextHolder::restoreState
void restoreState()
Definition:
CGHelpers.hxx:100
CGContextHolder::mpContext
CGContextRef mpContext
Definition:
CGHelpers.hxx:79
CGLayerHolder
Definition:
CGHelpers.hxx:21
CGLayerHolder::setScale
void setScale(float fScale)
Definition:
CGHelpers.hxx:73
CGLayerHolder::set
void set(CGLayerRef const &pLayer)
Definition:
CGHelpers.hxx:69
CGLayerHolder::get
CGLayerRef get() const
Definition:
CGHelpers.hxx:65
CGLayerHolder::CGLayerHolder
CGLayerHolder(CGLayerRef pLayer, float fScale=1.0)
Definition:
CGHelpers.hxx:35
CGLayerHolder::CGLayerHolder
CGLayerHolder()
Definition:
CGHelpers.hxx:29
CGLayerHolder::getSizePixels
CGSize getSizePixels() const
Definition:
CGHelpers.hxx:42
CGLayerHolder::mfScale
float mfScale
Definition:
CGHelpers.hxx:26
CGLayerHolder::getSizePoints
CGSize getSizePoints() const
Definition:
CGHelpers.hxx:53
CGLayerHolder::getScale
float getScale() const
Definition:
CGHelpers.hxx:71
CGLayerHolder::isSet
bool isSet() const
Definition:
CGHelpers.hxx:67
CGLayerHolder::mpLayer
CGLayerRef mpLayer
Definition:
CGHelpers.hxx:23
utils.h
Generated on Sun Jul 30 2023 04:34:59 for LibreOffice Module vcl (master) by
1.9.3