Author: gedmurphy
Date: Wed Jan 24 18:25:43 2007
New Revision: 25615
URL:
http://svn.reactos.org/svn/reactos?rev=25615&view=rev
Log:
merge new icon/cursor selection code, cursors and radio button drawing code from head
Modified:
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_appstarting.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_cdautostart.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_cross.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_dragobject.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_hand.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_help.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_ibeam.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_icon.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_no.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_normal.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_pen.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_size.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizeall.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizenesw.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizens.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizenwse.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizewe.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_up.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_wait.cur
branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/draw.c
branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/icon.c
Modified:
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_appstarting.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified:
branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_cdautostart.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_cross.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_dragobject.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_hand.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_help.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_ibeam.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_icon.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_no.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_normal.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_pen.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_size.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizeall.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizenesw.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizens.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizenwse.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_sizewe.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_up.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/resources/ocr_wait.cur
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
Binary files - no diff available.
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/draw.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/draw.c (original)
+++ branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/draw.c Wed Jan 24 18:25:43
2007
@@ -717,123 +717,81 @@
return TRUE;
}
-/* Ported from WINE20020904 */
-/* Draw a radio/radioimage/radiomask button coming from DrawFrameControl()
- *
- * Does a pretty good job in emulating MS behavior. Some quirks are
- * however there because MS uses a TrueType font (Marlett) to draw
- * the buttons.
- */
static BOOL UITOOLS95_DFC_ButtonRadio(HDC dc, LPRECT r, UINT uFlags)
{
- RECT myr;
- int i;
- int SmallDiam = UITOOLS_MakeSquareRect(r, &myr);
- int BorderShrink = SmallDiam / 16;
- HPEN hpsave;
- HBRUSH hbsave;
- int xc, yc;
-
- if(BorderShrink < 1) BorderShrink = 1;
-
- if((uFlags & 0xff) == DFCS_BUTTONRADIOIMAGE)
- {
- FillRect(dc, r, (HBRUSH)GetStockObject(BLACK_BRUSH));
- }
-
- xc = myr.left + SmallDiam - SmallDiam/2;
- yc = myr.top + SmallDiam - SmallDiam/2;
-
- /* Define bounding box */
- i = 14*SmallDiam/16;
- myr.left = xc - i+i/2;
- myr.right = xc + i/2;
- myr.top = yc - i+i/2;
- myr.bottom = yc + i/2;
+ RECT rc;
+ LOGFONT lf;
+ HFONT hFont, hOldFont;
+ int SmallDiam, i;
+
+ LPCTSTR OutRight = TEXT("j"); // Outer right
+ LPCTSTR OutLeft = TEXT("k"); // Outer left
+ LPCTSTR InRight = TEXT("l"); // inner right
+ LPCTSTR InLeft = TEXT("m"); // inner left
+ LPCTSTR Center = TEXT("n"); // center
+
+ SmallDiam = UITOOLS_MakeSquareRect(r, &rc);
+
+ ZeroMemory(&lf, sizeof(LOGFONT));
+ lf.lfHeight = SmallDiam;
+ lf.lfWidth = 0;
+ lf.lfWeight = FW_NORMAL;
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lstrcpy(lf.lfFaceName, TEXT("Marlett"));
+ hFont = CreateFontIndirect(&lf);
+ hOldFont = SelectObject(dc, hFont);
if((uFlags & 0xff) == DFCS_BUTTONRADIOMASK)
{
- hbsave = (HBRUSH)SelectObject(dc, GetStockObject(BLACK_BRUSH));
- Ellipse(dc, myr.left, myr.top, myr.right, myr.bottom);
- SelectObject(dc, hbsave);
+ SetBkMode(dc, OPAQUE);
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
+ TextOut(dc, rc.left, rc.top, Center, 1);
+ SetBkMode(dc, TRANSPARENT);
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
+ TextOut(dc, rc.left, rc.top, OutRight, 1);
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
+ TextOut(dc, rc.left, rc.top, OutLeft, 1);
}
else
{
- if(uFlags & (DFCS_FLAT|DFCS_MONO))
- {
- hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_WINDOWFRAME));
- hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
- Ellipse(dc, myr.left, myr.top, myr.right, myr.bottom);
- SelectObject(dc, hbsave);
- SelectObject(dc, hpsave);
+ SetBkMode(dc, TRANSPARENT);
+
+ /* Center section, white for active, grey for inactive */
+ i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
+ SetTextColor(dc, GetSysColor(i));
+ TextOut(dc, rc.left, rc.top, Center, 1);
+
+ if(uFlags & (DFCS_FLAT | DFCS_MONO))
+ {
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
+ TextOut(dc, rc.left, rc.top, OutRight, 1);
+ TextOut(dc, rc.left, rc.top, OutLeft, 1);
+ TextOut(dc, rc.left, rc.top, InRight, 1);
+ TextOut(dc, rc.left, rc.top, InLeft, 1);
}
else
{
- hpsave = (HPEN)SelectObject(dc, GetSysColorPen(COLOR_BTNHIGHLIGHT));
- hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(COLOR_BTNHIGHLIGHT));
- Pie(dc, myr.left, myr.top, myr.right+1, myr.bottom+1, myr.left-1, myr.bottom,
myr.right+1, myr.top);
-
- SelectObject(dc, GetSysColorPen(COLOR_BTNSHADOW));
- SelectObject(dc, GetSysColorBrush(COLOR_BTNSHADOW));
- Pie(dc, myr.left, myr.top, myr.right+1, myr.bottom+1, myr.right+1, myr.top,
myr.left-1, myr.bottom);
-
- myr.left += BorderShrink;
- myr.right -= BorderShrink;
- myr.top += BorderShrink;
- myr.bottom -= BorderShrink;
-
- SelectObject(dc, GetSysColorPen(COLOR_3DLIGHT));
- SelectObject(dc, GetSysColorBrush(COLOR_3DLIGHT));
- Pie(dc, myr.left, myr.top, myr.right+1, myr.bottom+1, myr.left-1, myr.bottom,
myr.right+1, myr.top);
-
- SelectObject(dc, GetSysColorPen(COLOR_3DDKSHADOW));
- SelectObject(dc, GetSysColorBrush(COLOR_3DDKSHADOW));
- Pie(dc, myr.left, myr.top, myr.right+1, myr.bottom+1, myr.right+1, myr.top,
myr.left-1, myr.bottom);
- SelectObject(dc, hbsave);
- SelectObject(dc, hpsave);
+ SetTextColor(dc, GetSysColor(COLOR_BTNSHADOW));
+ TextOut(dc, rc.left, rc.top, OutRight, 1);
+ SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
+ TextOut(dc, rc.left, rc.top, OutLeft, 1);
+ SetTextColor(dc, GetSysColor(COLOR_3DDKSHADOW));
+ TextOut(dc, rc.left, rc.top, InRight, 1);
+ SetTextColor(dc, GetSysColor(COLOR_3DLIGHT));
+ TextOut(dc, rc.left, rc.top, InLeft, 1);
}
-
- i = 10*SmallDiam/16;
- myr.left = xc - i+i/2;
- myr.right = xc + i/2;
- myr.top = yc - i+i/2;
- myr.bottom = yc + i/2;
- i= !(uFlags & (DFCS_INACTIVE|DFCS_PUSHED)) ? COLOR_WINDOW : COLOR_BTNFACE;
- hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
- hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
- Ellipse(dc, myr.left, myr.top, myr.right, myr.bottom);
- SelectObject(dc, hbsave);
- SelectObject(dc, hpsave);
}
if(uFlags & DFCS_CHECKED)
{
- i = 6*SmallDiam/16;
- i = i < 1 ? 1 : i;
- myr.left = xc - i+i/2;
- myr.right = xc + i/2;
- myr.top = yc - i+i/2;
- myr.bottom = yc + i/2;
-
- i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_WINDOWTEXT;
- hbsave = (HBRUSH)SelectObject(dc, GetSysColorBrush(i));
- hpsave = (HPEN)SelectObject(dc, GetSysColorPen(i));
- Ellipse(dc, myr.left, myr.top, myr.right, myr.bottom);
- SelectObject(dc, hpsave);
- SelectObject(dc, hbsave);
- }
-
- /* FIXME: M$ has a Polygon in the center at relative points: */
- /* 0.476, 0.476 (times SmallDiam, SmallDiam) */
- /* 0.476, 0.525 */
- /* 0.500, 0.500 */
- /* 0.500, 0.499 */
- /* when the button is unchecked. The reason for it is unknown. The */
- /* color is COLOR_BTNHIGHLIGHT, although the Polygon gets painted at */
- /* least 3 times (it looks like a clip-region when you see it happen). */
- /* I do not really see a reason why this should be implemented. If you */
- /* have a good reason, let me know. Maybe this is a quirk in the Marlett */
- /* font. */
+ LPCTSTR Check = TEXT("i");
+
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
+ TextOut(dc, rc.left, rc.top, Check, 1);
+ }
+
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
+ SelectObject(dc, hOldFont);
return TRUE;
}
Modified: branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/icon.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-branch-0_3_1/reactos/dll/wi…
==============================================================================
--- branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/icon.c (original)
+++ branches/ros-branch-0_3_1/reactos/dll/win32/user32/windows/icon.c Wed Jan 24 18:25:43
2007
@@ -247,10 +247,10 @@
if (! fIcon)
{
wXHotspot = *(WORD*)pbIconBits;
- pbIconBits+=sizeof(WORD);
+ pbIconBits += sizeof(WORD);
wYHotspot = *(WORD*)pbIconBits;
- pbIconBits+=sizeof(WORD);
- cbIconBits-=2*sizeof(WORD);
+ pbIconBits += sizeof(WORD);
+ cbIconBits -= 2 * sizeof(WORD);
}
else
{
@@ -266,7 +266,7 @@
}
memcpy(SafeIconImage, pbIconBits, cbIconBits);
- /* take into acount the origonal height was for both the AND and XOR images */
+ /* take into acount the original height was for both the AND and XOR images */
if(fIcon)
SafeIconImage->icHeader.biHeight /= 2;
@@ -326,7 +326,7 @@
return (HICON)0;
}
/* FIXME - does there really *have* to be a color bitmap? monochrome cursors don't
have one */
- if(IconInfo->hbmColor && !GetObjectW(IconInfo->hbmColor, sizeof(BITMAP),
&ColorBitmap))
+ if(/*IconInfo->hbmColor &&*/ !GetObjectW(IconInfo->hbmColor,
sizeof(BITMAP), &ColorBitmap))
{
return (HICON)0;
}
@@ -440,35 +440,47 @@
PBYTE presbits,
BOOL fIcon)
{
- return LookupIconIdFromDirectoryEx( presbits, fIcon,
- fIcon ? GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXCURSOR),
- fIcon ? GetSystemMetrics(SM_CYICON) : GetSystemMetrics(SM_CYCURSOR), LR_DEFAULTCOLOR
);
-}
-
-/* Ported from WINE20030408 */
-GRPCURSORICONDIRENTRY*
-CURSORICON_FindBestCursor( GRPCURSORICONDIR *dir, int width, int height, int colors)
-{
- int i;
- GRPCURSORICONDIRENTRY *entry, *bestEntry = NULL;
+ return LookupIconIdFromDirectoryEx(presbits,
+ fIcon,
+ fIcon ? GetSystemMetrics(SM_CXICON) :
GetSystemMetrics(SM_CXCURSOR),
+ fIcon ? GetSystemMetrics(SM_CYICON) :
GetSystemMetrics(SM_CYCURSOR),
+ LR_DEFAULTCOLOR);
+}
+
+
+
+
+
+/*
+ * The following macro function accounts for the irregularities of
+ * accessing cursor and icon resources in files and resource entries.
+ */
+typedef BOOL
+(*fnGetCIEntry)(LPVOID dir, int n, int *width, int *height, int *bits );
+
+/**********************************************************************
+ * CURSORICON_FindBestIcon
+ *
+ * Find the icon closest to the requested size and number of colors.
+ */
+static int
+CURSORICON_FindBestIcon(LPVOID dir,
+ fnGetCIEntry get_entry,
+ int Width,
+ int Height,
+ int ColorBits)
+{
+ int i, cx, cy, Bits, BestBits = 0, BestEntry = -1;
UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff;
UINT iTempXDiff, iTempYDiff, iTempColorDiff;
-
- if (dir->idCount < 1)
- {
- DPRINT("Empty directory!\n");
- return NULL;
- }
- if (dir->idCount == 1)
- return &dir->idEntries[0]; /* No choice... */
/* Find Best Fit */
iTotalDiff = 0xFFFFFFFF;
iColorDiff = 0xFFFFFFFF;
- for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
- {
- iTempXDiff = abs(width - entry->ResInfo.icon.bWidth);
- iTempYDiff = abs(height - entry->ResInfo.icon.bHeight);
+ for (i = 0; get_entry(dir, i, &cx, &cy, &Bits); i++ )
+ {
+ iTempXDiff = abs(Width - cx);
+ iTempYDiff = abs(Height - cy);
if(iTotalDiff > (iTempXDiff + iTempYDiff))
{
@@ -479,49 +491,52 @@
}
/* Find Best Colors for Best Fit */
- for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
- {
- if(abs(width - entry->ResInfo.icon.bWidth) == (int) iXDiff &&
- abs(height - entry->ResInfo.icon.bHeight) == (int) iYDiff)
+ for (i = 0; get_entry(dir, i, &cx, &cy, &Bits); i++ )
+ {
+ if(abs(Width - cx) == iXDiff && abs(Height - cy) == iYDiff)
{
- iTempColorDiff = abs(colors - entry->ResInfo.icon.bColorCount);
-
+ iTempColorDiff = abs(ColorBits - Bits);
if(iColorDiff > iTempColorDiff)
- {
- bestEntry = entry;
+ {
+ BestEntry = i;
+ BestBits = Bits;
iColorDiff = iTempColorDiff;
- }
+ }
}
}
- return bestEntry;
-}
-
-/* Ported from WINE20030408 */
-GRPCURSORICONDIRENTRY*
-CURSORICON_FindBestIcon( GRPCURSORICONDIR *dir, int width, int height, int colorbits)
-{
- int i;
- GRPCURSORICONDIRENTRY *entry, *bestEntry = NULL;
+ DPRINT("Best Icon: ResId: %d, bits : %d\n", BestEntry, BestBits);
+
+ return BestEntry;
+}
+
+
+
+/**********************************************************************
+ * CURSORICON_FindBestCursor
+ *
+ * Find the cursor closest to the requested size.
+ * FIXME: parameter 'color' ignored and entries with more than 1 bpp
+ * ignored too
+ */
+static int
+CURSORICON_FindBestCursor(LPVOID dir,
+ fnGetCIEntry get_entry,
+ int Width,
+ int Height,
+ int ColorBits)
+{
+ int i, cx, cy, Bits, BestBits = 0, BestEntry = -1;
UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff;
UINT iTempXDiff, iTempYDiff, iTempColorDiff;
-
- if (dir->idCount < 1)
- {
- DPRINT("Empty directory!\n");
- return NULL;
- }
- if (dir->idCount == 1)
- return &dir->idEntries[0]; /* No choice... */
/* Find Best Fit */
iTotalDiff = 0xFFFFFFFF;
iColorDiff = 0xFFFFFFFF;
- for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
- {
- iTempXDiff = abs(width - entry->ResInfo.icon.bWidth);
-
- iTempYDiff = abs(height - entry->ResInfo.icon.bHeight);
+ for (i = 0; get_entry(dir, i, &cx, &cy, &Bits); i++ )
+ {
+ iTempXDiff = abs(Width - cx);
+ iTempYDiff = abs(Height - cy);
if(iTotalDiff > (iTempXDiff + iTempYDiff))
{
@@ -529,68 +544,141 @@
iYDiff = iTempYDiff;
iTotalDiff = iXDiff + iYDiff;
}
- }
+ }
/* Find Best Colors for Best Fit */
- for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
- {
- if(abs(width - entry->ResInfo.icon.bWidth) == (int) iXDiff &&
- abs(height - entry->ResInfo.icon.bHeight) == (int) iYDiff)
+ for (i = 0; get_entry(dir, i, &cx, &cy, &Bits); i++ )
+ {
+ if(abs(Width - cx) == iXDiff && abs(Height - cy) == iYDiff)
{
- iTempColorDiff = abs(colorbits - entry->wBitCount);
+ iTempColorDiff = abs(ColorBits - Bits);
if(iColorDiff > iTempColorDiff)
{
- bestEntry = entry;
+ BestEntry = i;
+ BestBits = Bits;
iColorDiff = iTempColorDiff;
}
}
}
- return bestEntry;
-}
-
-/* Ported from WINE20030408 */
-/*
- * @implemented
- */
-INT STDCALL
-LookupIconIdFromDirectoryEx(
- PBYTE presbits,
- BOOL fIcon,
- int cxDesired,
- int cyDesired,
- UINT Flags)
-{
- GRPCURSORICONDIR *dir = (GRPCURSORICONDIR*)presbits;
- UINT retVal = 0;
-
- if (dir && !dir->idReserved && (IMAGE_ICON == dir->idType ||
IMAGE_CURSOR == dir->idType))
- {
- GRPCURSORICONDIRENTRY *entry;
- HDC hdc;
- int ColorBits;
-
- hdc = CreateICW(NULL, NULL, NULL, NULL);
- if (Flags & LR_MONOCHROME)
- {
- ColorBits = 1;
- }
- else
- {
- ColorBits = GetDeviceCaps(hdc, BITSPIXEL);
- if (ColorBits > 8)
- ColorBits = 8;
- }
- DeleteDC(hdc);
-
- entry = CURSORICON_FindBestIcon( dir, cxDesired, cyDesired, ColorBits );
-
- if (entry)
- retVal = entry->nID;
- }
- else
- {
- DbgPrint("invalid resource directory\n");
- }
- return retVal;
-}
+ DPRINT("Best Cursor: ResId: %d, bits : %d\n", BestEntry, BestBits);
+
+ return BestEntry;
+}
+
+
+static BOOL
+CURSORICON_GetResIconEntry(LPVOID dir,
+ int n,
+ int *Width,
+ int *Height,
+ int *Bits)
+{
+ GRPCURSORICONDIR *ResDir = dir;
+ ICONRESDIR *Icon;
+
+ if (ResDir->idCount <= n)
+ return FALSE;
+
+ Icon = &ResDir->idEntries[n].ResInfo.icon;
+ *Width = Icon->bWidth;
+ *Height = Icon->bHeight;
+ *Bits = ResDir->idEntries[n].wBitCount;
+ return TRUE;
+}
+
+static BOOL
+CURSORICON_GetResCursorEntry(LPVOID dir,
+ int n,
+ int *Width,
+ int *Height,
+ int *Bits)
+{
+ GRPCURSORICONDIR *ResDir = dir;
+ CURSORRESDIR *Cursor;
+
+ if (ResDir->idCount <= n)
+ return FALSE;
+
+ Cursor = &ResDir->idEntries[n].ResInfo.cursor;
+ *Width = Cursor->wWidth;
+ *Height = Cursor->wHeight;
+ *Bits = ResDir->idEntries[n].wBitCount;
+ return TRUE;
+}
+
+static GRPCURSORICONDIRENTRY *
+CURSORICON_FindBestIconRes(GRPCURSORICONDIR * dir,
+ int Width,
+ int Height,
+ int ColorBits)
+{
+ int n;
+ n = CURSORICON_FindBestIcon(dir,
+ CURSORICON_GetResIconEntry,
+ Width,
+ Height,
+ ColorBits);
+ if (n < 0)
+ return NULL;
+
+ return &dir->idEntries[n];
+}
+
+static GRPCURSORICONDIRENTRY *
+CURSORICON_FindBestCursorRes(GRPCURSORICONDIR *dir,
+ int Width,
+ int Height,
+ int ColorBits)
+{
+ int n;
+ n = CURSORICON_FindBestCursor(dir,
+ CURSORICON_GetResCursorEntry,
+ Width,
+ Height,
+ ColorBits);
+ if (n < 0)
+ return NULL;
+
+ return &dir->idEntries[n];
+}
+
+
+INT WINAPI
+LookupIconIdFromDirectoryEx(PBYTE xdir,
+ BOOL bIcon,
+ INT width,
+ INT height,
+ UINT cFlag)
+{
+ GRPCURSORICONDIR *dir = (GRPCURSORICONDIR*)xdir;
+ UINT retVal = 0;
+ if(dir && !dir->idReserved && (IMAGE_ICON == dir->idType ||
IMAGE_CURSOR == dir->idType))
+ {
+ GRPCURSORICONDIRENTRY *entry = NULL;
+ int ColorBits;
+
+ if (cFlag & LR_MONOCHROME)
+ {
+ ColorBits = 1;
+ }
+ else
+ {
+ HDC hdc = CreateICW(NULL, NULL, NULL, NULL);
+ ColorBits = GetDeviceCaps(hdc, BITSPIXEL);
+ DeleteDC(hdc);
+ }
+
+ if(bIcon)
+ entry = CURSORICON_FindBestIconRes(dir, width, height, ColorBits);
+ else
+ entry = CURSORICON_FindBestCursorRes(dir, width, height, 1);
+
+ if (entry)
+ retVal = entry->nID;
+ }
+ else
+ DPRINT1("%s() : Invalid resource directory\n", __FUNCTION__);
+
+ return retVal;
+}