4
* This module implements the common elements of the Mac and Windows
5
* specific features of menus. This file is not used for UNIX.
7
* Copyright (c) 1996-1997 by Sun Microsystems, Inc.
9
* See the file "license.terms" for information on usage and redistribution
10
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
* RCS: @(#) $Id: tkMacWinMenu.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
17
static int postCommandGeneration;
19
static int PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
23
*----------------------------------------------------------------------
27
* The guts of the preprocessing. Recursive.
30
* The return value is a standard Tcl result (errors can occur
31
* while the postcommands are being processed).
34
* Since commands can get executed while this routine is being executed,
35
* the entire world can change.
37
*----------------------------------------------------------------------
41
PreprocessMenu(menuPtr)
44
int index, result, finished;
45
TkMenu *cascadeMenuPtr;
47
Tcl_Preserve((ClientData) menuPtr);
50
* First, let's process the post command on ourselves. If this command
51
* destroys this menu, or if there was an error, we are done.
54
result = TkPostCommand(menuPtr);
55
if ((result != TCL_OK) || (menuPtr->tkwin == NULL)) {
60
* Now, we go through structure and process all of the commands.
61
* Since the structure is changing, we stop after we do one command,
62
* and start over. When we get through without doing any, we are done.
68
for (index = 0; index < menuPtr->numEntries; index++) {
69
if ((menuPtr->entries[index]->type == CASCADE_ENTRY)
70
&& (menuPtr->entries[index]->name != NULL)) {
71
if ((menuPtr->entries[index]->childMenuRefPtr != NULL)
72
&& (menuPtr->entries[index]->childMenuRefPtr->menuPtr
75
menuPtr->entries[index]->childMenuRefPtr->menuPtr;
76
if (cascadeMenuPtr->postCommandGeneration !=
77
postCommandGeneration) {
78
cascadeMenuPtr->postCommandGeneration =
79
postCommandGeneration;
80
result = PreprocessMenu(cascadeMenuPtr);
81
if (result != TCL_OK) {
93
Tcl_Release((ClientData)menuPtr);
98
*----------------------------------------------------------------------
100
* TkPreprocessMenu --
102
* On the Mac and on Windows, all of the postcommand processing has
103
* to be done on the entire tree underneath the main window to be
104
* posted. This means that we have to traverse the menu tree and
105
* issue the postcommands for all of the menus that have cascades
106
* attached. Since the postcommands can change the menu structure while
107
* we are traversing, we have to be extremely careful. Basically, the
108
* idea is to traverse the structure until we succesfully process
109
* one postcommand. Then we start over, and do it again until
110
* we traverse the whole structure without processing any postcommands.
112
* We are also going to set up the cascade back pointers in here
113
* since we have to traverse the entire structure underneath the menu
114
* anyway, We can clear the postcommand marks while we do that.
117
* The return value is a standard Tcl result (errors can occur
118
* while the postcommands are being processed).
121
* Since commands can get executed while this routine is being executed,
122
* the entire world can change.
124
*----------------------------------------------------------------------
128
TkPreprocessMenu(menuPtr)
131
postCommandGeneration++;
132
menuPtr->postCommandGeneration = postCommandGeneration;
133
return PreprocessMenu(menuPtr);