Further wxDC changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49949 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2007-11-14 14:49:40 +00:00
parent 677dc0ed1a
commit 4f37154e98
16 changed files with 493 additions and 284 deletions

View File

@ -434,14 +434,19 @@ public:
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset) = 0;
wxCoord xoffset, wxCoord yoffset ) = 0;
virtual void DrawLines(const wxPointList *list,
wxCoord xoffset, wxCoord yoffset );
virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle = wxODDEVEN_RULE) = 0;
virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle);
void DrawPolygon(const wxPointList *list,
wxCoord xoffset, wxCoord yoffset,
int fillStyle );
#if wxUSE_SPLINES
@ -450,6 +455,26 @@ public:
virtual void DoDrawSpline(const wxPointList *points);
#endif
// ---------------------------------------------------------
// wxMemoryDC Impl API
virtual void DoSelect(const wxBitmap& WXUNUSED(bmp))
{ }
virtual const wxBitmap& GetSelectedBitmap() const
{ return wxNullBitmap; }
virtual wxBitmap& GetSelectedBitmap()
{ return wxNullBitmap; }
// ---------------------------------------------------------
// wxPrinterDC Impl API
virtual wxRect GetPaperRect()
{ int w = 0; int h = 0; DoGetSize( &w, &h ); return wxRect(0,0,w,h); }
virtual int GetResolution()
{ return -1; }
private:
wxDC *m_owner;
@ -562,6 +587,9 @@ public:
wxSize GetPPI() const
{ return m_pimpl->GetPPI(); }
virtual int GetResolution()
{ return m_pimpl->GetResolution(); }
// Right-To-Left (RTL) modes
void SetLayoutDirection(wxLayoutDirection dir)
@ -847,30 +875,31 @@ public:
void DrawLines(int n, wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0)
{ m_pimpl->DoDrawLines(n, points, xoffset, yoffset); }
#if 0
// needs to be removed
void DrawLines(const wxPointList *list,
wxCoord xoffset = 0, wxCoord yoffset = 0)
#endif
{ m_pimpl->DrawLines( list, xoffset, yoffset ); }
#if WXWIN_COMPATIBILITY_2_8
wxDEPRECATED( void DrawLines(const wxList *list,
wxCoord xoffset = 0, wxCoord yoffset = 0) );
#endif // WXWIN_COMPATIBILITY_2_8
void DrawPolygon(int n, wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE)
{ m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); }
#if 0
// needs to be removed
void DrawPolygon(const wxPointList *list,
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE)
{ m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); }
#endif
void DrawPolyPolygon(int n, int count[], wxPoint points[],
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE)
{ m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); }
#if WXWIN_COMPATIBILITY_2_8
wxDEPRECATED( void DrawPolygon(const wxList *list,
wxCoord xoffset = 0, wxCoord yoffset = 0,
int fillStyle = wxODDEVEN_RULE) );
#endif // WXWIN_COMPATIBILITY_2_8
void DrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ m_pimpl->DoDrawRectangle(x, y, width, height); }
@ -1477,6 +1506,9 @@ public:
// Resolution in Pixels per inch
virtual wxSize GetPPI() const = 0;
virtual int GetResolution()
{ return -1; }
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return m_ok; }

View File

@ -22,18 +22,6 @@
// wxMemoryDC
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxMemoryImplDCBase
{
public:
wxMemoryImplDCBase() { }
virtual void DoSelect(const wxBitmap& bmp) = 0;
virtual const wxBitmap& DoGetSelectedBitmap() const = 0;
virtual wxBitmap& DoGetSelectedBitmap() = 0;
};
class WXDLLIMPEXP_CORE wxMemoryDC: public wxDC
{
public:

View File

@ -24,21 +24,17 @@
// wxPrinterDC
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxPrinterImplDCBase
{
public:
wxPrinterImplDCBase() { }
virtual wxRect DoGetPaperRect() = 0;
};
class WXDLLIMPEXP_CORE wxPrinterDC: public wxDC
{
public:
wxPrinterDC();
wxPrinterDC( const wxPrintData& data );
wxRect GetPaperRect();
int GetResolution();
private:
DECLARE_DYNAMIC_CLASS()
};
#else

View File

@ -22,6 +22,13 @@ class WXDLLIMPEXP_CORE wxScreenDC : public wxWindowDC
public:
wxScreenDC();
static bool StartDrawingOnTop(wxWindow * WXUNUSED(window))
{ return true; }
static bool StartDrawingOnTop(wxRect * WXUNUSED(rect) = NULL)
{ return true; }
static bool EndDrawingOnTop()
{ return true; }
private:
DECLARE_DYNAMIC_CLASS(wxScreenDC)
};

View File

@ -16,6 +16,7 @@
#if wxUSE_PRINTING_ARCHITECTURE && wxUSE_POSTSCRIPT
#include "wx/dc.h"
#include "wx/dcprint.h"
#include "wx/dialog.h"
#include "wx/module.h"
#include "wx/cmndata.h"
@ -25,7 +26,10 @@
// wxPostScriptDC
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxPostScriptDC: public wxDC
#if wxUSE_NEW_DC
class WXDLLEXPORT wxPostScriptDC : public wxDC
{
public:
wxPostScriptDC();
@ -33,7 +37,35 @@ public:
// Recommended constructor
wxPostScriptDC(const wxPrintData& printData);
virtual ~wxPostScriptDC();
private:
DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
};
#endif
#if wxUSE_NEW_DC
class WXDLLEXPORT wxPostScriptImplDC : public wxImplDC
#else
#define wxPostScriptImplDC wxPostScriptDC
class WXDLLEXPORT wxPostScriptDC : public wxDC
#endif
{
public:
#if wxUSE_NEW_DC
wxPostScriptImplDC( wxPrinterDC *owner );
wxPostScriptImplDC( wxPrinterDC *owner, const wxPrintData& data );
wxPostScriptImplDC( wxPostScriptDC *owner );
wxPostScriptImplDC( wxPostScriptDC *owner, const wxPrintData& data );
#else
wxPostScriptDC();
// Recommended constructor
wxPostScriptDC(const wxPrintData& printData);
#endif
void Init();
virtual ~wxPostScriptImplDC();
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const;
@ -83,12 +115,12 @@ public:
virtual int GetDepth() const { return 24; }
static void SetResolution(int ppi);
static int GetResolution();
void PsPrint( const wxString& psdata );
private:
// Overrridden for wxPrinterDC Impl
virtual int GetResolution();
virtual wxRect GetPaperRect();
protected:
bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style = wxFLOOD_SURFACE);
@ -106,7 +138,7 @@ protected:
void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
#if wxUSE_SPLINES
void DoDrawSpline(const wxPointList *points);
#endif // wxUSE_SPLINES
#endif
bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
@ -136,7 +168,7 @@ protected:
double m_pageHeight;
private:
DECLARE_DYNAMIC_CLASS(wxPostScriptDC)
DECLARE_DYNAMIC_CLASS(wxPostScriptImplDC)
};
#endif

View File

