OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [demos/] [samples/] [SHList.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Tix Demostration Program
2
#
3
# This sample program is structured in such a way so that it can be
4
# executed from the Tix demo program "widget": it must have a
5
# procedure called "RunSample". It should also have the "if" statment
6
# at the end of this file so that it can be run as a standalone
7
# program using tixwish.
8
 
9
# This file demonstrates the use of the tixScrolledHList widget.
10
#
11
 
12
proc RunSample {w} {
13
 
14
    # We create the frame and the ScrolledHList widget
15
    # at the top of the dialog box
16
    #
17
    frame $w.top -relief raised -bd 1
18
 
19
    # Put a simple hierachy into the HList (two levels). Use colors and
20
    # separator widgets (frames) to make the list look fancy
21
    #
22
    tixScrolledHList $w.top.a
23
    pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left
24
 
25
 
26
    # This is our little relational database
27
    #
28
    set bosses {
29
        {jeff  "Jeff Waxman"}
30
        {john  "John Lee"}
31
        {peter "Peter Kenson"}
32
    }
33
 
34
    set employees {
35
        {alex   john    "Alex Kellman"}
36
        {alan   john    "Alan Adams"}
37
        {andy   peter   "Andreas Crawford"}
38
        {doug   jeff    "Douglas Bloom"}
39
        {jon    peter   "Jon Baraki"}
40
        {chris  jeff    "Chris Geoffrey"}
41
        {chuck  jeff    "Chuck McLean"}
42
    }
43
 
44
    set hlist [$w.top.a subwidget hlist]
45
 
46
    # Let configure the appearance of the HList subwidget 
47
    #
48
    $hlist config -separator "." -width 25 -drawbranch 0 -indent 10
49
 
50
    set index 0
51
    foreach line $bosses {
52
        if {$index != 0} {
53
            frame $hlist.sep$index -bd 2 -height 2 -width 150 -relief sunken \
54
                -bg [$hlist cget -bg]
55
 
56
            $hlist addchild {} -itemtype window \
57
                -window $hlist.sep$index -state disabled
58
        }
59
        $hlist add [lindex $line 0] -itemtype text \
60
            -text [lindex $line 1]
61
        incr index
62
    }
63
 
64
    foreach line $employees {
65
        # "." is the separator character we chose above
66
        #
67
        set entrypath [lindex $line 1].[lindex $line 0]
68
        #             ^^^^^^^^^^^^^^^   ^^^^^^^^^^^^^^^
69
        #             parent entryPath / child's name
70
 
71
        $hlist add $entrypath -text [lindex $line 2]
72
 
73
        # [Hint] Make sure the [lindex $line 1].[lindex $line 0] you choose
74
        #        are unique names. If you cannot be sure of this (because of
75
        #        the structure of your database, e.g.) you can use the
76
        #        "addchild" widget command instead:
77
        #
78
        #  $hlist addchild [lindex $line 1] -text [lindex $line 2]
79
        #                  ^^^^^^^^^^^^^^^^
80
        #                  parent entryPath 
81
 
82
    }
83
 
84
    # Use a ButtonBox to hold the buttons.
85
    #
86
    tixButtonBox $w.box -orientation horizontal
87
    $w.box add ok     -text Ok     -underline 0 -command "destroy $w" \
88
        -width 6
89
    $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \
90
        -width 6
91
 
92
    pack $w.box -side bottom -fill x
93
    pack $w.top -side top -fill both -expand yes
94
}
95
 
96
 
97
# This "if" statement makes it possible to run this script file inside or
98
# outside of the main demo program "widget".
99
#
100
if {![info exists tix_demo_running]} {
101
    wm withdraw .
102
    set w .demo
103
    toplevel $w
104
    RunSample $w
105
    bind .demo <Destroy> exit
106
}
107
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.