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 static void
textbox_tell(Widget *widget, char *property, char *command) textbox_tell(Widget *widget, char *property, char *command)
{ {
char *ntok, *tok; Data *d = widget->data;
ssize_t command_len = a_strlen(command);
int i = 0, phys_screen = get_phys_screen(widget->statusbar->screen);
if(!property || !command) if(!property || !command)
return; return;
Data *d = widget->data; if(!a_strcmp(property, "text"))
{
if (d->text) if (d->text)
p_delete(&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, ' '); widget->font = XftFontOpenName(globalconf.display,
if((!ntok && command_len - (tok - command) == 7) || get_phys_screen(widget->statusbar->screen), command);
ntok - tok == 7) 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) if(!a_strcmp(command, "center") || !a_strcmp(command, "left") ||
*ntok = 0; !a_strcmp(command, "right"))
if(!i) d->align = draw_get_align(command);
draw_color_new(globalconf.display, phys_screen, tok, &d->fg);
else else
draw_color_new(globalconf.display, phys_screen, tok, &d->bg); warn("text_align value must be (case-sensitive) \"center\", \"left\",\
if (ntok) or \"right\". But is: %s.\n", command);
*ntok = ' ';
tok = ntok + (ntok != NULL);
} }
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 else
break; warn("No such property: %s\n", property);
} return;
d->text = a_strdup(tok);
} }
Widget * Widget *