@ -18,7 +18,7 @@
#if wxUSE_NEW_DC
class WXDLLIMPEXP_CORE wxGTKMemoryImplDC : public wxGTKWindowImplDC, public wxMemoryImplDCBase
class WXDLLIMPEXP_CORE wxGTKMemoryImplDC : public wxGTKWindowImplDC
#else
#define wxGTKMemoryImplDC wxMemoryDC
class WXDLLIMPEXP_CORE wxMemoryDC : public wxWindowDC, public wxMemoryDCBase
@ -48,19 +48,19 @@ public:
virtual void SetTextForeground( const wxColour &col );
virtual void SetTextBackground( const wxColour &col );
// implementation
wxBitmap GetSelectedBitmap() const { return m_selected; }
protected:
// overridden from wxImplDC
virtual void DoGetSize( int *width, int *height ) const;
virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const;
// overridden from wxMemoryImplDCBase
// overridden for wxMemoryDC Impl
virtual void DoSelect(const wxBitmap& bitmap);
virtual const wxBitmap& DoGetSelectedBitmap() const;
virtual wxBitmap& DoGetSelectedBitmap();
public:
virtual const wxBitmap& GetSelectedBitmap() const;
virtual wxBitmap& GetSelectedBitmap();
private:
wxBitmap m_selected;
private:

View File

@ -91,7 +91,11 @@ public:
virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
wxPageSetupDialogData * data = NULL );
#if wxUSE_NEW_DC
virtual wxImplDC* CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data );
#else
virtual wxDC* CreatePrinterDC( const wxPrintData& data );
#endif
virtual bool HasPrintSetupDialog();
virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data );
@ -207,11 +211,20 @@ private:
// wxGnomePrinterDC
//-----------------------------------------------------------------------------
class wxGnomePrinterDC: public wxDC
#if wxUSE_NEW_DC
class wxGnomePrinterImplDC : public wxImplDC
#else
#define wxGnomePrinterImplDC wxGnomePrinterDC
class wxGnomePrinterDC : public wxDC
#endif
{
public:
#if wxUSE_NEW_DC
wxGnomePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data );
#else
wxGnomePrinterDC( const wxPrintData& data );
virtual ~wxGnomePrinterDC();
#endif
virtual ~wxGnomePrinterImplDC();
bool Ok() const { return IsOk(); }
bool IsOk() const;
@ -235,8 +248,6 @@ public:
virtual int GetDepth() const { return 24; }
void SetBackgroundMode(int WXUNUSED(mode)) { }
void SetPalette(const wxPalette& WXUNUSED(palette)) { }
static void SetResolution(int ppi);
static int GetResolution();
protected:
bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
@ -274,6 +285,10 @@ protected:
void SetPrintData(const wxPrintData& data);
wxPrintData& GetPrintData() { return m_printData; }
// overriden for wxPrinterDC Impl
virtual wxRect GetPaperRect();
virtual int GetResolution();
private:
wxPrintData m_printData;
PangoContext *m_context;
@ -292,8 +307,8 @@ private:
void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
private:
DECLARE_DYNAMIC_CLASS(wxGnomePrinterDC)
DECLARE_NO_COPY_CLASS(wxGnomePrinterDC)
DECLARE_DYNAMIC_CLASS(wxGnomePrinterImplDC)
DECLARE_NO_COPY_CLASS(wxGnomePrinterImplDC)
};
// ----------------------------------------------------------------------------

View File

@ -53,7 +53,11 @@ public:
virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent,
wxPageSetupDialogData * data = NULL );
#if wxUSE_NEW_DC
virtual wxImplDC* CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data );
#else
virtual wxDC* CreatePrinterDC( const wxPrintData& data );
#endif
virtual bool HasPrintSetupDialog();
virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data );
@ -218,11 +222,20 @@ private:
// wxGtkPrinterDC
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxGtkPrinterDC: public wxDC
#if wxUSE_NEW_DC
class WXDLLIMPEXP_CORE wxGtkPrinterImplDC : public wxImplDC
#else
#define wxGtkPrinterImplDC wxGtkPrinterDC
class WXDLLIMPEXP_CORE wxGtkPrinterDC : public wxDC
#endif
{
public:
#if wxUSE_NEW_DC
wxGtkPrinterImplDC( wxPrinterDC *owner, const wxPrintData& data );
#else
wxGtkPrinterDC( const wxPrintData& data );
virtual ~wxGtkPrinterDC();
#endif
virtual ~wxGtkPrinterImplDC();
bool Ok() const { return IsOk(); }
bool IsOk() const;
@ -247,7 +260,10 @@ public:
void SetBackgroundMode(int mode);
void SetPalette(const wxPalette& WXUNUSED(palette)) { }
void SetResolution(int ppi);
int GetResolution();
// overriden for wxPrinterDC Impl
virtual int GetResolution();
virtual wxRect GetPaperRect();
protected:
bool DoFloodFill(wxCoord x1, wxCoord y1, const wxColour &col, int style=wxFLOOD_SURFACE );
@ -304,8 +320,8 @@ private:
double m_PS2DEV;
double m_DEV2PS;
DECLARE_DYNAMIC_CLASS(wxGtkPrinterDC)
DECLARE_NO_COPY_CLASS(wxGtkPrinterDC)
DECLARE_DYNAMIC_CLASS(wxGtkPrinterImplDC)
DECLARE_NO_COPY_CLASS(wxGtkPrinterImplDC)
};
// ----------------------------------------------------------------------------

View File

