summaryrefslogtreecommitdiff
path: root/src/widget/widget.c
blob: 4e4143e126eec50658c9e084c7c317a48b35dd2c (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdlib.h>
#include <assert.h>

#include "main.h"

#include "widget.h"
#include "widget_label.h"

widget_t *widget_new(int type, int x, int y, int w, int h, void *private_data)
{
	widget_t *new;

	new = malloc(sizeof(widget_t));
	new->type = type;
	new->x = x;
	new->y = y;
	new->w = w;
	new->h = h;
	new->private_data = private_data;

	return new;
}

void widget_set_location(widget_t *p, int x, int y)
{
	p->x = x;
	p->y = y;
}

void widget_get_location(widget_t *p, int *x, int *y)
{
	if (x != NULL) {
		*x = p->x;
	}

	if (y != NULL) {
		*y = p->y;
	}
}

void widget_get_size(widget_t *p, int w, int h)
{
	p->w = w;
	p->h = h;
}

void widget_set_size(widget_t *p, int *w, int *h)
{
	if (w != NULL) {
		*w = p->w;
	}

	if (h != NULL) {
		*h = p->h;
	}
}

void widget_destroy(widget_t *p)
{
	free(p);
}