4 * Copyright 1993 Alexandre Julliard
13 /***********************************************************************
16 HPEN CreatePen( short style, short width, COLORREF color )
18 LOGPEN logpen = { style, { width, 0 }, color };
19 dprintf_gdi(stddeb, "CreatePen: %d %d %06lx\n", style, width, color );
20 return CreatePenIndirect( &logpen );
24 /***********************************************************************
25 * CreatePenIndirect (GDI.62)
27 HPEN CreatePenIndirect( LOGPEN * pen )
32 if (pen->lopnStyle > PS_INSIDEFRAME) return 0;
33 hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
35 penPtr = (PENOBJ *) GDI_HEAP_LIN_ADDR( hpen );
36 memcpy( &penPtr->logpen, pen, sizeof(LOGPEN) );
41 /***********************************************************************
44 int PEN_GetObject( PENOBJ * pen, int count, LPSTR buffer )
46 if (count > sizeof(LOGPEN)) count = sizeof(LOGPEN);
47 memcpy( buffer, &pen->logpen, count );
52 /***********************************************************************
55 HPEN PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen )
57 static char dash_dash[] = { 5, 3 }; /* ----- ----- ----- */
58 static char dash_dot[] = { 2, 2 }; /* -- -- -- -- -- -- */
59 static char dash_dashdot[] = { 4,3,2,3 }; /* ---- -- ---- -- */
60 static char dash_dashdotdot[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */
61 HPEN prevHandle = dc->w.hPen;
63 if (dc->header.wMagic == METAFILE_DC_MAGIC)
64 if (MF_CreatePenIndirect(dc, hpen, &(pen->logpen)))
71 dc->u.x.pen.style = pen->logpen.lopnStyle;
72 dc->u.x.pen.width = pen->logpen.lopnWidth.x * dc->w.VportExtX
74 if (dc->u.x.pen.width < 0) dc->u.x.pen.width = -dc->u.x.pen.width;
75 if (dc->u.x.pen.width == 1) dc->u.x.pen.width = 0; /* Faster */
76 dc->u.x.pen.pixel = COLOR_ToPhysical( dc, pen->logpen.lopnColor );
77 switch(pen->logpen.lopnStyle)
80 dc->u.x.pen.dashes = dash_dash;
81 dc->u.x.pen.dash_len = 2;
84 dc->u.x.pen.dashes = dash_dot;
85 dc->u.x.pen.dash_len = 2;
88 dc->u.x.pen.dashes = dash_dashdot;
89 dc->u.x.pen.dash_len = 4;
92 dc->u.x.pen.dashes = dash_dashdotdot;
93 dc->u.x.pen.dash_len = 6;