Commit | Line | Data |
---|---|---|
e745ede7 DL |
1 | #include "copyright.h" |
2 | ||
e745ede7 | 3 | /* Copyright Massachusetts Institute of Technology 1985 */ |
61e1e4e8 | 4 | /* Copyright (C) 2001, 2002, 2003, 2004, 2005, |
4e6835db | 5 | 2006, 2007 Free Software Foundation, Inc. */ |
e745ede7 DL |
6 | |
7 | /* | |
8 | * XMenu: MIT Project Athena, X Window system menu package | |
9 | * | |
10 | * XMenuLocate - Return data necessary to position and locate | |
11 | * a menu on the screen. | |
12 | * | |
13 | * Author: Tony Della Fera, DEC | |
14 | * January 11, 1985 | |
15 | * | |
16 | */ | |
17 | ||
18 | #include "XMenuInt.h" | |
19 | ||
20 | int | |
21 | XMenuLocate(display, menu, p_num, s_num, x_pos, y_pos, ul_x, ul_y, width, height) | |
22 | register Display *display; /* Previously opened display. */ | |
23 | register XMenu *menu; /* Menu object being located. */ | |
24 | int p_num; /* Active pane number. */ | |
25 | int s_num; /* Active selection number. */ | |
26 | int x_pos; /* X coordinate of mouse active position. */ | |
27 | int y_pos; /* Y coordinate of mouse active position. */ | |
28 | int *ul_x; /* Returned upper left menu X coordinate. */ | |
29 | int *ul_y; /* Returned upper left menu Y coordinate. */ | |
30 | int *width; /* Returned menu width. */ | |
31 | int *height; /* Returned menu height. */ | |
32 | { | |
33 | register XMPane *p_ptr; /* XMPane pointer. */ | |
34 | register XMSelect *s_ptr; /* XMSelect pointer. */ | |
177c0ea7 | 35 | |
e745ede7 DL |
36 | /* |
37 | * Are the position arguments positive? | |
38 | */ | |
39 | if ((x_pos <= 0) || (y_pos <= 0)) { | |
40 | _XMErrorCode = XME_ARG_BOUNDS; | |
41 | return(XM_FAILURE); | |
42 | } | |
43 | ||
44 | /* | |
45 | * Find the right pane. | |
46 | */ | |
47 | p_ptr = _XMGetPanePtr(menu, p_num); | |
48 | if (p_ptr == NULL) return(XM_FAILURE); | |
49 | ||
50 | /* | |
51 | * Find the right selection. | |
52 | */ | |
53 | s_ptr = _XMGetSelectionPtr(p_ptr, s_num); | |
54 | ||
55 | /* | |
56 | * Check to see that the menu's dependencies have been | |
57 | * recomputed and are up to date. If not, do it now. | |
58 | */ | |
59 | if (menu->recompute) XMenuRecompute(display, menu); | |
60 | ||
61 | /* | |
62 | * Compute the new menu origin such that the active point lies | |
63 | * in the center of the desired active pane and selection. | |
64 | * This sets the values of ul_x and ul_y. | |
65 | */ | |
66 | _XMTransToOrigin(display, menu, p_ptr, s_ptr, x_pos, y_pos, ul_x, ul_y); | |
67 | ||
68 | /* | |
69 | * Set remaining return argument values. | |
70 | */ | |
71 | *width = menu->width; | |
72 | *height = menu->height; | |
73 | ||
74 | /* | |
75 | * Return successfully. | |
76 | */ | |
77 | _XMErrorCode = XME_NO_ERROR; | |
78 | return(XM_SUCCESS); | |
79 | } | |
ab5796a9 MB |
80 | |
81 | /* arch-tag: 1ff94bab-cf67-4c92-bff4-dc0130153173 | |
82 | (do not change this comment) */ |