Tue Jan 18 21:17:24 PST 2000 Michael Jennings <mej@eterm.org>

Finally got around to adding a bevel to the edges and solid-color
	menus.  Also added arrows for submenus.


SVN revision: 1950
This commit is contained in:
Michael Jennings 2000-01-19 05:18:14 +00:00
parent b329b52608
commit baa4e7ee51
4 changed files with 88 additions and 32 deletions

View File

@ -3066,3 +3066,9 @@ Tue Jan 18 20:16:01 PST 2000 Michael Jennings <mej@eterm.org>
the selected state was not defined.
-------------------------------------------------------------------------------
Tue Jan 18 21:17:24 PST 2000 Michael Jennings <mej@eterm.org>
Finally got around to adding a bevel to the edges and solid-color
menus. Also added arrows for submenus.
-------------------------------------------------------------------------------

View File

@ -36,7 +36,7 @@ static const char cvs_ident[] = "$Id$";
#include "startup.h"
void
draw_shadow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int shadow)
draw_shadow(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int shadow)
{
ASSERT(w != 0);
@ -44,16 +44,31 @@ draw_shadow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int
LOWER_BOUND(shadow, 1);
for (w += x - 1, h += y - 1; shadow > 0; shadow--, w--, h--) {
XDrawLine(Xdisplay, win, gc_top, x, y, w, y);
XDrawLine(Xdisplay, win, gc_top, x, y, x, h);
XDrawLine(Xdisplay, d, gc_top, x, y, w, y);
XDrawLine(Xdisplay, d, gc_top, x, y, x, h);
x++; y++;
XDrawLine(Xdisplay, win, gc_bottom, w, h, w, y);
XDrawLine(Xdisplay, win, gc_bottom, w, h, x, h);
XDrawLine(Xdisplay, d, gc_bottom, w, h, w, y);
XDrawLine(Xdisplay, d, gc_bottom, w, h, x, h);
}
}
void
draw_arrow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow, unsigned char type)
draw_shadow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w, int h, int shadow)
{
static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) {
gc_top = XCreateGC(Xdisplay, TermWin.parent, 0, NULL);
gc_bottom = XCreateGC(Xdisplay, TermWin.parent, 0, NULL);
}
XSetForeground(Xdisplay, gc_top, top);
XSetForeground(Xdisplay, gc_bottom, bottom);
draw_shadow(d, gc_top, gc_bottom, x, y, w, h, shadow);
}
void
draw_arrow(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow, unsigned char type)
{
BOUND(shadow, 1, 2);
@ -61,30 +76,30 @@ draw_arrow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow,
switch (type) {
case DRAW_ARROW_UP:
for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, win, gc_top, x, y + w, x + w / 2, y);
XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x + w / 2, y);
XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x, y + w);
XDrawLine(Xdisplay, d, gc_top, x, y + w, x + w / 2, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x + w / 2, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x, y + w);
}
break;
case DRAW_ARROW_DOWN:
for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, win, gc_top, x, y, x + w / 2, y + w);
XDrawLine(Xdisplay, win, gc_top, x, y, x + w, y);
XDrawLine(Xdisplay, win, gc_bottom, x + w, y, x + w / 2, y + w);
XDrawLine(Xdisplay, d, gc_top, x, y, x + w / 2, y + w);
XDrawLine(Xdisplay, d, gc_top, x, y, x + w, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y, x + w / 2, y + w);
}
break;
case DRAW_ARROW_LEFT:
for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x + w, y);
XDrawLine(Xdisplay, win, gc_bottom, x + w, y + w, x, y + w / 2);
XDrawLine(Xdisplay, win, gc_top, x, y + w / 2, x + w, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x + w, y);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + w, x, y + w / 2);
XDrawLine(Xdisplay, d, gc_top, x, y + w / 2, x + w, y);
}
break;
case DRAW_ARROW_RIGHT:
for (; shadow > 0; shadow--, x++, y++, w--) {
XDrawLine(Xdisplay, win, gc_top, x, y, x, y + w);
XDrawLine(Xdisplay, win, gc_top, x, y, x + w, y + w / 2);
XDrawLine(Xdisplay, win, gc_bottom, x, y + w, x + w, y + w / 2);
XDrawLine(Xdisplay, d, gc_top, x, y, x, y + w);
XDrawLine(Xdisplay, d, gc_top, x, y, x + w, y + w / 2);
XDrawLine(Xdisplay, d, gc_bottom, x, y + w, x + w, y + w / 2);
}
break;
default:
@ -93,10 +108,25 @@ draw_arrow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow,
}
void
draw_box(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h)
draw_arrow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w, int shadow, unsigned char type)
{
XDrawLine(Xdisplay, win, gc_top, x + w, y, x, y);
XDrawLine(Xdisplay, win, gc_top, x, y, x, y + h);
XDrawLine(Xdisplay, win, gc_bottom, x, y + h, x + w, y + h);
XDrawLine(Xdisplay, win, gc_bottom, x + w, y + h, x + w, y);
static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) {
gc_top = XCreateGC(Xdisplay, TermWin.parent, 0, NULL);
gc_bottom = XCreateGC(Xdisplay, TermWin.parent, 0, NULL);
}
XSetForeground(Xdisplay, gc_top, top);
XSetForeground(Xdisplay, gc_bottom, bottom);
draw_arrow(d, gc_top, gc_bottom, x, y, w, shadow, type);
}
void
draw_box(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int h)
{
XDrawLine(Xdisplay, d, gc_top, x + w, y, x, y);
XDrawLine(Xdisplay, d, gc_top, x, y, x, y + h);
XDrawLine(Xdisplay, d, gc_bottom, x, y + h, x + w, y + h);
XDrawLine(Xdisplay, d, gc_bottom, x + w, y + h, x + w, y);
}

View File

@ -33,10 +33,10 @@
#define DRAW_ARROW_LEFT (1UL << 2)
#define DRAW_ARROW_RIGHT (1UL << 3)
#define draw_uparrow_raised(win, g1, g2, x, y, w, s) draw_arrow(win, g1, g2, x, y, w, s, DRAW_ARROW_UP)
#define draw_uparrow_clicked(win, g1, g2, x, y, w, s) draw_arrow(win, g2, g1, x, y, w, s, DRAW_ARROW_UP)
#define draw_downarrow_raised(win, g1, g2, x, y, w, s) draw_arrow(win, g1, g2, x, y, w, s, DRAW_ARROW_DOWN)
#define draw_downarrow_clicked(win, g1, g2, x, y, w, s) draw_arrow(win, g2, g1, x, y, w, s, DRAW_ARROW_DOWN)
#define draw_uparrow_raised(d, g1, g2, x, y, w, s) draw_arrow(d, g1, g2, x, y, w, s, DRAW_ARROW_UP)
#define draw_uparrow_clicked(d, g1, g2, x, y, w, s) draw_arrow(d, g2, g1, x, y, w, s, DRAW_ARROW_UP)
#define draw_downarrow_raised(d, g1, g2, x, y, w, s) draw_arrow(d, g1, g2, x, y, w, s, DRAW_ARROW_DOWN)
#define draw_downarrow_clicked(d, g1, g2, x, y, w, s) draw_arrow(d, g2, g1, x, y, w, s, DRAW_ARROW_DOWN)
/************ Structures ************/
@ -45,9 +45,11 @@
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN
extern void draw_shadow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int shadow);
extern void draw_arrow(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow, unsigned char type);
extern void draw_box(Window win, GC gc_top, GC gc_bottom, int x, int y, int w, int h);
extern void draw_shadow(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int h, int shadow);
extern void draw_shadow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w, int h, int shadow);
extern void draw_arrow(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int shadow, unsigned char type);
extern void draw_arrow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w, int shadow, unsigned char type);
extern void draw_box(Drawable d, GC gc_top, GC gc_bottom, int x, int y, int w, int h);
_XFUNCPROTOEND

View File

@ -769,12 +769,21 @@ menuitem_select(menu_t * menu)
render_simage(images[image_submenu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_submenu, 0);
if (image_mode_is(image_submenu, MODE_AUTO)) {
enl_ipc_sync();
} else if (!image_mode_is(image_submenu, MODE_MASK)) {
draw_shadow_from_colors(menu->swin, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor],
0, 0, item->w - MENU_VGAP, item->h, 2);
draw_arrow_from_colors(menu->swin, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor],
item->w - 3 * MENU_HGAP, (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT);
}
#if 0
paste_simage(images[image_submenu].selected, image_submenu, menu->swin, 0, 0, item->w - MENU_VGAP, item->h);
#endif
} else {
render_simage(images[image_menu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_menu, 0);
if (image_mode_is(image_menu, MODE_MASK)) {
render_simage(images[image_menu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_menu, 0);
} else {
draw_shadow_from_colors(menu->swin, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], 0, 0, item->w - MENU_VGAP, item->h, 2);
}
if (image_mode_is(image_menu, MODE_AUTO)) {
enl_ipc_sync();
}
@ -880,6 +889,9 @@ menu_draw(menu_t * menu)
if (images[image_submenu].selected->iml->pad) {
width += images[image_submenu].selected->iml->pad->left + images[image_submenu].selected->iml->pad->right;
}
if (!image_mode_is(image_menu, MODE_MASK) || !image_mode_is(image_submenu, MODE_MASK)) {
width += 3 * MENU_VGAP;
}
menu->w = width;
menu->h = height;
}
@ -947,6 +959,7 @@ menu_draw(menu_t * menu)
gc = XCreateGC(Xdisplay, menu->win, GCForeground, &gcvalue);
XFillRectangle(Xdisplay, pmap->pixmap, gc, 0, 0, menu->w, menu->h);
XFreeGC(Xdisplay, gc);
draw_shadow_from_colors(pmap->pixmap, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], 0, 0, menu->w, menu->h, 2);
}
menu->bg = images[image_menu].norm->pmap->pixmap;
D_MENU(("menu_draw(): Menu background is 0x%08x\n", menu->bg));
@ -992,7 +1005,12 @@ menu_draw(menu_t * menu)
}
switch (item->type) {
case MENUITEM_SUBMENU:
paste_simage(images[image_submenu].norm, image_submenu, menu->bg, item->x, item->y, item->w - MENU_VGAP, item->h);
if (image_mode_is(image_submenu, MODE_MASK)) {
paste_simage(images[image_submenu].norm, image_submenu, menu->bg, item->x, item->y, item->w - MENU_VGAP, item->h);
} else {
draw_arrow_from_colors(menu->bg, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor],
item->x + item->w - 3 * MENU_HGAP, item->y + (item->h - MENU_VGAP) / 2, MENU_VGAP, 2, DRAW_ARROW_RIGHT);
}
break;
#if 0
case MENUITEM_STRING: