OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [iwidgets3.0.0/] [doc/] [menubar.n] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1995 DSC Technologies Corporation
3
'\"
4
'\" See the file "license.terms" for information on usage and redistribution
5
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
'\"
7
'\" @(#) menubar.n
8
'/"
9
.so man.macros
10
.HS menubar iwid
11
.BS
12
'\" Note:  do not modify the .SH NAME line immediately below!
13
.SH NAME
14
menubar \- Create and manipulate menubar menu widgets
15
.SH SYNOPSIS
16
\fBmenubar\fR \fIpathName\fR ?\fIoptions\fR?
17
.SH "INHERITANCE"
18
itk::Widget <- menubar
19
.SH "STANDARD OPTIONS"
20
.LP
21
.nf
22
.ta 4c 8c 12c
23
\fBactiveBackground\fR  \fBborderWidth\fR       \fBhighlightBackground\fR       \fBpadY\fR
24
\fBactiveBorderWidth\fR \fBcursor\fR    \fBhighligthThickness\fR        \fBrelief\fR
25
\fBactiveForeground\fR  \fBdisabledForeground\fR        \fBhighlightColor\fR    \fBwrapLength\fR
26
\fBanchor\fR    \fBfont\fR      \fBjustify\fR
27
\fBbackground\fR        \fBforeground\fR        \fBpadX\fR
28
.fi
29
.LP
30
See the "options" manual entry for details on the standard options.
31
.SH "WIDGET-SPECIFIC OPTIONS"
32
.LP
33
.nf
34
Name:   \fBhelpVariable\fR
35
Class:  \fBHelpVariable\fR
36
Command-Line Switch:    \fB-helpvariable\fR
37
.fi
38
.IP
39
Specifies the global variable to update whenever the mouse is in motion over a menu entry. This global variable is updated with the current value of the active menu entry's \fBhelpStr\fR. Other widgets can "watch" this variable with the trace command, or as is the case with entry or label widgets, they can set their \fBtextVariable\fR to the same global variable. This allows for a simple implementation of a help status bar. Whenever the mouse leaves a menu entry, the helpVariable is set to the empty string {}. The mainwindow(1) associates its helpstatus and its menubar in this fashion.
40
.LP
41
.nf
42
Name:   \fBmenuButtons\fR
43
Class:  \fBMenuButtons\fR
44
Command-Line Switch:    \fB-menubuttons\fR
45
.fi
46
.IP
47
The menuButton option is a string which specifies the arrangement of menubuttons on the menubar frame. Each menubutton entry is delimited by the newline character.
48
.nf
49
.IP
50
.ta 2c 8c 12c
51
menubar .mb -menubuttons {
52
        menubutton file -text File
53
        menubutton edit -text Edit
54
        menubutton options -text Options
55
}
56
.fi
57
.IP
58
specifies that three menubuttons will be added to the menubar (file, edit, options). Each entry is translated into an add command call.
59
.IP
60
The \fBmenuButtons\fR option can accept embedded variables, commands, and
61
backslash quoting. Embedded variables and commands must be enclosed in
62
curly braces ({}) to ensure proper parsing of the substituted values.
63
.BE
64
.SH DESCRIPTION
65
.PP
66
The \fBmenubar\fR command creates a new window (given by the \fIpathName\fR argument) and makes it into a \fBmenubar\fR menu widget. Additional options, described above may be specified on the command line or in the option database to configure aspects of the menubar such as its colors and font. The \fBmenubar\fR command returns its \fIpathName\fR argument. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.
67
.PP
68
A \fBmenubar\fR is a widget that simplifies the task of creating menu hierarchies. It encapsulates a \fBframe\fR widget, as well as \fBmenubuttons\fR, \fBmenus\fR, and menu \fBentries\fR. The menubar allows menus to be specified and referenced in a more consistent manner than using Tk to build menus directly.
69
 
70
\fBMenubar\fR allows a menu tree to be expressed in a hierachical "language". The \fBmenubar\fR accepts a \fBmenuButtons\fR option that allows a list of menubuttons to be added to the menubar. In turn, each menubutton accepts a \fBmenu\fR option that specifies a list of menu entries to be added to the menubutton's menu. Cascade entries also accept the \fBmenu\fR option for specifying a list of menu entries to be added to the cascade's menu.
71
 
