URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
578 |
markom |
# postghost.tcl - Ghost a menu item at post time.
|
2 |
|
|
# Copyright (C) 1997 Cygnus Solutions.
|
3 |
|
|
# Written by Tom Tromey <tromey@cygnus.com>.
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
# Helper proc.
|
7 |
|
|
proc GHOST_helper {menu index predicate} {
|
8 |
|
|
if {[eval $predicate]} then {
|
9 |
|
|
set state normal
|
10 |
|
|
} else {
|
11 |
|
|
set state disabled
|
12 |
|
|
}
|
13 |
|
|
$menu entryconfigure $index -state $state
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
# Add a -postcommand to a menu. This is careful not to stomp other
|
17 |
|
|
# postcommands.
|
18 |
|
|
proc add_post_command {menu callback} {
|
19 |
|
|
set old [$menu cget -postcommand]
|
20 |
|
|
# We use a "\n" and not a ";" to separate so that people can put
|
21 |
|
|
# comments into their -postcommands without fear.
|
22 |
|
|
$menu configure -postcommand "$old\n$callback"
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
# Run this to make a menu item which ghosts or unghosts depending on a
|
26 |
|
|
# predicate that is run at menu-post time. The NO_CACHE option
|
27 |
|
|
# prevents the index from being looked up statically; this is useful
|
28 |
|
|
# if you want to use an entry name as the index and you have a very
|
29 |
|
|
# dynamic menu (ie one where the numeric index of a named item is not
|
30 |
|
|
# constant over time). If PREDICATE returns 0 at post time, then the
|
31 |
|
|
# item will be ghosted.
|
32 |
|
|
proc ghosting_menu_item {menu index predicate {no_cache 0}} {
|
33 |
|
|
if {! $no_cache} then {
|
34 |
|
|
set index [$menu index $index]
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
add_post_command $menu [list GHOST_helper $menu $index $predicate]
|
38 |
|
|
}
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.