source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/lib/linux/tk8.4/demos/menu.tcl @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 6.6 KB
Line 
1# menu.tcl --
2#
3# This demonstration script creates a window with a bunch of menus
4# and cascaded menus using menubars.
5#
6# RCS: @(#) $Id: menu.tcl,v 1.4 2002/08/31 06:12:28 das Exp $
7
8if {![info exists widgetDemo]} {
9    error "This script should be run from the \"widget\" demo."
10}
11
12set w .menu
13catch {destroy $w}
14toplevel $w
15wm title $w "Menu Demonstration"
16wm iconname $w "menu"
17positionWindow $w
18
19label $w.msg -font $font -wraplength 4i -justify left
20if {[string equal [tk windowingsystem] "classic"]
21        || [string equal [tk windowingsystem] "aqua"]} {
22    $w.msg configure -text "This window contains a menubar with cascaded menus.  You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse."
23} else {
24    $w.msg configure -text "This window contains a menubar with cascaded menus.  You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu.  You can then traverse among the menus using the arrow keys.  When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character.  If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu."
25}
26pack $w.msg -side top
27
28set menustatus "    "
29frame $w.statusBar
30label $w.statusBar.label -textvariable menustatus -relief sunken -bd 1 -font "Helvetica 10" -anchor w
31pack $w.statusBar.label -side left -padx 2 -expand yes -fill both
32pack $w.statusBar -side bottom -fill x -pady 2
33
34frame $w.buttons
35pack $w.buttons -side bottom -fill x -pady 2m
36button $w.buttons.dismiss -text Dismiss -command "destroy $w"
37button $w.buttons.code -text "See Code" -command "showCode $w"
38pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
39
40menu $w.menu -tearoff 0
41
42set m $w.menu.file
43menu $m -tearoff 0
44$w.menu add cascade -label "File" -menu $m -underline 0
45$m add command -label "Open..." -command {error "this is just a demo: no action has been defined for the \"Open...\" entry"}
46$m add command -label "New" -command {error "this is just a demo: no action has been defined for the \"New\" entry"}
47$m add command -label "Save" -command {error "this is just a demo: no action has been defined for the \"Save\" entry"}
48$m add command -label "Save As..." -command {error "this is just a demo: no action has been defined for the \"Save As...\" entry"}
49$m add separator
50$m add command -label "Print Setup..." -command {error "this is just a demo: no action has been defined for the \"Print Setup...\" entry"}
51$m add command -label "Print..." -command {error "this is just a demo: no action has been defined for the \"Print...\" entry"}
52$m add separator
53$m add command -label "Dismiss Menus Demo" -command "destroy $w"
54
55set m $w.menu.basic
56$w.menu add cascade -label "Basic" -menu $m -underline 0
57menu $m -tearoff 0
58$m add command -label "Long entry that does nothing"
59if {[string equal [tk windowingsystem] "classic"] 
60        || [string equal [tk windowingsystem] "aqua"]} {
61    set modifier Command
62} elseif {$tcl_platform(platform) == "windows"} {
63    set modifier Control
64} else {
65    set modifier Meta
66}
67foreach i {A B C D E F} {
68    $m add command -label "Print letter \"$i\"" -underline 14 \
69            -accelerator Meta+$i -command "puts $i" -accelerator $modifier+$i
70    bind $w <$modifier-[string tolower $i]> "puts $i"
71}
72
73set m $w.menu.cascade
74$w.menu add cascade -label "Cascades" -menu $m -underline 0
75menu $m -tearoff 0
76$m add command -label "Print hello" \
77        -command {puts stdout "Hello"} -accelerator $modifier+H -underline 6
78bind $w <$modifier-h> {puts stdout "Hello"}
79$m add command -label "Print goodbye" -command {\
80    puts stdout "Goodbye"} -accelerator $modifier+G -underline 6
81bind $w <$modifier-g> {puts stdout "Goodbye"}
82$m add cascade -label "Check buttons" \
83        -menu $w.menu.cascade.check -underline 0
84$m add cascade -label "Radio buttons" \
85        -menu $w.menu.cascade.radio -underline 0
86
87set m $w.menu.cascade.check
88menu $m -tearoff 0
89$m add check -label "Oil checked" -variable oil
90$m add check -label "Transmission checked" -variable trans
91$m add check -label "Brakes checked" -variable brakes
92$m add check -label "Lights checked" -variable lights
93$m add separator
94$m add command -label "Show current values" \
95    -command "showVars $w.menu.cascade.dialog oil trans brakes lights"
96$m invoke 1
97$m invoke 3
98
99set m $w.menu.cascade.radio
100menu $m -tearoff 0
101$m add radio -label "10 point" -variable pointSize -value 10
102$m add radio -label "14 point" -variable pointSize -value 14
103$m add radio -label "18 point" -variable pointSize -value 18
104$m add radio -label "24 point" -variable pointSize -value 24
105$m add radio -label "32 point" -variable pointSize -value 32
106$m add sep
107$m add radio -label "Roman" -variable style -value roman
108$m add radio -label "Bold" -variable style -value bold
109$m add radio -label "Italic" -variable style -value italic
110$m add sep
111$m add command -label "Show current values" \
112        -command "showVars $w.menu.cascade.dialog pointSize style"
113$m invoke 1
114$m invoke 7
115
116set m $w.menu.icon
117$w.menu add cascade -label "Icons" -menu $m -underline 0
118menu $m -tearoff 0
119$m add command \
120    -bitmap @[file join $tk_library demos images pattern.bmp] \
121    -hidemargin 1 \
122    -command {
123        tk_dialog .pattern {Bitmap Menu Entry} {The menu entry you invoked displays a bitmap rather than a text string.  Other than this, it is just like any other menu entry.} {} 0 OK
124}
125foreach i {info questhead error} {
126    $m add command -bitmap $i -command "puts {You invoked the $i bitmap}" -hidemargin 1
127}
128$m entryconfigure 2 -columnbreak 1
129
130set m $w.menu.more
131$w.menu add cascade -label "More" -menu $m -underline 0
132menu $m -tearoff 0
133foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Make life meaningful}} {
134    $m add command -label $i -command [list puts "You invoked \"$i\""]
135}
136$m entryconfigure "Does almost nothing" \
137        -bitmap questhead  -compound left  -command {
138    tk_dialog .compound {Compound Menu Entry} {The menu entry you invoked\
139            displays both a bitmap and a text string.  Other than this, it\
140            is just like any other menu entry.} {} 0 OK
141}
142
143set m $w.menu.colors
144$w.menu add cascade -label "Colors" -menu $m -underline 1
145menu $m
146foreach i {red orange yellow green blue} {
147    $m add command -label $i -background $i \
148            -command [list puts "You invoked \"$i\""]
149}
150
151$w configure -menu $w.menu
152
153bind Menu <<MenuSelect>> {
154    global $menustatus
155    if {[catch {%W entrycget active -label} label]} {
156        set label "    "
157    }
158    set menustatus $label
159    update idletasks
160}
Note: See TracBrowser for help on using the repository browser.