Mercurial > vim
comparison src/gui_athena.c @ 47:eff3887963cc
updated for version 7.0028
author | vimboss |
---|---|
date | Sun, 02 Jan 2005 11:28:13 +0000 |
parents | 3fc0f57ecb91 |
children | 2a8d48bdc5de |
comparison
equal
deleted
inserted
replaced
46:46d39f2eff86 | 47:eff3887963cc |
---|---|
452 toolBar = NULL; | 452 toolBar = NULL; |
453 #endif | 453 #endif |
454 } | 454 } |
455 | 455 |
456 #if defined(FEAT_TOOLBAR) || defined(PROTO) | 456 #if defined(FEAT_TOOLBAR) || defined(PROTO) |
457 # include "gui_x11_pm.h" | |
458 # ifdef HAVE_X11_XPM_H | |
459 # include <X11/xpm.h> | |
460 # endif | |
461 | |
462 static void createXpmImages __ARGS((char_u *path, char **xpm, Pixmap *sen)); | |
463 static void get_toolbar_pixmap __ARGS((vimmenu_T *menu, Pixmap *sen)); | |
464 | |
465 /* | |
466 * Allocated a pixmap for toolbar menu "menu". | |
467 * Return in "sen". | |
468 */ | |
469 static void | |
470 get_toolbar_pixmap(menu, sen) | |
471 vimmenu_T *menu; | |
472 Pixmap *sen; | |
473 { | |
474 char_u buf[MAXPATHL]; /* buffer storing expanded pathname */ | |
475 char **xpm = NULL; /* xpm array */ | |
476 | |
477 buf[0] = NUL; /* start with NULL path */ | |
478 | |
479 if (menu->iconfile != NULL) | |
480 { | |
481 /* Use the "icon=" argument. */ | |
482 gui_find_iconfile(menu->iconfile, buf, "xpm"); | |
483 createXpmImages(buf, NULL, sen); | |
484 | |
485 /* If it failed, try using the menu name. */ | |
486 if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK) | |
487 createXpmImages(buf, NULL, sen); | |
488 if (*sen != (Pixmap)0) | |
489 return; | |
490 } | |
491 | |
492 if (menu->icon_builtin || gui_find_bitmap(menu->name, buf, "xpm") == FAIL) | |
493 { | |
494 if (menu->iconidx >= 0 && menu->iconidx | |
495 < (sizeof(built_in_pixmaps) / sizeof(built_in_pixmaps[0]))) | |
496 xpm = built_in_pixmaps[menu->iconidx]; | |
497 else | |
498 xpm = tb_blank_xpm; | |
499 } | |
500 | |
501 if (xpm != NULL || buf[0] != NUL) | |
502 createXpmImages(buf, xpm, sen); | |
503 } | |
504 | |
505 /* | |
506 * Read an Xpm file, doing color substitutions for the foreground and | |
507 * background colors. If there is an error reading a color xpm file, | |
508 * drop back and read the monochrome file. If successful, create the | |
509 * insensitive Pixmap too. | |
510 */ | |
511 static void | |
512 createXpmImages(path, xpm, sen) | |
513 char_u *path; | |
514 char **xpm; | |
515 Pixmap *sen; | |
516 { | |
517 Window rootWindow; | |
518 XpmAttributes attrs; | |
519 XpmColorSymbol color[5] = | |
520 { | |
521 {"none", "none", 0}, | |
522 {"iconColor1", NULL, 0}, | |
523 {"bottomShadowColor", NULL, 0}, | |
524 {"topShadowColor", NULL, 0}, | |
525 {"selectColor", NULL, 0} | |
526 }; | |
527 int screenNum; | |
528 int status; | |
529 Pixmap mask; | |
530 Pixmap map; | |
531 | |
532 gui_mch_get_toolbar_colors( | |
533 &color[BACKGROUND].pixel, | |
534 &color[FOREGROUND].pixel, | |
535 &color[BOTTOM_SHADOW].pixel, | |
536 &color[TOP_SHADOW].pixel, | |
537 &color[HIGHLIGHT].pixel); | |
538 | |
539 /* Setup the color subsititution table */ | |
540 attrs.valuemask = XpmColorSymbols; | |
541 attrs.colorsymbols = color; | |
542 attrs.numsymbols = 5; | |
543 | |
544 screenNum = DefaultScreen(gui.dpy); | |
545 rootWindow = RootWindow(gui.dpy, screenNum); | |
546 | |
547 /* Create the "sensitive" pixmap */ | |
548 if (xpm != NULL) | |
549 status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm, | |
550 &map, &mask, &attrs); | |
551 else | |
552 status = XpmReadFileToPixmap(gui.dpy, rootWindow, (char *)path, | |
553 &map, &mask, &attrs); | |
554 if (status == XpmSuccess && map != 0) | |
555 { | |
556 XGCValues gcvalues; | |
557 GC back_gc; | |
558 GC mask_gc; | |
559 | |
560 /* Need to create new Pixmaps with the mask applied. */ | |
561 gcvalues.foreground = color[BACKGROUND].pixel; | |
562 back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); | |
563 mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues); | |
564 XSetClipMask(gui.dpy, mask_gc, mask); | |
565 | |
566 /* Create the "sensitive" pixmap. */ | |
567 *sen = XCreatePixmap(gui.dpy, rootWindow, | |
568 attrs.width, attrs.height, | |
569 DefaultDepth(gui.dpy, screenNum)); | |
570 XFillRectangle(gui.dpy, *sen, back_gc, 0, 0, | |
571 attrs.width, attrs.height); | |
572 XCopyArea(gui.dpy, map, *sen, mask_gc, 0, 0, | |
573 attrs.width, attrs.height, 0, 0); | |
574 | |
575 XFreeGC(gui.dpy, back_gc); | |
576 XFreeGC(gui.dpy, mask_gc); | |
577 XFreePixmap(gui.dpy, map); | |
578 } | |
579 else | |
580 *sen = 0; | |
581 | |
582 XpmFreeAttributes(&attrs); | |
583 } | |
584 | |
457 void | 585 void |
458 gui_mch_set_toolbar_pos(x, y, w, h) | 586 gui_mch_set_toolbar_pos(x, y, w, h) |
459 int x; | 587 int x; |
460 int y; | 588 int y; |
461 int w; | 589 int w; |
969 /* For a toolbar item: Free the pixmap and allocate a new one, | 1097 /* For a toolbar item: Free the pixmap and allocate a new one, |
970 * so that the background color is right. */ | 1098 * so that the background color is right. */ |
971 if (mp->image != (Pixmap)0) | 1099 if (mp->image != (Pixmap)0) |
972 { | 1100 { |
973 XFreePixmap(gui.dpy, mp->image); | 1101 XFreePixmap(gui.dpy, mp->image); |
974 get_toolbar_pixmap(mp, &mp->image, NULL); | 1102 get_toolbar_pixmap(mp, &mp->image); |
975 if (mp->image != (Pixmap)0) | 1103 if (mp->image != (Pixmap)0) |
976 XtVaSetValues(mp->id, XtNbitmap, mp->image, NULL); | 1104 XtVaSetValues(mp->id, XtNbitmap, mp->image, NULL); |
977 } | 1105 } |
978 | 1106 |
979 # ifdef FEAT_BEVAL | 1107 # ifdef FEAT_BEVAL |
1069 XtSetArg(args[n], XtNlabel, ""); n++; | 1197 XtSetArg(args[n], XtNlabel, ""); n++; |
1070 XtSetArg(args[n], XtNborderWidth, 0); n++; | 1198 XtSetArg(args[n], XtNborderWidth, 0); n++; |
1071 } | 1199 } |
1072 else | 1200 else |
1073 { | 1201 { |
1074 get_toolbar_pixmap(menu, &menu->image, NULL); | 1202 get_toolbar_pixmap(menu, &menu->image); |
1075 XtSetArg(args[n], XtNlabel, menu->dname); n++; | 1203 XtSetArg(args[n], XtNlabel, menu->dname); n++; |
1076 XtSetArg(args[n], XtNinternalHeight, 1); n++; | 1204 XtSetArg(args[n], XtNinternalHeight, 1); n++; |
1077 XtSetArg(args[n], XtNinternalWidth, 1); n++; | 1205 XtSetArg(args[n], XtNinternalWidth, 1); n++; |
1078 XtSetArg(args[n], XtNborderWidth, 1); n++; | 1206 XtSetArg(args[n], XtNborderWidth, 1); n++; |
1079 if (menu->image != 0) | 1207 if (menu->image != 0) |