1 ! Copyright (C) 2006, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel sequences colors fonts ui.gadgets
4 ui.gadgets.frames ui.gadgets.grids ui.gadgets.icons ui.gadgets.labels
5 ui.gadgets.borders ui.pens.image ;
8 TUPLE: labeled-gadget < frame content ;
12 CONSTANT: @center { 1 1 }
13 CONSTANT: @left { 0 1 }
14 CONSTANT: @right { 2 1 }
15 CONSTANT: @top { 1 0 }
16 CONSTANT: @bottom { 1 2 }
18 CONSTANT: @top-left { 0 0 }
19 CONSTANT: @top-right { 2 0 }
20 CONSTANT: @bottom-left { 0 2 }
21 CONSTANT: @bottom-right { 2 2 }
23 : labeled-image ( name -- image )
24 "labeled-block-" prepend theme-image ;
26 : labeled-icon ( name -- icon )
27 labeled-image <icon> ;
29 CONSTANT: labeled-title-background
37 : <labeled-title> ( gadget -- label )
39 [ labeled-title-background font-with-background ] change-font
41 "title-middle" labeled-image
42 <image-pen> t >>fill? >>interior ;
44 : /-FOO-\ ( title labeled -- labeled )
45 "title-left" labeled-icon @top-left grid-add
46 swap <labeled-title> @top grid-add
47 "title-right" labeled-icon @top-right grid-add ;
49 : |-----| ( gadget labeled -- labeled )
50 "left-edge" labeled-icon @left grid-add
51 swap [ >>content ] [ @center grid-add ] bi
52 "right-edge" labeled-icon @right grid-add ;
54 : \-----/ ( labeled -- labeled )
55 "bottom-left" labeled-icon @bottom-left grid-add
56 "bottom-middle" labeled-icon @bottom grid-add
57 "bottom-right" labeled-icon @bottom-right grid-add ;
59 M: labeled-gadget focusable-child* content>> ;
63 : <labeled-gadget> ( gadget title -- newgadget )
64 3 3 labeled-gadget new-frame