aboutsummaryrefslogtreecommitdiff
path: root/src/widget.c
blob: 6cf1b62485c562241ec9985b9a433f84dbe75662 (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
/* See LICENSE file for copyright and license details. */

#include <stdio.h>
#include <stdlib.h>
#include "widget.h"

static void
cherry_widget_draw(CherryWidget *widget)
{
	widget->drawn = 1;
}

CherryWidget *
cherry_widget_new(void)
{
	CherryWidget *widget = malloc(sizeof(*widget));
	widget->x = 0;
	widget->y = 0;
	widget->widgets = clist_create();
	widget->width = 0;
	widget->height = 0;
	widget->visible = 0;
	widget->draw = cherry_widget_draw;

	return widget;
}

void
cherry_widget_get_dimension(CherryWidget *widget, int *width, int *height) {
	*width = widget->width;
	*height = widget->height;
}

void
cherry_widget_add_component(CherryWidget *parent, CherryWidget *child)
{
	clist_add(&parent->widgets, child);
}