- Timestamp:
- Mar 27, 2001, 6:17:52 PM (24 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/loadres.cpp
r4586 r5385 1 /* $Id: loadres.cpp,v 1.3 4 2000-11-12 10:58:12sandervl Exp $ */1 /* $Id: loadres.cpp,v 1.35 2001-03-27 16:17:51 sandervl Exp $ */ 2 2 3 3 /* … … 25 25 #include "dib.h" 26 26 #include "initterm.h" 27 #include <win\cursoricon.h>28 27 #include <winres.h> 28 #include "pmwindow.h" 29 29 30 30 #define DBG_LOCALLOG DBG_loadres … … 121 121 dprintf(("LoadIconA %x %x", hinst, lpszIcon)); 122 122 return LoadImageW(hinst, lpszIcon, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE); 123 }124 //******************************************************************************125 //******************************************************************************126 HCURSOR LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor, DWORD cxDesired,127 DWORD cyDesired, DWORD fuLoad)128 {129 HCURSOR hCursor;130 HANDLE hMapping = 0;131 char *ptr = NULL;132 HRSRC hRes;133 LPSTR restype = RT_CURSORA;134 LPVOID lpOS2Resdata = NULL;135 136 if(fuLoad & LR_LOADFROMFILE)137 {138 hMapping = VIRTUAL_MapFileW( lpszCursor, (LPVOID *)&ptr, TRUE);139 if(hMapping == INVALID_HANDLE_VALUE)140 return 0;141 142 lpOS2Resdata = ConvertCursorToOS2(ptr);143 hCursor = OSLibWinCreatePointer(lpOS2Resdata, cxDesired, cyDesired);144 FreeOS2Resource(lpOS2Resdata);145 146 UnmapViewOfFile(ptr);147 CloseHandle(hMapping);148 }149 else150 {151 if(!hinst)152 {153 hRes = FindResourceW(hInstanceUser32,lpszCursor,RT_CURSORW);154 if(!hRes) {155 hRes = FindResourceW(hInstanceUser32,lpszCursor,RT_GROUP_CURSORW);156 restype = RT_GROUP_CURSORA;157 }158 if(hRes)159 {160 lpOS2Resdata = ConvertResourceToOS2(hInstanceUser32, restype, hRes);161 hCursor = OSLibWinCreatePointer(lpOS2Resdata, cxDesired, cyDesired);162 FreeOS2Resource(lpOS2Resdata);163 }164 else hCursor = OSLibWinQuerySysPointer((ULONG)lpszCursor, cxDesired, cyDesired);165 }166 else167 { //not a system icon168 hRes = FindResourceW(hinst,lpszCursor,RT_CURSORW);169 if(!hRes) {170 hRes = FindResourceW(hinst,lpszCursor,RT_GROUP_CURSORW);171 restype = RT_GROUP_CURSORA;172 }173 if(hRes) {174 lpOS2Resdata = ConvertResourceToOS2(hinst, restype, hRes);175 hCursor = OSLibWinCreatePointer(lpOS2Resdata, cxDesired, cyDesired);176 FreeOS2Resource(lpOS2Resdata);177 }178 else hCursor = 0;179 }180 }181 dprintf(("LoadCursorA %x from %x returned %x\n", lpszCursor, hinst, hCursor));182 183 return(hCursor);184 123 } 185 124 //****************************************************************************** … … 466 405 case IMAGE_ICON: 467 406 { 407 #ifdef __WIN32OS2__ 408 ULONG palEnts = (1 << ScreenBitsPerPel); 409 #else 468 410 HDC hdc = GetDC(0); 469 411 UINT palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL); … … 471 413 palEnts = 256; 472 414 ReleaseDC(0, hdc); 415 #endif 473 416 474 417 hRet = CURSORICON_Load(hinst, lpszName, cxDesired, cyDesired, palEnts, FALSE, fuLoad); … … 477 420 478 421 case IMAGE_CURSOR: 479 hRet = (HANDLE)LoadCursorW(hinst, lpszName, cxDesired, cyDesired, fuLoad); 480 break; 481 // return CURSORICON_Load(hinst, name, desiredx, desiredy, 1, TRUE, loadflags); 422 return CURSORICON_Load(hinst, lpszName, cxDesired, cyDesired, 1, TRUE, fuLoad); 482 423 483 424 default: 484 485 425 dprintf(("LoadImageW: unsupported type %d!!", uType)); 426 return 0; 486 427 } 487 428 dprintf(("LoadImageW returned %x\n", (int)hRet)); … … 518 459 return (HANDLE)CURSORICON_ExtCopy(hnd, type, desiredx, desiredy, flags); 519 460 case IMAGE_CURSOR: 520 /* Should call CURSORICON_ExtCopy but more testing 521 * needs to be done before we change this 522 */ 523 return O32_CopyCursor(hnd); 524 // return CopyCursorIcon(hnd,type, desiredx, desiredy, flags); 461 /* Should call CURSORICON_ExtCopy but more testing 462 * needs to be done before we change this 463 */ 464 return CURSORICON_ExtCopy(hnd,type, desiredx, desiredy, flags); 525 465 default: 526 466 dprintf(("CopyImage: Unsupported type")); -
trunk/src/user32/oslibres.cpp
r4573 r5385 1 /* $Id: oslibres.cpp,v 1.1 1 2000-11-09 18:15:18sandervl Exp $ */1 /* $Id: oslibres.cpp,v 1.12 2001-03-27 16:17:52 sandervl Exp $ */ 2 2 /* 3 3 * Window API wrappers for OS/2 … … 22 22 #include "oslibmsg.h" 23 23 #include "oslibgdi.h" 24 #include "oslibres.h" 24 25 #include "pmwindow.h" 25 26 … … 228 229 } 229 230 //****************************************************************************** 231 //NOTE: Depends on origin of bitmap data!!! 232 // Assumes 1 bpp bitmaps have a top left origin and all others have a bottom left origin 233 //****************************************************************************** 234 HANDLE OSLibWinCreateCursor(CURSORICONINFO *pInfo, char *pAndBits, BITMAP_W *pAndBmp, char *pXorBits, BITMAP_W *pXorBmp) 235 { 236 POINTERINFO pointerInfo = {0}; 237 HANDLE hPointer; 238 HBITMAP hbmColor = 0, hbmMask = 0; 239 BITMAPINFO2 *pBmpColor, *pBmpMask; 240 int masksize, colorsize, rgbsize, i; 241 HPS hps; 242 char *dest, *src; 243 244 hps = WinGetScreenPS(HWND_DESKTOP); 245 masksize = sizeof(BITMAPINFO2) + (pAndBmp->bmHeight * 2 * pAndBmp->bmWidthBytes) + 2*sizeof(RGB2); 246 pBmpMask = (BITMAPINFO2 *)malloc(masksize); 247 if(pBmpMask == NULL) { 248 DebugInt3(); 249 return 0; 250 } 251 memset(pBmpMask, 0, masksize); 252 pBmpMask->cbFix = sizeof(BITMAPINFOHEADER2); 253 pBmpMask->cx = (USHORT)pAndBmp->bmWidth; 254 pBmpMask->cy = (USHORT)pAndBmp->bmHeight*2; 255 pBmpMask->cPlanes = pAndBmp->bmPlanes; 256 pBmpMask->cBitCount = 1; 257 pBmpMask->ulCompression = BCA_UNCOMP; 258 pBmpMask->ulColorEncoding = BCE_RGB; 259 memset(&pBmpMask->argbColor[0], 0, sizeof(RGB2)); 260 memset(&pBmpMask->argbColor[1], 0xff, sizeof(RGB)); //not the reserved byte 261 //Xor bits are already 0 262 //copy And bits (must reverse scanlines because origin is top left instead of bottom left) 263 src = pAndBits; 264 dest = ((char *)&pBmpMask->argbColor[2]) + (pAndBmp->bmHeight * 2 - 1) * (pAndBmp->bmWidthBytes); 265 for(i=0;i<pAndBmp->bmHeight;i++) { 266 memcpy(dest, src, pAndBmp->bmWidthBytes); 267 dest -= pAndBmp->bmWidthBytes; 268 src += pAndBmp->bmWidthBytes; 269 } 270 hbmMask = GpiCreateBitmap(hps, (BITMAPINFOHEADER2 *)pBmpMask, CBM_INIT, 271 (PBYTE)&pBmpMask->argbColor[2], pBmpMask); 272 273 if(hbmMask == GPI_ERROR) { 274 dprintf(("OSLibWinCreatePointer: GpiCreateBitmap failed!")); 275 WinReleasePS(hps); 276 free(pBmpMask); 277 return 0; 278 } 279 if(pXorBits) 280 {//color bitmap present 281 RGBQUAD *rgb; 282 RGB2 *os2rgb; 283 284 if(pXorBmp->bmBitsPixel <= 8) 285 rgbsize = (1<<pXorBmp->bmBitsPixel)*sizeof(RGB2); 286 else rgbsize = 0; 287 288 colorsize = sizeof(BITMAPINFO2) + (pXorBmp->bmHeight * pXorBmp->bmWidthBytes) + rgbsize; 289 pBmpColor = (BITMAPINFO2 *)malloc(colorsize); 290 if(pBmpColor == NULL) { 291 DebugInt3(); 292 return 0; 293 } 294 memset(pBmpColor, 0, colorsize); 295 pBmpColor->cbFix = sizeof(BITMAPINFOHEADER2); 296 pBmpColor->cx = (USHORT)pXorBmp->bmWidth; 297 pBmpColor->cy = (USHORT)pXorBmp->bmHeight; 298 pBmpColor->cPlanes = pXorBmp->bmPlanes; 299 pBmpColor->cBitCount = pXorBmp->bmBitsPixel; 300 pBmpColor->ulCompression = BCA_UNCOMP; 301 pBmpColor->ulColorEncoding = BCE_RGB; 302 303 os2rgb = &pBmpColor->argbColor[0]; 304 rgb = (RGBQUAD *)(pXorBits); 305 306 if(pXorBmp->bmBitsPixel <= 8) { 307 for(i=0;i<(1<<pXorBmp->bmBitsPixel);i++) { 308 os2rgb->bRed = rgb->rgbRed; 309 os2rgb->bBlue = rgb->rgbBlue; 310 os2rgb->bGreen = rgb->rgbGreen; 311 os2rgb++; 312 rgb++; 313 } 314 } 315 316 if(pXorBmp->bmBitsPixel == 1) { 317 //copy Xor bits (must reverse scanlines because origin is top left instead of bottom left) 318 src = (char *)rgb; 319 dest = ((char *)os2rgb) + (pXorBmp->bmHeight - 1) * pXorBmp->bmWidthBytes; 320 for(i=0;i<pXorBmp->bmHeight;i++) { 321 memcpy(dest, src, pXorBmp->bmWidthBytes); 322 dest -= pXorBmp->bmWidthBytes; 323 src += pXorBmp->bmWidthBytes; 324 } 325 } 326 else memcpy(os2rgb, rgb, pXorBmp->bmHeight * pXorBmp->bmWidthBytes); 327 328 hbmColor = GpiCreateBitmap(hps, (BITMAPINFOHEADER2 *)pBmpColor, CBM_INIT, 329 (PBYTE)os2rgb, pBmpColor); 330 331 if(hbmColor == GPI_ERROR) { 332 dprintf(("OSLibWinCreateIcon: GpiCreateBitmap failed!")); 333 GpiDeleteBitmap(hbmMask); 334 WinReleasePS(hps); 335 free(pBmpMask); 336 return 0; 337 } 338 } 339 340 pointerInfo.fPointer = TRUE; 341 pointerInfo.xHotspot = pInfo->ptHotSpot.x; 342 pointerInfo.yHotspot = mapY(pInfo->nHeight, pInfo->ptHotSpot.y); 343 pointerInfo.hbmColor = hbmColor; 344 pointerInfo.hbmPointer = hbmMask; 345 hPointer = WinCreatePointerIndirect(HWND_DESKTOP, &pointerInfo); 346 347 if(hPointer == NULL) { 348 dprintf(("OSLibWinCreateCursor: WinCreatePointerIndirect failed! (lasterr=%x)", WinGetLastError(GetThreadHAB()))); 349 } 350 GpiDeleteBitmap(hbmMask); 351 if(hbmColor) GpiDeleteBitmap(hbmColor); 352 WinReleasePS(hps); 353 354 free(pBmpMask); 355 free(pBmpColor); 356 return hPointer; 357 } 358 //****************************************************************************** 230 359 //****************************************************************************** 231 360 HANDLE OSLibWinQuerySysIcon(ULONG type,INT w,INT h) … … 332 461 //****************************************************************************** 333 462 //****************************************************************************** 463 VOID OSLibWinDestroyPointer(HANDLE hPointer) 464 { 465 WinDestroyPointer(hPointer); 466 } 467 //****************************************************************************** 468 //****************************************************************************** 469 BOOL OSLibWinSetPointer(HANDLE hPointer) 470 { 471 return WinSetPointer(HWND_DESKTOP, hPointer); 472 } 473 //****************************************************************************** 474 //****************************************************************************** -
trunk/src/user32/oslibres.h
r4573 r5385 1 /* $Id: oslibres.h,v 1. 5 2000-11-09 18:15:18sandervl Exp $ */1 /* $Id: oslibres.h,v 1.6 2001-03-27 16:17:52 sandervl Exp $ */ 2 2 /* 3 3 * Window GUI resource wrapper functions for OS/2 … … 14 14 15 15 #ifdef OS2_INCLUDED 16 #include "win32type.h"16 #include <win32type.h> 17 17 #endif 18 19 #include <win\cursoricon.h> 20 21 #ifdef OS2_INCLUDED 22 typedef struct 23 { 24 BYTE rgbBlue; 25 BYTE rgbGreen; 26 BYTE rgbRed; 27 BYTE rgbReserved; 28 } RGBQUAD, *LPRGBQUAD; 29 #endif 30 31 typedef struct 32 { 33 INT bmType; 34 INT bmWidth; 35 INT bmHeight; 36 INT bmWidthBytes; 37 WORD bmPlanes; 38 WORD bmBitsPixel; 39 LPVOID bmBits; 40 } BITMAP_W, *LPBITMAP_W; 18 41 19 42 HANDLE OSLibWinSetAccelTable(HWND hwnd, HANDLE hAccel, PVOID acceltemplate); 20 43 HANDLE OSLibWinCreateIcon(PVOID iconbitmap, ULONG cxDesired, ULONG cyDesired); 44 45 //NOTE: Depends on origin of bitmap data!!! 46 // Assumes 1 bpp bitmaps have a top left origin and all others have a bottom left origin 21 47 HANDLE OSLibWinCreatePointer(PVOID cursorbitmap, ULONG cxDesired, ULONG cyDesired); 48 49 HANDLE OSLibWinCreateCursor(CURSORICONINFO *pInfo, char *pAndBits, BITMAP_W *pAndBmp, char *pXorBits, BITMAP_W *pXorBmp); 22 50 HANDLE OSLibWinQuerySysPointer(ULONG type,INT w,INT h); 23 51 HANDLE OSLibWinQuerySysIcon(ULONG type,INT w,INT h); 52 VOID OSLibWinDestroyPointer(HANDLE hPointer); 53 BOOL OSLibWinSetPointer(HANDLE hPointer); 24 54 25 55 #endif //__OSLIBGDI_H__ -
trunk/src/user32/oslibwin.cpp
r5215 r5385 1 /* $Id: oslibwin.cpp,v 1.8 8 2001-02-20 15:40:22 sandervl Exp $ */1 /* $Id: oslibwin.cpp,v 1.89 2001-03-27 16:17:52 sandervl Exp $ */ 2 2 /* 3 3 * Window API wrappers for OS/2 … … 209 209 //****************************************************************************** 210 210 //****************************************************************************** 211 BOOL OSLibWinSetPointerPos(int x, int y) 212 { 213 return WinSetPointerPos(HWND_DESKTOP, x, y); 214 } 215 //****************************************************************************** 216 //****************************************************************************** 211 217 HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode) 212 218 { -
trunk/src/user32/oslibwin.h
r5215 r5385 1 /* $Id: oslibwin.h,v 1.5 0 2001-02-20 15:40:22 sandervl Exp $ */1 /* $Id: oslibwin.h,v 1.51 2001-03-27 16:17:52 sandervl Exp $ */ 2 2 /* 3 3 * Window API wrappers for OS/2 … … 183 183 BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText); 184 184 BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint); //pptlPoint == POINTL pointer! 185 BOOL OSLibWinSetPointerPos(int x, int y); 185 186 186 187 #define SWPOS_SIZE 0x0001 -
trunk/src/user32/user32.cpp
r5367 r5385 1 /* $Id: user32.cpp,v 1.9 3 2001-03-24 15:40:56sandervl Exp $ */1 /* $Id: user32.cpp,v 1.94 2001-03-27 16:17:52 sandervl Exp $ */ 2 2 3 3 /* … … 334 334 //****************************************************************************** 335 335 //****************************************************************************** 336 HCURSOR WIN32API CreateCursor( HINSTANCE hInst, int xHotSpot, int yHotSpot, int nWidth, int nHeight, const VOID *pvANDPlane, const VOID *pvXORPlane)337 {338 dprintf(("USER32: CreateCursor\n"));339 return O32_CreateCursor(hInst,xHotSpot,yHotSpot,nWidth,nHeight,pvANDPlane,pvXORPlane);340 }341 //******************************************************************************342 //******************************************************************************343 BOOL WIN32API DestroyCursor( HCURSOR hCursor)344 {345 dprintf(("USER32: DestroyCursor\n"));346 return O32_DestroyCursor(hCursor);347 }348 //******************************************************************************349 //******************************************************************************350 336 BOOL WIN32API GetClipCursor( LPRECT lpRect) 351 337 { 352 338 dprintf(("USER32: GetClipCursor\n")); 353 339 return O32_GetClipCursor(lpRect); 354 }355 //******************************************************************************356 //******************************************************************************357 HCURSOR WIN32API GetCursor(void)358 {359 dprintf2(("USER32: GetCursor\n"));360 return O32_GetCursor();361 }362 //******************************************************************************363 //******************************************************************************364 BOOL WIN32API GetCursorPos( PPOINT lpPoint)365 {366 dprintf2(("USER32: GetCursorPos\n"));367 368 if (!lpPoint) return FALSE;369 if (OSLibWinQueryPointerPos(lpPoint)) //POINT == POINTL370 {371 mapScreenPoint((OSLIBPOINT*)lpPoint);372 return TRUE;373 } else return FALSE;374 }375 //******************************************************************************376 //******************************************************************************377 HCURSOR WIN32API SetCursor( HCURSOR hcur)378 {379 HCURSOR rc;380 381 rc = O32_SetCursor(hcur);382 dprintf(("USER32: SetCursor %x (prev %x (%x))\n", hcur, rc, O32_GetCursor()));383 return rc;384 }385 //******************************************************************************386 //******************************************************************************387 BOOL WIN32API SetCursorPos( int X, int Y)388 {389 dprintf(("USER32: SetCursorPos %d %d", X,Y));390 return O32_SetCursorPos(X,Y);391 }392 /*****************************************************************************393 * Name : BOOL WIN32API SetSystemCursor394 * Purpose : The SetSystemCursor function replaces the contents of the system395 * cursor specified by dwCursorId with the contents of the cursor396 * specified by hCursor, and then destroys hCursor. This function397 * lets an application customize the system cursors.398 * Parameters: HCURSOR hCursor set specified system cursor to this cursor's399 * contents, then destroy this400 * DWORD dwCursorID system cursor specified by its identifier401 * Variables :402 * Result : If the function succeeds, the return value is TRUE.403 * If the function fails, the return value is FALSE. To get extended404 * error information, call GetLastError.405 * Remark :406 * Status : UNTESTED STUB407 *408 * Author : Patrick Haller [Thu, 1998/02/26 11:55]409 *****************************************************************************/410 BOOL WIN32API SetSystemCursor(HCURSOR hCursor,411 DWORD dwCursorId)412 {413 dprintf(("USER32:SetSystemCursor (%08xh,%08x) not supported.\n",414 hCursor,415 dwCursorId));416 417 return DestroyCursor(hCursor);418 }419 //******************************************************************************420 //******************************************************************************421 int WIN32API ShowCursor( BOOL bShow)422 {423 dprintf2(("USER32: ShowCursor %d", bShow));424 return O32_ShowCursor(bShow);425 340 } 426 341 -
trunk/src/user32/winicon.cpp
r4825 r5385 1 /* $Id: winicon.cpp,v 1. 19 2000-12-17 15:04:14sandervl Exp $ */1 /* $Id: winicon.cpp,v 1.20 2001-03-27 16:17:52 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Icon Code for OS/2 … … 14 14 * 1998 Turchanov Sergey 15 15 * 1998 Huw D M Davies 16 * Theory: 17 * 18 * http://www.microsoft.com/win32dev/ui/icons.htm 19 * 20 * Cursors and icons are stored in a global heap block, with the 21 * following layout: 22 * 23 * CURSORICONINFO info; 24 * BYTE[] ANDbits; 25 * BYTE[] XORbits; 26 * 27 * The bits structures are in the format of a device-dependent bitmap. 28 * 29 * This layout is very sub-optimal, as the bitmap bits are stored in 30 * the X client instead of in the server like other bitmaps; however, 31 * some programs (notably Paint Brush) expect to be able to manipulate 32 * the bits directly :-( 33 * 34 * FIXME: what are we going to do with animation and color (bpp > 1) cursors ?! 35 * 36 ************************************************************************************************** 37 * 38 * TODO: Scaling of system cursors (store them as resources in user32 instead of using PM pointers) 39 * TODO: We use the hColorBmp member of the CURSORICONINFO structure to store the PM cursor handle 40 * Might mess up PaintBrush (see above) 16 41 * 17 42 * Project Odin Software License can be found in LICENSE.TXT … … 27 52 #include <win\virtual.h> 28 53 #include "initterm.h" 54 #include "oslibres.h" 55 #include "oslibwin.h" 29 56 30 57 #define DBG_LOCALLOG DBG_winicon 31 58 #include "dbglocal.h" 32 59 33 static WORD ICON_HOTSPOT = 0x4242; 60 61 /********************************************************************** 62 * ICONCACHE for cursors/icons loaded with LR_SHARED. 63 * 64 * FIXME: This should not be allocated on the system heap, but on a 65 * subsystem-global heap (i.e. one for all Win16 processes, 66 * and one for each Win32 process). 67 */ 68 typedef struct tagICONCACHE 69 { 70 struct tagICONCACHE *next; 71 72 HMODULE hModule; 73 HRSRC hRsrc; 74 HRSRC hGroupRsrc; 75 HANDLE handle; 76 INT count; 77 } ICONCACHE; 78 79 static ICONCACHE *IconAnchor = NULL; 80 static CRITICAL_SECTION IconCrst = CRITICAL_SECTION_INIT; 81 static WORD ICON_HOTSPOT = 0x4242; 82 static HCURSOR hActiveCursor = 0; 83 34 84 35 85 static HGLOBAL CURSORICON_CreateFromResource( HINSTANCE hInstance, DWORD dwResGroupId, HGLOBAL hObj, LPBYTE bits, … … 43 93 CURSORICONDIR **res, LPBYTE **ptr); 44 94 95 static INT CURSORICON_DelSharedIcon( HANDLE handle ); 96 static void CURSORICON_AddSharedIcon( HMODULE hModule, HRSRC hRsrc, HRSRC hGroupRsrc, HANDLE handle ); 97 static HANDLE CURSORICON_FindSharedIcon( HMODULE hModule, HRSRC hRsrc ); 98 static ICONCACHE* CURSORICON_FindCache(HANDLE handle); 99 45 100 /*********************************************************************** 46 101 * CreateIcon (USER32.75) … … 63 118 info.hInstance = hInstance; 64 119 info.dwResGroupId = -1; 120 info.hColorBmp = 0; 65 121 return CreateCursorIconIndirect(0, &info, lpANDbits, lpXORbits); 66 122 } … … 126 182 info->hInstance = -1; 127 183 info->dwResGroupId = -1; 184 info->hColorBmp = 0; 185 128 186 /* Transfer the bitmap bits to the CURSORICONINFO structure */ 129 187 GetBitmapBits( iconinfo->hbmMask ,sizeAnd,(char*)(info + 1) ); … … 213 271 memcpy(&pInfo->bmiColors[0], (char *)(ciconinfo + 1) + coloroff, colorsize); 214 272 } 215 //else TODO: color masks (cur erntly unused in CreateDIBitmap)273 //else TODO: color masks (currently unused in CreateDIBitmap) 216 274 217 275 iconinfo->hbmColor = CreateDIBitmap(hdc, &pInfo->bmiHeader, CBM_INIT, src, pInfo, DIB_RGB_COLORS); … … 235 293 return TRUE; 236 294 } 295 //****************************************************************************** 296 //****************************************************************************** 297 HCURSOR WIN32API CreateCursor(HINSTANCE hInst, int xHotSpot, int yHotSpot, int nWidth, int nHeight, 298 const VOID *lpANDbits, const VOID *lpXORbits) 299 { 300 CURSORICONINFO info; 301 302 dprintf(("CreateCursor %dx%d spot=%d,%d xor=%p and=%p\n", 303 nWidth, nHeight, xHotSpot, yHotSpot, lpXORbits, lpANDbits)); 304 305 info.ptHotSpot.x = xHotSpot; 306 info.ptHotSpot.y = yHotSpot; 307 info.nWidth = nWidth; 308 info.nHeight = nHeight; 309 info.nWidthBytes = 0; 310 info.bPlanes = 1; 311 info.bBitsPerPixel = 1; 312 info.hInstance = hInst; 313 info.dwResGroupId = -1; 314 info.hColorBmp = 0; 315 316 return CreateCursorIconIndirect( 0, &info, lpANDbits, lpXORbits ); 317 } 318 //****************************************************************************** 319 //****************************************************************************** 320 BOOL WIN32API DestroyCursor( HCURSOR hCursor) 321 { 322 dprintf(("USER32: DestroyCursor %x", hCursor)); 323 return CURSORICON_Destroy( hCursor, CID_WIN32 ); 324 } 325 //****************************************************************************** 326 //****************************************************************************** 327 HCURSOR WIN32API GetCursor(void) 328 { 329 dprintf2(("USER32: GetCursor")); 330 return hActiveCursor; 331 } 332 //****************************************************************************** 333 //****************************************************************************** 334 HCURSOR WIN32API SetCursor( HCURSOR hCursor) 335 { 336 HCURSOR hOldCursor; 337 338 dprintf(("USER32: SetCursor %x (prev %x)", hCursor, hActiveCursor)); 339 if (hCursor == hActiveCursor) return hActiveCursor; /* No change */ 340 341 hOldCursor = hActiveCursor; 342 hActiveCursor = hCursor; 343 344 CURSORICONINFO *iconinfo = (CURSORICONINFO *)GlobalLock((HGLOBAL)hCursor); 345 if (!iconinfo) { 346 dprintf(("ERROR: Invalid cursor!")); 347 return 0; 348 } 349 if(!iconinfo->hColorBmp) { 350 dprintf(("SetCursor: invalid os/2 pointer handle!!")); 351 } 352 353 if(OSLibWinSetPointer(iconinfo->hColorBmp) == FALSE) { 354 dprintf(("OSLibWinSetPointer %x returned FALSE!!", iconinfo->hColorBmp)); 355 } 356 GlobalUnlock(hCursor); 357 358 return hOldCursor; 359 } 360 //****************************************************************************** 361 //****************************************************************************** 362 BOOL WIN32API GetCursorPos( PPOINT lpPoint) 363 { 364 dprintf2(("USER32: GetCursorPos %x", lpPoint)); 365 366 if (!lpPoint) return FALSE; 367 368 if (OSLibWinQueryPointerPos(lpPoint)) //POINT == POINTL 369 { 370 mapScreenPoint((OSLIBPOINT*)lpPoint); 371 return TRUE; 372 } 373 else return FALSE; 374 } 375 //****************************************************************************** 376 //****************************************************************************** 377 BOOL WIN32API SetCursorPos( int X, int Y) 378 { 379 dprintf(("USER32: SetCursorPos %d %d", X,Y)); 380 return OSLibWinSetPointerPos(X, mapScreenY(Y)); 381 } 382 //****************************************************************************** 383 //****************************************************************************** 384 /***************************************************************************** 385 * Name : BOOL WIN32API SetSystemCursor 386 * Purpose : The SetSystemCursor function replaces the contents of the system 387 * cursor specified by dwCursorId with the contents of the cursor 388 * specified by hCursor, and then destroys hCursor. This function 389 * lets an application customize the system cursors. 390 * Parameters: HCURSOR hCursor set specified system cursor to this cursor's 391 * contents, then destroy this 392 * DWORD dwCursorID system cursor specified by its identifier 393 * Variables : 394 * Result : If the function succeeds, the return value is TRUE. 395 * If the function fails, the return value is FALSE. To get extended 396 * error information, call GetLastError. 397 * Remark : 398 * Status : UNTESTED STUB 399 * 400 * Author : Patrick Haller [Thu, 1998/02/26 11:55] 401 *****************************************************************************/ 402 BOOL WIN32API SetSystemCursor(HCURSOR hCursor, DWORD dwCursorId) 403 { 404 dprintf(("USER32:SetSystemCursor (%08xh,%08x) not supported.\n", 405 hCursor, 406 dwCursorId)); 407 408 return DestroyCursor(hCursor); 409 } 410 //****************************************************************************** 411 //****************************************************************************** 412 int WIN32API ShowCursor( BOOL bShow) 413 { 414 dprintf2(("USER32: ShowCursor %d", bShow)); 415 return O32_ShowCursor(bShow); 416 } 417 //****************************************************************************** 418 //****************************************************************************** 237 419 /*********************************************************************** 238 * CreateCursorIconIndirect (USER.408)420 * CreateCursorIconIndirect 239 421 */ 240 422 HGLOBAL WIN32API CreateCursorIconIndirect( HINSTANCE hInstance, … … 276 458 LPBYTE bits; 277 459 460 #ifdef __WIN32OS2__ 461 //TODO: Can system cursors be loaded by name??? (#xxx) 462 if (fCursor && hInstance == NULL && !HIWORD(name)) 463 { 464 HCURSOR hCursor = OSLibWinQuerySysPointer((ULONG)name, width, height); 465 if(hCursor) 466 { 467 /* If shared icon, check whether it was already loaded */ 468 if ((loadflags & LR_SHARED) 469 && (h = CURSORICON_FindSharedIcon( -1, hCursor ) ) != 0 ) 470 { 471 dprintf(("Found icon/cursor in cache; returned old handle %x", h)); 472 return h; 473 } 474 475 HANDLE hObj = GlobalAlloc( GMEM_MOVEABLE, sizeof(CURSORICONINFO)); 476 if (!hObj) 477 { 478 DebugInt3(); 479 return 0; 480 } 481 CURSORICONINFO *info; 482 483 info = (CURSORICONINFO *)GlobalLock( hObj ); 484 info->ptHotSpot.x = 0; 485 info->ptHotSpot.y = 0; 486 info->nWidth = width; 487 info->nHeight = height; 488 info->nWidthBytes = width*height/8; 489 info->bPlanes = 1; 490 info->bBitsPerPixel = 1; 491 info->hColorBmp = hCursor; 492 info->hInstance = -1; 493 info->dwResGroupId = -1; 494 495 if (loadflags & LR_SHARED ) 496 CURSORICON_AddSharedIcon( -1, hCursor, -1, hObj ); 497 498 GlobalUnlock( hObj ); 499 500 return hObj; 501 } 502 } 503 #endif 278 504 if ( loadflags & LR_LOADFROMFILE ) /* Load from file */ 279 505 { 280 506 LPBYTE *ptr; 507 281 508 if (!CURSORICON_SimulateLoadingFromResourceW((LPWSTR)name, fCursor, &dir, &ptr)) 282 509 return 0; … … 288 515 h = CURSORICON_CreateFromResource( 0, -1, 0, bits, dirEntry->dwBytesInRes, 289 516 !fCursor, 0x00030000, width, height, loadflags); 517 290 518 HeapFree( GetProcessHeap(), 0, dir ); 291 519 HeapFree( GetProcessHeap(), 0, ptr ); … … 339 567 } 340 568 569 /* If shared icon, check whether it was already loaded */ 570 if ((loadflags & LR_SHARED) 571 && (h = CURSORICON_FindSharedIcon( hInstance, hRsrc ) ) != 0 ) 572 { 573 dprintf(("Found icon/cursor in cache; returned old handle %x", h)); 574 return h; 575 } 576 341 577 if (!(handle = LoadResource( hInstance, hRsrc ))) return 0; 342 578 bits = (LPBYTE)LockResource( handle ); … … 344 580 !fCursor, 0x00030000, width, height, loadflags); 345 581 FreeResource( handle ); 582 583 /* If shared icon, add to icon cache */ 584 585 if ( h && (loadflags & LR_SHARED) ) 586 CURSORICON_AddSharedIcon( hInstance, hRsrc, hGroupRsrc, h ); 346 587 347 588 } … … 706 947 if( !hXorBits || !hAndBits ) 707 948 { 708 dprintf(("\tunable to create an icon bitmap. \n"));949 dprintf(("\tunable to create an icon bitmap.")); 709 950 return 0; 710 951 } … … 739 980 info->bPlanes = bmpXor.bmPlanes; 740 981 info->bBitsPerPixel = bmpXor.bmBitsPixel; 741 info->hColorBmp = hXorBits;742 982 info->hInstance = hInstance; 743 983 info->dwResGroupId = dwResGroupId; 984 info->hColorBmp = 0; 744 985 745 986 /* Transfer the bitmap bits to the CURSORICONINFO structure */ … … 769 1010 GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd); 770 1011 } 1012 if(!bIcon) { 1013 info->hColorBmp = OSLibWinCreateCursor(info, (char *)(info + 1), (LPBITMAP_W)&bmpAnd, (char *)(info + 1) + sizeAnd, (LPBITMAP_W)&bmpXor); 1014 dprintf(("Create cursor %x with OS/2 pointer handle %x", hObj, info->hColorBmp)); 1015 } 771 1016 GlobalUnlock( hObj ); 772 1017 } … … 789 1034 WORD retv; 790 1035 791 #if 0792 1036 /* Check whether destroying active cursor */ 793 1037 794 1038 if ( hActiveCursor == handle ) 795 1039 { 796 ERR_(cursor)("Destroying active cursor!\n");1040 dprintf(("WARNING: Destroying active cursor!" )); 797 1041 SetCursor( 0 ); 798 1042 } 1043 799 1044 /* Try shared cursor/icon first */ 800 801 1045 if ( !(flags & CID_NONSHARED) ) 802 1046 { … … 808 1052 /* FIXME: OEM cursors/icons should be recognized */ 809 1053 } 1054 /* Now assume non-shared cursor/icon */ 1055 1056 #ifdef __WIN32OS2__ 1057 CURSORICONINFO *iconinfo = (CURSORICONINFO *)GlobalLock((HGLOBAL)handle); 1058 if (!iconinfo) { 1059 dprintf(("ERROR: Invalid cursor!")); 1060 return 0; 1061 } 1062 1063 if(iconinfo->hColorBmp) { 1064 OSLibWinDestroyPointer(iconinfo->hColorBmp); 1065 } 1066 GlobalUnlock(handle); 810 1067 #endif 811 /* Now assume non-shared cursor/icon */812 1068 813 1069 retv = GlobalFree( handle ); … … 874 1130 || nFlags & LR_MONOCHROME) 875 1131 { 1132 ICONCACHE* pIconCache = CURSORICON_FindCache(Handle); 1133 1134 /* Not Found in Cache, then do a straight copy 1135 */ 1136 if(pIconCache == NULL) 1137 { 1138 #ifdef __WIN32OS2__ 1139 hNew = CURSORICON_Copy(Handle); 1140 #else 1141 hNew = CURSORICON_Copy(0, Handle); 1142 #endif 1143 if(nFlags & LR_COPYFROMRESOURCE) 1144 { 1145 dprintf(("WARNING: LR_COPYFROMRESOURCE: Failed to load from cache\n")); 1146 } 1147 } 1148 else 1149 { 876 1150 int iTargetCY = iDesiredCY, iTargetCX = iDesiredCX; 877 1151 LPBYTE pBits; … … 968 1242 bIsIcon, 0x00030000, iTargetCX, iTargetCY, nFlags); 969 1243 FreeResource(hMem); 1244 } 970 1245 } 971 1246 else … … 1005 1280 iColorDiff = 0xFFFFFFFF; 1006 1281 for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++) 1007 1282 { 1008 1283 iTempXDiff = abs(width - entry->ResInfo.icon.bWidth); 1009 1284 iTempYDiff = abs(height - entry->ResInfo.icon.bHeight); … … 1015 1290 iTotalDiff = iXDiff + iYDiff; 1016 1291 } 1017 1292 } 1018 1293 1019 1294 /* Find Best Colors for Best Fit */ 1020 1295 for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++) 1021 1296 { 1022 1297 if(abs(width - entry->ResInfo.icon.bWidth) == iXDiff && 1023 1298 abs(height - entry->ResInfo.icon.bHeight) == iYDiff) … … 1029 1304 #endif 1030 1305 if(iColorDiff > iTempColorDiff) 1031 {1032 bestEntry = entry;1306 { 1307 bestEntry = entry; 1033 1308 iColorDiff = iTempColorDiff; 1034 }1309 } 1035 1310 } 1036 1311 } … … 1049 1324 */ 1050 1325 static CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir, 1051 int width, int height, int color)1326 int width, int height, int color) 1052 1327 { 1053 1328 int i, maxwidth, maxheight; … … 1140 1415 //****************************************************************************** 1141 1416 //****************************************************************************** 1417 1418 //ICON cache implementation (Wine code) 1419 1420 /********************************************************************** 1421 * CURSORICON_FindSharedIcon 1422 */ 1423 static HANDLE CURSORICON_FindSharedIcon( HMODULE hModule, HRSRC hRsrc ) 1424 { 1425 HANDLE handle = 0; 1426 ICONCACHE *ptr; 1427 1428 EnterCriticalSection( &IconCrst ); 1429 1430 for ( ptr = IconAnchor; ptr; ptr = ptr->next ) 1431 if ( ptr->hModule == hModule && ptr->hRsrc == hRsrc ) 1432 { 1433 ptr->count++; 1434 handle = ptr->handle; 1435 break; 1436 } 1437 1438 LeaveCriticalSection( &IconCrst ); 1439 1440 return handle; 1441 } 1442 1443 /************************************************************************* 1444 * CURSORICON_FindCache 1445 * 1446 * Given a handle, find the corresponding cache element 1447 * 1448 * PARAMS 1449 * Handle [I] handle to an Image 1450 * 1451 * RETURNS 1452 * Success: The cache entry 1453 * Failure: NULL 1454 * 1455 */ 1456 static ICONCACHE* CURSORICON_FindCache(HANDLE handle) 1457 { 1458 ICONCACHE *ptr; 1459 ICONCACHE *pRet=NULL; 1460 BOOL IsFound = FALSE; 1461 int count; 1462 1463 EnterCriticalSection( &IconCrst ); 1464 1465 for (count = 0, ptr = IconAnchor; ptr != NULL && !IsFound; ptr = ptr->next, count++ ) 1466 { 1467 if ( handle == ptr->handle ) 1468 { 1469 IsFound = TRUE; 1470 pRet = ptr; 1471 } 1472 } 1473 1474 LeaveCriticalSection( &IconCrst ); 1475 1476 return pRet; 1477 } 1478 1479 /********************************************************************** 1480 * CURSORICON_AddSharedIcon 1481 */ 1482 static void CURSORICON_AddSharedIcon( HMODULE hModule, HRSRC hRsrc, HRSRC hGroupRsrc, HANDLE handle ) 1483 { 1484 ICONCACHE *ptr = (ICONCACHE *)HeapAlloc( GetProcessHeap(), 0, sizeof(ICONCACHE) ); 1485 if ( !ptr ) return; 1486 1487 ptr->hModule = hModule; 1488 ptr->hRsrc = hRsrc; 1489 ptr->handle = handle; 1490 ptr->hGroupRsrc = hGroupRsrc; 1491 ptr->count = 1; 1492 1493 EnterCriticalSection( &IconCrst ); 1494 ptr->next = IconAnchor; 1495 IconAnchor = ptr; 1496 LeaveCriticalSection( &IconCrst ); 1497 } 1498 1499 /********************************************************************** 1500 * CURSORICON_DelSharedIcon 1501 */ 1502 static INT CURSORICON_DelSharedIcon( HANDLE handle ) 1503 { 1504 INT count = -1; 1505 ICONCACHE *ptr; 1506 1507 EnterCriticalSection( &IconCrst ); 1508 1509 for ( ptr = IconAnchor; ptr; ptr = ptr->next ) 1510 if ( ptr->handle == handle ) 1511 { 1512 if ( ptr->count > 0 ) ptr->count--; 1513 count = ptr->count; 1514 break; 1515 } 1516 1517 LeaveCriticalSection( &IconCrst ); 1518 1519 return count; 1520 } 1521 1522 /********************************************************************** 1523 * CURSORICON_FreeModuleIcons 1524 */ 1525 void CURSORICON_FreeModuleIcons( HMODULE hModule ) 1526 { 1527 ICONCACHE **ptr = &IconAnchor; 1528 1529 EnterCriticalSection( &IconCrst ); 1530 1531 while ( *ptr ) 1532 { 1533 if ( (*ptr)->hModule == hModule ) 1534 { 1535 ICONCACHE *freePtr = *ptr; 1536 *ptr = freePtr->next; 1537 1538 #ifdef __WIN32OS2__ 1539 CURSORICON_Destroy(freePtr->handle, CID_NONSHARED); 1540 #else 1541 GlobalFree( freePtr->handle ); 1542 #endif 1543 HeapFree( GetProcessHeap(), 0, freePtr ); 1544 continue; 1545 } 1546 ptr = &(*ptr)->next; 1547 } 1548 1549 LeaveCriticalSection( &IconCrst ); 1550 } 1551
Note:
See TracChangeset
for help on using the changeset viewer.