72
Additionally, the menubar allows each component of the menubar system to be referenced by a simple \fImenuPathName\fR syntax. The menubar also extends the set of options for menu entries to include a \fBhelpStr\fR option.
73
.SH "MENU PATH NAMES"
74
.PP
75
A \fImenuPathName\fR is a series of component names separated by the `.' character. Each menubar component can be referenced via these \fImenuPathNames\fR. \fImenuPathNames\fR are similar to widget pathNames in Tk. Some correspond directly to a widget pathName (components of type \fBmenu\fR or \fBmenubutton\fR), others correspond to a menu entry type. Every widget and entry in a menubar can be referenced with the \fImenuPathName\fR naming convention. A menubar can have four types of components:
76
.IP
77
\fBframe\fR. A menubar holds exactly one frame which manages menubuttons. The frame is always signified by the `.' character as the path name.
78
.IP
79
\fBmenubutton\fR. A menubutton corresponds directly to a Tk menubutton. See menubutton(n).
80
.IP
81
\fBmenu\fR. A menu is attached to a menubutton and corresponds directly to Tk's menu widget. A menu is always signified by the \fImenuPathName\fR ending with the keyword \fBmenu\fR. See menu(n).
82
.IP
83
\fBentry\fR. An entry corresponds directly to Tk's menu widget entries. Menus consist of a column of one line entries. Entries may be of type: \fBcommand\fR, \fBcheckbutton\fR, \fBradiobutton\fR, \fBseparator\fR, or \fBcascade\fR. For a complete description of these types see the discussion on \fBENTRIES\fR in menu(n).
84
.PP
85
The suffix of a \fImenuPathName\fR may have the form of:
86
.TP 14
87
\fItkWidgetName\fR
88
Specifies the name of the component, either a \fBframe\fR, \fBmenubutton\fR, \fBmenu\fR, or an \fBentry\fR. This is the normal naming of widgets. For example, .file references a \fBmenubutton\fR named \fIfile\fR.
89
.PP
90
The \fImenuPathName\fR is a series of segment names, each separated by the '.' character. Segment names may be one of the following forms:
91
.TP 14
92
\fInumber\fR
93
Specifies the index of the the component. For menubuttons, 0 corresponds to the left-most menubutton of the menu bar frame. As an example, \fI.1\fR would correspond to the second menubutton on the menu bar frame.
94
.IP
95
For entries, 0 corresponds to the top-most entry of the menu. For example, .file.0 would correspond to the first entry on the menu attached to the menubutton named \fIfile\fR.
96
.TP 14
97
\fBend\fR
98
Specifes the last component. For menubuttons, it specifies the right-most entry of the menu bar frame. For menu entries, it specifies the bottom-most entry of the menu.
99
.TP 14
100
\fBlast\fR
101
Same as end.
102
.PP
103
Finally, menu components always end with the \fBmenu\fR keyword. These components are automatically created via the -menu option on menubuttons and cascades or via the \fBadd\fR or \fBinsert\fR commands.
104
.TP 14
105
\fBmenu\fR
106
Specifes the menu pane that is associated with the given menubutton prefix. For example, \fI.file.menu\fR specifies the menu pane attached to the \fI.file\fR menubutton.
107
.PP
108
For example, the path \fI.file.new\fR specifies the entry named new on the menu associated with the file menubutton located on the menu bar. The path \fI.file.menu\fR specifies the menu pane associated with the menubutton \fI.file\fR. The path \fI.last\fR specifies the last menu on the menu bar. The path \fI.0.last\fR would specify the first menu (file) and the last entry on that menu (quit), yielding \fI.file.quit\fR.
109
 
110
As a restriction, the last name segment of \fImenuPathName\fR cannot be one of the keywords last, menu, end, nor may it be a numeric value (integer).
111
.SH "WIDGET-SPECIFIC METHODS"
112
.PP
113
The \fBmenubar\fR command creates a new Tcl command whose name is \fIpathName\fR.
114
This command may be used to invoke various operations on the widget. It has
115
the following general form:
116
.DS C
117
\fIpathName option \fR?\fIarg arg ...\fR?
118
.DE
119
\fIoption\fR and the \fIarg\fRs
120
determine the exact behavior of the command.
121
.PP
122
In addition, many of the widget commands for menubar take as one argument a path name to a menu component. These path names are called \fImenuPathName\fRs. See the discussion on \fBMENUBAR PATH NAMES\fR above.
123
.PP
124
The following commands are possible for menubar widgets:
125
.TP
126
\fIpathName\fR \fBadd\fR \fItype\fR \fImenuPathName\fR ?\fIoption value option value\fR?
127
Adds either a menu to the menu bar or a menu entry to a menu pane.
128
.IP
129
If additional arguments are present, they specify \fIoption\fRs available to component type \fBentry\fR. See the man pages for \fBmenu\fR(1) in the section on \fBENTRIES\fR.
130
 