@ -28,7 +28,9 @@
#include "wx/dcclient.h"
#include "wx/dcmemory.h"
#include "wx/dcscreen.h"
#include "wx/dcprint.h"
#include "wx/dcbuffer.h" // for IMPLEMENT_DYNAMIC_CLASS
#include "wx/prntbase.h"
#ifndef WX_PRECOMP
#include "wx/math.h"
@ -334,31 +336,10 @@ wxImplDC* wxNativeDCFactory::CreateScreenDC( wxScreenDC *owner )
#endif
}
wxImpleDC *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *ownder, const wxPrintData &data )
wxImplDC *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data )
{
#if defined(__WXMSW__)
return new wxWindowsPrinterImplDC( owner );
#elif defined(__WXGTK20__)
return new wxGTKPrinterImplDC( owner );
#elif defined(__WXGTK__)
return new wxGTKPrinterImplDC( owner );
#elif defined(__WXMAC__)
return new wxMacPrinterImplDC( owner );
#elif defined(__WXCOCOA__)
return new wxCocoaPrinterImplDC( owner );
#elif defined(__WXMOTIF__)
return new wxMotifPrinterImplDC( owner );
#elif defined(__WXX11__)
return new wxX11PrinterImplDC( owner );
#elif defined(__WXMGL__)
return new wxMGLPrinterImplDC( owner );
#elif defined(__WXDFB__)
return new wxDFBPrinterImplDC( owner );
#elif defined(__WXPM__)
return new wxPMPrinterImplDC( owner );
#elif defined(__PALMOS__)
return new wxPalmPrinterImplDC( owner );
#endif
wxPrintFactory *factory = wxPrintFactory::GetFactory();
return factory->CreatePrinterImplDC( owner, data );
}
//-----------------------------------------------------------------------------
@ -429,50 +410,22 @@ void wxMemoryDC::SelectObject(wxBitmap& bmp)
if (bmp.IsOk())
bmp.UnShare();
#ifdef __WXGTK__
wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
#else
// TODO
#endif
if (mem_pimpl)
mem_pimpl->DoSelect(bmp);
GetImpl()->DoSelect(bmp);
}
void wxMemoryDC::SelectObjectAsSource(const wxBitmap& bmp)
{
#ifdef __WXGTK__
wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
#else
// TODO
#endif
mem_pimpl->DoSelect(bmp);
GetImpl()->DoSelect(bmp);
}
const wxBitmap& wxMemoryDC::GetSelectedBitmap() const
{
#ifdef __WXGTK__
wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
#else
// TODO
#endif
if (mem_pimpl)
return mem_pimpl->DoGetSelectedBitmap();
return wxNullBitmap;
return GetImpl()->GetSelectedBitmap();
}
wxBitmap& wxMemoryDC::GetSelectedBitmap()
{
#ifdef __WXGTK__
wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
#else
// TODO
#endif
if (mem_pimpl)
return mem_pimpl->DoGetSelectedBitmap();
return wxNullBitmap;
return GetImpl()->GetSelectedBitmap();
}
@ -506,6 +459,24 @@ wxScreenDC::wxScreenDC()
m_pimpl = factory->CreateScreenDC( this );
}
//-----------------------------------------------------------------------------
// wxPrinterDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPrinterDC, wxDC)
wxPrinterDC::wxPrinterDC()
{
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 );
}
//-----------------------------------------------------------------------------
// wxImplDC
//-----------------------------------------------------------------------------
@ -760,9 +731,9 @@ void wxImplDC::GetMultiLineTextExtent(const wxString& text,
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
wxString curLine;
for ( const wxChar *pc = text; ; pc++ )
for ( wxString::const_iterator pc = text.begin(); ; ++pc )
{
if ( *pc == _T('\n') || *pc == _T('\0') )
if ( pc == text.end() || *pc == _T('\n') )
{
if ( curLine.empty() )
{
@ -793,15 +764,14 @@ void wxImplDC::GetMultiLineTextExtent(const wxString& text,
heightTextTotal += heightLine;
}
if ( *pc == _T('\n') )
if ( pc == text.end() )
{
break;
}
else // '\n'
{
curLine.clear();
}
else
{
// the end of string
break;
}
}
else
{
@ -1089,6 +1059,7 @@ static bool wx_spline_add_point(double x, double y)
static void wx_spline_draw_point_array(wxDC *dc)
{
dc->DrawLines(&wx_spline_point_list, 0, 0 );
wxPointList::compatibility_iterator node = wx_spline_point_list.GetFirst();
while (node)
{

View File

@ -205,6 +205,21 @@ wxDialog *wxNativePrintFactory::CreatePrintSetupDialog( wxWindow *parent,
#endif
}
#if wxUSE_NEW_DC
wxImplDC* wxNativePrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data )
{
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
return new wxWindowsPrinterDCImpl( owner, data );
#elif defined(__WXMAC__)
return new wxMacPrinterDCImpl( owner, data );
#else
return new wxPostScriptImplDC( owner, data );
#endif
}
#else
wxDC* wxNativePrintFactory::CreatePrinterDC( const wxPrintData& data )
{
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
@ -216,6 +231,8 @@ wxDC* wxNativePrintFactory::CreatePrinterDC( const wxPrintData& data )
#endif
}
#endif
bool wxNativePrintFactory::HasOwnPrintToFile()
{
// Only relevant for PostScript and here the

View File

@ -235,6 +235,24 @@ static char wxPostScriptHeaderReencodeISO2[] =
// wxPostScriptDC
//-------------------------------------------------------------------------------
#if wxUSE_NEW_DC
IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC)
wxPostScriptDC::wxPostScriptDC()
{
m_pimpl = new wxPostScriptImplDC( this );
}
wxPostScriptDC::wxPostScriptDC(const wxPrintData& printData)
{
m_pimpl = new wxPostScriptImplDC( this, printData );
}
#endif
// conversion
static const double RAD2DEG = 180.0 / M_PI;
@ -248,60 +266,88 @@ static const double DEV2PS = 72.0 / 600.0;
#define YLOG2DEV(x) ((m_pageHeight - (double)LogicalToDeviceY(x)) * DEV2PS)
#define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * DEV2PS)
IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC)
#if wxUSE_NEW_DC
IMPLEMENT_ABSTRACT_CLASS(wxPostScriptImplDC, wxImplDC)
#else
IMPLEMENT_ABSTRACT_CLASS(wxPostScriptDC, wxDC)
#endif
//-------------------------------------------------------------------------------
void wxPostScriptDC::SetResolution(int WXUNUSED(ppi))
#if wxUSE_NEW_DC
wxPostScriptImplDC::wxPostScriptImplDC( wxPostScriptDC *owner ) :
wxImplDC( owner )
{
}
int wxPostScriptDC::GetResolution()
{
return DPI;
}
wxPostScriptDC::wxPostScriptDC ()
{
m_pstream = (FILE*) NULL;
m_currentRed = 0;
m_currentGreen = 0;
m_currentBlue = 0;
m_pageNumber = 0;
m_clipping = false;
m_underlinePosition = 0.0;
m_underlineThickness = 0.0;
Init();
m_pageHeight = 842 * PS2DEV;
m_ok = true;
}
wxPostScriptDC::wxPostScriptDC (const wxPrintData& printData)
wxPostScriptImplDC::wxPostScriptImplDC( wxPostScriptDC *owner, const wxPrintData& data ) :
wxImplDC( owner )
{
m_pstream = (FILE*) NULL;
m_currentRed = 0;
m_currentGreen = 0;
m_currentBlue = 0;
m_pageNumber = 0;
m_clipping = false;
m_underlinePosition = 0.0;
m_underlineThickness = 0.0;
Init();
// this calculates m_pageHeight required for
// taking the inverted Y axis into account
SetPrintData( printData );
SetPrintData( data );
m_ok = true;
}
#endif
#if wxUSE_NEW_DC
wxPostScriptImplDC::wxPostScriptImplDC( wxPrinterDC *owner ) :
wxImplDC( owner )
#else
wxPostScriptDC::wxPostScriptDC()
#endif
{
Init();
m_pageHeight = 842 * PS2DEV;
m_ok = true;
}
#if wxUSE_NEW_DC
wxPostScriptImplDC::wxPostScriptImplDC( wxPrinterDC *owner, const wxPrintData& data ) :
wxImplDC( owner )
#else
wxPostScriptDC::wxPostScriptDC( const wxPrintData& data )
#endif
{
Init();
// this calculates m_pageHeight required for
// taking the inverted Y axis into account
SetPrintData( data );
m_ok = true;
}
wxPostScriptDC::~wxPostScriptDC ()
void wxPostScriptImplDC::Init()
{
m_pstream = (FILE*) NULL;
m_currentRed = 0;
m_currentGreen = 0;
m_currentBlue = 0;
m_pageNumber = 0;
m_clipping = false;
m_underlinePosition = 0.0;
m_underlineThickness = 0.0;
}
wxPostScriptImplDC::~wxPostScriptImplDC ()
{
if (m_pstream)
{
@ -310,18 +356,39 @@ wxPostScriptDC::~wxPostScriptDC ()
}
}
bool wxPostScriptDC::IsOk() const
bool wxPostScriptImplDC::IsOk() const
{
return m_ok;
}
void wxPostScriptDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoord h)
wxRect wxPostScriptImplDC::GetPaperRect()
{
int w = 0;
int h = 0;
DoGetSize( &w, &h );
return wxRect(0,0,w,h);
}
int wxPostScriptImplDC::GetResolution()
{
return DPI;
}
void wxPostScriptImplDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
wxCHECK_RET( m_ok , wxT("invalid postscript dc") );
if (m_clipping) DestroyClippingRegion();
if (m_clipping)
DestroyClippingRegion();
#if wxUSE_NEW_DC
m_clipX1 = x;
m_clipY1 = y;
m_clipX2 = x + w;
m_clipY2 = y + h;
#else
wxDC::DoSetClippingRegion(x, y, w, h);
#endif
m_clipping = true;
@ -342,7 +409,7 @@ void wxPostScriptDC::DoSetClippingRegion (wxCoord x, wxCoord y, wxCoord w, wxCoo
}
void wxPostScriptDC::DestroyClippingRegion()
void wxPostScriptImplDC::DestroyClippingRegion()
{
wxCHECK_RET( m_ok , wxT("invalid postscript dc") );
@ -352,34 +419,38 @@ void wxPostScriptDC::DestroyClippingRegion()
PsPrint( "grestore\n" );
}
#if wxUSE_NEW_DC
wxImplDC::DestroyClippingRegion();
#else
wxDC::DestroyClippingRegion();
#endif
}
void wxPostScriptDC::Clear()
void wxPostScriptImplDC::Clear()
{
// This should fail silently to avoid unnecessary
// asserts
// wxFAIL_MSG( wxT("wxPostScriptDC::Clear not implemented.") );
// wxFAIL_MSG( wxT("wxPostScriptImplDC::Clear not implemented.") );
}
bool wxPostScriptDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style))
bool wxPostScriptImplDC::DoFloodFill (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style))
{
wxFAIL_MSG( wxT("wxPostScriptDC::FloodFill not implemented.") );
wxFAIL_MSG( wxT("wxPostScriptImplDC::FloodFill not implemented.") );
return false;
}
bool wxPostScriptDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const
bool wxPostScriptImplDC::DoGetPixel (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxColour * WXUNUSED(col)) const
{
wxFAIL_MSG( wxT("wxPostScriptDC::GetPixel not implemented.") );
wxFAIL_MSG( wxT("wxPostScriptImplDC::GetPixel not implemented.") );
return false;
}
void wxPostScriptDC::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
void wxPostScriptImplDC::DoCrossHair (wxCoord WXUNUSED(x), wxCoord WXUNUSED(y))
{
wxFAIL_MSG( wxT("wxPostScriptDC::CrossHair not implemented.") );
wxFAIL_MSG( wxT("wxPostScriptImplDC::CrossHair not implemented.") );
}
void wxPostScriptDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
void wxPostScriptImplDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -401,7 +472,7 @@ void wxPostScriptDC::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
CalcBoundingBox( x2, y2 );
}
void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
void wxPostScriptImplDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -479,7 +550,7 @@ void wxPostScriptDC::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2,
}
}
void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
void wxPostScriptImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -494,7 +565,7 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d
if ( wxIsSameDouble(sa, ea) )
{
DrawEllipse(x,y,w,h);
DoDrawEllipse(x,y,w,h);
return;
}
@ -533,7 +604,7 @@ void wxPostScriptDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d
}
}
void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y)
void wxPostScriptImplDC::DoDrawPoint (wxCoord x, wxCoord y)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -554,7 +625,7 @@ void wxPostScriptDC::DoDrawPoint (wxCoord x, wxCoord y)
CalcBoundingBox( x, y );
}
void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
void wxPostScriptImplDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -624,7 +695,7 @@ void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wx
}
}
void wxPostScriptDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
void wxPostScriptImplDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -700,7 +771,7 @@ void wxPostScriptDC::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wx
}
}
void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
void wxPostScriptImplDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -734,7 +805,7 @@ void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCo
PsPrint( "stroke\n" );
}
void wxPostScriptDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxPostScriptImplDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -788,7 +859,7 @@ void wxPostScriptDC::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoo
}
}
void wxPostScriptDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
void wxPostScriptImplDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -870,7 +941,7 @@ void wxPostScriptDC::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width
}
}
void wxPostScriptDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxPostScriptImplDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -912,15 +983,15 @@ void wxPostScriptDC::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord
}
}
void wxPostScriptDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )
void wxPostScriptImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )
{
DrawBitmap( icon, x, y, true );
DoDrawBitmap( icon, x, y, true );
}
/* this has to be char, not wxChar */
static char hexArray[] = "0123456789ABCDEF";
void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool WXUNUSED(useMask) )
void wxPostScriptImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool WXUNUSED(useMask) )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -990,7 +1061,7 @@ void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y,
PsPrint( "origstate restore\n" );
}
void wxPostScriptDC::SetFont( const wxFont& font )
void wxPostScriptImplDC::SetFont( const wxFont& font )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1084,7 +1155,7 @@ void wxPostScriptDC::SetFont( const wxFont& font )
PsPrint( buffer );
}
void wxPostScriptDC::SetPen( const wxPen& pen )
void wxPostScriptImplDC::SetPen( const wxPen& pen )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1192,7 +1263,7 @@ void wxPostScriptDC::SetPen( const wxPen& pen )
}
}
void wxPostScriptDC::SetBrush( const wxBrush& brush )
void wxPostScriptImplDC::SetBrush( const wxBrush& brush )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1236,7 +1307,7 @@ void wxPostScriptDC::SetBrush( const wxBrush& brush )
}
}
void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
void wxPostScriptImplDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1283,7 +1354,7 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
wxCoord text_w, text_h, text_descent;
GetTextExtent(text, &text_w, &text_h, &text_descent);
GetOwner()->GetTextExtent(text, &text_w, &text_h, &text_descent);
int size = m_font.GetPointSize();
@ -1344,7 +1415,7 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y )
CalcBoundingBox( x + size * text.length() * 2/3 , y );
}
void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle )
void wxPostScriptImplDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle )
{
if ( wxIsNullDouble(angle) )
{
@ -1439,7 +1510,7 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord
{
wxCoord uy = (wxCoord)(y + size - m_underlinePosition);
wxCoord w, h;
GetTextExtent(text, &w, &h);
GetOwner()->GetTextExtent(text, &w, &h);
buffer.Printf(
"gsave\n"
@ -1459,18 +1530,18 @@ void wxPostScriptDC::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord
CalcBoundingBox( x + size * text.length() * 2/3 , y );
}
void wxPostScriptDC::SetBackground (const wxBrush& brush)
void wxPostScriptImplDC::SetBackground (const wxBrush& brush)
{
m_backgroundBrush = brush;
}
void wxPostScriptDC::SetLogicalFunction (int WXUNUSED(function))
void wxPostScriptImplDC::SetLogicalFunction (int WXUNUSED(function))
{
wxFAIL_MSG( wxT("wxPostScriptDC::SetLogicalFunction not implemented.") );
wxFAIL_MSG( wxT("wxPostScriptImplDC::SetLogicalFunction not implemented.") );
}
#if wxUSE_SPLINES
void wxPostScriptDC::DoDrawSpline( const wxPointList *points )
void wxPostScriptImplDC::DoDrawSpline( const wxPointList *points )
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1551,13 +1622,13 @@ void wxPostScriptDC::DoDrawSpline( const wxPointList *points )
}
#endif // wxUSE_SPLINES
wxCoord wxPostScriptDC::GetCharWidth() const
wxCoord wxPostScriptImplDC::GetCharWidth() const
{
// Chris Breeze: reasonable approximation using wxMODERN/Courier
return (wxCoord) (GetCharHeight() * 72.0 / 120.0);
}
void wxPostScriptDC::SetPrintData(const wxPrintData& data)
void wxPostScriptImplDC::SetPrintData(const wxPrintData& data)
{
m_printData = data;
@ -1580,38 +1651,38 @@ void wxPostScriptDC::SetPrintData(const wxPrintData& data)
#if wxUSE_NEW_DC
#else
void wxPostScriptDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
void wxPostScriptImplDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
wxDCBase::SetAxisOrientation(xLeftRight,yBottomUp);
}
void wxPostScriptDC::SetMapMode(int mode)
void wxPostScriptImplDC::SetMapMode(int mode)
{
wxDCBase::SetMapMode(mode);
}
void wxPostScriptDC::SetUserScale(double x, double y)
void wxPostScriptImplDC::SetUserScale(double x, double y)
{
wxDCBase::SetUserScale(x,y);
}
void wxPostScriptDC::SetLogicalScale(double x, double y)
void wxPostScriptImplDC::SetLogicalScale(double x, double y)
{
wxDCBase::SetLogicalScale(x,y);
}
void wxPostScriptDC::SetLogicalOrigin(wxCoord x, wxCoord y)
void wxPostScriptImplDC::SetLogicalOrigin(wxCoord x, wxCoord y)
{
wxDCBase::SetLogicalOrigin(x,y);
}
void wxPostScriptDC::SetDeviceOrigin(wxCoord x, wxCoord y)
void wxPostScriptImplDC::SetDeviceOrigin(wxCoord x, wxCoord y)
{
wxDCBase::SetDeviceOrigin(x,y);
}
#endif
void wxPostScriptDC::ComputeScaleAndOrigin()
void wxPostScriptImplDC::ComputeScaleAndOrigin()
{
const wxRealPoint origScale(m_scaleX, m_scaleY);
@ -1630,7 +1701,7 @@ void wxPostScriptDC::ComputeScaleAndOrigin()
}
}
void wxPostScriptDC::DoGetSize(int* width, int* height) const
void wxPostScriptImplDC::DoGetSize(int* width, int* height) const
{
wxPaperSize id = m_printData.GetPaperId();
@ -1660,7 +1731,7 @@ void wxPostScriptDC::DoGetSize(int* width, int* height) const
*height = wxRound( h * PS2DEV );
}
void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const
void wxPostScriptImplDC::DoGetSizeMM(int *width, int *height) const
{
wxPaperSize id = m_printData.GetPaperId();
@ -1688,13 +1759,13 @@ void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const
}
// Resolution in pixels per logical inch
wxSize wxPostScriptDC::GetPPI(void) const
wxSize wxPostScriptImplDC::GetPPI(void) const
{
return wxSize( DPI, DPI );
}
bool wxPostScriptDC::StartDoc( const wxString& message )
bool wxPostScriptImplDC::StartDoc( const wxString& message )
{
wxCHECK_MSG( m_ok, false, wxT("invalid postscript dc") );
@ -1783,7 +1854,7 @@ bool wxPostScriptDC::StartDoc( const wxString& message )
return true;
}
void wxPostScriptDC::EndDoc ()
void wxPostScriptImplDC::EndDoc ()
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1883,7 +1954,7 @@ void wxPostScriptDC::EndDoc ()
#endif
}
void wxPostScriptDC::StartPage()
void wxPostScriptImplDC::StartPage()
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
@ -1921,14 +1992,14 @@ void wxPostScriptDC::StartPage()
PsPrint( "90 rotate\n" );
}
void wxPostScriptDC::EndPage ()
void wxPostScriptImplDC::EndPage ()
{
wxCHECK_RET( m_ok , wxT("invalid postscript dc") );
PsPrint( "showpage\n" );
}
bool wxPostScriptDC::DoBlit( wxCoord xdest, wxCoord ydest,
bool wxPostScriptImplDC::DoBlit( wxCoord xdest, wxCoord ydest,
wxCoord fwidth, wxCoord fheight,
wxDC *source,
wxCoord xsrc, wxCoord ysrc,
@ -1938,20 +2009,20 @@ bool wxPostScriptDC::DoBlit( wxCoord xdest, wxCoord ydest,
wxCHECK_MSG( source, false, wxT("invalid source dc") );
/* blit into a bitmap */
// blit into a bitmap
wxBitmap bitmap( (int)fwidth, (int)fheight );
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
memDC.Blit(0, 0, fwidth, fheight, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */
memDC.SelectObject(wxNullBitmap);
/* draw bitmap. scaling and positioning is done there */
DrawBitmap( bitmap, xdest, ydest );
//draw bitmap. scaling and positioning is done there
GetOwner()->DrawBitmap( bitmap, xdest, ydest );
return true;
}
wxCoord wxPostScriptDC::GetCharHeight() const
wxCoord wxPostScriptImplDC::GetCharHeight() const
{
if (m_font.Ok())
return m_font.GetPointSize();
@ -1959,7 +2030,7 @@ wxCoord wxPostScriptDC::GetCharHeight() const
return 12;
}
void wxPostScriptDC::PsPrint( const wxString& str )
void wxPostScriptImplDC::PsPrint( const wxString& str )
{
const wxCharBuffer psdata(str.utf8_str());
@ -1986,7 +2057,7 @@ void wxPostScriptDC::PsPrint( const wxString& str )
}
}
void wxPostScriptDC::DoGetTextExtent(const wxString& string,
void wxPostScriptImplDC::DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent, wxCoord *externalLeading,
const wxFont *theFont ) const

View File

@ -101,7 +101,7 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
}
// May have pressed cancel.
if (!dc || !dc->Ok())
if (!dc || !dc->IsOk())
{
if (dc) delete dc;
sm_lastError = wxPRINTER_ERROR;
@ -113,8 +113,8 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
printout->SetPPIPrinter( wxPostScriptDC::GetResolution(),
wxPostScriptDC::GetResolution() );
printout->SetPPIPrinter( dc->GetResolution(),
dc->GetResolution() );
// Set printout parameters
printout->SetDC(dc);
@ -335,13 +335,15 @@ void wxPostScriptPrintPreview::DetermineScaling()
wxSize ScreenPixels = wxGetDisplaySize();
wxSize ScreenMM = wxGetDisplaySizeMM();
int resolution = 600; // TODO, this is correct, but get this from wxPSDC somehow
m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
m_previewPrintout->SetPPIPrinter(wxPostScriptDC::GetResolution(), wxPostScriptDC::GetResolution());
m_previewPrintout->SetPPIPrinter( resolution, resolution );
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());
sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * wxPostScriptDC::GetResolution() / 72.0);
sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * wxPostScriptDC::GetResolution() / 72.0);
sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * resolution / 72.0);
sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * resolution / 72.0);
wxSize sizeTenthsMM(paper->GetSize());
wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10);
@ -362,7 +364,7 @@ void wxPostScriptPrintPreview::DetermineScaling()
m_previewPrintout->SetPaperRectPixels(wxRect(0, 0, m_pageWidth, m_pageHeight));
// At 100%, the page should look about page-size on the screen.
m_previewScaleX = (float)0.8 * 72.0 / (float)wxPostScriptDC::GetResolution();
m_previewScaleX = (float)0.8 * 72.0 / (float)resolution;
m_previewScaleY = m_previewScaleX;
}
}

