|
|
1.1 ! root 1: #include <X/mit-copyright.h> ! 2: ! 3: /* $Header: XMenuLocate.c,v 10.4 86/02/01 16:15:24 tony Rel $ */ ! 4: /* Copyright Massachusetts Institute of Technology 1985 */ ! 5: ! 6: /* ! 7: * XMenu: MIT Project Athena, X Window system menu package ! 8: * ! 9: * XMenuLocate - Return data necessary to position and locate ! 10: * a menu on the screen. ! 11: * ! 12: * Author: Tony Della Fera, DEC ! 13: * January 11, 1985 ! 14: * ! 15: */ ! 16: ! 17: #include "XMenuInternal.h" ! 18: ! 19: int ! 20: XMenuLocate(menu, p_num, s_num, x_pos, y_pos, ul_x, ul_y, width, height) ! 21: register XMenu *menu; /* Menu object being located. */ ! 22: int p_num; /* Active pane number. */ ! 23: int s_num; /* Active selection number. */ ! 24: int x_pos; /* X coordinate of mouse active position. */ ! 25: int y_pos; /* Y coordinate of mouse active position. */ ! 26: int *ul_x; /* Returned upper left menu X coordinate. */ ! 27: int *ul_y; /* Returned upper left menu Y coordinate. */ ! 28: int *width; /* Returned menu width. */ ! 29: int *height; /* Returned menu height. */ ! 30: { ! 31: register int i; /* Loop counter. */ ! 32: register XMPane *p_ptr; /* XMPane pointer. */ ! 33: register XMSelect *s_ptr; /* XMSelect pointer. */ ! 34: ! 35: /* ! 36: * Are the position arguments positive? ! 37: */ ! 38: if ((x_pos <= 0) || (y_pos <= 0)) { ! 39: _XMErrorCode = XME_ARG_BOUNDS; ! 40: return(XM_FAILURE); ! 41: } ! 42: ! 43: /* ! 44: * Find the right pane. ! 45: */ ! 46: p_ptr = _XMGetPanePtr(menu, p_num); ! 47: if (p_ptr == NULL) return(XM_FAILURE); ! 48: ! 49: /* ! 50: * Find the right selection. ! 51: */ ! 52: s_ptr = _XMGetSelectionPtr(p_ptr, s_num); ! 53: if (s_ptr == NULL) return(XM_FAILURE); ! 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(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(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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.