131
If \fItype\fR is one of \fBcascade\fR, \fBcheckbutton\fR, \fBcommand\fR, \fBradiobutton\fR, or \fBseparator\fR it adds a new entry to the bottom of the menu denoted by the prefix of \fImenuPathName\fR. If additonal arguments are present, they specify options available to menu \fBentry\fR widgets. In addition, the \fBhelpStr\fR option is added by the menubar widget to all components of type entry.
132
.RS
133
.TP
134
\fB-helpstr\fR \fIvalue\fR
135
Specifes the string to associate with the entry. When the mouse moves over the associated entry, the variable denoted by \fBhelpVariable\fR is set. Another widget can bind to the helpVariable and thus display status help.
136
.RE
137
.IP
138
If the type of the component added is \fBmenubutton\fR or \fBcascade\fR, a menubutton or cascade is added to the menubar. If additional arguments are present, they specify options available to menubutton or cascade widgets. In addition, the \fBmenu\fR option is added by the menubar widget to all menubutton and cascade widgets.
139
.RS
140
.TP
141
\fB-menu\fR \fImenuSpec\fR
142
This is only valid for \fImenuPathName\fRs of type \fBmenubutton\fR or \fBcascade\fR. Specifes an option set and/or a set of entries to place on a menu and associate with the menubutton or cascade. The \fBoption\fR keyword allows the menu widget to be configured. Each item in the \fImenuSpec\fR is treated as add commands (each with the possibility of having other -menu options). In this way a menu can be recursively built.
143
.IP
144
The last segment of \fImenuPathName\fR cannot be one of the keywords \fBlast\fR, \fBmenu\fR, \fBend\fR. Additionally, it may not be a \fInumber\fR. However the \fImenuPathName\fR may be referenced in this manner (see discussion of \fBCOMPONENT PATH NAMES\fR).
145
.IP
146
Note that the same curly brace quoting rules apply to \fB-menu\fR option strings as did to \fB-menubuttons\fR option strings. See the earlier discussion on \fBumenubuttons\fR in the "\fBWIDGET-SPECIFIC OPTIONS\fR" section.
147
.RE
148
.TP
149
\fIpathName\fR \fBcget\fR \fIoption\fR
150
Returns the current value of the configuration option given by \fIoption\fR.
151
.TP
152
\fIpathName\fR \fBconfigure\fR ?\fIoptions\fR \fIvalue\fR \fIoption\fR \fIvalue\fR?
153
Query or modify the configuration options of the widget. If no \fIoption\fR is specified, returns a list describing all of the available options for \fBpathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). If \fIoption\fR is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string.
154
.TP
155
\fIpathName\fR \fBdelete\fR \fImenuPathName\fR ?\fImenuPathName2\fR?
156
If \fImenuPathName\fR is of component type \fBMenubutton\fR or \fBMenu\fR, delete operates on menus. If \fImenuPathName\fR is of component type \fBEntry\fR, delete operates on menu entries.
157
 
158
This command deletes all components between \fImenuPathName\fR and \fImenuPathName2\fR inclusive. If \fImenuPathName2\fR is omitted then it defaults to \fImenuPathName\fR. Returns an empty string.
159
 
160
If \fImenuPathName\fR is of type menubar, then all menus and the menu bar frame will be destroyed. In this case \fImenuPathName2\fR is ignored.
161
.TP
162
\fIpathName\fR \fBindex\fR \fImenuPathName\fR
163
If \fImenuPathName\fR is of type menubutton or menu, it returns the position of the menu/menubutton on the menubar frame.
164
 
