diff --git a/GNUmakefile b/GNUmakefile index 01ec37b..ed3afe2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -35,7 +35,7 @@ E_LIBS = $(LIBS) -lMw L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o L_OBJS += src/external/ds.o src/external/image.o L_OBJS += src/widget/window.o src/widget/button.o src/widget/frame.o src/widget/menu.o src/widget/submenu.o src/widget/image.o src/widget/scrollbar.o -L_OBJS += src/cursor/default.o +L_OBJS += src/cursor/default.o src/cursor/cross.o ifeq ($(TARGET),NetBSD) CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include diff --git a/include/Mw/Cursor.h b/include/Mw/Cursor.h index c7f9777..9cbe6fa 100644 --- a/include/Mw/Cursor.h +++ b/include/Mw/Cursor.h @@ -24,6 +24,16 @@ MWDECL MwCursor MwCursorDefault; */ MWDECL MwCursor MwCursorDefaultMask; +/*! + * %brief Cross cursor + */ +MWDECL MwCursor MwCursorCross; + +/*! + * %brief Cross cursor mask + */ +MWDECL MwCursor MwCursorCrossMask; + #ifdef __cplusplus } #endif diff --git a/src/backend/gdi.c b/src/backend/gdi.c index 3363d9a..a7ee6ee 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -324,7 +324,11 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { HCURSOR cursor; BYTE* dmask = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight); BYTE* dimage = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight); - int y, x; + int y, x, ys, xs; + + xs = -mask->x + image->x; + ys = MwCursorDataHeight + mask->y; + ys = MwCursorDataHeight + image->y - ys; memset(dmask, 0xff, (MwCursorDataHeight / 8) * MwCursorDataHeight); memset(dimage, 0, (MwCursorDataHeight / 8) * MwCursorDataHeight); @@ -343,19 +347,19 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { } for(y = 0; y < image->height; y++) { - BYTE* l = &dimage[(y + (MwCursorDataHeight + mask->y)) * (MwCursorDataHeight / 8)]; + BYTE* l = &dimage[(y + ys) * (MwCursorDataHeight / 8)]; unsigned int n = image->data[y]; for(x = image->width - 1; x >= 0; x--) { if(n & 1) { - l[(x - mask->x) / 8] |= (1 << (7 - ((x - mask->x) % 8))); + l[(x + xs) / 8] |= (1 << (7 - ((x + xs) % 8))); } n = n >> 1; } } - cursor = CreateCursor(GetModuleHandle(NULL), -mask->x, MwCursorDataHeight + mask->y, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage); + cursor = CreateCursor(GetModuleHandle(NULL), xs, ys, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage); SetClassLongPtr(handle->hWnd, GCLP_HCURSOR, (LONG_PTR)cursor); SetCursor(cursor); diff --git a/src/backend/x11.c b/src/backend/x11.c index 0c2d782..1007e75 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -338,10 +338,14 @@ void MwLLForceRender(MwLL handle) { void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { XcursorImage* img = XcursorImageCreate(MwCursorDataHeight, MwCursorDataHeight); Cursor cur; - int y, x; + int y, x, ys, xs; - img->xhot = -mask->x; - img->yhot = MwCursorDataHeight + mask->y; + xs = -mask->x + image->x; + ys = MwCursorDataHeight + mask->y; + ys = MwCursorDataHeight + image->y - ys; + + img->xhot = xs; + img->yhot = ys; memset(img->pixels, 0, MwCursorDataHeight * MwCursorDataHeight * sizeof(XcursorPixel)); for(y = 0; y < mask->height; y++) { @@ -358,7 +362,7 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { for(x = image->width - 1; x >= 0; x--) { int px = 0; if(l & 1) px = 255; - img->pixels[(img->yhot + y) * MwCursorDataHeight + (img->xhot + x)] |= (px << 16) | (px << 8) | (px); + img->pixels[(ys + y) * MwCursorDataHeight + (xs + x)] |= (px << 16) | (px << 8) | (px); l = l >> 1; } diff --git a/src/cursor/cross.c b/src/cursor/cross.c new file mode 100644 index 0000000..1daa231 --- /dev/null +++ b/src/cursor/cross.c @@ -0,0 +1,44 @@ +/* $Id$ */ +#include + +/** + * Created by bitmaptobdf + * + * Copyright notice: + * These ""glyphs"" are unencumbered + */ +MwCursor MwCursorCross = { + 14, 14, -6, -8, {14343, /* ###........### */ + 15375, /* ####......#### */ + 15903, /* #####....##### */ + 7998, /* .#####..#####. */ + 4092, /* ..##########.. */ + 2040, /* ...########... */ + 1008, /* ....######.... */ + 1008, /* ....######.... */ + 2040, /* ...########... */ + 4092, /* ..##########.. */ + 7998, /* .#####..#####. */ + 15903, /* #####....##### */ + 15375, /* ####......#### */ + 14343, /* ###........### */ + 0, 0}}; +MwCursor MwCursorCrossMask = { + 16, 16, -7, -9, { + 61455, /* ####........#### */ + 63519, /* #####......##### */ + 64575, /* ######....###### */ + 65151, /* #######..####### */ + 32766, /* .##############. */ + 16380, /* ..############.. */ + 8184, /* ...##########... */ + 4080, /* ....########.... */ + 4080, /* ....########.... */ + 8184, /* ...##########... */ + 16380, /* ..############.. */ + 32766, /* .##############. */ + 65151, /* #######..####### */ + 64575, /* ######....###### */ + 63519, /* #####......##### */ + 61455 /* ####........#### */ + }};