diff --git a/GNUmakefile b/GNUmakefile index 13d4f98..d9cd319 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -20,6 +20,7 @@ $(error Add your platform definition) endif ifeq ($(UNIX),1) +CFLAGS += -DUSE_X11 LIB = lib SO = .so L_OBJS += src/x11.o diff --git a/include/Milsko/LowLevel.h b/include/Milsko/LowLevel.h new file mode 100644 index 0000000..26a2bad --- /dev/null +++ b/include/Milsko/LowLevel.h @@ -0,0 +1,27 @@ +/* $Id$ */ +#ifndef __MILSKO_PLATFORM_H__ +#define __MILSKO_PLATFORM_H__ + +#include +#include +#include + +#include + +#ifdef _MILSKO +#ifdef USE_X11 +#include +#endif +#ifdef USE_GDI +#include +#endif +#else +typedef void* HMILSKO; +typedef void* HMILSKOCOLOR; +#endif + +HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height); +void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color); +HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b); + +#endif diff --git a/include/Milsko/Milsko.h b/include/Milsko/Milsko.h index 46760c0..4d9a1f2 100644 --- a/include/Milsko/Milsko.h +++ b/include/Milsko/Milsko.h @@ -2,5 +2,6 @@ #ifndef __MILSKO_MILSKO_H__ #define __MILSKO_MILSKO_H__ +#include #endif diff --git a/include/Milsko/TypeDef.h b/include/Milsko/TypeDef.h new file mode 100644 index 0000000..1f98f6f --- /dev/null +++ b/include/Milsko/TypeDef.h @@ -0,0 +1,10 @@ +/* $Id$ */ +#ifndef __MILSKO_TYPEDEF_H__ +#define __MILSKO_TYPEDEF_H__ + +typedef struct _MilskoPoint { + int x; + int y; +} MilskoPoint; + +#endif diff --git a/include/Milsko/X11.h b/include/Milsko/X11.h new file mode 100644 index 0000000..090b519 --- /dev/null +++ b/include/Milsko/X11.h @@ -0,0 +1,19 @@ +/* $Id$ */ +#ifndef __MILSKO_X11_H__ +#define __MILSKO_X11_H__ + +#include +#include + +typedef struct __Milsko { + Display* display; + Window window; + GC gc; + Colormap colormap; +}* HMILSKO; + +typedef struct __MilskoColor { + unsigned long pixel; +}* HMILSKOCOLOR; + +#endif diff --git a/src/x11.c b/src/x11.c index 102ce9f..db72522 100644 --- a/src/x11.c +++ b/src/x11.c @@ -1,3 +1,42 @@ /* $Id$ */ #include +HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height){ + HMILSKO r; + Window p; + + r = malloc(sizeof(*r)); + if(parent == NULL){ + r->display = XOpenDisplay(NULL); + p = XRootWindow(r->display, XDefaultScreen(r->display)); + }else{ + r->display = parent->display; + p = parent->window; + } + r->window = XCreateSimpleWindow(r->display, p, x, y, width, height, 0, 0, WhitePixel(r->display, XDefaultScreen(r->display))); + r->colormap = DefaultColormap(r->display, XDefaultScreen(r->display)); + r->gc = XCreateGC(r->display, r->window, 0, 0); + + XMapWindow(r->display, r->window); + + return r; +} + +void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color){ +} + +HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b){ + HMILSKOCOLOR c = malloc(sizeof(*c)); + XColor xc; + xc.red = 256 * r; + xc.green = 256 * g; + xc.blue = 256 * b; + XAllocColor(handle->display, handle->colormap, &xc); + + c->pixel = xc.pixel; + return c; +} + +void MilskoLLFreeColor(HMILSKOCOLOR color){ + free(color); +}