summaryrefslogtreecommitdiff
path: root/oldXMenu/Post.c
blob: 524773673bcbbed5a444b708bc7969a165c6776b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* Copyright    Massachusetts Institute of Technology    1985	*/

/*

Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology

Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
M.I.T. makes no representations about the suitability of
this software for any purpose.  It is provided "as is"
without express or implied warranty.

*/




/*
 * XMenu:	MIT Project Athena, X Window system menu package
 *
 *	XMenuPost -	Maps a given menu to the display and activates
 *			the menu for user selection.  The user is allowed to
 *			specify the mouse button event mask that will be used
 *			to identify a selection request.  When a selection
 *			request is received (i.e., when the specified mouse
 *			event occurs) the data  returned will be either the
 *			data associated with the particular selection active
 *			at the time of the selection request or NULL if no
 *			selection was active.  A menu selection is shown to
 *			be active by placing a highlight box around the
 *			selection as the mouse cursor enters its active
 *			region.  Inactive selections will not be highlighted.
 *			As the mouse cursor moved from one menu pane
 *			to another menu pane the pane being entered is raised
 *			and activated and the pane being left is deactivated.
 *			If an error occurs NULL will be returned with the
 *			p_num set to POST_ERROR, s_num set to
 *			NO_SELECTION and _XMErrorCode set to an
 *			appropriate value.
 *			Every time the routine returns successfully the
 *			p_num and s_num indices will be set to indicate
 *			the currently active pane and/or selection.  If the
 *			mouse was not in a selection window at the time
 *			s_num will be set to NO_SELECTION.
 *
 *	Author:		Tony Della Fera, DEC
 *			August, 1984
 *
 */

#include "XMenuInt.h"

char *
XMenuPost(register Display *display, register XMenu *menu, register int *p_num, register int *s_num, register int x_pos, register int y_pos, int event_mask)
                              	/* Previously opened display. */
                         	/* Menu to post. */
                        	/* Pane number selected. */
                        	/* Selection number selected. */
                       		/* X coordinate of menu position. */
                       		/* Y coordinate of menu position. */
                   		/* Mouse button event mask. */
{
    register int stat;		/* Routine call return status. */
    char *data;			/* Return data. */

    /*
     * Set up initial pane and selection assumptions.
     */

    /*
     * Make the procedure call.
     */
    stat = XMenuActivate(
			 display,
			 menu,
			 p_num, s_num,
			 x_pos, y_pos,
			 event_mask,
			 &data, 0);

    /*
     * Check the return value and return accordingly.
     */
    switch (stat) {
	case XM_FAILURE:
	    *p_num = POST_ERROR;
	    *s_num = NO_SELECTION;
	    return(NULL);
	case XM_NO_SELECT:
	case XM_IA_SELECT:
	    *s_num = NO_SELECTION;
	    return(NULL);
	case XM_SUCCESS:
	default:
	    return(data);
    }
}