basic stuff

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@11 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-28 08:37:12 +00:00
parent b12c08d2d3
commit 31e9818e42
9 changed files with 66 additions and 25 deletions

View File

@@ -8,6 +8,7 @@ LDFLAGS =
LIBS =
L_OBJS = src/ds.o src/core.o
L_OBJS += src/window.o
ifeq ($(TARGET),NetBSD)
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include

View File

@@ -3,28 +3,12 @@
#define __MILSKO_CORE_H__
#include <Milsko/MachDep.h>
typedef struct _MilskoClass* MilskoClass;
#ifdef _MILSKO
#include <Milsko/LowLevel.h>
typedef struct _Milsko* HMILSKO;
typedef struct _Milsko {
HMILSKOLL lowlevel;
HMILSKO parent;
HMILSKO* children;
MilskoClass class;
}* HMILSKO;
#else
typedef void* HMILSKO;
#endif
typedef struct _MilskoClass {
}* MilskoClass;
#include <Milsko/TypeDef.h>
MILSKODECL HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsigned int width, unsigned int height);
MILSKODECL void MilskoDestroyWidget(HMILSKO handle);
MILSKODECL void MilskoLoop(HMILSKO handle);
MILSKODECL void MilskoStep(HMILSKO handle);
MILSKODECL int MilskoPending(HMILSKO handle);
#endif

View File

@@ -2,9 +2,6 @@
#ifndef __MILSKO_LL_H__
#define __MILSKO_LL_H__
#include <Milsko/MachDep.h>
#include <Milsko/TypeDef.h>
#ifdef _MILSKO
#ifdef USE_X11
#include <Milsko/X11.h>
@@ -17,6 +14,9 @@ typedef void* HMILSKOLL;
typedef void* HMILSKOCOLOR;
#endif
#include <Milsko/MachDep.h>
#include <Milsko/TypeDef.h>
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);
@@ -24,5 +24,6 @@ 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);
MILSKODECL void MilskoLLSleep(int ms);
#endif

View File

@@ -5,6 +5,10 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#else
#include <unistd.h>
#endif
#if defined(_MILSKO) && defined(_WIN32)
#define MILSKODECL extern __declsped(dllexport)

View File

@@ -6,4 +6,6 @@
#include <Milsko/LowLevel.h>
#include <Milsko/Core.h>
#include <Milsko/Window.h>
#endif

View File

@@ -9,4 +9,24 @@ typedef struct _MilskoPoint {
int y;
} MilskoPoint;
typedef struct _MilskoClass* MilskoClass;
#ifdef _MILSKO
#include <Milsko/LowLevel.h>
typedef struct _Milsko* HMILSKO;
typedef struct _Milsko {
HMILSKOLL lowlevel;
HMILSKO parent;
HMILSKO* children;
MilskoClass class;
}* HMILSKO;
#else
typedef void* HMILSKO;
#endif
typedef struct _MilskoClass {
}* MilskoClass, MilskoClassRec;
#endif

View File

@@ -8,10 +8,10 @@ HMILSKO MilskoCreateWidget(MilskoClass class, HMILSKO parent, int x, int y, unsi
h->parent = parent;
h->children = NULL;
h->lowlevel = MilskoLLCreate(parent->lowlevel, x, y, width, height);
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
h->class = class;
arrput(parent->children, h);
if(parent != NULL) arrput(parent->children, h);
return h;
}
@@ -40,3 +40,22 @@ void MilskoDestroyWidget(HMILSKO handle) {
MilskoLLDestroy(handle->lowlevel);
free(handle);
}
MILSKODECL void MilskoStep(HMILSKO handle){
MilskoLLNextEvent(handle->lowlevel);
}
MILSKODECL int MilskoPending(HMILSKO handle){
int i;
for(i = 0; i < arrlen(handle->children); i++){
if(MilskoPending(handle->children[i])) return 1;
}
return MilskoLLPending(handle->lowlevel);
}
MILSKODECL void MilskoLoop(HMILSKO handle){
while(1){
MilskoStep(handle);
MilskoLLSleep(10);
}
}

6
src/window.c Normal file
View File

@@ -0,0 +1,6 @@
/* $Id$ */
#include <Milsko/Milsko.h>
MilskoClassRec MilskoWindowClassRec = {
};
MilskoClass MilskoWindowClass = &MilskoWindowClassRec;

View File

@@ -88,3 +88,7 @@ void MilskoLLNextEvent(HMILSKOLL handle) {
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
}
}
void MilskoLLSleep(int ms){
usleep(ms * 1000);
}