4 * Copyright 1993 Alexandre Julliard
7 #define NO_TRANSITION_TYPES /* This file is Win32-clean */
15 static const char PEN_dash
[] = { 5,3 }; /* ----- ----- ----- */
16 static const char PEN_dot
[] = { 1,1 }; /* -- -- -- -- -- -- */
17 static const char PEN_dashdot
[] = { 4,3,2,3 }; /* ---- -- ---- -- */
18 static const char PEN_dashdotdot
[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */
20 /***********************************************************************
21 * CreatePen16 (GDI.61)
23 HPEN16
CreatePen16( INT16 style
, INT16 width
, COLORREF color
)
25 LOGPEN32 logpen
= { style
, { width
, 0 }, color
};
26 dprintf_gdi(stddeb
, "CreatePen16: %d %d %06lx\n", style
, width
, color
);
27 return CreatePenIndirect32( &logpen
);
31 /***********************************************************************
32 * CreatePen32 (GDI32.55)
34 HPEN32
CreatePen32( INT32 style
, INT32 width
, COLORREF color
)
36 LOGPEN32 logpen
= { style
, { width
, 0 }, color
};
37 dprintf_gdi(stddeb
, "CreatePen32: %d %d %06lx\n", style
, width
, color
);
38 return CreatePenIndirect32( &logpen
);
42 /***********************************************************************
43 * CreatePenIndirect16 (GDI.62)
45 HPEN16
CreatePenIndirect16( const LOGPEN16
* pen
)
50 if (pen
->lopnStyle
> PS_INSIDEFRAME
) return 0;
51 hpen
= GDI_AllocObject( sizeof(PENOBJ
), PEN_MAGIC
);
53 penPtr
= (PENOBJ
*)GDI_HEAP_LIN_ADDR( hpen
);
54 penPtr
->logpen
.lopnStyle
= pen
->lopnStyle
;
55 penPtr
->logpen
.lopnColor
= pen
->lopnColor
;
56 CONV_POINT16TO32( &pen
->lopnWidth
, &penPtr
->logpen
.lopnWidth
);
61 /***********************************************************************
62 * CreatePenIndirect32 (GDI32.56)
64 HPEN32
CreatePenIndirect32( const LOGPEN32
* pen
)
69 if (pen
->lopnStyle
> PS_INSIDEFRAME
) return 0;
70 hpen
= GDI_AllocObject( sizeof(PENOBJ
), PEN_MAGIC
);
72 penPtr
= (PENOBJ
*)GDI_HEAP_LIN_ADDR( hpen
);
73 penPtr
->logpen
.lopnStyle
= pen
->lopnStyle
;
74 penPtr
->logpen
.lopnWidth
= pen
->lopnWidth
;
75 penPtr
->logpen
.lopnColor
= pen
->lopnColor
;
80 /***********************************************************************
83 INT16
PEN_GetObject16( PENOBJ
* pen
, INT16 count
, LPSTR buffer
)
86 logpen
.lopnStyle
= pen
->logpen
.lopnStyle
;
87 logpen
.lopnColor
= pen
->logpen
.lopnColor
;
88 CONV_POINT32TO16( &pen
->logpen
.lopnWidth
, &logpen
.lopnWidth
);
89 if (count
> sizeof(logpen
)) count
= sizeof(logpen
);
90 memcpy( buffer
, &logpen
, count
);
95 /***********************************************************************
98 INT32
PEN_GetObject32( PENOBJ
* pen
, INT32 count
, LPSTR buffer
)
100 if (count
> sizeof(pen
->logpen
)) count
= sizeof(pen
->logpen
);
101 memcpy( buffer
, &pen
->logpen
, count
);
106 /***********************************************************************
109 HPEN32
PEN_SelectObject( DC
* dc
, HPEN32 hpen
, PENOBJ
* pen
)
111 HPEN32 prevHandle
= dc
->w
.hPen
;
113 if (dc
->header
.wMagic
== METAFILE_DC_MAGIC
)
115 LOGPEN16 logpen
= { pen
->logpen
.lopnStyle
,
116 { pen
->logpen
.lopnWidth
.x
,
117 pen
->logpen
.lopnWidth
.y
},
118 pen
->logpen
.lopnColor
};
119 if (MF_CreatePenIndirect( dc
, hpen
, &logpen
)) return prevHandle
;
125 dc
->u
.x
.pen
.style
= pen
->logpen
.lopnStyle
;
126 dc
->u
.x
.pen
.width
= pen
->logpen
.lopnWidth
.x
* dc
->vportExtX
/ dc
->wndExtX
;
127 if (dc
->u
.x
.pen
.width
< 0) dc
->u
.x
.pen
.width
= -dc
->u
.x
.pen
.width
;
128 if (dc
->u
.x
.pen
.width
== 1) dc
->u
.x
.pen
.width
= 0; /* Faster */
129 dc
->u
.x
.pen
.pixel
= COLOR_ToPhysical( dc
, pen
->logpen
.lopnColor
);
130 switch(pen
->logpen
.lopnStyle
)
133 dc
->u
.x
.pen
.dashes
= (char *)PEN_dash
;
134 dc
->u
.x
.pen
.dash_len
= 2;
137 dc
->u
.x
.pen
.dashes
= (char *)PEN_dot
;
138 dc
->u
.x
.pen
.dash_len
= 2;
141 dc
->u
.x
.pen
.dashes
= (char *)PEN_dashdot
;
142 dc
->u
.x
.pen
.dash_len
= 4;
145 dc
->u
.x
.pen
.dashes
= (char *)PEN_dashdotdot
;
146 dc
->u
.x
.pen
.dash_len
= 6;