diff --git a/src/borders.c b/src/borders.c index 32eddc15..cc3a57a3 100644 --- a/src/borders.c +++ b/src/borders.c @@ -112,7 +112,7 @@ BorderWinpartITclassApply(EWin * ewin, int i, int force) ITApply(ewb->win, ewin->border->part[i].iclass, is, ewb->state, ewin->state.active, EoIsSticky(ewin), - ST_BORDER, ewin->border->part[i].tclass, ts, txt); + ST_BORDER, ewin->border->part[i].tclass, ts, txt, 1); } static int diff --git a/src/buttons.c b/src/buttons.c index 2f310b9c..54a73806 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -262,7 +262,7 @@ static void ButtonDraw(Button * b) { ITApply(EoGetWin(b), b->iclass, NULL, - b->state, 0, 0, ST_BUTTON, b->tclass, NULL, b->label); + b->state, 0, 0, ST_BUTTON, b->tclass, NULL, b->label, 0); EoShapeUpdate(b, 0); } diff --git a/src/coords.c b/src/coords.c index bf89eeca..bba5d86c 100644 --- a/src/coords.c +++ b/src/coords.c @@ -125,7 +125,7 @@ CoordsShow(EWin * ewin) EobjMap(eo, 0); } - ITApply(eo->win, ic, NULL, STATE_NORMAL, 1, 0, ST_SOLID, tc, NULL, s); + ITApply(eo->win, ic, NULL, STATE_NORMAL, 1, 0, ST_SOLID, tc, NULL, s, 1); if (md) /* Assuming that shape change only happens when size changes too */ EobjShapeUpdate(eo, 0); diff --git a/src/dialog.c b/src/dialog.c index a10a26fd..a9c0d11c 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -440,7 +440,7 @@ DialogDrawButton(Dialog * d __UNUSED__, DButton * db) else { ITApply(db->win, db->iclass, NULL, state, 0, 0, - ST_WIDGET, db->tclass, NULL, db->text); + ST_WIDGET, db->tclass, NULL, db->text, 0); } } #endif @@ -1660,7 +1660,7 @@ DialogDrawItem(Dialog * d, DItem * di) else if (!(di->hilited) && (di->clicked)) state = STATE_CLICKED; ITApply(di->win, di->iclass, NULL, state, 0, 0, - ST_WIDGET, di->tclass, NULL, di->text); + ST_WIDGET, di->tclass, NULL, di->text, 0); break; case DITEM_AREA: diff --git a/src/iclass.c b/src/iclass.c index 8e1693c1..ee4a3814 100644 --- a/src/iclass.c +++ b/src/iclass.c @@ -1165,7 +1165,7 @@ ImagestateDrawBevel(ImageState * is, Drawable win, GC gc, int w, int h) void ITApply(Win win, ImageClass * ic, ImageState * is, int state, int active, int sticky, int image_type, - TextClass * tc, TextState * ts, const char *text) + TextClass * tc, TextState * ts, const char *text, int flags) { int w, h; @@ -1212,7 +1212,7 @@ ITApply(Win win, ImageClass * ic, ImageState * is, TextstateTextDraw(ts, win, pmap, text, 0, 0, w, h, &(ic->padding), 0, - TextclassGetJustification(tc)); + TextclassGetJustification(tc), flags); } /* Set window pixmap */ @@ -1261,7 +1261,8 @@ void ImageclassApply(ImageClass * ic, Win win, int active, int sticky, int state, int image_type) { - ITApply(win, ic, NULL, state, active, sticky, image_type, NULL, NULL, NULL); + ITApply(win, ic, NULL, state, active, sticky, image_type, NULL, NULL, NULL, + 0); } void diff --git a/src/iclass.h b/src/iclass.h index 2fff7805..7afd829b 100644 --- a/src/iclass.h +++ b/src/iclass.h @@ -121,6 +121,7 @@ EImage *ImageclassGetImageBlended(ImageClass * ic, Win win, int image_type); void ITApply(Win win, ImageClass * ic, ImageState * is, int state, int active, int sticky, int image_type, - TextClass * tc, TextState * ts, const char *text); + TextClass * tc, TextState * ts, const char *text, + int flags); #endif /* _ICLASS_H */ diff --git a/src/tclass.h b/src/tclass.h index a90cc28d..e3ef1db1 100644 --- a/src/tclass.h +++ b/src/tclass.h @@ -112,7 +112,7 @@ __EXPORT__ void TextstateTextFit(TextState * ts, char **ptext, int *pw, void TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, int x, int y, int w, int h, const EImageBorder * pad, - int fsize, int justification); + int fsize, int justh, int justv); void TextSize(TextClass * tclass, int active, int sticky, int state, const char *text, int *width, int *height, int fsize); diff --git a/src/text.c b/src/text.c index b0d470c1..ce58a053 100644 --- a/src/text.c +++ b/src/text.c @@ -828,12 +828,12 @@ TextstateTextFit(TextState * ts, char **ptext, int *pw, int textwidth_limit) void TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, int x, int y, int w, int h, const EImageBorder * pad, - int fsize __UNUSED__, int justification) + int fsize __UNUSED__, int justh, int justv) { const char *str; char **lines; int i, num_lines; - int textwidth_limit, offset_x, offset_y; + int textwidth_limit, textheight_limit, offset_x, offset_y; int xx, yy, ww, hh, ascent; Pixmap drawable; @@ -865,6 +865,7 @@ TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, h -= pad->top + pad->bottom; } textwidth_limit = w; + textheight_limit = h; } else { @@ -876,11 +877,12 @@ TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, w -= pad->top + pad->bottom; } textwidth_limit = h; + textheight_limit = w; } #if 0 - Eprintf("TextstateTextDraw %d,%d %dx%d(%d): %s\n", x, y, w, h, - textwidth_limit, text); + Eprintf("TextstateTextDraw %d,%d %dx%d(%dx%d): %s\n", x, y, w, h, + textwidth_limit, textheight_limit, text); #endif xx = x; @@ -900,9 +902,11 @@ TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, if (ww > textwidth_limit) ts->ops->TextFit(ts, &lines[i], &ww, textwidth_limit); + if (justv) + yy += (textheight_limit - hh) / 2; if (i == 0) yy += ascent; - xx = x + (((textwidth_limit - ww) * justification) >> 10); + xx = x + (((textwidth_limit - ww) * justh) >> 10); im = TextImageGet(win, draw, xx - 1, yy - 1 - ascent, ww + 2, hh + 2, ts); @@ -931,9 +935,11 @@ TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, if (ww > textwidth_limit) ts->ops->TextFit(ts, &lines[i], &ww, textwidth_limit); + if (justv) + yy += (textheight_limit - hh) / 2; if (i == 0) yy += ascent; - xx = x + (((textwidth_limit - ww) * justification) >> 10); + xx = x + (((textwidth_limit - ww) * justh) >> 10); if (ts->style.orientation != FONT_TO_RIGHT) drawable = ECreatePixmap(win, ww + 2, hh + 2, 0); @@ -976,7 +982,7 @@ TextstateTextDraw(TextState * ts, Win win, Drawable draw, const char *text, void TextDraw(TextClass * tclass, Win win, Drawable draw, int active, int sticky, int state, const char *text, int x, int y, int w, int h, int fsize, - int justification) + int justh) { TextState *ts; @@ -987,6 +993,5 @@ TextDraw(TextClass * tclass, Win win, Drawable draw, int active, int sticky, if (!ts) return; - TextstateTextDraw(ts, win, draw, text, x, y, w, h, NULL, fsize, - justification); + TextstateTextDraw(ts, win, draw, text, x, y, w, h, NULL, fsize, justh, 0); }