summaryrefslogtreecommitdiff
path: root/test/pixmap_browser.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-06-27 09:56:00 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-06-27 09:56:00 +0200
commit26e6c3f930a052a1e729d160b0e8e5b6042b5018 (patch)
treea8d9ced3f2c8eac6414394a9b2930a1757a1ee50 /test/pixmap_browser.cxx
parent93f19c3a2457f1c87f3c0781481f0bcc1602a514 (diff)
Add classes Fl_SVG_File_Surface and Fl_EPS_File_Surface to draw to SVG and EPS.
Test programs device and pixmap_browser use these new classes. Class Fl_SVG_File_Surface can be optionally made non functional using the --disable-svg configure option or turning off OPTION_USE_SVG in CMake. Class Fl_EPS_File_Surface can be optionally made non functional using the --disable-print configure option or turning off OPTION_PRINT_SUPPORT in CMake.
Diffstat (limited to 'test/pixmap_browser.cxx')
-rw-r--r--test/pixmap_browser.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/test/pixmap_browser.cxx b/test/pixmap_browser.cxx
index 7d2ea3c3c..b2611703b 100644
--- a/test/pixmap_browser.cxx
+++ b/test/pixmap_browser.cxx
@@ -27,7 +27,8 @@
#include <errno.h>
#include <FL/Fl_File_Chooser.H>
#include <FL/fl_message.H>
-
+#include <FL/Fl_SVG_File_Surface.H>
+#include <FL/Fl_Native_File_Chooser.H>
Fl_Box *b;
Fl_Double_Window *w;
Fl_Shared_Image *img;
@@ -77,16 +78,17 @@ void file_cb(const char *n) {
void button_cb(Fl_Widget *,void *) {
fl_file_chooser_callback(file_cb);
const char *fname = fl_file_chooser("Image file?","*.{bm,bmp,gif,jpg,pbm,pgm,png,ppm,xbm,xpm"
-#ifdef FLTK_USE_NANOSVG
+#ifdef FLTK_USE_SVG
",svg"
#ifdef HAVE_LIBZ
",svgz"
-#endif
-#endif
+#endif // HAVE_LIBZ
+#endif // FLTK_USE_SVG
"}", name);
puts(fname ? fname : "(null)"); fflush(stdout);
fl_file_chooser_callback(0);
}
+
void print_cb(Fl_Widget *widget, void *) {
Fl_Printer printer;
int width, height;
@@ -101,6 +103,19 @@ void print_cb(Fl_Widget *widget, void *) {
printer.end_page();
printer.end_job();
}
+
+void svg_cb(Fl_Widget *widget, void *) {
+ Fl_Native_File_Chooser fnfc;
+ fnfc.title("Pick a .svg file");
+ fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
+ fnfc.filter("SVG\t*.svg\n");
+ fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM | Fl_Native_File_Chooser::USE_FILTER_EXT);
+ if (fnfc.show() ) return;
+ FILE *svg = fl_fopen(fnfc.filename(), "w");
+ Fl_SVG_File_Surface surf(widget->window()->decorated_w(), widget->window()->decorated_h(), svg);
+ surf.draw_decorated_window(widget->window());
+ surf.close();
+}
int dvisual = 0;
int arg(int, char **argv, int &i) {
@@ -126,6 +141,8 @@ int main(int argc, char **argv) {
window.resizable(b);
Fl_Button print(300,425,50,25,"Print");
print.callback(print_cb);
+ Fl_Button svg(190,425,100,25,"save as SVG");
+ svg.callback(svg_cb);
window.show(argc,argv);
return Fl::run();