user32: Move a number of 16-bit cursor/icon functions to user16.c.
This commit is contained in:
parent
671b4d129d
commit
3806f9aee9
|
@ -1426,30 +1426,6 @@ HCURSOR WINAPI CreateCursor( HINSTANCE hInstance,
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CreateIcon (USER.407)
|
||||
*/
|
||||
HICON16 WINAPI CreateIcon16( HINSTANCE16 hInstance, INT16 nWidth,
|
||||
INT16 nHeight, BYTE bPlanes, BYTE bBitsPixel,
|
||||
LPCVOID lpANDbits, LPCVOID lpXORbits )
|
||||
{
|
||||
CURSORICONINFO info;
|
||||
|
||||
TRACE_(icon)("%dx%dx%d, xor=%p, and=%p\n",
|
||||
nWidth, nHeight, bPlanes * bBitsPixel, lpXORbits, lpANDbits);
|
||||
|
||||
info.ptHotSpot.x = ICON_HOTSPOT;
|
||||
info.ptHotSpot.y = ICON_HOTSPOT;
|
||||
info.nWidth = nWidth;
|
||||
info.nHeight = nHeight;
|
||||
info.nWidthBytes = 0;
|
||||
info.bPlanes = bPlanes;
|
||||
info.bBitsPerPixel = bBitsPixel;
|
||||
|
||||
return CreateCursorIconIndirect16( hInstance, &info, lpANDbits, lpXORbits );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CreateIcon (USER32.@)
|
||||
*
|
||||
|
@ -1499,50 +1475,6 @@ HICON WINAPI CreateIcon(
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CreateCursorIconIndirect (USER.408)
|
||||
*/
|
||||
HGLOBAL16 WINAPI CreateCursorIconIndirect16( HINSTANCE16 hInstance,
|
||||
CURSORICONINFO *info,
|
||||
LPCVOID lpANDbits,
|
||||
LPCVOID lpXORbits )
|
||||
{
|
||||
HGLOBAL16 handle;
|
||||
char *ptr;
|
||||
int sizeAnd, sizeXor;
|
||||
|
||||
hInstance = GetExePtr( hInstance ); /* Make it a module handle */
|
||||
if (!lpXORbits || !lpANDbits || info->bPlanes != 1) return 0;
|
||||
info->nWidthBytes = get_bitmap_width_bytes(info->nWidth,info->bBitsPerPixel);
|
||||
sizeXor = info->nHeight * info->nWidthBytes;
|
||||
sizeAnd = info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
|
||||
sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
|
||||
return 0;
|
||||
FarSetOwner16( handle, hInstance );
|
||||
ptr = GlobalLock16( handle );
|
||||
memcpy( ptr, info, sizeof(*info) );
|
||||
memcpy( ptr + sizeof(CURSORICONINFO), lpANDbits, sizeAnd );
|
||||
memcpy( ptr + sizeof(CURSORICONINFO) + sizeAnd, lpXORbits, sizeXor );
|
||||
GlobalUnlock16( handle );
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CopyIcon (USER.368)
|
||||
*/
|
||||
HICON16 WINAPI CopyIcon16( HINSTANCE16 hInstance, HICON16 hIcon )
|
||||
{
|
||||
CURSORICONINFO *info = GlobalLock16( hIcon );
|
||||
void *and_bits = info + 1;
|
||||
void *xor_bits = (BYTE *)and_bits + info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
HGLOBAL16 ret = CreateCursorIconIndirect16( hInstance, info, and_bits, xor_bits );
|
||||
GlobalUnlock16( hIcon );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CopyIcon (USER32.@)
|
||||
*/
|
||||
|
@ -1565,20 +1497,6 @@ HICON WINAPI CopyIcon( HICON hIcon )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CopyCursor (USER.369)
|
||||
*/
|
||||
HCURSOR16 WINAPI CopyCursor16( HINSTANCE16 hInstance, HCURSOR16 hCursor )
|
||||
{
|
||||
CURSORICONINFO *info = GlobalLock16( hCursor );
|
||||
void *and_bits = info + 1;
|
||||
void *xor_bits = (BYTE *)and_bits + info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
HGLOBAL16 ret = CreateCursorIconIndirect16( hInstance, info, and_bits, xor_bits );
|
||||
GlobalUnlock16( hCursor );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* DestroyIcon32 (USER.610)
|
||||
*
|
||||
|
@ -1789,25 +1707,6 @@ BOOL WINAPI DrawIcon( HDC hdc, INT x, INT y, HICON hIcon )
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DumpIcon (USER.459)
|
||||
*/
|
||||
DWORD WINAPI DumpIcon16( SEGPTR pInfo, WORD *lpLen,
|
||||
SEGPTR *lpXorBits, SEGPTR *lpAndBits )
|
||||
{
|
||||
CURSORICONINFO *info = MapSL( pInfo );
|
||||
int sizeAnd, sizeXor;
|
||||
|
||||
if (!info) return 0;
|
||||
sizeXor = info->nHeight * info->nWidthBytes;
|
||||
sizeAnd = info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
if (lpAndBits) *lpAndBits = pInfo + sizeof(CURSORICONINFO);
|
||||
if (lpXorBits) *lpXorBits = pInfo + sizeof(CURSORICONINFO) + sizeAnd;
|
||||
if (lpLen) *lpLen = sizeof(CURSORICONINFO) + sizeAnd + sizeXor;
|
||||
return MAKELONG( sizeXor, sizeXor );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetCursor (USER32.@)
|
||||
*
|
||||
|
@ -1913,17 +1812,6 @@ BOOL WINAPI SetSystemCursor(HCURSOR hcur, DWORD id)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* LookupIconIdFromDirectoryEx (USER.364)
|
||||
*
|
||||
* FIXME: exact parameter sizes
|
||||
*/
|
||||
INT16 WINAPI LookupIconIdFromDirectoryEx16( LPBYTE dir, BOOL16 bIcon,
|
||||
INT16 width, INT16 height, UINT16 cFlag )
|
||||
{
|
||||
return LookupIconIdFromDirectoryEx( dir, bIcon, width, height, cFlag );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* LookupIconIdFromDirectoryEx (USER32.@)
|
||||
*/
|
||||
|
@ -1967,55 +1855,6 @@ INT WINAPI LookupIconIdFromDirectory( LPBYTE dir, BOOL bIcon )
|
|||
bIcon ? GetSystemMetrics(SM_CYICON) : GetSystemMetrics(SM_CYCURSOR), bIcon ? 0 : LR_MONOCHROME );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* GetIconID (USER.455)
|
||||
*/
|
||||
WORD WINAPI GetIconID16( HGLOBAL16 hResource, DWORD resType )
|
||||
{
|
||||
LPBYTE lpDir = GlobalLock16(hResource);
|
||||
|
||||
TRACE_(cursor)("hRes=%04x, entries=%i\n",
|
||||
hResource, lpDir ? ((CURSORICONDIR*)lpDir)->idCount : 0);
|
||||
|
||||
switch(resType)
|
||||
{
|
||||
case RT_CURSOR:
|
||||
return (WORD)LookupIconIdFromDirectoryEx16( lpDir, FALSE,
|
||||
GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR), LR_MONOCHROME );
|
||||
case RT_ICON:
|
||||
return (WORD)LookupIconIdFromDirectoryEx16( lpDir, TRUE,
|
||||
GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0 );
|
||||
default:
|
||||
WARN_(cursor)("invalid res type %d\n", resType );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* LoadCursorIconHandler (USER.336)
|
||||
*
|
||||
* Supposed to load resources of Windows 2.x applications.
|
||||
*/
|
||||
HGLOBAL16 WINAPI LoadCursorIconHandler16( HGLOBAL16 hResource, HMODULE16 hModule, HRSRC16 hRsrc )
|
||||
{
|
||||
FIXME_(cursor)("(%04x,%04x,%04x): old 2.x resources are not supported!\n",
|
||||
hResource, hModule, hRsrc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* LoadIconHandler (USER.456)
|
||||
*/
|
||||
HICON16 WINAPI LoadIconHandler16( HGLOBAL16 hResource, BOOL16 bNew )
|
||||
{
|
||||
LPBYTE bits = LockResource16( hResource );
|
||||
|
||||
TRACE_(cursor)("hRes=%04x\n",hResource);
|
||||
|
||||
return HICON_16(CreateIconFromResourceEx( bits, 0, TRUE,
|
||||
bNew ? 0x00030000 : 0x00020000, 0, 0, LR_DEFAULTCOLOR));
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* LoadCursorW (USER32.@)
|
||||
*/
|
||||
|
|
|
@ -132,6 +132,29 @@ static void logfont_32_to_16( const LOGFONTA* font32, LPLOGFONT16 font16 )
|
|||
lstrcpynA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
|
||||
}
|
||||
|
||||
static int get_bitmap_width_bytes( int width, int bpp )
|
||||
{
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
return 2 * ((width+15) / 16);
|
||||
case 4:
|
||||
return 2 * ((width+3) / 4);
|
||||
case 24:
|
||||
width *= 3;
|
||||
/* fall through */
|
||||
case 8:
|
||||
return width + (width & 1);
|
||||
case 16:
|
||||
case 15:
|
||||
return width * 2;
|
||||
case 32:
|
||||
return width * 4;
|
||||
default:
|
||||
WARN("Unknown depth %d, please report.\n", bpp );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Helper for wsprintf16
|
||||
|
@ -1463,6 +1486,18 @@ BOOL16 WINAPI EnableHardwareInput16(BOOL16 bEnable)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* LoadCursorIconHandler (USER.336)
|
||||
*
|
||||
* Supposed to load resources of Windows 2.x applications.
|
||||
*/
|
||||
HGLOBAL16 WINAPI LoadCursorIconHandler16( HGLOBAL16 hResource, HMODULE16 hModule, HRSRC16 hRsrc )
|
||||
{
|
||||
FIXME("(%04x,%04x,%04x): old 2.x resources are not supported!\n", hResource, hModule, hRsrc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetMouseEventProc (USER.337)
|
||||
*/
|
||||
|
@ -1537,6 +1572,46 @@ BOOL16 WINAPI DCHook16( HDC16 hdc, WORD code, DWORD data, LPARAM lParam )
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* LookupIconIdFromDirectoryEx (USER.364)
|
||||
*
|
||||
* FIXME: exact parameter sizes
|
||||
*/
|
||||
INT16 WINAPI LookupIconIdFromDirectoryEx16( LPBYTE dir, BOOL16 bIcon,
|
||||
INT16 width, INT16 height, UINT16 cFlag )
|
||||
{
|
||||
return LookupIconIdFromDirectoryEx( dir, bIcon, width, height, cFlag );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CopyIcon (USER.368)
|
||||
*/
|
||||
HICON16 WINAPI CopyIcon16( HINSTANCE16 hInstance, HICON16 hIcon )
|
||||
{
|
||||
CURSORICONINFO *info = GlobalLock16( hIcon );
|
||||
void *and_bits = info + 1;
|
||||
void *xor_bits = (BYTE *)and_bits + info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
HGLOBAL16 ret = CreateCursorIconIndirect16( hInstance, info, and_bits, xor_bits );
|
||||
GlobalUnlock16( hIcon );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CopyCursor (USER.369)
|
||||
*/
|
||||
HCURSOR16 WINAPI CopyCursor16( HINSTANCE16 hInstance, HCURSOR16 hCursor )
|
||||
{
|
||||
CURSORICONINFO *info = GlobalLock16( hCursor );
|
||||
void *and_bits = info + 1;
|
||||
void *xor_bits = (BYTE *)and_bits + info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
HGLOBAL16 ret = CreateCursorIconIndirect16( hInstance, info, and_bits, xor_bits );
|
||||
GlobalUnlock16( hCursor );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SubtractRect (USER.373)
|
||||
*/
|
||||
|
@ -1687,6 +1762,58 @@ HCURSOR16 WINAPI CreateCursor16(HINSTANCE16 hInstance,
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CreateIcon (USER.407)
|
||||
*/
|
||||
HICON16 WINAPI CreateIcon16( HINSTANCE16 hInstance, INT16 nWidth,
|
||||
INT16 nHeight, BYTE bPlanes, BYTE bBitsPixel,
|
||||
LPCVOID lpANDbits, LPCVOID lpXORbits )
|
||||
{
|
||||
static const WORD ICON_HOTSPOT = 0x4242;
|
||||
CURSORICONINFO info;
|
||||
|
||||
info.ptHotSpot.x = ICON_HOTSPOT;
|
||||
info.ptHotSpot.y = ICON_HOTSPOT;
|
||||
info.nWidth = nWidth;
|
||||
info.nHeight = nHeight;
|
||||
info.nWidthBytes = 0;
|
||||
info.bPlanes = bPlanes;
|
||||
info.bBitsPerPixel = bBitsPixel;
|
||||
|
||||
return CreateCursorIconIndirect16( hInstance, &info, lpANDbits, lpXORbits );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* CreateCursorIconIndirect (USER.408)
|
||||
*/
|
||||
HGLOBAL16 WINAPI CreateCursorIconIndirect16( HINSTANCE16 hInstance,
|
||||
CURSORICONINFO *info,
|
||||
LPCVOID lpANDbits,
|
||||
LPCVOID lpXORbits )
|
||||
{
|
||||
HGLOBAL16 handle;
|
||||
char *ptr;
|
||||
int sizeAnd, sizeXor;
|
||||
|
||||
hInstance = GetExePtr( hInstance ); /* Make it a module handle */
|
||||
if (!lpXORbits || !lpANDbits || info->bPlanes != 1) return 0;
|
||||
info->nWidthBytes = get_bitmap_width_bytes(info->nWidth,info->bBitsPerPixel);
|
||||
sizeXor = info->nHeight * info->nWidthBytes;
|
||||
sizeAnd = info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
|
||||
sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
|
||||
return 0;
|
||||
FarSetOwner16( handle, hInstance );
|
||||
ptr = GlobalLock16( handle );
|
||||
memcpy( ptr, info, sizeof(*info) );
|
||||
memcpy( ptr + sizeof(CURSORICONINFO), lpANDbits, sizeAnd );
|
||||
memcpy( ptr + sizeof(CURSORICONINFO) + sizeAnd, lpXORbits, sizeXor );
|
||||
GlobalUnlock16( handle );
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* InitThreadInput (USER.409)
|
||||
*/
|
||||
|
@ -2036,6 +2163,37 @@ BOOL16 WINAPI AdjustWindowRectEx16( LPRECT16 rect, DWORD style, BOOL16 menu, DWO
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* GetIconID (USER.455)
|
||||
*/
|
||||
WORD WINAPI GetIconID16( HGLOBAL16 hResource, DWORD resType )
|
||||
{
|
||||
BYTE *dir = GlobalLock16(hResource);
|
||||
|
||||
switch (resType)
|
||||
{
|
||||
case RT_CURSOR:
|
||||
return LookupIconIdFromDirectoryEx16( dir, FALSE, GetSystemMetrics(SM_CXCURSOR),
|
||||
GetSystemMetrics(SM_CYCURSOR), LR_MONOCHROME );
|
||||
case RT_ICON:
|
||||
return LookupIconIdFromDirectoryEx16( dir, TRUE, GetSystemMetrics(SM_CXICON),
|
||||
GetSystemMetrics(SM_CYICON), 0 );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* LoadIconHandler (USER.456)
|
||||
*/
|
||||
HICON16 WINAPI LoadIconHandler16( HGLOBAL16 hResource, BOOL16 bNew )
|
||||
{
|
||||
LPBYTE bits = LockResource16( hResource );
|
||||
return HICON_16(CreateIconFromResourceEx( bits, 0, TRUE,
|
||||
bNew ? 0x00030000 : 0x00020000, 0, 0, LR_DEFAULTCOLOR));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DestroyIcon (USER.457)
|
||||
*/
|
||||
|
@ -2052,6 +2210,26 @@ BOOL16 WINAPI DestroyCursor16(HCURSOR16 hCursor)
|
|||
return DestroyIcon32(hCursor, 0);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DumpIcon (USER.459)
|
||||
*/
|
||||
DWORD WINAPI DumpIcon16( SEGPTR pInfo, WORD *lpLen,
|
||||
SEGPTR *lpXorBits, SEGPTR *lpAndBits )
|
||||
{
|
||||
CURSORICONINFO *info = MapSL( pInfo );
|
||||
int sizeAnd, sizeXor;
|
||||
|
||||
if (!info) return 0;
|
||||
sizeXor = info->nHeight * info->nWidthBytes;
|
||||
sizeAnd = info->nHeight * get_bitmap_width_bytes( info->nWidth, 1 );
|
||||
if (lpAndBits) *lpAndBits = pInfo + sizeof(CURSORICONINFO);
|
||||
if (lpXorBits) *lpXorBits = pInfo + sizeof(CURSORICONINFO) + sizeAnd;
|
||||
if (lpLen) *lpLen = sizeof(CURSORICONINFO) + sizeAnd + sizeXor;
|
||||
return MAKELONG( sizeXor, sizeXor );
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* DRAG_QueryUpdate16
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue