home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _7a9349d71c0cfa12afdab4162236c684 < prev    next >
Encoding:
Text File  |  2004-06-01  |  16.3 KB  |  540 lines

  1. #  Copyright (c) 1996, Expert Interface Technologies
  2. #  See the file "license.terms" for information on usage and
  3. #  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  4. #  The file man.macros and some of the macros used by this file are
  5. #  copyrighted: (c) 1990 The Regents of the University of California.
  6. #               (c) 1994-1995 Sun Microsystems, Inc.
  7. #  The license terms of the Tcl/Tk distribution are in the file
  8. #  license.tcl.
  9.  
  10. ## TO CHECK:
  11. ##
  12. ## callback:  checked for defined of code ref (compare -edit*cmd)
  13. ##
  14. ## option
  15. ##    formatcmd  mentions format method but there is no format
  16. ##           method documented
  17. ##
  18. ## methods:
  19. ##     bdtype:    what is it? no description given
  20. ##    see:       not documented? Not implemented??
  21. ##
  22. ## todo:    missing peaces marked by ????
  23.  
  24. =head1 NAME
  25.  
  26. Tk::TixGrid - Create and manipulate Tix Grid widgets
  27.  
  28. =for pm TixGrid/TixGrid.pm
  29.  
  30. =for category Tix Extensions
  31.  
  32. =head1 SYNOPSIS
  33.  
  34. S<    >I<$tixgrid> = I<$parent>->B<TixGrid>?(I<options>)?;
  35.  
  36. =head1 DESCRIPTION
  37.  
  38. This widget is intended as the basis of "spread sheet" like interfaces.
  39. The widget displays its contents in a two dimensional "grid" of cells.
  40. Each cell may contain one Tix display item, which may be in text,
  41. graphics or other formats. See L<Tk::DItem> for more information
  42. about Tix display items. Because these "items" need not be "windows" large
  43. grids can be handled  without consuming excessive display system resources.
  44.  
  45. Individual cells, or groups of cells, can be formatted with a wide range of
  46. attributes, such as its color, relief and border. However because the
  47. widget is intended to handle large grids the mechanisms to achieve these
  48. are lower level, and more callback oriented than for other widgets. The
  49. assumption is that to avoid storing display details of a large number
  50. of cells, the data will be re-computed as needed.
  51.  
  52. The port of Tix C code and some of the bindings to perl/Tk is done but still
  53. need further work. In several places the intent of the Tix code is not
  54. yet understood. For example the 'edit' interface is clearly intended
  55. for spread-sheet like cell content editing in an auxillary "entry" widget
  56. or similar, but how that should work is not yet clear.
  57.  
  58. The B<TixGrid> method creates a new TixGrid window and returns a
  59. blessed reference of this TixGrid widget.  Additional options,
  60. described below, may be specified on the command line or in the
  61. option database to configure aspects of the B<TixGrid> widget.
  62.  
  63. =head1 STANDARD OPTIONS
  64.  
  65. B<-background>
  66.     B<-borderwidth>
  67.     B<-cursor>
  68.     B<-font>
  69.     B<-foreground>
  70.     B<-height>
  71.     B<-highlightbackground>
  72.     B<-highlightcolor>
  73.     B<-highlightthickness>
  74.     B<-padx>
  75.     B<-pady>
  76.     B<-relief>
  77.     B<-selectbackground>
  78.     B<-selectborderwidth>
  79.     B<-selectforeground>
  80.     B<-state>
  81.     B<-takefocus>
  82.     B<-width>
  83.     B<-xscrollcommand>
  84.     B<-yscrollcommand>
  85.  
  86. See L<Tk::options> for details of the standard options.
  87.  
  88. =head1 WIDGET-SPECIFIC OPTIONS
  89.  
  90. =over 4
  91.  
  92. =item Name:    B<browseCmd>
  93.  
  94. =item Class:    B<BrowseCmd>
  95.  
  96. =item Switch:    B<-browsecmd>
  97.  
  98. If defined, gives a perl/Tk L<callback|Tk::callbacks> to be executed when the
  99. user browses a grid cell (This is normally the case when the user clicks on an
  100. entry).  When this callback is called, it is passed with two additional
  101. parameters: I<x> I<y>, where (I<x>,I<y>) is the location of the cell that has
  102. just been clicked.
  103.  
  104. =item Name:    B<Command>
  105.  
  106. =item Class:    B<Command>
  107.  
  108. =item Switch:    B<-command>
  109.  
  110. If defined, gives a perl/Tk L<callback|Tk::callbacks> to be executed when the
  111. user double-clicks a grid cell.  When this callback is called, it is passed
  112. with two additional parameters: I<x> I<y>, where (I<x>,I<y>) is the location of
  113. the cell that has just been clicked.
  114.  
  115. =item Name:    B<editDoneCmd>
  116.  
  117. =item Class:    B<EditDoneCmd>
  118.  
  119. =item Switch:    B<-editdonecmd>
  120.  
  121. If defined, gives a perl/Tk L<callback|Tk::callbacks>
  122. to be executed when the
  123. user has edited grid cell. When this callback is called, it is
  124. passed with two additional parameters: I<x> I<y>, where (I<x>,I<y>)
  125. is the location of the cell that has just been edited.
  126.  
  127. =item Name:    B<editNotifyCmd>
  128.  
  129. =item Class:    B<EditNotifyCmd>
  130.  
  131. =item Switch:    B<-editnotifycmd>
  132.  
  133. If defined gives a perl/Tk L<callback|Tk::callbacks>
  134. to be executed when the user tries to edit a grid cell.
  135. When this callback is called, it is passed with two additional
  136. parameters: I<x> I<y>, where (I<x>,I<y>,) is the location
  137. of the cell. This callback should return a boolean value: B<true>
  138. indicates that the cell is editable and B<false> otherwise.
  139.  
  140. =item Name:    B<FloatingCols>
  141.  
  142. =item Class:    B<floatingCols>
  143.  
  144. =item Switch:    B<-floatingcols>
  145.  
  146. Defines the number of extra columns beyond the existing grid
  147. that can be brought into view by scrolling.
  148.  
  149. =item Name:    B<FloatingRows>
  150.  
  151. =item Class:    B<floatingRows>
  152.  
  153. =item Switch:    B<-floatingrows>
  154.  
  155. Defines the number of extra rows beyond the the existing grid
  156. that can be brought into view by scrolling.
  157.  
  158. =item Name:    B<formatCmd>
  159.  
  160. =item Class:    B<FormatCmd>
  161.  
  162. =item Switch:    B<-formatcmd>
  163.  
  164. If defined, gives a perl/Tk L<callback|Tk::callbacks> to be
  165. executed when the grid cells need to be displayed on the screen.
  166. Its primary purpose is to draw the background of the region
  167. before the cells are rendered on top. This is normally
  168. achieved by calling B<formatGrid> or B<formatBorder> (see below).
  169. However other uses can  be made of this low-level callback. For example it can be used
  170. to "lazily" populate the grid by calling the B<set> method only as cells come
  171. into view.
  172.  
  173. When this callback is called, it is passed with five additional
  174. parameters: I<type> I<x1> I<y1> I<x2> I<y2>.
  175.  
  176. I<x1> I<y1> I<x2> I<y2> gives the extent of the region that needs
  177. formatting.
  178.  
  179. I<type> gives the logical type of the region in the grid. It may be one of the
  180. following.
  181.  
  182. =over 8
  183.  
  184. =item B<x_region>
  185.  
  186. The horizontal margin.
  187.  
  188. =item B<y_region>
  189.  
  190. The vertical margin.
  191.  
  192. =item B<s_region>
  193.  
  194. The area in the top left corner where the horizontal and vertical margins
  195. are joined.
  196.  
  197. =item B<main>
  198.  
  199. The main body i.e. all the cells that do not fall into the above three types.
  200.  
  201. =back
  202.  
  203. =item Name:    B<leftMargin>
  204.  
  205. =item Class:    B<LeftMargin>
  206.  
  207. =item Switch:    B<-leftmargin>
  208.  
  209. Gives the width of vertical margin in cells (columns).
  210. A zero indicates that no vertical margin exists. A positive value I<N>
  211. indicates that first I<N> columns are "labels" and are always displayed
  212. and not scrolled.
  213.  
  214. =item Name:    B<itemType>
  215.  
  216. =item Class:    B<ItemType>
  217.  
  218. =item Switch:    B<-itemtype>
  219.  
  220. Default item type for cells.
  221.  
  222. =item Name:    B<selectMode>
  223.  
  224. =item Class:    B<SelectMode>
  225.  
  226. =item Switch:    B<-selectmode>
  227.  
  228. Specifies one of several styles for manipulating the selection.
  229. The value of the option may be arbitrary, but the default bindings
  230. expect it to be either B<single>, B<browse>, B<multiple>, or B<extended>;
  231. the default value is B<single>.
  232.  
  233. =item Name:    B<selectUnit>
  234.  
  235. =item Class:    B<SelectUnit>
  236.  
  237. =item Switch:    B<-selectunit>
  238.  
  239. Specifies the selection unit. Valid values are B<cell>, B<column> or B<row>.
  240.  
  241. =item Name:    B<sizeCmd>
  242.  
  243. =item Class:    B<SizeCmd>
  244.  
  245. =item Switch:    B<-sizecmd>
  246.  
  247. Callback is called (with no extra arguments) when grid sizes are
  248. re-computed. For example if window changes size, a different font
  249. is specified etc.
  250.  
  251. It is called just after scrollbars (if present) are updated.
  252.  
  253. =item Name:    B<topMargin>
  254.  
  255. =item Class:    B<TopMargin>
  256.  
  257. =item Switch:    B<-topmargin>
  258.  
  259. Gives the width of horizontal margin in cells (rows).
  260. A zero indicates that no horizontal margin exists. A positive value
  261. I<N> indicates that first I<N> rows are "labels" and are always
  262. displayed and not scrolled.
  263.  
  264. =back
  265.  
  266. =head1 WIDGET METHODS
  267.  
  268. The B<TixGrid> method creates a TixGrid widget and returns a blessed
  269. reference of this TixGrid widget.  This reference may be used to
  270. invoke various operations on the widget.  It has the following general
  271. form:
  272.  
  273. S<    >I<$tixgrid>->B<method>?(I<arg, arg, ...>)?
  274.  
  275. I<arg>s determine the exact behavior of the method.
  276.  
  277. This object supports the B<configure> and B<cget> methods
  278. described in L<Tk::options> which can be used to enquire and
  279. modify the options described above.
  280. The widget also inherits all the methods provided by the generic
  281. L<Tk::Widget|Tk::Widget> class.
  282.  
  283. The following additional methods are possible for B<TixGrid> widgets:
  284.  
  285. =over 4
  286.  
  287. =item I<$tixgrid>->B<anchorGet>(I<x>, I<y>)
  288.  
  289. =item I<$tixgrid>->B<anchorSet>(I<x>, I<y>)
  290.  
  291. =item I<$tixgrid>->B<anchorClear>
  292.  
  293. Manipulates the B<anchor cell> of the B<TixGrid> widget.
  294. The anchor cell is the end of the selection that is fixed
  295. while the user is dragging out a selection with the mouse.
  296.  
  297. =item ($bd,$col,$row) = I<$tixgrid>->B<bdtype>(I<x,y> ?,I<xDelta>,I<yDelta>?)
  298.  
  299. Determines if the the screen (pixel) position I<x,y> is in a border.
  300. This is useful for changing the mouse cursor when the user points at a
  301. border - e.g. to indicate that the border can be adjusted
  302. interactively.
  303.  
  304. If in a border returns a list of three elements. First element
  305. is 'xy', 'x' or 'y', second two elements are integers.
  306. (Value of these are not understood, seem to indicate which
  307. column and row of the border the screen position corresponds to?)
  308.  
  309. If not in a border returns an empty list.
  310.  
  311. =item I<$tixgrid>->B<delete>(I<dim>, I<from>?, I<to>?)
  312.  
  313. =item I<$tixgrid>->B<deleteColumn>(I<from>?, I<to>?)
  314.  
  315. =item I<$tixgrid>->B<deleteRow>(I<from>?, I<to>?)
  316.  
  317. I<Dim> may be B<row> or B<column>. If I<to> is not given,
  318. deletes a single row (or column) at the position I<from>.
  319. If I<to> is given, deletes the range of rows (or columns)
  320. from position I<from> through I<to>.
  321.  
  322. =item I<$tixgrid>->B<dragsite>(I<option>, I<x>, I<y>)
  323.  
  324. =item I<$tixgrid>->B<dropsite>(I<option>, I<x>, I<y>)
  325.  
  326. Tcl/Tix has (or was going to have) Drag&Drop support.
  327. Meaning for perl/Tk is not clear yet.
  328.  
  329. =item I<$tixgrid>->B<editApply>
  330.  
  331. If any cell is being edited, de-highlight the cell and
  332. applies the changes.
  333.  
  334. =item I<$tixgrid>->B<editSet>(I<x>, I<y>)
  335.  
  336. Highlights the cell at (I<x>,I<y>) for editing,
  337. if the B<-editnotify> callback returns true for this cell.
  338.  
  339. =item I<$tixgrid>->B<entrycget>(I<x>, I<y>, 'I<-option>')
  340.  
  341. =item I<$tixgrid>->B<entryconfigure>(I<x>, I<y>?, I<-option>??=>I<value>, I<-option>=>I<value>, I<...>?)
  342.  
  343. Provide a configue interface to cells in the grid.
  344. The I<-option>s depend on the item type of the cell.
  345.  
  346. =item I<$tixgrid>->B<formatBorder>(I<x1,y1>, I<x2,y2>, I<options>);
  347.  
  348. =item I<$tixgrid>->B<formatGrid>(I<x1,y1>, I<x2,y2>, I<options>);
  349.  
  350. The B<formatBorder> and B<formatBorder> methods can only be called by the
  351. B<-formatcmd> callback of the tixGrid widget. They draw the background of
  352. the region described by I<x1,y1>, I<x2,y2> according the the supplied
  353. I<options>. One call to B<-formatcmd> callback can make multiple
  354. calls to B<formatBorder> and/or B<formatBorder> for different
  355. sub-regions.
  356.  
  357. B<formatBorder> draws the background using Tk relief style,
  358. B<formatGrid> also draws grid lines between the cells.
  359. It only makes sense to call one or the other for a particular
  360. sub-region as one will over-write the other.
  361.  
  362. The options allowed are:
  363.  
  364. =over 8
  365.  
  366. =item -background / -bg
  367.  
  368. =item -borderwidth / -bd
  369.  
  370. =item -filled
  371.  
  372. =item -relief
  373.  
  374. =item -selectbackground
  375.  
  376. =item -xoff
  377.  
  378. =item -xon
  379.  
  380. =item -yoff
  381.  
  382. =item -yon
  383.  
  384. =back
  385.  
  386. The B<-xon/-xoff and -yon/-yoff> options are obscure. If anyone
  387. can figure out how to do something interesting given what
  388. F<pTk/tixGrFmt.c> is doing with them please let Nick know!.
  389.  
  390. =item I<$tixgrid>->B<geometryinfo>(?I<width>, I<height>?)
  391.  
  392. Returns list of four values - two sets of two floating point numbers.
  393. First set is the scrollbar fractions for x direction, second set
  394. is scrollbar fractions for y direction. If I<width> and I<height>
  395. are specified then fractions are based on as if window size was of
  396. specified size (in pixels, but not allowing normal GetPixels units).
  397. Otherwise fractions are based on current size of the window.
  398.  
  399. Usage obscure.
  400.  
  401. =item I<$tixgrid>->B<index>(I<xcoord>, I<ycoord>)
  402.  
  403. Retuns I<(x, y)> of entry at position (I<$coordx>, I<$coordy>).
  404. Either coordinate may be B<'max'> which is largest existing entry
  405. in that direction, B<'end'> which is one I<beyond> largest existing
  406. entry, or a number. (This is how you find out how big the grid is.)
  407.  
  408. =item I<$tixgrid>->B<infoBbox>(I<x>,I<y>)
  409.  
  410. Return the pixel bounding box of the cell at I<x,y>.
  411.  
  412. =item I<$tixgrid>->B<infoExists>(I<x>,I<y>)
  413.  
  414. Returns true if there is an item in the cell at I<x,y>.
  415. Throws an exception (dies) if I<x,y> is outside the
  416. grid - this may change (Nick doesn't like it).
  417.  
  418. =item I<$tixgrid>->B<move>(I<dim>, I<from>, I<to>, I<offset>)
  419.  
  420. =item I<$tixgrid>->B<moveColumn>(I<from>, I<to>, I<offset>)
  421.  
  422. =item I<$tixgrid>->B<moveRow>(I<from>, I<to>, I<offset>)
  423.  
  424. I<Dim> may be B<row> or B<column>. Moves the range of rows
  425. (or columns) from position I<from> through I<to> by the distance
  426. indicated by I<offset>. For example,
  427. I<$tixgrid>->B<moveRow>(B<2>, B<4>, B<1>) moves the rows 2,3,4
  428. to rows 3,4,5.
  429.  
  430. =item I<$tixgrid>->B<nearest>(I<x>, I<y>)
  431.  
  432. Screen pos (pixels) to entry (nx,ny) translation.
  433.  
  434. =item I<$tixgrid>->B<selectionAdjust>(I<x1>, I<y1> ?,I<x2>, I<y2>?)
  435.  
  436. =item I<$tixgrid>->B<selectionClear>(I<x1>, I<y1> ?,I<x2>, I<y2>?)
  437.  
  438. =item I<$tixgrid>->B<selectionIncludes>(I<x1>, I<y1> ?,I<x2>, I<y2>?)
  439.  
  440. =item I<$tixgrid>->B<selectionSet>(I<x1>, I<y1> ?,I<x2>, I<y2>?)
  441.  
  442. =item I<$tixgrid>->B<selectionToggle>(I<x1>, I<y1> ?,I<x2>, I<y2>?)
  443.  
  444. Selection support methods - probably buggy.
  445.  
  446. x1 (y1) has not to be greater than x2 (y2), but only x2 and y2 can be 'max'.
  447.  
  448. BUG: I<selectionIncludes>: has no visible effect (as in Tix). Eh???
  449.  
  450. BUG: I<selectionClear>: only works for 0, 0, max, max (as in Tix). Eh???
  451.  
  452. When I<x2, y2> are not given they default to I<x1, y1>, respectively.
  453.  
  454. =item I<$tixgrid>->B<set>(I<x>, I<y>?, B<-itemtype>=>I<type>??, I<-option>=>I<value>, I<...>?)
  455.  
  456. Creates a new display item at the cell at (I<x>,I<y>). The optional
  457. B<-itemtype> parameter gives the type of the display item.
  458. An additional list of I<option-value> pairs specify options
  459. of the display item. If a display item already exists at this cell,
  460. the old item will be deleted automatically.
  461.  
  462. =item I<$tixgrid>->B<size>(I<dim>, I<index>?, I<-option>??=>I<value>, I<...>?)
  463.  
  464. =item I<$tixgrid>->B<sizeColumn>(I<index>?, I<-option>??=>I<value>, I<...>?)
  465.  
  466. =item I<$tixgrid>->B<sizeRow>(I<index>?, I<-option>??=>I<value>, I<...>?)
  467.  
  468. Queries or sets the size of the row or column given by I<dim> and
  469. I<index>. I<Dim> may be B<row> or B<column>.  I<Index> may be any
  470. non-negative integer that gives the position of a given row (or column).
  471. I<Index> can also be the string B<default>; in this case, this method
  472. queries or sets the default size of all rows (or columns).
  473. When no I<option-value> pair is given, this method returns
  474. a list containing the current size setting of the given row (or column).
  475. When I<option-value> pairs are given, the corresponding options
  476. of the size setting of the given row are changed. I<-option> may be
  477. one of the following:
  478.  
  479. =over 8
  480.  
  481. =item B<-pad0> => I<pixels>
  482.  
  483. Specifies the paddings to the left of a column or the top of a row.
  484.  
  485. =item B<-pad1> => I<pixels>
  486.  
  487. Specifies the paddings to the right of a column or the bottom of a row.
  488.  
  489. =item B<-size> => I<val>
  490.  
  491. Specifies the width of a column or the height of a row.
  492. I<Val> may be: B<auto> -- the width of the column is set
  493. the widest cell in the column; a valid Tk screen distance
  494. unit (see B<Tk_GetPixels>); or a real number following by the
  495. word B<chars> (e.g. B<3.4chars>) that sets the width of the
  496. column to the given number of characters.
  497.  
  498. =back
  499.  
  500. =item I<$tixgrid>->B<sort>(I<dimension>, I<start>, I<end>, ?I<args ...>?)
  501.  
  502. ?docu here? (not supported on Win* OSs up to now)
  503.  
  504. =item I<$tixgrid>->B<unset>(I<x>, I<y>)
  505.  
  506. Clears the cell at (I<x>,I<y>) by removing its display item.
  507.  
  508. =item I<$tixgrid>->B<xview>
  509.  
  510. Normal horizontal scrollbar method.
  511.  
  512. =item I<$tixgrid>->B<yview>
  513.  
  514. Normal vertical scrollbar method.
  515.  
  516. =back
  517.  
  518. =head1 BINDINGS
  519.  
  520. To be done - only most obvious basic bindings work. The Tcl/Tix code
  521. was coded as a "state machine" which is not easy to follow.
  522.  
  523. =head1 SEE ALSO
  524.  
  525. L<Tk::DItem|Tk::DItem>
  526. L<Tk::callbacks|Tk::callbacks>
  527. L<Tk::FloatEntry|Tk::FloatEntry>
  528.  
  529. =head1 BUGS
  530.  
  531. Tcl/Tix was/is not finished and both C code and bindings of TixGrid
  532. have some bugs.
  533.  
  534. =head1 KEYWORDS
  535.  
  536. tix, tixgrid, table, display item, spreadsheet
  537.  
  538. =cut
  539.  
  540.