remove default wxDC ctor to make it impossible to construct DCs without the associated wxDCImpl (this breaks compilation of classes such as wxMirrorDC instead of crashing at run-time); fixed wxMirrorDC compilation after breaking it; renamed wxDCFactory::GetFactory() to just Get(), no need to be repetitive
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -130,7 +130,8 @@ public:
|
||||
#endif
|
||||
|
||||
static void SetDCFactory( wxDCFactory *factory );
|
||||
static wxDCFactory *GetFactory();
|
||||
static wxDCFactory *Get();
|
||||
|
||||
private:
|
||||
static wxDCFactory *m_factory;
|
||||
};
|
||||
@@ -544,8 +545,7 @@ private:
|
||||
class WXDLLIMPEXP_CORE wxDC : public wxObject
|
||||
{
|
||||
public:
|
||||
wxDC() { m_pimpl = NULL; }
|
||||
~wxDC() { if (m_pimpl) delete m_pimpl; }
|
||||
virtual ~wxDC() { delete m_pimpl; }
|
||||
|
||||
wxDCImpl *GetImpl()
|
||||
{ return m_pimpl; }
|
||||
@@ -1036,10 +1036,14 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
wxDCImpl *m_pimpl;
|
||||
// ctor takes ownership of the pointer
|
||||
wxDC(wxDCImpl *pimpl) : m_pimpl(pimpl) { }
|
||||
|
||||
wxDCImpl * const m_pimpl;
|
||||
|
||||
private:
|
||||
DECLARE_ABSTRACT_CLASS(wxDC)
|
||||
DECLARE_NO_COPY_CLASS(wxDC)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -2,8 +2,6 @@
|
||||
// Name: wx/dcclient.h
|
||||
// Purpose: wxClientDC base header
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created:
|
||||
// Copyright: (c) Julian Smart
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows Licence
|
||||
@@ -21,11 +19,13 @@
|
||||
class WXDLLIMPEXP_CORE wxWindowDC : public wxDC
|
||||
{
|
||||
public:
|
||||
wxWindowDC();
|
||||
wxWindowDC(wxWindow *win);
|
||||
|
||||
protected:
|
||||
wxWindowDC(wxDCImpl *impl) : wxDC(impl) { }
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
||||
DECLARE_ABSTRACT_CLASS(wxWindowDC)
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -35,11 +35,13 @@ private:
|
||||
class WXDLLIMPEXP_CORE wxClientDC : public wxWindowDC
|
||||
{
|
||||
public:
|
||||
wxClientDC();
|
||||
wxClientDC(wxWindow *win);
|
||||
|
||||
protected:
|
||||
wxClientDC(wxDCImpl *impl) : wxWindowDC(impl) { }
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
||||
DECLARE_ABSTRACT_CLASS(wxClientDC)
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -49,12 +51,13 @@ private:
|
||||
class WXDLLIMPEXP_CORE wxPaintDC : public wxClientDC
|
||||
{
|
||||
public:
|
||||
wxPaintDC();
|
||||
wxPaintDC(wxWindow *win);
|
||||
|
||||
protected:
|
||||
wxPaintDC(wxDCImpl *impl) : wxClientDC(impl) { }
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxPaintDC)
|
||||
DECLARE_ABSTRACT_CLASS(wxPaintDC)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_DCCLIENT_H_BASE_
|
||||
#endif // _WX_DCCLIENT_H_BASE_
|
||||
|
@@ -18,7 +18,7 @@
|
||||
// wxMirrorDC allows to write the same code for horz/vertical layout
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxMirrorDC : public wxDC
|
||||
class WXDLLEXPORT wxMirrorDCImpl : public wxDCImpl
|
||||
{
|
||||
public:
|
||||
// constructs a mirror DC associated with the given real DC
|
||||
@@ -26,13 +26,12 @@ public:
|
||||
// if mirror parameter is true, all vertical and horizontal coordinates are
|
||||
// exchanged, otherwise this class behaves in exactly the same way as a
|
||||
// plain DC
|
||||
//
|
||||
// the cast to wxMirrorDC is a dirty hack done to allow us to call the
|
||||
// protected methods of wxDCBase directly in our code below, without it it
|
||||
// would be impossible (this is correct from C++ point of view but doesn't
|
||||
// make any sense in this particular situation)
|
||||
wxMirrorDC(wxDC& dc, bool mirror) : m_dc((wxMirrorDC&)dc)
|
||||
{ m_mirror = mirror; }
|
||||
wxMirrorDCImpl(wxDC *owner, wxDCImpl& dc, bool mirror)
|
||||
: wxDCImpl(owner),
|
||||
m_dc(dc)
|
||||
{
|
||||
m_mirror = mirror;
|
||||
}
|
||||
|
||||
// wxDCBase operations
|
||||
virtual void Clear() { m_dc.Clear(); }
|
||||
@@ -53,8 +52,7 @@ public:
|
||||
virtual bool CanGetTextExtent() const { return m_dc.CanGetTextExtent(); }
|
||||
virtual int GetDepth() const { return m_dc.GetDepth(); }
|
||||
virtual wxSize GetPPI() const { return m_dc.GetPPI(); }
|
||||
virtual bool Ok() const { return IsOk(); }
|
||||
virtual bool IsOk() const { return m_dc.Ok(); }
|
||||
virtual bool IsOk() const { return m_dc.IsOk(); }
|
||||
virtual void SetMapMode(int mode) { m_dc.SetMapMode(mode); }
|
||||
virtual void SetUserScale(double x, double y)
|
||||
{ m_dc.SetUserScale(GetX(x, y), GetY(x, y)); }
|
||||
@@ -68,12 +66,6 @@ public:
|
||||
virtual void SetLogicalFunction(int function)
|
||||
{ m_dc.SetLogicalFunction(function); }
|
||||
|
||||
// helper functions which may be useful for the users of this class
|
||||
wxSize Reflect(const wxSize& sizeOrig)
|
||||
{
|
||||
return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig;
|
||||
}
|
||||
|
||||
protected:
|
||||
// returns x and y if not mirroring or y and x if mirroring
|
||||
wxCoord GetX(wxCoord x, wxCoord y) const { return m_mirror ? y : x; }
|
||||
@@ -276,10 +268,31 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
wxMirrorDC& m_dc;
|
||||
wxDCImpl& m_dc;
|
||||
|
||||
bool m_mirror;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxMirrorDCImpl)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxMirrorDC : public wxDC
|
||||
{
|
||||
public:
|
||||
wxMirrorDC(wxDC& dc, bool mirror)
|
||||
: wxDC(new wxMirrorDCImpl(this, *dc.GetImpl(), mirror))
|
||||
{
|
||||
m_mirror = mirror;
|
||||
}
|
||||
|
||||
// helper functions which may be useful for the users of this class
|
||||
wxSize Reflect(const wxSize& sizeOrig)
|
||||
{
|
||||
return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_mirror;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxMirrorDC)
|
||||
};
|
||||
|
||||
|
@@ -27,11 +27,13 @@ class WXDLLIMPEXP_CORE wxPrinterDC : public wxDC
|
||||
public:
|
||||
wxPrinterDC();
|
||||
wxPrinterDC(const wxPrintData& data);
|
||||
virtual ~wxPrinterDC();
|
||||
|
||||
wxRect GetPaperRect();
|
||||
int GetResolution();
|
||||
|
||||
protected:
|
||||
wxPrinterDC(wxDCImpl *impl) : wxDC(impl) { }
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxPrinterDC)
|
||||
};
|
||||
|
@@ -204,9 +204,11 @@ class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC
|
||||
{
|
||||
public:
|
||||
wxSVGFileDC(const wxString& filename,
|
||||
int width=320, int height=240, double dpi=72.0 )
|
||||
int width = 320,
|
||||
int height = 240,
|
||||
double dpi = 72.0)
|
||||
: wxDC(new wxSVGFileDCImpl(this, filename, width, height, dpi))
|
||||
{
|
||||
m_pimpl = new wxSVGFileDCImpl( this, filename, width, height, dpi );
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -243,7 +243,10 @@ protected:
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
int fillStyle = wxODDEVEN_RULE);
|
||||
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const
|
||||
{ return subrect == NULL ? GetSelectedBitmap() : GetSelectedBitmap().GetSubBitmap(*subrect); }
|
||||
{
|
||||
return subrect == NULL ? GetSelectedBitmap()
|
||||
: GetSelectedBitmap().GetSubBitmap(*subrect);
|
||||
}
|
||||
|
||||
|
||||
#if wxUSE_PALETTE
|
||||
@@ -355,13 +358,10 @@ class WXDLLEXPORT wxDCTemp: public wxDC
|
||||
{
|
||||
public:
|
||||
wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize)
|
||||
: wxDC(new wxDCTempImpl(this, hdc, size))
|
||||
{
|
||||
m_pimpl = new wxDCTempImpl( this, hdc, size );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _WX_MSW_DC_H_
|
||||
|
||||
|
@@ -71,8 +71,8 @@ class WXDLLEXPORT wxPrinterDCFromHDC: public wxPrinterDC
|
||||
{
|
||||
public:
|
||||
wxPrinterDCFromHDC( WXHDC theDC )
|
||||
: wxPrinterDC(new wxPrinterDCImpl(this, theDC))
|
||||
{
|
||||
m_pimpl = new wxPrinterDCImpl( this, theDC );
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -73,7 +73,7 @@ void wxDCFactory::SetDCFactory( wxDCFactory *factory )
|
||||
wxDCFactory::m_factory = factory;
|
||||
}
|
||||
|
||||
wxDCFactory *wxDCFactory::GetFactory()
|
||||
wxDCFactory *wxDCFactory::Get()
|
||||
{
|
||||
if (!wxDCFactory::m_factory)
|
||||
wxDCFactory::m_factory = new wxNativeDCFactory;
|
||||
@@ -147,32 +147,22 @@ wxDCImpl *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintD
|
||||
// wxWindowDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
|
||||
|
||||
wxWindowDC::wxWindowDC()
|
||||
{
|
||||
}
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxWindowDC, wxDC)
|
||||
|
||||
wxWindowDC::wxWindowDC(wxWindow *win)
|
||||
: wxDC(wxDCFactory::Get()->CreateWindowDC(this, win))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreateWindowDC( this, win );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxClientDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
|
||||
|
||||
wxClientDC::wxClientDC()
|
||||
{
|
||||
}
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxClientDC, wxWindowDC)
|
||||
|
||||
wxClientDC::wxClientDC(wxWindow *win)
|
||||
: wxWindowDC(wxDCFactory::Get()->CreateClientDC(this, win))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreateClientDC( this, win );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -182,21 +172,18 @@ wxClientDC::wxClientDC( wxWindow *win )
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
|
||||
|
||||
wxMemoryDC::wxMemoryDC()
|
||||
: wxDC(wxDCFactory::Get()->CreateMemoryDC(this))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreateMemoryDC( this );
|
||||
}
|
||||
|
||||
wxMemoryDC::wxMemoryDC(wxBitmap& bitmap)
|
||||
: wxDC(wxDCFactory::Get()->CreateMemoryDC(this, bitmap))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreateMemoryDC( this, bitmap );
|
||||
}
|
||||
|
||||
wxMemoryDC::wxMemoryDC(wxDC *dc)
|
||||
: wxDC(wxDCFactory::Get()->CreateMemoryDC(this, dc))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreateMemoryDC( this, dc );
|
||||
}
|
||||
|
||||
void wxMemoryDC::SelectObject(wxBitmap& bmp)
|
||||
@@ -230,16 +217,11 @@ wxBitmap& wxMemoryDC::GetSelectedBitmap()
|
||||
// wxPaintDC
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
|
||||
|
||||
wxPaintDC::wxPaintDC()
|
||||
{
|
||||
}
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxPaintDC, wxClientDC)
|
||||
|
||||
wxPaintDC::wxPaintDC(wxWindow *win)
|
||||
: wxClientDC(wxDCFactory::Get()->CreatePaintDC(this, win))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreatePaintDC( this, win );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -249,9 +231,8 @@ wxPaintDC::wxPaintDC( wxWindow *win )
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
|
||||
|
||||
wxScreenDC::wxScreenDC()
|
||||
: wxDC(wxDCFactory::Get()->CreateScreenDC(this))
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreateScreenDC( this );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -263,19 +244,12 @@ wxScreenDC::wxScreenDC()
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxPrinterDC, wxDC)
|
||||
|
||||
wxPrinterDC::wxPrinterDC()
|
||||
: wxDC(wxDCFactory::Get()->CreatePrinterDC(this, wxPrintData()))
|
||||
{
|
||||
wxPrintData data; // Does this make sense?
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreatePrinterDC( this, data );
|
||||
}
|
||||
|
||||
wxPrinterDC::wxPrinterDC(const wxPrintData& data)
|
||||
{
|
||||
wxDCFactory *factory = wxDCFactory::GetFactory();
|
||||
m_pimpl = factory->CreatePrinterDC( this, data );
|
||||
}
|
||||
|
||||
wxPrinterDC::~wxPrinterDC()
|
||||
: wxDC(wxDCFactory::Get()->CreatePrinterDC(this, data))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -289,7 +263,7 @@ int wxPrinterDC::GetResolution()
|
||||
return GetImpl()->GetResolution();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // wxUSE_PRINTING_ARCHITECTURE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxDCImpl
|
||||
|
@@ -337,14 +337,12 @@ public:
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxPaintDCEx,wxPaintDC)
|
||||
|
||||
wxPaintDCEx::wxPaintDCEx(wxWindow *window, WXHDC dc)
|
||||
: wxPaintDC(new wxPaintDCExImpl(this, window, dc))
|
||||
{
|
||||
m_pimpl = new wxPaintDCExImpl( this, window, dc );
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxPaintDCExImpl::wxPaintDCExImpl( wxDC *owner, wxWindow *window, WXHDC dc ) :
|
||||
wxPaintDCImpl( owner )
|
||||
wxPaintDCExImpl::wxPaintDCExImpl(wxDC *owner, wxWindow *window, WXHDC dc)
|
||||
: wxPaintDCImpl( owner )
|
||||
{
|
||||
wxCHECK_RET( dc, wxT("wxPaintDCEx requires an existing device context") );
|
||||
|
||||
|
@@ -223,8 +223,11 @@ IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC)
|
||||
wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename,
|
||||
int width, int height,
|
||||
const wxString& description)
|
||||
: wxDC(new wxEnhMetaFileDCImpl(this,
|
||||
filename,
|
||||
width, height,
|
||||
description))
|
||||
{
|
||||
m_pimpl = new wxEnhMetaFileDCImpl( this, filename, width, height, description );
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user