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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * TkMacMDEF.c --
3
 *
4
 *      This module is implements the MDEF for tkMenus. The address of the
5
 *      real entry proc will be blasted into the MDEF.
6
 *
7
 * Copyright (c) 1996 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: tkMacMDEF.c,v 1.1.1.1 2002-01-16 10:25:55 markom Exp $
13
 */
14
 
15
#define MAC_TCL
16
#define NeedFunctionPrototypes 1
17
#define NeedWidePrototypes 0
18
 
19
#include <Menus.h>
20
#include <LowMem.h>
21
#include "tkMacInt.h"
22
 
23
 
24
/*
25
 * The following structure is built from assembly equates in MPW 3.0
26
 * AIncludes file: "Private.a." We're forced to update several locations not
27
 * documented in "Inside Mac" to make our MDEF behave properly with hierarchical
28
 * menus.
29
 */
30
 
31
#if STRUCTALIGNMENTSUPPORTED
32
#pragma options align=mac68k
33
#endif
34
typedef struct mbPrivate {
35
    Byte unknown[6];
36
    Rect mbItemRect;            /* rect of currently chosen menu item */
37
} mbPrivate;
38
#if STRUCTALIGNMENTSUPPORTED
39
#pragma options align=reset
40
#endif
41
 
42
/*
43
 * We are forced to update a low-memory global to get cascades to work. This
44
 * global does not have a LMEquate associated with it.
45
 */
46
 
47
#define SELECTRECT (*(Rect *)0x09fa)    /* Menu select seems to need this */
48
#define MBSAVELOC (*(short *)0x0B5C)    /* address of handle to mbarproc private data redefined below */
49
 
50
pascal void             main _ANSI_ARGS_((short message,
51
                            MenuHandle menu, Rect *menuRect,
52
                            Point hitPt, short *whichItem));
53
 
54
 
55
/*
56
 *----------------------------------------------------------------------
57
 *
58
 * TkMacStdMenu --
59
 *
60
 *      The dispatch routine called by the system to handle menu drawing,
61
 *      scrolling, etc. This is a stub; the address of the real routine
62
 *      is blasted in. The real routine will be a UniversalProcPtr,
63
 *      which will give the real dispatch routine in Tk globals
64
 *      and the like.
65
 *
66
 * Results:
67
 *      None.
68
 *
69
 * Side effects:
70
 *      This routine causes menus to be drawn and will certainly allocate
71
 *      memory as a result. Also, the menu can scroll up and down, and
72
 *      various other interface actions can take place
73
 *
74
 *----------------------------------------------------------------------
75
 */
76
 
77
pascal void
78
main(
79
    short message,              /* What action are we taking? */
80
    MenuHandle menu,            /* The menu we are working with */
81
    Rect *menuRect,             /* A pointer to the rect we are working with */
82
    Point hitPt,                /* Where the mouse was hit for appropriate
83
                                 * messages. */
84
    short *whichItemPtr)        /* Output result. Which item was hit by
85
                                 * the user? */
86
{
87
    /*
88
     * The constant 'MDEF' is what will be punched during menu intialization.
89
     */
90
 
91
    TkMenuDefProcPtr procPtr = (TkMenuDefProcPtr) 'MDEF';
92
    TkMenuLowMemGlobals globals;
93
    short oldItem;
94
 
95
    globals.menuDisable = LMGetMenuDisable();
96
    globals.menuTop = LMGetTopMenuItem();
97
    globals.menuBottom = LMGetAtMenuBottom();
98
    if (MBSAVELOC == -1) {
99
        globals.itemRect = (**(mbPrivate***)&MBSAVELOC)->mbItemRect;
100
    }
101
    if (message == mChooseMsg) {
102
        oldItem = *whichItemPtr;
103
    }
104
 
105
    TkCallMenuDefProc(procPtr, message, menu, menuRect, hitPt, whichItemPtr,
106
            &globals);
107
 
108
    LMSetMenuDisable(globals.menuDisable);
109
    LMSetTopMenuItem(globals.menuTop);
110
    LMSetAtMenuBottom(globals.menuBottom);
111
    if ((message == mChooseMsg) && (oldItem != *whichItemPtr)
112
            && (MBSAVELOC != -1)) {
113
        (**(mbPrivate***)&MBSAVELOC)->mbItemRect = globals.itemRect;
114
        SELECTRECT = globals.itemRect;
115
    }
116
}

powered by: WebSVN 2.1.0

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