diff options
| author | Tomas Chvatal <scarabeus@gentoo.org> | 2009-02-03 13:56:55 +0100 |
|---|---|---|
| committer | Tomas Chvatal <scarabeus@gentoo.org> | 2009-02-03 13:56:55 +0100 |
| commit | 87821f04c9565450d8e724be76993ae5ea2c20c4 (patch) | |
| tree | cd98fd39a789464294fd05ae00eeea5bd9411138 /src/widget/label.c | |
| parent | 509890f14896d2064916555c04a3bfeec537cb1d (diff) | |
Revert "Revert "First pass renaming sreen and widgets.""
This reverts commit 509890f14896d2064916555c04a3bfeec537cb1d.
Diffstat (limited to 'src/widget/label.c')
| -rw-r--r-- | src/widget/label.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/widget/label.c b/src/widget/label.c new file mode 100644 index 0000000..a2d0a48 --- /dev/null +++ b/src/widget/label.c @@ -0,0 +1,64 @@ + +#include <stdlib.h> +#include <assert.h> + +#include "main.h" +#include "interface.h" +#include "font.h" +#include "label.h" +#include "widget.h" + +widget_t *newWidgetLabel(char *text, int x, int y, int bind) +{ + widget_label_t *new; + + new = malloc(sizeof(widget_label_t)); + new->text = strdup(text); + new->bind = bind; + getTextSize(text, &(new->w), &(new->h)); + + return newWidget(WIDGET_TYPE_LABEL, x, y, new->w, new->h, new); +} + +void drawWidgetLabel(widget_t * widget) +{ + widget_label_t *p; + + assert(widget != NULL); + assert(widget->type == WIDGET_TYPE_LABEL); + + p = (widget_label_t *) widget->private_data; + + switch (p->bind) { + case WIDGET_LABEL_RIGHT: + drawFont(p->text, widget->x + p->w, widget->y + p->h / 2, COLOR_WHITE); + break; + case WIDGET_LABEL_LEFT: + drawFont(p->text, widget->x, widget->y + widget->h / 2, COLOR_WHITE); + break; + case WIDGET_LABEL_CENTER: + drawFont(p->text, widget->x - p->w / 2, widget->y + p->h / 2, COLOR_WHITE); + break; + } +} + +void eventWidgetLabel(widget_t * widget) +{ + assert(widget != NULL); + assert(widget->type == WIDGET_TYPE_LABEL); +} + +void destroyWidgetLabel(widget_t * widget) +{ + widget_label_t *p; + + assert(widget != NULL); + assert(widget->type == WIDGET_TYPE_LABEL); + + p = (widget_label_t *) widget->private_data; + + free(p->text); + free(p); + + destroyWidget(widget); +} |