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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [library/] [MultView.tcl] - Blame information for rev 1781

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# MultView.tcl --
2
#
3
#       Implements the multi-view widget
4
#
5
# Copyright (c) 1996, Expert Interface Technologies
6
#
7
# See the file "license.terms" for information on usage and redistribution
8
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
#
10
 
11
 
12
tixWidgetClass tixMultiView {
13
    -classname TixMultiView
14
    -superclass tixPrimitive
15
    -method {
16
        add
17
    }
18
    -flag {
19
        -browsecmd -command -view
20
    }
21
    -forcecall {
22
        -view
23
    }
24
    -configspec {
25
        {-browsecmd browseCmd BrowseCmd ""}
26
        {-command command Command ""}
27
        {-view view View icon tixMultiView:VerifyView}
28
    }
29
    -alias {
30
    }
31
 
32
    -default {
33
    }
34
}
35
 
36
proc tixMultiView:InitWidgetRec {w} {
37
    upvar #0 $w data
38
    global env
39
 
40
    tixChainMethod $w InitWidgetRec
41
}
42
 
43
#----------------------------------------------------------------------
44
#               Construct widget
45
#----------------------------------------------------------------------
46
proc tixMultiView:ConstructWidget {w} {
47
    upvar #0 $w data
48
 
49
    tixChainMethod $w ConstructWidget
50
 
51
    set data(w:stlist) [tixScrolledTList $w.stlist]
52
    set data(w:sgrid)  [tixScrolledGrid $w.sgrid]
53
    set data(w:icon)   [tixIconView  $w.icon]
54
 
55
    set data(w:tlist) [$data(w:stlist) subwidget tlist]
56
    set data(w:grid)  [$data(w:sgrid) subwidget grid]
57
 
58
    $data(w:grid) config -formatcmd "tixMultiView:GridFormat $w" \
59
        -leftmargin 0 -topmargin 1
60
}
61
 
62
proc tixMultiView:SetBindings {w} {
63
    upvar #0 $w data
64
 
65
    tixChainMethod $w SetBindings
66
}
67
 
68
proc tixMultiView:GetWid {w which} {
69
    upvar #0 $w data
70
 
71
    case $which {
72
        list {
73
            return $data(w:stlist)
74
        }
75
        icon {
76
            return $data(w:icon)
77
        }
78
        detail {
79
            return $data(w:sgrid)
80
        }
81
    }
82
}
83
#----------------------------------------------------------------------
84
# Configuration
85
#----------------------------------------------------------------------
86
proc tixMultiView:config-view {w value} {
87
    upvar #0 $w data
88
 
89
    if {$data(-view) != ""} {
90
        pack forget [tixMultiView:GetWid $w $data(-view)]
91
    }
92
 
93
    pack [tixMultiView:GetWid $w $value] -expand yes -fill both
94
}
95
#----------------------------------------------------------------------
96
# Private methods
97
#----------------------------------------------------------------------
98
proc tixMultiView:GridFormat {w area x1 y1 x2 y2} {
99
    upvar #0 $w data
100
 
101
    case $area {
102
        main {
103
        }
104
        {x-margin y-margin s-margin} {
105
            # cborder specifies consecutive 3d borders
106
            #
107
            $data(w:grid) format cborder $x1 $y1 $x2 $y2 \
108
                -fill 1 -relief raised -bd 2 -bg gray60 \
109
                -selectbackground gray80
110
        }
111
    }
112
 
113
}
114
 
115
#----------------------------------------------------------------------
116
# Public methods
117
#----------------------------------------------------------------------
118
 
119
# Return value is the index of "$name" in the grid subwidget
120
#
121
#
122
proc tixMultiView:add {w name args} {
123
    upvar #0 $w data
124
 
125
    set validOptions {-image -text}
126
 
127
    set opt(-image)  ""
128
    set opt(-text)   ""
129
 
130
    tixHandleOptions -nounknown opt $validOptions $args
131
 
132
    $data(w:icon) add $name $opt(-image) $opt(-text)
133
    $data(w:tlist) insert end -itemtype imagetext \
134
        -image $opt(-image) -text $opt(-text)
135
    $data(w:grid) set 0 end -itemtype imagetext \
136
        -image $opt(-image) -text $opt(-text)
137
 
138
    return max
139
}
140
 
141
#----------------------------------------------------------------------
142
# checker
143
#----------------------------------------------------------------------
144
proc tixMultiView:VerifyView {value} {
145
    case $value {
146
        {icon list detail} {
147
            return $value
148
        }
149
    }
150
    error "bad view \"$value\", must be detail, icon or list"
151
}
152
 

powered by: WebSVN 2.1.0

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