|
|
1.1 ! root 1: #include <X11/copyright.h> ! 2: ! 3: /* $Header: InsSel.c,v 1.2 87/09/10 20:31:25 chris Exp $ */ ! 4: /* Copyright Massachusetts Institute of Technology 1985 */ ! 5: ! 6: /* ! 7: * XMenu: MIT Project Athena, X Window system menu package ! 8: * ! 9: * XMenuInsertSelection - Inserts a selection into an XMenu object ! 10: * ! 11: * Author: Tony Della Fera, DEC ! 12: * 20-Nov-85 ! 13: * ! 14: */ ! 15: ! 16: #include "XMenuInternal.h" ! 17: ! 18: int ! 19: XMenuInsertSelection(menu, p_num, s_num, data, label, active) ! 20: register XMenu *menu; /* Menu object to be modified. */ ! 21: register int p_num; /* Pane number to be modified. */ ! 22: register int s_num; /* Selection number of new selection. */ ! 23: char *data; /* Data value. */ ! 24: char *label; /* Selection label. */ ! 25: int active; /* Make selection active? */ ! 26: { ! 27: register XMPane *p_ptr; /* XMPane pointer. */ ! 28: register XMSelect *s_ptr; /* XMSelect pointer. */ ! 29: ! 30: XMSelect *select; /* Newly created selection. */ ! 31: ! 32: int label_length; /* Label lenght in characters. */ ! 33: int label_width; /* Label width in pixels. */ ! 34: ! 35: /* ! 36: * Check for NULL pointers! ! 37: */ ! 38: if (label == NULL) { ! 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 selection number one less than the one specified since that ! 51: * is the selection after which the insertion will occur. ! 52: */ ! 53: s_ptr = _XMGetSelectionPtr(p_ptr, (s_num - 1)); ! 54: if (s_ptr == NULL) return(XM_FAILURE); ! 55: ! 56: /* ! 57: * Calloc the XMSelect structure. ! 58: */ ! 59: select = (XMSelect *)calloc(1, sizeof(XMSelect)); ! 60: if (select == NULL) { ! 61: _XMErrorCode = XME_CALLOC; ! 62: return(XM_FAILURE); ! 63: } ! 64: ! 65: /* ! 66: * Determine label size. ! 67: */ ! 68: label_length = strlen(label); ! 69: label_width = XTextWidth(menu->s_fnt_info, label, label_length); ! 70: ! 71: ! 72: /* ! 73: * Fill the XMSelect structure. ! 74: */ ! 75: select->type = SELECTION; ! 76: select->active = active; ! 77: select->serial = -1; ! 78: select->label = label; ! 79: select->label_width = label_width; ! 80: select->label_length = label_length; ! 81: select->data = data; ! 82: select->parent_p = p_ptr; ! 83: ! 84: /* ! 85: * Insert the selection after the selection with the selection ! 86: * number one less than the desired number for the new selection. ! 87: */ ! 88: insque(select, s_ptr); ! 89: ! 90: /* ! 91: * Update the selection count. ! 92: */ ! 93: p_ptr->s_count++; ! 94: ! 95: /* ! 96: * Schedule a recompute. ! 97: */ ! 98: menu->recompute = 1; ! 99: ! 100: /* ! 101: * Return the selection number just inserted. ! 102: */ ! 103: _XMErrorCode = XME_NO_ERROR; ! 104: return(s_num); ! 105: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.