|
Revision 4196, 2.8 kB
(checked in by miyoshi, 2 years ago)
|
Sync up with Emacs CVS HEAD.
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
#include "copyright.h" |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
#include <config.h> |
|---|
| 17 |
#include "XMenuInt.h" |
|---|
| 18 |
|
|---|
| 19 |
int |
|---|
| 20 |
XMenuInsertSelection(menu, p_num, s_num, data, label, active) |
|---|
| 21 |
register XMenu *menu; |
|---|
| 22 |
register int p_num; |
|---|
| 23 |
register int s_num; |
|---|
| 24 |
char *data; |
|---|
| 25 |
char *label; |
|---|
| 26 |
int active; |
|---|
| 27 |
{ |
|---|
| 28 |
register XMPane *p_ptr; |
|---|
| 29 |
register XMSelect *s_ptr; |
|---|
| 30 |
|
|---|
| 31 |
XMSelect *select; |
|---|
| 32 |
|
|---|
| 33 |
int label_length; |
|---|
| 34 |
int label_width; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
if (label == NULL) { |
|---|
| 40 |
_XMErrorCode = XME_ARG_BOUNDS; |
|---|
| 41 |
return(XM_FAILURE); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
p_ptr = _XMGetPanePtr(menu, p_num); |
|---|
| 48 |
if (p_ptr == NULL) return(XM_FAILURE); |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
s_ptr = _XMGetSelectionPtr(p_ptr, (s_num - 1)); |
|---|
| 55 |
if (s_ptr == NULL) return(XM_FAILURE); |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
select = (XMSelect *)calloc(1, sizeof(XMSelect)); |
|---|
| 61 |
if (select == NULL) { |
|---|
| 62 |
_XMErrorCode = XME_CALLOC; |
|---|
| 63 |
return(XM_FAILURE); |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
label_length = strlen(label); |
|---|
| 70 |
label_width = XTextWidth(menu->s_fnt_info, label, label_length); |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
if (!strcmp (label, "--") || !strcmp (label, "---")) |
|---|
| 77 |
{ |
|---|
| 78 |
select->type = SEPARATOR; |
|---|
| 79 |
select->active = 0; |
|---|
| 80 |
} |
|---|
| 81 |
else |
|---|
| 82 |
{ |
|---|
| 83 |
select->type = SELECTION; |
|---|
| 84 |
select->active = active; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
select->active = active; |
|---|
| 88 |
select->serial = -1; |
|---|
| 89 |
select->label = label; |
|---|
| 90 |
select->label_width = label_width; |
|---|
| 91 |
select->label_length = label_length; |
|---|
| 92 |
select->data = data; |
|---|
| 93 |
select->parent_p = p_ptr; |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
emacs_insque(select, s_ptr); |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
p_ptr->s_count++; |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
menu->recompute = 1; |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
_XMErrorCode = XME_NO_ERROR; |
|---|
| 115 |
return(s_num); |
|---|
| 116 |
} |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|