KiCad PCB EDA Suite
HIDPI_GL_CANVAS Class Reference

wxGLCanvas wrapper for HiDPI/Retina support. More...

#include <hidpi_gl_canvas.h>

Inheritance diagram for HIDPI_GL_CANVAS:

Public Member Functions

 HIDPI_GL_CANVAS (wxWindow *parent, wxWindowID id=wxID_ANY, const int *attribList=NULL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxGLCanvasName, const wxPalette &palette=wxNullPalette)
virtual wxSize GetNativePixelSize () const
virtual float GetBackingScaleFactor () const
void SetScaleFactor (double aFactor)
 Set the canvas scale factor, probably for a hi-DPI display. More...
double GetScaleFactor () const
 Get the current scale factor. More...

Private Attributes

double m_scale_factor
 The current scale factor (e.g. More...

Detailed Description

wxGLCanvas wrapper for HiDPI/Retina support.

This is a small wrapper class to enable HiDPI/Retina support for wxGLCanvas. HiDPI currently only works with a patched wxWidgets version, see:

Definition at line 40 of file hidpi_gl_canvas.h.

Constructor & Destructor Documentation


HIDPI_GL_CANVAS::HIDPI_GL_CANVAS ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const int *  attribList = NULL,
const wxPoint pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = wxGLCanvasName,
const wxPalette &  palette = wxNullPalette 

Definition at line 32 of file hidpi_gl_canvas.cpp.

35  : wxGLCanvas( parent, id, attribList, pos, size, style, name, palette ),
37 {
39  SetViewWantsBestResolution( true );
40 #endif
41 }
static double GetDefaultScaleFactor()
Get the "default" scaling factor to use if not other config is available.
double m_scale_factor
The current scale factor (e.g.
const char * name
Definition: DXF_plotter.cpp:60

Member Function Documentation

◆ GetBackingScaleFactor()

float HIDPI_GL_CANVAS::GetBackingScaleFactor ( ) const

Definition at line 56 of file hidpi_gl_canvas.cpp.

57 {
59  // this is ugly, but original method isn't marked const although it doesn't modify anything
60  // => clean up when it officially has arrived in wxWidgets
61  return static_cast< wxGLCanvas* >( const_cast< HIDPI_GL_CANVAS* >( this ))->GetBackingScaleFactor();
62 #else
64  // Return the cached value (which originally was set from config or automatically)
65  return m_scale_factor;
66 #endif
67 }
double m_scale_factor
The current scale factor (e.g.

References m_scale_factor.

Referenced by KIGFX::OPENGL_GAL::beginDrawing(), KIGFX::OPENGL_GAL::DrawGrid(), GetNativePixelSize(), KIGFX::OPENGL_GAL::getScreenPixelSize(), and KIGFX::OPENGL_GAL::ResizeScreen().

◆ GetNativePixelSize()

wxSize HIDPI_GL_CANVAS::GetNativePixelSize ( ) const

Definition at line 44 of file hidpi_gl_canvas.cpp.

45 {
46  wxSize size = wxGLCanvas::GetClientSize();
48  const float scaleFactor = GetBackingScaleFactor();
49  size.x *= scaleFactor;
50  size.y *= scaleFactor;
52  return size;
53 }
virtual float GetBackingScaleFactor() const

References GetBackingScaleFactor().

Referenced by EDA_3D_CANVAS::OnMouseMove(), EDA_3D_CANVAS::OnPaint(), and KIGFX::OPENGL_GAL::OPENGL_GAL().

◆ GetScaleFactor()

double HIDPI_GL_CANVAS::GetScaleFactor ( ) const

Get the current scale factor.

Definition at line 76 of file hidpi_gl_canvas.cpp.

77 {
78  return m_scale_factor;
79 }
double m_scale_factor
The current scale factor (e.g.

References m_scale_factor.

Referenced by KIGFX::OPENGL_GAL::updatedGalDisplayOptions().

◆ SetScaleFactor()

void HIDPI_GL_CANVAS::SetScaleFactor ( double  aFactor)

Set the canvas scale factor, probably for a hi-DPI display.

Definition at line 70 of file hidpi_gl_canvas.cpp.

71 {
72  m_scale_factor = aNewScaleFactor;
73 }
double m_scale_factor
The current scale factor (e.g.

References m_scale_factor.

Referenced by PANEL_PREV_3D::loadCommonSettings(), EDA_3D_VIEWER::loadCommonSettings(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().

Member Data Documentation

◆ m_scale_factor

double HIDPI_GL_CANVAS::m_scale_factor

The current scale factor (e.g.

for hi-DPI displays)

Definition at line 71 of file hidpi_gl_canvas.h.

Referenced by GetBackingScaleFactor(), GetScaleFactor(), and SetScaleFactor().

The documentation for this class was generated from the following files: