2 * ReactOS Win32 Subsystem
4 * Copyright (C) 1998 - 2004 ReactOS Team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 /* PRIVATE FUNCTIONS **********************************************************/
31 IntGdiCreatePenIndirect(PLOGPEN LogPen
)
34 PGDIBRUSHOBJ PenObject
;
35 static const WORD wPatternAlternate
[] = {0x5555};
36 static const WORD wPatternDash
[] = {0x0F0F};
37 static const WORD wPatternDot
[] = {0x3333};
39 if (LogPen
->lopnStyle
> PS_INSIDEFRAME
)
42 hPen
= PENOBJ_AllocPen();
45 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
46 DPRINT("Can't allocate pen\n");
50 PenObject
= PENOBJ_LockPen(hPen
);
51 /* FIXME - Handle PenObject == NULL!!! */
52 PenObject
->ptPenWidth
= LogPen
->lopnWidth
;
53 PenObject
->ulPenStyle
= LogPen
->lopnStyle
;
54 PenObject
->BrushAttr
.lbColor
= LogPen
->lopnColor
;
55 PenObject
->flAttrs
= GDIBRUSH_IS_OLDSTYLEPEN
;
56 switch (LogPen
->lopnStyle
)
59 PenObject
->flAttrs
|= GDIBRUSH_IS_NULL
;
63 PenObject
->flAttrs
|= GDIBRUSH_IS_SOLID
;
67 PenObject
->flAttrs
|= GDIBRUSH_IS_BITMAP
;
68 PenObject
->hbmPattern
= NtGdiCreateBitmap(8, 1, 1, 1, (LPBYTE
)wPatternAlternate
);
72 PenObject
->flAttrs
|= GDIBRUSH_IS_BITMAP
;
73 PenObject
->hbmPattern
= NtGdiCreateBitmap(8, 1, 1, 1, (LPBYTE
)wPatternDot
);
77 PenObject
->flAttrs
|= GDIBRUSH_IS_BITMAP
;
78 PenObject
->hbmPattern
= NtGdiCreateBitmap(8, 1, 1, 1, (LPBYTE
)wPatternDash
);
82 /* FIXME: does it need some additional work? */
83 PenObject
->flAttrs
|= GDIBRUSH_IS_SOLID
;
87 DPRINT1("FIXME: IntGdiCreatePenIndirect is UNIMPLEMENTED pen %x\n",LogPen
->lopnStyle
);
90 PENOBJ_UnlockPen(PenObject
);
96 PEN_GetObject(PGDIBRUSHOBJ PenObject
, INT Count
, PLOGPEN Buffer
)
101 if( Buffer
== NULL
) return sizeof(LOGPEN
);
103 LogPen
.lopnWidth
= PenObject
->ptPenWidth
;
104 LogPen
.lopnStyle
= PenObject
->ulPenStyle
;
105 LogPen
.lopnColor
= PenObject
->BrushAttr
.lbColor
;
106 memcpy(Buffer
, &LogPen
, Count
);
112 /* PUBLIC FUNCTIONS ***********************************************************/
123 LogPen
.lopnStyle
= PenStyle
;
124 LogPen
.lopnWidth
.x
= Width
;
125 LogPen
.lopnWidth
.y
= 0;
126 LogPen
.lopnColor
= Color
;
128 return IntGdiCreatePenIndirect(&LogPen
);
132 NtGdiCreatePenIndirect(CONST PLOGPEN LogPen
)
135 NTSTATUS Status
= STATUS_SUCCESS
;
142 SafeLogPen
= *LogPen
;
146 Status
= _SEH_GetExceptionCode();
150 if (!NT_SUCCESS(Status
))
152 SetLastNtError(Status
);
156 return IntGdiCreatePenIndirect(&SafeLogPen
);
163 IN ULONG iBrushStyle
,
165 IN ULONG_PTR lClientHatch
,
170 IN BOOL bOldStylePen
,
171 IN OPTIONAL HBRUSH hbrush
)
175 if (PenStyle
& PS_USERSTYLE
)
176 PenStyle
= (PenStyle
& ~PS_STYLE_MASK
) | PS_SOLID
;
178 LogPen
.lopnStyle
= PenStyle
& PS_STYLE_MASK
;
179 LogPen
.lopnWidth
.x
= Width
;
180 LogPen
.lopnColor
= ulColor
;
182 return IntGdiCreatePenIndirect(&LogPen
);