From 8c788c3911b59915f43e17e92627ba00049e6eaa Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sun, 28 Sep 2025 07:03:05 +0000 Subject: [PATCH] stuff git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@9 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Milsko/Core.h | 13 +++++++++++-- include/Milsko/LowLevel.h | 15 ++++++++------- include/Milsko/MachDep.h | 8 ++++++++ include/Milsko/TypeDef.h | 2 ++ include/Milsko/X11.h | 2 ++ src/core.c | 33 ++++++++++++++++++++++++++++++++- 6 files changed, 63 insertions(+), 10 deletions(-) diff --git a/include/Milsko/Core.h b/include/Milsko/Core.h index b915485..f08727f 100644 --- a/include/Milsko/Core.h +++ b/include/Milsko/Core.h @@ -2,17 +2,26 @@ #ifndef __MILSKO_CORE_H__ #define __MILSKO_CORE_H__ +#include + #ifdef _MILSKO #include +typedef struct _Milsko* HMILSKO; + typedef struct _Milsko { HMILSKOLL lowlevel; + HMILSKO parent; + HMILSKO* children; }* HMILSKO; #else typedef void* HMILSKO; #endif -HMILSKO MilskoCreateWidget(HMILSKO parent, int x, int y, unsigned int width, unsigned int height); -void MilskoDestroyWidget(HMILSKO handle); +typedef struct _MilskoClass { +}* MilskoClass; + +MILSKODECL HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsigned int width, unsigned int height); +MILSKODECL void MilskoDestroyWidget(HMILSKO handle); #endif diff --git a/include/Milsko/LowLevel.h b/include/Milsko/LowLevel.h index 7ee0add..e7d4e3e 100644 --- a/include/Milsko/LowLevel.h +++ b/include/Milsko/LowLevel.h @@ -2,6 +2,7 @@ #ifndef __MILSKO_LL_H__ #define __MILSKO_LL_H__ +#include #include #ifdef _MILSKO @@ -16,12 +17,12 @@ typedef void* HMILSKOLL; typedef void* HMILSKOCOLOR; #endif -HMILSKOLL MilskoLLCreate(HMILSKOLL parent, int x, int y, int width, int height); -void MilskoLLDestroy(HMILSKOLL handle); -void MilskoLLPolygon(HMILSKOLL handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color); -HMILSKOCOLOR MilskoLLAllocColor(HMILSKOLL handle, int r, int g, int b); -void MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h); -int MilskoLLPending(HMILSKOLL handle); -void MilskoLLNextEvent(HMILSKOLL handle); +MILSKODECL HMILSKOLL MilskoLLCreate(HMILSKOLL parent, int x, int y, int width, int height); +MILSKODECL void MilskoLLDestroy(HMILSKOLL handle); +MILSKODECL void MilskoLLPolygon(HMILSKOLL handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color); +MILSKODECL HMILSKOCOLOR MilskoLLAllocColor(HMILSKOLL handle, int r, int g, int b); +MILSKODECL void MilskoLLGetXYWH(HMILSKOLL handle, int* x, int* y, unsigned int* w, unsigned int* h); +MILSKODECL int MilskoLLPending(HMILSKOLL handle); +MILSKODECL void MilskoLLNextEvent(HMILSKOLL handle); #endif diff --git a/include/Milsko/MachDep.h b/include/Milsko/MachDep.h index b842d9c..8d4419e 100644 --- a/include/Milsko/MachDep.h +++ b/include/Milsko/MachDep.h @@ -6,4 +6,12 @@ #include #include +#if defined(_MILSKO) && defined(_WIN32) +#define MILSKODECL extern __declsped(dllexport) +#elif defined(_WIN32) +#define MILSKODECL extern __declsped(dllimport) +#else +#define MILSKODECL extern +#endif + #endif diff --git a/include/Milsko/TypeDef.h b/include/Milsko/TypeDef.h index 1f98f6f..8c56255 100644 --- a/include/Milsko/TypeDef.h +++ b/include/Milsko/TypeDef.h @@ -2,6 +2,8 @@ #ifndef __MILSKO_TYPEDEF_H__ #define __MILSKO_TYPEDEF_H__ +#include + typedef struct _MilskoPoint { int x; int y; diff --git a/include/Milsko/X11.h b/include/Milsko/X11.h index e46b363..560e840 100644 --- a/include/Milsko/X11.h +++ b/include/Milsko/X11.h @@ -2,6 +2,8 @@ #ifndef __MILSKO_X11_H__ #define __MILSKO_X11_H__ +#include + #include #include diff --git a/src/core.c b/src/core.c index 3d74cef..03bd07c 100644 --- a/src/core.c +++ b/src/core.c @@ -1,10 +1,41 @@ /* $Id$ */ #include -HMILSKO MilskoCreateWidget(HMILSKO parent, int x, int y, unsigned int width, unsigned int height) { +#include "stb_ds.h" + +HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsigned int width, unsigned int height) { HMILSKO h = malloc(sizeof(*h)); + + h->parent = parent; + h->children = NULL; + h->lowlevel = MilskoLLCreate(parent->lowlevel, x, y, width, height); + + arrput(parent->children, h); + + return h; } void MilskoDestroyWidget(HMILSKO handle) { + 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); free(handle); }