Re: Re: FLUID: how can I have SVG icons embedded in the code?
Ian MacArthur
Apr 18, 2024
BUT: It doesn't rescale when I resize the widget. So I guess I do still need a resize() method to handle that still?
OK, tried this over lunch - here's an example as a fluid file, seems to work for me at any rate... You'll need to provide a SVG image called "test_img.svg" but other than that should just work.
fluid -c test1.fl
fltk-config --use-images --compile test1.cxx
====================== test1.fl ===
# data file for the Fltk User Interface Designer (fluid) version 1.0400 header_name {.h} code_name {.cxx} decl {\#include <FL/Fl_SVG_Image.H>} {public global }
decl {\#include <FL/Fl_Box.H>} {public global }
data svg3 {private local filename {../img/test_img.svg} textmode }
class svg_rsz {open : {public Fl_Box} } { Function {svg_rsz(Fl_SVG_Image *svg2, int X, int Y, int W, int H, const char* L=0) : Fl_Box(X,Y,W,H,L)} { comment Constructor open } { code {svg = svg2; svg->resize(w(),h()); image(svg);} {} } Function {resize(int x, int y, int w, int h)} { comment {A resize method} open return_type void } { code {Fl_Box::resize(x,y,w,h); svg->resize(this->w(),this->h());} {} } decl {Fl_SVG_Image *svg;} {private local } }
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.