165
If \fImenuPathName\fR is of type \fBcommand\fR, \fBseparator\fR, \fBradiobutton\fR, \fBcheckbutton\fR, or \fBcascade\fR, it returns the menu widget's numerical index for the entry corresponding to \fImenuPathName\fR. If path is not found or the path is equal to ".", a value of -1 is returned.
166
.TP
167
\fIpathName\fR \fBinsert\fR \fImenuPathName\fR \fItype\fR \fIname\fR ?\fIoption\fR \fIvalue\fR?
168
Insert a new component named name before the component specified by \fImenuPathName\fR.
169
.IP
170
If \fImenuPathName\fR is of type \fBMenubutton\fR or \fBMenu\fR, the new component inserted is of type \fBMenu\fR and given the name name. In this case valid \fIoption\fR \fIvalue\fR pairs are those accepted by menubuttons.
171
.IP
172
If \fImenuPathName\fR is of type \fBEntry\fR, the new component inserted is of type \fBentry\fR and given the name \fIname\fR. In this case, valid \fIoption\fR \fIvalue\fR pairs are those accepted by menu entries.
173
\fIName\fR cannot be one of the keywords \fBlast\fR, \fBmenu\fR, \fBend\fR. Additionally, it may not be a number. However the \fImenuPathName\fR may be referenced in this manner (see discussion of \fBCOMPONENT PATH NAMES\fR).
174
.TP
175
\fIpathName\fR \fBinvoke\fR \fImenuPathName\fR
176
Invoke the action of the menu entry denoted by \fImenuPathName\fR. See the sections on the individual entries in the menu(1) man pages. If the menu entry is disabled then nothing happens. If the entry has a command associated with it then the result of that command is returned as the result of the \fBinvoke\fR widget command. Otherwise the result is an empty string.
177
 
178
If \fImenuPathName\fR is not a menu entry, an error is issued.
179
.TP
180
\fIpathName\fR \fBmenucget\fR \fImenuPathName\fR \fIoption\fR
181
Returns the current value of the configuration option given by \fIoption\fR. The component type of \fImenuPathName\fR determines the valid available options.
182
.TP
183
\fIpathName\fR \fBmenuconfigure\fR \fImenuPathName\fR ?\fIoption\fR \fIvalue\fR?
184
Query or modify the configuration options of the componet of the menubar specified by \fImenuPathName\fR. If no \fIoption\fR is specified, returns a list describing all of the available options for \fImenuPathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). If \fIoption\fR is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. The component type of \fImenuPathName\fR determines the valid available options.
185
.TP
186
\fIpathName\fR \fBpath\fR ?\fImode\fR? \fIpattern\fR
187
Returns a fully formed \fImenuPathName\fR that matches \fIpattern\fR. If no match is found it returns -1. The \fImode\fR argument indicates how the search is to be matched against \fIpattern\fR and it must have one of the following values:
188
.RS
189
.TP
190
\fB-glob\fR
191
Pattern is a glob-style pattern which is matched against each component path using the same rules as the string match command.
192
.TP
193
\fB-regexp\fR
194
Pattern is treated as a regular expression and matched against each component of the \fImenuPathName\fR using the same rules as the regexp command.
195
The default mode is -glob.
196
.RE
197
.TP
198
\fIpathName\fR \fBtype\fR \fImenuPathName\fR
199
Returns the type of the component specified by \fImenuPathName\fR. For menu entries, this is the type argument passed to the \fBadd\fR/\fBinsert\fR widget command when the entry was created, such as \fBcommand\fR or \fBseparator\fR. Othewise it is either a \fBmenubutton\fR or a \fBmenu\fR.
200
.TP
201
\fIpathName\fR \fByposition\fR \fImenuPathName\fR
202
Returns a decimal string giving the y-coordinate within the menu window of the topmost pixel in the entry specified by \fImenuPathName\fR. If the \fImenuPathName\fR is not an entry, an error is issued.
203
.SH "EXAMPLE ONE: USING GRAMMAR"
204
.PP
205
The following example creates a menubar with "File", "Edit", "Options" menubuttons. Each of these menubuttons has an associated menu.
206
In turn the File menu has menu entries, as well as the Edit
207
menu and the Options menu. The Options menu is a tearoff menu
208
with selectColor (for radiobuttons) set to blue.
209
In addition, the Options menu has a cascade titled More,
210
with several menu entries attached to it as well. An entry widget is
211
provided to display help status.
212
.PP
213
menubar .mb -helpvariable helpVar -menubuttons {
214
    menubutton file -text File -menu {
215
        options -tearoff false
216
        command new -label New \\
217
            -helpstr "Open new document" \\
218
            -command {puts NEW}
219
        command close -label Close \\
220
            -helpstr "Close current document" \\
221
            -command {puts CLOSE}
222
        separator sep1
223
        command exit -label Exit -command {exit} \\
224
            -helpstr "Exit application"
225
    }
226
    menubutton edit -text Edit -menu {
227
        options -tearoff false
228
        command undo -label Undo -underline 0 \\
229
            -helpstr "Undo last command" \\
230
            -command {puts UNDO}
231
        separator sep2
232
        command cut -label Cut -underline 1 \\
233
            -helpstr "Cut selection to clipboard" \\
234
            -command {puts CUT}
235
        command copy -label Copy -underline 1 \\
236
            -helpstr "Copy selection to clipboard" \\
237
            -command {puts COPY}
238
        command paste -label Paste -underline 0 \\
239
            -helpstr "Paste clipboard contents" \\
240
            -command {puts PASTE}
241
    }
242
    menubutton options -text Options -menu {
243
        options -tearoff false -selectcolor blue
244
        radiobutton byName -variable viewMode \\
245
            -value NAME -label "by Name" \\
246
            -helpstr "View files by name order" \\
247
            -command {puts NAME}
248
        radiobutton byDate -variable viewMode \\
249
            -value DATE -label "by Date" \\
250
            -helpstr "View files by date order" \\
251
            -command {puts DATE}
252
        cascade prefs -label Preferences -menu {
253
            command colors -label Colors... \\
254
                -helpstr "Change text colors" \\
255
                -command {puts COLORS}
256
            command fonts -label Fonts... \\
257
                -helpstr "Change text font" \\
258
                -command {puts FONT}
259
        }
260
    }
261
 
262
}
263
.if
264
.nf
265
frame .fr -width 300 -height 300
266
entry .ef -textvariable helpVar
267
pack .mb -anchor nw -fill x -expand yes
268
pack .fr -fill both -expand yes
269
pack .ef -anchor sw -fill x -expand yes
270
.if
271
.SH "EXAMPLE TWO: USING METHODS"
272
Alternatively the same menu could be created by using the add and configure methods:
273
.PP
274
.nf
275
.ta 2c 4c 6c 8c 10c 12c 14c 16c
276
 menubar .mb
