Commit | Line | Data |
---|---|---|
2cd3138f GM |
1 | /* Copyright Massachusetts Institute of Technology 1985 */ |
2 | ||
e745ede7 DL |
3 | #include "copyright.h" |
4 | ||
e745ede7 DL |
5 | |
6 | /* | |
7 | * XMenu: MIT Project Athena, X Window system menu package | |
8 | * | |
9 | * XMenuPost - Maps a given menu to the display and activates | |
10 | * the menu for user selection. The user is allowed to | |
11 | * specify the mouse button event mask that will be used | |
177c0ea7 | 12 | * to identify a selection request. When a selection |
e745ede7 DL |
13 | * request is received (i.e., when the specified mouse |
14 | * event occurs) the data returned will be either the | |
15 | * data associated with the particular selection active | |
16 | * at the time of the selection request or NULL if no | |
17 | * selection was active. A menu selection is shown to | |
18 | * be active by placing a highlight box around the | |
19 | * selection as the mouse cursor enters its active | |
20 | * region. Inactive selections will not be highlighted. | |
21 | * As the mouse cursor moved from one menu pane | |
22 | * to another menu pane the pane being entered is raised | |
23 | * and activated and the pane being left is deactivated. | |
24 | * If an error occurs NULL will be returned with the | |
25 | * p_num set to POST_ERROR, s_num set to | |
26 | * NO_SELECTION and _XMErrorCode set to an | |
27 | * appropriate value. | |
28 | * Every time the routine returns successfully the | |
29 | * p_num and s_num indices will be set to indicate | |
30 | * the currently active pane and/or selection. If the | |
31 | * mouse was not in a selection window at the time | |
32 | * s_num will be set to NO_SELECTION. | |
33 | * | |
34 | * Author: Tony Della Fera, DEC | |
35 | * August, 1984 | |
36 | * | |
37 | */ | |
38 | ||
39 | #include "XMenuInt.h" | |
40 | ||
41 | char * | |
b782e2d7 DN |
42 | 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) |
43 | /* Previously opened display. */ | |
44 | /* Menu to post. */ | |
45 | /* Pane number selected. */ | |
46 | /* Selection number selected. */ | |
47 | /* X coordinate of menu position. */ | |
48 | /* Y coordinate of menu position. */ | |
49 | /* Mouse button event mask. */ | |
e745ede7 DL |
50 | { |
51 | register int stat; /* Routine call return status. */ | |
52 | char *data; /* Return data. */ | |
53 | ||
54 | /* | |
55 | * Set up initial pane and selection assumptions. | |
56 | */ | |
57 | ||
58 | /* | |
59 | * Make the procedure call. | |
60 | */ | |
61 | stat = XMenuActivate( | |
177c0ea7 | 62 | display, |
e745ede7 | 63 | menu, |
177c0ea7 JB |
64 | p_num, s_num, |
65 | x_pos, y_pos, | |
66 | event_mask, | |
3153caff | 67 | &data, 0); |
e745ede7 DL |
68 | |
69 | /* | |
70 | * Check the return value and return accordingly. | |
71 | */ | |
72 | switch (stat) { | |
73 | case XM_FAILURE: | |
74 | *p_num = POST_ERROR; | |
75 | *s_num = NO_SELECTION; | |
76 | return(NULL); | |
77 | case XM_NO_SELECT: | |
78 | case XM_IA_SELECT: | |
79 | *s_num = NO_SELECTION; | |
80 | return(NULL); | |
81 | case XM_SUCCESS: | |
82 | default: | |
83 | return(data); | |
84 | } | |
85 | } | |
ab5796a9 | 86 |