2025-09-28 06:52:49 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
#include <Milsko/Milsko.h>
|
|
|
|
|
|
2025-09-28 07:03:05 +00:00
|
|
|
#include "stb_ds.h"
|
|
|
|
|
|
|
|
|
|
HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsigned int width, unsigned int height) {
|
2025-09-28 06:52:49 +00:00
|
|
|
HMILSKO h = malloc(sizeof(*h));
|
2025-09-28 07:03:05 +00:00
|
|
|
|
|
|
|
|
h->parent = parent;
|
|
|
|
|
h->children = NULL;
|
|
|
|
|
h->lowlevel = MilskoLLCreate(parent->lowlevel, x, y, width, height);
|
2025-09-28 07:11:55 +00:00
|
|
|
h->class = class;
|
2025-09-28 07:03:05 +00:00
|
|
|
|
|
|
|
|
arrput(parent->children, h);
|
|
|
|
|
|
|
|
|
|
return h;
|
2025-09-28 06:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MilskoDestroyWidget(HMILSKO handle) {
|
2025-09-28 07:03:05 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if(handle->children != NULL) {
|
|
|
|
|
for(i = 0; i < arrlen(handle->children); i++) {
|
|
|
|
|
if(handle->children[i] == handle) {
|
|
|
|
|
MilskoDestroyWidget(handle->children[i]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arrfree(handle->children);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(handle->parent != NULL) {
|
|
|
|
|
for(i = 0; i < arrlen(handle->parent->children); i++) {
|
|
|
|
|
if(handle->parent->children[i] == handle) {
|
|
|
|
|
arrdel(handle->parent->children, i);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MilskoLLDestroy(handle->lowlevel);
|
2025-09-28 06:52:49 +00:00
|
|
|
free(handle);
|
|
|
|
|
}
|