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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [library/] [ChkList.tcl] - Blame information for rev 1771

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

Line No. Rev Author Line
1 578 markom
# ChkList.tcl --
2
#
3
#       This file implements the TixCheckList 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
tixWidgetClass tixCheckList {
12
    -classname TixCheckList
13
    -superclass tixTree
14
    -method {
15
        getselection getstatus setstatus
16
    }
17
    -flag {
18
        -radio
19
    }
20
    -configspec {
21
        {-radio radio Radio false tixVerifyBoolean}
22
 
23
        {-ignoreinvoke ignoreInvoke IgnoreInvoke true tixVerifyBoolean}
24
    }
25
    -static {
26
        -radio
27
    }
28
    -default {
29
        {.scrollbar                     auto}
30
        {.doubleClick                   false}
31
        {*Scrollbar.background          #d9d9d9}
32
        {*Scrollbar.relief              sunken}
33
        {*Scrollbar.takeFocus           0}
34
        {*Scrollbar.troughColor         #c3c3c3}
35
        {*Scrollbar.width               15}
36
        {*borderWidth                   1}
37
        {*hlist.background              #c3c3c3}
38
        {*hlist.drawBranch              1}
39
        {*hlist.height                  10}
40
        {*hlist.highlightBackground      #d9d9d9}
41
        {*hlist.indicator               1}
42
        {*hlist.indent                  20}
43
        {*hlist.itemType                imagetext}
44
        {*hlist.padX                    3}
45
        {*hlist.padY                    0}
46
        {*hlist.relief                  sunken}
47
        {*hlist.takeFocus               1}
48
        {*hlist.wideSelection           0}
49
        {*hlist.width                   20}
50
    }
51
}
52
 
53
proc tixCheckList:InitWidgetRec {w} {
54
    upvar #0 $w data
55
 
56
    tixChainMethod $w InitWidgetRec
57
 
58
    if {$data(-radio)} {
59
        set data(selected) ""
60
    }
61
}
62
 
63
#----------------------------------------------------------------------
64
#
65
#                       Widget commands
66
#
67
#----------------------------------------------------------------------
68
 
69
# Helper function for getselection
70
#
71
proc tixCheckList:GetSel {w var ent mode} {
72
    upvar #0 $w data
73
    upvar $var img
74
 
75
    set ents ""
76
 
77
    catch {
78
        if ![string comp [$data(w:hlist) entrycget $ent -bitmap] $img($mode)] {
79
            lappend ents $ent
80
        }
81
    }
82
 
83
    foreach child [$data(w:hlist) info children $ent] {
84
        set ents [concat $ents [tixCheckList:GetSel $w img $child $mode]]
85
    }
86
 
87
    return $ents
88
}
89
 
90
 
91
# Mode can be on, off, default
92
#
93
proc tixCheckList:getselection {w {mode on}} {
94
    upvar #0 $w data
95
 
96
    set img(on)      [tix getbitmap ck_on]
97
    set img(off)     [tix getbitmap ck_off]
98
    set img(default) [tix getbitmap ck_def]
99
 
100
    set ents ""
101
    foreach child [$data(w:hlist) info children] {
102
        set ents [concat $ents [tixCheckList:GetSel $w img $child $mode]]
103
    }
104
    return $ents
105
}
106
 
107
proc tixCheckList:getstatus {w ent} {
108
    upvar #0 $w data
109
 
110
    if {[$data(w:hlist) entrycget $ent -itemtype] == "imagetext"} {
111
        set img(on)      [tix getbitmap ck_on]
112
        set img(off)     [tix getbitmap ck_off]
113
        set img(default) [tix getbitmap ck_def]
114
 
115
        set bitmap [$data(w:hlist) entrycget $ent -bitmap]
116
 
117
        if {"x$bitmap" == "x$img(on)"} {
118
            set status on
119
        }
120
        if {"x$bitmap" == "x$img(off)"} {
121
            set status off
122
        }
123
        if {"x$bitmap" == "x$img(default)"} {
124
            set status default
125
        }
126
    }
127
 
128
    if [info exists status] {
129
        return $status
130
    } else {
131
        return "none"
132
    }
133
}
134
 
135
proc tixCheckList:setstatus {w ent {mode on}} {
136
    upvar #0 $w data
137
 
138
    if {$data(-radio)} {
139
        set status [tixCheckList:getstatus $w $ent]
140
 
141
        if {"x$status" == "x$mode"} {
142
            return
143
        }
144
 
145
        if {$mode == "on"} {
146
            if {$data(selected) != ""} {
147
                tixCheckList:Select $w $data(selected) off
148
            }
149
            set data(selected) $ent
150
            tixCheckList:Select $w $ent $mode
151
        } elseif {$mode == "off"} {
152
            if {"x$data(selected)" == "x$ent"} {
153
                return
154
            }
155
            tixCheckList:Select $w $ent $mode
156
        } else {
157
            tixCheckList:Select $w $ent $mode
158
        }
159
    } else {
160
        tixCheckList:Select $w $ent $mode
161
    }
162
}
163
 
164
proc tixCheckList:Select {w ent mode} {
165
    upvar #0 $w data
166
 
167
    if {[$data(w:hlist) entrycget $ent -itemtype] == "imagetext"} {
168
        set img(on)      ck_on
169
        set img(off)     ck_off
170
        set img(default) ck_def
171
 
172
        if [catch {
173
            set bitmap [tix getbitmap $img($mode)]
174
            $data(w:hlist) entryconfig $ent -bitmap $bitmap
175
        }] {
176
            # must be the "none" mode
177
            #
178
            catch {
179
                $data(w:hlist) entryconfig $ent -bitmap ""
180
            }
181
        }
182
    }
183
 
184
    return $mode
185
}
186
 
187
proc tixCheckList:HandleCheck {w ent} {
188
    upvar #0 $w data
189
 
190
    if {[$data(w:hlist) entrycget $ent -itemtype] == "imagetext"} {
191
        set img(on)      [tix getbitmap ck_on]
192
        set img(off)     [tix getbitmap ck_off]
193
        set img(default) [tix getbitmap ck_def]
194
 
195
        set curMode [tixCheckList:getstatus $w $ent]
196
 
197
        case $curMode {
198
            on {
199
                tixCheckList:setstatus $w $ent off
200
            }
201
            off {
202
                tixCheckList:setstatus $w $ent on
203
            }
204
            none {
205
                return
206
            }
207
            default {
208
                tixCheckList:setstatus $w $ent on
209
            }
210
        }
211
    }
212
}
213
 
214
proc tixCheckList:Command {w B} {
215
    upvar #0 $w data
216
    upvar $B bind
217
 
218
    set ent [tixEvent flag V]
219
    tixCheckList:HandleCheck $w $ent
220
 
221
    tixChainMethod $w Command $B
222
}
223
 
224
proc tixCheckList:BrowseCmd {w B} {
225
    upvar #0 $w data
226
    upvar $B bind
227
 
228
    set ent [tixEvent flag V]
229
 
230
    case [tixEvent type] {
231
        {<ButtonPress-1> <space>} {
232
            tixCheckList:HandleCheck $w $ent
233
        }
234
    }
235
 
236
    tixChainMethod $w BrowseCmd $B
237
}

powered by: WebSVN 2.1.0

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