forked from gambit/gambit
/
fig16-15.scm
executable file
·123 lines (102 loc) · 3.99 KB
/
fig16-15.scm
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env gsi-script
; File: "fig16-15.scm"
; Copyright (c) 1997-2007 by Marc Feeley, All Rights Reserved.
; Translation into Scheme of Figure 16.15 from Chapter 16 of John
; Ousterhout's "Tcl and the Tk Toolkit".
(include "tcltk#.scm") ; import Tcl/Tk procedures and variables
(load "tcltk")
(define bold "bold")
(define italic "italic")
(define underline "underline")
(define font "font")
(define (bullet) (display "bullet") (newline))
(define (margins) (display "margins") (newline))
(frame ".mbar" relief: 'raised bd: 2)
(frame ".dummy" width: "10c" height: "5c")
(pack ".mbar" ".dummy" side: 'top fill: 'x)
(menubutton ".mbar.file" text: "File" underline: 0)
(menu ".mbar.file.menu")
(tcl ".mbar.file" 'configure menu: ".mbar.file.menu")
(menubutton ".mbar.edit" text: "Edit" underline: 0)
(menu ".mbar.edit.menu")
(tcl ".mbar.edit" 'configure menu: ".mbar.edit.menu")
(menubutton ".mbar.graphics" text: "Graphics" underline: 0)
(menu ".mbar.graphics.menu")
(tcl ".mbar.graphics" 'configure menu: ".mbar.graphics.menu")
(menubutton ".mbar.text" text: "Text" underline: 0)
(menu ".mbar.text.menu")
(tcl ".mbar.text" 'configure menu: ".mbar.text.menu")
(tcl ".mbar.text.menu" 'add 'checkbutton label: "Bold" variable: bold)
(tcl ".mbar.text.menu" 'add 'checkbutton label: "Italic" variable: italic)
(tcl ".mbar.text.menu" 'add 'checkbutton label: "Underline" variable: underline)
(tcl ".mbar.text.menu" 'add 'separator)
(tcl ".mbar.text.menu" 'add 'radiobutton label: "Times" variable: font
value: "times")
(tcl ".mbar.text.menu" 'add 'radiobutton label: "Helvetica" variable: font
value: "helvetica")
(tcl ".mbar.text.menu" 'add 'radiobutton label: "Courier" variable: font
value: "courier")
(tcl ".mbar.text.menu" 'add 'separator)
(tcl ".mbar.text.menu" 'add 'command label: "Insert Bullet" command: bullet)
(tcl ".mbar.text.menu" 'add 'command label: "Margins and Tabs..." command: margins)
(set-variable! font "courier")
(menubutton ".mbar.view" text: "View" underline: 0)
(menu ".mbar.view.menu")
(tcl ".mbar.view" 'configure menu: ".mbar.view.menu")
(menubutton ".mbar.help" text: "Help" underline: 0)
(menu ".mbar.help.menu")
(tcl ".mbar.help" 'configure menu: ".mbar.help.menu")
(pack ".mbar.file" ".mbar.edit" ".mbar.graphics" ".mbar.text" ".mbar.view" side: 'left)
(pack ".mbar.help" side: 'right)
(focus ".mbar")
; ==> Equivalent program in pure Tcl/Tk:
;
; frame .mbar -relief raised -bd 2
; frame .dummy -width 10c -height 5c
; pack .mbar .dummy -side top -fill x
;
; menubutton .mbar.file -text File -underline 0 -menu .mbar.file.menu
; menubutton .mbar.edit -text Edit -underline 0 -menu .mbar.edit.menu
; menubutton .mbar.graphics -text Graphics -underline 0 \
; -menu .mbar.graphics.menu
; menubutton .mbar.text -text Text -underline 0 -menu .mbar.text.menu
; menubutton .mbar.view -text View -underline 0 -menu .mbar.view.menu
; menubutton .mbar.help -text Help -underline 0 -menu .mbar.help.menu
;
; menu .mbar.file.menu
;
; menu .mbar.edit.menu
;
; menu .mbar.graphics.menu
;
; menu .mbar.text.menu
; .mbar.text.menu add checkbutton -label Bold -variable bold
; .mbar.text.menu add checkbutton -label Italic -variable italic
; .mbar.text.menu add checkbutton -label Underline -variable underline
; .mbar.text.menu add separator
; .mbar.text.menu add radiobutton -label Times -variable font -value times
; .mbar.text.menu add radiobutton -label Helvetica -variable font \
; -value helvetica
; .mbar.text.menu add radiobutton -label Courier -variable font -value courier
; .mbar.text.menu add separator
; .mbar.text.menu add command -label "Insert Bullet" -command bullet
; .mbar.text.menu add command -label "Margins and Tabs..." -command margins
;
; set font courier
;
; menu .mbar.view.menu
;
; menu .mbar.help.menu
;
; pack .mbar.file .mbar.edit .mbar.graphics .mbar.text .mbar.view -side left
; pack .mbar.help -side right
;
; focus .mbar
;
; proc bullet {} {
; puts "bullet"
; }
;
; proc margins {} {
; puts "margins"
; }