Re: [fltk.general] FL_Table?

30 views
Skip to first unread message

Greg Ercolano

unread,
Jul 25, 2013, 12:18:19 PM7/25/13
to fltkg...@googlegroups.com
On 07/24/13 23:36, domonic Thomson wrote:
> I know this is very general, but is there any easy way to understand FL_Table?
> I'm trying to create a basic table (using the Simple Table code from the examples) but it seems extremely complicated.
>
> Is there an alternative explanation out there?

Hmm, OK, Fl_Table is an unsual widget in that all drawing of what's in it
is up to your code that you supply in your draw_cell() callback.

Fl_Table manages where all the cells are (for scrolling and interactive
column/row sizing), and whenever the table wants to redraw itself,
it calls the draw_cell() method for each cell, passing it the xywh
of the cell (the position and size) and the row/column number. It's
up to your code to take the row/col number and turn that into something
to be displayed in the xywh area, which you're supposed to draw into it
with the FLTK drawing functions.

The switch() statement handles context for the cell:

> some cells appear in the header of the table and should be drawn
slightly differently depending on how you want the headers to look.
In that case the context will be CONTEXT_ROW_HEADER or CONTEXT_COL_HEADER,
so your switch statement code should use whatever draw functions
you want to draw the cells in the header.

> some cells in the table are just regular cells. In that case,
the context will be CONTEXT_CELL, so your draw code should handle that
just a bit differently, so that you're drawing cell data, not header data.

> There's other contexts such as CONTEXT_STARTPAGE that you can either
use or ignore; it's invoked when the table is about to start redrawing itself.
(sometimes you might want to, for instance, take a snapshot of a database
so that you have a cached copy of the data you want to display in the table)

Hope that helps.

Fl_Table is unusual in that it leaves most of the drawing of the widget
up to you (the cell headers and cell data). While this means you have to
understand how to draw boxes and text, it gives you a lot of control about
how the data is displayed, allowing you to get as efficient as you want about
how table data is memory managed and drawn.

Reply all
Reply to author
Forward
0 new messages