summaryrefslogtreecommitdiffstats
path: root/demos/outlook-folders.tcl
blob: b9be739d134bc9a2579a3b6a96f79291a00338bd (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# RCS: @(#) $Id: outlook-folders.tcl,v 1.10 2005/07/11 01:59:07 treectrl Exp $

#
# Demo: Outlook Express folder list
#
proc DemoOutlookFolders {} {

	InitPics outlook-*

	set T .f2.f1.t

	set height [font metrics [$T cget -font] -linespace]
	if {$height < 18} {
		set height 18
	}

	#
	# Configure the treectrl widget
	#

	$T configure -itemheight $height -selectmode browse \
		-showroot yes -showrootbutton no -showbuttons yes -showlines $::ShowLines

	#
	# Create columns
	#

	$T column create -text Folders -tag C0
	$T configure -treecolumn C0

	#
	# Create elements
	#

	$T element create elemImgAny image
	$T element create elemTxtRead text -fill [list $::SystemHighlightText {selected focus}] \
		-lines 1
	$T element create elemTxtUnread text -fill [list $::SystemHighlightText {selected focus}] \
		-font [list "[$T cget -font] bold"] -lines 1
	$T element create elemTxtCount text -fill blue
	$T element create elemImgFolder image -image outlook-folder
	$T element create elemRectSel rect -fill [list $::SystemHighlight {selected focus} gray {selected !focus}] \
		-showfocus yes

	#
	# Create styles using the elements
	#

	# image + text
	set S [$T style create styAnyRead]
	$T style elements $S {elemRectSel elemImgAny elemTxtRead}
	$T style layout $S elemImgAny -expand ns
	$T style layout $S elemTxtRead -padx {4 0} -expand ns -squeeze x
	$T style layout $S elemRectSel -union [list elemTxtRead] -iexpand ns -ipadx 2

	# image + text + text
	set S [$T style create styAnyUnread]
	$T style elements $S {elemRectSel elemImgAny elemTxtUnread elemTxtCount}
	$T style layout $S elemImgAny -expand ns
	$T style layout $S elemTxtUnread -padx 4 -expand ns -squeeze x
	$T style layout $S elemTxtCount -expand ns
	$T style layout $S elemRectSel -union [list elemTxtUnread] -iexpand ns -ipadx 2

	# folder + text
	set S [$T style create styFolderRead]
	$T style elements $S {elemRectSel elemImgFolder elemTxtRead}
	$T style layout $S elemImgFolder -expand ns
	$T style layout $S elemTxtRead -padx {4 0} -expand ns -squeeze x
	$T style layout $S elemRectSel -union [list elemTxtRead] -iexpand ns -ipadx 2

	# folder + text + text
	set S [$T style create styFolderUnread]
	$T style elements $S {elemRectSel elemImgFolder elemTxtUnread elemTxtCount}
	$T style layout $S elemImgFolder -expand ns
	$T style layout $S elemTxtUnread -padx 4 -expand ns -squeeze x
	$T style layout $S elemTxtCount -expand ns
	$T style layout $S elemRectSel -union [list elemTxtUnread] -iexpand ns -ipadx 2

	#
	# Create items and assign styles
	#

	$T item style set root C0 styAnyRead
	$T item element configure root C0 \
		elemImgAny -image outlook-main + \
		elemTxtRead -text "Outlook Express"

	set parentList [list root {} {} {} {} {} {}]
	set parent root
	foreach {depth img text button unread} {
		0 local "Local Folders" yes 0
			1 inbox Inbox no 5
			1 outbox Outbox no 0
			1 sent "Sent Items" no 0
			1 deleted "Deleted Items" no 50
			1 draft Drafts no 0
			1 folder "Messages to Dad" no 0
			1 folder "Messages to Sis" no 0
			1 folder "Messages to Me" yes 5
				2 folder "2001" no 0
				2 folder "2000" no 0
				2 folder "1999" no 0
		0 server "news.gmane.org" yes 0
			1 group "gmane.comp.lang.lua.general" no 498
	} {
		set item [$T item create -button $button]
		if {[string equal $img folder]} {
			if {$unread} {
				$T item style set $item C0 styFolderUnread
				$T item element configure $item C0 \
					elemTxtUnread -text $text + \
					elemTxtCount -text "($unread)"
			} else {
				$T item style set $item C0 styFolderRead
				$T item element configure $item C0 elemTxtRead -text $text
			}
		} else {
			if {$unread} {
				$T item style set $item C0 styAnyUnread
				$T item element configure $item C0 \
					elemImgAny -image outlook-$img + \
					elemTxtUnread -text $text + \
					elemTxtCount -text "($unread)"
			} else {
				$T item style set $item C0 styAnyRead
				$T item element configure $item C0 \
					elemImgAny -image outlook-$img + \
					elemTxtRead -text $text
			}
		}
		$T item lastchild [lindex $parentList $depth] $item
		incr depth
		set parentList [lreplace $parentList $depth $depth $item]
	}

	return
}