head	1.7;
access;
symbols
	core-8-5-9:1.6
	core-8-5-8:1.6
	macosx-cocoa-merge:1.6
	macosx-cocoa-premerge:1.6
	macosx-carbon-freeze:1.6
	core-8-5-7:1.6
	core-8-5-6:1.6
	core-8-6-b1:1.6
	core-8-6-a3:1.6
	core-8-5-5:1.6
	core-8-6-a2:1.6
	core-8-5-4:1.6
	core-8-5-3:1.6
	core-8-6-a1:1.6
	core-8-4-19:1.3
	core-8-5-branch:1.6.0.2
	core-8-5-2:1.6
	core-8-4-18:1.3
	core-8-5-1:1.6
	core-8-4-17:1.3
	core-8-5-0:1.6
	core-8-5-b3:1.5
	core-8-5-b2:1.5
	core-8-4-16:1.3
	core-8-5-b1:1.5
	core-stablilizer-merge:1.4
	core-stabilizer-branch:1.4.0.2
	core-stabilizer-merge:1.6
	core-8-4-15:1.3
	core-8-5-a6:1.4
	core-8-5-a5:1.4
	core-8-4-14:1.3
	core-8-5-a4:1.4
	core-8-4-13:1.3
	core-8-4-12:1.3
	core-8-4-11:1.3
	core-8-5-a3:1.3
	core-8-4-10:1.3
	core-8-4-9-branch:1.3.0.24
	core-8-5-a2:1.3
	core-8-4-9:1.3
	core-8-4-8:1.3
	core-8-4-7:1.3
	core-8-5-a1:1.3
	core-8-4-6:1.3
	core-8-4-5:1.3
	mistachkin-dev-branch:1.3.0.22
	core-8-4-4:1.3
	core-8-4-3:1.3
	core-8-4-branch:1.3.0.20
	core-8-4-2:1.3
	core-8-4-1:1.3
	core-8-3-5:1.3
	core-8-4-0:1.3
	macosx-8-4-merge-2002-08-31-trunk:1.3
	macosx-8-4-premerge-2002-08-31-branch:1.3
	macosx-8-4-premerge-2002-08-31-trunk:1.3
	macosx-8-4-merge-2002-08-30-branch:1.3
	macosx-8-4-merge-2002-08-30-trunk:1.3
	macosx-8-4-merge-2002-08-20-branch:1.3
	macosx-8-4-merge-2002-08-20-trunk:1.3
	core-8-4-b2:1.3
	core-8-4-b1:1.3
	macosx-premerge-6-9-02:1.3
	core-8-4-a4:1.3
	core-8-3-4:1.3
	macosx-8-4-branch:1.3.0.18
	macosx-8-4-branchpoint:1.3
	core-8-4-a3:1.3
	core-8-3-3:1.3
	dgp-privates-into-namespace:1.3.0.16
	tclpro-1-5-0:1.3
	core-8-4-win-speedup:1.3.0.14
	core-8-4-a2:1.3
	tclpro-1-4-1:1.3
	tclpro-1-4-0:1.3
	core-8-3-2:1.3
	ajuba-ajuba2-2-1-base:1.3
	ajuba-ajuba2-2-0:1.3
	core-8-4-a1:1.3
	core-8-3-1-branch:1.3.0.12
	core-8-3-1:1.3
	scriptics-sc-2-0-b5:1.3
	scriptics-sc-2-0-fixed:1.3
	scriptics-sc-2-0-b2:1.3
	scriptics-sc-2-0-b1:1.3
	core-8-3-0:1.3
	core-8-3-b2:1.3
	core-8-3-b1:1.3
	scriptics-sc-1-1:1.3
	scriptics-sc-1-1-b1:1.3
	core-8-2-3:1.3
	scriptics-sc-1-1-branch:1.3.0.10
	scriptics-sc-1-1-base:1.3
	scriptics-sc-1-0:1.3
	scriptics-sc-1-0-branch:1.3.0.8
	scriptics-sc-1-0-base:1.3
	core-8-2-2:1.3
	core-8-2-1:1.3
	scriptics-bc-1-0-b1:1.3
	core-8-2-1-branch:1.3.0.6
	scriptics-tclpro-1-3-0:1.3
	core-8-2-0:1.3
	core-8-2-b3-branch:1.3.0.4
	core-8-2-b3-base:1.3
	scriptics-tclpro-1-3-b4:1.3
	core-8-2-b2:1.3
	scriptics-tclpro-1-3-b3:1.3
	core-8-2-b1:1.3
	scriptics-tclpro-1-3-b2:1.3
	merge-to-mainline-5/21/99:1.3
	scriptics-tclpro-1-3-b2-branch:1.3.0.2
	core-8-1-1:1.3
	scriptics-tclpro-1-3-b1:1.3
	core-8-1-1-base:1.3
	core-8-1-0:1.3
	merge-to-mainline-4-29-99:1.3
	merge-to-mainline-4-23-99:1.3
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.2.0.6
	core-8-0-6-base:1.2
	core-8-0-5:1.2
	core-8-1-b3:1.1.4.3
	core-8-1-b2:1.1.4.3
	dev-8-1-stubs-branch:1.1.4.3.0.2
	dev-stubs-branch:1.2.0.4
	scriptics-tclpro-1-2:1.2
	scriptics-tclpro-1-2-b2:1.2
	core-8-1-merge-2/10/99:1.2
	core-8-0-5-branch:1.2.0.2
	core-8-0-5-base:1.2
	scriptics-tclpro-1-2-b1:1.2
	scriptics-tclpro-1-2-a1:1.2
	core-8-1-b1:1.1.4.2
	core-8-0-4:1.2
	core-8-1-a2:1.1.4.1
	core-8-0-2:1.1
	core-8-0-3:1.2;
