Simplify and rationalize wxGDIPlusContext class constructors.
Remove the now unnecessary default ctor from wxGDIPlusContext and wxGDIPlusMeasuringContext and add a ctor taking just wxGraphicsRenderer that can be useful to the derived classes instead. Merge Init() and SetDefaults() and initialize everything at once in the new Init() now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69356 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -309,7 +309,7 @@ public:
|
|||||||
wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height );
|
wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height );
|
||||||
wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd );
|
wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd );
|
||||||
wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr);
|
wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr);
|
||||||
wxGDIPlusContext();
|
wxGDIPlusContext(wxGraphicsRenderer* renderer);
|
||||||
|
|
||||||
virtual ~wxGDIPlusContext();
|
virtual ~wxGDIPlusContext();
|
||||||
|
|
||||||
@@ -377,10 +377,11 @@ protected:
|
|||||||
|
|
||||||
wxDouble m_fontScaleRatio;
|
wxDouble m_fontScaleRatio;
|
||||||
|
|
||||||
private:
|
// Used from ctors (including those in the derived classes) and takes
|
||||||
void Init();
|
// ownership of the graphics pointer that must be non-NULL.
|
||||||
void SetDefaults();
|
void Init(Graphics* graphics, int width, int height);
|
||||||
|
|
||||||
|
private:
|
||||||
virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y)
|
virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y)
|
||||||
{ DoDrawFilledText(str, x, y, wxNullGraphicsBrush); }
|
{ DoDrawFilledText(str, x, y, wxNullGraphicsBrush); }
|
||||||
virtual void DoDrawFilledText(const wxString& str, wxDouble x, wxDouble y,
|
virtual void DoDrawFilledText(const wxString& str, wxDouble x, wxDouble y,
|
||||||
@@ -400,9 +401,6 @@ public:
|
|||||||
wxGDIPlusMeasuringContext( wxGraphicsRenderer* renderer ) : wxGDIPlusContext( renderer , m_hdc = GetDC(NULL), 1000, 1000 )
|
wxGDIPlusMeasuringContext( wxGraphicsRenderer* renderer ) : wxGDIPlusContext( renderer , m_hdc = GetDC(NULL), 1000, 1000 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
wxGDIPlusMeasuringContext()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~wxGDIPlusMeasuringContext()
|
virtual ~wxGDIPlusMeasuringContext()
|
||||||
{
|
{
|
||||||
@@ -1269,66 +1267,50 @@ public :
|
|||||||
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height )
|
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HDC hdc, wxDouble width, wxDouble height )
|
||||||
: wxGraphicsContext(renderer)
|
: wxGraphicsContext(renderer)
|
||||||
{
|
{
|
||||||
Init();
|
Init(new Graphics(hdc), width, height);
|
||||||
m_context = new Graphics( hdc);
|
|
||||||
m_width = width;
|
|
||||||
m_height = height;
|
|
||||||
SetDefaults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc )
|
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, const wxDC& dc )
|
||||||
: wxGraphicsContext(renderer)
|
: wxGraphicsContext(renderer)
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
|
|
||||||
wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl );
|
wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl );
|
||||||
HDC hdc = (HDC) msw->GetHDC();
|
HDC hdc = (HDC) msw->GetHDC();
|
||||||
|
|
||||||
m_context = new Graphics(hdc);
|
|
||||||
wxSize sz = dc.GetSize();
|
wxSize sz = dc.GetSize();
|
||||||
m_width = sz.x;
|
|
||||||
m_height = sz.y;
|
|
||||||
|
|
||||||
SetDefaults();
|
Init(new Graphics(hdc), sz.x, sz.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd )
|
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, HWND hwnd )
|
||||||
: wxGraphicsContext(renderer)
|
: wxGraphicsContext(renderer)
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
m_enableOffset = true;
|
|
||||||
m_context = new Graphics( hwnd);
|
|
||||||
RECT rect = wxGetWindowRect(hwnd);
|
RECT rect = wxGetWindowRect(hwnd);
|
||||||
m_width = rect.right - rect.left;
|
Init(new Graphics(hwnd), rect.right - rect.left, rect.bottom - rect.top);
|
||||||
m_height = rect.bottom - rect.top;
|
m_enableOffset = true;
|
||||||
SetDefaults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr )
|
wxGDIPlusContext::wxGDIPlusContext( wxGraphicsRenderer* renderer, Graphics* gr )
|
||||||
: wxGraphicsContext(renderer)
|
: wxGraphicsContext(renderer)
|
||||||
{
|
{
|
||||||
Init();
|
Init(gr, 0, 0);
|
||||||
m_context = gr;
|
|
||||||
SetDefaults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGDIPlusContext::wxGDIPlusContext() : wxGraphicsContext(NULL)
|
wxGDIPlusContext::wxGDIPlusContext(wxGraphicsRenderer* renderer)
|
||||||
{
|
: wxGraphicsContext(renderer)
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxGDIPlusContext::Init()
|
|
||||||
{
|
{
|
||||||
|
// Derived class must call Init() later but just set m_context to NULL for
|
||||||
|
// safety to avoid crashing in our dtor if Init() ends up not being called.
|
||||||
m_context = NULL;
|
m_context = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGDIPlusContext::Init(Graphics* graphics, int width, int height)
|
||||||
|
{
|
||||||
|
m_context = graphics;
|
||||||
m_state1 = 0;
|
m_state1 = 0;
|
||||||
m_state2 = 0;
|
m_state2 = 0;
|
||||||
m_height = 0;
|
m_width = width;
|
||||||
m_width = 0;
|
m_height = height;
|
||||||
m_fontScaleRatio = 1.0;
|
m_fontScaleRatio = 1.0;
|
||||||
}
|
|
||||||
|
|
||||||
void wxGDIPlusContext::SetDefaults()
|
|
||||||
{
|
|
||||||
m_context->SetTextRenderingHint(TextRenderingHintSystemDefault);
|
m_context->SetTextRenderingHint(TextRenderingHintSystemDefault);
|
||||||
m_context->SetPixelOffsetMode(PixelOffsetModeHalf);
|
m_context->SetPixelOffsetMode(PixelOffsetModeHalf);
|
||||||
m_context->SetSmoothingMode(SmoothingModeHighQuality);
|
m_context->SetSmoothingMode(SmoothingModeHighQuality);
|
||||||
|
Reference in New Issue
Block a user