mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-09 10:53:27 +00:00
prop
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@17 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -9,6 +9,16 @@ typedef struct _MilskoPoint {
|
|||||||
int y;
|
int y;
|
||||||
} MilskoPoint;
|
} MilskoPoint;
|
||||||
|
|
||||||
|
typedef struct _MilskoTextKeyValue {
|
||||||
|
char* key;
|
||||||
|
char* value;
|
||||||
|
} MilskoTextKeyValue;
|
||||||
|
|
||||||
|
typedef struct _MilskoIntegerKeyValue {
|
||||||
|
char* key;
|
||||||
|
int value;
|
||||||
|
} MilskoIntegerKeyValue;
|
||||||
|
|
||||||
typedef struct _MilskoClass* MilskoClass;
|
typedef struct _MilskoClass* MilskoClass;
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
@@ -21,6 +31,9 @@ typedef struct _Milsko {
|
|||||||
HMILSKO parent;
|
HMILSKO parent;
|
||||||
HMILSKO* children;
|
HMILSKO* children;
|
||||||
MilskoClass class;
|
MilskoClass class;
|
||||||
|
|
||||||
|
MilskoTextKeyValue* text;
|
||||||
|
MilskoIntegerKeyValue* integer;
|
||||||
}* HMILSKO;
|
}* HMILSKO;
|
||||||
#else
|
#else
|
||||||
typedef void* HMILSKO;
|
typedef void* HMILSKO;
|
||||||
|
|||||||
28
src/core.c
28
src/core.c
@@ -13,6 +13,12 @@ HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsi
|
|||||||
|
|
||||||
if(parent != NULL) arrput(parent->children, h);
|
if(parent != NULL) arrput(parent->children, h);
|
||||||
|
|
||||||
|
sh_new_strdup(h->text);
|
||||||
|
sh_new_strdup(h->integer);
|
||||||
|
|
||||||
|
shdefault(h->text, NULL);
|
||||||
|
shdefault(h->integer, -1);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,14 +44,23 @@ void MilskoDestroyWidget(HMILSKO handle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MilskoLLDestroy(handle->lowlevel);
|
MilskoLLDestroy(handle->lowlevel);
|
||||||
|
|
||||||
|
shfree(handle->integer);
|
||||||
|
|
||||||
|
for(i = 0; i < shlen(handle->text); i++) {
|
||||||
|
free(handle->text[i].value);
|
||||||
|
handle->text[i].value = NULL;
|
||||||
|
}
|
||||||
|
shfree(handle->text);
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
MILSKODECL void MilskoStep(HMILSKO handle) {
|
void MilskoStep(HMILSKO handle) {
|
||||||
MilskoLLNextEvent(handle->lowlevel);
|
MilskoLLNextEvent(handle->lowlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
MILSKODECL int MilskoPending(HMILSKO handle) {
|
int MilskoPending(HMILSKO handle) {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
if(MilskoPending(handle->children[i])) return 1;
|
if(MilskoPending(handle->children[i])) return 1;
|
||||||
@@ -53,7 +68,7 @@ MILSKODECL int MilskoPending(HMILSKO handle) {
|
|||||||
return MilskoLLPending(handle->lowlevel);
|
return MilskoLLPending(handle->lowlevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
MILSKODECL void MilskoLoop(HMILSKO handle) {
|
void MilskoLoop(HMILSKO handle) {
|
||||||
while(1) {
|
while(1) {
|
||||||
MilskoStep(handle);
|
MilskoStep(handle);
|
||||||
MilskoLLSleep(10);
|
MilskoLLSleep(10);
|
||||||
@@ -74,12 +89,19 @@ void MilskoSetInteger(HMILSKO handle, const char* key, int n) {
|
|||||||
if(strcmp(key, MilskoNheight) == 0) h = n;
|
if(strcmp(key, MilskoNheight) == 0) h = n;
|
||||||
if(xy) MilskoLLSetXY(handle->lowlevel, x, y);
|
if(xy) MilskoLLSetXY(handle->lowlevel, x, y);
|
||||||
if(wh) MilskoLLSetWH(handle->lowlevel, w, h);
|
if(wh) MilskoLLSetWH(handle->lowlevel, w, h);
|
||||||
|
} else {
|
||||||
|
shput(handle->integer, key, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoSetText(HMILSKO handle, const char* key, const char* value) {
|
void MilskoSetText(HMILSKO handle, const char* key, const char* value) {
|
||||||
if(strcmp(key, MilskoNtitle) == 0) {
|
if(strcmp(key, MilskoNtitle) == 0) {
|
||||||
MilskoLLSetTitle(handle->lowlevel, value);
|
MilskoLLSetTitle(handle->lowlevel, value);
|
||||||
|
} else {
|
||||||
|
char* v = malloc(strlen(value) + 1);
|
||||||
|
strcpy(v, value);
|
||||||
|
|
||||||
|
shput(handle->text, key, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,6 @@ void MilskoLLSleep(int ms) {
|
|||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
MILSKODECL void MilskoLLSetTitle(HMILSKOLL handle, const char* title) {
|
void MilskoLLSetTitle(HMILSKOLL handle, const char* title) {
|
||||||
XSetStandardProperties(handle->display, handle->window, title, "Milsko Widget Toolkit", None, (char**)NULL, 0, NULL);
|
XSetStandardProperties(handle->display, handle->window, title, "Milsko Widget Toolkit", None, (char**)NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user