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:
C3D_MODEL_VIEWER EDA_3D_CANVAS KIGFX::OPENGL_GAL

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 GetClientSize () const
 
virtual float GetBackingScaleFactor () const
 

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: http://trac.wxwidgets.org/ticket/15700

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 30 of file hidpi_gl_canvas.cpp.

37  :
38  wxGLCanvas( parent, id, attribList, pos, size, style, name, palette )
39 {
40 #ifdef RETINA_OPENGL_PATCH
41  SetViewWantsBestResolution( true );
42 #endif
43 }
const char * name
Definition: DXF_plotter.cpp:61

Member Function Documentation

float HIDPI_GL_CANVAS::GetBackingScaleFactor ( ) const
virtual

Definition at line 59 of file hidpi_gl_canvas.cpp.

Referenced by GetClientSize(), and KIGFX::OPENGL_GAL::ResizeScreen().

60 {
61 #ifdef RETINA_OPENGL_PATCH
62  // this is ugly, but original method isn't marked const although it doesn't modify anything
63  // => clean up when it officially has arrived in wxWidgets
64  return static_cast< wxGLCanvas* >( const_cast< HIDPI_GL_CANVAS* >( this ))->GetBackingScaleFactor();
65 #else
66  return 1.0f;
67 #endif
68 }
wxGLCanvas wrapper for HiDPI/Retina support.
wxSize HIDPI_GL_CANVAS::GetClientSize ( ) const
virtual

Definition at line 46 of file hidpi_gl_canvas.cpp.

References GetBackingScaleFactor().

Referenced by C3D_MODEL_VIEWER::OnMouseMove(), EDA_3D_CANVAS::OnMouseMove(), C3D_MODEL_VIEWER::OnPaint(), and EDA_3D_CANVAS::OnPaint().

47 {
48  wxSize size = wxGLCanvas::GetClientSize();
49 
50 #ifdef RETINA_OPENGL_PATCH
51  const float scaleFactor = GetBackingScaleFactor();
52  size.x *= scaleFactor;
53  size.y *= scaleFactor;
54 #endif
55 
56  return size;
57 }
virtual float GetBackingScaleFactor() const

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