#  Copyright (c) 1996, Expert Interface Technologies
#  See the file "license.terms" for information on usage and
#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#  The file man.macros and some of the macros used by this file are
#  copyrighted: (c) 1990 The Regents of the University of California.
#               (c) 1994-1995 Sun Microsystems, Inc.
#  The license terms of the Tcl/Tk distribution are in the file
#  license.tcl.

## TO CHECK:
##
## callback:  checked for defined of code ref (compare -edit*cmd)
##
## option
##	formatcmd  mentions format method but there is no format
##		   method documented
##
## methods:
## 	bdtype:    what is it? no description given
##	see:	   not documented? Not implemented??
##
## todo:	missing peaces marked by ????

=head1 NAME

Tk::TixGrid - Create and manipulate Tix Grid widgets

=for pm TixGrid/TixGrid.pm

=for category Tix Extensions

=head1 SYNOPSIS

S<    >I<$tixgrid> = I<$parent>->B<TixGrid>?(I<options>)?;

    The port of C code and bindings is done but needs
    debugging.  THERE ARE KNOWN BUGS. Work in progress ...

=head1 STANDARD OPTIONS

B<-background>
	B<-borderwidth>
	B<-cursor>
	B<-font>
	B<-foreground>
	B<-height>
	B<-highlightbackground>
	B<-highlightcolor>
	B<-highlightthickness>
	B<-padx>
	B<-pady>
	B<-relief>
	B<-selectbackground>
	B<-selectborderwidth>
	B<-selectforeground>
	B<-state>
	B<-takefocus>
	B<-width>
	B<-xscrollcommand>
	B<-yscrollcommand>

See L<Tk::options> for details of the standard options.

=head1 WIDGET-SPECIFIC OPTIONS

=over 4

=item Name:	B<browseCmd>

=item Class:	B<BrowseCmd>

=item Switch:	B<-browsecmd>

?docu here?  Not in configure output but used in bindings ??!!

If defined, gives a perl/Tk L<callback|Tk::callbacks>
to be executed when the
user browses a grid cell (This is normally the case when
the user clicks on an entry).  When this callback is called, it is
passed with two additional parameters: I<x> I<y>, where (I<x>,I<y>)
is the location of the cell that has just been clicked.

=item Name:	B<Command>

=item Class:	B<Command>

=item Switch:	B<-command>

?docu here?  Not in configure output but used in bindings ??!!

=item Name:	B<editDoneCmd>

=item Class:	B<EditDoneCmd>

=item Switch:	B<-editdonecmd>

If defined, gives a perl/Tk L<callback|Tk::callbacks>
to be executed when the
user has edited grid cell. When this callback is called, it is
passed with two additional parameters: I<x> I<y>, where (I<x>,I<y>)
is the location of the cell that has just been edited.

=item Name:	B<editNotifyCmd>

=item Class:	B<EditNotifyCmd>

=item Switch:	B<-editnotifycmd>

If defined gives a perl/Tk L<callback|Tk::callbacks>
to be executed when the user tries to edit a grid cell.
When this callback is called, it is passed with two additional
parameters: I<x> I<y>, where (I<x>,I<y>,) is the location
of the cell. This callback should return a boolean value: B<true>
indicates that the cell is editable and B<false> otherwise.

=item Name:	B<FloatingCols>

=item Class:	B<floatingCols>

=item Switch:	B<-floatingcols>

Defines the number of columns that fixed when the widget
is horizontally scrolled.  These column(s)
can be used as label(s) for the column(s).  The floating column(s)
can be configured in the B<-formatcmd> callback with the
B<formatBorder> method.  The default value is 0.

=item Name:	B<FloatingRows>

=item Class:	B<floatingRows>

=item Switch:	B<-floatingrows>

Defines the number of rows that are fixed when the widget
is vertically scrolled.  These row(s)
can be used as label(s) for the row(s).  The floating row(s)
can be configured in the B<-formatcmd> callback with the
B<formatBorder> method.  The default value is 0.

=item Name:	B<formatCmd>

=item Class:	B<FormatCmd>

