Fri Aug 20 13:23:44 PDT 1999 Michael Jennings <mej@eterm.org>

Since Mr. Kletnieks reminded me that I never finished it, I finally
	implemented support for right-justified menu text. :-)  Now you'll
	know why some of those menus seemed unnecessarily wide.


SVN revision: 64
This commit is contained in:
Michael Jennings 1999-08-20 20:25:04 +00:00
parent 022e3021d3
commit b89ca88e52
3 changed files with 23 additions and 4 deletions

View File

@ -2302,3 +2302,10 @@ Thu Aug 19 16:45:36 PDT 1999 Michael Jennings <mej@eterm.org>
fonts. fonts.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Fri Aug 20 13:23:44 PDT 1999 Michael Jennings <mej@eterm.org>
Since Mr. Kletnieks reminded me that I never finished it, I finally
implemented support for right-justified menu text. :-) Now you'll
know why some of those menus seemed unnecessarily wide.
-------------------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
# $Id$ # $Id$
DIRS = tile scale DIRS = tile scale
EXTRA_DIST = tile/014.png tile/circuit.png tile/backwave.jpg tile/button1.jpg tile/button5.jpg \ EXTRA_DIST = tile/014.png tile/circuit.png tile/backwave.jpg tile/40.png tile/6.png \
tile/nebula.jpg scale/fourthday.jpg scale/gaia.jpg scale/galleon.jpg scale/night_of_the_dragon.jpg \ tile/nebula.jpg scale/fourthday.jpg scale/gaia.jpg scale/galleon.jpg scale/night_of_the_dragon.jpg \
README.backgrounds README.backgrounds
pixmapdir = $(pkgdatadir)/pix pixmapdir = $(pkgdatadir)/pix

View File

@ -770,6 +770,9 @@ menuitem_select(menu_t * menu, menuitem_t * item)
render_simage(images[image_menu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_menu, 0); render_simage(images[image_menu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_menu, 0);
} }
draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len); draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len);
if (item->rtext) {
draw_string(menu->swin, menu->gc, item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->h - MENU_VGAP, item->rtext, item->rlen);
}
} }
void void
@ -787,6 +790,10 @@ menuitem_deselect(menu_t * menu, menuitem_t * item)
paste_simage(images[image_submenu].norm, menu->win, item->x, item->y, item->w - MENU_VGAP, item->h); paste_simage(images[image_submenu].norm, menu->win, item->x, item->y, item->w - MENU_VGAP, item->h);
} }
draw_string(menu->win, menu->gc, 2 * MENU_HGAP, item->y + item->h - MENU_VGAP, item->text, item->len); draw_string(menu->win, menu->gc, 2 * MENU_HGAP, item->y + item->h - MENU_VGAP, item->text, item->len);
if (item->rtext) {
draw_string(menu->win, menu->gc, item->x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->y + item->h - MENU_VGAP,
item->rtext, item->rlen);
}
} }
} }
@ -827,7 +834,6 @@ menu_draw(menu_t * menu)
int ascent, descent, direction; int ascent, descent, direction;
XCharStruct chars; XCharStruct chars;
Screen *scr; Screen *scr;
unsigned short longest = 0;
ASSERT(menu != NULL); ASSERT(menu != NULL);
@ -839,6 +845,8 @@ menu_draw(menu_t * menu)
XChangeGC(Xdisplay, menu->gc, GCForeground, &gcvalue); XChangeGC(Xdisplay, menu->gc, GCForeground, &gcvalue);
if (!menu->w) { if (!menu->w) {
unsigned short longest;
len = strlen(menu->title); len = strlen(menu->title);
longest = XTextWidth(menu->font, menu->title, len); longest = XTextWidth(menu->font, menu->title, len);
height = menu->fheight + 3 * MENU_VGAP; height = menu->fheight + 3 * MENU_VGAP;
@ -848,9 +856,9 @@ menu_draw(menu_t * menu)
width = XTextWidth(menu->font, item->text, j); width = XTextWidth(menu->font, item->text, j);
if (item->rtext) { if (item->rtext) {
width += XTextWidth(menu->font, item->rtext, item->rlen) + (2*MENU_HGAP); width += XTextWidth(menu->font, item->rtext, item->rlen) + (2 * MENU_HGAP);
} }
longest = (longest>width)?longest:width; longest = (longest > width) ? longest : width;
height += ((item->type == MENUITEM_SEP) ? (MENU_VGAP) : (menu->fheight)) + MENU_VGAP; height += ((item->type == MENUITEM_SEP) ? (MENU_VGAP) : (menu->fheight)) + MENU_VGAP;
} }
width = longest + (4 * MENU_HGAP); width = longest + (4 * MENU_HGAP);
@ -941,6 +949,10 @@ menu_draw(menu_t * menu)
break; break;
} }
draw_string(menu->win, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len); draw_string(menu->win, menu->gc, str_x, str_y - MENU_VGAP / 2, item->text, item->len);
if (item->rtext) {
draw_string(menu->win, menu->gc, str_x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 3 * MENU_HGAP, str_y - MENU_VGAP / 2,
item->rtext, item->rlen);
}
} }
} }
} }