mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-22 09:04:08 +00:00
cursor
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@180 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -319,3 +319,49 @@ void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
|
||||
void MwLLForceRender(MwLL handle) {
|
||||
InvalidateRect(handle->hWnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
memset(dmask, 0xff, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
||||
memset(dimage, 0, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
||||
|
||||
for(y = 0; y < mask->height; y++) {
|
||||
BYTE* l = &dmask[y * (MwCursorDataHeight / 8)];
|
||||
unsigned int n = mask->data[y];
|
||||
for(x = mask->width - 1; x >= 0; x--) {
|
||||
l[x / 8] = l[x / 8] >> 1;
|
||||
if(!(n & 1)) {
|
||||
l[x / 8] |= 1 << 7;
|
||||
}
|
||||
|
||||
n = n >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(y = 0; y < image->height; y++) {
|
||||
BYTE* l = &dimage[(y + (MwCursorDataHeight + mask->y)) * (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)));
|
||||
}
|
||||
|
||||
n = n >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
cursor = CreateCursor(GetModuleHandle(NULL), -mask->x, MwCursorDataHeight + mask->y, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
||||
|
||||
SetClassLongPtr(handle->hWnd, GCLP_HCURSOR, (LONG_PTR)cursor);
|
||||
SetCursor(cursor);
|
||||
|
||||
DestroyCursor(cursor);
|
||||
|
||||
free(dimage);
|
||||
free(dmask);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user