virtual void GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height,
wxDouble *descent, wxDouble *externalLeading ) const;
virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const;
+ virtual bool ShouldOffset() const;
private:
void Init();
void wxGDIPlusPathData::AddArc( wxDouble x, wxDouble y, wxDouble r, double startAngle, double endAngle, bool clockwise )
{
double sweepAngle = endAngle - startAngle ;
- if( abs(sweepAngle) >= 2*M_PI)
+ if( fabs(sweepAngle) >= 2*M_PI)
{
sweepAngle = 2 * M_PI;
}
}
}
+bool wxGDIPlusContext::ShouldOffset() const
+{
+ int penwidth = 0 ;
+ if ( !m_pen.IsNull() )
+ {
+ penwidth = (int)((wxGDIPlusPenData*)m_pen.GetRefData())->GetWidth();
+ if ( penwidth == 0 )
+ penwidth = 1;
+ }
+ return ( penwidth % 2 ) == 1;
+}
+
void* wxGDIPlusContext::GetNativeContext()
{
return m_context;
void EnsureIsLoaded();
void Load();
void Unload();
+ friend class wxGDIPlusRendererModule;
private :
bool m_loaded;
void wxGDIPlusRenderer::Unload()
{
if ( m_gditoken )
+ {
GdiplusShutdown(m_gditoken);
+ m_gditoken = NULL;
+ }
+ m_loaded = false;
}
wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxWindowDC& dc)
return wxNullGraphicsFont;
}
+// Shutdown GDI+ at app exit, before possible dll unload
+class wxGDIPlusRendererModule : public wxModule
+{
+public:
+ virtual bool OnInit() { return true; }
+ virtual void OnExit() { gs_GDIPlusRenderer.Unload(); }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxGDIPlusRendererModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusRendererModule, wxModule)
+
#endif // wxUSE_GRAPHICS_CONTEXT