KiCad PCB EDA Suite
Loading...
Searching...
No Matches
cairo_print.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 CERN
3 * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
4 *
5 * Author: Maciej Suminski <[email protected]>
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef _CAIRO_PRINT_H_
23#define _CAIRO_PRINT_H_
24
25#include <gal/cairo/cairo_gal.h>
26#include <gal/gal_print.h>
27
28class wxDC;
29class wxGCDC;
30
31namespace KIGFX
32{
39{
40public:
41 CAIRO_PRINT_CTX( wxDC* aDC );
43
44 cairo_t* GetContext() const
45 {
46 return m_ctx;
47 }
48
49 cairo_surface_t* GetSurface() const
50 {
51 return m_surface;
52 }
53
54 double GetNativeDPI() const override
55 {
56 return m_dpi;
57 }
58
59 bool HasNativeLandscapeRotation() const override
60 {
61#if defined(__WXGTK__) && !defined(__WXGTK3__)
62 return false;
63#else
64 return true;
65#endif
66 }
67
68private:
69 wxGCDC* m_gcdc;
70 cairo_t* m_ctx;
71 cairo_surface_t* m_surface;
72
73#ifdef __WXMSW__
75 void* m_hdc; // the real type is HDC, but do not pull in extra headers
76#endif /* __WXMSW__ */
77
78 double m_dpi;
79};
80
81
83{
84public:
85 CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
86 std::unique_ptr<CAIRO_PRINT_CTX> aContext );
87
88 void ComputeWorldScreenMatrix() override;
89
90 GAL* GetGAL() override
91 {
92 return this;
93 }
94
95 PRINT_CONTEXT* GetPrintCtx() const override
96 {
97 return m_printCtx.get();
98 }
99
105 void SetNativePaperSize( const VECTOR2D& aSize, bool aRotateIfLandscape ) override;
106
110 void SetSheetSize( const VECTOR2D& aSize ) override;
111
112private:
114 bool isLandscape() const
115 {
117 }
118
121
125
126 std::unique_ptr<CAIRO_PRINT_CTX> m_printCtx;
127};
128} // namespace KIGFX
129
130#endif /* _CAIRO_PRINT_H_ */
Provide a Cairo context created from wxPrintDC.
Definition: cairo_print.h:39
bool HasNativeLandscapeRotation() const override
Definition: cairo_print.h:59
cairo_t * GetContext() const
Definition: cairo_print.h:44
double GetNativeDPI() const override
Definition: cairo_print.h:54
cairo_surface_t * m_surface
Definition: cairo_print.h:71
cairo_surface_t * GetSurface() const
Definition: cairo_print.h:49
PRINT_CONTEXT * GetPrintCtx() const override
Definition: cairo_print.h:95
void SetSheetSize(const VECTOR2D &aSize) override
GAL * GetGAL() override
Definition: cairo_print.h:90
bool isLandscape() const
< Returns true if page orientation is landscape
Definition: cairo_print.h:114
void SetNativePaperSize(const VECTOR2D &aSize, bool aRotateIfLandscape) override
std::unique_ptr< CAIRO_PRINT_CTX > m_printCtx
Definition: cairo_print.h:126
void ComputeWorldScreenMatrix() override
Compute the world <-> screen transformation matrix.
VECTOR2D m_nativePaperSize
Flag indicating whether the platform rotates page automatically or GAL needs to handle it in the tran...
Definition: cairo_print.h:120
Wrapper around GAL to provide information needed for printing.
Definition: gal_print.h:44
Abstract interface for drawing on a 2D-surface.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247