Create.c 20 KB

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