NAME

Gtk2::Ex::TreeMaker - A short intro

SYNOPSIS

use Gtk2 -init;
use Gtk2::Ex::TreeMaker;

# Initialize the treemaker
my $treemaker = Gtk2::Ex::TreeMaker->new();

# Create the column names. The first columnname has to be 'Name'
my $column_names = [
   { ColumnName => 'Name' },
   { ColumnName => 'Nov-2003' }, { ColumnName => 'Dec-2003' }, 
   { ColumnName => 'Jan-2004' }, { ColumnName => 'Feb-2004' }
];

# Here is the set of relational records to be displayed
my $recordset = [
   ['Texas','Dallas','Fruits','Dec-2003','300'],
   ['Texas','Dallas','Veggies','Jan-2004','120'],
   ['Texas','Austin','Fruits','Nov-2003','310'],
   ['Texas','Austin','Veggies','Feb-2004','20']
];

# Set the column_names first
$treemaker->set_column_names($column_names);

# Now set the data_flat using the relational records
$treemaker->set_data_flat($recordset);


# Build the model

$treemaker->build_model;

# Create a root window to display the widget
my $window = Gtk2::Window->new;
$window->signal_connect(destroy => sub { Gtk2->main_quit; });

# Add the widget to the root window
$window->add($treemaker->get_widget());

$window->set_default_size(500, 300);
$window->show_all;
Gtk2->main;

DESCRIPTION

Write the story here

USER INTERACTION

May be some more details

METHODS

Gtk2::Ex::TreeMaker->new

Accepts no arguments. Just returns a reference to the object

Gtk2::Ex::TreeMaker->set_data_flat

Accepts and array of arrays as the argument. For example,

my $recordset = [
   ['Texas','Dallas','Fruits','Dec-2003','300'],
   ['Texas','Dallas','Veggies','Jan-2004','120'],
   ['Texas','Austin','Fruits','Nov-2003','310'],
   ['Texas','Austin','Veggies','Feb-2004','20']
];

Gtk2::Ex::TreeMaker->set_column_names

The argument is an array. Each element of the array is a hash. The hash uses 'ColumnName' as the key. For example,

my $column_names = [
   { ColumnName => 'Name' },
   { ColumnName => 'Nov-2003' }, { ColumnName => 'Dec-2003' }, 
   { ColumnName => 'Jan-2004' }, { ColumnName => 'Feb-2004' }
];

Gtk2::Ex::TreeMaker->build_model

This is the core recursive method that actually builds the tree.

Accepts no arguments. Returns nothing.

Gtk2::Ex::TreeMaker->get_widget

Returns the widget that you can later attach to a root window or any other container.

TODO

Here is a list of stuff that I plan to add to this module.

  • Do something when cells are edited

    Probably, provide a callback hook for a sub that can be called when cells are edited. This sub can be responsible for caching all the changes and then applying it back to source data when a "SAVE" button is pressed, for example.

  • Not all cells need to be editable

    Provide some kind of criteria to decide whether a cell should be editable or not.

  • Some cells may need to be "hyperlinked"

    Some of the cells may have to be made clickable (hyperlinks). When clicked, may be the cell can drop down a menu or lead you to another view. Provide a callback on click (or rightclick) on the cells.

AUTHOR

Ofey Aikon, <ofey_aikon@yahoo.com>

BUGS

Please report any bugs or feature requests to bug-gtk2-ex-recordsfilter@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2004 Ofey Aikon, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.