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 The 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 wxImage;
29class wxDC;
30class wxGCDC;
31
32namespace KIGFX
33{
40{
41public:
42 CAIRO_PRINT_CTX( wxImage* aImage, double aDPI );
43 CAIRO_PRINT_CTX( wxDC* aDC );
45
46 cairo_t* GetContext() const
47 {
48 return m_ctx;
49 }
50
51 cairo_surface_t* GetSurface() const
52 {
53 return m_surface;
54 }
55
56 double GetNativeDPI() const override
57 {
58 return m_dpi;
59 }
60
61 bool HasNativeLandscapeRotation() const override
62 {
63#if defined(__WXGTK__) && !defined(__WXGTK3__)
64 return false;
65#else
66 return true;
67#endif
68 }
69
70private:
71 wxGCDC* m_gcdc = nullptr;
72 wxImage* m_targetImage = nullptr;
73 cairo_t* m_ctx = nullptr;
74 cairo_surface_t* m_surface = nullptr;
75
76#ifdef __WXMSW__
78 void* m_hdc = nullptr; // the real type is HDC, but do not pull in extra headers
79#endif /* __WXMSW__ */
80
81 double m_dpi = 72.0;
82};
83
84
86{
87public:
88 CAIRO_PRINT_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions,
89 std::unique_ptr<CAIRO_PRINT_CTX> aContext );
90
91 static std::unique_ptr<CAIRO_PRINT_GAL> Create( GAL_DISPLAY_OPTIONS& aOptions, wxImage* aImage, double aDPI );
92
93 void ComputeWorldScreenMatrix() override;
94
95 GAL* GetGAL() override
96 {
97 return this;
98 }
99
100 PRINT_CONTEXT* GetPrintCtx() const override
101 {
102 return m_printCtx.get();
103 }
104
110 void SetNativePaperSize( const VECTOR2D& aSize, bool aRotateIfLandscape ) override;
111
115 void SetSheetSize( const VECTOR2D& aSize ) override;
116
117private:
119 bool isLandscape() const
120 {
122 }
123
126
130
131 std::unique_ptr<CAIRO_PRINT_CTX> m_printCtx;
132};
133} // namespace KIGFX
134
135#endif /* _CAIRO_PRINT_H_ */
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition cairo_gal.cpp:52
bool HasNativeLandscapeRotation() const override
Definition cairo_print.h:61
CAIRO_PRINT_CTX(wxImage *aImage, double aDPI)
cairo_t * GetContext() const
Definition cairo_print.h:46
double GetNativeDPI() const override
Definition cairo_print.h:56
cairo_surface_t * m_surface
Definition cairo_print.h:74
cairo_surface_t * GetSurface() const
Definition cairo_print.h:51
PRINT_CONTEXT * GetPrintCtx() const override
GAL * GetGAL() override
Definition cairo_print.h:95
bool isLandscape() const
< Returns true if page orientation is landscape
CAIRO_PRINT_GAL(GAL_DISPLAY_OPTIONS &aDisplayOptions, std::unique_ptr< CAIRO_PRINT_CTX > aContext)
std::unique_ptr< CAIRO_PRINT_CTX > m_printCtx
static std::unique_ptr< CAIRO_PRINT_GAL > Create(GAL_DISPLAY_OPTIONS &aOptions, wxImage *aImage, double aDPI)
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...
Wrapper around GAL to provide information needed for printing.
Definition gal_print.h:45
Abstract interface for drawing on a 2D-surface.
#define GAL_API
Definition gal.h:28
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
VECTOR2< double > VECTOR2D
Definition vector2d.h:694