diff --git a/GNUmakefile b/GNUmakefile index 4d5839a..e1adbeb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -40,13 +40,25 @@ ifeq ($(TARGET),NetBSD) CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include LDFLAGS += -L/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/X11R7/lib -Wl,-R/usr/pkg/lib UNIX = 1 + +OPENGL = 1 else ifeq ($(TARGET),Linux) L_LIBS += -ldl UNIX = 1 + +OPENGL = 1 VULKAN = 1 else ifeq ($(TARGET),Windows) WINDOWS = 1 + +OPENGL = 1 VULKAN = 1 +else ifeq ($(TARGET),UnixWare) +CC = gcc +UNIX = 1 +L_LIBS += -lsocket -lnsl + +NO_XRENDER = 1 else $(error Add your platform definition) endif @@ -54,7 +66,13 @@ endif ifeq ($(UNIX),1) L_CFLAGS += -DUSE_X11 L_OBJS += src/backend/x11.o -L_LIBS += -lX11 -lXrender -lXext +L_LIBS += -lX11 +ifeq ($(NO_XRENDER),1) +L_CFLAGS += -DNO_XRENDER +else +L_LIBS += -lXrender +endif +L_LIBS += -lXext GL = -lGL @@ -62,8 +80,6 @@ E_LIBS += -lm SO = .so EXEC = - -OPENGL = 1 else ifeq ($(WINDOWS),1) L_CFLAGS += -DUSE_GDI L_LDFLAGS += -Wl,--out-implib,src/libMw.lib -static-libgcc @@ -74,8 +90,6 @@ GL = -lopengl32 SO = .dll EXEC = .exe - -OPENGL = 1 endif EXAMPLES = examples/example$(EXEC) examples/rotate$(EXEC) examples/image$(EXEC) diff --git a/include/Mw/Image.h b/include/Mw/Image.h new file mode 100644 index 0000000..87e7a81 --- /dev/null +++ b/include/Mw/Image.h @@ -0,0 +1,25 @@ +/* $Id$ */ +/*! + * %file Mw/Image.h + * %brief Image widget + */ +#ifndef __MW_IMAGE_H__ +#define __MW_IMAGE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * %brief Image widget class + */ +MWDECL MwClass MwImageClass; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/Mw/X11.h b/include/Mw/X11.h index 28e245e..2993cbc 100644 --- a/include/Mw/X11.h +++ b/include/Mw/X11.h @@ -11,10 +11,12 @@ #include #include -#include +#include #include #include +#ifndef NO_XRENDER #include +#endif struct _MwLL { Display* display; diff --git a/src/backend/x11.c b/src/backend/x11.c index bc983e1..9f734bc 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -206,7 +206,9 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei MwLLPixmap r = malloc(sizeof(*r)); char* d = malloc(4 * width * height); int y, x; - int evbase, erbase; +#ifndef NO_XRENDER + int evbase, erbase; +#endif r->width = width; r->height = height; @@ -214,11 +216,13 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei r->use_shm = XShmQueryExtension(handle->display) ? 1 : 0; r->data = malloc(width * height * 4); +#ifndef NO_XRENDER if(!XRenderQueryExtension(handle->display, &evbase, &erbase)) { fprintf(stderr, "XRender missing - cannot proceed pixmap creation\n"); r->image = NULL; return r; } +#endif if(r->use_shm) { r->image = XShmCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 24, ZPixmap, NULL, &r->shm, width, height); @@ -269,6 +273,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) { } void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { +#ifndef NO_XRENDER if(pixmap->image != NULL) { Pixmap px = XCreatePixmap(handle->display, handle->window, pixmap->width, pixmap->height, 24); XRenderPictFormat* format = XRenderFindStandardFormat(handle->display, PictStandardRGB24); @@ -309,6 +314,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { XFreePixmap(handle->display, px); } +#endif } void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) { diff --git a/src/widget/image.c b/src/widget/image.c new file mode 100644 index 0000000..0aa0df1 --- /dev/null +++ b/src/widget/image.c @@ -0,0 +1,28 @@ +/* $Id$ */ +#include + +static void create(MwWidget handle) { + MwSetDefault(handle); +} + +static void draw(MwWidget handle) { + MwRect r; + MwLLPixmap px = MwGetVoid(handle, MwNpixmap); + + r.x = 0; + r.y = 0; + r.width = MwGetInteger(handle, MwNwidth); + r.height = MwGetInteger(handle, MwNheight); + if(px != NULL) { + MwLLDrawPixmap(handle->lowlevel, &r, px); + } +} + +MwClassRec MwImageClassRec = { + create, /* create */ + NULL, /* destroy */ + draw, /* draw */ + NULL, /* click */ + NULL /* parent_resize */ +}; +MwClass MwImageClass = &MwImageClassRec;