mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 09:00:54 +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
|
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
|
LDFLAGS += -L/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/X11R7/lib -Wl,-R/usr/pkg/lib
|
||||||
UNIX = 1
|
UNIX = 1
|
||||||
|
|
||||||
|
OPENGL = 1
|
||||||
else ifeq ($(TARGET),Linux)
|
else ifeq ($(TARGET),Linux)
|
||||||
L_LIBS += -ldl
|
L_LIBS += -ldl
|
||||||
UNIX = 1
|
UNIX = 1
|
||||||
|
|
||||||
|
OPENGL = 1
|
||||||
VULKAN = 1
|
VULKAN = 1
|
||||||
else ifeq ($(TARGET),Windows)
|
else ifeq ($(TARGET),Windows)
|
||||||
WINDOWS = 1
|
WINDOWS = 1
|
||||||
|
|
||||||
|
OPENGL = 1
|
||||||
VULKAN = 1
|
VULKAN = 1
|
||||||
|
else ifeq ($(TARGET),UnixWare)
|
||||||
|
CC = gcc
|
||||||
|
UNIX = 1
|
||||||
|
L_LIBS += -lsocket -lnsl
|
||||||
|
|
||||||
|
NO_XRENDER = 1
|
||||||
else
|
else
|
||||||
$(error Add your platform definition)
|
$(error Add your platform definition)
|
||||||
endif
|
endif
|
||||||
@@ -54,7 +66,13 @@ endif
|
|||||||
ifeq ($(UNIX),1)
|
ifeq ($(UNIX),1)
|
||||||
L_CFLAGS += -DUSE_X11
|
L_CFLAGS += -DUSE_X11
|
||||||
L_OBJS += src/backend/x11.o
|
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
|
GL = -lGL
|
||||||
|
|
||||||
@@ -62,8 +80,6 @@ E_LIBS += -lm
|
|||||||
|
|
||||||
SO = .so
|
SO = .so
|
||||||
EXEC =
|
EXEC =
|
||||||
|
|
||||||
OPENGL = 1
|
|
||||||
else ifeq ($(WINDOWS),1)
|
else ifeq ($(WINDOWS),1)
|
||||||
L_CFLAGS += -DUSE_GDI
|
L_CFLAGS += -DUSE_GDI
|
||||||
L_LDFLAGS += -Wl,--out-implib,src/libMw.lib -static-libgcc
|
L_LDFLAGS += -Wl,--out-implib,src/libMw.lib -static-libgcc
|
||||||
@@ -74,8 +90,6 @@ GL = -lopengl32
|
|||||||
|
|
||||||
SO = .dll
|
SO = .dll
|
||||||
EXEC = .exe
|
EXEC = .exe
|
||||||
|
|
||||||
OPENGL = 1
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
EXAMPLES = examples/example$(EXEC) examples/rotate$(EXEC) examples/image$(EXEC)
|
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/TypeDefs.h>
|
||||||
#include <Mw/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
|
|
||||||
#include <X11/X.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/extensions/XShm.h>
|
#include <X11/extensions/XShm.h>
|
||||||
|
#ifndef NO_XRENDER
|
||||||
#include <X11/extensions/Xrender.h>
|
#include <X11/extensions/Xrender.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct _MwLL {
|
struct _MwLL {
|
||||||
Display* display;
|
Display* display;
|
||||||
|
|||||||
@@ -206,7 +206,9 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei
|
|||||||
MwLLPixmap r = malloc(sizeof(*r));
|
MwLLPixmap r = malloc(sizeof(*r));
|
||||||
char* d = malloc(4 * width * height);
|
char* d = malloc(4 * width * height);
|
||||||
int y, x;
|
int y, x;
|
||||||
|
#ifndef NO_XRENDER
|
||||||
int evbase, erbase;
|
int evbase, erbase;
|
||||||
|
#endif
|
||||||
|
|
||||||
r->width = width;
|
r->width = width;
|
||||||
r->height = height;
|
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->use_shm = XShmQueryExtension(handle->display) ? 1 : 0;
|
||||||
r->data = malloc(width * height * 4);
|
r->data = malloc(width * height * 4);
|
||||||
|
|
||||||
|
#ifndef NO_XRENDER
|
||||||
if(!XRenderQueryExtension(handle->display, &evbase, &erbase)) {
|
if(!XRenderQueryExtension(handle->display, &evbase, &erbase)) {
|
||||||
fprintf(stderr, "XRender missing - cannot proceed pixmap creation\n");
|
fprintf(stderr, "XRender missing - cannot proceed pixmap creation\n");
|
||||||
r->image = NULL;
|
r->image = NULL;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(r->use_shm) {
|
if(r->use_shm) {
|
||||||
r->image = XShmCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 24, ZPixmap, NULL, &r->shm, width, height);
|
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) {
|
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
||||||
|
#ifndef NO_XRENDER
|
||||||
if(pixmap->image != NULL) {
|
if(pixmap->image != NULL) {
|
||||||
Pixmap px = XCreatePixmap(handle->display, handle->window, pixmap->width, pixmap->height, 24);
|
Pixmap px = XCreatePixmap(handle->display, handle->window, pixmap->width, pixmap->height, 24);
|
||||||
XRenderPictFormat* format = XRenderFindStandardFormat(handle->display, PictStandardRGB24);
|
XRenderPictFormat* format = XRenderFindStandardFormat(handle->display, PictStandardRGB24);
|
||||||
@@ -309,6 +314,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
|||||||
|
|
||||||
XFreePixmap(handle->display, px);
|
XFreePixmap(handle->display, px);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
|
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