=item Switch:	B<-formatcmd>

If defined, gives a perl/Tk L<callback|Tk::callbacks> to be
executed when the grid cells need to be formatted on the screen.
Normally, this callback calls the B<format> method (see below).
When this callback is called, it is passed with five additional
parameters: I<type> I<x1> I<y1> I<x2> I<y2>. I<type> gives the
logical type of the region in the grid. It may be one of the
following.

=over 8

=item B<x-region>

the horizontal margin

=item B<y-region>

the vertical margin

=item B<s-region>

the area where the horizontal and vertical margins are joined

=item B<main>

all the cells that do not fall into the above three types

=back

I<x1> I<y1> I<x2> I<y2> gives the extent of the region that needs
formatting.

=item Name:	B<leftMargin>

=item Class:	B<LeftMargin>

=item Switch:	B<-leftmargin>

In the number of cells, gives the width of vertical margin.
A zero indicates that no vertical should be drawn.

=item Name:	B<itemType>

=item Class:	B<ItemType>

=item Switch:	B<-itemtype>

?docu here?

=item Name:	B<selectMode>

=item Class:	B<SelectMode>

=item Switch:	B<-selectmode>

Specifies one of several styles for manipulating the selection.
The value of the option may be arbitrary, but the default bindings
expect it to be either B<single>, B<browse>, B<multiple>, or B<extended>;
the default value is B<single>.

=item Name:	B<selectUnit>

=item Class:	B<SelectUnit>

=item Switch:	B<-selectunit>

Specifies the selection unit. Valid values are B<cell>, B<column> or B<row>.

=item Name:	B<sizeCmd>

=item Class:	B<SizeCmd>

=item Switch:	B<-sizecmd>

?docu here?

=item Name:	B<topMargin>

=item Class:	B<TopMargin>

=item Switch:	B<-topmargin>

In the number of cells, gives the height of horizontal margin.
A zero indicates that no horizontal should be drawn.

=back

=head1 DESCRIPTION

The B<TixGrid> method creates a TixGrid new window and returns a
blessed reference of this TixGrid widget.
Additional options,
described above, may be specified on the command line or in the
option database to configure aspects of the B<TixGrid> widget
such as its cursor and relief.

A Grid widget displays its contents in a two dimensional grid of cells.
Each cell may contain one Tix display item, which may be in text,
graphics or other formats. See L<Tk::DItem> for more information
about Tix display items. Individual cells, or groups of cells,
can be formatted with a wide range of attributes, such as its color,
relief and border.

=head1 WIDGET METHODS

The B<TixGrid> method creates a TixGrid widget and returns a blessed
reference of this TixGrid widget.  This reference may be used to
invoke various operations on the widget.  It has the following general
form:

S<    >I<$tixgrid>->B<method>?(I<arg, arg, ...>)?

I<arg>s determine the exact behavior of the method. The following
methods are possible for B<TixGrid> widgets:

=over 4

=item I<$tixgrid>->B<anchor>(I<action>, I<x>, I<y>)

=item I<$tixgrid>->B<anchor>I<Action>(I<x>, I<y>)

Manipulates the B<anchor cell> of the B<TixGrid> widget.
The anchor cell is the end of the selection that is fixed
while the user is dragging out a selection with the mouse.
I<Action> can be B<clear>, B<get> or B<set>.  If I<action>
is B<clear>, I<x> and I<y> args are not accepted.

=item I<$tixgrid>->B<bdtype>(I<x>, I<y> ?,I<xbdWidth>, I<ybdWidth>?)

????

=item I<$tixgrid>->B<cget>('I<-option>')

Returns the current value of the configuration option given
by I<-option>. I<-option> may have any of the values accepted
by the B<TixGrid> constructor method.

=item I<$tixgrid>->B<configure>(?I<-option>??=>I<value>, I<-option>=>I<value>, I<...>?)

