Debian Codegraph @

texmf-dist/source/latex/menu/menu.dtx

raw
1 \def\fileversion{v0.994}
2 \def\filedate{2007/11/18}
3 % ^^A For index and changes, run:
4 % ^^A makeindex -s gglo -o Menu.gls Menu.glo
5 % ^^A makeindex -s gind -o Menu.ind Menu.idx
6 %
7 % \CheckSum{237}
8 %%
9 %% \CharacterTable
10 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
11 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
12 %% Digits \0\1\2\3\4\5\6\7\8\9
13 %% Exclamation \! Double quote \" Hash (number) \#
14 %% Dollar \$ Percent \% Ampersand \&
15 %% Acute accent \' Left paren \( Right paren \)
16 %% Asterisk \* Plus \+ Comma \,
17 %% Minus \- Point \. Solidus \/
18 %% Colon \: Semicolon \; Less than \<
19 %% Equals \= Greater than \> Question mark \?
20 %% Commercial at \@ Left bracket \[ Backslash \\
21 %% Right bracket \] Circumflex \^ Underscore \_
22 %% Grave accent \` Left brace \{ Vertical bar \|
23 %% Right brace \} Tilde \~}
24 %%
25 % \DoNotIndex{\" , \-, \flqq,\frqq, \ ,\def, \begin, \end}
26 % \DoNotIndex{\csname,\endcsname, \expandafter, \global, \newcommand}
27 % \DoNotIndex{\advance, \filedate, \fileversion, \MessageBreak}
28 % \DoNotIndex{\newcount, \newcounter, \newif, \or}
29 % \DoNotIndex{\if, \else, \fi, \ifcase, \ifdefined, \ifnum, \ifx, \loop, \repeat}
30 % \DoNotIndex{\heartsuit}
31 % \DoNotIndex{\NeedsTeXFormat, \providecommand, \ProvidesPackage, \relax, \RequirePackage}
32 % \DoNotIndex{\par, \chapter, \section, \subsection, \subsubsection, \paragraph, }
33 % \DoNotIndex{\selectlanguage, \stepcounter, \ss, \space, \setcounter}
34 % \DoNotIndex{\value, \typeout, \long, \renewcommand}
35 %
36 % \iffalse
37 %<*driver>
38 \documentclass{ltxdoc}
39 \usepackage{menu}
40 \usepackage{makeidx}
41 \usepackage[draft]{fixme}
42 %\IfFileExists{hyperref.sty}{\usepackage{hyperref}}{}
43 \IfFileExists{keystroke.sty}{
44 \usepackage{keystroke}
45 }{
46 \newcommand{\keystroke}[1]{\fbox{##1}}
47 }
48 \CodelineIndex
49 \makeindex
50 %\OnlyDescription
51 \begin{document}
52 \DocInput{menu.dtx}
53 \end{document}
54 %</driver>
55 %
56 %<*package>
57 % \fi
58 % \title{Menu.sty: Typesetting menus}
59 % \author{Knut Lickert}
60 % \maketitle
61 %
62 %\begin{abstract}
63 % Menu.sty define a command |\menu{Programm!!Menu1!Command}| and
64 % expand it to something like \menu{Programm!!Menu1!Command}. You
65 % can use it for documentations of programs.
66 %\end{abstract}
67 %
68 % \section{Where to use the style}
69 % If you write a documentation of a program you have to define
70 % things like "Push button \keystroke{F1} or go to the Menu to
71 % \menu{Help!Help} and you get help". This style help you to write
72 % the menu entry.
73 %
74 % \subsection{Other packages}
75 % I have not found a package to typeset menus (that's why this style
76 % was written). If you find one, please contact me
77 % ([email protected]).
78 %
79 % \begin{description}
80 % \item[keystroke]
81 % A \LaTeX\ package which provides macros for the graphical
82 % representation of the keys on a computer keyboard.\par
83 % Example: \Ctrl, \Shift \AltGr
84 % \end{description}
85 %
86 %
87 % \section{How to use the style}
88 % \subsection{Inline-Menu}
89 %
90 % \DescribeMacro{\menu}
91 % |\menu| has one parameter. The macro is used to typeset a path in a
92 % menu. Like |\index| different levels are separated with a "!"
93 % inside the parameter. Instead a "!" you can use two "!!" and so you
94 % can define bigger steps in the menu. I use programs, where a menu
95 % is starting another menu (e.g.\ in a popup). So instead of saying
96 % "Goto \menu{Menu1!Entry1!Menu2} and then from
97 % \menu{Menu2!Menu3!Entry3}" I write "Goto
98 % \menu{Menu1!Entry1!Menu2!!Menu3!Entry3}.
99 %
100 % Example:
101 % \verb|\menu{File!Save!!Filename}|: \menu{File!Save!!Filename}
102 %
103 % This is only to show one path in a menu.
104 % This command may not be used to show a complete menu.
105 % I recommand to make a snapshot of your programm and include the picture
106 % via \verb|includegraphics| (Package graphicx)
107 %
108 %
109 % \subsection{Menu-Figure}
110 % \fixme{Description}
111 %\DescribeEnv{menufolder}
112 %Number of parameter: 2
113 %
114 %\DescribeMacro{\menuitem}
115 %Number of parameter: 2
116 %
117 %\DescribeMacro{\menuitemactive}
118 %Number of parameter: 2
119 %
120 %\DescribeMacro{\menuseparator}
121 % Add a separator line. An optional length can be defined.
122 %
123 % Example:
124 %\begin{verbatim}
125 %\settowidth{\menuitemlength}{Close and d\underline on't save}
126 %\begin{menufolder}{\underline Menu}%
127 % \menuitem{Close and d\underline on't save}
128 % \menuitem{Close and sa\underline ve}
129 % \menuitemactive{I\underline tem}
130 %\end{menufolder}
131 %}
132 %\end{verbatim}
133
134 %\settowidth{\menuitemlength}{Close and d\underline on't save}
135 %\begin{menufolder}{\underline Menu}%
136 % \menuitem{Close and d\underline on't save}
137 % \menuitem{Close and sa\underline ve}
138 % \menuitemactive{I\underline tem}
139 %\end{menufolder}
140 %
141 %\subsubsection{Options}
142 %There are different options to modify the look of menus.
143 %
144 %\begin{description}
145 % \item[hand] The hand point to the active menu item.
146 % Requires bbding.
147 % \item[framed] The menu entries are framed
148 % \item[grey] framed and background values.\fixme{change
149 % option name}
150 %\end{description}
151 %
152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153 % \section{Changing the look}
154 % \DescribeMacro{\menutext}
155 % A step of a menu is written with this macro, default is
156 % |\texttt|. You can change it with |\renewcommand|, e.g.\
157 % |\renewcommand{\menutext}[1]{\emph{#1}|
158 %
159 % \subsection{Inline-Menus}
160 % \DescribeMacro{\menumathsymbols}
161 % If you want to replace the symbols, you can use |\menusymbols|.
162 % Parameter one is the flag for "!", Parameter for "!!"
163 % (Default is \(\rightarrow\) and \(\Rightarrow\)).
164 %
165 % \DescribeMacro{\menusymbols}
166 % Like |\menumathsymbols| with two differences:
167 % \begin{itemize}
168 % \item There is no math-environment (if you need it, you can
169 % guarantee it with |\ensuremath|)
170 % \item There are two optional parameters, defining a start and
171 % end command of a menu.
172 % \end{itemize}
173 % This command gives you a flexible possibility to change the look
174 % of menus.
175 %
176 % \begin{description}
177 % \item[$\backslash$menusymbols] Define a style with the parameters:
178 % \item[{[Start]}] How should a menu start.\par
179 % A |\par| is not allowed, but you can use a |\\|. If a paragraph
180 % ends before the |\menu|, you must use |~\\| instead.
181 % \item[\{\}] The look/actions for a "!" in a menu.
182 % \item[\{\}] The look/actions for a "!!" in a menu.
183 % \item[{[End]}] How should a menu end.
184 % \end{description}
185 %
186 % \subsubsection{Examples}
187 % \newcommand{\example}[1]{\texttt{$\backslash$menu\{#1\}} & \menu{#1}\\}
188 %
189 % \paragraph{Predefined look}~\par
190 %
191 % \begin{tabular}{ll}
192 % Coding & Result\\\hline
193 % \example{Menu!Menu}
194 % \example{Menu!!Menu}
195 % \example{Menu!!Next Menu!Entry}
196 % \end{tabular}
197 %
198 % \paragraph{Changed symbols}
199 %
200 % After |\menumathsymbols{>}{\gg}| you get\par
201 % \menumathsymbols{>}{\gg}
202 % \begin{tabular}{ll}
203 % Coding & Result\\\hline
204 % \example{Menu!Menu}
205 % \example{Menu!!Menu}
206 % \example{Menu!!Next Menu!Entry}
207 % \end{tabular}
208 %
209 % Attention: If you want to change it local, you must define a
210 % block.
211 %
212 % \paragraph{Define your own styles}
213 %
214 % You can define your own "styles", |\menu{Menu!!Next Menu!Entry}|
215 % makes an entry like:
216 %
217 % \begin{minipage}[t]{0.5\textwidth}
218 %\begin{verbatim}
219 %\newlength{\menusep}
220 %\menusymbols[
221 % \setlength{\menusep}{0em}~\\
222 % ]{
223 % \\
224 % \addtolength{\menusep}{1em}
225 % \hspace*{\menusep}
226 % }{
227 % $\wr$\\
228 % \addtolength{\menusep}{2em}
229 % \hspace*{\menusep}
230 % }[
231 % \ensuremath{\Leftarrow}
232 % ]
233 %\end{verbatim}
234 % \end{minipage}
235 % \begin{minipage}[t]{0.4\textwidth}
236 % Example for a new style
237 % \menusymbols[\setlength{\menusep}{0em}~\\]{
238 % \\
239 % \addtolength{\menusep}{1em}
240 % \hspace*{\menusep}
241 % }{
242 % $\wr$\\
243 % \addtolength{\menusep}{2em}
244 % \hspace*{\menusep}
245 % }[
246 % \ensuremath{\Leftarrow}
247 % ]
248 % \menu{Menu!!Next Menu!Entry}
249 % \end{minipage}
250 %
251 % \subsection{Layout of Menu-figures}
252 %
253 % The macros can be replaced. See the implementation for examples.
254 %
255 % \fixme{describe length}
256 %
257 %\DescribeMacro{\menufolderentry}
258 % Defines the look of the entry of a menu.
259 % Parameters are length (optional) and text.
260 %
261 %\DescribeMacro{\menuitem}
262 % Defines the look of one item in the menu.
263 % Parameters are length (optional) and text.
264 %
265 %\DescribeMacro{\menuitemactive}
266 % Defines the look of an active item in the menu.
267 % Parameters are length (optional) and text.
268 %
269 %\DescribeMacro{\menuitemactivesymbol}
270 % This symbol is used to show to the active item.
271 %
272 % \subsubsection{Examples}
273 % \fixme{Examples}
274 %
275 % \section{Ideas for the future}
276 % \begin{itemize}
277 % \item Create Index entries for menus (optional)\par
278 % If I do it, it would be an additional index (style multind).
279 % I think this would be wrong in the normal index.
280 % \item An optional parameter: |\menu[Programm]{Menu!...}|\par
281 % Does anybody need it? At the moment I think there is no need.
282 % When there is the possibility of index entries, then it could be sensefull
283 % (Index is sorted by Programm, Menu1, Menu2\ldots).
284 % \item A command |\popup| or |\rightmouse| to define a click on the
285 % right mouse button. |\click[Feld]{menu!entry}|.
286 % This function could be a feature of the package keystroke.
287 % %^^A use mousesymbols.tex
288 % \end{itemize}
289 %
290 % Any comments? Up to now I don't need this features, so I will not
291 % implement them. If you need it, or think you have a better idea,
292 % send me a mail to [email protected].
293 %
294 % If you built your own "fancy" style, or have another idea to use
295 % "!!" and "!", please send me your idea.
296 %
297 % \StopEventually\relax
298 % \part*{Implementation}
299 % \begin{macrocode}
300 \NeedsTeXFormat{LaTeX2e}
301 \ProvidesPackage{menu}[
302 \filedate\space\fileversion\space menu-Package]
303 \typeout{menu.sty: Support of typeout menus}
304 \RequirePackage{xspace}
305 %\RequirePackage{keystroke}[2003/08/15 v1.5]
306 % \end{macrocode}
307 %
308 % \section{Commands}
309 % \begin{macro}{\menu}
310 % Take the parameter and send it with an endflag ("\(<\)") to |\@menu|.
311 % \begin{macrocode}
312 \newcommand{\menu}[1]{\@menusymbolStart\@menu #1!<\@menusymbolEnd}
313 % \end{macrocode}
314 % \end{macro}%^^A{\menu}
315 %
316 % \begin{macro}{\menutext}
317 % How to write one step of the menu?
318 % \begin{macrocode}
319 \newcommand{\menutext}[1]{\texttt{#1}}
320 % \end{macrocode}
321 % \end{macro}%^^A{\menu}
322 %
323 % \begin{macro}{\@menu}
324 % Get two parameters, separated with "!".
325 % Parameter one can be:
326 % \begin{macrocode}
327 \def\@menu#1!#2<{%
328 \def\@menuParOne{#1}%
329 \def\@menuParTwo{#2}%
330 \def\gt{!}%
331 % \end{macrocode}
332 % Check if the first parameter has content.
333 %
334 % \begin{macrocode}
335 \ifx\@empty\@menuParOne%
336 {\ifx\@menuParTwo\gt%
337 \else\expandafter\@menuTo\@menuParTwo <\@menu#2<%
338 \fi}%
339 \else%
340 % \end{macrocode}
341 % \changes{v0.994}{2007-11-18}{No separator for direct menu entries}
342 % First parameter has content, so let's print it.
343 % \begin{macrocode}
344 \menutext{#1}%
345 % \end{macrocode}
346 % Add a \verb|\@menuto| and the second part,
347 % but only if there is a second part.
348 % \begin{macrocode}
349 \ifx\@menuParTwo\@empty%
350 \else%
351 \expandafter\@menuto\@menuParTwo <\@menu#2!<%
352 \fi%
353 \fi%
354 }
355 % \end{macrocode}
356 % \end{macro}%^^A{\@menu}
357 % \begin{macro}{\@menuto}
358 % \begin{macrocode}
359 \def\@menuto#1#2<{\ifx!#1\else\@menusymbolOne\allowbreak\fi}
360 % \end{macrocode}
361 % \end{macro}%^^A{\menuto}
362 % \begin{macro}{\@menuTo}
363 % \begin{macrocode}
364 \def\@menuTo#1#2<{\ifx!#1\else\@menusymbolTwo\allowbreak\fi}
365 % \end{macrocode}
366 % \end{macro}%^^A{\menuTo}
367 %
368 % \section{The different symbols}
369 % \begin{macro}{\@menusymbolStart}
370 % The symbol, printed on start of |\menu|.
371 % \begin{macrocode}
372 \newcommand*\@menusymbolStart{}
373 \newcommand*\@menusymbolEnd{}
374 % \end{macrocode}
375 % \end{macro}%^^A{\@menusymbolOne}
376 %
377 % \begin{macro}{\@menusymbolOne}
378 % The symbol, printed when a "!" occurs in |\menu|.
379 % \begin{macrocode}
380 \newcommand*\@menusymbolOne{\ensuremath{\rightarrow}}
381 % \end{macrocode}
382 % \end{macro}%^^A{\@menusymbolOne}
383 % \begin{macro}{\@menusymbolTwo}
384 % The symbol, printed when a "!!" occurs in |\menu|.
385 % \begin{macrocode}
386 \newcommand*\@menusymbolTwo{\ensuremath{\Rightarrow}}
387 % \end{macrocode}
388 % \end{macro}%^^A{\@menusymbolTwo}
389 %
390 % \begin{macro}{\menusymbol}
391 % Possibility to redefine the symbols for "!" and "!!".
392 % \begin{macrocode}
393 \newcommand*\menusymbols[3][]{%
394 \renewcommand*\@menusymbolStart{#1}%
395 \renewcommand*\@menusymbolOne{#2}%
396 \renewcommand*\@menusymbolTwo{#3}%
397 \@menusymbols%
398 }
399 % \end{macrocode}
400 % \end{macro}%^^A{\@menusymbols}
401 %
402 % \begin{macro}{\@menusymbol}
403 % Define the End-Makro for a menu.
404 % \begin{macrocode}
405 \newcommand*\@menusymbols[1][]{%
406 \renewcommand*\@menusymbolEnd{#1}%
407 }
408 % \end{macrocode}
409 % \end{macro}%^^A{\@menusymbols}
410 % \begin{macro}{\menumathsymbols}
411 % Possibility to redefine the symbols for "!" and "!!".
412 % \begin{macrocode}
413 \newcommand*\menumathsymbols[3][]{
414 \renewcommand*\@menusymbolStart{\ensuremath{#1}}
415 \renewcommand*\@menusymbolOne{\ensuremath{#2}}
416 \renewcommand*\@menusymbolTwo{\ensuremath{#3}}
417 }
418 % \end{macrocode}
419 % \end{macro}%^^A{\@menumathsymbol}
420 %
421 % \section{The Predefined Layouts}
422 %
423 % \subsection{Standard}
424 % \begin{macrocode}
425 \menumathsymbols{\rightarrow}{\Rightarrow}
426 % \end{macrocode}
427 %
428 % \section{Menu-Drawings}
429 % \begin{macrocode}
430 \newlength{\menuitemlength}
431 \newlength{\menusep}
432 \setlength{\menuitemlength}{6em}
433 \setlength{\menusep}{3em}
434 % \end{macrocode}
435 % \begin{macro}{\menuitemactivesymbol}
436 % \begin{macrocode}
437 \newcommand\menuitemactivesymbol{\ensuremath{\Leftarrow}}%
438 % \end{macrocode}
439 % \end{macro}%^^A\menuitemactivesymbol
440 %
441 % \begin{environment}{menufolder}
442 % \fixme{parameter 1 must be a length (2cm results in 22cm)}
443 % A negative parskip results in an overlapping menu.
444 % \begin{macrocode}
445 \newenvironment{menufolder}[2][\menuitemlength]{%
446 \begin{minipage}{2#1}%
447 \setlength{\parskip}{0pt}%
448 \menufolderentry[#1]{#2}\par%
449 \addtolength{\leftskip}{\menusep}%
450 }{%
451 \end{minipage}%
452 }
453 % \end{macrocode}
454 % \end{environment}%^^Amenufolder
455 % \begin{macro}{\menufolderentry}
456 % \begin{macrocode}
457 \newcommand\menufolderentry[2][\menuitemlength]{%
458 \makebox[#1][l]{\menutext{#2}\hfill}%
459 }
460 % \end{macrocode}
461 % \end{macro}%^^A\menufolderentry
462 % \begin{macro}{\menuitem}
463 % \begin{macrocode}
464 \newcommand\menuitem[2][\menuitemlength]{%
465 \makebox[#1][l]{\menutext{#2}\hfill}\par%
466 }
467 % \end{macrocode}
468 % \end{macro}%^^A\menuitem
469 % \begin{macro}{\menuitemactive}
470 % \begin{macrocode}
471 \newcommand\menuitemactive[2][\menuitemlength]{%
472 \makebox[#1][l]{\menutext{\emph{#2}}\hfill\menuitemactivesymbol}\par%
473 }
474 % \end{macrocode}
475 % \end{macro}%^^A\menuitemactive
476 %
477 % \begin{macro}{\menuseparator}
478 %\fixme{besser positionieren (raisebox?)}
479 % \begin{macrocode}
480 \newcommand\menuseparator[1][\menuitemlength]{%
481 \makebox[#1][l]{~\hrulefill~}\par%
482 }
483 % \end{macrocode}
484 % \end{macro}%^^A\menuseparator
485 %
486 %\subsection{Options}
487 % \begin{macrocode}
488 \newif\ifmenuoptionhand
489 \DeclareOption{hand}{
490 \menuoptionhandtrue
491 }
492 % \end{macrocode}
493 %
494 % \begin{macrocode}
495 \newif\ifmenuoptionframed
496 \DeclareOption{framed}{
497 \menuoptionframedtrue
498 }
499 % \end{macrocode}
500 %
501 % \begin{macrocode}
502 \newif\ifmenuoptiongrey
503 \DeclareOption{grey}{
504 \menuoptiongreytrue
505 }
506 % \end{macrocode}
507 %
508 % Process the options to set the flags.
509 % \begin{macrocode}
510 \ProcessOptions\relax
511 % \end{macrocode}
512 %
513 %\subsubsection{Option hand}
514 % Activate the hand-option.
515 % \begin{macrocode}
516 \ifmenuoptionhand
517 \RequirePackage{bbding}%fuer \HandLeftUp
518 % \end{macrocode}
519 % \begin{macro}{\menuitemactivesymbol}
520 % \begin{macrocode}
521 \renewcommand\menuitemactivesymbol{\HandLeftUp}%
522 % \end{macrocode}
523 % \end{macro}%^^A{\menuitemactivesymbol}
524 % \begin{macrocode}
525 \fi%ifmenuoptionhand
526 % \end{macrocode}
527 %
528 %\subsubsection{Option framed}
529 % Activate the framed-option.
530 % \begin{macrocode}
531 \ifmenuoptionframed
532 \RequirePackage{fancybox}%fuer shadowbox
533 % \end{macrocode}
534 % \begin{macro}{\menufolderentry}
535 % \begin{macrocode}
536 \renewcommand\menufolderentry[2][\menuitemlength]{%
537 \framebox[#1][l]{\menutext{#2}\hfill}%
538 }
539 % \end{macrocode}
540 % \end{macro}%^^A\menufolderentry
541 % \begin{macro}{\menuitem}
542 % \begin{macrocode}
543 \renewcommand\menuitem[2][\menuitemlength]{%
544 \framebox[#1][l]{\menutext{#2}\hfill}\par%
545 }
546 % \end{macrocode}
547 % \end{macro}%^^A\menuitem
548 % \begin{macro}{\menuitemactive}
549 % \begin{macrocode}
550 \renewcommand\menuitemactive[2][\menuitemlength]{%
551 \shadowbox to #1{\menutext{\emph{#2}}\hfill\menuitemactivesymbol}\par%
552 }
553 % \end{macrocode}
554 % \end{macro}%^^A\menuitemactive
555 % \begin{macrocode}
556 \fi%Option framed
557 % \end{macrocode}
558 %
559 %\subsubsection{Option grey}
560 % Activate the grey-option.
561 % \begin{macrocode}
562 \ifmenuoptiongrey
563 \RequirePackage{fancybox}%fuer shadowbox
564 \RequirePackage{color}%fuer farbige Boxen
565 \definecolor{menugrey}{rgb}{0.9,0.9,0.9}
566 % \end{macrocode}
567 % \begin{macro}{\menufolderentry}
568 % \begin{macrocode}
569 \renewcommand\menufolderentry[2][\menuitemlength]{%
570 \fcolorbox{white}{black}{\makebox[#1]{\menutext{\textcolor{white}{#2}}}}\par%
571 }
572 % \end{macrocode}
573 % \end{macro}%^^A\menufolderentry
574 % \begin{macro}{\menuitem}
575 % \begin{macrocode}
576 \renewcommand\menuitem[2][\menuitemlength]{%
577 \fcolorbox{black}{menugrey}{\makebox[#1]{\menutext{\textcolor{white}{#2\hfill}}}}\par%
578 }
579 % \end{macrocode}
580 % \end{macro}%^^A\menuitem
581 % \begin{macro}{\menuitemactive}
582 %\fixme{offset 1ex}
583 % \begin{macrocode}
584 \renewcommand\menuitemactive[2][\menuitemlength]{%
585 \textsf{\hspace*{1ex}\shadowbox to #1 {\menutext{#2}\hfill\menuitemactivesymbol}}\par%fixme
586 }
587 % \end{macrocode}%
588 % \end{macro}%^^A\menuitemactive
589 %
590 %
591 % \begin{macro}{\menuseparator}
592 %\fixme{verbessern}
593 % \begin{macrocode}
594 \renewcommand\menuseparator[1][\menuitemlength]{%
595 \makebox[#1][l]{~\hrulefill~}\par%
596 }
597 % \end{macrocode}
598 % \end{macro}%^^A\menuseparator
599 % \begin{macrocode}
600 \fi%Option grey
601 % \end{macrocode}
602 %
603 % \Finale
604 % \PrintIndex
605 % \end{document}
606 %</package>