1 |
# WWWHelpProc.tcl: a rather generic help system |
2 |
# by Benjamin A. Allan |
3 |
# Created: August 28, 1996 |
4 |
# Part of ASCEND |
5 |
# Revision: $Revision: 1.23 $ |
6 |
# Last modified on: $Date: 1998/06/18 15:55:10 $ |
7 |
# Last modified by: $Author: mthomas $ |
8 |
# Revision control file: $RCSfile: WWWHelpProc.tcl,v $ |
9 |
# |
10 |
# This file is part of the ASCEND Tcl/Tk Interface. |
11 |
# |
12 |
# Copyright (C) 1996-1998 Carnegie Mellon University |
13 |
# |
14 |
# The ASCEND Tcl/Tk Interface is free software; you can redistribute |
15 |
# it and/or modify it under the terms of the GNU General Public |
16 |
# License as published by the Free Software Foundation; either |
17 |
# version 2 of the License, or (at your option) any later version. |
18 |
# |
19 |
# The ASCEND Tcl/Tk Interface is distributed in hope that it will be |
20 |
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
21 |
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 |
# GNU General Public License for more details. |
23 |
# |
24 |
# You should have received a copy of the GNU General Public License |
25 |
# along with the program; if not, write to the Free Software |
26 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the |
27 |
# file named COPYING. COPYING is found in ../compiler. |
28 |
|
29 |
#--------------------------------------------------------------------------- |
30 |
# a rather generic help system. in this Case being used for ascend. |
31 |
# The help info is basically a directory structure of html |
32 |
# The magic part is done here which defines bindings for nearly |
33 |
# all ascend gui buttons. |
34 |
|
35 |
# |
36 |
# proc set_Help_Defaults {} |
37 |
#--------------------------------------------------------------------------- |
38 |
# Initializes help utility information. |
39 |
# these may be customized per site or per user in the |
40 |
# AscendRC or .ascendrc file, since those files will |
41 |
# be read (one or the other) after this function is called. |
42 |
# The three important global variables are: |
43 |
# ascHelpVect(rootURL) |
44 |
# This should be a directory name ending with a / |
45 |
# This is not a URL! |
46 |
# The directory is the directory containing the top |
47 |
# level ascend help files for your site. |
48 |
# ascHelpVect(start_command) |
49 |
# This is the command we should execute to start a web |
50 |
# browser with a specific URL. It is used to spawn a |
51 |
# web browser independent of ASCEND. Every place that %U |
52 |
# appears in this command, we will substitute the |
53 |
# URL to be viewed. This is only called after the |
54 |
# restart_command has failed. |
55 |
# ascHelpVect(restart_command) |
56 |
# This is the command we should execute to redirect |
57 |
# the attention of your already running web browser. |
58 |
# If this command returns an error code, we will |
59 |
# attempt to start a new browser. |
60 |
# If your favorite browser does not support restarting, |
61 |
# set ascHelpVect(restart_command) "false" This will cause |
62 |
# a new browser to start for every help query from the |
63 |
# ASCEND interface. |
64 |
# Every place that %U appears in this command, we will |
65 |
# substitute the URL to be viewed. |
66 |
#--------------------------------------------------------------------------- |
67 |
proc set_Help_Defaults {} { |
68 |
global ascHelpVect env tcl_platform |
69 |
if {$tcl_platform(platform) == "windows"} { |
70 |
set ascHelpVect(rootURL) $env(ASCENDDIST) |
71 |
regsub -all -- {\\} $env(ASCENDDIST) / ascHelpVect(rootURL) |
72 |
append ascHelpVect(rootURL) /help/ |
73 |
set ascHelpVect(start_command) \ |
74 |
{{C:/Program Files/Plus!/Microsoft Internet/Iexplore.exe} %U} |
75 |
set ascHelpVect(restart_command) \ |
76 |
{{C:/Program Files/Netscape/Navigator/Program/netscape.exe} %U} |
77 |
if {[file exists \ |
78 |
{C:/Program Files/Netscape/Communicator/Program/netscape.exe}]} { |
79 |
set ascHelpVect(restart_command) \ |
80 |
{{C:/Program Files/Netscape/Communicator/Program/netscape.exe} %U} |
81 |
} |
82 |
} else { |
83 |
set ascHelpVect(rootURL) $env(ASCENDDIST) |
84 |
append ascHelpVect(rootURL) /help/ |
85 |
set ascHelpVect(start_command) "netscape %U" |
86 |
set ascHelpVect(restart_command) "netscape -remote openURL(%U)" |
87 |
} |
88 |
# above probably go in utilities window. |
89 |
set ascHelpVect(extension) ".htm" |
90 |
global ascHelpVect |
91 |
#>> asc_bv_init |
92 |
} |
93 |
|
94 |
# |
95 |
# proc Help_do_Help {} |
96 |
#--------------------------------------------------------------------------- |
97 |
# the help help button |
98 |
#--------------------------------------------------------------------------- |
99 |
proc Help_do_Help {} { |
100 |
Help_button help.help.intro |
101 |
} |
102 |
|
103 |
# |
104 |
# proc Help_Open {} |
105 |
#--------------------------------------------------------------------------- |
106 |
# fire up the help window, on nothing in particular |
107 |
#--------------------------------------------------------------------------- |
108 |
proc Help_Open {} { |
109 |
Help_button "beginner" |
110 |
} |
111 |
# |
112 |
# proc Help_do_AskExpert {} |
113 |
#--------------------------------------------------------------------------- |
114 |
# spawn ask expert mail.modal |
115 |
#--------------------------------------------------------------------------- |
116 |
proc Help_do_AskExpert {} { |
117 |
global ascHelpVect |
118 |
catch {eval "exec" $ascHelpVect(askmail)} |
119 |
} |
120 |
|
121 |
# |
122 |
# proc Help_do_Window {$win} |
123 |
#--------------------------------------------------------------------------- |
124 |
#--------------------------------------------------------------------------- |
125 |
proc Help_do_Window {$win} { |
126 |
Help_button [winfo toplevel $win] |
127 |
} |
128 |
|
129 |
#>>#### initialization stuff |
130 |
#>># |
131 |
#>># proc Help_BindAllM3 {} |
132 |
#>>#-------------------------------------------------------------------------- |
133 |
#>># bind every goddamned button with an M3 call, keeping overhead as small as |
134 |
#>># maintainably possible |
135 |
#>>#-------------------------------------------------------------------------- |
136 |
#>>proc Help_BindAllM3 {} { |
137 |
#>> Help_BindButtons |
138 |
#>> Help_BindMenuButtons |
139 |
#>> Help_BindRadioButtons |
140 |
#>> Help_BindMenus |
141 |
#>> Help_BindCascades |
142 |
#>> puts "Click M3 on any button for button help." |
143 |
#>>} |
144 |
#>> |
145 |
#>>#### FUNCTIONS THAT SET UP THE BINDINGS EN MASSE |
146 |
#>># |
147 |
#>># proc Help_BindButtons {} |
148 |
#>>#------------------------------------------------------------------------- |
149 |
#>>#set M3 bindings on buttons for nontransients. transients ibnd themselves |
150 |
#>># ascend specific |
151 |
#>>#------------------------------------------------------------------------- |
152 |
#>>proc Help_BindButtons {} { |
153 |
#>> foreach bb { |
154 |
#>> {{.solver.lbl_frm.btn_int} {solver.interrupt}} |
155 |
#>> {{.toolbox.bottom_frm.browser_btn} {toolbox.window}} |
156 |
#>> {{.toolbox.bottom_frm.display_btn} {toolbox.window}} |
157 |
#>> {{.toolbox.bottom_frm.library_btn} {toolbox.window}} |
158 |
#>> {{.toolbox.bottom_frm.probe_btn} {toolbox.window}} |
159 |
#>> {{.toolbox.bottom_frm.script_btn} {toolbox.window}} |
160 |
#>> {{.toolbox.bottom_frm.sims_btn} {toolbox.window}} |
161 |
#>> {{.toolbox.bottom_frm.solver_btn} {toolbox.window}} |
162 |
#>> {{.toolbox.bottom_frm.units_btn} {toolbox.window}} |
163 |
#>> {{.toolbox.top_frm.util_btn} {utilities}} |
164 |
#>> {{.toolbox.top_frm.exit_btn} {toolbox.exit}} |
165 |
#>> {{.toolbox.top_frm.hlp_btn} {help.help.intro}} |
166 |
#>> {{.toolbox.top_frm.filler5} {toolbox.bugreport}} |
167 |
#>> } { |
168 |
#>> Help_BindButton [lindex $bb 0] [lindex $bb 1] |
169 |
#>> } |
170 |
#>>} |
171 |
#>> |
172 |
#>> |
173 |
#>># |
174 |
#>># proc Help_BindRadioButtons {} |
175 |
#>>#------------------------------------------------------------------------ |
176 |
#>>#set M3 bindings on radiobuttons for nontransients. |
177 |
#>>#transients ibnd themselves |
178 |
#>># ascend specific |
179 |
#>>#------------------------------------------------------------------------ |
180 |
#>>proc Help_BindRadioButtons {} { |
181 |
#>> foreach rb { |
182 |
#>> } { |
183 |
#>> Help_BindButton [lindex $rb 0] [lindex $rb 1] |
184 |
#>> } |
185 |
#>>} |
186 |
#>> |
187 |
#>># |
188 |
#>># proc Help_BindMenuButtons {} |
189 |
#>>#------------------------------------------------------------------------- |
190 |
#>>#set M3 bindings on menubuttons transients bind their own |
191 |
#>># ascend specific |
192 |
#>>#------------------------------------------------------------------------- |
193 |
#>>proc Help_BindMenuButtons {} { |
194 |
#>> foreach mb { |
195 |
#>> {{.browser.menubar.display} {browser.display}} |
196 |
#>> {{.browser.menubar.edit} {browser.edit}} |
197 |
#>> {{.browser.menubar.export} {browser.export}} |
198 |
#>> {{.browser.menubar.find} {browser.find}} |
199 |
#>> {{.browser.menubar.help} {help.help.intro}} |
200 |
#>> {{.display.menubar.file} {display.execute}} |
201 |
#>> {{.display.menubar.view} {display.view}} |
202 |
#>> {{.display.menubar.help} {help.help.intro}} |
203 |
#>> {{.library.menubar.create} {library.create}} |
204 |
#>> {{.library.menubar.display} {library.display}} |
205 |
#>> {{.library.menubar.edit} {library.edit}} |
206 |
#>> {{.library.menubar.find} {library.find}} |
207 |
#>> {{.library.menubar.help} {help.help.intro}} |
208 |
#>> {{.probe.menubar.edit} {probe.edit}} |
209 |
#>> {{.probe.menubar.file} {probe.execute}} |
210 |
#>> {{.probe.menubar.export} {probe.export}} |
211 |
#>> {{.probe.menubar.help} {help.help.intro}} |
212 |
#>> {{.script.menubar.edit} {script.edit}} |
213 |
#>> {{.script.menubar.execute} {script.execute}} |
214 |
#>> {{.script.menubar.help} {help.help.intro}} |
215 |
#>> {{.sims.menubar.edit} {simulations.edit}} |
216 |
#>> {{.sims.menubar.export} {simulations.export}} |
217 |
#>> {{.sims.menubar.help} {help.help.intro}} |
218 |
#>> {{.solver.menubar.analyze} {solver.analyze}} |
219 |
#>> {{.solver.menubar.display} {solver.display}} |
220 |
#>> {{.solver.menubar.edit} {solver.edit}} |
221 |
#>> {{.solver.menubar.edit.options} {solver.grill}} |
222 |
#>> {{.solver.menubar.execute} {solver.execute}} |
223 |
#>> {{.solver.menubar.export} {solver.export}} |
224 |
#>> {{.solver.menubar.help} {help.help.intro}} |
225 |
#>> {{.units.menubar.edit} {units.edit}} |
226 |
#>> {{.units.menubar.help} {help.help.intro}} |
227 |
#>> } { |
228 |
#>> Help_BindButton [lindex $mb 0] [lindex $mb 1] |
229 |
#>> } |
230 |
#>> global ascSolvVect |
231 |
#>> if {$ascSolvVect(modelbar)} { |
232 |
#>> Help_BindButton .solver.main_frm.btn_expo solver.import |
233 |
#>> Help_BindMenu .solver.main_frm.btn_expo.m solver.import |
234 |
#>> } |
235 |
#>>} |
236 |
#>> |
237 |
#>># |
238 |
#>># proc Help_BindMenus {} |
239 |
#>>#------------------------------------------------------------------------- |
240 |
#>>#set M3 bindings on menus. transients bind their own. |
241 |
#>># ascend specific |
242 |
#>>#------------------------------------------------------------------------- |
243 |
#>>proc Help_BindMenus {} { |
244 |
#>> foreach m { |
245 |
#>> {{.browser.menubar.display} {browser.display}} |
246 |
#>> {{.browser.menubar.edit} {browser.edit}} |
247 |
#>> {{.browser.menubar.export} {browser.export}} |
248 |
#>> {{.browser.menubar.find} {browser.find}} |
249 |
#>> {{.browser.menubar.help} {browser.help}} |
250 |
#>> {{.display.menubar.file} {display.execute}} |
251 |
#>> {{.display.menubar.view} {display.view}} |
252 |
#>> {{.display.menubar.help} {display.help}} |
253 |
#>> {{.library.menubar.create} {library.create}} |
254 |
#>> {{.library.menubar.display} {library.display}} |
255 |
#>> {{.library.menubar.edit} {library.edit}} |
256 |
#>> {{.library.menubar.find} {library.find}} |
257 |
#>> {{.library.menubar.help} {library.help}} |
258 |
#>> {{.probe.menubar.edit} {probe.edit}} |
259 |
#>> {{.probe.menubar.file} {probe.execute}} |
260 |
#>> {{.probe.menubar.export} {probe.export}} |
261 |
#>> {{.probe.menubar.help} {probe.help}} |
262 |
#>> {{.script.menubar.edit} {script.edit}} |
263 |
#>> {{.script.menubar.execute} {script.execute}} |
264 |
#>> {{.script.menubar.help} {script.help}} |
265 |
#>> {{.sims.menubar.edit} {simulations.edit}} |
266 |
#>> {{.sims.menubar.export} {simulations.export}} |
267 |
#>> {{.sims.menubar.help} {simulations.help}} |
268 |
#>> {{.solver.menubar.analyze} {solver.analyze}} |
269 |
#>> {{.solver.menubar.display} {solver.display}} |
270 |
#>> {{.solver.menubar.edit} {solver.edit}} |
271 |
#>> {{.solver.menubar.edit.options} {solver.grill}} |
272 |
#>> {{.solver.menubar.execute} {solver.execute}} |
273 |
#>> {{.solver.menubar.export} {solver.export}} |
274 |
#>> {{.solver.menubar.help} {solver.help}} |
275 |
#>> {{.units.menubar.edit} {units.edit}} |
276 |
#>> {{.units.menubar.help} {units.help}} |
277 |
#>> } { |
278 |
#>> Help_BindMenu [lindex $m 0] [lindex $m 1] |
279 |
#>> } |
280 |
#>>} |
281 |
#>> |
282 |
#>># |
283 |
#>># proc Help_BindCascades {} |
284 |
#>>#------------------------------------------------------------------------- |
285 |
#>>#set M3 bindings on cascade menus. transients bind their own. |
286 |
#>># ascend specific |
287 |
#>>#------------------------------------------------------------------------- |
288 |
#>>proc Help_BindCascades {} { |
289 |
#>> foreach m { |
290 |
#>> {{.browser.menubar.edit.compile} {browser.edit} {compile}} |
291 |
#>> {{.solver.menubar.analyze.depend} {solver.analyze} {finddependenteqns}} |
292 |
#>> {{.solver.menubar.edit.solvers} {solver.edit} {selectsolver}} |
293 |
#>> } { |
294 |
#>> Help_BindCascadeMenu [lindex $m 0] [lindex $m 1] [lindex $m 2] |
295 |
#>> } |
296 |
#>>} |
297 |
#>> |
298 |
#>>#### FUNCTIONS THAT CREATE BINDINGS |
299 |
#>># |
300 |
#>># proc Help_BindButton {b p args} |
301 |
#>>#------------------------------------------------------------------------- |
302 |
#>>#set M3 binding for button b to Help_button p args |
303 |
#>>#------------------------------------------------------------------------- |
304 |
#>>proc Help_BindButton {b p args} { |
305 |
#>> if {[llength $args]} { |
306 |
#>> bind $b <B3-ButtonRelease> "Help_button $p $args" |
307 |
#>> } else { |
308 |
#>> bind $b <B3-ButtonRelease> "Help_button $p" |
309 |
#>> } |
310 |
#>>} |
311 |
#>> |
312 |
#>> |
313 |
#>># |
314 |
#>># proc Help_BindCascadeMenu {m p} |
315 |
#>>#------------------------------------------------------------------------- |
316 |
#>>#set M3 binding for menu w with Help_menu prefix p |
317 |
#>>#------------------------------------------------------------------------- |
318 |
#>>proc Help_BindCascadeMenu {m p q} { |
319 |
#>> bind $m <B3-ButtonRelease> "Help_CascadeItemBinding $m $p $q" |
320 |
#>>} |
321 |
#>># |
322 |
#>># proc Help_BindMenu {m p} |
323 |
#>>#------------------------------------------------------------------------- |
324 |
#>>#set M3 binding for menu w with Help_menu prefix p |
325 |
#>>#------------------------------------------------------------------------- |
326 |
#>>proc Help_BindMenu {m p} { |
327 |
#>> bind $m <B3-ButtonRelease> "Help_MenuItemBinding $m $p" |
328 |
#>>} |
329 |
#>> |
330 |
#>>### BINDINGS THAT GET CALLED |
331 |
#>> |
332 |
#>># |
333 |
#>># proc Help_MenuItemBinding {m p} |
334 |
#>>#------------------------------------------------------------------------- |
335 |
#>># m is the menu widget name, p is the qlfdid prefix for m |
336 |
#>># mashes button entry name into something safe and calls help on |
337 |
#>># prefix.mash |
338 |
#>>#------------------------------------------------------------------------- |
339 |
#>>proc Help_MenuItemBinding {m p} { |
340 |
#>> set l [$m index active] |
341 |
#>> if {$l == "none"} {return} |
342 |
#>> set l [lindex [$m entryconfigure $l -label] 4] |
343 |
#>> regsub -all { } $l "" l |
344 |
#>> set l [string tolower $l] |
345 |
#>> Help_button $p $l |
346 |
#>>} |
347 |
#>># |
348 |
#>># proc Help_CascadeItemBinding {m p q} |
349 |
#>>#------------------------------------------------------------------------- |
350 |
#>># m is the menu widget name, p is the qlfdid prefix for m |
351 |
#>># q is the cascaded menu name mashed |
352 |
#>># mashes p q names into something safe and calls help. |
353 |
#>>#------------------------------------------------------------------------- |
354 |
#>>proc Help_CascadeItemBinding {m p q} { |
355 |
#>> set l [$m index active] |
356 |
#>> if {$l == "none"} {return} |
357 |
#>> set l [lindex [$m entryconfigure $l -label] 4] |
358 |
#>> regsub -all { } $l "" l |
359 |
#>> set l [string tolower $l] |
360 |
#>> Help_button $p $q.$l |
361 |
#>>} |
362 |
|
363 |
# |
364 |
# Help_button {qlfdid item} |
365 |
#--------------------------------------------------------------------------- |
366 |
# callback M3-release |
367 |
# if argument is {none} returns immediately. |
368 |
# Argument is the qlfdid relative to root of the button. |
369 |
# args, if present, should be a menu item and will be |
370 |
# treated as a <name> tag in html. |
371 |
# |
372 |
# if args empty: |
373 |
# qlfdid is a filename or valid url portion, relative to root |
374 |
# function to bind to fullblown buttons of various sorts |
375 |
# e.g. menu button, radio button, just plain buttons |
376 |
# |
377 |
# if args !empty: |
378 |
# menu items and cascades need an intermediate binding to |
379 |
# concoct this item argument which follows the # in html |
380 |
#--------------------------------------------------------------------------- |
381 |
proc Help_button {hqlfdid args} { |
382 |
global ascHelpVect ascScripVect |
383 |
if {$hqlfdid=="none"} {return} |
384 |
set data "See $hqlfdid.pdf section $args\nat\n" |
385 |
append data http://www.cs.cmu.edu/~ascend/pdfhelp.htm |
386 |
asctk_dialog .helpmsg $ascScripVect(font) "Help location" $data info 0 OK |
387 |
return |
388 |
# old code |
389 |
set qlist [split $hqlfdid .] |
390 |
set url [join $qlist /] |
391 |
set url "$ascHelpVect(rootURL)$url$ascHelpVect(extension)" |
392 |
if {[llength $args]} { |
393 |
set url "$url#$args" |
394 |
} |
395 |
Help_do_URL $url |
396 |
} |
397 |
|
398 |
#### utility function. simple eh? |
399 |
|
400 |
# this function opens or reopens a URL with the user defined web protocol |
401 |
proc Help_do_URL {url} { |
402 |
global ascHelpVect |
403 |
set comm "$ascHelpVect(rootURL)" |
404 |
set err 0 |
405 |
set errmess WebOK |
406 |
regsub -all %U $ascHelpVect(restart_command) $url comm |
407 |
puts "Executing: $comm &" |
408 |
set err [catch {eval "exec $comm"} errmess] |
409 |
if {$err} { |
410 |
puts stderr "Error: $errmess" |
411 |
puts stderr "Trying to start a WWW browser" |
412 |
puts stderr "If it doesn't work send mail to ascend+help@cs.cmu.edu" |
413 |
puts stderr "after verifying your WWW info in the utilities window." |
414 |
regsub -all %U $ascHelpVect(start_command) $url comm |
415 |
eval "exec $comm &" |
416 |
} |
417 |
} |
418 |
|
419 |
|
420 |
#>># defines bindings for balloon help |
421 |
#>>proc asc_bv_init {} { |
422 |
#>> global bv |
423 |
#>> set bv(popped) 0 |
424 |
#>> set bv(ow) . |
425 |
#>> set bv(label) root |
426 |
#>> set bv(popup) . |
427 |
#>> set bv(lastleave) . |
428 |
#>> bind Menu <<MenuSelect>> {asc_bv_monitor %W} |
429 |
#>> bind all <Leave> {asc_bv_leavekill %W} |
430 |
#>> bind all <Enter> {asc_bv_enterkill %W} |
431 |
#>>} |
432 |
#>> |
433 |
#>># with a few twisty exceptions, leaving any widget kills the popup |
434 |
#>>proc asc_bv_leavekill {w} { |
435 |
#>> set to [winfo containing [winfo pointerx $w] [winfo pointery $w]] |
436 |
#>> if {$to == $w} {return ; #damn overeager wm } |
437 |
#>> catch {$w entrycget active -menu} |
438 |
#>> if {[winfo class $w] == "Menu" && |
439 |
#>> [$w cget -type] == "menubar" && |
440 |
#>> $to == [$w entrycget active -menu]} { |
441 |
#>> return |
442 |
#>> } |
443 |
#>> set root "" |
444 |
#>> catch {set root [string range $to 0 4]} |
445 |
#>> if {$root == ".ball"} {return} |
446 |
#>> # puts "allleave destroy $w $to $root" |
447 |
#>> destroy .balloon |
448 |
#>>} |
449 |
#>> |
450 |
#>># entering any widget except the popup kills the popup |
451 |
#>>proc asc_bv_enterkill {w} { |
452 |
#>> set to [winfo containing [winfo pointerx $w] [winfo pointery $w]] |
453 |
#>> set root "" |
454 |
#>> catch {set root [string range $to 0 4]} |
455 |
#>> if {$root != ".ball" && |
456 |
#>> [winfo class $w] != "Menu" && |
457 |
#>> [winfo class $w] != "Menubutton"} { |
458 |
#>> # puts "allenter destroy" |
459 |
#>> destroy .balloon |
460 |
#>> } |
461 |
#>>} |
462 |
#>> |
463 |
#>> |
464 |
#>>proc asc_bv_monitor {w} { |
465 |
#>> if {$w == ".balloon"} {return} |
466 |
#>> if {[llength [split $w .]]==3} {return} |
467 |
#>> if {![$w yposition active]} { return } ;# ignore separators |
468 |
#>> set rootx 0 |
469 |
#>> set rooty 0 |
470 |
#>> if {[$w type active] == "cascade" } { |
471 |
#>> set rootx [expr [winfo rootx $w] + [winfo width $w] -15] |
472 |
#>> set rooty [expr [winfo rooty $w] + [$w yposition active] + 15] |
473 |
#>> } else { |
474 |
#>> set rootx [expr [winfo rootx $w] + [winfo width $w] -4] |
475 |
#>> set rooty [expr [winfo rooty $w] + [$w yposition active] + 5] |
476 |
#>> } |
477 |
#>> asc_bv_post $rootx $rooty "[$w entrycget active -label]" \ |
478 |
#>> [string tolower [$w cget -tearoffcommand]] |
479 |
#>>} |
480 |
#>> |
481 |
#>>proc asc_bv_post {x y l ow} { |
482 |
#>> global bv |
483 |
#>> |
484 |
#>> if {$bv(ow) == $ow && $bv(label) == $l || $bv(popped)} {return} |
485 |
#>> set bv(label) $l |
486 |
#>> set bv(ow) $ow |
487 |
#>> # puts "wipost destroy" |
488 |
#>> destroy .balloon |
489 |
#>> if {$l == ""} {return} ;# no help on menubars |
490 |
#>> toplevel .balloon -class Help |
491 |
#>> wm withdraw .balloon |
492 |
#>> wm overrideredirect .balloon 1 |
493 |
#>> .balloon configure -cursor question_arrow |
494 |
#>> set se "we need to lookup the short help" |
495 |
#>> button .balloon.s \ |
496 |
#>> -text $se \ |
497 |
#>> -foreground black \ |
498 |
#>> -background yellow \ |
499 |
#>> -justify left \ |
500 |
#>> -highlightthickness 0 \ |
501 |
#>> -padx 0 \ |
502 |
#>> -pady 0 \ |
503 |
#>> -command "puts \"help $ow $l\"" |
504 |
#>> button .balloon.m \ |
505 |
#>> -text "More on $l" \ |
506 |
#>> -foreground black \ |
507 |
#>> -background yellow \ |
508 |
#>> -justify left \ |
509 |
#>> -highlightthickness 0 \ |
510 |
#>> -padx 0 \ |
511 |
#>> -pady 0 \ |
512 |
#>> -command balloon_more |
513 |
#>> button .balloon.p \ |
514 |
#>> -text "Stop balloon help" \ |
515 |
#>> -foreground black \ |
516 |
#>> -background yellow \ |
517 |
#>> -justify left \ |
518 |
#>> -highlightthickness 0 \ |
519 |
#>> -padx 0 \ |
520 |
#>> -pady 0 \ |
521 |
#>> -command balloon_stop |
522 |
#>> button .balloon.q \ |
523 |
#>> -text "Dismiss" \ |
524 |
#>> -foreground black \ |
525 |
#>> -background yellow \ |
526 |
#>> -justify left \ |
527 |
#>> -highlightthickness 0 \ |
528 |
#>> -padx 0 \ |
529 |
#>> -pady 0 \ |
530 |
#>> -command balloon_pop |
531 |
#>> |
532 |
#>> pack append .balloon \ |
533 |
#>> .balloon.s {top frame center expand fillx} \ |
534 |
#>> .balloon.m {top frame center expand fillx} \ |
535 |
#>> .balloon.p {top frame center expand fillx} \ |
536 |
#>> .balloon.q {top frame center expand fillx} |
537 |
#>> |
538 |
#>> wm geometry .balloon "" |
539 |
#>> |
540 |
#>> asc_bv_popup .balloon $x $y |
541 |
#>> |
542 |
#>>} |
543 |
#>> |
544 |
#>>proc asc_bv_popup {menu x y {entry {}}} { |
545 |
#>> global bv |
546 |
#>> global tcl_platform |
547 |
#>> # if {($bv(popup) != "") || ($bv(postedMb) != "")} { |
548 |
#>> # catch {.balloon unpost} |
549 |
#>> # } |
550 |
#>> asc_bv_PostOverPoint $menu $x $y $entry |
551 |
#>>} |
552 |
#>> |
553 |
#>> |
554 |
#>>proc asc_bv_PostOverPoint {menu x y {entry {}}} { |
555 |
#>> global tcl_platform |
556 |
#>> # this function needs to be smarter about off screen popups |
557 |
#>> wm geometry .balloon "+$x+$y" |
558 |
#>> wm deiconify .balloon |
559 |
#>>} |
560 |
|