textbox handles properties now

text, fg, bg, font, width and text_align actually
This commit is contained in:
marco candrian 2008-02-17 08:39:53 +01:00 committed by Julien Danjou
parent c384252bc6
commit 57e9cb468f
1 changed files with 39 additions and 25 deletions

View File

@ -67,37 +67,51 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
static void
textbox_tell(Widget *widget, char *property, char *command)
{
char *ntok, *tok;
ssize_t command_len = a_strlen(command);
int i = 0, phys_screen = get_phys_screen(widget->statusbar->screen);
Data *d = widget->data;
if(!property || !command)
return;
Data *d = widget->data;
if(!a_strcmp(property, "text"))
{
if (d->text)
p_delete(&d->text);
d->text = a_strdup(command);
}
else if(!a_strcmp(property, "fg"))
draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->fg);
for (i = 0, tok = command; tok && i < 2 && *tok == '#'; i++)
else if(!a_strcmp(property, "bg"))
draw_color_new(globalconf.display, widget->statusbar->screen, command, &d->bg);
else if(!a_strcmp(property, "font"))
{
ntok = strchr(tok, ' ');
if((!ntok && command_len - (tok - command) == 7) ||
ntok - tok == 7)
widget->font = XftFontOpenName(globalconf.display,
get_phys_screen(widget->statusbar->screen), command);
if(!widget->font)
widget->font = globalconf.screens[widget->statusbar->screen].font;
}
else if(!a_strcmp(property, "width"))
d->width = atoi(command);
else if(!a_strcmp(property, "text_align"))
{
if(ntok)
*ntok = 0;
if(!i)
draw_color_new(globalconf.display, phys_screen, tok, &d->fg);
if(!a_strcmp(command, "center") || !a_strcmp(command, "left") ||
!a_strcmp(command, "right"))
d->align = draw_get_align(command);
else
draw_color_new(globalconf.display, phys_screen, tok, &d->bg);
if (ntok)
*ntok = ' ';
tok = ntok + (ntok != NULL);
warn("text_align value must be (case-sensitive) \"center\", \"left\",\
or \"right\". But is: %s.\n", command);
}
else if(!a_strcmp(property, "align") || !a_strcmp(property, "mouse") ||
!a_strcmp(property, "x") || !a_strcmp(property, "y"))
warn("Property \"%s\" can't get changed.\n", property);
else
break;
}
d->text = a_strdup(tok);
warn("No such property: %s\n", property);
return;
}
Widget *