Query or modify the configuration options of the widget.
If no I<-option> is specified, returns a list describing all
of the available options for I<$tixgrid> (see B<Tk_ConfigureInfo>
for information on the format of this list.) If I<-option> is
specified with no I<value>, then the method returns a list describing
the one named option (this list will be identical to the corresponding
sublist of the value returned if no I<-option> is specified).
If one or more I<option-value> pairs are specified, then the
method modifies the given widget option(s) to have the given value(s);
in this case the method returns an empty string. I<-option> may have
any of the values accepted by the B<TixGrid> constructor method.

=item I<$tixgrid>->B<delete>(I<dim>, I<from>?, I<to>?)

=item I<$tixgrid>->B<deleteColumn>(I<from>?, I<to>?)

=item I<$tixgrid>->B<deleteRow>(I<from>?, I<to>?)

I<Dim> may be B<row> or B<column>. If I<to> is not given,
deletes a single row (or column) at the position I<from>.
If I<to> is given, deletes the range of rows (or columns)
from position I<from> through I<to>.

=item I<$tixgrid>->B<dragsite>(I<option>, I<x>, I<y>)

?docu here? not implemented :-(

=item I<$tixgrid>->B<dropsite>(I<option>, I<x>, I<y>)

?docu here? not implemented :-(

=item I<$tixgrid>->B<editApply>

If any cell is being edited, de-highlight the cell and
applies the changes.

=item I<$tixgrid>->B<editSet>(I<x>, I<y>)

Highlights the cell at (I<x>,I<y>) for editing,
if the B<-editnotify> callback returns true for this cell.

=item I<$tixgrid>->B<entrycget>(I<x>, I<y>, 'I<-option>')

Returns the current value of the configuration option given by
I<-option> of the cell at (I<x>,I<y>).  I<-option> may have any
of the values accepted by the B<set> method.

=item I<$tixgrid>->B<entryconfigure>(I<x>, I<y>?, I<-option>??=>I<value>, I<-option>=>I<value>, I<...>?)

Query or modify the configuration options of the cell at (I<x>,I<y>).
If no I<-option> is specified, returns a list describing all of the
available options for the cell (see B<Tk_ConfigureInfo> for information
on the format of this list.)  If I<-option> is specified with no
I<value>, then the method returns a list describing the one named
option (this list will be identical to the corresponding sublist
of the value returned if no I<-option> is specified.) If one or
more I<option-value> pairs are specified, then the method modifies
the given widget option(s) to have the given value(s); in this case
the method returns an empty string.  I<Option> may have any of the
values accepted by the B<set> method.

=item I<$tixgrid>->B<format>(I<option>, ?I<args>, ...?)

=item I<$tixgrid>->B<formatBorder>(I<x1,y1>, I<x2,y2>, I<options>);

=item I<$tixgrid>->B<formatGrid>(I<x1,y1>, I<x2,y2>, I<options>);

the B<format> method can only be called by the B<-formatcmd> callback
of the tixGrid widget.

?docu complete?

=item I<$tixgrid>->B<geometryinfo>(?I<width>, ?I<height>, ...?)

?docu here?  Return a list of 4 floats! Currently "{first1 last1} {first2,last2}" :-(

=item I<$tixgrid>->B<index>(I<$coordx>, I<$coordy>)

?docu here?

retuns I<(nx, ny)> of entry at position (I<$coordx>, I<$coordy>).
(??widget or screen offset??)

=item I<$tixgrid>->B<info>(I<option>, ?I<args>, ...?)

?docu here?

=item I<$tixgrid>->B<move>(I<dim>, I<from>, I<to>, I<offset>)

=item I<$tixgrid>->B<moveColumn>(I<from>, I<to>, I<offset>)

=item I<$tixgrid>->B<moveRow>(I<from>, I<to>, I<offset>)

I<Dim> may be B<row> or B<column>. Moves the range of rows
(or columns) from position I<from> through I<to> by the distance
indicated by I<offset>. For example,
I<$tixgrid>->B<moveRow>(B<2>, B<4>, B<1>) moves the rows 2,3,4
to rows 3,4,5.

=item I<$tixgrid>->B<nearest>(I<x>, I<y>)

?docu here?  screen pos (pixels) to entry (nx,ny) translation.

=item I<$tixgrid>->B<selection>(I<option>, I<x1>, I<y1> ?,I<x2>, I<y2>?)

=item I<$tixgrid>->B<selection>I<Option>(I<x1>, I<y1> ?,I<x2>, I<y2>?)

Option one of: B<adjust>, B<clear>, B<includes>, B<set>, and B<toggle>.

x1 (y1) has not to be greater than x2 (y2), but only x2 and y2 can be 'max'.

BUG: I<selection includes>: has no visible effect (as in Tix). Eh???

BUG: I<selection clear>: only works for 0, 0, max, max (as in Tix). Eh???

When I<x2, y2> are not given they default to I<x1, y1>, respectively.

=over 8

=item I<$tixgrid>->B<selectionAdjust>(I<x1>, I<y1> ?,I<x2>, I<y2>?)

?docu here?

=item I<$tixgrid>->B<selectionClear>(I<x1>, I<y1> ?,I<x2>, I<y2>?)

?docu here?

=item I<$tixgrid>->B<selectionIncludes>(I<x1>, I<y1> ?,I<x2>, I<y2>?)

?docu here?

=item I<$tixgrid>->B<selectionSet>(I<x1>, I<y1> ?,I<x2>, I<y2>?)

?docu here?

=item I<$tixgrid>->B<selectionToggle>(I<x1>, I<y1> ?,I<x2>, I<y2>?)

?docu here?

=back

=item I<$tixgrid>->B<set>(I<x>, I<y>?, B<-itemtype>=>I<type>??, I<-option>=>I<value>, I<...>?)

Creates a new display item at the cell at (I<x>,I<y>). The optional
B<-itemtype> parameter gives the type of the display item.
An additional list of I<option-value> pairs specify options
of the display item. If a display item already exists at this cell,
the old item will be deleted automatically.

=item I<$tixgrid>->B<size>(I<dim>, I<index>?, I<-option>??=>I<value>, I<...>?)

=item I<$tixgrid>->B<sizeColumn>(I<index>?, I<-option>??=>I<value>, I<...>?)

=item I<$tixgrid>->B<sizeRow>(I<index>?, I<-option>??=>I<value>, I<...>?)

Queries or sets the size of the row or column given by I<dim> and
I<index>. I<Dim> may be B<row> or B<column>.  I<Index> may be any
non-negative integer that gives the position of a given row (or column).
I<Index> can also be the string B<default>; in this case, this method
queries or sets the default size of all rows (or columns).
When no I<option-value> pair is given, this method returns
a list containing the current size setting of the given row (or column).
When I<option-value> pairs are given, the corresponding options
of the size setting of the given row are changed. I<-option> may be
one of the following:

=over 8

=item B<-pad0> => I<pixels>

Specifies the paddings to the left of a column or the top of a row.

=item B<-pad1> => I<pixels>

Specifies the paddings to the right of a column or the bottom of a row.

=item B<-size> => I<val>

Specifies the width of a column or the height of a row.
I<Val> may be: B<auto> -- the width of the column is set
the widest cell in the column; a valid Tk screen distance
unit (see B<Tk_GetPixels>); or a real number following by the
word B<chars> (e.g. B<3.4chars>) that sets the width of the
column to the given number of characters.

=back

=item I<$tixgrid>->B<sort>(I<dimension>, I<start>, I<end>, ?I<args ...>?)

?docu here? (not supported on Win* OSs up to now)

=item I<$tixgrid>->B<unset>(I<x>, I<y>)

Clears the cell at (I<x>,I<y>) by removing its display item.

=item I<$tixgrid>->B<xview>

?docu here?

=item I<$tixgrid>->B<yview>

?docu here?

=back

=head1 BINDINGS

to be done.

=head1 SEE ALSO

L<Tk::DItem|Tk::DItem>
L<Tk::callbacks|Tk::callbacks>
L<Tk::FloatEntry|Tk::FloatEntry>

=head1 BUGS

C code and bindings of TixGrid have some bugs.

=head1 KEYWORDS

tix, tixgrid, table, display item, spreadsheet

=cut

