4 * Copyright 1993, 1994 Alexandre Julliard
17 /***********************************************************************
18 * CreateBrushIndirect16 (GDI.50)
20 HBRUSH16 WINAPI
CreateBrushIndirect16( const LOGBRUSH16
* brush
)
23 HBRUSH16 hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
24 if (!hbrush
) return 0;
25 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
26 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
27 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
28 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
29 GDI_HEAP_UNLOCK( hbrush
);
34 /***********************************************************************
35 * CreateBrushIndirect32 (GDI32.27)
37 HBRUSH32 WINAPI
CreateBrushIndirect32( const LOGBRUSH32
* brush
)
40 HBRUSH32 hbrush
= GDI_AllocObject( sizeof(BRUSHOBJ
), BRUSH_MAGIC
);
41 if (!hbrush
) return 0;
42 brushPtr
= (BRUSHOBJ
*) GDI_HEAP_LOCK( hbrush
);
43 brushPtr
->logbrush
.lbStyle
= brush
->lbStyle
;
44 brushPtr
->logbrush
.lbColor
= brush
->lbColor
;
45 brushPtr
->logbrush
.lbHatch
= brush
->lbHatch
;
46 GDI_HEAP_UNLOCK( hbrush
);
51 /***********************************************************************
52 * CreateHatchBrush16 (GDI.58)
54 HBRUSH16 WINAPI
CreateHatchBrush16( INT16 style
, COLORREF color
)
56 LOGBRUSH32 logbrush
= { BS_HATCHED
, color
, style
};
57 dprintf_gdi(stddeb
, "CreateHatchBrush16: %d %06lx\n", style
, color
);
58 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
59 return CreateBrushIndirect32( &logbrush
);
63 /***********************************************************************
64 * CreateHatchBrush32 (GDI32.48)
66 HBRUSH32 WINAPI
CreateHatchBrush32( INT32 style
, COLORREF color
)
68 LOGBRUSH32 logbrush
= { BS_HATCHED
, color
, style
};
69 dprintf_gdi(stddeb
, "CreateHatchBrush32: %d %06lx\n", style
, color
);
70 if ((style
< 0) || (style
>= NB_HATCH_STYLES
)) return 0;
71 return CreateBrushIndirect32( &logbrush
);
75 /***********************************************************************
76 * CreatePatternBrush16 (GDI.60)
78 HBRUSH16 WINAPI
CreatePatternBrush16( HBITMAP16 hbitmap
)
80 return (HBRUSH16
)CreatePatternBrush32( hbitmap
);
84 /***********************************************************************
85 * CreatePatternBrush32 (GDI32.54)
87 HBRUSH32 WINAPI
CreatePatternBrush32( HBITMAP32 hbitmap
)
89 LOGBRUSH32 logbrush
= { BS_PATTERN
, 0, 0 };
90 BITMAPOBJ
*bmp
, *newbmp
;
92 dprintf_gdi(stddeb
, "CreatePatternBrush: %04x\n", hbitmap
);
94 /* Make a copy of the bitmap */
96 if (!(bmp
= (BITMAPOBJ
*) GDI_GetObjPtr( hbitmap
, BITMAP_MAGIC
)))
98 logbrush
.lbHatch
= (INT32
)CreateBitmapIndirect16( &bmp
->bitmap
);
99 newbmp
= (BITMAPOBJ
*) GDI_GetObjPtr( (HGDIOBJ32
)logbrush
.lbHatch
,
103 GDI_HEAP_UNLOCK( hbitmap
);
106 XCopyArea( display
, bmp
->pixmap
, newbmp
->pixmap
, BITMAP_GC(bmp
),
107 0, 0, bmp
->bitmap
.bmWidth
, bmp
->bitmap
.bmHeight
, 0, 0 );
108 GDI_HEAP_UNLOCK( hbitmap
);
109 GDI_HEAP_UNLOCK( logbrush
.lbHatch
);
110 return CreateBrushIndirect32( &logbrush
);
114 /***********************************************************************
115 * CreateDIBPatternBrush16 (GDI.445)
117 HBRUSH16 WINAPI
CreateDIBPatternBrush16( HGLOBAL16 hbitmap
, UINT16 coloruse
)
119 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
120 BITMAPINFO
*info
, *newInfo
;
123 dprintf_gdi(stddeb
, "CreateDIBPatternBrush: %04x\n", hbitmap
);
125 /* Make a copy of the bitmap */
127 if (!(info
= (BITMAPINFO
*)GlobalLock16( hbitmap
))) return 0;
129 if (info
->bmiHeader
.biCompression
)
130 size
= info
->bmiHeader
.biSizeImage
;
132 size
= (info
->bmiHeader
.biWidth
* info
->bmiHeader
.biBitCount
+ 31) / 32
133 * 8 * info
->bmiHeader
.biHeight
;
134 size
+= DIB_BitmapInfoSize( info
, coloruse
);
136 if (!(logbrush
.lbHatch
= (INT16
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
138 GlobalUnlock16( hbitmap
);
141 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
142 memcpy( newInfo
, info
, size
);
143 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
144 GlobalUnlock16( hbitmap
);
145 return CreateBrushIndirect32( &logbrush
);
149 /***********************************************************************
150 * CreateDIBPatternBrush32 (GDI32.34)
152 HBRUSH32 WINAPI
CreateDIBPatternBrush32( HGLOBAL32 hbitmap
, UINT32 coloruse
)
154 LOGBRUSH32 logbrush
= { BS_DIBPATTERN
, coloruse
, 0 };
155 BITMAPINFO
*info
, *newInfo
;
158 dprintf_gdi(stddeb
, "CreateDIBPatternBrush: %04x\n", hbitmap
);
160 /* Make a copy of the bitmap */
162 if (!(info
= (BITMAPINFO
*)GlobalLock32( hbitmap
))) return 0;
164 if (info
->bmiHeader
.biCompression
)
165 size
= info
->bmiHeader
.biSizeImage
;
167 size
= (info
->bmiHeader
.biWidth
* info
->bmiHeader
.biBitCount
+ 31) / 32
168 * 8 * info
->bmiHeader
.biHeight
;
169 size
+= DIB_BitmapInfoSize( info
, coloruse
);
171 if (!(logbrush
.lbHatch
= (INT32
)GlobalAlloc16( GMEM_MOVEABLE
, size
)))
173 GlobalUnlock16( hbitmap
);
176 newInfo
= (BITMAPINFO
*) GlobalLock16( (HGLOBAL16
)logbrush
.lbHatch
);
177 memcpy( newInfo
, info
, size
);
178 GlobalUnlock16( (HGLOBAL16
)logbrush
.lbHatch
);
179 GlobalUnlock16( hbitmap
);
180 return CreateBrushIndirect32( &logbrush
);
184 /***********************************************************************
185 * CreateSolidBrush (GDI.66)
187 HBRUSH16 WINAPI
CreateSolidBrush16( COLORREF color
)
189 LOGBRUSH32 logbrush
= { BS_SOLID
, color
, 0 };
190 dprintf_gdi(stddeb
, "CreateSolidBrush16: %06lx\n", color
);
191 return CreateBrushIndirect32( &logbrush
);
195 /***********************************************************************
196 * CreateSolidBrush32 (GDI32.64)
198 HBRUSH32 WINAPI
CreateSolidBrush32( COLORREF color
)
200 LOGBRUSH32 logbrush
= { BS_SOLID
, color
, 0 };
201 dprintf_gdi(stddeb
, "CreateSolidBrush32: %06lx\n", color
);
202 return CreateBrushIndirect32( &logbrush
);
206 /***********************************************************************
207 * SetBrushOrg (GDI.148)
209 DWORD WINAPI
SetBrushOrg( HDC16 hdc
, INT16 x
, INT16 y
)
212 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
213 if (!dc
) return FALSE
;
214 retval
= dc
->w
.brushOrgX
| (dc
->w
.brushOrgY
<< 16);
221 /***********************************************************************
222 * SetBrushOrgEx (GDI32.308)
224 BOOL32 WINAPI
SetBrushOrgEx( HDC32 hdc
, INT32 x
, INT32 y
, LPPOINT32 oldorg
)
226 DC
* dc
= (DC
*) GDI_GetObjPtr( hdc
, DC_MAGIC
);
228 if (!dc
) return FALSE
;
231 oldorg
->x
= dc
->w
.brushOrgX
;
232 oldorg
->y
= dc
->w
.brushOrgY
;
240 /***********************************************************************
241 * GetSysColorBrush16 (USER.281)
243 HBRUSH16 WINAPI
GetSysColorBrush16( INT16 index
)
245 return (HBRUSH16
)GetSysColorBrush32(index
);
249 /***********************************************************************
250 * GetSysColorBrush32 (USER32.289)
252 HBRUSH32 WINAPI
GetSysColorBrush32( INT32 index
)
255 case COLOR_SCROLLBAR
:
256 return sysColorObjects
.hbrushScrollbar
;
257 case COLOR_BACKGROUND
:
258 return sysColorObjects
.hbrushBackground
;
259 case COLOR_ACTIVECAPTION
:
260 return sysColorObjects
.hbrushActiveCaption
;
261 case COLOR_INACTIVECAPTION
:
262 return sysColorObjects
.hbrushInactiveCaption
;
264 return sysColorObjects
.hbrushMenu
;
266 return sysColorObjects
.hbrushWindow
;
267 case COLOR_WINDOWFRAME
:
268 return sysColorObjects
.hbrushWindowFrame
;
270 return sysColorObjects
.hbrushMenuText
;
271 case COLOR_WINDOWTEXT
:
272 return sysColorObjects
.hbrushWindowText
;
273 case COLOR_CAPTIONTEXT
:
274 return sysColorObjects
.hbrushCaptionText
;
275 case COLOR_ACTIVEBORDER
:
276 return sysColorObjects
.hbrushActiveBorder
;
277 case COLOR_INACTIVEBORDER
:
278 return sysColorObjects
.hbrushInactiveBorder
;
279 case COLOR_APPWORKSPACE
:
280 return sysColorObjects
.hbrushAppWorkspace
;
281 case COLOR_HIGHLIGHT
:
282 return sysColorObjects
.hbrushHighlight
;
283 case COLOR_HIGHLIGHTTEXT
:
284 return sysColorObjects
.hbrushHighlightText
;
285 case COLOR_BTNFACE
: /* same as COLOR_3DFACE */
286 return sysColorObjects
.hbrushBtnFace
;
287 case COLOR_BTNSHADOW
: /* same as COLOR_3DSHADOW */
288 return sysColorObjects
.hbrushBtnShadow
;
290 return sysColorObjects
.hbrushGrayText
;
292 return sysColorObjects
.hbrushBtnText
;
293 case COLOR_INACTIVECAPTIONTEXT
:
294 return sysColorObjects
.hbrushInactiveCaptionText
;
295 case COLOR_BTNHIGHLIGHT
: /* same as COLOR_(3DHIGH|3DHI|BTNHI)LIGHT */
296 return sysColorObjects
.hbrushBtnHighlight
;
297 case COLOR_3DDKSHADOW
:
298 return sysColorObjects
.hbrush3DDkShadow
;
300 return sysColorObjects
.hbrush3DLight
;
302 return sysColorObjects
.hbrushInfoText
;
304 return sysColorObjects
.hbrushInfoBk
;
306 fprintf( stderr
, "GetSysColorBrush32: Unknown index(%d)\n", index
);
309 return GetStockObject32(LTGRAY_BRUSH
);
314 /***********************************************************************
317 BOOL32
BRUSH_DeleteObject( HBRUSH16 hbrush
, BRUSHOBJ
* brush
)
319 switch(brush
->logbrush
.lbStyle
)
322 DeleteObject32( (HGDIOBJ32
)brush
->logbrush
.lbHatch
);
325 GlobalFree16( (HGLOBAL16
)brush
->logbrush
.lbHatch
);
328 return GDI_FreeObject( hbrush
);
332 /***********************************************************************
335 INT16
BRUSH_GetObject16( BRUSHOBJ
* brush
, INT16 count
, LPSTR buffer
)
339 logbrush
.lbStyle
= brush
->logbrush
.lbStyle
;
340 logbrush
.lbColor
= brush
->logbrush
.lbColor
;
341 logbrush
.lbHatch
= brush
->logbrush
.lbHatch
;
342 if (count
> sizeof(logbrush
)) count
= sizeof(logbrush
);
343 memcpy( buffer
, &logbrush
, count
);
348 /***********************************************************************
351 INT32
BRUSH_GetObject32( BRUSHOBJ
* brush
, INT32 count
, LPSTR buffer
)
353 if (count
> sizeof(brush
->logbrush
)) count
= sizeof(brush
->logbrush
);
354 memcpy( buffer
, &brush
->logbrush
, count
);