Tabular data widgets [design thoughts]




I've been doing a bit of thinking recently about one area where GTK is
lacking: widgets to display tabular data.

As examples of the kind of tasks that such widgets should be able to 
handle:

* Browsing a database with 100,000 records
* Displaying a spreadsheet with 100's of rows and columns
* Displaying a hierarchical list of data (think of Netscape News or
  the Win95 file dialog)

Clearly, no one widget is going to be able to allow all of these and
yet have decent performance and be easy to program with ... but I
think it might be possible to get substantial code re-use between
a set of widgets.

A few of the design parameters:

- Each cell can't be its own window or even its own widget for obvious
  performance reasons.

- For applications like the first two, the widget shouldn't need to
  store the contents of every row or cell. (Otherwise there would be a
  huge increase in memory usage and startup-time 

- Each cell should be able to display
   * a text string, clipped to the cell boundaries
   * a pixmap
   * an embedded widget

- Simple tasks should be able to be accomplished simply, but the
  design should allow for more advanced tasks to be done, and to be
  done efficiently.

I was thinking of a heirarchy of widgets like:

 GtkGrid
 +-- GtkRows (need a better name)
 |   \-- GtkHList
 \-- GtkSpreadsheet

Where:

GtkGrid
-------
It has code for drawing and scrolling a grid of cells with
optional row/column labels but does no storage and enforces very
little policy. When cells need to be drawn it emits a "draw_cells"
signal, and the descendent widget/application calls 
gtk_grid_draw_cell (grid, row, column, contents) for each affected
cell.

GtkRows
-------
A row-oriented descendent of GtkGrid. It more-or-less enforces the
policies of a multi-column listbox (selection, navigation, etc...)
but only stores the rows currently on the screen. When more rows
are needed it emits a "get_rows" signal, and the descendent widget/
application calls gtk_rows_set_row() for each row. 

GtkHList
--------
A full-fledged heirarchical list widget (probably pretty similar to
the Tix HList widget), supporting collapsing/expanding branches, etc.
Unlike the above widgets, it would actually store all the data
internally. (This class could be used for simple multi-column lists
when size isn't an issue)

GtkSpreadsheet
--------------
A descendent of GtkGrid specialized for displaying 2D data, with more
policy (and storage?) [ I don't have too clear an idea what is needed
here ]

Anyways, there is clearly an ambitious amount of work here, and I'm
not promising to write all of it, or even, in the immediate future,
most of it, but I wanted to air my design thoughts and get some
feedback on people's requirements (what capabilities are needed from
this sort of widget) and on the proposed design.

                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]