XMenu.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenu.h - Include file for the MIT Project Athena
  7. * XMenu X window system menu package.
  8. *
  9. * Author: Tony Della Fera, DEC
  10. * August, 1984
  11. */
  12. #ifndef _XMenu_h_
  13. #define _XMenu_h_
  14. #include <stdlib.h>
  15. #include <X11/Xutil.h>
  16. #include "X10.h"
  17. #define FAILURE -1
  18. #define SUCCESS 1
  19. #define POST_ERROR -1
  20. #define NO_SELECTION -1
  21. #define XM_FAILURE -1
  22. #define XM_SUCCESS 1
  23. #define XM_NO_SELECT 2
  24. #define XM_IA_SELECT 3
  25. #define XME_CODE_COUNT 17
  26. #define XME_NO_ERROR 0
  27. #define XME_NOT_INIT 1
  28. #define XME_ARG_BOUNDS 2
  29. #define XME_P_NOT_FOUND 3
  30. #define XME_S_NOT_FOUND 4
  31. #define XME_STYLE_PARAM 5
  32. #define XME_GRAB_MOUSE 6
  33. #define XME_INTERP_LOC 7
  34. #define XME_CALLOC 8
  35. #define XME_CREATE_ASSOC 9
  36. #define XME_STORE_BITMAP 10
  37. #define XME_MAKE_TILES 11
  38. #define XME_MAKE_PIXMAP 12
  39. #define XME_CREATE_CURSOR 13
  40. #define XME_OPEN_FONT 14
  41. #define XME_CREATE_WINDOW 15
  42. #define XME_CREATE_TRANSP 16
  43. /*
  44. * XMenu error code and error list definitions.
  45. */
  46. extern int _XMErrorCode;
  47. extern char const *const _XMErrorList[];
  48. /*
  49. * Define the XMWindow datatypes.
  50. *
  51. * An XMWindow is either an XMPane or an XMSelect.
  52. *
  53. * XMWindow is wrapper used to identify the constant window
  54. * information that makes up XMPane and XMSelect objects.
  55. *
  56. * An XMPane is a menu pane made up of one or more XMSelect and a label.
  57. *
  58. * An XMSelect is a menu selection object with a label and a data pointer.
  59. */
  60. typedef enum _xmwintype {PANE, SELECTION, PL_HEADER, SL_HEADER, SEPARATOR} XMWType;
  61. typedef struct _xmwindow {
  62. struct _xmwindow *next; /* Next obj pointer (for emacs_insque). */
  63. struct _xmwindow *prev; /* Prev obj pointer (for emacs_insque). */
  64. XMWType type; /* Type of window. */
  65. Window window; /* X Window Id. */
  66. int window_x; /* Window upper left X coordinate. */
  67. int window_y; /* Window upper left y coordinate. */
  68. int window_w; /* Window width. */
  69. int window_h; /* Window height. */
  70. int active; /* Window active? */
  71. int activated; /* Window activated? */
  72. int pad_l1; /* ---- */
  73. char *pad_l2; /* ---- */
  74. int pad_l3; /* ---- */
  75. int pad_l4; /* ---- */
  76. int pad_l5; /* ---- */
  77. int pad_l6; /* ---- */
  78. int pad_l7; /* ---- */
  79. int pad_l8; /* ---- */
  80. struct _xmwindow *pad_l9; /* ---- */
  81. char *pad_l10; /* ---- */
  82. struct _xmwindow *pad_l11; /* ---- */
  83. } XMWindow;
  84. typedef struct _xmpane {
  85. struct _xmpane *next; /* Next obj pointer (for emacs_insque). */
  86. struct _xmpane *prev; /* Prev obj pointer (for emacs_insque). */
  87. XMWType type; /* Type of window. */
  88. Window window; /* X Window Id. */
  89. int window_x; /* Window upper left X coordinate. */
  90. int window_y; /* Window upper left y coordinate. */
  91. int window_w; /* Window width. */
  92. int window_h; /* Window height. */
  93. int active; /* Window active? */
  94. int activated; /* Window activated? */
  95. int serial; /* -- Pane serial number. */
  96. char const *label; /* -- Pane label. */
  97. int label_width; /* -- Pane label width in pixels. */
  98. int label_length; /* -- Pane label length in chars. */
  99. int label_x; /* -- Pane label X offset. */
  100. int label_uy; /* -- Pane label upper Y offset. */
  101. int label_ly; /* -- Pane label lower Y offset. */
  102. int s_count; /* -- Selections in this pane. */
  103. struct _xmselect *s_list; /* -- Selection window list. */
  104. char *pad_l10; /* ---- */
  105. struct _xmwindow *pad_l11; /* ---- */
  106. } XMPane;
  107. typedef struct _xmselect {
  108. struct _xmselect *next; /* Next obj pointer (for emacs_insque). */
  109. struct _xmselect *prev; /* Prev obj pointer (for emacs_insque). */
  110. XMWType type; /* Type of window. */
  111. Window window; /* X Window Id. */
  112. Window parent; /* X Window id of parent window. */
  113. int window_x; /* Window upper left X coordinate. */
  114. int window_y; /* Window upper left y coordinate. */
  115. int window_w; /* Window width. */
  116. int window_h; /* Window height. */
  117. int active; /* Window active? */
  118. int activated; /* Window activated? */
  119. int serial; /* -- Selection serial number. */
  120. char *label; /* -- Selection label. */
  121. int label_width; /* -- Selection label width in pixels. */
  122. int label_length; /* -- Selection label length in chars. */
  123. int label_x; /* -- Selection label X offset. */
  124. int label_y; /* -- Selection label Y offset. */
  125. int pad_l7; /* ---- */
  126. int pad_l8; /* ---- */
  127. struct _xmwindow *pad_l9; /* ---- */
  128. char *data; /* -- Selection data pointer. */
  129. struct _xmpane *parent_p; /* -- Selection parent pane structure. */
  130. char const *help_string; /* Help string or null. */
  131. } XMSelect;
  132. /*
  133. * Define the XMStyle datatype.
  134. *
  135. * Menu presentation style information.
  136. *
  137. */
  138. typedef enum _xmstyle {
  139. LEFT, /* Left oriented object. */
  140. RIGHT, /* Right oriented object. */
  141. CENTER /* Center oriented object. */
  142. } XMStyle;
  143. /*
  144. * Define the XMMode datatype.
  145. *
  146. * Menu presentation mode information.
  147. *
  148. */
  149. typedef enum _xmmode {
  150. BOX, /* BOXed graphic rendition. */
  151. INVERT /* INVERTed graphic rendition. */
  152. } XMMode;
  153. /*
  154. * Define the XMenu datatype.
  155. *
  156. * All dimensions are in pixels unless otherwise noted.
  157. */
  158. typedef struct _xmenu {
  159. /* -------------------- Menu data -------------------- */
  160. XMStyle menu_style; /* Menu display style. */
  161. XMMode menu_mode; /* Menu display mode. */
  162. int freeze; /* Freeze server mode? */
  163. int aeq; /* Asynchronous Event Queuing mode? */
  164. int recompute; /* Recompute menu dependencies? */
  165. Window parent; /* Menu's parent window. */
  166. int width; /* Overall menu width. */
  167. int height; /* Overall menu height. */
  168. int x_pos; /* Overall menu origin. */
  169. int y_pos; /* Overall menu origin. */
  170. Cursor mouse_cursor; /* Mouse cursor raster. */
  171. XAssocTable *assoc_tab; /* XMWindow association table. */
  172. XMPane *p_list; /* List of XMPanes. */
  173. /* -------------------- Pane window data -------------------- */
  174. XMStyle p_style; /* Pane display style. */
  175. int p_events; /* Pane window X events. */
  176. XFontStruct *p_fnt_info; /* Flag font info structure. */
  177. GC pane_GC; /* Pane graphics context. */
  178. int p_fnt_pad; /* Fixed flag font padding in pixels. */
  179. double p_spread; /* Pane spread in flag height fractions. */
  180. int p_bdr_width; /* Pane border width. */
  181. int flag_height; /* Flag height. */
  182. int p_width; /* Menu pane width. */
  183. int p_height; /* Menu pane height. */
  184. int p_x_off; /* Pane window X offset. */
  185. int p_y_off; /* Pane window Y offset. */
  186. int p_count; /* Number of panes per menu. */
  187. /* -------------------- Selection window data -------------------- */
  188. XMStyle s_style; /* Selection display style. */
  189. int s_events; /* Selection window X events. */
  190. XFontStruct *s_fnt_info; /* Body font info structure. */
  191. int s_fnt_pad; /* Fixed body font padding in pixels. */
  192. double s_spread; /* Select spread in line height fractions. */
  193. int s_bdr_width; /* Select border width. */
  194. int s_width; /* Selection window width. */
  195. int s_height; /* Selection window height. */
  196. int s_x_off; /* Selection window X offset. */
  197. int s_y_off; /* Selection window Y offset. */
  198. int s_count; /* Maximum number of selections per pane. */
  199. GC normal_select_GC; /* GC used for inactive selections. */
  200. GC inverse_select_GC; /* GC used for active (current) selection. */
  201. GC inact_GC; /* GC used for inactive selections and */
  202. /* panes headers. */
  203. /* -------------------- Color data -------------------- */
  204. unsigned long p_bdr_color; /* Color of pane border pixmap. */
  205. unsigned long s_bdr_color; /* Color of selection border pixmap. */
  206. unsigned long p_frg_color; /* Color of pane foreground pixmap. */
  207. unsigned long s_frg_color; /* Color of selection pixmap. */
  208. unsigned long bkgnd_color; /* Color of menu background pixmap. */
  209. /* -------------------- Pixmap data -------------------- */
  210. Pixmap p_bdr_pixmap; /* Pane border pixmap. */
  211. Pixmap s_bdr_pixmap; /* Selection border pixmap. */
  212. Pixmap p_frg_pixmap; /* Pane foreground pixmap. */
  213. Pixmap s_frg_pixmap; /* Selection foreground pixmap. */
  214. Pixmap bkgnd_pixmap; /* Menu background pixmap. */
  215. Pixmap inact_pixmap; /* Menu inactive pixmap. */
  216. } XMenu;
  217. typedef void (*Wait_func)(void*);
  218. /*
  219. * XMenu library routine declarations.
  220. */
  221. XMenu *XMenuCreate(Display *display, Window parent, char const *def_env);
  222. int XMenuAddPane(Display *display, XMenu *menu, char const *label, int active);
  223. int XMenuAddSelection(Display *display, XMenu *menu, int p_num, char *data, char *label, int active, char const *help);
  224. int XMenuInsertPane(XMenu *menu, int p_num, char *label, int active);
  225. int XMenuInsertSelection(XMenu *menu, int p_num, int s_num, char *data, char *label, int active);
  226. int XMenuFindPane(XMenu *menu, char *label);
  227. int XMenuFindSelection(XMenu *menu, int p_num, char *label);
  228. int XMenuChangePane(XMenu *menu, int p_num, char *label);
  229. int XMenuChangeSelection(Display *display, XMenu *menu, int p_num, int s_num, char *data, int data_sw, char *label, int label_sw);
  230. int XMenuSetPane(XMenu *menu, int p_num, int active);
  231. int XMenuSetSelection(XMenu *menu, int p_num, int s_num, int active);
  232. int XMenuRecompute(Display *display, XMenu *menu);
  233. void XMenuEventHandler(int (*handler) (XEvent *));
  234. int XMenuLocate(Display *display, XMenu *menu, int p_num, int s_num, int x_pos, int y_pos, int *ul_x, int *ul_y, int *width, int *height);
  235. void XMenuSetFreeze(XMenu *menu, int freeze);
  236. void XMenuActivateSetWaitFunction(Wait_func func, void *data);
  237. int XMenuActivate(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, unsigned int event_mask, char **data, void (*help_callback) (char const *, int, int));
  238. char *XMenuPost(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, int event_mask);
  239. int XMenuDeletePane(Display *display, XMenu *menu, int p_num);
  240. int XMenuDeleteSelection(Display *display, XMenu *menu, int p_num, int s_num);
  241. void XMenuDestroy(Display *display, XMenu *menu);
  242. char const *XMenuError(void);
  243. void XMenuSetAEQ(XMenu *menu, int aeq);
  244. #endif
  245. /* Don't add after this point. */