Annotation of 43BSDReno/contrib/emacs-18.55/oldXMenu/Create.c, revision 1.1.1.1

1.1       root        1: /* $Header: Create.c,v 1.14 88/02/02 19:02:31 jim 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 "XMenuInt.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:     GC inact_GC_noexpose;
                    108: 
                    109:     XColor color_def;          /* Temp color definition holder. */
                    110:     XColor screen_def;         /* Temp screen color defintion holder */
                    111:     XColor p_bdr_color;                /* Color of border. */
                    112:     XColor s_bdr_color;                /* Color of highlight. */
                    113:     XColor p_frg_color;                /* Color of pane foreground color. */
                    114:     XColor s_frg_color;                /* Color of selection foreground. */
                    115:     XColor bkgnd_color;                /* Color of background.. */
                    116:     XColor mouse_color;                /* Color of mouse cursor. */
                    117:     Cursor mouse_cursor;       /* Mouse cursor. */
                    118:     Pixmap inact_bitmap;        /* Menu inactive pixmap. */
                    119: 
                    120:     int inact_pnum;            /* Inactive background pattern number. */
                    121: 
                    122:     Pixel p_bdr_pixel;         /* Pane border pixel. */
                    123:     Pixel s_bdr_pixel;         /* Selection border pixel. */
                    124:     Pixel p_frg_pixel;         /* Pane forground pixel. */
                    125:     Pixel s_frg_pixel;         /* Selection forground pixel. */
                    126:     Pixel bkgnd_pixel;         /* Menu background pixel. */
                    127: 
                    128:     int *width, *height;
                    129:     Pixmap *bitmap;
                    130:     int *x_hot, *y_hot;
                    131:     int status;                 /* Return code from XReadBitmapFile. */
                    132: 
                    133:     Pixmap cursor;              /* Cursor pixmap holder. */
                    134:     Pixmap cursor_mask;         /* Cursor mask pixmap holder. */
                    135:     Pixmap stipple_pixmap;     /* Stippple mask for half-tone text. */
                    136:     unsigned long valuemask;
                    137:     XGCValues *values;
                    138:     
                    139: 
                    140:     /*
                    141:      * Calloc the XMenu structure and the initial pane.
                    142:      */
                    143:     menu = (XMenu *)calloc(1, sizeof(XMenu));
                    144:     if (menu == NULL) {
                    145:        _XMErrorCode = XME_CALLOC;
                    146:        return(NULL);
                    147:     }
                    148:     pane = (XMPane *)calloc(1, sizeof(XMPane));
                    149:     if (pane == NULL) {
                    150:        _XMErrorCode = XME_CALLOC;
                    151:        return(NULL);
                    152:     }
                    153:     
                    154:     /* 
                    155:      * Create the XAssocTable
                    156:      */
                    157:     assoc_tab = (XAssocTable *)XCreateAssocTable(XASSOC_TABLE_SIZE);
                    158:     if(assoc_tab == NULL) {
                    159:        _XMErrorCode= XME_CREATE_ASSOC;
                    160:        return(NULL);
                    161:     }
                    162: 
                    163:     /*
                    164:      * Set up the default environment name.
                    165:      */
                    166:     if (def_env == NULL || *def_env == '\0') def_env = "XMenu";
                    167: 
                    168:     /*
                    169:      * Set up internal fail-safe defaults.
                    170:      */
                    171:     freeze = DEF_FREEZE;
                    172:     reverse = DEF_REVERSE;
                    173:     menu_style = DEF_MENU_STYLE;
                    174:     menu_mode = DEF_MENU_MODE;
                    175:     inact_pnum = DEF_INACT_PNUM;
                    176: 
                    177:     p_style = DEF_P_STYLE;
                    178:     p_spread = DEF_P_SPREAD;
                    179:     p_fnt_name = DEF_P_FNT_NAME;
                    180:     p_bdr_width = DEF_P_BDR_WIDTH;
                    181: 
                    182:     s_style = DEF_S_STYLE;
                    183:     s_spread = DEF_S_SPREAD;
                    184:     s_fnt_name = DEF_S_FNT_NAME;
                    185:     s_bdr_width = DEF_S_BDR_WIDTH;
                    186: 
                    187:     /*
                    188:      * Get default values from X.
                    189:      */
                    190:     def_val = XGetDefault(display, def_env, "MenuFreeze");
                    191:     if (def_val != NULL) {
                    192:        if (strcmp(def_val, "on") == 0) freeze = 1;
                    193:        else if (strcmp(def_val, "off") == 0) freeze = 0;
                    194:     }
                    195: 
                    196:     def_val = XGetDefault(display, def_env, "MenuReverseVideo");
                    197:     if (def_val != NULL) {
                    198:        if (strcmp(def_val, "on") == 0) reverse = 1;
                    199:        else if (strcmp(def_val, "off") == 0) reverse = 0;
                    200:     }
                    201: 
                    202:     def_val = XGetDefault(display, def_env, "MenuStyle");
                    203:     if (def_val != NULL) {
                    204:        if (strcmp(def_val, "right_hand") == 0) menu_style = RIGHT;
                    205:        else if (strcmp(def_val, "left_hand") == 0) menu_style = LEFT;
                    206:        else if (strcmp(def_val, "center") == 0) menu_style = CENTER;
                    207:     }
                    208: 
                    209:     def_val = XGetDefault(display, def_env, "MenuMode");
                    210:     if (def_val != NULL) {
                    211:        if (strcmp(def_val, "box") == 0) menu_mode = BOX;
                    212:        else if (strcmp(def_val, "invert") == 0) menu_mode = INVERT;
                    213:     }
                    214:     
                    215:     def_val = XGetDefault(display, def_env, "MenuMouse");
                    216:     if (
                    217:        def_val != NULL &&
                    218:        DisplayCells(display, DefaultScreen(display)) > 2 &&
                    219:        XAllocNamedColor(display, 
                    220:                         DefaultColormap(display, DefaultScreen(display)), 
                    221:                         def_val, 
                    222:                         &mouse_color, &color_def)
                    223:        );
                    224:     else if (reverse &&
                    225:             XAllocNamedColor(display,
                    226:                              DefaultColormap(display, DefaultScreen(display)),
                    227:                              "white",
                    228:                              &mouse_color, &color_def)
                    229:             );
                    230:     
                    231:     else if (XAllocNamedColor(display,
                    232:                              DefaultColormap(display, DefaultScreen(display)),
                    233:                              "black", 
                    234:                              &mouse_color, &color_def)
                    235:             );
                    236:     
                    237:     else ;
                    238: 
                    239:     def_val = XGetDefault(display, def_env, "MenuBackground");
                    240:     if (
                    241:        def_val != NULL &&
                    242:        DisplayCells(display, DefaultScreen(display)) > 2 &&
                    243:        XAllocNamedColor(display,
                    244:                         DefaultColormap(display, DefaultScreen(display)),
                    245:                         def_val,
                    246:                         &bkgnd_color, &color_def)
                    247:        );
                    248:     else if (reverse &&
                    249:             XAllocNamedColor(display,
                    250:                              DefaultColormap(display, DefaultScreen(display)),
                    251:                              "black",
                    252:                              &bkgnd_color, &color_def)
                    253:             );
                    254:     else if (XAllocNamedColor(display,
                    255:                              DefaultColormap(display, DefaultScreen(display)),
                    256:                              "white",
                    257:                              &bkgnd_color, &color_def)
                    258:             );
                    259:     else;
                    260: 
                    261:     def_val = XGetDefault(display, def_env, "MenuInactivePattern");
                    262:     if (def_val != NULL) {
                    263:        if (strcmp(def_val, "dimple1") == 0) inact_pnum = 0;
                    264:        else if (strcmp(def_val, "dimple3") == 0) inact_pnum = 1;
                    265:        else if (strcmp(def_val, "gray1") == 0) inact_pnum = 2;
                    266:        else if (strcmp(def_val, "gray3") == 0) inact_pnum = 3;
                    267:        else if (strcmp(def_val, "cross_weave") == 0) inact_pnum = 4;
                    268:     }
                    269: 
                    270:     def_val = XGetDefault(display, def_env, "PaneStyle");
                    271:     if (def_val != NULL) {
                    272:        if (strcmp(def_val, "flush_left") == 0) p_style = LEFT;
                    273:        else if (strcmp(def_val, "flush_right") == 0) p_style = RIGHT;
                    274:        else if (strcmp(def_val, "center") == 0) p_style = CENTER;
                    275:     }
                    276: 
                    277:     def_val = XGetDefault(display, def_env, "PaneFont");
                    278:     if (def_val != NULL) p_fnt_name = def_val;
                    279: 
                    280:     def_val = XGetDefault(display, def_env, "PaneForeground");
                    281:     if (
                    282:        def_val != NULL &&
                    283:        DisplayCells(display, DefaultScreen(display)) > 2 
                    284:        )
                    285:       XAllocNamedColor(display, DefaultColormap(display,
                    286:                                                DefaultScreen(display)),
                    287:                       def_val,
                    288:                       &p_frg_color, &color_def);
                    289:          
                    290:     else if (reverse) XAllocNamedColor(display,
                    291:                                       DefaultColormap(display, 
                    292:                                                       DefaultScreen(display)),
                    293:                                       "white",
                    294:                                       &p_frg_color, &color_def);
                    295:     else XAllocNamedColor(display,
                    296:                          DefaultColormap(display, DefaultScreen(display)),
                    297:                          "black",
                    298:                          &p_frg_color, &color_def);
                    299: 
                    300:     def_val = XGetDefault(display, def_env, "PaneBorder");
                    301:     if (
                    302:        def_val != NULL &&
                    303:        DisplayCells(display, DefaultScreen(display)) > 2 &&
                    304:        XAllocNamedColor(display,
                    305:                         DefaultColormap(display, DefaultScreen(display)),
                    306:                         def_val,
                    307:                         &p_bdr_color, &color_def)
                    308:        );
                    309:     else if (reverse &&
                    310:             XAllocNamedColor(display, 
                    311:                              DefaultColormap(display, DefaultScreen(display)),
                    312:                              "white",
                    313:                              &p_bdr_color, &color_def)
                    314:             );
                    315:     else XAllocNamedColor(display, 
                    316:                          DefaultColormap(display, DefaultScreen(display)),
                    317:                          "black",
                    318:                          &p_bdr_color, &color_def);
                    319:     
                    320:     def_val = XGetDefault(display, def_env, "PaneBorderWidth");
                    321:     if (def_val != NULL) p_bdr_width = atoi(def_val);
                    322:     
                    323:     def_val = XGetDefault(display, def_env, "PaneSpread");
                    324:     if (def_val != NULL) p_spread = atof(def_val);
                    325: 
                    326:     def_val = XGetDefault(display, def_env, "SelectionStyle");
                    327:     if (def_val != NULL) {
                    328:        if (strcmp(def_val, "flush_left") == 0) s_style = LEFT;
                    329:        else if (strcmp(def_val, "flush_right") == 0) s_style = RIGHT;
                    330:        else if (strcmp(def_val, "center") == 0) s_style = CENTER;
                    331:     }
                    332: 
                    333:     def_val = XGetDefault(display, def_env, "SelectionFont");
                    334:     if (def_val != NULL) s_fnt_name = def_val;
                    335: 
                    336:     def_val = XGetDefault(display, def_env, "SelectionForeground");
                    337:     if (
                    338:        def_val != NULL &&
                    339:        DisplayCells(display, DefaultScreen(display)) > 2 &&
                    340:        XAllocNamedColor(display,
                    341:                         DefaultColormap(display, DefaultScreen(display)),
                    342:                         def_val,
                    343:                         &s_frg_color, &color_def)
                    344:        ); 
                    345:     else if (reverse &&
                    346:             XAllocNamedColor(display,
                    347:                              DefaultColormap(display, DefaultScreen(display)),
                    348:                              "white",
                    349:                              &s_frg_color, &color_def)
                    350:             ) ;
                    351:     else if (XAllocNamedColor(display,
                    352:                              DefaultColormap(display, DefaultScreen(display)),
                    353:                              "black",
                    354:                              &s_frg_color, &color_def)
                    355:             ) ;
                    356:     else ;
                    357:     
                    358: 
                    359:     def_val = XGetDefault(display, def_env, "SelectionBorder");
                    360:     if (
                    361:        def_val != NULL &&
                    362:        DisplayCells(display, DefaultScreen(display)) > 2 &&
                    363:        XAllocNamedColor(display,
                    364:                         DefaultColormap(display, DefaultScreen(display)),
                    365:                         def_val,
                    366:                         &s_bdr_color, &color_def)
                    367:        ) ;
                    368:     else if (reverse &&
                    369:             XAllocNamedColor(display, 
                    370:                              DefaultColormap(display, DefaultScreen(display)),
                    371:                              "white",
                    372:                              &s_bdr_color, &color_def)
                    373:             ) ;
                    374:     else if (XAllocNamedColor(display,
                    375:                              DefaultColormap(display, DefaultScreen(display)),
                    376:                              "black",
                    377:                              &s_bdr_color, &color_def)
                    378:             ) ;
                    379:     else ;
                    380: 
                    381:     def_val = XGetDefault(display, def_env, "SelectionBorderWidth");
                    382:     if (def_val != NULL) s_bdr_width = atoi(def_val);
                    383:     
                    384:     def_val = XGetDefault(display, def_env, "SelectionSpread");
                    385:     if (def_val != NULL) s_spread = atof(def_val);
                    386: 
                    387:     /*
                    388:      * Create and store the inactive pattern pixmap.
                    389:      */
                    390:     switch (inact_pnum) 
                    391:       {
                    392:   case 0:
                    393:          inact_bitmap = XCreateBitmapFromData(
                    394:                                               display,
                    395:                                               RootWindow(display, DefaultScreen(display)), 
                    396:                                               dimple1_bits, 
                    397:                                               16, 16
                    398:                                               );
                    399:          break;
                    400:   case 1:
                    401:          inact_bitmap = XCreateBitmapFromData(
                    402:                                               display, 
                    403:                                               RootWindow(display, DefaultScreen(display)), 
                    404:                                               dimple3_bits, 
                    405:                                               16,16);
                    406:          break;
                    407:   case 2:
                    408:          inact_bitmap = XCreateBitmapFromData(
                    409:                                               display, RootWindow(display, DefaultScreen(display)), 
                    410:                                               gray1_bits, 16, 16);
                    411:          break;
                    412:   case 3:
                    413:          inact_bitmap = XCreateBitmapFromData(
                    414:                                               display, 
                    415:                                               RootWindow(display, DefaultScreen(display)), 
                    416:                                               gray3_bits, 16, 16);
                    417:          break;
                    418:   case 4:
                    419:          inact_bitmap = XCreateBitmapFromData(
                    420:                                               display, 
                    421:                                               RootWindow(display, DefaultScreen(display)), 
                    422:                                               cross_weave_bits, 16, 16);
                    423:          break;
                    424:   default:
                    425:          break;
                    426:          
                    427:       }
                    428:     if (inact_bitmap == NULL) {
                    429:        _XMErrorCode = XME_STORE_BITMAP;
                    430:        return(NULL);
                    431:     }
                    432: 
                    433:     /*
                    434:      * Load the mouse cursor.
                    435:      */
                    436:          
                    437:     switch (menu_style) {
                    438:         case LEFT:
                    439:            cursor = XCreateBitmapFromData(display,
                    440:                                           RootWindow(display,
                    441:                                                      DefaultScreen(display)),
                    442:                                           left_ptr_bits,
                    443:                                           left_ptr_width,
                    444:                                           left_ptr_height);
                    445:            cursor_mask = XCreateBitmapFromData(display,
                    446:                                                RootWindow(display,
                    447:                                                      DefaultScreen(display)),
                    448:                                                left_ptrmsk_bits,
                    449:                                                left_ptrmsk_width,
                    450:                                                left_ptrmsk_height);
                    451:            mouse_cursor = XCreatePixmapCursor(
                    452:                                               display,
                    453:                                               cursor, cursor_mask, 
                    454:                                               &mouse_color, &bkgnd_color,
                    455:                                               left_ptr_x_hot,
                    456:                                               left_ptr_y_hot
                    457:                                               );
                    458:            XFreePixmap(display, cursor);
                    459:            XFreePixmap(display, cursor_mask);      
                    460:            break;
                    461:         case RIGHT:
                    462:            cursor = XCreateBitmapFromData(display,
                    463:                                           RootWindow(display,
                    464:                                                      DefaultScreen(display)),
                    465:                                           right_ptr_bits,
                    466:                                           right_ptr_width,
                    467:                                           right_ptr_height);
                    468:            cursor_mask = XCreateBitmapFromData(display,
                    469:                                                RootWindow(display,
                    470:                                                      DefaultScreen(display)),
                    471:                                                right_ptrmsk_bits,
                    472:                                                right_ptrmsk_width,
                    473:                                                right_ptrmsk_height);
                    474:            mouse_cursor = XCreatePixmapCursor(
                    475:                                               display,
                    476:                                               cursor, cursor_mask,
                    477:                                               &mouse_color, &bkgnd_color,
                    478:                                               right_ptr_x_hot,
                    479:                                               right_ptr_y_hot
                    480:                                               );
                    481:            XFreePixmap(display, cursor);
                    482:            XFreePixmap(display, cursor_mask);      
                    483:            break;
                    484:         case CENTER:
                    485:            cursor = XCreateBitmapFromData(display,
                    486:                                           RootWindow(display,
                    487:                                                      DefaultScreen(display)),
                    488:                                           cntr_ptr_bits,
                    489:                                           cntr_ptr_width,
                    490:                                           cntr_ptr_height);
                    491:            cursor_mask = XCreateBitmapFromData(display,
                    492:                                                RootWindow(display,
                    493:                                                      DefaultScreen(display)),
                    494:                                                cntr_ptrmsk_bits,
                    495:                                                cntr_ptrmsk_width,
                    496:                                                cntr_ptrmsk_height);
                    497:            mouse_cursor = XCreatePixmapCursor(
                    498:                                               display,
                    499:                                               cursor, cursor_mask,
                    500:                                               &mouse_color, &bkgnd_color,
                    501:                                               cntr_ptr_x_hot,
                    502:                                               cntr_ptr_y_hot
                    503:                                               );
                    504:            XFreePixmap(display, cursor);
                    505:            XFreePixmap(display, cursor_mask);      
                    506:        break;
                    507:  default:
                    508:        /* Error! Invalid style parameter. */
                    509:        _XMErrorCode = XME_STYLE_PARAM;
                    510:        return(NULL);
                    511:     }
                    512:     if (mouse_cursor == _X_FAILURE) {
                    513:        _XMErrorCode = XME_CREATE_CURSOR;
                    514:        return(NULL);
                    515:     }
                    516: 
                    517:     /*
                    518:      * Open the pane and selection fonts.
                    519:      */
                    520:     
                    521:     p_fnt_info = XLoadQueryFont(display, p_fnt_name);
                    522:     if (p_fnt_info == NULL) {
                    523:        _XMErrorCode = XME_OPEN_FONT;
                    524:        return(NULL);
                    525:        
                    526:     }
                    527: 
                    528:     s_fnt_info = XLoadQueryFont(display, s_fnt_name);
                    529:     if (s_fnt_info == NULL) {
                    530:        _XMErrorCode = XME_OPEN_FONT;
                    531:        return(NULL);
                    532:     }
                    533:     /*
                    534:      * Calculate the fixed padding value in pixels for each font.
                    535:      */
                    536:     p_fnt_height = p_fnt_info->max_bounds.ascent + p_fnt_info->max_bounds.descent;
                    537:     s_fnt_height = s_fnt_info->max_bounds.ascent + s_fnt_info->max_bounds.descent;
                    538:     p_fnt_pad = s_spread * p_fnt_height;
                    539:     s_fnt_pad = s_spread * s_fnt_height;
                    540: 
                    541:     /*
                    542:      * Calculate fixed height and offset requirements.
                    543:      */
                    544:     flag_height = p_fnt_height + (p_fnt_pad << 1);
                    545: 
                    546:     p_height = 0;
                    547:     p_y_off = flag_height + p_bdr_width;
                    548:     p_x_off = p_y_off * p_spread;
                    549: 
                    550:     s_height = s_fnt_height + (s_fnt_pad << 1) + (s_bdr_width << 1);
                    551:     s_y_off = s_height;
                    552:     s_x_off = p_x_off;
                    553: 
                    554:     /*
                    555:      * Set up the pane list header.
                    556:      */
                    557:     pane->next = pane;
                    558:     pane->prev = pane;
                    559:     pane->type = PL_HEADER;
                    560:     pane->serial = -1;
                    561: 
                    562:     /*
                    563:      * Initialize the internal pane and selection creation queues.
                    564:      */
                    565:     _XMWinQueInit();
                    566:     
                    567:     /*
                    568:      * Create pane, active, and inactive GC's.
                    569:      */
                    570:     values = (XGCValues *)malloc(sizeof(XGCValues));
                    571:     valuemask = (GCForeground | GCBackground | GCFont | GCLineWidth);
                    572: 
                    573:     /*
                    574:      * First, pane.
                    575:      */
                    576: 
                    577:     values->foreground = p_frg_color.pixel;
                    578:     values->background = bkgnd_color.pixel;
                    579:     values->font = p_fnt_info->fid;
                    580:     values->line_width = p_bdr_width;
                    581:     
                    582:     pane_GC = XCreateGC(
                    583:                        display, 
                    584:                        RootWindow(display, DefaultScreen(display)),
                    585:                        valuemask,
                    586:                        values);
                    587:     /*
                    588:      * Then normal video selection.
                    589:      */
                    590: 
                    591:     values->foreground = s_frg_color.pixel;
                    592:     values->background = bkgnd_color.pixel;
                    593:     values->font = s_fnt_info->fid;
                    594:     values->line_width = s_bdr_width;
                    595:     normal_select_GC = XCreateGC(display, 
                    596:                                 RootWindow(display, DefaultScreen(display)),
                    597:                                 valuemask,
                    598:                                 values);
                    599:     /*
                    600:      * Inverse video selection.
                    601:      */
                    602: 
                    603:     values->foreground = bkgnd_color.pixel;            
                    604:     values->background = s_frg_color.pixel;
                    605:     values->font = s_fnt_info->fid;
                    606:     values->line_width = s_bdr_width;
                    607:     inverse_select_GC = XCreateGC(display, 
                    608:                                  RootWindow(display, DefaultScreen(display)),
                    609:                                  valuemask,
                    610:                                  values);
                    611:     stipple_pixmap = XCreateBitmapFromData(display,
                    612:                                           RootWindow(display,
                    613:                                                      DefaultScreen(display)),
                    614:                                           stipple_bits,                
                    615:                                           stipple_width,               
                    616:                                           stipple_height);     
                    617:     
                    618:     /*
                    619:      * Finally, inactive pane header and selections
                    620:      */
                    621:     valuemask |= (GCFillStyle | GCStipple);
                    622:     values->foreground = s_frg_color.pixel;
                    623:     values->background = bkgnd_color.pixel;
                    624:     values->font = s_fnt_info->fid;
                    625:     values->line_width = s_bdr_width;
                    626:     values->fill_style = FillStippled;
                    627:     values->stipple = stipple_pixmap;
                    628:        
                    629:     inact_GC = XCreateGC(display, 
                    630:                         RootWindow(display, DefaultScreen(display)),
                    631:                         valuemask,
                    632:                         values);
                    633: 
                    634:     valuemask |= (GCGraphicsExposures);
                    635:     values->graphics_exposures = False;
                    636:     inact_GC_noexpose = XCreateGC (display, 
                    637:                                   RootWindow (display, 
                    638:                                               DefaultScreen (display)),
                    639:                                   valuemask, values);
                    640: 
                    641: 
                    642:     /*
                    643:      * Construct the XMenu object.
                    644:      */
                    645:     /* -------------------- Menu data -------------------- */
                    646:     menu->menu_style = menu_style;
                    647:     menu->menu_mode = menu_mode;
                    648:     menu->freeze = freeze;
                    649:     menu->aeq = 0;
                    650:     menu->recompute = 1;
                    651:     menu->parent = parent;
                    652:     menu->height = 0;
                    653:     menu->width = 0;
                    654:     menu->mouse_cursor = mouse_cursor;
                    655:     menu->assoc_tab = assoc_tab;
                    656:     menu->p_list = pane;
                    657:     /* -------------------- Pane window data -------------------- */
                    658:     menu->p_style = p_style;
                    659:     menu->p_events = DEF_P_EVENTS;
                    660:     menu->p_fnt_info = p_fnt_info;
                    661:     menu->p_fnt_pad = p_fnt_pad;
                    662:     menu->p_spread = p_spread;
                    663:     menu->p_bdr_width = p_bdr_width;
                    664:     menu->flag_height = flag_height;
                    665:     menu->p_width = 0;
                    666:     menu->p_height = p_height;
                    667:     menu->p_x_off = p_x_off;
                    668:     menu->p_y_off = p_y_off;
                    669:     menu->p_count = 0;
                    670:     menu->pane_GC = pane_GC;
                    671:     menu->x_pos = 0;
                    672:     menu->y_pos = 0;
                    673:     /* -------------------- Selection window data -------------------- */
                    674:     menu->s_style = s_style;
                    675:     menu->s_events = DEF_S_EVENTS;
                    676:     menu->s_fnt_info = s_fnt_info;
                    677:     menu->s_fnt_pad = s_fnt_pad;
                    678:     menu->s_spread = s_spread;
                    679:     menu->s_bdr_width = s_bdr_width;           /* unnecessary */
                    680:     menu->s_width = 0;
                    681:     menu->s_height = s_height;
                    682:     menu->s_x_off = s_x_off;
                    683:     menu->s_y_off = s_y_off;
                    684:     menu->s_count = 0;
                    685:     menu->normal_select_GC = normal_select_GC;
                    686:     menu->inverse_select_GC = inverse_select_GC;
                    687:     menu->inact_GC = inact_GC;
                    688:     /* -------------------- Color data -------------------- */
                    689:     menu->p_bdr_color = p_bdr_color.pixel;
                    690:     menu->s_bdr_color = s_bdr_color.pixel;
                    691:     menu->p_frg_color = p_frg_color.pixel;
                    692:     menu->s_frg_color = s_frg_color.pixel;
                    693:     menu->bkgnd_color = bkgnd_color.pixel;
                    694:     /* -------------------- Pixmap data -------------------- */
                    695:     menu->p_bdr_pixmap = NULL;
                    696:     menu->s_bdr_pixmap = NULL;
                    697:     menu->p_frg_pixmap = NULL;
                    698:     menu->s_frg_pixmap = NULL;
                    699:     menu->bkgnd_pixmap = NULL;
                    700:     if (DisplayPlanes (display, DefaultScreen (display)) == 1)
                    701:        menu->inact_pixmap = inact_bitmap;
                    702:     else
                    703:     {
                    704:        int loop;
                    705:        
                    706:        menu->inact_pixmap = XCreatePixmap (display,
                    707:                                            parent,
                    708:                                            16,
                    709:                                            16,
                    710:                                            DisplayPlanes (display,
                    711:                                                           DefaultScreen (display)));
                    712:        if (menu->inact_pixmap == NULL)
                    713:        {
                    714:            _XMErrorCode = XME_STORE_BITMAP;
                    715:            return(NULL);
                    716:        }
                    717: 
                    718:        XCopyPlane (display, inact_bitmap, menu->inact_pixmap, 
                    719:                    inact_GC_noexpose, 0, 0, 16, 16, 0, 0, 1);
                    720: 
                    721: /*
                    722:        for (loop = 0;
                    723:             loop < DisplayPlanes (display, DefaultScreen (display));
                    724:             loop++)
                    725:        {
                    726:            XCopyPlane (display,
                    727:                        inact_bitmap,
                    728:                        menu->inact_pixmap,
                    729:                        inact_GC,
                    730:                        0,
                    731:                        0,
                    732:                        16,
                    733:                        16,
                    734:                        0,
                    735:                        0,
                    736:                        (1 << loop));
                    737:        }
                    738: */
                    739:     }
                    740: 
                    741:     /*
                    742:      * Return the completed XMenu.
                    743:      */
                    744:     _XMErrorCode = XME_NO_ERROR;
                    745:     return(menu);
                    746: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.