summaryrefslogtreecommitdiff
path: root/src/widget_label.c
blob: 0cb0929377628574fde3ad2bf6b62fda4f64905f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

#include "main.h"
#include "interface.h"
#include "font.h"
#include "widget_label.h"

widget_label_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->x = x;
	new->y = y;
	new->bind = bind;
	getTextSize(text, &new->w, &new->h);

	return new;
}

void drawWidgetLabel(widget_label_t *p)
{
	switch( p->bind )
	{
		case WIDGET_LABEL_RIGHT :
			drawFont(p->text, p->x+p->w, p->y, COLOR_WHITE);
		break;
		case WIDGET_LABEL_LEFT :
			drawFont(p->text, p->x, p->y+p->h/2, COLOR_WHITE);
		break;
		case WIDGET_LABEL_CENTER :
			drawFont(p->text, p->x-p->w/2, p->y, COLOR_WHITE);
		break;
	}
}

void eventWidgetLabel(widget_label_t *p)
{
}

void destroyWidgetLabel(widget_label_t *p)
{
	free(p->text);
	free(p);
}