Commit caf81dc0 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

Implemented ImageList_GetDragImage.

Fixed ImageList_SetDragCursorImage and ImageList_Merge. No need for StretchBlt in ImageList_BeginDrag. Added some traces.
parent 97ba6732
...@@ -41,12 +41,14 @@ DEFAULT_DEBUG_CHANNEL(imagelist); ...@@ -41,12 +41,14 @@ DEFAULT_DEBUG_CHANNEL(imagelist);
/* internal image list data used for Drag & Drop operations */ /* internal image list data used for Drag & Drop operations */
static HIMAGELIST himlInternalDrag = NULL; static HIMAGELIST himlInternalDrag = NULL;
/* offset of the Hotspot to the origin of the himlInternalDrag image */
static INT nInternalDragHotspotX = 0; static INT nInternalDragHotspotX = 0;
static INT nInternalDragHotspotY = 0; static INT nInternalDragHotspotY = 0;
static HWND hwndInternalDrag = 0; static HWND hwndInternalDrag = 0;
static INT xInternalPos = 0; /* coordinates of the Hotspot relative to the window origin */
static INT yInternalPos = 0; static INT nInternalDragPosX = 0;
static INT nInternalDragPosY = 0;
static HDC hdcBackBuffer = 0; static HDC hdcBackBuffer = 0;
static HBITMAP hbmBackBuffer = 0; static HBITMAP hbmBackBuffer = 0;
...@@ -703,18 +705,22 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack, ...@@ -703,18 +705,22 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
INT dxHotspot, INT dyHotspot) INT dxHotspot, INT dyHotspot)
{ {
HDC hdcSrc, hdcDst; HDC hdcSrc, hdcDst;
INT cx, cy;
FIXME("partially implemented!\n"); FIXME("partially implemented!\n");
TRACE("(himlTrack=%p iTrack=%d dx=%d dy=%d)\n", himlTrack, iTrack,
dxHotspot, dyHotspot);
if (himlTrack == NULL) if (himlTrack == NULL)
return FALSE; return FALSE;
cx = himlTrack->cx;
cy = himlTrack->cy;
if (himlInternalDrag) if (himlInternalDrag)
ImageList_EndDrag (); ImageList_EndDrag ();
himlInternalDrag = himlInternalDrag = ImageList_Create (cx, cy, himlTrack->flags, 1, 1);
ImageList_Create (himlTrack->cx, himlTrack->cy,
himlTrack->flags, 1, 1);
if (himlInternalDrag == NULL) { if (himlInternalDrag == NULL) {
ERR("Error creating drag image list!\n"); ERR("Error creating drag image list!\n");
return FALSE; return FALSE;
...@@ -729,14 +735,12 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack, ...@@ -729,14 +735,12 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
/* copy image */ /* copy image */
SelectObject (hdcSrc, himlTrack->hbmImage); SelectObject (hdcSrc, himlTrack->hbmImage);
SelectObject (hdcDst, himlInternalDrag->hbmImage); SelectObject (hdcDst, himlInternalDrag->hbmImage);
StretchBlt (hdcDst, 0, 0, himlInternalDrag->cx, himlInternalDrag->cy, hdcSrc, BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY);
iTrack * himlTrack->cx, 0, himlTrack->cx, himlTrack->cy, SRCCOPY);
/* copy mask */ /* copy mask */
SelectObject (hdcSrc, himlTrack->hbmMask); SelectObject (hdcSrc, himlTrack->hbmMask);
SelectObject (hdcDst, himlInternalDrag->hbmMask); SelectObject (hdcDst, himlInternalDrag->hbmMask);
StretchBlt (hdcDst, 0, 0, himlInternalDrag->cx, himlInternalDrag->cy, hdcSrc, BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY);
iTrack * himlTrack->cx, 0, himlTrack->cx, himlTrack->cy, SRCCOPY);
DeleteDC (hdcSrc); DeleteDC (hdcSrc);
DeleteDC (hdcDst); DeleteDC (hdcDst);
...@@ -1028,6 +1032,8 @@ ImageList_Destroy (HIMAGELIST himl) ...@@ -1028,6 +1032,8 @@ ImageList_Destroy (HIMAGELIST himl)
BOOL WINAPI BOOL WINAPI
ImageList_DragEnter (HWND hwndLock, INT x, INT y) ImageList_DragEnter (HWND hwndLock, INT x, INT y)
{ {
TRACE("(hwnd=%#x x=%d y=%d)\n", hwndLock, x, y);
if (himlInternalDrag == NULL) if (himlInternalDrag == NULL)
return FALSE; return FALSE;
...@@ -1036,8 +1042,8 @@ ImageList_DragEnter (HWND hwndLock, INT x, INT y) ...@@ -1036,8 +1042,8 @@ ImageList_DragEnter (HWND hwndLock, INT x, INT y)
else else
hwndInternalDrag = GetDesktopWindow (); hwndInternalDrag = GetDesktopWindow ();
xInternalPos = x; nInternalDragPosX = x;
yInternalPos = y; nInternalDragPosY = y;
hdcBackBuffer = CreateCompatibleDC (0); hdcBackBuffer = CreateCompatibleDC (0);
hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer, hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer,
...@@ -1100,10 +1106,12 @@ ImageList_DragLeave (HWND hwndLock) ...@@ -1100,10 +1106,12 @@ ImageList_DragLeave (HWND hwndLock)
BOOL WINAPI BOOL WINAPI
ImageList_DragMove (INT x, INT y) ImageList_DragMove (INT x, INT y)
{ {
TRACE("(x=%d y=%d)\n", x, y);
ImageList_DragShowNolock (FALSE); ImageList_DragShowNolock (FALSE);
xInternalPos = x; nInternalDragPosX = x;
yInternalPos = y; nInternalDragPosY = y;
ImageList_DragShowNolock (TRUE); ImageList_DragShowNolock (TRUE);
...@@ -1457,10 +1465,17 @@ ImageList_GetBkColor (HIMAGELIST himl) ...@@ -1457,10 +1465,17 @@ ImageList_GetBkColor (HIMAGELIST himl)
HIMAGELIST WINAPI HIMAGELIST WINAPI
ImageList_GetDragImage (POINT *ppt, POINT *pptHotspot) ImageList_GetDragImage (POINT *ppt, POINT *pptHotspot)
{ {
FIXME("semi-stub!\n"); if (himlInternalDrag) {
if (ppt) {
if (himlInternalDrag) ppt->x = nInternalDragPosX;
ppt->y = nInternalDragPosY;
}
if (pptHotspot) {
pptHotspot->x = nInternalDragHotspotX;
pptHotspot->y = nInternalDragHotspotY;
}
return (himlInternalDrag); return (himlInternalDrag);
}
return NULL; return NULL;
} }
...@@ -1834,6 +1849,9 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2, ...@@ -1834,6 +1849,9 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
INT xOff1, yOff1, xOff2, yOff2; INT xOff1, yOff1, xOff2, yOff2;
INT nX1, nX2; INT nX1, nX2;
TRACE("(himl1=%p i1=%d himl2=%p i2=%d dx=%d dy=%d)\n", himl1, i1, himl2,
i2, dx, dy);
if ((himl1 == NULL) || (himl2 == NULL)) if ((himl1 == NULL) || (himl2 == NULL))
return NULL; return NULL;
...@@ -1918,6 +1936,7 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2, ...@@ -1918,6 +1936,7 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
DeleteDC (hdcSrcImage); DeleteDC (hdcSrcImage);
DeleteDC (hdcDstImage); DeleteDC (hdcDstImage);
himlDst->cCurImage = 1;
} }
return himlDst; return himlDst;
...@@ -2479,8 +2498,7 @@ ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag, ...@@ -2479,8 +2498,7 @@ ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag,
INT dxHotspot, INT dyHotspot) INT dxHotspot, INT dyHotspot)
{ {
HIMAGELIST himlTemp; HIMAGELIST himlTemp;
INT dx, dy;
FIXME("semi-stub!\n");
if (himlInternalDrag == NULL) if (himlInternalDrag == NULL)
return FALSE; return FALSE;
...@@ -2488,16 +2506,28 @@ ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag, ...@@ -2488,16 +2506,28 @@ ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag,
TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n", TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n",
dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY); dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag, /* Calculate the offset between the origin of the old image and the
dxHotspot, dyHotspot); * origin of the second image.
* dxHotspot, dyHotspot is the offset of THE Hotspot (there is only one
* hotspot) to the origin of the second image (himlDrag).
* See M$DN for details */
dx = nInternalDragHotspotX - dxHotspot;
dy = nInternalDragHotspotY - dyHotspot;
himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag, dx, dy);
ImageList_Destroy (himlInternalDrag); ImageList_Destroy (himlInternalDrag);
himlInternalDrag = himlTemp; himlInternalDrag = himlTemp;
nInternalDragHotspotX = dxHotspot; /* update the InternalDragOffset, if the origin of the origin of the
nInternalDragHotspotY = dyHotspot; * DragImage was changed by ImageList_Merge. */
if (dx > nInternalDragHotspotX) {
nInternalDragHotspotX = dx;
}
if (dy > nInternalDragHotspotY) {
nInternalDragHotspotY = dy;
}
return FALSE; return TRUE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment