wine/objects/pen.c
Alexandre Julliard 73450d65c3 Release 940518
Tue May 17 23:03:16 1994  Bob Amstadt  (bob@pooh)

	* [windows/dce.c]
	Fixed bug with dce initialization that was causing dialog boxes to not
	be displayed.

	* [if1632/callback.c]
	Better fix for bug found by Martin.

Sat May 14 19:48:39 1994  Rick Sladkey  (jrs@world.std.com)

        * [ memory/heap.c ]
        Redirect HEAP_ReAlloc calls with NULL argument to HEAP_Alloc.

May 16, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [objects/font.c]
	Make EnumFonts() calling a callback with dummy fonts ... :-)

	* [objects/text.c]
	Add Empty Stub for ExtTextOut(), which temporarely call Textout().

	* [if1632/callback.c]
	Temporarely go around bug in CallWindowProc(), you will see printfs.

	* [controls/edit.c]
	Make EDIT controls focused by a mouse click.

	* [misc/property.c]
	Bug Fix in function EnumProps(), better use of CallBack16().

	* [misc/mmsystem.c]
	Basic Skelton's for MCI messages dispatching function.

Sun May 15 16:15:17 1994  Erik Bos (erik@hacktic.nl)

        * [windows/utility.c]
        Added windows_wsprintf() for the emulator, wsprintf() is
        for libwine.

Sat May 14 22:16:40 1994  Rick Sladkey  (jrs@world.std.com)

        * [misc/cursor.c]
        Fix pointer problems in LoadCursor leading to heap corruption.

        *  [ controls/menu.c ]
        Fix two NULL dereferencing bugs.

Sun May 15 20:07:48 1994  Rick Sladkey  (jrs@world.std.com)

        * [objects/font.c]
        Fix NULL pointer dereferencing bug in GetCharWidth.

        * [loader/resource.c]
        Fix under-allocation of memory in LoadAccelerators.

        * [windows/class.c]
        Ignore negative sizes for extra fields in RegisterClass.

Sun May 15 06:35:03 1994  David Metcalfe <david@prism.demon.co.uk>

        * [objects/metafile.c] [include/metafile.h] [include/windows.h]
          [objects/gdiobj.c] [objects/brush.c] [objects/pen.c]
          [objects/text.c] [objects/dcvalues.c] [windows/graphics.c]
          [windows/dc.c] [windows/mapping.c]
        Beginnings of metafile support.

        * [misc/file.c]
        Corrected spelling of _lcreat.

        * [controls/edit.c]
        Minor bug fixes.
1994-05-18 18:29:32 +00:00

99 lines
2.7 KiB
C

/*
* GDI pen objects
*
* Copyright 1993 Alexandre Julliard
*/
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "gdi.h"
#include "metafile.h"
extern WORD COLOR_ToPhysical( DC *dc, COLORREF color );
/***********************************************************************
* CreatePen (GDI.61)
*/
HPEN CreatePen( short style, short width, COLORREF color )
{
LOGPEN logpen = { style, { width, 0 }, color };
#ifdef DEBUG_GDI
printf( "CreatePen: %d %d %06x\n", style, width, color );
#endif
return CreatePenIndirect( &logpen );
}
/***********************************************************************
* CreatePenIndirect (GDI.62)
*/
HPEN CreatePenIndirect( LOGPEN * pen )
{
PENOBJ * penPtr;
HPEN hpen;
if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
if (!hpen) return 0;
penPtr = (PENOBJ *) GDI_HEAP_ADDR( hpen );
memcpy( &penPtr->logpen, pen, sizeof(LOGPEN) );
return hpen;
}
/***********************************************************************
* PEN_GetObject
*/
int PEN_GetObject( PENOBJ * pen, int count, LPSTR buffer )
{
if (count > sizeof(LOGPEN)) count = sizeof(LOGPEN);
memcpy( buffer, &pen->logpen, count );
return count;
}
/***********************************************************************
* PEN_SelectObject
*/
HPEN PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
{
static char dash_dash[] = { 5, 3 }; /* ----- ----- ----- */
static char dash_dot[] = { 2, 2 }; /* -- -- -- -- -- -- */
static char dash_dashdot[] = { 4,3,2,3 }; /* ---- -- ---- -- */
static char dash_dashdotdot[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */
HPEN prevHandle = dc->w.hPen;
if (dc->header.wMagic == METAFILE_DC_MAGIC)
return MF_CreatePenIndirect(dc, &(pen->logpen));
dc->w.hPen = hpen;
dc->u.x.pen.style = pen->logpen.lopnStyle;
dc->u.x.pen.width = pen->logpen.lopnWidth.x * dc->w.VportExtX
/ dc->w.WndExtX;
if (dc->u.x.pen.width < 0) dc->u.x.pen.width = -dc->u.x.pen.width;
if (dc->u.x.pen.width == 1) dc->u.x.pen.width = 0; /* Faster */
dc->u.x.pen.pixel = COLOR_ToPhysical( dc, pen->logpen.lopnColor );
switch(pen->logpen.lopnStyle)
{
case PS_DASH:
dc->u.x.pen.dashes = dash_dash;
dc->u.x.pen.dash_len = 2;
break;
case PS_DOT:
dc->u.x.pen.dashes = dash_dot;
dc->u.x.pen.dash_len = 2;
break;
case PS_DASHDOT:
dc->u.x.pen.dashes = dash_dashdot;
dc->u.x.pen.dash_len = 4;
break;
case PS_DASHDOTDOT:
dc->u.x.pen.dashes = dash_dashdotdot;
dc->u.x.pen.dash_len = 6;
break;
}
return prevHandle;
}