mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-06 01:19:44 +00:00
things
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@18 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
28
src/core.c
28
src/core.c
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "stb_ds.h"
|
||||
|
||||
#define Dispatch(x, y) \
|
||||
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
||||
|
||||
HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsigned int width, unsigned int height) {
|
||||
HMILSKO h = malloc(sizeof(*h));
|
||||
|
||||
@@ -19,12 +22,16 @@ HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsi
|
||||
shdefault(h->text, NULL);
|
||||
shdefault(h->integer, -1);
|
||||
|
||||
Dispatch(h, create);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
void MilskoDestroyWidget(HMILSKO handle) {
|
||||
int i;
|
||||
|
||||
Dispatch(handle, destroy);
|
||||
|
||||
if(handle->children != NULL) {
|
||||
for(i = 0; i < arrlen(handle->children); i++) {
|
||||
if(handle->children[i] == handle) {
|
||||
@@ -105,6 +112,27 @@ void MilskoSetText(HMILSKO handle, const char* key, const char* value) {
|
||||
}
|
||||
}
|
||||
|
||||
int MilskoGetInteger(HMILSKO handle, const char* key) {
|
||||
if(strcmp(key, MilskoNx) == 0 || strcmp(key, MilskoNy) == 0 || strcmp(key, MilskoNwidth) == 0 || strcmp(key, MilskoNheight) == 0) {
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
|
||||
MilskoLLGetXYWH(handle->lowlevel, &x, &y, &w, &h);
|
||||
|
||||
if(strcmp(key, MilskoNx) == 0) return x;
|
||||
if(strcmp(key, MilskoNy) == 0) return y;
|
||||
if(strcmp(key, MilskoNwidth) == 0) return w;
|
||||
if(strcmp(key, MilskoNheight) == 0) return h;
|
||||
return -1;
|
||||
} else {
|
||||
return shget(handle->integer, key);
|
||||
}
|
||||
}
|
||||
|
||||
const char* MilskoGetText(HMILSKO handle, const char* key) {
|
||||
return shget(handle->text, key);
|
||||
}
|
||||
|
||||
void MilskoApply(HMILSKO handle, ...) {
|
||||
va_list va;
|
||||
char* key;
|
||||
|
||||
10
src/window.c
10
src/window.c
@@ -1,5 +1,11 @@
|
||||
/* $Id$ */
|
||||
#include <Milsko/Milsko.h>
|
||||
|
||||
MilskoClassRec MilskoWindowClassRec = {};
|
||||
MilskoClass MilskoWindowClass = &MilskoWindowClassRec;
|
||||
MilskoClassRec MilskoWindowClassRec = {
|
||||
NULL, /* opaque */
|
||||
NULL, /* create */
|
||||
NULL, /* destroy */
|
||||
NULL, /* draw */
|
||||
NULL /* click */
|
||||
};
|
||||
MilskoClass MilskoWindowClass = &MilskoWindowClassRec;
|
||||
|
||||
Reference in New Issue
Block a user