locks; strict;
comment	@ * @;


1.7
date	2010.01.02.22.52.38;	author dkf;	state Exp;
branches;
next	1.6;

1.6
date	2007.12.13.15.24.15;	author dgp;	state Exp;
branches;
next	1.5;

1.5
date	2007.09.07.00.34.53;	author dgp;	state Exp;
branches;
next	1.4;

1.4
date	2005.11.14.22.44.11;	author dkf;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	99.04.16.01.51.19;	author stanton;	state Exp;
branches;
next	1.2;

1.2
date	98.09.14.18.23.14;	author stanton;	state Exp;
branches;
next	1.1;

1.1
date	98.04.01.09.52.00;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.29.00.25.21;	author stanton;	state Exp;
branches;
next	1.1.4.2;

1.1.4.2
date	98.09.30.02.17.07;	author stanton;	state Exp;
branches;
next	1.1.4.3;

1.1.4.3
date	98.12.13.08.16.08;	author lfb;	state Exp;
branches;
next	;

1.4.2.1
date	2007.09.07.01.25.35;	author dgp;	state Exp;
branches;
next	;


desc
@@


1.7
log
@SMALL FIX: Remove useless explicit casts now that we require C89 or later.
@
text
@/*
 * tkMacWinMenu.c --
 *
 *	This module implements the common elements of the Mac and Windows
 *	specific features of menus. This file is not used for UNIX.
 *
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.6 2007/12/13 15:24:15 dgp Exp $
 */

#include "tkInt.h"
#include "tkMenu.h"

