Release 951105
Fri Nov 3 20:08:17 1995 Alexandre Julliard <julliard@sunsite.unc.edu>
* [configure.in]
Attempt to check for -li386 on NetBSD. Please test this.
Mon Oct 30 12:40:32 EST 1995 Jim Peterson <jspeter@birch.ee.vt.edu>
* [*/*]
Eliminated various warnings with either explicit casts or more
accurate variable/parameter declarations (e.g. INT instead of short
or WORD).
Changed macros 'min' and 'max' to 'MIN' and 'MAX', since they're
macros.
* [controls/edit.c] [windows/defdlg.c]
Added '#ifdef SUPERFLUOUS_FUNCTIONS' wrappers around function
definition of EDIT_KeyVScrollDoc, EDIT_TextLineNumber, and
DEFDLG_FindDefButton to avoid warnings.
* [controls/button.c] [controls/scroll.c] [windows/defwnd.c]
[windows/message.c] [windows/nonclient.c]
Converted MAKEPOINT macro call to manual conversion.
* [include/windows.h]
For WINELIB32, structures POINT, SIZE, and RECT have LONG members
instead of INT. This also invalidates the macro MAKEPOINT(), which
is not supported in Win32. Also defined the POINTS structure (SHORT
members) and the MAKEPOINTS macro.
* [misc/commdlg.c]
Changed a lot of 'strcpy' calls to 'strncpy' calls. I'm desperate to
find this memory bug, and this should be done anyway.
* [controls/edit.c]
Well, the alteration mentioned above didn't do it, but #ifdef'ing out
a few lines in EDIT_ClearText did. This leads to bugs, but for now,
it's better than bizzare memory troubles.
* [toolkit/miscstubs.c]
Removed warning messages in GLOBAL_CreateBlock(), GLOBAL_FreeBlock(),
and RELAY32_GetEntryPoint(). These are the most popular warnings, and
their current implementation seems fine.
Sat Oct 28 09:39:18 1995 Jochen Karrer <cip307@wpax01.Physik.Uni-Wuerzburg.DE>
* [objects/cursoricon.c]
Fix for "broken" X servers that invert masked cursor colors.
Fri Oct 27 19:27:21 1995 Alex Korobka <alex@phm6.pharm.sunysb.edu>
* [windows/dialog.c] [windows/nonclient.c]
Remove unnecessary items from the system menu.
Thu Oct 26 05:03:03 MET 1995 Philippe De Muyter <phdm@info.ucl.ac.be>
* [objects/color.c] [objects/palette.c]
Make GetNearestColor return a RGB value instead of a pixel value.
Wed Oct 25 23:33:39 1995 Martin von Loewis <loewis@informatik.hu-berlin.de>
* [controls/desktop.c][controls/menu.c][include/menu.h]
Changed WORD parameters to UINT parameters.
* [include/wintypes.h]
Made UINT 32bit for WINELIB.
* [loader/main.c]
Disabled RELAY32_Init and MODULE_Init for WINELIB.
* [misc/main.c]
Assume CPU386 for WINELIB.
* [rc/winerc]
add_popup: set MF_POPUP flag on menu item.
* [toolkit/Makefile.in][toolkit/hello3.c][toolkit/hello3res.c]
Add resource demo hello3 for WINELIB.
New file README.resources.
* [toolkit/miscstubs.c]
Add a case for 17.
Tue Oct 17 15:13:10 IST 1995 Itai Nahshon <nahshon@vnet.ibm.com>
* [loader/module.c]
Do not append .exe if the file name already has an extension.
* [misc/profile.c]
Avoid creating a file with a junk name if a .ini file does not
exist.
* [if1632/gdi.spec] [if1632/user.spec] [if1632/dummy.c]
Added a lot of dummy stubs for Windows Hebrew version.
Tue Oct 17 01:03:24 1995 William Magro <wmagro@tc.cornell.edu>
* [controls/button.c]
Fix for buttons with no label.
* [controls/combo.c][controls/listbox.c]
Fixes for scrollbar positioning. Now disappears correctly
for short lists.
* [controls/edit.c]
Handle memory allocation differently when building as library.
* [controls/static]
Don't destroy old icon before drawing new icon. (Fixes landscape/
portrait toggle icon in print dialog.)
* [if1632/gdi.spec]
New functions SetMetaFileBits and GetMetaFileBits
* [include/sysmetrics.h] [windows/sysmetrics.c]
Add support for GetSystemMetrics(SM_CMETRICS) == SM_CMETRICS
* [include/windows.h]
META_EXTTEXTOUT, not META_SETTEXTOUT
define GetCurrentTime as GetTickCount (for wine library)
* [loader/main.c]
Don't initialize built-in modules in wine library
* [memory/local.c]
LocalReAlloc was defined incorrectly. Swap flags and size arguments.
* [misc/main.c]
Always report CPUTYPE=4 to wine library.
* [objects/dib.c]
RLE8 images were missing top line when decompressed.
* [objects/metafile.c]
SetMetaFileBits and GetMetaFileBits implemented. Works when called
from winhelp. More testing needed. Various memory leaks plugged.
Various other bug fixes. New metafile operations added in
PlayMetaFileRecord: CreatePalette, SetTextAlign, SelectPalette,
SetMapperFlags, RealizePalette, ExtTextOut, Escape. Testing needed.
* [toolkit/heap.c]
LocalUnLock changed to LocalUnlock
Sun Oct 15 21:55:33 1995 Anand Kumria <akumria@ozemail.com.au>
* [misc/winsock.c]
Return the correct error number, for host lookup operations.
Also, correct the problem with send_message.
Fri Oct 13 19:04:35 1995 Morten Welinder <terra@diku.dk>
* [Makefile.in]
Using nm's built-in sorting.
* [*/*.c]
Use xmalloc for malloc and xrealloc for realloc in all ungarded
cases.
* [debugger/dbg.y]
Handle C-like expressions. Clean-up.
* [debugger/debug.l]
Lots of new tokens for expressions.
* [debugger/info.c]
Implement "list" command for disassembling.
* [misc/ole2nls.c]
Implement more Danish stuff.
Fri Oct 6 10:39:39 1995 Ram'on Garc'ia <ramon@ie3.clubs.etsit.upm.es>
* [loader/module.c]
Updated self-loading modules to support for new 32 bit
stack frames.
diff --git a/objects/bitblt.c b/objects/bitblt.c
index ae7dd30..89ae404 100644
--- a/objects/bitblt.c
+++ b/objects/bitblt.c
@@ -17,6 +17,7 @@
#include "stddebug.h"
/* #define DEBUG_BITBLT */
#include "debug.h"
+#include "xmalloc.h"
#define DST 0 /* Destination drawable */
@@ -1063,11 +1064,11 @@
dcSrc, xSrc, ySrc, widthSrc, heightSrc,
&visRectSrc, &visRectDst ))
return TRUE;
- dprintf_bitblt( stddeb, " vissrc=%d,%d-%d,%d visdst=%d,%d-%d,%d\n",
- visRectSrc.left, visRectSrc.top,
- visRectSrc.right, visRectSrc.bottom,
- visRectDst.left, visRectDst.top,
- visRectDst.right, visRectDst.bottom );
+ dprintf_bitblt( stddeb, " vissrc=%ld,%ld-%ld,%ld visdst=%ld,%ld-%ld,%ld\n",
+ (LONG)visRectSrc.left, (LONG)visRectSrc.top,
+ (LONG)visRectSrc.right, (LONG)visRectSrc.bottom,
+ (LONG)visRectDst.left, (LONG)visRectDst.top,
+ (LONG)visRectDst.right, (LONG)visRectDst.bottom );
}
else
{
@@ -1075,9 +1076,9 @@
if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst,
NULL, 0, 0, 0, 0, NULL, &visRectDst ))
return TRUE;
- dprintf_bitblt( stddeb, " vissrc=none visdst=%d,%d-%d,%d\n",
- visRectDst.left, visRectDst.top,
- visRectDst.right, visRectDst.bottom );
+ dprintf_bitblt( stddeb, " vissrc=none visdst=%ld,%ld-%ld,%ld\n",
+ (LONG)visRectDst.left, (LONG)visRectDst.top,
+ (LONG)visRectDst.right, (LONG)visRectDst.bottom );
}
width = visRectDst.right - visRectDst.left;
diff --git a/objects/brush.c b/objects/brush.c
index 982920a..1034c40 100644
--- a/objects/brush.c
+++ b/objects/brush.c
@@ -11,6 +11,7 @@
#include "color.h"
#include "stddebug.h"
#include "debug.h"
+#include "xmalloc.h"
#define NB_HATCH_STYLES 6
diff --git a/objects/clipping.c b/objects/clipping.c
index e6a3335..08e65d7 100644
--- a/objects/clipping.c
+++ b/objects/clipping.c
@@ -311,8 +311,9 @@
RECT tmpRect;
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return FALSE;
- dprintf_clipping(stddeb,"RectVisible: "NPFMT" %d,%dx%d,%d\n",
- hdc, rect->left, rect->top, rect->right, rect->bottom );
+ dprintf_clipping(stddeb,"RectVisible: "NPFMT" %ld,%ldx%ld,%ld\n",
+ hdc, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right,
+ (LONG)rect->bottom );
if (!dc->w.hGCClipRgn) return FALSE;
/* copy rectangle to avoid overwriting by LPtoDP */
tmpRect = *rect;
diff --git a/objects/color.c b/objects/color.c
index 5941340..41e222c 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -12,6 +12,7 @@
#include "gdi.h"
#include "color.h"
#include "palette.h"
+#include "xmalloc.h"
Colormap COLOR_WinColormap = 0;
int COLOR_FixedMap = 0;
@@ -126,8 +127,8 @@
if ((COLOR_WinColormap == DefaultColormapOfScreen(screen)) && (screenDepth <= 8))
{
- COLOR_PaletteToPixel = (int *)malloc( sizeof(int) * size );
- COLOR_PixelToPalette = (int *)malloc( sizeof(int) * size );
+ COLOR_PaletteToPixel = (int *)xmalloc( sizeof(int) * size );
+ COLOR_PixelToPalette = (int *)xmalloc( sizeof(int) * size );
for (i = 0; i < size; i++) /* Set the default mapping */
COLOR_PaletteToPixel[i] = COLOR_PixelToPalette[i] = i;
}
@@ -334,6 +335,7 @@
idx = color & 0xffff;
if (idx >= palPtr->logpalette.palNumEntries)
{
+ fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is out of bounds, assuming black\n", color, idx);
/* out of bounds */
red = green = blue = 0;
}
@@ -375,12 +377,20 @@
}
if (dc&&dc->u.x.pal.mappingSize)
{
- if (index >= dc->u.x.pal.mappingSize) return 0;
+ if (index >= dc->u.x.pal.mappingSize)
+ {
+ fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is >= dc->u.x.pal.mappingSize, assuming pixel 0\n", color, index);
+ return 0;
+ }
mapping = (WORD *) GDI_HEAP_LIN_ADDR( dc->u.x.pal.hMapping );
}
else
{
- if (index >= NB_RESERVED_COLORS) return 0;
+ if (index >= NB_RESERVED_COLORS)
+ {
+ fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is >= NB_RESERVED_COLORS, assuming pixel 0\n", color, index);
+ return 0;
+ }
mapping = (WORD *) GDI_HEAP_LIN_ADDR( hSysColorTranslation );
}
if (mapping) return mapping[index];
@@ -425,20 +435,6 @@
/***********************************************************************
- * GetNearestColor (GDI.154)
- */
-COLORREF GetNearestColor( HDC hdc, COLORREF color )
-{
- WORD index;
- DC *dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
- if (!dc) return 0;
- if (screenDepth > 8) return color; /* FIXME */
- index = (WORD)(COLOR_ToPhysical( dc, color & 0xffffff ) & 0xffff);
- return PALETTEINDEX( index );
-}
-
-
-/***********************************************************************
* RealizeDefaultPalette (GDI.365)
*/
WORD RealizeDefaultPalette( HDC hdc )
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 6cc3f2a..fcb553e 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -32,6 +32,7 @@
#include "win.h"
#include "stddebug.h"
#include "debug.h"
+#include "xmalloc.h"
Cursor CURSORICON_XCursor = None; /* Current X cursor */
@@ -278,8 +279,8 @@
size = DIB_BitmapInfoSize( bmi, DIB_RGB_COLORS );
/* Make sure we have room for the monochrome bitmap later on */
- size = max( size, sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD) );
- pInfo = (BITMAPINFO *)malloc( size );
+ size = MAX( size, sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD) );
+ pInfo = (BITMAPINFO *)xmalloc( size );
memcpy( pInfo, bmi, size );
if (pInfo->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
@@ -442,7 +443,7 @@
return CURSORICON_Load( hInstance, name,
SYSMETRICS_CXICON, SYSMETRICS_CYICON,
- min( 16, 1 << screenDepth ), FALSE );
+ MIN( 16, 1 << screenDepth ), FALSE );
}
@@ -506,7 +507,7 @@
*/
HICON CopyIcon( HANDLE hInstance, HICON hIcon )
{
- dprintf_icon( stddeb, "CopyIcon: %04x %04x\n", hInstance, hIcon );
+ dprintf_icon( stddeb, "CopyIcon: "NPFMT" "NPFMT"\n", hInstance, hIcon );
return CURSORICON_Copy( hInstance, hIcon );
}
@@ -516,7 +517,7 @@
*/
HCURSOR CopyCursor( HANDLE hInstance, HCURSOR hCursor )
{
- dprintf_cursor( stddeb, "CopyCursor: %04x %04x\n", hInstance, hCursor );
+ dprintf_cursor( stddeb, "CopyCursor: "NPFMT" "NPFMT"\n", hInstance, hCursor );
return CURSORICON_Copy( hInstance, hCursor );
}
@@ -526,8 +527,9 @@
*/
BOOL DestroyIcon( HICON hIcon )
{
- dprintf_icon( stddeb, "DestroyIcon: %04x\n", hIcon );
- return GlobalFree( hIcon );
+ dprintf_icon( stddeb, "DestroyIcon: "NPFMT"\n", hIcon );
+ /* FIXME: should check for OEM icon here */
+ return (GlobalFree( hIcon ) != 0);
}
@@ -536,8 +538,9 @@
*/
BOOL DestroyCursor( HCURSOR hCursor )
{
- dprintf_cursor( stddeb, "DestroyCursor: %04x\n", hCursor );
- return GlobalFree( hCursor );
+ dprintf_cursor( stddeb, "DestroyCursor: "NPFMT"\n", hCursor );
+ /* FIXME: should check for OEM cursor here */
+ return (GlobalFree( hCursor ) != 0);
}
@@ -628,7 +631,7 @@
if (!(ptr = (CURSORICONINFO*)GlobalLock( hCursor ))) return FALSE;
if (ptr->bPlanes * ptr->bBitsPerPixel != 1)
{
- fprintf( stderr, "Cursor %04x has more than 1 bpp!\n", hCursor );
+ fprintf( stderr, "Cursor "NPFMT" has more than 1 bpp!\n", hCursor );
return FALSE;
}
@@ -672,22 +675,26 @@
* bits on the screen) to black. This require some boolean
* arithmetic:
*
- * Windows X11
- * Xor And Result Bits Mask
- * 0 0 black 0 1
- * 0 1 no change X 0
- * 1 0 white 1 1
- * 1 1 inverted 0 1 (=black)
+ * Windows | X11
+ * Xor And Result | Bits Mask Result
+ * 0 0 black | 0 1 background
+ * 0 1 no change | X 0 no change
+ * 1 0 white | 1 1 foreground
+ * 1 1 inverted | 0 1 background
*
* which gives:
- * Bits = 'Xor' xor 'And'
+ * Bits = 'Xor' and not 'And'
* Mask = 'Xor' or not 'And'
+ *
+ * FIXME: apparently some servers do support 'inverted' color.
+ * I don't know if it's correct per the X spec, but maybe
+ * we ought to take advantage of it. -- AJ
*/
XCopyArea( display, pixmapAll, pixmapBits, BITMAP_monoGC,
0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
XCopyArea( display, pixmapAll, pixmapMask, BITMAP_monoGC,
0, 0, ptr->nWidth, ptr->nHeight, 0, 0 );
- XSetFunction( display, BITMAP_monoGC, GXxor );
+ XSetFunction( display, BITMAP_monoGC, GXandReverse );
XCopyArea( display, pixmapAll, pixmapBits, BITMAP_monoGC,
0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 );
XSetFunction( display, BITMAP_monoGC, GXorReverse );
@@ -740,7 +747,7 @@
HCURSOR hOldCursor;
if (hCursor == hActiveCursor) return hActiveCursor; /* No change */
- dprintf_cursor( stddeb, "SetCursor: %04x\n", hCursor );
+ dprintf_cursor( stddeb, "SetCursor: "NPFMT"\n", hCursor );
hOldCursor = hActiveCursor;
hActiveCursor = hCursor;
/* Change the cursor shape only if it is visible */
@@ -755,7 +762,7 @@
void SetCursorPos( short x, short y )
{
dprintf_cursor( stddeb, "SetCursorPos: x=%d y=%d\n", x, y );
- XWarpPointer( display, None, rootWindow, 0, 0, 0, 0, x, y );
+ XWarpPointer( display, rootWindow, rootWindow, 0, 0, 0, 0, x, y );
}
@@ -818,7 +825,8 @@
pt->x = rootX + desktopX;
pt->y = rootY + desktopY;
}
- dprintf_cursor(stddeb, "GetCursorPos: ret=%d,%d\n", pt->x, pt->y );
+ dprintf_cursor(stddeb, "GetCursorPos: ret=%ld,%ld\n", (LONG)pt->x,
+ (LONG)pt->y );
}
@@ -836,7 +844,7 @@
*/
WORD GetIconID( HANDLE hResource, DWORD resType )
{
- fprintf( stderr, "GetIconId(%04x,%ld): empty stub!\n",
+ fprintf( stderr, "GetIconId("NPFMT",%ld): empty stub!\n",
hResource, resType );
return 0;
}
@@ -847,7 +855,7 @@
*/
HICON LoadIconHandler( HANDLE hResource, BOOL bNew )
{
- fprintf( stderr, "LoadIconHandle(%04x,%d): empty stub!\n",
+ fprintf( stderr, "LoadIconHandle("NPFMT",%d): empty stub!\n",
hResource, bNew );
return 0;
}
diff --git a/objects/dc.c b/objects/dc.c
index 7dbd68e..41c981a 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -14,6 +14,7 @@
#include "color.h"
#include "debug.h"
#include "font.h"
+#include "xmalloc.h"
static DeviceCaps * displayDevCaps = NULL;
@@ -463,7 +464,7 @@
if (!displayDevCaps)
{
- displayDevCaps = (DeviceCaps *) malloc( sizeof(DeviceCaps) );
+ displayDevCaps = (DeviceCaps *) xmalloc( sizeof(DeviceCaps) );
DC_FillDevCaps( displayDevCaps );
}
diff --git a/objects/dib.c b/objects/dib.c
index 1082b74..3c02046 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -16,6 +16,7 @@
#include "stddebug.h"
#include "color.h"
#include "debug.h"
+#include "xmalloc.h"
/***********************************************************************
@@ -280,7 +281,7 @@
BYTE *begin = bits;
lines--;
- while ((INT)lines >= 0)
+ while ((short)lines >= 0)
{
length = *bits++;
if (length) { /* encoded */
@@ -451,7 +452,7 @@
* what caused the previous implementation to
* fail. [JAY]
*/
- line=0; /* Cause exit from do loop. */
+ line=-1; /* Cause exit from do loop. */
break;
}
@@ -511,7 +512,7 @@
} /* process either an encoded sequence or an escape sequence */
/* We expect to come here more than once per line. */
- } while (line > 0); /* Do this until the bitmap is filled */
+ } while (line >= 0); /* Do this until the bitmap is filled */
/*
* Everybody comes here at the end.
diff --git a/objects/font.c b/objects/font.c
index b1a89a8..be7ac76 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -518,8 +518,9 @@
size->cy = abs((dc->u.x.font.fstruct->ascent+dc->u.x.font.fstruct->descent)
* dc->w.WndExtY / dc->w.VportExtY);
- dprintf_font(stddeb,"GetTextExtentPoint("NPFMT" '%*.*s' %d %p): returning %d,%d\n",
- hdc, count, count, str, count, size, size->cx, size->cy );
+ dprintf_font(stddeb,"GetTextExtentPoint("NPFMT" '%*.*s' %d %p): returning %ld,%ld\n",
+ hdc, count, count, str, count, size, (LONG)size->cx,
+ (LONG)size->cy );
return TRUE;
}
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index b2434125..7f0e6a3 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -18,6 +18,7 @@
#include "stddebug.h"
/* #define DEBUG_GDI */
#include "debug.h"
+#include "xmalloc.h"
LPSTR GDI_Heap = NULL;
WORD GDI_HeapSel = 0;
@@ -200,7 +201,7 @@
int i = 1;
if (hNewObj == 0) return FALSE;
if (lpPenBrushList == NULL) {
- lpPenBrushList = malloc(MAX_OBJ * sizeof(HANDLE));
+ lpPenBrushList = xmalloc(MAX_OBJ * sizeof(HANDLE));
lpPenBrushList[0] = 0;
dprintf_gdi(stddeb,"GDI_AppendToPenBrushList() lpPenBrushList allocated !\n");
}
@@ -495,7 +496,7 @@
if (header->wMagic == PEN_MAGIC) {
PEN_GetObject( (PENOBJ *)header, sizeof(LOGPEN), lpLog);
dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnStyle=%04X\n", ((LPLOGPEN)lpLog)->lopnStyle);
- dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnWidth=%d\n", ((LPLOGPEN)lpLog)->lopnWidth.x);
+ dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnWidth=%ld\n", (LONG)((LPLOGPEN)lpLog)->lopnWidth.x);
dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnColor=%08lX\n", ((LPLOGPEN)lpLog)->lopnColor);
}
nRet = CallEnumObjectsProc(lpEnumFunc, GDI_HEAP_SEG_ADDR(hLog),
diff --git a/objects/metafile.c b/objects/metafile.c
index 9628e99..e1d176e 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -50,6 +50,7 @@
strcpy(mf->Filename, lpFilename);
mf->wMagic = METAFILE_MAGIC;
if ((mf->hFile = _lopen(lpFilename, OF_READ)) == HFILE_ERROR) {
+ GlobalFree(mf->hMetaHdr);
GlobalFree(hmf);
return 0;
}
@@ -60,13 +61,16 @@
}
_lclose(mf->hFile);
+ if (mh->mtType != 1) {
+ GlobalFree(mf->hMetaHdr);
+ GlobalFree(hmf);
+ return 0;
+ }
GlobalUnlock(mf->hMetaHdr);
GlobalUnlock(hmf);
- if (mh->mtType != 1)
- return 0;
- else
- return hmf;
+ return hmf;
+
}
/******************************************************************
@@ -86,11 +90,14 @@
if (!handle) return 0;
dc = (DC *)GDI_HEAP_LIN_ADDR(handle);
- if (!(dc->w.hMetaFile = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE))))
+ if (!(dc->w.hMetaFile = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE)))) {
+ GDI_FreeObject(handle);
return 0;
+ }
mf = (METAFILE *)GlobalLock(dc->w.hMetaFile);
if (!(mf->hMetaHdr = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAHEADER))))
{
+ GDI_FreeObject(handle);
GlobalFree(dc->w.hMetaFile);
return 0;
}
@@ -108,7 +115,12 @@
{
mh->mtType = 1;
strcpy(mf->Filename, lpFilename);
+#ifndef WINELIB
mf->hFile = _lcreat(lpFilename, 0);
+#else
+ /* temporary fix until _lcreate works under WINELIB */
+ mf->hFile = creat(lpFilename, 0666);
+#endif
if (_lwrite(mf->hFile, (char *)mh, MFHEADERSIZE) == -1)
{
GlobalFree(mf->hMetaHdr);
@@ -194,7 +206,7 @@
{
METAFILE *mf = (METAFILE *)GlobalLock(hmf);
- if (mf->wMagic != METAFILE_MAGIC)
+ if (!mf || mf->wMagic != METAFILE_MAGIC)
return FALSE;
GlobalFree(mf->hMetaHdr);
@@ -437,7 +449,7 @@
case META_POLYPOLYGON:
PolyPolygon(hdc, (LPPOINT)(mr->rdParam + *(mr->rdParam) + 1),
- (mr->rdParam + 1), *(mr->rdParam));
+ (LPINT)(mr->rdParam + 1), *(mr->rdParam));
break;
case META_POLYLINE:
@@ -499,12 +511,130 @@
CreateBrushIndirect((LOGBRUSH *)(&(mr->rdParam))));
break;
+ /* W. Magro: Some new metafile operations. Not all debugged. */
+ case META_CREATEPALETTE:
+ MF_AddHandle(ht, nHandles,
+ CreatePalette((LPLOGPALETTE)mr->rdParam));
+ break;
+
+ case META_SETTEXTALIGN:
+ fprintf(stderr,"PlayMetaFileRecord: SETTEXTALIGN: %hd\n",mr->rdParam[0]);
+ SetTextAlign(hdc, *(mr->rdParam));
+ break;
+
+ case META_SELECTPALETTE:
+ SelectPalette(hdc, *(ht->objectHandle + *(mr->rdParam+1)),*(mr->rdParam));
+ break;
+
+ case META_SETMAPPERFLAGS:
+ SetMapperFlags(hdc, *(mr->rdParam));
+ break;
+
+ case META_REALIZEPALETTE:
+ RealizePalette(hdc);
+ break;
+
+ case META_ESCAPE:
+ dprintf_metafile(stddeb,"PlayMetaFileRecord: META_ESCAPE unimplemented.\n");
+ break;
+
+ case META_EXTTEXTOUT: /* FIXME: don't know the exact parameters here */
+ {
+ short x,y,options,x5,x6,x7,x8;
+ y=mr->rdParam[0]; /* X position */
+ x=mr->rdParam[1]; /* Y position */
+ s1=mr->rdParam[2]; /* String length */
+ options=mr->rdParam[3];
+ x5=mr->rdParam[(s1+1)/2+4]; /* unknown meaning */
+ x6=mr->rdParam[(s1+1)/2+5]; /* unknown meaning */
+ x7=mr->rdParam[(s1+1)/2+6]; /* unknown meaning */
+ x8=mr->rdParam[(s1+1)/2+7]; /* unknown meaning */
+ ExtTextOut(hdc, x, y, options, (LPRECT) &mr->rdParam[(s1+1)/2+4], (char *)(mr->rdParam + 4), s1, NULL);
+ /* fprintf(stderr,"EXTTEXTOUT (len: %d) %hd : %hd %hd %hd %hd [%s].\n",
+ (mr->rdSize-s1),options,x5,x6,x7,x8,(char*) &(mr->rdParam[4]) );*/
+ }
+ break;
+ /* End new metafile operations. */
+
default:
- fprintf(stderr,"PlayMetaFileRecord: Unknown record type %x\n",
+ fprintf(stddeb,"PlayMetaFileRecord: Unknown record type %x\n",
mr->rdFunction);
}
}
+/******************************************************************
+ * GetMetaFileBits by William Magro, 19 Sep 1995
+ *
+ * Trade in a meta file object handle for a handle to the meta file memory
+ */
+HANDLE GetMetaFileBits(HMETAFILE hmf)
+{
+
+ /* save away the meta file bits handle */
+ METAFILE *mf = (METAFILE *)GlobalLock(hmf);
+ HANDLE hMem = mf->hMetaHdr;
+ METAHEADER *mh = (METAHEADER *)GlobalLock(hMem);
+
+ dprintf_metafile(stddeb,"GetMetaFileBits: hmf in: %x\n", hmf);
+
+ /* can't get bits of disk based metafile */
+ /* FIXME: should the disk file be loaded in this case? */
+ if(mh->mtType == 1) {
+ fprintf(stderr,
+ "GetMetaFileBits: application requested bits of disk meta file.\n");
+ GlobalUnlock(hMem);
+ GlobalUnlock(hmf);
+ return FALSE;
+ }
+
+ /* unlock the memory and invalidate the metafile handle */
+ GlobalUnlock(hMem);
+ GlobalFree(hmf);
+
+ dprintf_metafile(stddeb,"GetMetaFileBits: hMem out: %x\n", hMem);
+
+ return hMem;
+}
+
+/******************************************************************
+ * SetMetaFileBits by William Magro, 19 Sep 1995
+ *
+ * Trade in a meta file memory handle for a handle to a meta file object
+ */
+HMETAFILE SetMetaFileBits(HANDLE hMem)
+{
+ HMETAFILE hmf;
+ METAFILE *mf;
+ METAHEADER *mh = (METAHEADER *)GlobalLock(hMem);
+
+ dprintf_metafile(stddeb,"SetMetaFileBits: hMem in: %x\n", hMem);
+
+ if (!mh) return FALSE;
+
+ /* now it is a memory meta file */
+ mh->mtType = 0;
+
+ hmf = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE));
+ mf = (METAFILE *)GlobalLock(hmf);
+ if (!mf) {
+ GlobalUnlock(hMem);
+ GlobalFree(hmf);
+ return FALSE;
+ }
+
+ /* use the supplied memory handle */
+ mf->hMetaHdr = hMem;
+ mf->wMagic = METAFILE_MAGIC;
+ mf->MetaOffset = mh->mtHeaderSize * 2;
+ mf->hFile = mf->hBuffer = (HANDLE) NULL;
+
+ GlobalUnlock(hMem);
+ GlobalUnlock(hmf);
+
+ dprintf_metafile(stddeb,"SetMetaFileBits: hmf out: %x\n", hmf);
+
+ return hmf;
+}
/******************************************************************
* MF_WriteRecord
@@ -538,7 +668,7 @@
}
mh->mtSize += rlen / 2;
- mh->mtMaxRecord = max(mh->mtMaxRecord, rlen / 2);
+ mh->mtMaxRecord = MAX(mh->mtMaxRecord, rlen / 2);
GlobalUnlock(mf->hMetaHdr);
return TRUE;
}
diff --git a/objects/palette.c b/objects/palette.c
index 7fa2cfe..ccd0b42 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -23,6 +23,56 @@
static WORD SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
+
+/***********************************************************************
+ * PALETTE_GetNearestIndexAndColor
+ */
+static WORD PALETTE_GetNearestIndexAndColor(HPALETTE hpalette, COLORREF *color)
+{
+ int i, minDist, dist;
+ WORD index = 0;
+ BYTE r, g, b;
+ PALETTEENTRY * entry;
+ PALETTEOBJ * palPtr;
+
+ palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
+ if (!palPtr) return 0;
+
+ if ((COLOR_WinColormap != DefaultColormapOfScreen(screen)) &&
+ (hpalette == STOCK_DEFAULT_PALETTE))
+ {
+ if ((*color & 0xffffff) == 0) return 0; /* Entry 0 is black */
+ if ((*color & 0xffffff) == 0xffffff) /* Max entry is white */
+ return palPtr->logpalette.palNumEntries - 1;
+ }
+
+ r = GetRValue(*color);
+ g = GetGValue(*color);
+ b = GetBValue(*color);
+
+ entry = palPtr->logpalette.palPalEntry;
+ for (i = 0, minDist = MAXINT; minDist !=0 &&
+ i < palPtr->logpalette.palNumEntries ; i++)
+ {
+ if (entry->peFlags != 0xff)
+ {
+ dist = (r - entry->peRed) * (r - entry->peRed) +
+ (g - entry->peGreen) * (g - entry->peGreen) +
+ (b - entry->peBlue) * (b - entry->peBlue);
+ if (dist < minDist)
+ {
+ minDist = dist;
+ index = i;
+ }
+ }
+ entry++;
+ }
+ entry = &palPtr->logpalette.palPalEntry[index];
+ *color = RGB( entry->peRed, entry->peGreen, entry->peBlue );
+ return index;
+}
+
+
/***********************************************************************
* CreatePalette (GDI.360)
*/
@@ -145,51 +195,30 @@
*/
WORD GetNearestPaletteIndex( HPALETTE hpalette, COLORREF color )
{
- int i, minDist, dist;
- WORD index = 0;
- BYTE r, g, b;
- PALETTEENTRY * entry;
- PALETTEOBJ * palPtr;
-
- palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
- if (!palPtr) return 0;
-
- if ((COLOR_WinColormap != DefaultColormapOfScreen(screen)) &&
- (hpalette == STOCK_DEFAULT_PALETTE))
- {
- if ((color & 0xffffff) == 0) return 0; /* Entry 0 is black */
- if ((color & 0xffffff) == 0xffffff) /* Max entry is white */
- return palPtr->logpalette.palNumEntries - 1;
- }
-
- r = GetRValue(color);
- g = GetGValue(color);
- b = GetBValue(color);
-
- entry = palPtr->logpalette.palPalEntry;
- for (i = 0, minDist = MAXINT; minDist !=0 &&
- i < palPtr->logpalette.palNumEntries ; i++)
- {
- if (entry->peFlags != 0xff)
- {
- dist = (r - entry->peRed) * (r - entry->peRed) +
- (g - entry->peGreen) * (g - entry->peGreen) +
- (b - entry->peBlue) * (b - entry->peBlue);
- if (dist < minDist)
- {
- minDist = dist;
- index = i;
- }
- }
- entry++;
- }
+ WORD index = PALETTE_GetNearestIndexAndColor( hpalette, &color );
dprintf_palette(stddeb,"GetNearestPaletteIndex("NPFMT",%06lx): returning %d\n",
- hpalette, color, index );
+ hpalette, color, index );
return index;
}
/***********************************************************************
+ * GetNearestColor (GDI.154)
+ */
+COLORREF GetNearestColor( HDC hdc, COLORREF color )
+{
+ COLORREF nearest = color;
+ DC *dc;
+
+ if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
+ PALETTE_GetNearestIndexAndColor( dc->w.hPalette, &nearest );
+ dprintf_palette(stddeb,"GetNearestColor(%06lx): returning %06lx\n",
+ color, nearest );
+ return nearest;
+}
+
+
+/***********************************************************************
* PALETTE_GetObject
*/
int PALETTE_GetObject( PALETTEOBJ * palette, int count, LPSTR buffer )
diff --git a/objects/region.c b/objects/region.c
index 5be23ff..73adc51 100644
--- a/objects/region.c
+++ b/objects/region.c
@@ -240,7 +240,7 @@
/***********************************************************************
* CreatePolygonRgn (GDI.63)
*/
-HRGN CreatePolygonRgn( POINT * points, short count, short mode )
+HRGN CreatePolygonRgn( POINT * points, INT count, INT mode )
{
return CreatePolyPolygonRgn( points, &count, 1, mode );
}
@@ -249,8 +249,8 @@
/***********************************************************************
* CreatePolyPolygonRgn (GDI.451)
*/
-HRGN CreatePolyPolygonRgn( POINT * points, short * count,
- short nbpolygons, short mode )
+HRGN CreatePolyPolygonRgn( POINT * points, INT * count,
+ INT nbpolygons, INT mode )
{
RGNOBJ * obj;
HRGN hrgn;
diff --git a/objects/text.c b/objects/text.c
index fd94b10..3b6ec22 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -15,6 +15,7 @@
#include "stddebug.h"
/* #define DEBUG_TEXT */
#include "debug.h"
+#include "xmalloc.h"
#define TAB 9
#define LF 10
@@ -196,8 +197,9 @@
int width = rect->right - rect->left;
int max_width = 0;
- dprintf_text(stddeb,"DrawText: '%s', %d , [(%d,%d),(%d,%d)]\n", str, count,
- rect->left, rect->top, rect->right, rect->bottom);
+ dprintf_text(stddeb,"DrawText: '%s', %d , [(%ld,%ld),(%ld,%ld)]\n", str,
+ count, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right,
+ (LONG)rect->bottom);
if (count == -1) count = strlen(str);
strPtr = str;
@@ -307,8 +309,9 @@
dprintf_text(stddeb,"ExtTextOut: %d,%d '%*.*s', %d flags=%d\n",
x, y, count, count, str, count, flags);
if (lprect != NULL) {
- dprintf_text(stddeb, "rect %d %d %d %d\n",
- lprect->left, lprect->top, lprect->right, lprect->bottom );
+ dprintf_text(stddeb, "rect %ld %ld %ld %ld\n", (LONG)lprect->left,
+ (LONG)lprect->top, (LONG)lprect->right,
+ (LONG)lprect->bottom );
}
/* Setup coordinates */
@@ -418,7 +421,7 @@
{
XTextItem *items, *pitem;
- items = malloc( count * sizeof(XTextItem) );
+ items = xmalloc( count * sizeof(XTextItem) );
for (i = 0, pitem = items; i < count; i++, pitem++)
{
pitem->chars = str + i;