1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors colors combinators combinators.smart formatting
4 kernel literals math math.functions models sorting.human
5 sorting.slots strings ui ui.gadgets.scrollers
6 ui.gadgets.search-tables ui.gadgets.tables ;
9 ! ui.gadgets.tables demo
10 SINGLETON: color-renderer
14 CONSTANT: full-block-string $[ 10 CHAR: full-block <string> ]
18 M: color-renderer filled-column
21 M: color-renderer column-titles
22 drop { "Color" "Name" "Red" "Green" "Blue" "Hex" } ;
24 M: color-renderer row-columns
26 full-block-string swap
28 [ red>> "%.5f" sprintf ]
29 [ green>> "%.5f" sprintf ]
30 [ blue>> "%.5f" sprintf ]
35 M: color-renderer row-color
38 M: color-renderer row-value
41 : <color-table> ( -- table )
42 named-colors { humani<=> } sort-by <model>
44 [ ] <search-table> dup table>>
46 COLOR: dark-gray >>column-line-color
50 MAIN-WINDOW: color-table-demo { { title "Colors" } { pref-dim { 500 300 } } }
51 <color-table> <scroller> >>gadgets ;