summaryrefslogtreecommitdiff
path: root/src/widget/image.c
blob: ad49f9e210f1668d8fdcc5894ad02411b07e7b92 (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

#include <stdlib.h>
#include <assert.h>

#include <stdlib.h>
#include "main.h"
#include "image.h"
#include "interface.h"
#include "font.h"

#include "widget.h"
#include "widget_image.h"

widget_t *newWidgetImage(int x, int y, image_t * image)
{
	widget_image_t *new;

	new = malloc(sizeof(widget_image_t));
	new->image = image;

	return newWidget(WIDGET_TYPE_IMAGE, x, y, image->w, image->h, new);
}

void drawWidgetImage(widget_t * widget)
{
	widget_image_t *p;

	assert(widget != NULL);
	assert(widget->type == WIDGET_TYPE_IMAGE);

	p = (widget_image_t *) widget->private_data;
	drawImage(p->image, widget->x, widget->y, 0, 0, p->image->w, p->image->h);
}

void eventWidgetImage(widget_t * widget)
{
	assert(widget != NULL);
	assert(widget->type == WIDGET_TYPE_IMAGE);
}

void destroyWidgetImage(widget_t * widget)
{
	widget_image_t *p;

	assert(widget != NULL);
	assert(widget->type == WIDGET_TYPE_IMAGE);

	p = (widget_image_t *) widget->private_data;

	free(p);
	destroyWidget(widget);
}