asmwarrior / SvgPanel

a wxPanel which can show svg image and simple text labels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SvgPanel

A wxPanel which can show svg image and simple text labels.

The code contains two parts: 1, original file nanosvg.h and nanosvgrast.h are from memononen/nanosvg: Simple stupid SVG parser 2, original file svg_panel.h and svg_panel.cpp are from doublemax's svg panel sources in wxWidgets Discussion Forum - Index page, see this post for details Re: Use SVG Icons with wxDataViewCtrl (and others)

Note that currently, memononen/nanosvg: Simple stupid SVG parser does not support parsing the Text field in svg file. I have modifed nanosvg.h to support parsing the Text field in the SVG file. I mainly followed commits in this pull request: Adds basic text parsing by jamislike · Pull Request #94 · memononen/nanosvg, but with some extra code changes, Also, I have merged from the latest master code of nanosvg.

The svg_panel.h and svg_panel.cpp files are modifed to extract the Text field and show them by wxWidgets' DrawText function. So, basically, the rasterizer from nanosvg is used to generated the background wxBitmap image, and later text labels were drawn on top of the wxBitmap image.

Here is the screen shot of a svg file drawing.svg shown in the panel compared with shown in the Inkscape editor. You can also open the svg file in the web browser directly for a comparsion.

svg image shown in panel vs Inkscape

How to use the code

Just copy/drag the 4 source files(nanosvg.h, nanosvgrast.h, svg_panel.h and svg_panel.cpp) to your project file, and construct a SVGPanel window where you needed.

About

a wxPanel which can show svg image and simple text labels


Languages

Language:C 89.5%Language:C++ 10.5%