]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/tables/tables-docs.factor
81e5f0f77842a1782919c4981a07dff57dffa431
[factor.git] / basis / ui / gadgets / tables / tables-docs.factor
1 USING: help.markup help.syntax ui.commands kernel ;
2 IN: ui.gadgets.tables
3
4 ARTICLE: "ui.gadgets.tables.renderers" "Table row renderer protocol"
5 "Table gadgets use a row renderer to display rows and do a few other things."
6 $nl
7 "Renderers are usually instances of singleton classes, since they don't need any state of their own. Renderers are required to implement a single generic word:"
8 { $subsection row-columns }
9 "Renderers can also implement the following optional generic words for additional row information:"
10 { $subsection row-value }
11 { $subsection row-color }
12 "The following optional generic words allow the renderer to provide some information about the display of all rows:"
13 { $subsection prototype-row }
14 { $subsection column-alignment }
15 { $subsection filled-column }
16 { $subsection column-titles } ;
17
18 ARTICLE: "ui.gadgets.tables.selection" "Table row selection"
19 "A few slots in the table gadget concern row selection:"
20 { $table
21   { { $slot "selection" } { " - if set to a model, the values of the currently selected row or rows, as determined by a " { $link row-value } " call to the renderer, is stored in this model. See " { $link "models" } "." } }
22   { { $slot "selection-index" } { " - if set to a model, the indices of the currently selected rows." } }
23   { { $slot "selection-required?" } { " - if set to a true value, the table ensures that some row is always selected, if the model is non-empty. If set to " { $link f } ", a state where nothing is selected is permitted to occur. The default is " { $link f } "." } }
24   { { $slot "multiple-selection?" } { " - if set to a true value, users are allowed to select more than one value." } }
25 }
26 "Some words for row selection:"
27 { $subsection selected-rows }
28 { $subsection (selected-rows) }
29 { $subsection selected } ;
30
31 ARTICLE: "ui.gadgets.tables.actions" "Table row actions"
32 "When the user double-clicks on a row, or presses " { $command table "row" row-action } " while a row is selected, optional action and hook quotations are invoked. The action receives the row value and the hook receives the table gadget itself. These quotations are stored in the " { $slot "action" } " and " { $snippet "hook" } " slots of a table, respectively."
33 $nl
34 "If the " { $slot "single-click?" } " slot is set to a true value, then single-clicking on a row will invoke the row action. The default value is " { $link f } "."
35 $nl
36 "The row action can also be invoked programmatically:"
37 { $subsection row-action } ;
38
39 ARTICLE: "ui.gadgets.tables.config" "Table gadget configuration"
40 "Various slots in the table gadget can be set to change the appearance and behavior of the table gadget."
41 { $table
42   { { $slot "gap" } }
43   { { $slot "focus-border-color" } }
44   { { $slot "mouse-color" } }
45   { { $slot "column-line-color" } }
46   { { $slot "takes-focus?" } }
47 } ;
48
49 ARTICLE: "ui.gadgets.tables.example" "Table gadget example"
50 "The " { $vocab-link "color-table" } " vocabulary implements a simple application which demonstrates table gadgets. It lists all the colors in the " { $snippet "rgb.txt" } " database shipped with " { $vocab-link "colors.constants" } " in a table. Rows are highlighted with their actual color, and columns show the red, green, and blue components. Column titles are supplied." ;
51
52 ARTICLE: "ui.gadgets.tables" "Table gadgets"
53 "The " { $vocab-link "ui.gadgets.tables" } " vocabulary implements table gadgets. Table gadgets display a grid of values, with each row's columns generated by a renderer object."
54 $nl
55 "Tables display a model as a series of rows. The model must be a sequence, and a " { $emphasis "renderer" } " creates a sequence of columns for each row. Tables are built from and inherit all features of " { $link "ui.gadgets.line-support" } "."
56 { $command-map table "row" }
57 "The class of tables:"
58 { $subsection table }
59 { $subsection table? }
60 "Creating new tables:"
61 { $subsection <table> }
62 { $subsection "ui.gadgets.tables.renderers" }
63 { $subsection "ui.gadgets.tables.selection" }
64 { $subsection "ui.gadgets.tables.actions" }
65 { $subsection "ui.gadgets.tables.example" } ;
66
67 ABOUT: "ui.gadgets.tables"