mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-03 16:10:50 +00:00
bad solution
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@30 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -1,25 +1,27 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#ifndef __MILSKO_X11_H__
|
#ifndef __MILSKO_GDI_H__
|
||||||
#define __MILSKO_X11_H__
|
#define __MILSKO_GDI_H__
|
||||||
|
|
||||||
typedef struct _MilskoLowLevel* MilskoLL;
|
|
||||||
typedef struct _MilskoColor* MilskoLLColor;
|
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Milsko/MachDep.h>
|
||||||
|
|
||||||
|
typedef struct _MilskoLL * MilskoLL, MilskoLLRec;
|
||||||
|
typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
||||||
|
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Milsko/TypeDefs.h>
|
||||||
|
#include <Milsko/LowLevel.h>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
typedef struct _MilskoLowLevel {
|
struct _MilskoLL {
|
||||||
void* user;
|
void* user;
|
||||||
|
|
||||||
void (*draw)(MilskoLL handle);
|
void (*draw)(MilskoLL handle);
|
||||||
}* MilskoLL;
|
};
|
||||||
|
|
||||||
typedef struct _MilskoColor {
|
struct _MilskoColor {
|
||||||
int red;
|
int red;
|
||||||
int green;
|
int green;
|
||||||
int blue;
|
int blue;
|
||||||
}* MilskoLLColor;
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#ifndef __MILSKO_LL_H__
|
#ifndef __MILSKO_LOWLEVEL_H__
|
||||||
#define __MILSKO_LL_H__
|
#define __MILSKO_LOWLEVEL_H__
|
||||||
|
|
||||||
|
#include <Milsko/MachDep.h>
|
||||||
|
|
||||||
|
typedef struct _MilskoLLCallback *MilskoLLCallback, MilskoLLCallbackRec;
|
||||||
|
#ifdef _MILSKO
|
||||||
|
typedef struct _MilskoLL * MilskoLL, MilskoLLRec;
|
||||||
|
typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
||||||
|
#else
|
||||||
|
typedef void* MilskoLL;
|
||||||
|
typedef void* MilskoLLColor;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
@@ -9,14 +20,18 @@
|
|||||||
#ifdef USE_GDI
|
#ifdef USE_GDI
|
||||||
#include <Milsko/GDI.h>
|
#include <Milsko/GDI.h>
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
typedef void* MilskoLL;
|
|
||||||
typedef void* MilskoLLColor;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Milsko/TypeDefs.h>
|
||||||
|
|
||||||
|
#define MilskoLLDispatch(x, y) \
|
||||||
|
if(x->callback != NULL && x->callback->y != NULL) x->callback->y(x)
|
||||||
|
|
||||||
|
struct _MilskoLLCallback {
|
||||||
|
void (*draw)(MilskoLL handle);
|
||||||
|
void (*down)(MilskoLL handle);
|
||||||
|
void (*up)(MilskoLL handle);
|
||||||
|
};
|
||||||
|
|
||||||
MILSKODECL MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height);
|
MILSKODECL MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height);
|
||||||
MILSKODECL void MilskoLLDestroy(MilskoLL handle);
|
MILSKODECL void MilskoLLDestroy(MilskoLL handle);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,36 +4,49 @@
|
|||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Milsko/MachDep.h>
|
||||||
|
|
||||||
typedef struct _MilskoPoint {
|
typedef struct _MilskoClass * MilskoClass, MilskoClassRec;
|
||||||
|
typedef struct _MilskoPoint MilskoPoint;
|
||||||
|
typedef struct _MilskoRect MilskoRect;
|
||||||
|
typedef struct _MilskoTextKeyValue MilskoTextKeyValue;
|
||||||
|
typedef struct _MilskoIntegerKeyValue MilskoIntegerKeyValue;
|
||||||
|
#ifdef _MILSKO
|
||||||
|
typedef struct _Milsko *MilskoWidget, MilskoWidgetRec;
|
||||||
|
#else
|
||||||
|
typedef void* MilskoWidget;
|
||||||
|
#endif
|
||||||
|
typedef void (*MilskoHandler)(MilskoWidget handle);
|
||||||
|
|
||||||
|
#ifdef _MILSKO
|
||||||
|
#include <Milsko/LowLevel.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MilskoDispatch(x, y) \
|
||||||
|
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
||||||
|
|
||||||
|
struct _MilskoPoint {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
} MilskoPoint;
|
};
|
||||||
|
|
||||||
typedef struct _MilskoRect {
|
struct _MilskoRect {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
} MilskoRect;
|
};
|
||||||
|
|
||||||
typedef struct _MilskoTextKeyValue {
|
struct _MilskoTextKeyValue {
|
||||||
char* key;
|
char* key;
|
||||||
char* value;
|
char* value;
|
||||||
} MilskoTextKeyValue;
|
};
|
||||||
|
|
||||||
typedef struct _MilskoIntegerKeyValue {
|
struct _MilskoIntegerKeyValue {
|
||||||
char* key;
|
char* key;
|
||||||
int value;
|
int value;
|
||||||
} MilskoIntegerKeyValue;
|
};
|
||||||
|
|
||||||
typedef struct _MilskoClass* MilskoClass;
|
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
#include <Milsko/LowLevel.h>
|
struct _Milsko {
|
||||||
|
|
||||||
typedef struct _Milsko* MilskoWidget;
|
|
||||||
|
|
||||||
typedef struct _Milsko {
|
|
||||||
char* name;
|
char* name;
|
||||||
|
|
||||||
MilskoLL lowlevel;
|
MilskoLL lowlevel;
|
||||||
@@ -43,19 +56,15 @@ typedef struct _Milsko {
|
|||||||
|
|
||||||
MilskoTextKeyValue* text;
|
MilskoTextKeyValue* text;
|
||||||
MilskoIntegerKeyValue* integer;
|
MilskoIntegerKeyValue* integer;
|
||||||
}* MilskoWidget;
|
};
|
||||||
#else
|
|
||||||
typedef void* MilskoWidget;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void (*MilskoHandler)(MilskoWidget handle);
|
struct _MilskoClass {
|
||||||
|
|
||||||
typedef struct _MilskoClass {
|
|
||||||
void* opaque;
|
void* opaque;
|
||||||
MilskoHandler create;
|
MilskoHandler create;
|
||||||
MilskoHandler destroy;
|
MilskoHandler destroy;
|
||||||
MilskoHandler draw;
|
MilskoHandler draw;
|
||||||
MilskoHandler click;
|
MilskoHandler click;
|
||||||
} *MilskoClass, MilskoClassRec;
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
#ifndef __MILSKO_X11_H__
|
#ifndef __MILSKO_X11_H__
|
||||||
#define __MILSKO_X11_H__
|
#define __MILSKO_X11_H__
|
||||||
|
|
||||||
typedef struct _MilskoLowLevel* MilskoLL;
|
|
||||||
typedef struct _MilskoColor* MilskoLLColor;
|
|
||||||
|
|
||||||
#include <Milsko/MachDep.h>
|
#include <Milsko/MachDep.h>
|
||||||
|
|
||||||
|
typedef struct _MilskoLL * MilskoLL, MilskoLLRec;
|
||||||
|
typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
||||||
|
|
||||||
#include <Milsko/TypeDefs.h>
|
#include <Milsko/TypeDefs.h>
|
||||||
|
#include <Milsko/LowLevel.h>
|
||||||
|
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
typedef struct _MilskoLowLevel {
|
struct _MilskoLL {
|
||||||
Display* display;
|
Display* display;
|
||||||
Window window;
|
Window window;
|
||||||
GC gc;
|
GC gc;
|
||||||
@@ -22,14 +24,14 @@ typedef struct _MilskoLowLevel {
|
|||||||
unsigned int height;
|
unsigned int height;
|
||||||
void* user;
|
void* user;
|
||||||
|
|
||||||
void (*draw)(MilskoLL handle);
|
MilskoLLCallback callback;
|
||||||
}* MilskoLL;
|
};
|
||||||
|
|
||||||
typedef struct _MilskoColor {
|
struct _MilskoLLColor {
|
||||||
unsigned long pixel;
|
unsigned long pixel;
|
||||||
int red;
|
int red;
|
||||||
int green;
|
int green;
|
||||||
int blue;
|
int blue;
|
||||||
}* MilskoLLColor;
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
13
src/core.c
13
src/core.c
@@ -3,12 +3,9 @@
|
|||||||
|
|
||||||
#include "stb_ds.h"
|
#include "stb_ds.h"
|
||||||
|
|
||||||
#define Dispatch(x, y) \
|
|
||||||
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
|
||||||
|
|
||||||
static void llhandler(MilskoLL handle) {
|
static void llhandler(MilskoLL handle) {
|
||||||
MilskoWidget h = (MilskoWidget)handle->user;
|
MilskoWidget h = (MilskoWidget)handle->user;
|
||||||
Dispatch(h, draw);
|
MilskoDispatch(h, draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
@@ -22,8 +19,8 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
|||||||
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
|
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
|
||||||
h->class = class;
|
h->class = class;
|
||||||
|
|
||||||
h->lowlevel->user = h;
|
h->lowlevel->user = h;
|
||||||
h->lowlevel->draw = llhandler;
|
h->lowlevel->callback->draw = llhandler;
|
||||||
|
|
||||||
if(parent != NULL) arrput(parent->children, h);
|
if(parent != NULL) arrput(parent->children, h);
|
||||||
|
|
||||||
@@ -33,7 +30,7 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
|||||||
shdefault(h->text, NULL);
|
shdefault(h->text, NULL);
|
||||||
shdefault(h->integer, -1);
|
shdefault(h->integer, -1);
|
||||||
|
|
||||||
Dispatch(h, create);
|
MilskoDispatch(h, create);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
@@ -41,7 +38,7 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
|||||||
void MilskoDestroyWidget(MilskoWidget handle) {
|
void MilskoDestroyWidget(MilskoWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Dispatch(handle, destroy);
|
MilskoDispatch(handle, destroy);
|
||||||
|
|
||||||
free(handle->name);
|
free(handle->name);
|
||||||
|
|
||||||
|
|||||||
15
src/x11.c
15
src/x11.c
@@ -9,11 +9,14 @@ MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) {
|
|||||||
Window root;
|
Window root;
|
||||||
unsigned int border, depth;
|
unsigned int border, depth;
|
||||||
|
|
||||||
r = malloc(sizeof(*r));
|
r = malloc(sizeof(*r));
|
||||||
r->x = x;
|
r->x = x;
|
||||||
r->y = y;
|
r->y = y;
|
||||||
r->width = width;
|
r->width = width;
|
||||||
r->height = height;
|
r->height = height;
|
||||||
|
r->callback = malloc(sizeof(*r->callback));
|
||||||
|
|
||||||
|
memset(r->callback, 0, sizeof(*r->callback));
|
||||||
|
|
||||||
if(parent == NULL) {
|
if(parent == NULL) {
|
||||||
r->display = XOpenDisplay(NULL);
|
r->display = XOpenDisplay(NULL);
|
||||||
@@ -114,7 +117,7 @@ void MilskoLLNextEvent(MilskoLL handle) {
|
|||||||
XEvent ev;
|
XEvent ev;
|
||||||
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
||||||
if(ev.type == Expose) {
|
if(ev.type == Expose) {
|
||||||
if(handle->draw != NULL) handle->draw(handle);
|
MilskoLLDispatch(handle, draw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user