277
 .mb configure -menubuttons {
278
        menubutton file -text File -menu {
279
                command new -label New
280
                command close -label Close
281
                separator sep1
282
                command         quit -label Quit
283
        }
284
        menubutton edit -text Edit
285
 }
286
.if
287
.PP
288
 .mb add command .edit.undo -label Undo -underline 0
289
 .mb add separator .edit.sep2
290
 .mb add command .edit.cut -label Cut -underline 1
291
 .mb add command .edit.copy -label Copy -underline 1
292
 .mb add command .edit.paste -label Paste -underline 0
293
 
294
 .mb add menubutton .options -text Options -menu {
295
        radiobutton byName -variable viewMode \\
296
                 -value NAME -label "by Name"
297
        radiobutton byDate -variable viewMode \\
298
                 -value DATE -label "by Date"
299
}
300
 
301
 .mb add cascade .options.prefs -label Preferences -menu {
302
                command colors -label Colors...
303
                command fonts -label Fonts...
304
 }
305
 pack .mb -side left -anchor nw -fill x -expand yes
306
.SH CAVEATS
307
The \fB-menubuttons\fR option as well as the \fB-menu\fR option is evaluated by menubar with the \fBsubst\fR command. The positive side of this is that the option string may contain variables, commands, and/or backslash substitutions. However, substitutions might expand into more than a single word. These expansions can be protected by enclosing candidate substitutions in curly braces ({}). This ensures, for example, a value for an option will still be treated as a single value and not multiple values. The following example illustrates this case:
308
.nf
309
.IP
310
.ta 2c 4c 6c
311
set fileMenuName "File Menu"
312
set var {}
313
menubar .mb -menubuttons {
314
        menubutton file -text {$fileMenuName}
315
        menubutton edit -text Edit -menu {
316
                checkbutton check \\
317
                        -label Check \\
318
                        -variable {[scope var]} \\
319
                        -onvalue 1 \\
320
                        -offvalue 0
321
        }
322
        menubutton options -text Options
323
}
324
.fi
325
.IP
326
The variable \fIfileMenuName\fR will expand to "File Menu" when the \fBsubst\fR command is used on the menubutton specification. In addition, the [\fBscope\fR...] command will expand to @scope :: var. By enclosing these inside {} they stay as a single value. Note that only {} work for this. [list...], "" etc. will not protect these from the subst command.
327
.SH ACKNOWLEDGMENTS
328
.LP
329
Bret Schumaker
330
.IP
331
1994 - Early work on a menubar widget.
332
.LP
333
Mark Ulferts, Mark Harrison, John Sigler
334
.IP
335
Invaluable feedback on grammar and usability of the menubar widget
336
.LP
337
.SH AUTHOR
338
Bill W. Scott
339
.SH KEYWORDS
340
frame, menu, menubutton, entries, help
341
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.