allow textbox to have special width

This commit is contained in:
Julien Danjou 2007-12-30 14:49:03 +01:00
parent 0eb4743385
commit 75c7d04adf
2 changed files with 6 additions and 1 deletions

View File

@ -517,6 +517,7 @@ config_parse(const char *confpatharg)
static cfg_opt_t widget_textbox_focus_opts[] = static cfg_opt_t widget_textbox_focus_opts[] =
{ {
CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "mouse", mouse_generic_opts, CFGF_MULTI),
CFG_INT((char *) "width", 0, CFGF_NONE),
CFG_STR((char *) "text", (char *) NULL, CFGF_NONE), CFG_STR((char *) "text", (char *) NULL, CFGF_NONE),
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),

View File

@ -48,7 +48,9 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
{ {
Data *d = widget->data; Data *d = widget->data;
if(!widget->width)
widget->width = textwidth(widget->font, d->text); widget->width = textwidth(widget->font, d->text);
widget->location = widget_calculate_offset(widget->statusbar->width, widget->location = widget_calculate_offset(widget->statusbar->width,
widget->width, widget->width,
offset, offset,
@ -91,6 +93,8 @@ textbox_new(Statusbar *statusbar, cfg_t *config)
else else
d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG];
w->width = cfg_getint(config, "width");
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);