-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathballoon.tcl
88 lines (79 loc) · 2.62 KB
/
balloon.tcl
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
##############################################################################
# balloon.tcl - procedures used by balloon help
#
# Copyright (C) 1996-1997 Stewart Allen
#
# This is part of vtcl source code
# Adapted for general purpose by
# Daniel Roche <[email protected]>
# thanks to D. Richard Hipp for the multi-headed display fix
# version 1.2 ( Sep 21 2000 )
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##############################################################################
#
bind Bulle <Enter> {
set Bulle(set) 0
set Bulle(first) 1
set Bulle(id) [after 500 {balloon %W $Bulle(%W) %X %Y}]
}
bind Bulle <Button> {
set Bulle(first) 0
kill_balloon
}
bind Bulle <Leave> {
set Bulle(first) 0
kill_balloon
}
bind Bulle <Motion> {
if {$Bulle(set) == 0} {
after cancel $Bulle(id)
set Bulle(id) [after 500 {balloon %W $Bulle(%W) %X %Y}]
}
}
proc set_balloon {target message} {
global Bulle
set Bulle($target) $message
bindtags $target "[bindtags $target] Bulle"
}
proc kill_balloon {} {
global Bulle
after cancel $Bulle(id)
if {[winfo exists .balloon] == 1} {
destroy .balloon
}
set Bulle(set) 0
}
proc balloon {target message {cx 0} {cy 0} } {
global Bulle
if {$Bulle(first) == 1 } {
set Bulle(first) 2
if { $cx == 0 && $cy == 0 } {
set x [expr [winfo rootx $target] + ([winfo width $target]/2)]
set y [expr [winfo rooty $target] + [winfo height $target] + 4]
} else {
set x [expr $cx + 4]
set y [expr $cy + 4]
}
toplevel .balloon -bg black -screen [winfo screen $target]
wm overrideredirect .balloon 1
label .balloon.l \
-text $message -relief flat \
-bg #ffffaa -fg black -padx 0 -pady 0 -anchor w
pack .balloon.l -side left -padx 0 -pady 0
wm geometry .balloon +${x}+${y}
set Bulle(set) 1
}
}