Hi,
I want to replace my png icons with SVG ones. I have tried to google and I could not find any useful information so far. Have anyone tried that? How far does wxWidgets support it?
Thanks!
Use SVG Icons with wxDataViewCtrl (and others)
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Use SVG Icons with wxDataViewCtrl (and others)
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Use SVG Icons with wxDataViewCtrl (and others)
wxWidgets itself has no SVG reading support. There is http://wxsvg.sourceforge.net/ but unfortunately it requires Cairo under Windows, so that's not an option for me.
For simple SVGs you can use https://github.com/memononen/nanosvg
It's very easy to integrate as it only consists of two header files. But it only supports a part of the SVG standard, so some SVGs may look broken or imcomplete. Most of the Tango icons look fine though.
For simple SVGs you can use https://github.com/memononen/nanosvg
It's very easy to integrate as it only consists of two header files. But it only supports a part of the SVG standard, so some SVGs may look broken or imcomplete. Most of the Tango icons look fine though.
Use the source, Luke!
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Use SVG Icons with wxDataViewCtrl (and others)
Thanks DM.doublemax wrote:wxWidgets itself has no SVG reading support. There is http://wxsvg.sourceforge.net/ but unfortunately it requires Cairo under Windows, so that's not an option for me.
For simple SVGs you can use https://github.com/memononen/nanosvg
It's very easy to integrate as it only consists of two header files. But it only supports a part of the SVG standard, so some SVGs may look broken or imcomplete. Most of the Tango icons look fine though.
I will try nanosvg.
Cairo is a no-go for me too
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Re: Use SVG Icons with wxDataViewCtrl (and others)
Here is the source for my SVG_panel i used for testing nanosvg. Maybe it helps.
- Attachments
-
- svg_panel.h
- (484 Bytes) Downloaded 215 times
-
- svg_panel.cpp
- (3.06 KiB) Downloaded 271 times
Use the source, Luke!
Re: Use SVG Icons with wxDataViewCtrl (and others)
FYI:
If you use Msys2, you will see there are already some SVG library packages, you can easily install them by the pacman command:
Package: mingw-w64-x86_64-wxsvg - MSYS2 Packages
Package: mingw-w64-x86_64-librsvg - MSYS2 Packages
Once you install this package, all the appendices are also installed.
If you use Msys2, you will see there are already some SVG library packages, you can easily install them by the pacman command:
Package: mingw-w64-x86_64-wxsvg - MSYS2 Packages
Package: mingw-w64-x86_64-librsvg - MSYS2 Packages
Once you install this package, all the appendices are also installed.
Re: Use SVG Icons with wxDataViewCtrl (and others)
Thanks!
It looks like wxWigets are now using nanosvg.
Just FYI: wxWidgets does now include nanosvg as SVG renderer · Issue #201 · memononen/nanosvg
Re: Use SVG Icons with wxDataViewCtrl (and others)
I try to use doublemax's svg_panel.cpp/h file to show a svg file.
While I see that nanosvg can not support showing the text field. Luckily, I found someone has a pull request to the nanosvg, and the parser can extract the text, and I can now draw the text by the dc.DrawText function over the rasterized svg image.
See discussion here: Adds basic text parsing by jamislike · Pull Request #94 · memononen/nanosvg
And see the image shot here, note that the text "abc" is drawn by the native dc.DrawText function.
While I see that nanosvg can not support showing the text field. Luckily, I found someone has a pull request to the nanosvg, and the parser can extract the text, and I can now draw the text by the dc.DrawText function over the rasterized svg image.
See discussion here: Adds basic text parsing by jamislike · Pull Request #94 · memononen/nanosvg
And see the image shot here, note that the text "abc" is drawn by the native dc.DrawText function.
Re: Use SVG Icons with wxDataViewCtrl (and others)
FYI:
I have create a github repo to share my work on show SVG text by the nanosvg and doublemax's svg_panel.cpp/h.
See here: asmwarrior/SvgPanel: a wxPanel which can show svg image and simple text labels
I have create a github repo to share my work on show SVG text by the nanosvg and doublemax's svg_panel.cpp/h.
See here: asmwarrior/SvgPanel: a wxPanel which can show svg image and simple text labels