symbols

17 views
Skip to first unread message

holm.h...@gmail.com

unread,
Feb 23, 2026, 3:10:07 AM (9 days ago) Feb 23
to fltk.general

Hello,

I have used several of the fltk predefined symbols and these have a positive effect on the user interface.

I would like to add more icons, tailored to my application. Is that possible ?
If so how to proceed ?

Best regards
Håvard

pvr...@btinternet.com

unread,
Feb 23, 2026, 3:41:18 AM (9 days ago) Feb 23
to fltkg...@googlegroups.com
Hi Håvard

I have several in my application. 

You need a method to draw the symbol: here's is one I have for an envelope for a button to generate an e-mail.

// Draw the mail symbol
void draw_mail(Fl_Color c) {
      Fl_Color sv = fl_color();
      // Fill in lower section]
      fl_color(fl_lighter(fl_lighter(c)));
      fl_begin_polygon();
      fl_vertex(-0.7, -0.5);
      fl_vertex(+0.7, -0.5);
      fl_vertex(+0.7, +0.5);
      fl_vertex(-0.7, +0.5);
      fl_end_polygon();
      // Fill in flap
      fl_color(c);
      fl_begin_polygon();
      fl_vertex(-0.7, -0.5);
      fl_vertex(+0.7, -0.5);
      fl_vertex(0, +0.1);
      fl_end_polygon();
      // Draw the outline
      fl_begin_loop();
      fl_vertex(-0.7, -0.5);
      fl_vertex(+0.7, -0.5);
      fl_vertex(+0.7, +0.5);
      fl_vertex(-0.7, +0.5);
      fl_end_loop();
      // Draw the upward join
      fl_begin_line();
      fl_vertex(-0.7, +0.5);
      fl_vertex(0, -0.1);
      fl_vertex(+0.7, +0.5);
      fl_end_line();
      // Restore colour
      fl_color(sv);
}

Drawing coordinates are in fractions of the button size. I can't remember if it's width or height or the smaller. All my symbols are used in square buttons. The colour parameter is the labelcolor.

Then you need to associate the @text with the symbol.

      fl_add_symbol("mail", &draw_mail, true);

Associates the symbol "@mail" with the drawn envelope. 

I have others: open and closed eyes for password visible or not and a calendar icon.

I hope that helps.

Regards Phil.

From: fltkg...@googlegroups.com <fltkg...@googlegroups.com> on behalf of holm.h...@gmail.com <holm.h...@gmail.com>
Sent: Monday, February 23, 2026 8:10 AM
To: fltk.general <fltkg...@googlegroups.com>
Subject: [fltk.general] symbols
 
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/25f89860-171c-4272-833a-c762941722a4n%40googlegroups.com.

holm.h...@gmail.com

unread,
Feb 23, 2026, 5:22:52 AM (9 days ago) Feb 23
to fltk.general

Thank you very much Phil,

I have not tested out yet, but your explanation seems just like what I would need

Thank you!
Håvard

Manolo

unread,
Feb 23, 2026, 9:31:15 AM (9 days ago) Feb 23
to fltk.general
A completely different approach to generate "icons" would be to define them in SVG,
construct Fl_SVG_Image objects from them, and set them as the image of widgets in the app.
The SVG data can be stored in a file or in memory as a char array.

Gonzalo Garramuño

unread,
Feb 23, 2026, 10:02:57 AM (9 days ago) Feb 23
to fltkg...@googlegroups.com

El 23/2/26 a las 11:31, Manolo escribió:
> A completely different approach to generate "icons" would be to define
> them in SVG,
> construct Fl_SVG_Image objects from them, and set them as the image of
> widgets in the app.
> The SVG data can be stored in a file or in memory as a char array.
>
And, if using v1.5 HEAD, yet another approach is to use emoji icons,
which is plethora of icons already pre-defined and created for use.

holm.h...@gmail.com

unread,
Feb 23, 2026, 3:30:52 PM (9 days ago) Feb 23
to fltk.general

Hi,

In my application it is important to activate a "night-view-mode" with a dark coloring scheme. I have a function which transverse all widgets to update the coloring.
The predefined @sympols handles this very well.
I guess a ->image();  would be a little more tricky in this manner ?

Maybe an alternative would be to use the fl_add_symbol() function and the make the draw function( Phil's draw_mail) draw a image with the correct coloring ?

What do you think?

Best regards
Håvard

Albrecht Schlosser

unread,
Feb 23, 2026, 3:50:02 PM (9 days ago) Feb 23
to fltkg...@googlegroups.com
On 2/23/26 21:30 holm.h...@gmail.com wrote:
> In my application it is important to activate a "night-view-mode" with
> a dark coloring scheme. I have a function which transverse all widgets
> to update the coloring.
> The predefined @sympols handles this very well.
> I guess a ->image();  would be a little more tricky in this manner ?
>
> Maybe an alternative would be to use the fl_add_symbol() function and
> the make the draw function( Phil's draw_mail) draw a image with the
> correct coloring ?
>
> What do you think?

SVG images are just text, you can edit them in memory if you like. You
can even generate them from a template and inject colors as needed.

Greg Ercolano ("Erco") has an example of an SVG file created and
modified at runtime, see

"Erco's FLTK Cheat Page" at https://www.seriss.com/people/erco/fltk/.

The example I mean is:
https://www.seriss.com/people/erco/fltk/#FLTK-Simplex-Clock

Alternatively you could use several SVG or PNG images in different
colors for your icons and replace them, depending on the theming (dark,
light).

pvr...@btinternet.com

unread,
Feb 23, 2026, 3:59:55 PM (9 days ago) Feb 23
to fltkg...@googlegroups.com
Hi Håvard

I handle a "dark" mode feature using the following code:

      // Set foreground and background colours
      if (DARK) {
            Fl::foreground(240, 240, 240);             // 15/16 White
            Fl::background2(16, 16, 16);               // 1/16 white
            Fl::background(32, 32, 32);                // 1/8 white
      }
      else {
            Fl::foreground(16, 16, 16);                // 1/16 white
            Fl::background2(240, 240, 240);            // 15/16 white
            Fl::background(192, 192, 192);             // 3/4 white
      }

That I call before I instantiate any widgets, as it's invoked by a command line switch. This changes the colours represented by FL_FOREGROUND_COLOR etc. The non-DARK colours are the default 1.4 colours, the DARK set was achieved by a bit of trial and error to get the grey level right for FL_BACKGROUND_COLOR.

I use the default colours for most widgets and this allows them to be either light foreground on dark background or the other way round.

If (and it's a big if) the colours used by a widgets are kept as FL_FOREGROUND_COLOR then changing this dynamically may do what you want by just calling redraw() on your top window to switch colours without having to go round all the widgets in turn changing their colours. 

Regards Phil.




Sent: Monday, February 23, 2026 8:30 PM
To: fltk.general <fltkg...@googlegroups.com>
Subject: Re: [fltk.general] Re: symbols
 
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages