summaryrefslogtreecommitdiff
path: root/itcl/iwidgets3.0.0/demos/mainwindow
blob: b04934211a88224e12cb1e372acb243d140958c1 (plain)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/sh
# ----------------------------------------------------------------------
#  DEMO: mainwindow in [incr Widgets]
# ----------------------------------------------------------------------
#\
exec itkwish "$0" ${1+"$@"}
package require Iwidgets 3.0

#
# Demo script for the Mainwindow class
#
iwidgets::mainwindow .mw

set imagedir [file join ${iwidgets::library} demos images]

#
# Add a File menubutton
#
.mw menubar add menubutton file -text "File" -underline 0 -padx 8 -pady 2 \
    -menu {options -tearoff no
	   command new -label "New" -underline 0 \
	       -helpstr "Create a new file"
	   command open -label "Open ..." -underline 0 \
	       -helpstr "Open an existing file"
	   command save -label "Save" -underline 0 \
	       -helpstr "Save the current file"
	   command saveas -label "Save As ..." -underline 5 \
	       -helpstr "Save the file as a differnet name"
	   command print -label "Print" -underline 0 \
	       -helpstr "Print the file"
           separator sep1
	   command close -label "Close" -underline 0 \
	       -helpstr "Close the file"
	   separator sep2
	   command exit -label "Exit" -underline 1 \
	       -helpstr "Exit this application" -command ::exit
    }

#
# Add the Edit menubutton.
#
.mw menubar add menubutton edit -text "Edit" -underline 0 -padx 8 -pady 2 \
    -menu {options -tearoff no
	   command cut -label "Cut" -underline 2 \
	       -helpstr "Cut the selection into the clipboard"
           command copy -label "Copy" -underline 0 \
	       -helpstr "Copy the selection to the clipboard"
           command paste -label "Paste" -underline 0 \
	       -helpstr "Paste the clipboard to the current point"
           separator sep3
           command find -label "Find" -underline 2 \
	       -helpstr "Search the text"
           separator sep4
           command clear -label "Clear" -underline 2 \
	       -helpstr "Clear the selection"
    }

#
# Add the Help menubutton.
#
.mw menubar add menubutton help -text "Help" -underline 0 -padx 8 -pady 2 \
    -menu {options -tearoff no
	   command onwindow -label "On Window" -underline 3 \
	       -helpstr "Obtain help on the window"
           command onkeys -label "On Keys" -underline 3 \
	       -helpstr "Obtain help on the keys"
           command index -label "Index" -underline 0 \
	       -helpstr "View the help index"
           command onhelp -label "On Help" -underline 2 \
	       -helpstr "Obtain help on help"
           command onversion -label "On Version" -underline 2 \
	       -helpstr "View the version information"
    }

#
# Add items to the toolbar.
#
.mw toolbar add frame filler1 -width 108 -relief raised -borderwidth 2

.mw toolbar add button new \
    -image [image create photo new-img -file [file join $imagedir new.gif]] \
    -helpstr "Create a new file" \
    -balloonstr "New"

.mw toolbar add button open \
    -image [image create photo open-img -file [file join $imagedir open.gif]] \
    -helpstr "Open an existing file" \
    -balloonstr "Open"

.mw toolbar add button close \
    -image [image create photo close-img -file [file join $imagedir close.gif]] \
    -helpstr "Close the file" \
    -balloonstr "Close"

.mw toolbar add frame filler2 -width 20 -relief raised -borderwidth 2

.mw toolbar add button cut \
    -image [image create photo cut-img -file [file join $imagedir cut.gif]] \
    -helpstr "Cut the selection into the cut buffer" \
    -balloonstr "Cut"

.mw toolbar add button copy \
    -image [image create photo copy-img -file [file join $imagedir copy.gif]] \
    -helpstr "Copy the selection to the cut buffer" \
    -balloonstr "Copy"

.mw toolbar add button paste \
    -image [image create photo paste-img -file [file join $imagedir paste.gif]] \
    -helpstr "Paste the cut buffer to the current point" \
    -balloonstr "Paste"

.mw toolbar add button clear \
    -image [image create photo clear-img -file [file join $imagedir clear.gif]] \
    -helpstr "Clear the selection" \
    -balloonstr "Clear"

.mw toolbar add frame filler3 -relief raised -borderwidth 2

#
# Add items to the menubar.
#
.mw mousebar add button save \
    -image [image create photo save-img -file [file join $imagedir save.gif]] \
    -helpstr "Save the current file"

.mw mousebar add button print \
    -image [image create photo print-img -file [file join $imagedir print.gif]] \
    -helpstr "Print the file"

.mw mousebar add button find \
    -image [image create photo find-img -file [file join $imagedir find.gif]] \
    -helpstr "Search the text"

.mw mousebar add frame filler1 -height 20 -relief raised -borderwidth 2

.mw mousebar add button help \
    -image [image create photo help-img -file [file join $imagedir help.gif]] \
    -helpstr "Obtain help for this window"

.mw mousebar add frame filler2 -relief raised -borderwidth 2

.mw mousebar add button exit \
    -image [image create photo exit-img -file [file join $imagedir exit.gif]] \
    -helpstr "Exit this application" -command ::exit

.mw mousebar add frame filler3 -height 5

#
# Change the packing of the last fillers in the tool and mouse bar
# so that it expands across and down the rest of the mainwindow.
#
pack [.mw toolbar component filler3] -expand yes -fill both
pack [.mw mousebar component filler2] -expand yes -fill both


#
# Install a scrolledtext widget in the childsite.
#
iwidgets::scrolledtext [.mw childsite].st -visibleitems 40x8
pack [.mw childsite].st -fill both -expand yes

#
# Activate the main window.
#
.mw activate