summaryrefslogtreecommitdiffstats
path: root/demos/bitmaps.tcl
blob: fa1cf476d2fbcc91d7a69b2430ab062cc4067ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# RCS: @(#) $Id: bitmaps.tcl,v 1.11 2006/11/30 02:41:38 treectrl Exp $

#
# Demo: Bitmaps
#
proc DemoBitmaps {} {

    set T [DemoList]

    #
    # Configure the treectrl widget
    #

    $T configure -showroot no -showbuttons no -showlines no \
	-selectmode browse -orient horizontal -wrap "5 items" \
	-showheader no -backgroundimage sky

    #
    # Create columns
    #

    $T column create -itembackground {gray90 {}} -tags C0

    #
    # Create elements
    #

    $T element create elemTxt text -fill [list $::SystemHighlightText {selected focus}]
    $T element create elemSelTxt rect -fill [list $::SystemHighlight {selected focus}] \
	-showfocus yes
    $T element create elemSelBmp rect -outline [list $::SystemHighlight {selected focus}] \
	-outlinewidth 4
    $T element create elemBmp bitmap \
	-foreground [list $::SystemHighlight {selected focus}] \
	-background linen \
	-bitmap {question {selected}}

    #
    # Create styles using the elements
    #

    set S [$T style create STYLE -orient vertical]
    $T style elements $S {elemSelBmp elemBmp elemSelTxt elemTxt}
    $T style layout $S elemSelBmp -union elemBmp \
	-ipadx 6 -ipady 6
    $T style layout $S elemBmp -pady {0 6} -expand we
    $T style layout $S elemSelTxt -union elemTxt -ipadx 2
    $T style layout $S elemTxt -expand we

    # Set default item style
    $T column configure C0 -itemstyle $S

    #
    # Create items and assign styles
    #

    set bitmapNames [list error gray75 gray50 gray25 gray12 hourglass info \
	questhead question warning]

    foreach name $bitmapNames {
	set I [$T item create]
#		$T item style set $I 0 $S
	$T item text $I C0 $name
	$T item element configure $I C0 elemBmp -bitmap $name
	$T item lastchild root $I
    }

    foreach name $bitmapNames {
	set I [$T item create]
	$T item style set $I C0 $S
	$T item text $I C0 $name
if 1 {
	$T item element configure $I C0 elemBmp -bitmap $name \
	    -foreground [list brown {}] \
	    -background {"" {}}
} else {
	$T item element configure $I C0 elemBmp -bitmap $name \
	    -foreground [list $::SystemHighlight {selected focus} brown {}] \
	    -background {"" {}}
}
	$T item lastchild root $I
    }

    return
}