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