typedef struct ThreadSpecificData {
    int postCommandGeneration;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

static int		PreprocessMenu(TkMenu *menuPtr);

/*
 *----------------------------------------------------------------------
 *
 * PreprocessMenu --
 *
 *	The guts of the preprocessing. Recursive.
 *
 * Results:
 *	The return value is a standard Tcl result (errors can occur while the
 *	postcommands are being processed).
 *
 * Side effects:
 *	Since commands can get executed while this routine is being executed,
 *	the entire world can change.
 *
 *----------------------------------------------------------------------
 */

static int
PreprocessMenu(
    TkMenu *menuPtr)
{
    int index, result, finished;
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    Tcl_Preserve(menuPtr);

    /*
     * First, let's process the post command on ourselves. If this command
     * destroys this menu, or if there was an error, we are done.
     */

    result = TkPostCommand(menuPtr);
    if ((result != TCL_OK) || (menuPtr->tkwin == NULL)) {
	goto done;
    }

    /*
     * Now, we go through structure and process all of the commands. Since the
     * structure is changing, we stop after we do one command, and start over.
     * When we get through without doing any, we are done.
     */

    do {
	finished = 1;
	for (index = 0; index < menuPtr->numEntries; index++) {
	    register TkMenuEntry *entryPtr = menuPtr->entries[index];

	    if ((entryPtr->type == CASCADE_ENTRY)
		    && (entryPtr->namePtr != NULL)
		    && (entryPtr->childMenuRefPtr != NULL)
		    && (entryPtr->childMenuRefPtr->menuPtr != NULL)) {
		TkMenu *cascadeMenuPtr = entryPtr->childMenuRefPtr->menuPtr;

		if (cascadeMenuPtr->postCommandGeneration !=
			tsdPtr->postCommandGeneration) {
		    cascadeMenuPtr->postCommandGeneration =
			    tsdPtr->postCommandGeneration;
		    result = PreprocessMenu(cascadeMenuPtr);
		    if (result != TCL_OK) {
			goto done;
		    }
		    finished = 0;
		    break;
		}
	    }
	}
    } while (!finished);

  done:
    Tcl_Release(menuPtr);
    return result;
}

/*
 *----------------------------------------------------------------------
 *
 * TkPreprocessMenu --
 *
 *	On the Mac and on Windows, all of the postcommand processing has to be
 *	done on the entire tree underneath the main window to be posted. This
 *	means that we have to traverse the menu tree and issue the
 *	postcommands for all of the menus that have cascades attached. Since
 *	the postcommands can change the menu structure while we are
 *	traversing, we have to be extremely careful. Basically, the idea is to
 *	traverse the structure until we succesfully process one postcommand.
 *	Then we start over, and do it again until we traverse the whole
 *	structure without processing any postcommands.
 *
 *	We are also going to set up the cascade back pointers in here since we
 *	have to traverse the entire structure underneath the menu anyway. We
 *	can clear the postcommand marks while we do that.
 *
 * Results:
 *	The return value is a standard Tcl result (errors can occur while the
 *	postcommands are being processed).
 *
 * Side effects:
 *	Since commands can get executed while this routine is being executed,
 *	the entire world can change.
 *
 *----------------------------------------------------------------------
 */

int
TkPreprocessMenu(
    TkMenu *menuPtr)
{
    ThreadSpecificData *tsdPtr =
	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    tsdPtr->postCommandGeneration++;
    menuPtr->postCommandGeneration = tsdPtr->postCommandGeneration;
    return PreprocessMenu(menuPtr);
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
@


1.6
log
@merge stable branch onto HEAD
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.4.2.1 2007/09/07 01:25:35 dgp Exp $
d48 1
a48 1
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
d51 1
a51 1
    Tcl_Preserve((ClientData) menuPtr);
d96 1
a96 1
    Tcl_Release((ClientData) menuPtr);
d134 1
a134 1
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@


1.5
log
@header cleanup
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.4 2005/11/14 22:44:11 dkf Exp $
@


1.4
log
@ANSIfy
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.3 1999/04/16 01:51:19 stanton Exp $
d15 1
@


1.4.2.1
log
@merge updates from HEAD
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.4 2005/11/14 22:44:11 dkf Exp $
a14 1
#include "tkInt.h"
@


1.3
log
@* Merged 8.1 branch into the main trunk
@
text
@d1 1
a1 1
/* 
d9 2
a10 2
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
d12 1
a12 1
 * RCS: @@(#) $Id$
d22 1
a22 3

static int			PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));

d32 2
a33 2
 *	The return value is a standard Tcl result (errors can occur
 *	while the postcommands are being processed).
d43 2
a44 2
PreprocessMenu(menuPtr)
    TkMenu *menuPtr;
d47 3
a49 4
    TkMenu *cascadeMenuPtr;
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
   
d51 1
a51 1
    
d56 1
a56 1
     
d59 1
a59 1
    	goto done;
d61 1
a61 1
    
d63 3
a65 3
     * Now, we go through structure and process all of the commands.
     * Since the structure is changing, we stop after we do one command,
     * and start over. When we get through without doing any, we are done.
d67 1
a67 2
    
    
d69 23
a91 23
    	finished = 1;
        for (index = 0; index < menuPtr->numEntries; index++) {
            if ((menuPtr->entries[index]->type == CASCADE_ENTRY)
            	    && (menuPtr->entries[index]->namePtr != NULL)) {
            	if ((menuPtr->entries[index]->childMenuRefPtr != NULL)
            		&& (menuPtr->entries[index]->childMenuRefPtr->menuPtr
            		!= NULL)) {
            	    cascadeMenuPtr =
            	    	    menuPtr->entries[index]->childMenuRefPtr->menuPtr;
            	    if (cascadeMenuPtr->postCommandGeneration != 
            	    	    tsdPtr->postCommandGeneration) {
            	    	cascadeMenuPtr->postCommandGeneration = 
            	    		tsdPtr->postCommandGeneration;
            	        result = PreprocessMenu(cascadeMenuPtr);
            	        if (result != TCL_OK) {
            	            goto done;
            	        }
            	        finished = 0;
            	        break;
            	    }
            	}
            }
        }
d93 3
a95 3
    
    done:
    Tcl_Release((ClientData)menuPtr);
d104 13
a116 13
 *	On the Mac and on Windows, all of the postcommand processing has
 *	to be done on the entire tree underneath the main window to be
 *	posted. This means that we have to traverse the menu tree and
 *	issue the postcommands for all of the menus that have cascades
 *	attached. Since the postcommands can change the menu structure while
 *	we are traversing, we have to be extremely careful. Basically, the
 *	idea is to traverse the structure until we succesfully process
 *	one postcommand. Then we start over, and do it again until
 *	we traverse the whole structure without processing any postcommands.
 *
 *	We are also going to set up the cascade back pointers in here
 *	since we have to traverse the entire structure underneath the menu
 *	anyway, We can clear the postcommand marks while we do that.
d119 2
a120 2
 *	The return value is a standard Tcl result (errors can occur
 *	while the postcommands are being processed).
d130 2
a131 2
TkPreprocessMenu(menuPtr)
    TkMenu *menuPtr;
d133 2
a134 2
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
d140 8
@


1.2
log
@Replaced SCCS strings, fixed binary files
@
text
@d17 5
a21 1
static int postCommandGeneration;
d50 2
d76 1
a76 1
            	    && (menuPtr->entries[index]->name != NULL)) {
d83 1
a83 1
            	    	    postCommandGeneration) {
d85 1
a85 1
            	    		postCommandGeneration;
d137 5
a141 2
    postCommandGeneration++;
    menuPtr->postCommandGeneration = postCommandGeneration;
@


1.1
log
@Initial revision
@
text
@d12 1
a12 1
 * SCCS: @@(#) tkMacWinMenu.c 1.39 97/04/09 14:56:59
@


1.1.4.1
log
@initial tk8.1a2 version
@
text
@d12 1
a12 1
 * SCCS: @@(#) tkMacWinMenu.c 1.41 97/10/22 15:05:23
d70 1
a70 1
            	    && (menuPtr->entries[index]->namePtr != NULL)) {
@


1.1.4.2
log
@Merged 8.0.3 changes into 8.1
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
@


1.1.4.3
log
@
Tk 8.1 Muti-threading changes.

Moved static and global data elements into thread-local storage,
or introduced locks where not possible, as first stage of adding
thread safety to Tk.
@
text
@d12 1
a12 1
 * RCS: @@(#) $Id: tkMacWinMenu.c,v 1.1.4.2 1998/09/30 02:17:07 stanton Exp $
d17 1
a17 5
typedef struct ThreadSpecificData {
    int postCommandGeneration;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

a45 2
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
d77 1
a77 1
            	    	    tsdPtr->postCommandGeneration) {
d79 1
a79 1
            	    		tsdPtr->postCommandGeneration;
d131 2
a132 5
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    tsdPtr->postCommandGeneration++;
    menuPtr->postCommandGeneration = tsdPtr->postCommandGeneration;
@


