Wednesday, February 02, 2005

Gtk2::Ex::TreeMaker

Gtk2::Ex::TreeMaker - A high level widget to represent a set of relational records in a hierarchical spreadsheet kinda display. This task is typical to most of the business application user interfaces.

Description
Typically in business applications, users like to view data in a spreadsheet kind of display. (Columns represent timeline (typically) and rows represent measures like sales/inventory/blah/blah).

The data itself is typically stored internally as relational records. For example, here is some sales info (stored internally in a relational database)

-------------------------------------

Region, City, Product, Date, Quantity
-------------------------------------
Texas, Dallas, Fruits, Dec-2003, 300
Texas, Dallas, Veggies, Jan-2004, 120
Texas, Austin, Fruits, Nov-2003, 310
Texas, Austin, Veggies, Feb-2004, 20
-------------------------------------

The user will typically want to view the same data in a hierarchical (/spreadsheet) kinda display.

------------------------------------------------------

Prod / Date Nov-2003 Dec-2003 Jan-2004 Feb-2004
------------------------------------------------------
Texas
Dallas
Fruits 300
Veggies 120
Austin
Fruits 310
Veggies 20
------------------------------------------------------

With web-based business apps, similar views are created in the browser using lots of html/jsp coding.

The Gtk2::TreeView is an excellent widget to display a similar presentation of data in a desktop app. But creating a (hierarchical) TreeView from flat relational data can require some recursive function coding. It would be great if all this recursive code could be abstracted out and packaged separately.

This high level widget is designed with that purpose in mind. This module will accept a relational feed of records and automatically convert it into a hierarchical treeview using the Gtk2::TreeView. The process involves invoking some recursive functions to build a TreeModel and populate it. Also, since the spreadsheet itself can be rather long horizontally, the widget also has a FreezePane capability.


The above screenshot was generated using the following relational data (csv)
__DATA__

#state,city,product,date,text,editable,underline,background
Texas,Dallas,Fruits,Dec-2003,300,0,1,red
Texas,Dallas,Veggies,Jan-2004,120,1,0,blue
Texas,Austin,Fruits,Nov-2003,310,1,0,white
Texas,Austin,Veggies,Feb-2004,20,0,1,red
Texas,Austin,Veggies,Jun-2004,80,0,0,red
California,LA,Veggies,Jun-2004,80,1,0,brown

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?