mirror of
https://github.com/0intro/wmii
synced 2024-11-23 06:11:21 +03:00
some more changes in liblitz (I need now a working wmii that I can change the Client/Bar rendering)
This commit is contained in:
parent
942665ff64
commit
72c7d317e2
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cext.h>
|
||||
#include "blitz.h"
|
||||
|
||||
@ -13,14 +14,72 @@ blitz_create_input(Drawable drawable, GC gc)
|
||||
BlitzWidget *i = cext_emallocz(sizeof(BlitzWidget));
|
||||
i->drawable = drawable;
|
||||
i->gc = gc;
|
||||
i->draw = blitz_draw_input;
|
||||
return i;
|
||||
}
|
||||
|
||||
void
|
||||
blitz_draw_input(BlitzWidget *i)
|
||||
{
|
||||
unsigned int x, y, w, h, shortened, len;
|
||||
static char text[2048];
|
||||
XGCValues gcv;
|
||||
blitz_draw_tile(i);
|
||||
|
||||
|
||||
if (!i->text)
|
||||
return;
|
||||
|
||||
x = y = shortened = 0;
|
||||
w = h = 1;
|
||||
cext_strlcpy(text, i->text, sizeof(text));
|
||||
len = strlen(text);
|
||||
gcv.foreground = i->color.fg;
|
||||
gcv.background = i->color.bg;
|
||||
if(i->font.set)
|
||||
XChangeGC(__blitz.display, i->gc, GCForeground | GCBackground, &gcv);
|
||||
else {
|
||||
gcv.font = i->font.xfont->fid;
|
||||
XChangeGC(__blitz.display, i->gc, GCForeground | GCBackground | GCFont, &gcv);
|
||||
}
|
||||
|
||||
h = i->font.ascent + i->font.descent;
|
||||
y = i->rect.y + i->rect.height / 2 - h / 2 + i->font.ascent;
|
||||
|
||||
/* shorten text if necessary */
|
||||
while (len && (w = blitz_textwidth(&i->font, text)) > i->rect.width) {
|
||||
text[len - 1] = 0;
|
||||
len--;
|
||||
shortened = 1;
|
||||
}
|
||||
|
||||
if (w > i->rect.width)
|
||||
return;
|
||||
|
||||
/* mark shortened info in the string */
|
||||
if (shortened) {
|
||||
if (len > 3)
|
||||
text[len - 3] = '.';
|
||||
if (len > 2)
|
||||
text[len - 2] = '.';
|
||||
if (len > 1)
|
||||
text[len - 1] = '.';
|
||||
}
|
||||
switch (i->align) {
|
||||
case EAST:
|
||||
x = i->rect.x + i->rect.width - (h / 2 + w);
|
||||
break;
|
||||
case CENTER:
|
||||
x = i->rect.x + (i->rect.width - w) / 2;
|
||||
break;
|
||||
default:
|
||||
x = i->rect.x + h / 2;
|
||||
break;
|
||||
}
|
||||
if(i->font.set)
|
||||
XmbDrawString(__blitz.display, i->drawable, i->font.set, i->gc, x, y, text, len);
|
||||
else
|
||||
XDrawString(__blitz.display, i->drawable, i->gc, x, y, text, len);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -13,6 +13,7 @@ blitz_create_tile(Drawable drawable, GC gc)
|
||||
BlitzWidget *t = cext_emallocz(sizeof(BlitzWidget));
|
||||
t->drawable = drawable;
|
||||
t->gc = gc;
|
||||
t->draw = blitz_draw_tile;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user