mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-02 23:50:50 +00:00
things
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@146 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
24
GNUmakefile
24
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)
|
||||
|
||||
25
include/Mw/Image.h
Normal file
25
include/Mw/Image.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/Image.h
|
||||
* %brief Image widget
|
||||
*/
|
||||
#ifndef __MW_IMAGE_H__
|
||||
#define __MW_IMAGE_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* %brief Image widget class
|
||||
*/
|
||||
MWDECL MwClass MwImageClass;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -11,10 +11,12 @@
|
||||
#include <Mw/TypeDefs.h>
|
||||
#include <Mw/LowLevel.h>
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#ifndef NO_XRENDER
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
|
||||
struct _MwLL {
|
||||
Display* display;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
28
src/widget/image.c
Normal file
28
src/widget/image.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
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;
|
||||
Reference in New Issue
Block a user