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.28 by root, Tue Dec 27 16:41:40 2005 UTC vs.
Revision 1.29 by root, Tue Jan 3 02:43:33 2006 UTC

31#ifdef MENUBAR 31#ifdef MENUBAR
32#include "version.h" 32#include "version.h"
33#include "menubar.h" 33#include "menubar.h"
34 34
35#define Menu_PixelWidth(menu) \ 35#define Menu_PixelWidth(menu) \
36 (2 * SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE)) 36 (2 * MENU_SHADOW + Width2Pixel ((menu)->width + 3 * HSPACE))
37 37
38static const struct 38static const struct
39 { 39 {
40 const char name; /* (l)eft, (u)p, (d)own, (r)ight */ 40 const char name; /* (l)eft, (u)p, (d)own, (r)ight */
41 const unsigned char str[5]; /* str[0] = strlen (str+1) */ 41 const unsigned char str[5]; /* str[0] = strlen (str+1) */
804 default: 804 default:
805 top = bot = scrollbarGC; 805 top = bot = scrollbarGC;
806 break; /* neutral */ 806 break; /* neutral */
807 } 807 }
808 808
809 w = Height2Pixel (1) - 2 * SHADOW; 809 w = Height2Pixel (1) - 2 * MENU_SHADOW;
810 810
811 x -= SHADOW + (3 * w / 2); 811 x -= MENU_SHADOW + (3 * w / 2);
812 y += SHADOW * 3; 812 y += MENU_SHADOW * 3;
813 813
814 rxvt_Draw_Triangle (display->display, ActiveMenu->win, top, bot, x, y, w, 'r'); 814 rxvt_Draw_Triangle (display->display, ActiveMenu->win, top, bot, x, y, w, 'r');
815} 815}
816 816
817void 817void
836 top = bot = scrollbarGC; 836 top = bot = scrollbarGC;
837 break; /* neutral */ 837 break; /* neutral */
838 } 838 }
839 839
840 rxvt_Draw_Shadow (display->display, ActiveMenu->win, top, bot, 840 rxvt_Draw_Shadow (display->display, ActiveMenu->win, top, bot,
841 SHADOW + 0, SHADOW + y, 841 MENU_SHADOW + 0, MENU_SHADOW + y,
842 ActiveMenu->w - 2 * (SHADOW), 842 ActiveMenu->w - 2 * (MENU_SHADOW),
843 HEIGHT_TEXT + 2 * SHADOW); 843 HEIGHT_TEXT + 2 * MENU_SHADOW);
844 XFlush (display->display); 844 XFlush (display->display);
845} 845}
846 846
847#ifdef DEBUG_MENU_LAYOUT 847#ifdef DEBUG_MENU_LAYOUT
848void 848void
948 x = (TermWin_TotalWidth () - ActiveMenu->w); 948 x = (TermWin_TotalWidth () - ActiveMenu->w);
949 949
950 /* find the height */ 950 /* find the height */
951 for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next) 951 for (h = 0, item = ActiveMenu->head; item != NULL; item = item->next)
952 h += isSeparator (item->name) ? HEIGHT_SEPARATOR 952 h += isSeparator (item->name) ? HEIGHT_SEPARATOR
953 : HEIGHT_TEXT + 2 * SHADOW; 953 : HEIGHT_TEXT + 2 * MENU_SHADOW;
954 ActiveMenu->h = h + 2 * SHADOW; 954 ActiveMenu->h = h + 2 * MENU_SHADOW;
955 } 955 }
956 956
957 if (ActiveMenu->win == None) 957 if (ActiveMenu->win == None)
958 { 958 {
959 ActiveMenu->win = XCreateSimpleWindow (display->display, vt, 959 ActiveMenu->win = XCreateSimpleWindow (display->display, vt,
975 if (item->len2 > xright) 975 if (item->len2 > xright)
976 xright = item->len2; 976 xright = item->len2;
977 977
978 for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next) 978 for (y = 0, item = ActiveMenu->head; item != NULL; item = item->next)
979 { 979 {
980 const int xoff = (SHADOW + Width2Pixel (HSPACE) / 2); 980 const int xoff = (MENU_SHADOW + Width2Pixel (HSPACE) / 2);
981 register int h; 981 register int h;
982 GC gc = menubarGC; 982 GC gc = menubarGC;
983 983
984 if (isSeparator (item->name)) 984 if (isSeparator (item->name))
985 { 985 {
986 rxvt_Draw_Shadow (display->display, ActiveMenu->win, 986 rxvt_Draw_Shadow (display->display, ActiveMenu->win,
987 topShadowGC, botShadowGC, 987 topShadowGC, botShadowGC,
988 SHADOW, y + SHADOW + 1, 988 MENU_SHADOW, y + MENU_SHADOW + 1,
989 ActiveMenu->w - 2 * SHADOW, 0); 989 ActiveMenu->w - 2 * MENU_SHADOW, 0);
990 h = HEIGHT_SEPARATOR; 990 h = HEIGHT_SEPARATOR;
991 } 991 }
992 else 992 else
993 { 993 {
994 char *name = item->name; 994 char *name = item->name;
1018 x1 += x; 1018 x1 += x;
1019 1019
1020 /* find the height of this submenu */ 1020 /* find the height of this submenu */
1021 for (h = 0, it = menu->head; it != NULL; it = it->next) 1021 for (h = 0, it = menu->head; it != NULL; it = it->next)
1022 h += isSeparator (it->name) ? HEIGHT_SEPARATOR 1022 h += isSeparator (it->name) ? HEIGHT_SEPARATOR
1023 : HEIGHT_TEXT + 2 * SHADOW; 1023 : HEIGHT_TEXT + 2 * MENU_SHADOW;
1024 menu->h = h + 2 * SHADOW; 1024 menu->h = h + 2 * MENU_SHADOW;
1025 1025
1026 /* ensure menu is in window limits */ 1026 /* ensure menu is in window limits */
1027 if ((x1 + menu->w) >= width) 1027 if ((x1 + menu->w) >= width)
1028 x1 = (TermWin_TotalWidth () - menu->w); 1028 x1 = (TermWin_TotalWidth () - menu->w);
1029 1029
1036 else if (item->name2 && !strcmp (name, item->name2)) 1036 else if (item->name2 && !strcmp (name, item->name2))
1037 name = NULL; 1037 name = NULL;
1038 1038
1039 if (len && name) 1039 if (len && name)
1040 draw_string (*ActiveMenu->drawable, gc, fontset[0], 1040 draw_string (*ActiveMenu->drawable, gc, fontset[0],
1041 xoff, 2 * SHADOW + y, name, len); 1041 xoff, 2 * MENU_SHADOW + y, name, len);
1042 1042
1043 len = item->len2; 1043 len = item->len2;
1044 name = item->name2; 1044 name = item->name2;
1045 1045
1046 if (len && name) 1046 if (len && name)
1047 draw_string (*ActiveMenu->drawable, gc, fontset[0], 1047 draw_string (*ActiveMenu->drawable, gc, fontset[0],
1048 ActiveMenu->w - (xoff + Width2Pixel (xright)), 2 * SHADOW + y, name, len); 1048 ActiveMenu->w - (xoff + Width2Pixel (xright)), 2 * MENU_SHADOW + y, name, len);
1049 1049
1050 h = HEIGHT_TEXT + 2 * SHADOW; 1050 h = HEIGHT_TEXT + 2 * MENU_SHADOW;
1051 } 1051 }
1052 y += h; 1052 y += h;
1053 } 1053 }
1054} 1054}
1055 1055
2065 len = (ncol - (menu->x + HSPACE)); 2065 len = (ncol - (menu->x + HSPACE));
2066 2066
2067 drawbox_menubar (menu->x, len, +1); 2067 drawbox_menubar (menu->x, len, +1);
2068 draw_string (*menuBar.drawable, menubarGC, fontset[0], 2068 draw_string (*menuBar.drawable, menubarGC, fontset[0],
2069 (Width2Pixel (menu->x) + Width2Pixel (HSPACE) / 2), 2069 (Width2Pixel (menu->x) + Width2Pixel (HSPACE) / 2),
2070 SHADOW, menu->name, len); 2070 MENU_SHADOW, menu->name, len);
2071 2071
2072 if (x >= ncol) 2072 if (x >= ncol)
2073 break; 2073 break;
2074 } 2074 }
2075 } 2075 }
2127 2127
2128 ncol -= (x + len + HSPACE); 2128 ncol -= (x + len + HSPACE);
2129 if (len > 0 && ncol >= 0) 2129 if (len > 0 && ncol >= 0)
2130 draw_string (*menuBar.drawable, menubarGC, fontset[0], 2130 draw_string (*menuBar.drawable, menubarGC, fontset[0],
2131 Width2Pixel (x) + Width2Pixel (ncol + HSPACE) / 2, 2131 Width2Pixel (x) + Width2Pixel (ncol + HSPACE) / 2,
2132 SHADOW, title, len); 2132 MENU_SHADOW, title, len);
2133 } 2133 }
2134} 2134}
2135 2135
2136int 2136int
2137rxvt_term::menubar_mapping (int map) 2137rxvt_term::menubar_mapping (int map)
2182 menu_hide (); 2182 menu_hide ();
2183 return 1; 2183 return 1;
2184 } 2184 }
2185 2185
2186 /* determine the menu item corresponding to the Y index */ 2186 /* determine the menu item corresponding to the Y index */
2187 y = SHADOW; 2187 y = MENU_SHADOW;
2188 if (ev.x >= 0 && ev.x <= (ActiveMenu->w - SHADOW)) 2188 if (ev.x >= 0 && ev.x <= (ActiveMenu->w - MENU_SHADOW))
2189 { 2189 {
2190 for (item = ActiveMenu->head; item != NULL; item = item->next) 2190 for (item = ActiveMenu->head; item != NULL; item = item->next)
2191 { 2191 {
2192 int h = HEIGHT_TEXT + 2 * SHADOW; 2192 int h = HEIGHT_TEXT + 2 * MENU_SHADOW;
2193 2193
2194 if (isSeparator (item->name)) 2194 if (isSeparator (item->name))
2195 h = HEIGHT_SEPARATOR; 2195 h = HEIGHT_SEPARATOR;
2196 else if (ev.y >= y && ev.y < (y + h)) 2196 else if (ev.y >= y && ev.y < (y + h))
2197 break; 2197 break;
2205 menu_hide_all (); 2205 menu_hide_all ();
2206 return 0; 2206 return 0;
2207 } 2207 }
2208 2208
2209 thisitem = item; 2209 thisitem = item;
2210 this_y = y - SHADOW; 2210 this_y = y - MENU_SHADOW;
2211 2211
2212 /* erase the last item */ 2212 /* erase the last item */
2213 if (ActiveMenu->item != NULL) 2213 if (ActiveMenu->item != NULL)
2214 { 2214 {
2215 if (ActiveMenu->item != thisitem) 2215 if (ActiveMenu->item != thisitem)
2228 drawtriangle (ActiveMenu->w, y, +1); 2228 drawtriangle (ActiveMenu->w, y, +1);
2229 2229
2230 break; 2230 break;
2231 } 2231 }
2232 else 2232 else
2233 h = HEIGHT_TEXT + 2 * SHADOW; 2233 h = HEIGHT_TEXT + 2 * MENU_SHADOW;
2234 2234
2235 y += h; 2235 y += h;
2236 } 2236 }
2237 } 2237 }
2238 else 2238 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines