~ubuntu-branches/ubuntu/gutsy/tk8.4/gutsy-updates

« back to all changes in this revision

Viewing changes to library/scale.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-05 15:56:45 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070105155645-8srmlwqo7m1q86qi
Tags: 8.4.14-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# This file defines the default bindings for Tk scale widgets and provides
4
4
# procedures that help in implementing the bindings.
5
5
#
6
 
# RCS: @(#) $Id: scale.tcl,v 1.9.2.3 2003/10/03 00:42:17 patthoyts Exp $
 
6
# RCS: @(#) $Id: scale.tcl,v 1.9.2.5 2006/03/17 10:50:11 patthoyts Exp $
7
7
#
8
8
# Copyright (c) 1994 The Regents of the University of California.
9
9
# Copyright (c) 1994-1995 Sun Microsystems, Inc.
21
21
bind Scale <Enter> {
22
22
    if {$tk_strictMotif} {
23
23
        set tk::Priv(activeBg) [%W cget -activebackground]
24
 
        %W config -activebackground [%W cget -background]
 
24
        %W configure -activebackground [%W cget -background]
25
25
    }
26
26
    tk::ScaleActivate %W %x %y
27
27
}
30
30
}
31
31
bind Scale <Leave> {
32
32
    if {$tk_strictMotif} {
33
 
        %W config -activebackground $tk::Priv(activeBg)
 
33
        %W configure -activebackground $tk::Priv(activeBg)
34
34
    }
35
 
    if {[string equal [%W cget -state] "active"]} {
 
35
    if {[%W cget -state] eq "active"} {
36
36
        %W configure -state normal
37
37
    }
38
38
}
62
62
    tk::ScaleEndDrag %W
63
63
    tk::ScaleActivate %W %x %y
64
64
}
65
 
if {[string equal $tcl_platform(platform) "windows"]} {
 
65
if {$tcl_platform(platform) eq "windows"} {
66
66
    # On Windows do the same with button 3, as that is the right mouse button
67
67
    bind Scale <3>              [bind Scale <2>]
68
68
    bind Scale <B3-Motion>      [bind Scale <B2-Motion>]
114
114
# x, y -        Mouse coordinates.
115
115
 
116
116
proc ::tk::ScaleActivate {w x y} {
117
 
    if {[string equal [$w cget -state] "disabled"]} {
 
117
    if {[$w cget -state] eq "disabled"} {
118
118
        return
119
119
    }
120
 
    if {[string equal [$w identify $x $y] "slider"]} {
 
120
    if {[$w identify $x $y] eq "slider"} {
121
121
        set state active
122
122
    } else {
123
123
        set state normal
124
124
    }
125
 
    if {[string compare [$w cget -state] $state]} {
 
125
    if {[$w cget -state] ne $state} {
126
126
        $w configure -state $state
127
127
    }
128
128
}
143
143
    # save the relief
144
144
    set Priv($w,relief) [$w cget -sliderrelief]
145
145
 
146
 
    if {[string equal $el "trough1"]} {
 
146
    if {$el eq "trough1"} {
147
147
        ScaleIncrement $w up little initial
148
 
    } elseif {[string equal $el "trough2"]} {
 
148
    } elseif {$el eq "trough2"} {
149
149
        ScaleIncrement $w down little initial
150
 
    } elseif {[string equal $el "slider"]} {
 
150
    } elseif {$el eq "slider"} {
151
151
        set Priv(dragging) 1
152
152
        set Priv(initValue) [$w get]
153
153
        set coords [$w coords]
213
213
proc ::tk::ScaleIncrement {w dir big repeat} {
214
214
    variable ::tk::Priv
215
215
    if {![winfo exists $w]} return
216
 
    if {[string equal $big "big"]} {
 
216
    if {$big eq "big"} {
217
217
        set inc [$w cget -bigincrement]
218
218
        if {$inc == 0} {
219
219
            set inc [expr {abs([$w cget -to] - [$w cget -from])/10.0}]
224
224
    } else {
225
225
        set inc [$w cget -resolution]
226
226
    }
227
 
    if {([$w cget -from] > [$w cget -to]) ^ [string equal $dir "up"]} {
 
227
    if {([$w cget -from] > [$w cget -to]) ^ ($dir eq "up")} {
228
228
        set inc [expr {-$inc}]
229
229
    }
230
230
    $w set [expr {[$w get] + $inc}]
231
231
 
232
 
    if {[string equal $repeat "again"]} {
 
232
    if {$repeat eq "again"} {
233
233
        set Priv(afterId) [after [$w cget -repeatinterval] \
234
234
                [list tk::ScaleIncrement $w $dir $big again]]
235
 
    } elseif {[string equal $repeat "initial"]} {
 
235
    } elseif {$repeat eq "initial"} {
236
236
        set delay [$w cget -repeatdelay]
237
237
        if {$delay > 0} {
238
238
            set Priv(afterId) [after $delay \
252
252
 
253
253
proc ::tk::ScaleControlPress {w x y} {
254
254
    set el [$w identify $x $y]
255
 
    if {[string equal $el "trough1"]} {
 
255
    if {$el eq "trough1"} {
256
256
        $w set [$w cget -from]
257
 
    } elseif {[string equal $el "trough2"]} {
 
257
    } elseif {$el eq "trough2"} {
258
258
        $w set [$w cget -to]
259
259
    }
260
260
}
271
271
proc ::tk::ScaleButton2Down {w x y} {
272
272
    variable ::tk::Priv
273
273
 
274
 
    if {[string equal [$w cget -state] "disabled"]} {
 
274
    if {[$w cget -state] eq "disabled"} {
275
275
      return
276
276
    }
277
277
    $w configure -state active