ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/menubar.C
(Generate patch)

Comparing rxvt-unicode/src/menubar.C (file contents):
Revision 1.6 by pcg, Sun Feb 1 01:34:41 2004 UTC vs.
Revision 1.7 by pcg, Mon Feb 9 07:11:49 2004 UTC

746 default: 746 default:
747 top = bot = scrollbarGC; 747 top = bot = scrollbarGC;
748 break; /* neutral */ 748 break; /* neutral */
749 } 749 }
750 750
751 rxvt_Draw_Shadow(Xdisplay, menuBar.win, top, bot, 751 rxvt_Draw_Shadow(display->display, menuBar.win, top, bot,
752 x, 0, len, menuBar_TotalHeight()); 752 x, 0, len, menuBar_TotalHeight());
753} 753}
754 754
755void 755void
756rxvt_term::drawtriangle (int x, int y, int state) 756rxvt_term::drawtriangle (int x, int y, int state)
779 w = Height2Pixel(1) - 2 * SHADOW; 779 w = Height2Pixel(1) - 2 * SHADOW;
780 780
781 x -= SHADOW + (3 * w / 2); 781 x -= SHADOW + (3 * w / 2);
782 y += SHADOW * 3; 782 y += SHADOW * 3;
783 783
784 rxvt_Draw_Triangle(Xdisplay, ActiveMenu->win, top, bot, x, y, w, 784 rxvt_Draw_Triangle(display->display, ActiveMenu->win, top, bot, x, y, w,
785 'r'); 785 'r');
786} 786}
787 787
788void 788void
789rxvt_term::drawbox_menuitem (int y, int state) 789rxvt_term::drawbox_menuitem (int y, int state)
806 default: 806 default:
807 top = bot = scrollbarGC; 807 top = bot = scrollbarGC;
808 break; /* neutral */ 808 break; /* neutral */
809 } 809 }
810 810
811 rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, top, bot, 811 rxvt_Draw_Shadow(display->display, ActiveMenu->win, top, bot,
812 SHADOW + 0, SHADOW + y, 812 SHADOW + 0, SHADOW + y,
813 ActiveMenu->w - 2 * (SHADOW), 813 ActiveMenu->w - 2 * (SHADOW),
814 HEIGHT_TEXT + 2 * SHADOW); 814 HEIGHT_TEXT + 2 * SHADOW);
815 XFlush(Xdisplay); 815 XFlush(display->display);
816} 816}
817 817
818#ifdef DEBUG_MENU_LAYOUT 818#ifdef DEBUG_MENU_LAYOUT
819void 819void
820rxvt_print_menu_ancestors(menu_t *menu) 820rxvt_print_menu_ancestors(menu_t *menu)
922 : HEIGHT_TEXT + 2 * SHADOW; 922 : HEIGHT_TEXT + 2 * SHADOW;
923 ActiveMenu->h = h + 2 * SHADOW; 923 ActiveMenu->h = h + 2 * SHADOW;
924 } 924 }
925 if (ActiveMenu->win == None) 925 if (ActiveMenu->win == None)
926 { 926 {
927 ActiveMenu->win = XCreateSimpleWindow(Xdisplay, TermWin.vt, 927 ActiveMenu->win = XCreateSimpleWindow(display->display, TermWin.vt,
928 x, ActiveMenu->y, 928 x, ActiveMenu->y,
929 ActiveMenu->w, ActiveMenu->h, 929 ActiveMenu->w, ActiveMenu->h,
930 0, 930 0,
931 PixColors[Color_fg], 931 PixColors[Color_fg],
932 PixColors[Color_scroll]); 932 PixColors[Color_scroll]);
933 XMapWindow(Xdisplay, ActiveMenu->win); 933 XMapWindow(display->display, ActiveMenu->win);
934 } 934 }
935 rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, 935 rxvt_Draw_Shadow(display->display, ActiveMenu->win,
936 topShadowGC, botShadowGC, 936 topShadowGC, botShadowGC,
937 0, 0, ActiveMenu->w, ActiveMenu->h); 937 0, 0, ActiveMenu->w, ActiveMenu->h);
938 938
939 /* determine the correct right-alignment */ 939 /* determine the correct right-alignment */
940 for (xright = 0, item = ActiveMenu->head; item != NULL; item = item->next) 940 for (xright = 0, item = ActiveMenu->head; item != NULL; item = item->next)
947 register int h; 947 register int h;
948 GC gc = menubarGC; 948 GC gc = menubarGC;
949 949
950 if (isSeparator(item->name)) 950 if (isSeparator(item->name))
951 { 951 {
952 rxvt_Draw_Shadow(Xdisplay, ActiveMenu->win, 952 rxvt_Draw_Shadow(display->display, ActiveMenu->win,
953 topShadowGC, botShadowGC, 953 topShadowGC, botShadowGC,
954 SHADOW, y + SHADOW + 1, 954 SHADOW, y + SHADOW + 1,
955 ActiveMenu->w - 2 * SHADOW, 0); 955 ActiveMenu->w - 2 * SHADOW, 0);
956 h = HEIGHT_SEPARATOR; 956 h = HEIGHT_SEPARATOR;
957 } 957 }
1006 1006
1007 if (len && name) 1007 if (len && name)
1008 { 1008 {
1009#ifdef USE_XIM 1009#ifdef USE_XIM
1010 if (TermWin.fontset) 1010 if (TermWin.fontset)
1011 XmbDrawString(Xdisplay, 1011 XmbDrawString(display->display,
1012 ActiveMenu->win, TermWin.fontset, 1012 ActiveMenu->win, TermWin.fontset,
1013 gc, xoff, 1013 gc, xoff,
1014 2 * SHADOW + y + TermWin.font->ascent + 1, 1014 2 * SHADOW + y + TermWin.font->ascent + 1,
1015 name, len); 1015 name, len);
1016 else 1016 else
1017#endif 1017#endif
1018 XDrawString(Xdisplay, ActiveMenu->win, gc, xoff, 1018 XDrawString(display->display, ActiveMenu->win, gc, xoff,
1019 2 * SHADOW + y + TermWin.font->ascent + 1, 1019 2 * SHADOW + y + TermWin.font->ascent + 1,
1020 name, len); 1020 name, len);
1021 } 1021 }
1022 1022
1023 len = item->len2; 1023 len = item->len2;
1024 name = item->name2; 1024 name = item->name2;
1025 if (len && name) 1025 if (len && name)
1026 { 1026 {
1027#ifdef USE_XIM 1027#ifdef USE_XIM
1028 if (TermWin.fontset) 1028 if (TermWin.fontset)
1029 XmbDrawString(Xdisplay, 1029 XmbDrawString(display->display,
1030 ActiveMenu->win, TermWin.fontset, 1030 ActiveMenu->win, TermWin.fontset,
1031 gc, 1031 gc,
1032 ActiveMenu->w - (xoff + Width2Pixel(xright)), 1032 ActiveMenu->w - (xoff + Width2Pixel(xright)),
1033 2 * SHADOW + y + TermWin.font->ascent + 1, 1033 2 * SHADOW + y + TermWin.font->ascent + 1,
1034 name, len); 1034 name, len);
1035 else 1035 else
1036#endif 1036#endif
1037 XDrawString(Xdisplay, ActiveMenu->win, gc, 1037 XDrawString(display->display, ActiveMenu->win, gc,
1038 ActiveMenu->w - (xoff + Width2Pixel(xright)), 1038 ActiveMenu->w - (xoff + Width2Pixel(xright)),
1039 2 * SHADOW + y + TermWin.font->ascent + 1, 1039 2 * SHADOW + y + TermWin.font->ascent + 1,
1040 name, len); 1040 name, len);
1041 } 1041 }
1042 h = HEIGHT_TEXT + 2 * SHADOW; 1042 h = HEIGHT_TEXT + 2 * SHADOW;
1051 menu_t *ActiveMenu = ActiveMenu; 1051 menu_t *ActiveMenu = ActiveMenu;
1052 1052
1053 if (ActiveMenu == NULL) 1053 if (ActiveMenu == NULL)
1054 return; 1054 return;
1055 if (ActiveMenu->win != None) 1055 if (ActiveMenu->win != None)
1056 XDestroyWindow(Xdisplay, ActiveMenu->win); 1056 XDestroyWindow(display->display, ActiveMenu->win);
1057 ActiveMenu->win = None; 1057 ActiveMenu->win = None;
1058 ActiveMenu->item = NULL; 1058 ActiveMenu->item = NULL;
1059 1059
1060 if (ActiveMenu->parent == NULL) 1060 if (ActiveMenu->parent == NULL)
1061 drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1); 1061 drawbox_menubar (ActiveMenu->x, ActiveMenu->len, +1);
2001 const int w = Width2Pixel(1); 2001 const int w = Width2Pixel(1);
2002 const int y = (menuBar_TotalHeight() - w) / 2; 2002 const int y = (menuBar_TotalHeight() - w) / 2;
2003 int x = Arrows_x + (5 * Width2Pixel(i)) / 4; 2003 int x = Arrows_x + (5 * Width2Pixel(i)) / 4;
2004 2004
2005 if (!name || name == Arrows[i].name) 2005 if (!name || name == Arrows[i].name)
2006 rxvt_Draw_Triangle(Xdisplay, menuBar.win, top, bot, x, y, w, 2006 rxvt_Draw_Triangle(display->display, menuBar.win, top, bot, x, y, w,
2007 Arrows[i].name); 2007 Arrows[i].name);
2008 } 2008 }
2009 XFlush(Xdisplay); 2009 XFlush(display->display);
2010} 2010}
2011 2011
2012void 2012void
2013rxvt_term::menubar_expose () 2013rxvt_term::menubar_expose ()
2014{ 2014{
2025 2025
2026 gcvalue.font = TermWin.font->fid; 2026 gcvalue.font = TermWin.font->fid;
2027 2027
2028 gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg] 2028 gcvalue.foreground = (XDEPTH <= 2 ? PixColors[Color_fg]
2029 : PixColors[Color_Black]); 2029 : PixColors[Color_Black]);
2030 menubarGC = XCreateGC(Xdisplay, menuBar.win, 2030 menubarGC = XCreateGC(display->display, menuBar.win,
2031 GCForeground | GCFont, &gcvalue); 2031 GCForeground | GCFont, &gcvalue);
2032 2032
2033 } 2033 }
2034 /* make sure the font is correct */ 2034 /* make sure the font is correct */
2035 XSetFont(Xdisplay, menubarGC, TermWin.font->fid); 2035 XSetFont(display->display, menubarGC, TermWin.font->fid);
2036 XSetFont(Xdisplay, botShadowGC, TermWin.font->fid); 2036 XSetFont(display->display, botShadowGC, TermWin.font->fid);
2037 XClearWindow(Xdisplay, menuBar.win); 2037 XClearWindow(display->display, menuBar.win);
2038 2038
2039 menu_hide_all (); 2039 menu_hide_all ();
2040 2040
2041 x = 0; 2041 x = 0;
2042 if (CurrentBar != NULL) 2042 if (CurrentBar != NULL)
2055 len = (TermWin.ncol - (menu->x + HSPACE)); 2055 len = (TermWin.ncol - (menu->x + HSPACE));
2056 2056
2057 drawbox_menubar (menu->x, len, +1); 2057 drawbox_menubar (menu->x, len, +1);
2058#ifdef USE_XIM 2058#ifdef USE_XIM
2059 if (TermWin.fontset) 2059 if (TermWin.fontset)
2060 XmbDrawString(Xdisplay, 2060 XmbDrawString(display->display,
2061 menuBar.win, TermWin.fontset, 2061 menuBar.win, TermWin.fontset,
2062 menubarGC, 2062 menubarGC,
2063 (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), 2063 (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2),
2064 menuBar_height() - SHADOW, menu->name, len); 2064 menuBar_height() - SHADOW, menu->name, len);
2065 else 2065 else
2066#endif 2066#endif
2067 XDrawString(Xdisplay, menuBar.win, menubarGC, 2067 XDrawString(display->display, menuBar.win, menubarGC,
2068 (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2), 2068 (Width2Pixel(menu->x) + Width2Pixel(HSPACE) / 2),
2069 menuBar_height() - SHADOW, menu->name, len); 2069 menuBar_height() - SHADOW, menu->name, len);
2070 2070
2071 if (x >= TermWin.ncol) 2071 if (x >= TermWin.ncol)
2072 break; 2072 break;
2128 ncol -= (x + len + HSPACE); 2128 ncol -= (x + len + HSPACE);
2129 if (len > 0 && ncol >= 0) 2129 if (len > 0 && ncol >= 0)
2130 { 2130 {
2131#ifdef USE_XIM 2131#ifdef USE_XIM
2132 if (TermWin.fontset) 2132 if (TermWin.fontset)
2133 XmbDrawString(Xdisplay, 2133 XmbDrawString(display->display,
2134 menuBar.win, TermWin.fontset, 2134 menuBar.win, TermWin.fontset,
2135 menubarGC, 2135 menubarGC,
2136 Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, 2136 Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2,
2137 menuBar_height() - SHADOW, title, len); 2137 menuBar_height() - SHADOW, title, len);
2138 else 2138 else
2139#endif 2139#endif
2140 XDrawString(Xdisplay, menuBar.win, menubarGC, 2140 XDrawString(display->display, menuBar.win, menubarGC,
2141 Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2, 2141 Width2Pixel(x) + Width2Pixel(ncol + HSPACE) / 2,
2142 menuBar_height() - SHADOW, title, len); 2142 menuBar_height() - SHADOW, title, len);
2143 } 2143 }
2144 } 2144 }
2145} 2145}
2152 if (map && !menubar_visible(r)) 2152 if (map && !menubar_visible(r))
2153 { 2153 {
2154 menuBar.state = 1; 2154 menuBar.state = 1;
2155 if (menuBar.win == 0) 2155 if (menuBar.win == 0)
2156 return 0; 2156 return 0;
2157 XMapWindow(Xdisplay, menuBar.win); 2157 XMapWindow(display->display, menuBar.win);
2158 change = 1; 2158 change = 1;
2159 } 2159 }
2160 else if (!map && menubar_visible(r)) 2160 else if (!map && menubar_visible(r))
2161 { 2161 {
2162 menubar_expose (); 2162 menubar_expose ();
2163 menuBar.state = 0; 2163 menuBar.state = 0;
2164 XUnmapWindow(Xdisplay, menuBar.win); 2164 XUnmapWindow(display->display, menuBar.win);
2165 change = 1; 2165 change = 1;
2166 } 2166 }
2167 else 2167 else
2168 menubar_expose (); 2168 menubar_expose ();
2169 2169
2182 unsigned int unused_mask; 2182 unsigned int unused_mask;
2183 2183
2184 if (ActiveMenu == NULL) 2184 if (ActiveMenu == NULL)
2185 return 0; 2185 return 0;
2186 2186
2187 XQueryPointer(Xdisplay, ActiveMenu->win, 2187 XQueryPointer(display->display, ActiveMenu->win,
2188 &unused_root, &unused_child, 2188 &unused_root, &unused_child,
2189 &unused_root_x, &unused_root_y, 2189 &unused_root_x, &unused_root_y,
2190 &(ev->x), &(ev->y), &unused_mask); 2190 &(ev->x), &(ev->y), &unused_mask);
2191 2191
2192 if (ActiveMenu->parent != NULL && (ev->x < 0 || ev->y < 0)) 2192 if (ActiveMenu->parent != NULL && (ev->x < 0 || ev->y < 0))
2442 if (ev->button == Button1) 2442 if (ev->button == Button1)
2443 menu_select (ev); 2443 menu_select (ev);
2444 break; 2444 break;
2445 2445
2446 case MotionNotify: 2446 case MotionNotify:
2447 while (XCheckTypedWindowEvent(Xdisplay, TermWin.parent[0], 2447 while (XCheckTypedWindowEvent(display->display, TermWin.parent[0],
2448 MotionNotify, (XEvent *) ev)) ; 2448 MotionNotify, (XEvent *) ev)) ;
2449 2449
2450 if (ActiveMenu) 2450 if (ActiveMenu)
2451 while (menu_select (ev)) ; 2451 while (menu_select (ev)) ;
2452 else 2452 else
2455 { 2455 {
2456 Window unused_root, unused_child; 2456 Window unused_root, unused_child;
2457 int unused_root_x, unused_root_y; 2457 int unused_root_x, unused_root_y;
2458 unsigned int unused_mask; 2458 unsigned int unused_mask;
2459 2459
2460 XQueryPointer(Xdisplay, menuBar.win, 2460 XQueryPointer(display->display, menuBar.win,
2461 &unused_root, &unused_child, 2461 &unused_root, &unused_child,
2462 &unused_root_x, &unused_root_y, 2462 &unused_root_x, &unused_root_y,
2463 &(ev->x), &(ev->y), &unused_mask); 2463 &(ev->x), &(ev->y), &unused_mask);
2464 menubar_select (ev); 2464 menubar_select (ev);
2465 } 2465 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines