4 * Copyright 1993 Alexandre Julliard
7 static char Copyright
[] = "Copyright Alexandre Julliard, 1993";
11 extern WORD
COLOR_ToPhysical( DC
*dc
, COLORREF color
);
13 /***********************************************************************
16 HPEN
CreatePen( short style
, short width
, COLORREF color
)
18 LOGPEN logpen
= { style
, { width
, 0 }, color
};
20 printf( "CreatePen: %d %d %06x\n", style
, width
, color
);
22 return CreatePenIndirect( &logpen
);
26 /***********************************************************************
27 * CreatePenIndirect (GDI.62)
29 HPEN
CreatePenIndirect( LOGPEN
* pen
)
34 if (pen
->lopnStyle
> PS_INSIDEFRAME
) return 0;
35 hpen
= GDI_AllocObject( sizeof(PENOBJ
), PEN_MAGIC
);
37 penPtr
= (PENOBJ
*) GDI_HEAP_ADDR( hpen
);
38 memcpy( &penPtr
->logpen
, pen
, sizeof(LOGPEN
) );
43 /***********************************************************************
46 int PEN_GetObject( PENOBJ
* pen
, int count
, LPSTR buffer
)
48 if (count
> sizeof(LOGPEN
)) count
= sizeof(LOGPEN
);
49 memcpy( buffer
, &pen
->logpen
, count
);
54 /***********************************************************************
57 HPEN
PEN_SelectObject( DC
* dc
, HPEN hpen
, PENOBJ
* pen
)
59 static char dash_dash
[] = { 5, 3 }; /* ----- ----- ----- */
60 static char dash_dot
[] = { 2, 2 }; /* -- -- -- -- -- -- */
61 static char dash_dashdot
[] = { 4,3,2,3 }; /* ---- -- ---- -- */
62 static char dash_dashdotdot
[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */
64 HPEN prevHandle
= dc
->w
.hPen
;
67 dc
->u
.x
.pen
.style
= pen
->logpen
.lopnStyle
;
68 dc
->u
.x
.pen
.width
= pen
->logpen
.lopnWidth
.x
* dc
->w
.VportExtX
70 if (dc
->u
.x
.pen
.width
< 0) dc
->u
.x
.pen
.width
= -dc
->u
.x
.pen
.width
;
71 if (dc
->u
.x
.pen
.width
== 1) dc
->u
.x
.pen
.width
= 0; /* Faster */
72 dc
->u
.x
.pen
.pixel
= COLOR_ToPhysical( dc
, pen
->logpen
.lopnColor
);
73 switch(pen
->logpen
.lopnStyle
)
76 dc
->u
.x
.pen
.dashes
= dash_dash
;
77 dc
->u
.x
.pen
.dash_len
= 2;
80 dc
->u
.x
.pen
.dashes
= dash_dot
;
81 dc
->u
.x
.pen
.dash_len
= 2;
84 dc
->u
.x
.pen
.dashes
= dash_dashdot
;
85 dc
->u
.x
.pen
.dash_len
= 4;
88 dc
->u
.x
.pen
.dashes
= dash_dashdotdot
;
89 dc
->u
.x
.pen
.dash_len
= 6;