Create.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. Copyright (C) 1993-1994, 2001-2015 Free Software Foundation, Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * XMenu: MIT Project Athena, X Window system menu package
  17. *
  18. * XMenuCreate - Creates an X window system menu object.
  19. *
  20. * Author: Tony Della Fera, DEC
  21. * January 23, 1986
  22. *
  23. */
  24. #include "XMenuInt.h"
  25. #include <stdlib.h>
  26. #ifdef EMACS_BITMAP_FILES
  27. #include "../src/bitmaps/dimple1.xbm"
  28. #include "../src/bitmaps/dimple3.xbm"
  29. #include "../src/bitmaps/gray1.xbm"
  30. #include "../src/bitmaps/gray3.xbm"
  31. #include "../src/bitmaps/crosswv.xbm"
  32. #include "../src/bitmaps/leftptr.xbm"
  33. #include "../src/bitmaps/leftpmsk.xbm"
  34. #include "../src/bitmaps/rtptr.xbm"
  35. #include "../src/bitmaps/rtpmsk.xbm"
  36. #include "../src/bitmaps/cntrptr.xbm"
  37. #include "../src/bitmaps/cntrpmsk.xbm"
  38. #include "../src/bitmaps/stipple.xbm"
  39. #else
  40. #include <X11/bitmaps/dimple1>
  41. #include <X11/bitmaps/dimple3>
  42. #include <X11/bitmaps/gray1>
  43. #include <X11/bitmaps/gray3>
  44. #include <X11/bitmaps/cross_weave>
  45. #include <X11/bitmaps/left_ptr>
  46. #include <X11/bitmaps/left_ptrmsk>
  47. #include <X11/bitmaps/right_ptr>
  48. #include <X11/bitmaps/right_ptrmsk>
  49. #include <X11/bitmaps/cntr_ptr>
  50. #include <X11/bitmaps/cntr_ptrmsk>
  51. #include <X11/bitmaps/stipple>
  52. #endif /* not EMACS_BITMAP_FILES */
  53. #define DEF_FREEZE 0
  54. #define DEF_REVERSE 0
  55. #define DEF_MENU_STYLE LEFT
  56. #define DEF_MENU_MODE BOX
  57. #define DEF_INACT_PNUM 3
  58. #define DEF_P_STYLE CENTER
  59. #define DEF_P_EVENTS (EnterWindowMask | ExposureMask)
  60. #define DEF_P_FNT_NAME "fixed"
  61. #define DEF_P_SPREAD 0.5
  62. #define DEF_P_BDR_WIDTH 2
  63. #define DEF_S_STYLE LEFT
  64. #define DEF_S_EVENTS (EnterWindowMask | LeaveWindowMask)
  65. #define DEF_S_FNT_NAME "fixed"
  66. #define DEF_S_SPREAD 0.10
  67. #define DEF_S_BDR_WIDTH 1
  68. #define XASSOC_TABLE_SIZE 64
  69. char *x_get_resource_string (char const *, char const *);
  70. static Status
  71. XAllocDisplayColor(Display *display, Colormap map, char const *colorName,
  72. XColor *color, XColor *junk)
  73. {
  74. return (colorName!=0 &&
  75. XParseColor(display, map, colorName, color) &&
  76. XAllocColor(display, map, color));
  77. }
  78. XMenu *
  79. XMenuCreate(Display *display, Window parent, register char const *def_env)
  80. /* ID of previously opened display */
  81. /* Window ID of the menu's parent window. */
  82. /* X Defaults program environment name. */
  83. {
  84. register char *def_val; /* X Default value temp variable. */
  85. register XMenu *menu; /* Pointer to the new menu. */
  86. XMStyle menu_style; /* Menu display style. */
  87. XMMode menu_mode; /* Menu display mode. */
  88. XMPane *pane; /* Pane list header. */
  89. XAssocTable *assoc_tab; /* XAssocTable pointer. */
  90. int freeze; /* Freeze server mode. */
  91. int reverse; /* Reverse video mode. */
  92. XMStyle p_style; /* Pane display style. */
  93. char const *p_fnt_name; /* Flag font name. */
  94. XFontStruct *p_fnt_info; /* Flag font structure */
  95. int p_fnt_pad; /* Flag font padding in pixels. */
  96. double p_spread; /* Pane spread in flag height fractions. */
  97. int p_fnt_height; /* Pane character height. */
  98. int p_bdr_width; /* Pane border width. */
  99. int flag_height; /* Flag window height. */
  100. int p_height; /* Pane window height. */
  101. int p_x_off; /* Pane X offset. */
  102. int p_y_off; /* Pane Y offset. */
  103. GC pane_GC; /* Pane graphics context. */
  104. XMStyle s_style; /* Selection display style. */
  105. char const *s_fnt_name; /* Selection font name. */
  106. XFontStruct *s_fnt_info; /* Selection font structure. */
  107. int s_fnt_pad; /* Selection font padding in pixels. */
  108. int s_fnt_height; /* Selection font character height */
  109. double s_spread; /* Select spread in line height fractions. */
  110. int s_bdr_width; /* Highlight border width. */
  111. int s_height; /* Selection window height. */
  112. int s_x_off; /* Selection window X offset. */
  113. int s_y_off; /* Selection window Y offset. */
  114. GC normal_select_GC; /* GC used for normal video selection. */
  115. GC inverse_select_GC; /* GC used for inverse video selection. */
  116. GC inact_GC; /* GC for inactive pane header and */
  117. /* selections. */
  118. XColor color_def; /* Temp color definition holder. */
  119. XColor p_bdr_color; /* Color of border. */
  120. XColor s_bdr_color; /* Color of highlight. */
  121. XColor p_frg_color; /* Color of pane foreground color. */
  122. XColor s_frg_color; /* Color of selection foreground. */
  123. XColor bkgnd_color; /* Color of background.. */
  124. XColor mouse_color; /* Color of mouse cursor. */
  125. Cursor mouse_cursor; /* Mouse cursor. */
  126. Pixmap inact_bitmap; /* Menu inactive pixmap. */
  127. int inact_pnum; /* Inactive background pattern number. */
  128. Pixmap cursor; /* Cursor pixmap holder. */
  129. Pixmap cursor_mask; /* Cursor mask pixmap holder. */
  130. Pixmap stipple_pixmap; /* Stipple mask for half-tone text. */
  131. unsigned long valuemask;
  132. XGCValues *values;
  133. Window root = RootWindow (display, DefaultScreen (display));
  134. /*
  135. * Calloc the XMenu structure and the initial pane.
  136. */
  137. menu = (XMenu *)calloc(1, sizeof(XMenu));
  138. if (menu == NULL) {
  139. _XMErrorCode = XME_CALLOC;
  140. return(NULL);
  141. }
  142. pane = (XMPane *)calloc(1, sizeof(XMPane));
  143. if (pane == NULL) {
  144. _XMErrorCode = XME_CALLOC;
  145. return(NULL);
  146. }
  147. /*
  148. * Create the XAssocTable
  149. */
  150. assoc_tab = (XAssocTable *)XCreateAssocTable(XASSOC_TABLE_SIZE);
  151. if(assoc_tab == NULL) {
  152. _XMErrorCode= XME_CREATE_ASSOC;
  153. return(NULL);
  154. }
  155. /*
  156. * Set up the default environment name.
  157. */
  158. if (def_env == NULL || *def_env == '\0') def_env = "XMenu";
  159. /*
  160. * Set up internal fail-safe defaults.
  161. */
  162. freeze = DEF_FREEZE;
  163. reverse = DEF_REVERSE;
  164. menu_style = DEF_MENU_STYLE;
  165. menu_mode = DEF_MENU_MODE;
  166. inact_pnum = DEF_INACT_PNUM;
  167. p_style = DEF_P_STYLE;
  168. p_spread = DEF_P_SPREAD;
  169. p_fnt_name = DEF_P_FNT_NAME;
  170. p_bdr_width = DEF_P_BDR_WIDTH;
  171. s_style = DEF_S_STYLE;
  172. s_spread = DEF_S_SPREAD;
  173. s_fnt_name = DEF_S_FNT_NAME;
  174. s_bdr_width = DEF_S_BDR_WIDTH;
  175. /*
  176. * Get default values from X.
  177. */
  178. def_val = x_get_resource_string ("menuFreeze", "MenuFreeze");
  179. if (def_val != NULL) {
  180. if (strcmp(def_val, "on") == 0) freeze = 1;
  181. else if (strcmp(def_val, "off") == 0) freeze = 0;
  182. }
  183. def_val = x_get_resource_string ("menuReverseVideo", "MenuReverseVideo");
  184. if (def_val != NULL) {
  185. if (strcmp(def_val, "on") == 0) reverse = 1;
  186. else if (strcmp(def_val, "off") == 0) reverse = 0;
  187. }
  188. def_val = x_get_resource_string ("menuStyle", "MenuStyle");
  189. if (def_val != NULL) {
  190. if (strcmp(def_val, "right_hand") == 0) menu_style = RIGHT;
  191. else if (strcmp(def_val, "left_hand") == 0) menu_style = LEFT;
  192. else if (strcmp(def_val, "center") == 0) menu_style = CENTER;
  193. }
  194. def_val = x_get_resource_string ("menuMode", "MenuMode");
  195. if (def_val != NULL) {
  196. if (strcmp(def_val, "box") == 0) menu_mode = BOX;
  197. else if (strcmp(def_val, "invert") == 0) menu_mode = INVERT;
  198. }
  199. def_val = x_get_resource_string ("menuMouse", "MenuMouse");
  200. if (
  201. def_val != NULL &&
  202. DisplayCells(display, DefaultScreen(display)) > 2 &&
  203. XAllocDisplayColor(display,
  204. DefaultColormap(display, DefaultScreen(display)),
  205. def_val,
  206. &mouse_color, &color_def)
  207. );
  208. else if (reverse &&
  209. XAllocDisplayColor(display,
  210. DefaultColormap(display, DefaultScreen(display)),
  211. "white",
  212. &mouse_color, &color_def)
  213. );
  214. else if (XAllocDisplayColor(display,
  215. DefaultColormap(display, DefaultScreen(display)),
  216. "black",
  217. &mouse_color, &color_def)
  218. );
  219. else {}
  220. def_val = x_get_resource_string ("menuBackground", "MenuBackground");
  221. if (
  222. def_val != NULL &&
  223. DisplayCells(display, DefaultScreen(display)) > 2 &&
  224. XAllocDisplayColor(display,
  225. DefaultColormap(display, DefaultScreen(display)),
  226. def_val,
  227. &bkgnd_color, &color_def)
  228. );
  229. else if (reverse &&
  230. XAllocDisplayColor(display,
  231. DefaultColormap(display, DefaultScreen(display)),
  232. "black",
  233. &bkgnd_color, &color_def)
  234. );
  235. else if (XAllocDisplayColor(display,
  236. DefaultColormap(display, DefaultScreen(display)),
  237. "white",
  238. &bkgnd_color, &color_def)
  239. );
  240. else {}
  241. def_val = x_get_resource_string ("menuInactivePattern", "MenuInactivePattern");
  242. if (def_val != NULL) {
  243. if (strcmp(def_val, "dimple1") == 0) inact_pnum = 0;
  244. else if (strcmp(def_val, "dimple3") == 0) inact_pnum = 1;
  245. else if (strcmp(def_val, "gray1") == 0) inact_pnum = 2;
  246. else if (strcmp(def_val, "gray3") == 0) inact_pnum = 3;
  247. else if (strcmp(def_val, "cross_weave") == 0) inact_pnum = 4;
  248. }
  249. def_val = x_get_resource_string ("paneStyle", "PaneStyle");
  250. if (def_val != NULL) {
  251. if (strcmp(def_val, "flush_left") == 0) p_style = LEFT;
  252. else if (strcmp(def_val, "flush_right") == 0) p_style = RIGHT;
  253. else if (strcmp(def_val, "center") == 0) p_style = CENTER;
  254. }
  255. def_val = x_get_resource_string ("paneFont", "PaneFont");
  256. if (def_val != NULL) p_fnt_name = def_val;
  257. def_val = x_get_resource_string ("paneForeground", "PaneForeground");
  258. if (
  259. def_val != NULL &&
  260. DisplayCells(display, DefaultScreen(display)) > 2
  261. )
  262. XAllocDisplayColor(display, DefaultColormap(display,
  263. DefaultScreen(display)),
  264. def_val,
  265. &p_frg_color, &color_def);
  266. else if (reverse) XAllocDisplayColor(display,
  267. DefaultColormap(display,
  268. DefaultScreen(display)),
  269. "white",
  270. &p_frg_color, &color_def);
  271. else XAllocDisplayColor(display,
  272. DefaultColormap(display, DefaultScreen(display)),
  273. "black",
  274. &p_frg_color, &color_def);
  275. def_val = x_get_resource_string ("paneBorder", "PaneBorder");
  276. if (
  277. def_val != NULL &&
  278. DisplayCells(display, DefaultScreen(display)) > 2 &&
  279. XAllocDisplayColor(display,
  280. DefaultColormap(display, DefaultScreen(display)),
  281. def_val,
  282. &p_bdr_color, &color_def)
  283. );
  284. else if (reverse &&
  285. XAllocDisplayColor(display,
  286. DefaultColormap(display, DefaultScreen(display)),
  287. "white",
  288. &p_bdr_color, &color_def)
  289. );
  290. else XAllocDisplayColor(display,
  291. DefaultColormap(display, DefaultScreen(display)),
  292. "black",
  293. &p_bdr_color, &color_def);
  294. def_val = x_get_resource_string ("paneBorderWidth", "PaneBorderWidth");
  295. if (def_val != NULL) p_bdr_width = atoi(def_val);
  296. def_val = x_get_resource_string ("paneSpread", "PaneSpread");
  297. if (def_val != NULL) p_spread = atof(def_val);
  298. def_val = x_get_resource_string ("selectionStyle", "SelectionStyle");
  299. if (def_val != NULL) {
  300. if (strcmp(def_val, "flush_left") == 0) s_style = LEFT;
  301. else if (strcmp(def_val, "flush_right") == 0) s_style = RIGHT;
  302. else if (strcmp(def_val, "center") == 0) s_style = CENTER;
  303. }
  304. def_val = x_get_resource_string ("selectionFont", "SelectionFont");
  305. if (def_val != NULL) s_fnt_name = def_val;
  306. def_val = x_get_resource_string ("selectionForeground", "SelectionForeground");
  307. if (
  308. def_val != NULL &&
  309. DisplayCells(display, DefaultScreen(display)) > 2 &&
  310. XAllocDisplayColor(display,
  311. DefaultColormap(display, DefaultScreen(display)),
  312. def_val,
  313. &s_frg_color, &color_def)
  314. );
  315. else if (reverse &&
  316. XAllocDisplayColor(display,
  317. DefaultColormap(display, DefaultScreen(display)),
  318. "white",
  319. &s_frg_color, &color_def)
  320. ) ;
  321. else if (XAllocDisplayColor(display,
  322. DefaultColormap(display, DefaultScreen(display)),
  323. "black",
  324. &s_frg_color, &color_def)
  325. ) ;
  326. else {}
  327. def_val = x_get_resource_string ("selectionBorder", "SelectionBorder");
  328. if (
  329. def_val != NULL &&
  330. DisplayCells(display, DefaultScreen(display)) > 2 &&
  331. XAllocDisplayColor(display,
  332. DefaultColormap(display, DefaultScreen(display)),
  333. def_val,
  334. &s_bdr_color, &color_def)
  335. ) ;
  336. else if (reverse &&
  337. XAllocDisplayColor(display,
  338. DefaultColormap(display, DefaultScreen(display)),
  339. "white",
  340. &s_bdr_color, &color_def)
  341. ) ;
  342. else if (XAllocDisplayColor(display,
  343. DefaultColormap(display, DefaultScreen(display)),
  344. "black",
  345. &s_bdr_color, &color_def)
  346. ) ;
  347. else {}
  348. def_val = x_get_resource_string ("selectionBorderWidth", "SelectionBorderWidth");
  349. if (def_val != NULL) s_bdr_width = atoi(def_val);
  350. def_val = x_get_resource_string ("selectionSpread", "SelectionSpread");
  351. if (def_val != NULL) s_spread = atof(def_val);
  352. /*
  353. * Create and store the inactive pattern pixmap.
  354. */
  355. {
  356. char *data = NULL;
  357. int width, height;
  358. switch (inact_pnum)
  359. {
  360. case 0:
  361. data = (char *)dimple1_bits;
  362. width = dimple1_width;
  363. height = dimple1_height;
  364. break;
  365. case 1:
  366. data = (char *)dimple3_bits;
  367. width = dimple3_width;
  368. height = dimple3_height;
  369. break;
  370. case 2:
  371. data = (char *)gray1_bits;
  372. width = gray1_width;
  373. height = gray1_height;
  374. break;
  375. case 3:
  376. data = (char *)gray3_bits;
  377. width = gray3_width;
  378. height = gray3_height;
  379. break;
  380. case 4:
  381. data = (char *)cross_weave_bits;
  382. width = cross_weave_width;
  383. height = cross_weave_height;
  384. break;
  385. }
  386. if (! data)
  387. {
  388. _XMErrorCode = XME_STORE_BITMAP;
  389. return(NULL);
  390. }
  391. inact_bitmap =
  392. XCreatePixmapFromBitmapData
  393. (display, root, data, width, height,
  394. p_frg_color.pixel, bkgnd_color.pixel,
  395. DisplayPlanes (display, DefaultScreen (display)));
  396. }
  397. /*
  398. * Load the mouse cursor.
  399. */
  400. switch (menu_style) {
  401. case LEFT:
  402. cursor = XCreateBitmapFromData(display,
  403. root,
  404. left_ptr_bits,
  405. left_ptr_width,
  406. left_ptr_height);
  407. cursor_mask = XCreateBitmapFromData(display,
  408. root,
  409. left_ptrmsk_bits,
  410. left_ptrmsk_width,
  411. left_ptrmsk_height);
  412. mouse_cursor = XCreatePixmapCursor(
  413. display,
  414. cursor, cursor_mask,
  415. &mouse_color, &bkgnd_color,
  416. left_ptr_x_hot,
  417. left_ptr_y_hot
  418. );
  419. XFreePixmap(display, cursor);
  420. XFreePixmap(display, cursor_mask);
  421. break;
  422. case RIGHT:
  423. cursor = XCreateBitmapFromData(display,
  424. root,
  425. right_ptr_bits,
  426. right_ptr_width,
  427. right_ptr_height);
  428. cursor_mask = XCreateBitmapFromData(display,
  429. root,
  430. right_ptrmsk_bits,
  431. right_ptrmsk_width,
  432. right_ptrmsk_height);
  433. mouse_cursor = XCreatePixmapCursor(
  434. display,
  435. cursor, cursor_mask,
  436. &mouse_color, &bkgnd_color,
  437. right_ptr_x_hot,
  438. right_ptr_y_hot
  439. );
  440. XFreePixmap(display, cursor);
  441. XFreePixmap(display, cursor_mask);
  442. break;
  443. case CENTER:
  444. cursor = XCreateBitmapFromData(display,
  445. root,
  446. cntr_ptr_bits,
  447. cntr_ptr_width,
  448. cntr_ptr_height);
  449. cursor_mask = XCreateBitmapFromData(display,
  450. root,
  451. cntr_ptrmsk_bits,
  452. cntr_ptrmsk_width,
  453. cntr_ptrmsk_height);
  454. mouse_cursor = XCreatePixmapCursor(
  455. display,
  456. cursor, cursor_mask,
  457. &mouse_color, &bkgnd_color,
  458. cntr_ptr_x_hot,
  459. cntr_ptr_y_hot
  460. );
  461. XFreePixmap(display, cursor);
  462. XFreePixmap(display, cursor_mask);
  463. break;
  464. default:
  465. /* Error! Invalid style parameter. */
  466. _XMErrorCode = XME_STYLE_PARAM;
  467. return(NULL);
  468. }
  469. if (mouse_cursor == _X_FAILURE) {
  470. _XMErrorCode = XME_CREATE_CURSOR;
  471. return(NULL);
  472. }
  473. /*
  474. * Open the pane and selection fonts.
  475. */
  476. p_fnt_info = XLoadQueryFont(display, p_fnt_name);
  477. if (p_fnt_info == NULL) {
  478. _XMErrorCode = XME_OPEN_FONT;
  479. return(NULL);
  480. }
  481. s_fnt_info = XLoadQueryFont(display, s_fnt_name);
  482. if (s_fnt_info == NULL) {
  483. _XMErrorCode = XME_OPEN_FONT;
  484. return(NULL);
  485. }
  486. /*
  487. * Calculate the fixed padding value in pixels for each font.
  488. */
  489. p_fnt_height = p_fnt_info->max_bounds.ascent + p_fnt_info->max_bounds.descent;
  490. s_fnt_height = s_fnt_info->max_bounds.ascent + s_fnt_info->max_bounds.descent;
  491. p_fnt_pad = s_spread * p_fnt_height;
  492. s_fnt_pad = s_spread * s_fnt_height;
  493. /*
  494. * Calculate fixed height and offset requirements.
  495. */
  496. flag_height = p_fnt_height + (p_fnt_pad << 1);
  497. p_height = 0;
  498. p_y_off = flag_height + p_bdr_width;
  499. p_x_off = p_y_off * p_spread;
  500. s_height = s_fnt_height + (s_fnt_pad << 1) + (s_bdr_width << 1);
  501. s_y_off = s_height;
  502. s_x_off = p_x_off;
  503. /*
  504. * Set up the pane list header.
  505. */
  506. pane->next = pane;
  507. pane->prev = pane;
  508. pane->type = PL_HEADER;
  509. pane->serial = -1;
  510. /*
  511. * Initialize the internal pane and selection creation queues.
  512. */
  513. _XMWinQueInit();
  514. /*
  515. * Create pane, active, and inactive GC's.
  516. */
  517. values = (XGCValues *)malloc(sizeof(XGCValues));
  518. valuemask = (GCForeground | GCBackground | GCFont | GCLineWidth);
  519. /*
  520. * First, pane.
  521. */
  522. values->foreground = p_frg_color.pixel;
  523. values->background = bkgnd_color.pixel;
  524. values->font = p_fnt_info->fid;
  525. values->line_width = p_bdr_width;
  526. pane_GC = XCreateGC(
  527. display,
  528. root,
  529. valuemask,
  530. values);
  531. /*
  532. * Then normal video selection.
  533. */
  534. values->foreground = s_frg_color.pixel;
  535. values->background = bkgnd_color.pixel;
  536. values->font = s_fnt_info->fid;
  537. values->line_width = s_bdr_width;
  538. normal_select_GC = XCreateGC(display,
  539. root,
  540. valuemask,
  541. values);
  542. /*
  543. * Inverse video selection.
  544. */
  545. values->foreground = bkgnd_color.pixel;
  546. values->background = s_frg_color.pixel;
  547. values->font = s_fnt_info->fid;
  548. values->line_width = s_bdr_width;
  549. inverse_select_GC = XCreateGC(display,
  550. root,
  551. valuemask,
  552. values);
  553. stipple_pixmap = XCreateBitmapFromData(display,
  554. root,
  555. stipple_bits,
  556. stipple_width,
  557. stipple_height);
  558. /*
  559. * Finally, inactive pane header and selections
  560. */
  561. valuemask |= (GCFillStyle | GCStipple);
  562. values->foreground = s_frg_color.pixel;
  563. values->background = bkgnd_color.pixel;
  564. values->font = s_fnt_info->fid;
  565. values->line_width = s_bdr_width;
  566. values->fill_style = FillStippled;
  567. values->stipple = stipple_pixmap;
  568. inact_GC = XCreateGC(display,
  569. root,
  570. valuemask,
  571. values);
  572. valuemask |= (GCGraphicsExposures);
  573. values->graphics_exposures = False;
  574. /*
  575. * Construct the XMenu object.
  576. */
  577. /* -------------------- Menu data -------------------- */
  578. menu->menu_style = menu_style;
  579. menu->menu_mode = menu_mode;
  580. menu->freeze = freeze;
  581. menu->aeq = 0;
  582. menu->recompute = 1;
  583. menu->parent = parent;
  584. menu->height = 0;
  585. menu->width = 0;
  586. menu->mouse_cursor = mouse_cursor;
  587. menu->assoc_tab = assoc_tab;
  588. menu->p_list = pane;
  589. /* -------------------- Pane window data -------------------- */
  590. menu->p_style = p_style;
  591. menu->p_events = DEF_P_EVENTS;
  592. menu->p_fnt_info = p_fnt_info;
  593. menu->p_fnt_pad = p_fnt_pad;
  594. menu->p_spread = p_spread;
  595. menu->p_bdr_width = p_bdr_width;
  596. menu->flag_height = flag_height;
  597. menu->p_width = 0;
  598. menu->p_height = p_height;
  599. menu->p_x_off = p_x_off;
  600. menu->p_y_off = p_y_off;
  601. menu->p_count = 0;
  602. menu->pane_GC = pane_GC;
  603. menu->x_pos = 0;
  604. menu->y_pos = 0;
  605. /* -------------------- Selection window data -------------------- */
  606. menu->s_style = s_style;
  607. menu->s_events = DEF_S_EVENTS;
  608. menu->s_fnt_info = s_fnt_info;
  609. menu->s_fnt_pad = s_fnt_pad;
  610. menu->s_spread = s_spread;
  611. menu->s_bdr_width = s_bdr_width; /* unnecessary */
  612. menu->s_width = 0;
  613. menu->s_height = s_height;
  614. menu->s_x_off = s_x_off;
  615. menu->s_y_off = s_y_off;
  616. menu->s_count = 0;
  617. menu->normal_select_GC = normal_select_GC;
  618. menu->inverse_select_GC = inverse_select_GC;
  619. menu->inact_GC = inact_GC;
  620. /* -------------------- Color data -------------------- */
  621. menu->p_bdr_color = p_bdr_color.pixel;
  622. menu->s_bdr_color = s_bdr_color.pixel;
  623. menu->p_frg_color = p_frg_color.pixel;
  624. menu->s_frg_color = s_frg_color.pixel;
  625. menu->bkgnd_color = bkgnd_color.pixel;
  626. /* -------------------- Pixmap data -------------------- */
  627. menu->p_bdr_pixmap = None;
  628. menu->s_bdr_pixmap = None;
  629. menu->p_frg_pixmap = None;
  630. menu->s_frg_pixmap = None;
  631. menu->bkgnd_pixmap = None;
  632. menu->inact_pixmap = inact_bitmap;
  633. /*
  634. * Return the completed XMenu.
  635. */
  636. _XMErrorCode = XME_NO_ERROR;
  637. return(menu);
  638. }