add align option to textbox

This commit is contained in:
Julien Danjou 2008-01-03 16:02:41 +01:00
parent 6c7b0304a0
commit ec53f3d070
2 changed files with 4 additions and 1 deletions

View File

@ -534,6 +534,7 @@ config_parse(const char *confpatharg)
CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE), CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "align", (char *) "center", CFGF_NONE),
CFG_END() CFG_END()
}; };
static cfg_opt_t widget_focustitle_opts[] = static cfg_opt_t widget_focustitle_opts[] =

View File

@ -30,6 +30,7 @@ typedef struct
{ {
char *text; char *text;
int width; int width;
int align;
XColor fg; XColor fg;
XColor bg; XColor bg;
} Data; } Data;
@ -51,7 +52,7 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
widget->alignment); widget->alignment);
draw_text(ctx, widget->location, 0, widget->width, widget->statusbar->height, draw_text(ctx, widget->location, 0, widget->width, widget->statusbar->height,
AlignCenter, 0, widget->font, d->text, d->fg, d->bg); d->align, 0, widget->font, d->text, d->fg, d->bg);
return widget->width; return widget->width;
} }
@ -90,6 +91,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
d->width = cfg_getint(config, "width"); d->width = cfg_getint(config, "width");
d->align = draw_get_align(cfg_getstr(config, "align"));
if((buf = cfg_getstr(config, "font"))) if((buf = cfg_getstr(config, "font")))
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf); w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);