wxPdfDoc and wxWidgets-2.9.5  [SOLVED]

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 397
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

wxPdfDoc and wxWidgets-2.9.5

Postby xaviou » Tue Jun 11, 2013 9:53 am

Hi.

I'm currently trying to build wxPdfDocument (v0.9.3) with wxWidgets-2.9.5 (svn), and I get errors :

Code: Select all

In constructor 'wxPdfDC::wxPdfDC()':
error: cannot allocate an object of abstract type 'wxPdfDCImpl'
note:   because the following virtual functions are pure within 'wxPdfDCImpl':
note:     virtual void wxDCImpl::DoDrawLines(int, const wxPoint*, wxCoord, wxCoord)
note:     virtual void wxDCImpl::DoDrawPolygon(int, const wxPoint*, wxCoord, wxCoord, wxPolygonFillMode)
In constructor 'wxPdfDC::wxPdfDC(const wxPrintData&)':
error: cannot allocate an object of abstract type 'wxPdfDCImpl'
note:   since type 'wxPdfDCImpl' has pure virtual functions
In constructor 'wxPdfDC::wxPdfDC(wxPdfDocument*, double, double)':
error: cannot allocate an object of abstract type 'wxPdfDCImpl'
note:   since type 'wxPdfDCImpl' has pure virtual functions


The wxWidgets libs were build with the following parameters :
  • Release
  • Unicode
  • Dynamic
  • Multi-Libs
  • All other parameters to default

Note that it builds fine with wxWidgets-2.9.4.

Does anyone know if there is something to do to avoid these errors or do I have to wait a wxPdfDoc sources update ?

Thanks in advance.

Regards

Xav'
My wxWidgets stuff web page : X@v's wxStuff

utelle
Moderator
Moderator
Posts: 767
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDoc and wxWidgets-2.9.5  [SOLVED]

Postby utelle » Tue Jun 11, 2013 12:44 pm

xaviou wrote:I'm currently trying to build wxPdfDocument (v0.9.3) with wxWidgets-2.9.5 (svn),

Usually I build wxPdfDocument against officially released wxWidgets versions only and test for compatibility and implement fixes if some interface changes occur. wxWidgets SVN is a moving target and I can't spare the time to keep wxPdfDocument in sync with it. Nevertheless I checked the wxWidgets SVN to find out what's causing the problem.

xaviou wrote:and I get errors :

Code: Select all

In constructor 'wxPdfDC::wxPdfDC()':
error: cannot allocate an object of abstract type 'wxPdfDCImpl'
note:   because the following virtual functions are pure within 'wxPdfDCImpl':
note:     virtual void wxDCImpl::DoDrawLines(int, const wxPoint*, wxCoord, wxCoord)
note:     virtual void wxDCImpl::DoDrawPolygon(int, const wxPoint*, wxCoord, wxCoord, wxPolygonFillMode)
In constructor 'wxPdfDC::wxPdfDC(const wxPrintData&)':
error: cannot allocate an object of abstract type 'wxPdfDCImpl'
note:   since type 'wxPdfDCImpl' has pure virtual functions
In constructor 'wxPdfDC::wxPdfDC(wxPdfDocument*, double, double)':
error: cannot allocate an object of abstract type 'wxPdfDCImpl'
note:   since type 'wxPdfDCImpl' has pure virtual functions


The wxWidgets libs were build with the following parameters :
  • Release
  • Unicode
  • Dynamic
  • Multi-Libs
  • All other parameters to default

Note that it builds fine with wxWidgets-2.9.4.

Does anyone know if there is something to do to avoid these errors or do I have to wait a wxPdfDoc sources update ?

The methods DoDrawLines and DoDrawPolygon are in fact implemented in wxPdfDC. However, up to and including version 2.9.4 of wxWidgets the signatures of these methods were:

Code: Select all

  virtual void DoDrawLines(int n, wxPoint points[],
                           wxCoord xoffset, wxCoord yoffset);
  virtual void DoDrawPolygon(int n, wxPoint points[],
                             wxCoord xoffset, wxCoord yoffset,
                             wxPolygonFillMode fillStyle = wxODDEVEN_RULE);


In wxWidgets SVN there occurred a change of the signatures by adding constness to the wxPoint array parameters:

Code: Select all

  virtual void DoDrawLines(int n, const wxPoint points[],
                           wxCoord xoffset, wxCoord yoffset);
  virtual void DoDrawPolygon(int n, const wxPoint points[],
                             wxCoord xoffset, wxCoord yoffset,
                             wxPolygonFillMode fillStyle = wxODDEVEN_RULE);

To make wxPdfDocument compatible with wxWidgets SVN you would have to change the signatures of the methods in the header and source files of the wxPdfDC implementation (include/wx/pdfdc29.h and src/pdfdc29.inc).

Regards,

Ulrich

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 397
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: wxPdfDoc and wxWidgets-2.9.5

Postby xaviou » Tue Jun 11, 2013 4:52 pm

Hi.

It was a little more complicated, but I finally got it to work.

In addition to the signatures modifications, a line must be replaced in both these functions (in file src/pdfdoc29.inc) :

Code: Select all

wxPoint& point = points[i];

becomes

Code: Select all

const wxPoint& point = points[i];

This modification doesn't affect the compilation with wxWidgets-2.9.4

And there is another class that derives from wxPdfDCImpl : wxPdfPreviewDCImpl
So, the signatures modifications have to be done in file : include/wx/pdfprint.h

If someone is interested, I've attached to this reply a 7Zip archive that contains the modified files.
These modifications allow the compilation with all recents versions of wxWidgets (tested with 2.8.12, 2.9.4 and 2.9.5).

Regards

Xav'
Attachments
wxpdfdoc-0.9.3-modified-files.7z
7Zip Archive that contains the modified files to allow the compilation with wxWidgets-2.9.5
(13.5 KiB) Downloaded 123 times
My wxWidgets stuff web page : X@v's wxStuff

utelle
Moderator
Moderator
Posts: 767
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDoc and wxWidgets-2.9.5

Postby utelle » Wed Jun 12, 2013 6:26 am

xaviou wrote:It was a little more complicated, but I finally got it to work.

My posting was not meant as complete solution, but just as a pointer. However, you got the idea and were able to modify the code accordingly.

xaviou wrote:If someone is interested, I've attached to this reply a 7Zip archive that contains the modified files.
These modifications allow the compilation with all recents versions of wxWidgets (tested with 2.8.12, 2.9.4 and 2.9.5).

Thanks for providing your patches. I will incorporate them into wxPdfDocument when wxWidgets 2.9.5 will be officially released.

Regards,

Ulrich


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 2 guests