wxPdfDocument: vote for API changes

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.

How should wxPdfDocument handle line styles in graphics primitives?

Poll ended at Sun Nov 27, 2005 3:07 pm

Drop wxPdfLineStyle argument from graphics primitives. Use SetLineStyle always separately.
3
100%
Keep wxPdfLineStyle argument. Set and restore line styles in all graphics primitives.
0
No votes
No changes to the current API. If necessary restore line styles manually using SetLineStyle.
0
No votes
 
Total votes: 3

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

wxPdfDocument: vote for API changes

Post by utelle »

The current API of wxPdfDocument contains several methods for graphics primitives:

Line, Rect, RoundedRect, Curve, Ellipse, Circle, Polygon, ...

Almost all of these methods have a wxPdfLineStyle argument. Currently the line style is set before drawing the line, rectangle etc., but the previous line style is not restored afterwards.

I got some comments from users who don't like this behaviour due to the side effect of changing the line style for subsequent methods. So I consider to change the API in the next release.

There are several alternatives to handle line styles:
  • Drop wxPdfLineStyle argument from all graphics primitives and always use SetLineStyle to change the line style.
    Advantage
    : consistent behaviour, line style changes only when needed.
  • Keep wxPdfLineStyle argument, but automatically restore the previous line style in all graphics primitives.
    Advantage: consistent behaviour.
    Disadvantage: produces superfluous line style changes thereby enlarging the size of the resulting PDF file.
  • No changes to the current API.
    Advantage: allows to change line style only when needed.
    Disadvantage: inconsistent behaviour.
Personally, I would prefer to change the API according to the first described handling, i.e. drop the wxPdfStyle argument, but since already several hundred users have downloaded wxPdfDocument, there might be other opinions.

Regards,

Ulrich
User avatar
tierra
Site Admin
Site Admin
Posts: 1355
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA

Post by tierra »

You're first option (and the one you prefer) would be nice for the fact that it would be consistent with the way operations work on wxDC with pens, brushes, and fonts. Unfortunately I don't know how other PDF libraries work, and staying consistent with those might be a better option.

Either way, I'm not a current user of wxPdfDocument, so don't let my opinion make any decisions. Just wanted to point out wxDC's behaviour.
utelle
Moderator
Moderator
Posts: 1130
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany

Post by utelle »

tierra wrote:You're first option (and the one you prefer) would be nice for the fact that it would be consistent with the way operations work on wxDC with pens, brushes, and fonts.
Thank you for this remark. I guess this is a strong argument in favor of the first option, since I plan to provide a wxPdfDC class based on wxPdfDocument in a future version.
tierra wrote:Unfortunately I don't know how other PDF libraries work, and staying consistent with those might be a better option.
At least CLibPDF, PDFlib and libharu work as my first option describes.

Regards,

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

Post by utelle »

The decision has been made in favor of dropping the style parameters. A new version of wxPdfDocument incorporating the necessary changes and adding several enhancements has been released, see announcement.

Regards,

Ulrich