View File

@ -937,11 +937,20 @@ gtk_wx_cell_renderer_render (GtkCellRenderer *renderer,
{
wxRect renderrect( rect.x, rect.y, rect.width, rect.height );
wxWindowDC* dc = (wxWindowDC*) cell->GetDC();
#if wxUSE_NEW_DC
wxGTKWindowImplDC *impldc = (wxGTKWindowImplDC *) dc->GetImpl();
if (impldc->m_window == NULL)
{
impldc->m_window = window;
impldc->SetUpDC();
}
#else
if (dc->m_window == NULL)
{
dc->m_window = window;
dc->SetUpDC();
}
#endif
int state = 0;
if (flags & GTK_CELL_RENDERER_SELECTED)
@ -1651,6 +1660,20 @@ class wxDataViewCtrlDC: public wxWindowDC
public:
wxDataViewCtrlDC( wxDataViewCtrl *window )
{
#if wxUSE_NEW_DC
wxGTKWindowImplDC *impl = (wxGTKWindowImplDC*) GetImpl();
GtkWidget *widget = window->m_treeview;
// Set later
impl->m_window = NULL;
impl->m_context = window->GtkGetPangoDefaultContext();
impl->m_layout = pango_layout_new( impl->m_context );
impl->m_fontdesc = pango_font_description_copy( widget->style->font_desc );
impl->m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
#else
GtkWidget *widget = window->m_treeview;
// Set later
m_window = NULL;
@ -1660,7 +1683,7 @@ public:
m_fontdesc = pango_font_description_copy( widget->style->font_desc );
m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget );
#endif
// Set m_window later
// SetUpDC();
// m_owner = window;

View File

@ -2302,7 +2302,7 @@ void wxGTKWindowImplDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width
wxCoord xx, yy, ww, hh;
m_currentClippingRegion.GetBox( xx, yy, ww, hh );
#if wxUSE_NEW_DC
wxImplDC::DoSetClippingRegion( xx, yy, ww, hh );
wxGTKImplDC::DoSetClippingRegion( xx, yy, ww, hh );
#else
wxDC::DoSetClippingRegion( xx, yy, ww, hh );
#endif
@ -2338,7 +2338,7 @@ void wxGTKWindowImplDC::DoSetClippingRegionAsRegion( const wxRegion &region )
wxCoord xx, yy, ww, hh;
m_currentClippingRegion.GetBox( xx, yy, ww, hh );
#if wxUSE_NEW_DC
wxImplDC::DoSetClippingRegion( xx, yy, ww, hh );
wxGTKImplDC::DoSetClippingRegion( xx, yy, ww, hh );
#else
wxDC::DoSetClippingRegion( xx, yy, ww, hh );
#endif

View File

@ -186,12 +186,12 @@ wxBitmap wxGTKMemoryImplDC::DoGetAsBitmap(const wxRect *subrect) const
return subrect ? bmp.GetSubBitmap(*subrect) : bmp;
}
const wxBitmap& wxGTKMemoryImplDC::DoGetSelectedBitmap() const
const wxBitmap& wxGTKMemoryImplDC::GetSelectedBitmap() const
{
return m_selected;
}
wxBitmap& wxGTKMemoryImplDC::DoGetSelectedBitmap()
wxBitmap& wxGTKMemoryImplDC::GetSelectedBitmap()
{
return m_selected;
}

View File

@ -143,11 +143,22 @@ wxGtkPrintFactory::CreatePrintSetupDialog(wxWindow * WXUNUSED(parent),
return NULL;
}
#if wxUSE_NEW_DC
wxImplDC* wxGtkPrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data )
{
return new wxGtkPrinterImplDC( owner, data );
}
#else
wxDC* wxGtkPrintFactory::CreatePrinterDC( const wxPrintData& data )
{
return new wxGtkPrinterDC(data);
}
#endif
bool wxGtkPrintFactory::HasOwnPrintToFile()
{
return true;
@ -894,7 +905,11 @@ void wxGtkPrinter::BeginPrint(wxPrintout *printout, GtkPrintOperation *operation
SetPrintContext(context);
native->SetPrintContext( context );
#if wxUSE_NEW_DC
wxPrinterDC *printDC = new wxPrinterDC( printdata );
#else
wxGtkPrinterDC *printDC = new wxGtkPrinterDC( printdata );
#endif
m_dc = printDC;
if (!m_dc->IsOk())
@ -1065,7 +1080,12 @@ wxDC* wxGtkPrinter::PrintDialog( wxWindow *parent )
}
m_printDialogData = dialog.GetPrintDialogData();
#if wxUSE_NEW_DC
return new wxPrinterDC( m_printDialogData.GetPrintData() );
#else
return new wxGtkPrinterDC( m_printDialogData.GetPrintData() );
#endif
}
bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) )
@ -1083,9 +1103,19 @@ bool wxGtkPrinter::Setup( wxWindow * WXUNUSED(parent) )
#define YLOG2DEV(x) ((double)(LogicalToDeviceY(x)) * m_DEV2PS)
#define YLOG2DEVREL(x) ((double)(LogicalToDeviceYRel(x)) * m_DEV2PS)
IMPLEMENT_CLASS(wxGtkPrinterDC, wxDC)
#if wxUSE_NEW_DC
IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterImplDC, wxImplDC)
#else
IMPLEMENT_ABSTRACT_CLASS(wxGtkPrinterDC, wxDC)
#endif
#if wxUSE_NEW_DC
wxGtkPrinterImplDC::wxGtkPrinterImplDC( wxPrinterDC *owner, const wxPrintData& data ) :
wxImplDC( owner )
#else
wxGtkPrinterDC::wxGtkPrinterDC( const wxPrintData& data )
#endif
{
m_printData = data;
@ -1125,18 +1155,18 @@ wxGtkPrinterDC::wxGtkPrinterDC( const wxPrintData& data )
gs_cairo->cairo_translate(m_cairo, -ml, -mt);
}
wxGtkPrinterDC::~wxGtkPrinterDC()
wxGtkPrinterImplDC::~wxGtkPrinterImplDC()
{
g_object_unref(m_context);
g_object_unref(m_layout);
}
bool wxGtkPrinterDC::IsOk() const
bool wxGtkPrinterImplDC::IsOk() const
{
return m_gpc != NULL;
}
bool wxGtkPrinterDC::DoFloodFill(wxCoord WXUNUSED(x1),
bool wxGtkPrinterImplDC::DoFloodFill(wxCoord WXUNUSED(x1),
wxCoord WXUNUSED(y1),
const wxColour& WXUNUSED(col),
int WXUNUSED(style))
@ -1147,7 +1177,7 @@ bool wxGtkPrinterDC::DoFloodFill(wxCoord WXUNUSED(x1),
return false;
}
void wxGtkPrinterDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter)
void wxGtkPrinterImplDC::DoGradientFillConcentric(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, const wxPoint& circleCenter)
{
wxCoord xC = circleCenter.x;
wxCoord yC = circleCenter.y;
@ -1193,7 +1223,7 @@ void wxGtkPrinterDC::DoGradientFillConcentric(const wxRect& rect, const wxColour
CalcBoundingBox(xR+w, yR+h);
}
void wxGtkPrinterDC::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection)
void wxGtkPrinterImplDC::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection)
{
wxCoord x = rect.x;
wxCoord y = rect.y;
@ -1243,7 +1273,7 @@ void wxGtkPrinterDC::DoGradientFillLinear(const wxRect& rect, const wxColour& in
CalcBoundingBox(x+w, y+h);
}
bool wxGtkPrinterDC::DoGetPixel(wxCoord WXUNUSED(x1),
bool wxGtkPrinterImplDC::DoGetPixel(wxCoord WXUNUSED(x1),
wxCoord WXUNUSED(y1),
wxColour * WXUNUSED(col)) const
{
@ -1251,7 +1281,7 @@ bool wxGtkPrinterDC::DoGetPixel(wxCoord WXUNUSED(x1),
return false;
}
void wxGtkPrinterDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
void wxGtkPrinterImplDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
if (m_pen.GetStyle() == wxTRANSPARENT) return;
@ -1264,7 +1294,7 @@ void wxGtkPrinterDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
CalcBoundingBox( x2, y2 );
}
void wxGtkPrinterDC::DoCrossHair(wxCoord x, wxCoord y)
void wxGtkPrinterImplDC::DoCrossHair(wxCoord x, wxCoord y)
{
int w, h;
DoGetSize(&w, &h);
@ -1281,7 +1311,7 @@ void wxGtkPrinterDC::DoCrossHair(wxCoord x, wxCoord y)
CalcBoundingBox( w, h );
}
void wxGtkPrinterDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc)
void wxGtkPrinterImplDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc)
{
double dx = x1 - xc;
double dy = y1 - yc;
@ -1333,7 +1363,7 @@ void wxGtkPrinterDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoo
CalcBoundingBox (x2, y2);
}
void wxGtkPrinterDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
void wxGtkPrinterImplDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea)
{
gs_cairo->cairo_save( m_cairo );
@ -1359,7 +1389,7 @@ void wxGtkPrinterDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,d
CalcBoundingBox( x+w, y+h );
}
void wxGtkPrinterDC::DoDrawPoint(wxCoord x, wxCoord y)
void wxGtkPrinterImplDC::DoDrawPoint(wxCoord x, wxCoord y)
{
if (m_pen.GetStyle() == wxTRANSPARENT) return;
@ -1372,7 +1402,7 @@ void wxGtkPrinterDC::DoDrawPoint(wxCoord x, wxCoord y)
CalcBoundingBox( x, y );
}
void wxGtkPrinterDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
void wxGtkPrinterImplDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
{
if (m_pen.GetStyle() == wxTRANSPARENT) return;
@ -1392,7 +1422,7 @@ void wxGtkPrinterDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoo
gs_cairo->cairo_stroke ( m_cairo);
}
void wxGtkPrinterDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
void wxGtkPrinterImplDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
{
if (n==0) return;
@ -1426,12 +1456,16 @@ void wxGtkPrinterDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxC
gs_cairo->cairo_restore(m_cairo);
}
void wxGtkPrinterDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
void wxGtkPrinterImplDC::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle)
{
#if wxUSE_NEW_DC
wxImplDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle );
#else
wxDC::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle );
#endif
}
void wxGtkPrinterDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxGtkPrinterImplDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
width--;
height--;
@ -1449,7 +1483,7 @@ void wxGtkPrinterDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoor
CalcBoundingBox( x + width, y + height );
}
void wxGtkPrinterDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
void wxGtkPrinterImplDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius)
{
width--;
height--;
@ -1497,7 +1531,7 @@ void wxGtkPrinterDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width,
CalcBoundingBox(x+width,y+height);
}
void wxGtkPrinterDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxGtkPrinterImplDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
width--;
height--;
@ -1523,7 +1557,7 @@ void wxGtkPrinterDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord
}
#if wxUSE_SPLINES
void wxGtkPrinterDC::DoDrawSpline(const wxPointList *points)
void wxGtkPrinterImplDC::DoDrawSpline(const wxPointList *points)
{
SetPen (m_pen);
@ -1582,7 +1616,7 @@ void wxGtkPrinterDC::DoDrawSpline(const wxPointList *points)
}
#endif // wxUSE_SPLINES
bool wxGtkPrinterDC::DoBlit(wxCoord xdest, wxCoord ydest,
bool wxGtkPrinterImplDC::DoBlit(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop, bool useMask,
@ -1602,19 +1636,19 @@ bool wxGtkPrinterDC::DoBlit(wxCoord xdest, wxCoord ydest,
memDC.SelectObject(wxNullBitmap);
// Draw bitmap. scaling and positioning is done there.
DrawBitmap( bitmap, xdest, ydest, useMask );
GetOwner()->DrawBitmap( bitmap, xdest, ydest, useMask );
return true;
}
void wxGtkPrinterDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )
void wxGtkPrinterImplDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )
{
DoDrawBitmap( icon, x, y, true );
}
void wxGtkPrinterDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask )
void wxGtkPrinterImplDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask )
{
wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrinterDC::DoDrawBitmap"));
wxCHECK_RET( bitmap.IsOk(), wxT("Invalid bitmap in wxGtkPrinterImplDC::DoDrawBitmap"));
cairo_surface_t* surface;
x = wxCoord(XLOG2DEV(x));
@ -1725,12 +1759,12 @@ void wxGtkPrinterDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y,
gs_cairo->cairo_restore(m_cairo);
}
void wxGtkPrinterDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
void wxGtkPrinterImplDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y )
{
DoDrawRotatedText( text, x, y, 0.0 );
}
void wxGtkPrinterDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
void wxGtkPrinterImplDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle)
{
double xx = XLOG2DEV(x);
double yy = YLOG2DEV(y);
@ -1842,7 +1876,7 @@ void wxGtkPrinterDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord
CalcBoundingBox (x + w, y + h);
}
void wxGtkPrinterDC::Clear()
void wxGtkPrinterImplDC::Clear()
{
// Clear does nothing for printing, but keep the code
// for later reuse
@ -1855,7 +1889,7 @@ void wxGtkPrinterDC::Clear()
*/
}
void wxGtkPrinterDC::SetFont( const wxFont& font )
void wxGtkPrinterImplDC::SetFont( const wxFont& font )
{
m_font = font;
@ -1876,7 +1910,7 @@ void wxGtkPrinterDC::SetFont( const wxFont& font )
}
}
void wxGtkPrinterDC::SetPen( const wxPen& pen )
void wxGtkPrinterImplDC::SetPen( const wxPen& pen )
{
if (!pen.Ok()) return;
@ -1955,7 +1989,7 @@ void wxGtkPrinterDC::SetPen( const wxPen& pen )
}
}
void wxGtkPrinterDC::SetBrush( const wxBrush& brush )
void wxGtkPrinterImplDC::SetBrush( const wxBrush& brush )
{
if (!brush.Ok()) return;
@ -2048,7 +2082,7 @@ void wxGtkPrinterDC::SetBrush( const wxBrush& brush )
}
}
void wxGtkPrinterDC::SetLogicalFunction( int function )
void wxGtkPrinterImplDC::SetLogicalFunction( int function )
{
if (function == wxCLEAR)
gs_cairo->cairo_set_operator (m_cairo, CAIRO_OPERATOR_CLEAR);
@ -2066,7 +2100,7 @@ void wxGtkPrinterDC::SetLogicalFunction( int function )
gs_cairo->cairo_set_operator (m_cairo, CAIRO_OPERATOR_SOURCE);
}
void wxGtkPrinterDC::SetBackground( const wxBrush& brush )
void wxGtkPrinterImplDC::SetBackground( const wxBrush& brush )
{
m_backgroundBrush = brush;
gs_cairo->cairo_save(m_cairo);
@ -2077,7 +2111,7 @@ void wxGtkPrinterDC::SetBackground( const wxBrush& brush )
gs_cairo->cairo_restore(m_cairo);
}
void wxGtkPrinterDC::SetBackgroundMode(int mode)
void wxGtkPrinterImplDC::SetBackgroundMode(int mode)
{
if (mode == wxSOLID)
m_backgroundMode = wxSOLID;
@ -2085,38 +2119,38 @@ void wxGtkPrinterDC::SetBackgroundMode(int mode)
m_backgroundMode = wxTRANSPARENT;
}
void wxGtkPrinterDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
void wxGtkPrinterImplDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
gs_cairo->cairo_rectangle ( m_cairo, XLOG2DEV(x), YLOG2DEV(y), XLOG2DEVREL(width), YLOG2DEVREL(height));
gs_cairo->cairo_clip(m_cairo);
}
void wxGtkPrinterDC::DestroyClippingRegion()
void wxGtkPrinterImplDC::DestroyClippingRegion()
{
gs_cairo->cairo_reset_clip(m_cairo);
}
bool wxGtkPrinterDC::StartDoc(const wxString& WXUNUSED(message))
bool wxGtkPrinterImplDC::StartDoc(const wxString& WXUNUSED(message))
{
return true;
}
void wxGtkPrinterDC::EndDoc()
void wxGtkPrinterImplDC::EndDoc()
{
return;
}
void wxGtkPrinterDC::StartPage()
void wxGtkPrinterImplDC::StartPage()
{
return;
}
void wxGtkPrinterDC::EndPage()
void wxGtkPrinterImplDC::EndPage()
{
return;
}
wxCoord wxGtkPrinterDC::GetCharHeight() const
wxCoord wxGtkPrinterImplDC::GetCharHeight() const
{
pango_layout_set_text( m_layout, "H", 1 );
@ -2126,7 +2160,7 @@ wxCoord wxGtkPrinterDC::GetCharHeight() const
return wxRound( h * m_PS2DEV );
}
wxCoord wxGtkPrinterDC::GetCharWidth() const
wxCoord wxGtkPrinterImplDC::GetCharWidth() const
{
pango_layout_set_text( m_layout, "H", 1 );
@ -2136,7 +2170,7 @@ wxCoord wxGtkPrinterDC::GetCharWidth() const
return wxRound( w * m_PS2DEV );
}
void wxGtkPrinterDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height,
void wxGtkPrinterImplDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height,
wxCoord *descent,
wxCoord *externalLeading,
const wxFont *theFont ) const
@ -2194,7 +2228,7 @@ void wxGtkPrinterDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC
pango_layout_set_font_description( m_layout, m_fontdesc );
}
void wxGtkPrinterDC::DoGetSize(int* width, int* height) const
void wxGtkPrinterImplDC::DoGetSize(int* width, int* height) const
{
GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc );
@ -2204,7 +2238,7 @@ void wxGtkPrinterDC::DoGetSize(int* width, int* height) const
*height = wxRound( gtk_page_setup_get_paper_height( setup, GTK_UNIT_POINTS ) * m_PS2DEV );
}
void wxGtkPrinterDC::DoGetSizeMM(int *width, int *height) const
void wxGtkPrinterImplDC::DoGetSizeMM(int *width, int *height) const
{
GtkPageSetup *setup = gtk_print_context_get_page_setup( m_gpc );
@ -2214,23 +2248,28 @@ void wxGtkPrinterDC::DoGetSizeMM(int *width, int *height) const
*height = wxRound( gtk_page_setup_get_paper_height( setup, GTK_UNIT_MM ) );
}
wxSize wxGtkPrinterDC::GetPPI() const
wxSize wxGtkPrinterImplDC::GetPPI() const
{
return wxSize( (int)m_resolution, (int)m_resolution );
}
void wxGtkPrinterDC::SetPrintData(const wxPrintData& data)
void wxGtkPrinterImplDC::SetPrintData(const wxPrintData& data)
{
m_printData = data;
}
void wxGtkPrinterDC::SetResolution(int WXUNUSED(ppi))
// overriden for wxPrinterDC Impl
wxRect wxGtkPrinterImplDC::GetPaperRect()
{
// We can't change ppi of the GtkPrintContext.
// TODO: should we really support this?
// Does GtkPrint support printer margins?
int w = 0;
int h = 0;
DoGetSize( &w, &h );
return wxRect( 0,0,w,h );
}
int wxGtkPrinterDC::GetResolution()
int wxGtkPrinterImplDC::GetResolution()
{
return m_resolution;
}