summaryrefslogtreecommitdiff
path: root/src/widget/widget_label.c
diff options
context:
space:
mode:
authorTomas Chvatal <scarabeus@gentoo.org>2008-12-11 19:39:49 +0100
committerTomas Chvatal <scarabeus@gentoo.org>2008-12-11 19:39:49 +0100
commita83321436c8d40210bbbd0a44fe1290ed71638af (patch)
tree02004c36772311bdc1ba6b9a2508b20691cca5c6 /src/widget/widget_label.c
parent3ba6105170ecac2fb124d9eb7e81ba72dd4700b8 (diff)
Revert "First pass for renaming screen/widget."
This reverts commit 3ba6105170ecac2fb124d9eb7e81ba72dd4700b8.
Diffstat (limited to 'src/widget/widget_label.c')
-rw-r--r--src/widget/widget_label.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/widget/widget_label.c b/src/widget/widget_label.c
new file mode 100644
index 0000000..e3c907c
--- /dev/null
+++ b/src/widget/widget_label.c
@@ -0,0 +1,64 @@
+
+#include <stdlib.h>
+#include <assert.h>
+
+#include "main.h"
+#include "interface.h"
+#include "font.h"
+#include "widget_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);
+}