FLTK logo

Re: [fltk.general] Fl_Button label line spacing

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Button label line spacing Greg Ercolano Aug 11, 2021  
 


On 8/11/21 5:55 AM, Daniel Santos wrote:
Hi, I'm trying to put vertical text in a button, I'm using the \n newline, but the vertical spacing is too big, is it possible to put less spacing?
Thanks

    I take this to mean you have maybe:

     ___________________
    |                   |
    |     Line One      |
    |                   |
    |     Line Two      |
    |___________________|

    I don't think FLTK allows you to control the line spacing (hmm, not sure why that is),
    but you can derive a class from Fl_Button, and then handle the text drawing bit yourself,
    drawing each line where you want it with separarte fl_draw() calls to handle the text.

    Or, if it's a fixed message, you could just render the text as an image in a paint program
    and save it as an .xpm, then just #include the xpm and use it as the image() for the button..
    similar to how an xpm image is assigned to an Fl_Box in this demo:
    http://seriss.com/people/erco/fltk/#DraggableBoxes

    To assign an image you don't need to derive a class from Fl_Button, just assign the image()
    to it with e.g.

        #include "my_text.xpm"
        [..]
        static Fl_Pixmap my_text_pixmap(my_text);
        Fl_Button *but = new Fl_Button(..);
        but->image(my_text_pixmap);

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/81be6be2-404b-e3c4-fcbd-08f22198c9ed%40seriss.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.