KiCad PCB EDA Suite
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 <maciej.suminski@cern.ch>
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
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 
28 class wxDC;
29 class wxGCDC;
30 
31 namespace KIGFX
32 {
39 {
40 public:
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 
68 private:
69  wxGCDC* m_gcdc;
70  cairo_t* m_ctx;
71  cairo_surface_t* m_surface;
72 
73 #ifdef __WXMSW__
74  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 {
84 public:
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 
112 private:
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_ */
Wrapper around GAL to provide information needed for printing.
Definition: gal_print.h:43
double GetNativeDPI() const override
Definition: cairo_print.h:54
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:236
cairo_t * GetContext() const
Definition: cairo_print.h:44
cairo_surface_t * GetSurface() const
Definition: cairo_print.h:49
cairo_surface_t * m_surface
Definition: cairo_print.h:71
void SetNativePaperSize(const VECTOR2D &aSize, bool aRotateIfLandscape) override
std::unique_ptr< CAIRO_PRINT_CTX > m_printCtx
Definition: cairo_print.h:126
bool isLandscape() const
< Returns true if page orientation is landscape
Definition: cairo_print.h:114
void ComputeWorldScreenMatrix() override
Compute the world <-> screen transformation matrix.
bool HasNativeLandscapeRotation() const override
Definition: cairo_print.h:59
GAL * GetGAL() override
Definition: cairo_print.h:90
Provide a Cairo context created from wxPrintDC.
Definition: cairo_print.h:38
CAIRO_PRINT_CTX(wxDC *aDC)
Definition: cairo_print.cpp:50
CAIRO_PRINT_GAL(GAL_DISPLAY_OPTIONS &aDisplayOptions, std::unique_ptr< CAIRO_PRINT_CTX > aContext)
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
PRINT_CONTEXT * GetPrintCtx() const override
Definition: cairo_print.h:95
void SetSheetSize(const VECTOR2D &aSize) override
Abstract interface for drawing on a 2D-surface.