column widths (string widths to pixels) Fl_Browser?

15 views
Skip to first unread message

Svets

unread,
Jul 17, 2016, 5:09:33 AM7/17/16
to fltk.general
I'm having an issue working out column widths in Fl_Browser using the Fl_Browser::column_widths(static int arr[]) method?

The column widths are read in terms of pixels but my strings (which I'm measuring the column widths from) are font sized 12 in fixed widths fonts.

Is there any way to convert these to pixels so I can accurately work out the column widths for each string in the header row in my Fl_Browser?


Also,, is there any option to wrap text in the Fl_Browser so all my text will fit withing a narrower set of columns?  


Thanks


Greg Ercolano

unread,
Jul 17, 2016, 9:49:51 AM7/17/16
to fltkg...@googlegroups.com
On 07/17/16 02:09, Svets wrote:
The column widths are read in terms of pixels but my strings (which I'm measuring the column widths from) are font sized 12 in fixed widths fonts.

Is there any way to convert these to pixels so I can accurately work out the column widths for each string in the header row in my Fl_Browser?

    In the FLTK docs, see the section "Drawing Things In FLTK", and under that, the section "Drawing Text"
    There you'll find two functions to measure text: fl_width() and fl_text_extents()


Also,, is there any option to wrap text in the Fl_Browser so all my text will fit withing a narrower set of columns? 

    No, I don't think there's autowrap in Fl_Browser. You could maybe do it yourself, but that'd look
    weird though, because then line heights wouldn't be consistent.

    Better to just (a) make the widths right if you can, and (b) allow the user to slide the Fl_Browser column widths
    around, and let the text clip off. See "Extend Fl_Browser to have interactively resizable columns" on my cheat page
    for how to do that.

Reply all
Reply to author
Forward
0 new messages