2009-12-20 19:48:58 +00:00
|
|
|
/**
|
|
|
|
* a helper to handle the real device context used in kicad
|
|
|
|
* @file kicad_device_context.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __KICAD_DEVICE_CONTEXT_H__
|
|
|
|
#define __KICAD_DEVICE_CONTEXT_H__
|
|
|
|
|
|
|
|
// Comment this line to use the standard wxClientDC
|
|
|
|
// and uncomment to use buffered DC
|
2010-01-03 16:47:46 +00:00
|
|
|
// #define KICAD_USE_BUFFERED_DC // Currently under test
|
2009-12-20 19:48:58 +00:00
|
|
|
|
2010-01-12 13:15:13 +00:00
|
|
|
// Comment this line to use the standard wxPaintDC
|
|
|
|
// and uncomment to use buffered PaintDC
|
|
|
|
#define KICAD_USE_BUFFERED_PAINTDC // Currently under test
|
|
|
|
|
|
|
|
#if defined KICAD_USE_BUFFERED_DC || defined KICAD_USE_BUFFERED_PAINTDC
|
|
|
|
#ifndef KICAD_USE_BUFFERED_PAINTDC
|
|
|
|
#define KICAD_USE_BUFFERED_PAINTDC
|
|
|
|
#endif
|
|
|
|
#include <wx/dcbuffer.h>
|
2009-12-20 19:48:58 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM
|
|
|
|
#include <wx/dcgraph.h>
|
|
|
|
#endif
|
|
|
|
|
2009-12-20 19:48:58 +00:00
|
|
|
// Helper class to handle the client Device Context
|
|
|
|
class KicadGraphicContext : public wxClientDC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KicadGraphicContext( WinEDA_DrawPanel * aDrawPanel );
|
|
|
|
~KicadGraphicContext();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Macro used to declare a device context in kicad:
|
2010-02-08 18:15:42 +00:00
|
|
|
#if USE_WX_GRAPHICS_CONTEXT && USE_WX_ZOOM
|
|
|
|
#define INSTALL_DC(name,parent) \
|
|
|
|
wxClientDC _cDC( parent ); \
|
|
|
|
wxGCDC name(_cDC); \
|
|
|
|
parent->DoPrepareDC( name ); \
|
|
|
|
name.GetGraphicsContext()->Translate( 0.5, 0.5 );
|
|
|
|
#else
|
2009-12-20 19:48:58 +00:00
|
|
|
#ifdef KICAD_USE_BUFFERED_DC
|
2010-02-08 18:15:42 +00:00
|
|
|
#define INSTALL_DC(name,parent) \
|
|
|
|
wxClientDC _cDC( parent ); \
|
|
|
|
wxBufferedDC name(&_cDC, _cDC.GetSize() ); \
|
|
|
|
parent->DoPrepareDC( name );
|
2010-01-12 13:15:13 +00:00
|
|
|
#else
|
2010-02-08 18:15:42 +00:00
|
|
|
#define INSTALL_DC(name,parent) \
|
|
|
|
wxClientDC name( parent ); \
|
|
|
|
parent->DoPrepareDC( name );
|
|
|
|
#endif
|
2010-01-12 13:15:13 +00:00
|
|
|
#endif
|
2009-12-29 10:35:11 +00:00
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
#if USE_WX_GRAPHICS_CONTEXT
|
|
|
|
#define INSTALL_PAINTDC(name,parent) \
|
|
|
|
wxPaintDC _pDC(parent); \
|
|
|
|
wxGCDC name(_pDC); \
|
|
|
|
parent->DoPrepareDC( name ); \
|
|
|
|
name.GetGraphicsContext()->Translate( 0.5, 0.5);
|
|
|
|
#elif !defined( USE_WX_ZOOM ) && defined( KICAD_USE_BUFFERED_PAINTDC )
|
|
|
|
#define INSTALL_PAINTDC(name,parent) \
|
|
|
|
wxAutoBufferedPaintDC name(parent ); \
|
|
|
|
parent->DoPrepareDC( name );
|
2009-12-20 19:48:58 +00:00
|
|
|
#else
|
2010-02-08 18:15:42 +00:00
|
|
|
#define INSTALL_PAINTDC(name,parent) \
|
|
|
|
wxPaintDC name( parent ); \
|
|
|
|
parent->DoPrepareDC( name );
|
2009-12-20 19:48:58 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // __KICAD_DEVICE_CONTEXT_H__
|