4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
12 extern WORD
COLOR_ToPhysical( DC
*dc
, COLORREF color
);
14 /***********************************************************************
17 HPEN
CreatePen( short style
, short width
, COLORREF color
)
19 LOGPEN logpen
= { style
, { width
, 0 }, color
};
21 printf( "CreatePen: %d %d %06x\n", style
, width
, color
);
23 return CreatePenIndirect( &logpen
);
27 /***********************************************************************
28 * CreatePenIndirect (GDI.62)
30 HPEN
CreatePenIndirect( LOGPEN
* pen
)
35 if (pen
->lopnStyle
> PS_INSIDEFRAME
) return 0;
36 hpen
= GDI_AllocObject( sizeof(PENOBJ
), PEN_MAGIC
);
38 penPtr
= (PENOBJ
*) GDI_HEAP_ADDR( hpen
);
39 memcpy( &penPtr
->logpen
, pen
, sizeof(LOGPEN
) );
44 /***********************************************************************
47 int PEN_GetObject( PENOBJ
* pen
, int count
, LPSTR buffer
)
49 if (count
> sizeof(LOGPEN
)) count
= sizeof(LOGPEN
);
50 memcpy( buffer
, &pen
->logpen
, count
);
55 /***********************************************************************
58 HPEN
PEN_SelectObject( DC
* dc
, HPEN hpen
, PENOBJ
* pen
)
60 static char dash_dash
[] = { 5, 3 }; /* ----- ----- ----- */
61 static char dash_dot
[] = { 2, 2 }; /* -- -- -- -- -- -- */
62 static char dash_dashdot
[] = { 4,3,2,3 }; /* ---- -- ---- -- */
63 static char dash_dashdotdot
[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */
64 HPEN prevHandle
= dc
->w
.hPen
;
66 if (dc
->header
.wMagic
== METAFILE_DC_MAGIC
)
67 return 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;