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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [generic/] [tkMacWinMenu.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tkMacWinMenu.c --
3
 *
4
 *      This module implements the common elements of the Mac and Windows
5
 *      specific features of menus. This file is not used for UNIX.
6
 *
7
 * Copyright (c) 1996-1997 by Sun Microsystems, Inc.
8
 *
9
 * See the file "license.terms" for information on usage and redistribution
10
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
 *
12
 * RCS: @(#) $Id: tkMacWinMenu.c,v 1.1.1.1 2002-01-16 10:25:52 markom Exp $
13
 */
14
 
15
#include "tkMenu.h"
16
 
17
static int postCommandGeneration;
18
 
19
static int                      PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
20
 
21
 
22
/*
23
 *----------------------------------------------------------------------
24
 *
25
 * PreprocessMenu --
26
 *
27
 *      The guts of the preprocessing. Recursive.
28
 *
29
 * Results:
30
 *      The return value is a standard Tcl result (errors can occur
31
 *      while the postcommands are being processed).
32
 *
33
 * Side effects:
34
 *      Since commands can get executed while this routine is being executed,
35
 *      the entire world can change.
36
 *
37
 *----------------------------------------------------------------------
38
 */
39
 
40
static int
41
PreprocessMenu(menuPtr)
42
    TkMenu *menuPtr;
43
{
44
    int index, result, finished;
45
    TkMenu *cascadeMenuPtr;
46
 
47
    Tcl_Preserve((ClientData) menuPtr);
48
 
49
    /*
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.
52
     */
53
 
54
    result = TkPostCommand(menuPtr);
55
    if ((result != TCL_OK) || (menuPtr->tkwin == NULL)) {
56
        goto done;
57
    }
58
 
59
    /*
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.
63
     */
64
 
65
 
66
    do {
67
        finished = 1;
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
73
                        != NULL)) {
74
                    cascadeMenuPtr =
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) {
82
                            goto done;
83
                        }
84
                        finished = 0;
85
                        break;
86
                    }
87
                }
88
            }
89
        }
90
    } while (!finished);
91
 
92
    done:
93
    Tcl_Release((ClientData)menuPtr);
94
    return result;
95
}
96
 
97
/*
98
 *----------------------------------------------------------------------
99
 *
100
 * TkPreprocessMenu --
101
 *
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.
111
 *
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.
115
 *
116
 * Results:
117
 *      The return value is a standard Tcl result (errors can occur
118
 *      while the postcommands are being processed).
119
 *
120
 * Side effects:
121
 *      Since commands can get executed while this routine is being executed,
122
 *      the entire world can change.
123
 *
124
 *----------------------------------------------------------------------
125
 */
126
 
127
int
128
TkPreprocessMenu(menuPtr)
129
    TkMenu *menuPtr;
130
{
131
    postCommandGeneration++;
132
    menuPtr->postCommandGeneration = postCommandGeneration;
133
    return PreprocessMenu(menuPtr);
134
}

powered by: WebSVN 2.1.0

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