mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-08 02:13:29 +00:00
stuff
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@3 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -20,6 +20,7 @@ $(error Add your platform definition)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(UNIX),1)
|
ifeq ($(UNIX),1)
|
||||||
|
CFLAGS += -DUSE_X11
|
||||||
LIB = lib
|
LIB = lib
|
||||||
SO = .so
|
SO = .so
|
||||||
L_OBJS += src/x11.o
|
L_OBJS += src/x11.o
|
||||||
|
|||||||
27
include/Milsko/LowLevel.h
Normal file
27
include/Milsko/LowLevel.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
#ifndef __MILSKO_PLATFORM_H__
|
||||||
|
#define __MILSKO_PLATFORM_H__
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Milsko/TypeDef.h>
|
||||||
|
|
||||||
|
#ifdef _MILSKO
|
||||||
|
#ifdef USE_X11
|
||||||
|
#include <Milsko/X11.h>
|
||||||
|
#endif
|
||||||
|
#ifdef USE_GDI
|
||||||
|
#include <Milsko/GDI.h>
|
||||||
|
#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
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
#ifndef __MILSKO_MILSKO_H__
|
#ifndef __MILSKO_MILSKO_H__
|
||||||
#define __MILSKO_MILSKO_H__
|
#define __MILSKO_MILSKO_H__
|
||||||
|
|
||||||
|
#include <Milsko/LowLevel.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
include/Milsko/TypeDef.h
Normal file
10
include/Milsko/TypeDef.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
#ifndef __MILSKO_TYPEDEF_H__
|
||||||
|
#define __MILSKO_TYPEDEF_H__
|
||||||
|
|
||||||
|
typedef struct _MilskoPoint {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
} MilskoPoint;
|
||||||
|
|
||||||
|
#endif
|
||||||
19
include/Milsko/X11.h
Normal file
19
include/Milsko/X11.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
#ifndef __MILSKO_X11_H__
|
||||||
|
#define __MILSKO_X11_H__
|
||||||
|
|
||||||
|
#include <X11/X.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
typedef struct __Milsko {
|
||||||
|
Display* display;
|
||||||
|
Window window;
|
||||||
|
GC gc;
|
||||||
|
Colormap colormap;
|
||||||
|
}* HMILSKO;
|
||||||
|
|
||||||
|
typedef struct __MilskoColor {
|
||||||
|
unsigned long pixel;
|
||||||
|
}* HMILSKOCOLOR;
|
||||||
|
|
||||||
|
#endif
|
||||||
39
src/x11.c
39
src/x11.c
@@ -1,3 +1,42 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Milsko/Milsko.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user