root/oldXMenu/Create.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. XAllocDisplayColor
  2. XMenuCreate

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

/* [<][>][^][v][top][bottom][index][help] */