Added missing comma in index.html.
[wine.git] / objects / gdiobj.c
blob285d912e9aa6d98dc68ab8dde8104ff53abc69cf
1 /*
2 * GDI functions
4 * Copyright 1993 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <assert.h>
24 #include <stdlib.h>
25 #include <stdarg.h>
26 #include <stdio.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winreg.h"
32 #include "winerror.h"
34 #include "local.h"
35 #include "gdi.h"
36 #include "gdi_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
41 #define HGDIOBJ_32(h16) ((HGDIOBJ)(ULONG_PTR)(h16))
43 #define GDI_HEAP_SIZE 0xffe0
45 /***********************************************************************
46 * GDI stock objects
49 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
50 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
51 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
53 /* FIXME: these should perhaps be BS_HATCHED, at least for 1 bitperpixel */
54 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
55 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
57 /* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
58 /* See HatchBrushes in x11drv for the HS_DIAGCROSS+1 hack */
59 static const LOGBRUSH DkGrayBrush = { BS_HATCHED, RGB(0,0,0), (HS_DIAGCROSS+1) };
61 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
62 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
63 static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
65 static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 };
66 static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
68 /* reserve one extra entry for the stock default bitmap */
69 /* this is what Windows does too */
70 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
72 static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
74 static SYSLEVEL GDI_level;
75 static CRITICAL_SECTION_DEBUG critsect_debug =
77 0, 0, &GDI_level.crst,
78 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
79 0, 0, { 0, (DWORD)(__FILE__ ": GDI_level") }
81 static SYSLEVEL GDI_level = { { &critsect_debug, -1, 0, 0, 0, 0 }, 3 };
83 static WORD GDI_HeapSel;
85 inline static BOOL get_bool(char *buffer)
87 return (buffer[0] == 'y' || buffer[0] == 'Y' ||
88 buffer[0] == 't' || buffer[0] == 'T' ||
89 buffer[0] == '1');
93 /****************************************************************************
95 * language-independent stock fonts
99 static const LOGFONTW OEMFixedFont =
100 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
101 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
103 static const LOGFONTW AnsiFixedFont =
104 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
105 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
107 static const LOGFONTW AnsiVarFont =
108 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
109 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
110 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
112 /******************************************************************************
114 * language-dependent stock fonts
116 * 'ANSI' charset and 'DEFAULT' charset is not same.
117 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
118 * 'ANSI' charset seems to be identical with ISO-8859-1.
119 * 'DEFAULT' charset is a language-dependent charset.
121 * 'System' font seems to be an alias for language-dependent font.
125 * language-dependenet stock fonts for all known charsets
126 * please see TranslateCharsetInfo (objects/font.c) and
127 * CharsetBindingInfo (graphics/x11drv/xfont.c),
128 * and modify entries for your language if needed.
130 struct DefaultFontInfo
132 UINT charset;
133 LOGFONTW SystemFont;
134 LOGFONTW DeviceDefaultFont;
135 LOGFONTW SystemFixedFont;
136 LOGFONTW DefaultGuiFont;
139 static const struct DefaultFontInfo default_fonts[] =
141 { ANSI_CHARSET,
142 { /* System */
143 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
144 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
145 {'S','y','s','t','e','m','\0'}
147 { /* Device Default */
148 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
149 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
150 {'\0'}
152 { /* System Fixed */
153 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
154 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
155 {'\0'}
157 { /* DefaultGuiFont */
158 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
159 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
160 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
163 { EASTEUROPE_CHARSET,
164 { /* System */
165 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
166 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
167 {'S','y','s','t','e','m','\0'}
169 { /* Device Default */
170 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
171 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
172 {'\0'}
174 { /* System Fixed */
175 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
176 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
177 {'\0'}
179 { /* DefaultGuiFont */
180 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
181 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
182 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
185 { RUSSIAN_CHARSET,
186 { /* System */
187 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
188 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
189 {'S','y','s','t','e','m','\0'}
191 { /* Device Default */
192 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
193 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
194 {'\0'}
196 { /* System Fixed */
197 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
198 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
199 {'\0'}
201 { /* DefaultGuiFont */
202 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
203 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
204 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
207 { GREEK_CHARSET,
208 { /* System */
209 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
210 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
211 {'S','y','s','t','e','m','\0'}
213 { /* Device Default */
214 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
215 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
216 {'\0'}
218 { /* System Fixed */
219 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
220 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
221 {'\0'}
223 { /* DefaultGuiFont */
224 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
225 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
226 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
229 { TURKISH_CHARSET,
230 { /* System */
231 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
232 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
233 {'S','y','s','t','e','m','\0'}
235 { /* Device Default */
236 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
237 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
238 {'\0'}
240 { /* System Fixed */
241 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
242 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
243 {'\0'}
245 { /* DefaultGuiFont */
246 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
247 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
248 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
251 { HEBREW_CHARSET,
252 { /* System */
253 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
254 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
255 {'S','y','s','t','e','m','\0'}
257 { /* Device Default */
258 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
259 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
260 {'\0'}
262 { /* System Fixed */
263 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
264 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
265 {'\0'}
267 { /* DefaultGuiFont */
268 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
269 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
270 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
273 { ARABIC_CHARSET,
274 { /* System */
275 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
276 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
277 {'S','y','s','t','e','m','\0'}
279 { /* Device Default */
280 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
281 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
282 {'\0'}
284 { /* System Fixed */
285 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
286 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
287 {'\0'}
289 { /* DefaultGuiFont */
290 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
291 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
292 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
295 { BALTIC_CHARSET,
296 { /* System */
297 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
298 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
299 {'S','y','s','t','e','m','\0'}
301 { /* Device Default */
302 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
303 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
304 {'\0'}
306 { /* System Fixed */
307 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
308 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
309 {'\0'}
311 { /* DefaultGuiFont */
312 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
313 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
314 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
317 { THAI_CHARSET,
318 { /* System */
319 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
320 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
321 {'S','y','s','t','e','m','\0'}
323 { /* Device Default */
324 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
325 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
326 {'\0'}
328 { /* System Fixed */
329 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
330 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
331 {'\0'}
333 { /* DefaultGuiFont */
334 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
335 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
336 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
339 { SHIFTJIS_CHARSET,
340 { /* System */
341 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
342 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
343 {'S','y','s','t','e','m','\0'}
345 { /* Device Default */
346 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
347 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
348 {'\0'}
350 { /* System Fixed */
351 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
352 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
353 {'\0'}
355 { /* DefaultGuiFont */
356 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
357 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
358 {'M','S',' ','U','I',' ','G','o','t','h','i','c','\0'}
361 { GB2312_CHARSET,
362 { /* System */
363 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
364 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
365 {'S','y','s','t','e','m','\0'}
367 { /* Device Default */
368 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
369 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
370 {'\0'}
372 { /* System Fixed */
373 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
374 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
375 {'\0'}
377 { /* DefaultGuiFont */
378 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
379 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
380 {'M','S',' ','S','o','n','g','\0'} /* FIXME: Is this correct? */
383 { HANGEUL_CHARSET,
384 { /* System */
385 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
386 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
387 {'S','y','s','t','e','m','\0'}
389 { /* Device Default */
390 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
391 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
392 {'\0'}
394 { /* System Fixed */
395 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
396 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
397 {'\0'}
399 { /* DefaultGuiFont */
400 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
401 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
402 {'G','u','l','i','m'},
405 { CHINESEBIG5_CHARSET,
406 { /* System */
407 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
408 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
409 {'S','y','s','t','e','m','\0'}
411 { /* Device Default */
412 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
413 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
414 {'\0'}
416 { /* System Fixed */
417 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
418 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
419 {'\0'}
421 { /* DefaultGuiFont */
422 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
423 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
424 {'\0'} /* FIXME - what is the native font??? */
427 { JOHAB_CHARSET,
428 { /* System */
429 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
430 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
431 {'S','y','s','t','e','m','\0'}
433 { /* Device Default */
434 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
435 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
436 {'\0'}
438 { /* System Fixed */
439 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
440 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
441 {'\0'}
443 { /* DefaultGuiFont */
444 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
445 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
446 {'M','S',' ','M','i','n','g','l','i','u','\0'} /* FIXME: Is this correct? */
452 /******************************************************************************
453 * get_default_fonts
455 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
457 int n;
459 for(n=0;n<(sizeof(default_fonts)/sizeof(default_fonts[0]));n++)
461 if ( default_fonts[n].charset == charset )
462 return &default_fonts[n];
465 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
466 return &default_fonts[0];
470 /******************************************************************************
471 * get_default_charset (internal)
473 * get the language-dependent charset that can handle CP_ACP correctly.
475 static UINT get_default_charset( void )
477 CHARSETINFO csi;
478 UINT uACP;
480 uACP = GetACP();
481 csi.ciCharset = ANSI_CHARSET;
482 if ( ! TranslateCharsetInfo( (LPDWORD)uACP, &csi, TCI_SRCCODEPAGE ) )
484 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
485 return ANSI_CHARSET;
488 return csi.ciCharset;
492 /******************************************************************************
493 * create_stock_font
495 static HFONT create_stock_font( char const *fontName, const LOGFONTW *font, HKEY hkey )
497 LOGFONTW lf;
498 char key[256];
499 char buffer[MAX_PATH];
500 DWORD type, count;
502 if (!hkey) return CreateFontIndirectW( font );
504 lf = *font;
505 sprintf(key, "%s.Height", fontName);
506 count = sizeof(buffer);
507 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
508 lf.lfHeight = atoi(buffer);
510 sprintf(key, "%s.Bold", fontName);
511 count = sizeof(buffer);
512 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
513 lf.lfWeight = get_bool(buffer) ? FW_BOLD : FW_NORMAL;
515 sprintf(key, "%s.Italic", fontName);
516 count = sizeof(buffer);
517 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
518 lf.lfItalic = get_bool(buffer);
520 sprintf(key, "%s.Underline", fontName);
521 count = sizeof(buffer);
522 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
523 lf.lfUnderline = get_bool(buffer);
525 sprintf(key, "%s.StrikeOut", fontName);
526 count = sizeof(buffer);
527 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
528 lf.lfStrikeOut = get_bool(buffer);
529 return CreateFontIndirectW( &lf );
533 #define TRACE_SEC(handle,text) \
534 TRACE("(%p): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
537 /***********************************************************************
538 * inc_ref_count
540 * Increment the reference count of a GDI object.
542 inline static void inc_ref_count( HGDIOBJ handle )
544 GDIOBJHDR *header;
546 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
548 header->dwCount++;
549 GDI_ReleaseObj( handle );
554 /***********************************************************************
555 * dec_ref_count
557 * Decrement the reference count of a GDI object.
559 inline static void dec_ref_count( HGDIOBJ handle )
561 GDIOBJHDR *header;
563 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
565 if (header->dwCount) header->dwCount--;
566 if (header->dwCount != 0x80000000) GDI_ReleaseObj( handle );
567 else
569 /* handle delayed DeleteObject*/
570 header->dwCount = 0;
571 GDI_ReleaseObj( handle );
572 TRACE( "executing delayed DeleteObject for %p\n", handle );
573 DeleteObject( handle );
579 /***********************************************************************
580 * GDI_Init
582 * GDI initialization.
584 BOOL GDI_Init(void)
586 HINSTANCE16 instance;
587 HKEY hkey;
588 GDIOBJHDR *ptr;
589 const struct DefaultFontInfo* deffonts;
590 int i;
592 if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey))
593 hkey = 0;
595 /* create GDI heap */
596 if ((instance = LoadLibrary16( "GDI.EXE" )) >= 32) GDI_HeapSel = instance | 7;
598 /* create stock objects */
599 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
600 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
601 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
602 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
603 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
604 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
606 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
607 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
608 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
610 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
611 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
613 /* language-independent stock fonts */
614 stock_objects[OEM_FIXED_FONT] = create_stock_font( "OEMFixed", &OEMFixedFont, hkey );
615 stock_objects[ANSI_FIXED_FONT] = create_stock_font( "AnsiFixed", &AnsiFixedFont, hkey );
616 stock_objects[ANSI_VAR_FONT] = create_stock_font( "AnsiVar", &AnsiVarFont, hkey );
618 /* language-dependent stock fonts */
619 deffonts = get_default_fonts(get_default_charset());
620 stock_objects[SYSTEM_FONT] = create_stock_font( "System", &deffonts->SystemFont, hkey );
621 stock_objects[DEVICE_DEFAULT_FONT] = create_stock_font( "DeviceDefault", &deffonts->DeviceDefaultFont, hkey );
622 stock_objects[SYSTEM_FIXED_FONT] = create_stock_font( "SystemFixed", &deffonts->SystemFixedFont, hkey );
623 stock_objects[DEFAULT_GUI_FONT] = create_stock_font( "DefaultGui", &deffonts->DefaultGuiFont, hkey );
625 stock_objects[DC_BRUSH] = CreateBrushIndirect( &DCBrush );
626 stock_objects[DC_PEN] = CreatePenIndirect( &DCPen );
628 /* clear the NOSYSTEM bit on all stock objects*/
629 for (i = 0; i < NB_STOCK_OBJECTS; i++)
631 if (!stock_objects[i])
633 if (i == 9) continue; /* there's no stock object 9 */
634 ERR( "could not create stock object %d\n", i );
635 return FALSE;
637 ptr = GDI_GetObjPtr( stock_objects[i], MAGIC_DONTCARE );
638 ptr->wMagic &= ~OBJECT_NOSYSTEM;
639 GDI_ReleaseObj( stock_objects[i] );
642 if (hkey) RegCloseKey( hkey );
644 WineEngInit();
646 return TRUE;
649 #define FIRST_LARGE_HANDLE 16
650 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
651 static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES];
652 static int next_large_handle;
654 /***********************************************************************
655 * alloc_large_heap
657 * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject
659 inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle )
661 int i;
662 GDIOBJHDR *obj;
664 for (i = next_large_handle + 1; i < MAX_LARGE_HANDLES; i++)
665 if (!large_handles[i]) goto found;
666 for (i = 0; i <= next_large_handle; i++)
667 if (!large_handles[i]) goto found;
668 *handle = 0;
669 return NULL;
671 found:
672 if ((obj = HeapAlloc( GetProcessHeap(), 0, size )))
674 large_handles[i] = obj;
675 *handle = (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
676 next_large_handle = i;
678 return obj;
682 /***********************************************************************
683 * GDI_AllocObject
685 void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_obj_funcs *funcs )
687 GDIOBJHDR *obj;
688 HLOCAL16 hlocal;
690 _EnterSysLevel( &GDI_level );
691 switch(magic)
693 default:
694 if (GDI_HeapSel)
696 if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error;
697 assert( hlocal & 2 );
698 obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hlocal );
699 *handle = (HGDIOBJ)(ULONG_PTR)hlocal;
700 break;
702 /* fall through */
703 case DC_MAGIC:
704 case DISABLED_DC_MAGIC:
705 case META_DC_MAGIC:
706 case METAFILE_MAGIC:
707 case METAFILE_DC_MAGIC:
708 case ENHMETAFILE_MAGIC:
709 case ENHMETAFILE_DC_MAGIC:
710 case MEMORY_DC_MAGIC:
711 case BITMAP_MAGIC:
712 case PALETTE_MAGIC:
713 if (!(obj = alloc_large_heap( size, handle ))) goto error;
714 break;
717 obj->hNext = 0;
718 obj->wMagic = magic|OBJECT_NOSYSTEM;
719 obj->dwCount = 0;
720 obj->funcs = funcs;
721 obj->hdcs = NULL;
723 TRACE_SEC( *handle, "enter" );
724 return obj;
726 error:
727 _LeaveSysLevel( &GDI_level );
728 *handle = 0;
729 return NULL;
733 /***********************************************************************
734 * GDI_ReallocObject
736 * The object ptr must have been obtained with GDI_GetObjPtr.
737 * The new pointer must be released with GDI_ReleaseObj.
739 void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object )
741 HGDIOBJ new_handle;
743 if ((UINT_PTR)handle & 2) /* GDI heap handle */
745 HLOCAL16 h = LOWORD(handle);
746 LOCAL_Unlock( GDI_HeapSel, h );
747 if ((new_handle = (HGDIOBJ)(ULONG_PTR)LOCAL_ReAlloc( GDI_HeapSel, h, size, LMEM_MOVEABLE )))
749 assert( new_handle == handle ); /* moveable handle cannot change */
750 return LOCAL_Lock( GDI_HeapSel, h );
753 else
755 int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
756 if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
758 void *new_ptr = HeapReAlloc( GetProcessHeap(), 0, large_handles[i], size );
759 if (new_ptr)
761 large_handles[i] = new_ptr;
762 return new_ptr;
765 else ERR( "Invalid handle %p\n", handle );
767 TRACE_SEC( handle, "leave" );
768 _LeaveSysLevel( &GDI_level );
769 return NULL;
773 /***********************************************************************
774 * GDI_FreeObject
776 BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
778 GDIOBJHDR *object = ptr;
780 object->wMagic = 0; /* Mark it as invalid */
781 object->funcs = NULL;
782 if ((UINT_PTR)handle & 2) /* GDI heap handle */
784 HLOCAL16 h = LOWORD(handle);
785 LOCAL_Unlock( GDI_HeapSel, h );
786 LOCAL_Free( GDI_HeapSel, h );
788 else /* large heap handle */
790 int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
791 if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
793 HeapFree( GetProcessHeap(), 0, large_handles[i] );
794 large_handles[i] = NULL;
796 else ERR( "Invalid handle %p\n", handle );
798 TRACE_SEC( handle, "leave" );
799 _LeaveSysLevel( &GDI_level );
800 return TRUE;
804 /***********************************************************************
805 * GDI_GetObjPtr
807 * Return a pointer to the GDI object associated to the handle.
808 * Return NULL if the object has the wrong magic number.
809 * The object must be released with GDI_ReleaseObj.
811 void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
813 GDIOBJHDR *ptr = NULL;
815 _EnterSysLevel( &GDI_level );
817 if ((UINT_PTR)handle & 2) /* GDI heap handle */
819 HLOCAL16 h = LOWORD(handle);
820 ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, h );
821 if (ptr)
823 if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ||
824 (GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) ||
825 (GDIMAGIC(ptr->wMagic) > LAST_MAGIC))
827 LOCAL_Unlock( GDI_HeapSel, h );
828 ptr = NULL;
832 else /* large heap handle */
834 int i = ((UINT_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
835 if (i >= 0 && i < MAX_LARGE_HANDLES)
837 ptr = large_handles[i];
838 if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL;
842 if (!ptr)
844 _LeaveSysLevel( &GDI_level );
845 SetLastError( ERROR_INVALID_HANDLE );
846 WARN( "Invalid handle %p\n", handle );
848 else TRACE_SEC( handle, "enter" );
850 return ptr;
854 /***********************************************************************
855 * GDI_ReleaseObj
858 void GDI_ReleaseObj( HGDIOBJ handle )
860 if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, LOWORD(handle) );
861 TRACE_SEC( handle, "leave" );
862 _LeaveSysLevel( &GDI_level );
866 /***********************************************************************
867 * GDI_CheckNotLock
869 void GDI_CheckNotLock(void)
871 _CheckNotSysLevel( &GDI_level );
875 /***********************************************************************
876 * DeleteObject (GDI32.@)
878 BOOL WINAPI DeleteObject( HGDIOBJ obj )
880 /* Check if object is valid */
882 GDIOBJHDR * header;
883 if (HIWORD(obj)) return FALSE;
885 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
887 if (!(header->wMagic & OBJECT_NOSYSTEM)
888 && (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
890 TRACE("Preserving system object %p\n", obj);
891 GDI_ReleaseObj( obj );
892 return TRUE;
895 while (header->hdcs)
897 DC *dc = DC_GetDCPtr(header->hdcs->hdc);
898 struct hdc_list *tmp;
900 TRACE("hdc %p has interest in %p\n", header->hdcs->hdc, obj);
901 if(dc)
903 if(dc->funcs->pDeleteObject)
904 dc->funcs->pDeleteObject( dc->physDev, obj );
905 GDI_ReleaseObj( header->hdcs->hdc );
907 tmp = header->hdcs;
908 header->hdcs = header->hdcs->next;
909 HeapFree(GetProcessHeap(), 0, tmp);
912 if (header->dwCount)
914 TRACE("delayed for %p because object in use, count %ld\n", obj, header->dwCount );
915 header->dwCount |= 0x80000000; /* mark for delete */
916 GDI_ReleaseObj( obj );
917 return TRUE;
920 TRACE("%p\n", obj );
922 /* Delete object */
924 if (header->funcs && header->funcs->pDeleteObject)
925 return header->funcs->pDeleteObject( obj, header );
927 GDI_ReleaseObj( obj );
928 return FALSE;
931 /***********************************************************************
932 * GDI_hdc_using_object
934 * Call this if the dc requires DeleteObject notification
936 BOOL GDI_hdc_using_object(HGDIOBJ obj, HDC hdc)
938 GDIOBJHDR * header;
939 struct hdc_list **pphdc;
941 TRACE("obj %p hdc %p\n", obj, hdc);
943 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
945 if (!(header->wMagic & OBJECT_NOSYSTEM) &&
946 (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
948 GDI_ReleaseObj(obj);
949 return FALSE;
952 for(pphdc = &header->hdcs; *pphdc; pphdc = &(*pphdc)->next)
953 if((*pphdc)->hdc == hdc)
954 break;
956 if(!*pphdc) {
957 *pphdc = HeapAlloc(GetProcessHeap(), 0, sizeof(**pphdc));
958 (*pphdc)->hdc = hdc;
959 (*pphdc)->next = NULL;
962 GDI_ReleaseObj(obj);
963 return TRUE;
966 /***********************************************************************
967 * GDI_hdc_not_using_object
970 BOOL GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc)
972 GDIOBJHDR * header;
973 struct hdc_list *phdc, **prev;
975 TRACE("obj %p hdc %p\n", obj, hdc);
977 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
979 if (!(header->wMagic & OBJECT_NOSYSTEM) &&
980 (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
982 GDI_ReleaseObj(obj);
983 return FALSE;
986 phdc = header->hdcs;
987 prev = &header->hdcs;
989 while(phdc) {
990 if(phdc->hdc == hdc) {
991 *prev = phdc->next;
992 HeapFree(GetProcessHeap(), 0, phdc);
993 phdc = *prev;
994 } else {
995 prev = &phdc->next;
996 phdc = phdc->next;
1000 GDI_ReleaseObj(obj);
1001 return TRUE;
1004 /***********************************************************************
1005 * GetStockObject (GDI32.@)
1007 HGDIOBJ WINAPI GetStockObject( INT obj )
1009 HGDIOBJ ret;
1010 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
1011 ret = stock_objects[obj];
1012 TRACE("returning %p\n", ret );
1013 return ret;
1017 /***********************************************************************
1018 * GetObject (GDI.82)
1020 INT16 WINAPI GetObject16( HANDLE16 handle16, INT16 count, LPVOID buffer )
1022 GDIOBJHDR * ptr;
1023 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1024 INT16 result = 0;
1026 TRACE("%p %d %p\n", handle, count, buffer );
1027 if (!count) return 0;
1029 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
1031 if (ptr->funcs && ptr->funcs->pGetObject16)
1032 result = ptr->funcs->pGetObject16( handle, ptr, count, buffer );
1033 else
1034 SetLastError( ERROR_INVALID_HANDLE );
1036 GDI_ReleaseObj( handle );
1037 return result;
1041 /***********************************************************************
1042 * GetObjectA (GDI32.@)
1044 INT WINAPI GetObjectA( HANDLE handle, INT count, LPVOID buffer )
1046 GDIOBJHDR * ptr;
1047 INT result = 0;
1048 TRACE("%p %d %p\n", handle, count, buffer );
1050 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
1052 if (ptr->funcs && ptr->funcs->pGetObjectA)
1053 result = ptr->funcs->pGetObjectA( handle, ptr, count, buffer );
1054 else
1055 SetLastError( ERROR_INVALID_HANDLE );
1057 GDI_ReleaseObj( handle );
1058 return result;
1061 /***********************************************************************
1062 * GetObjectW (GDI32.@)
1064 INT WINAPI GetObjectW( HANDLE handle, INT count, LPVOID buffer )
1066 GDIOBJHDR * ptr;
1067 INT result = 0;
1068 TRACE("%p %d %p\n", handle, count, buffer );
1070 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
1072 if (ptr->funcs && ptr->funcs->pGetObjectW)
1073 result = ptr->funcs->pGetObjectW( handle, ptr, count, buffer );
1074 else
1075 SetLastError( ERROR_INVALID_HANDLE );
1077 GDI_ReleaseObj( handle );
1078 return result;
1081 /***********************************************************************
1082 * GetObjectType (GDI32.@)
1084 DWORD WINAPI GetObjectType( HANDLE handle )
1086 GDIOBJHDR * ptr;
1087 INT result = 0;
1088 TRACE("%p\n", handle );
1090 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
1092 switch(GDIMAGIC(ptr->wMagic))
1094 case PEN_MAGIC:
1095 result = OBJ_PEN;
1096 break;
1097 case BRUSH_MAGIC:
1098 result = OBJ_BRUSH;
1099 break;
1100 case BITMAP_MAGIC:
1101 result = OBJ_BITMAP;
1102 break;
1103 case FONT_MAGIC:
1104 result = OBJ_FONT;
1105 break;
1106 case PALETTE_MAGIC:
1107 result = OBJ_PAL;
1108 break;
1109 case REGION_MAGIC:
1110 result = OBJ_REGION;
1111 break;
1112 case DC_MAGIC:
1113 result = OBJ_DC;
1114 break;
1115 case META_DC_MAGIC:
1116 result = OBJ_METADC;
1117 break;
1118 case METAFILE_MAGIC:
1119 result = OBJ_METAFILE;
1120 break;
1121 case METAFILE_DC_MAGIC:
1122 result = OBJ_METADC;
1123 break;
1124 case ENHMETAFILE_MAGIC:
1125 result = OBJ_ENHMETAFILE;
1126 break;
1127 case ENHMETAFILE_DC_MAGIC:
1128 result = OBJ_ENHMETADC;
1129 break;
1130 case MEMORY_DC_MAGIC:
1131 result = OBJ_MEMDC;
1132 break;
1133 default:
1134 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) );
1135 break;
1137 GDI_ReleaseObj( handle );
1138 return result;
1141 /***********************************************************************
1142 * GetCurrentObject (GDI32.@)
1144 HANDLE WINAPI GetCurrentObject(HDC hdc,UINT type)
1146 HANDLE ret = 0;
1147 DC * dc = DC_GetDCPtr( hdc );
1149 if (dc)
1151 switch (type) {
1152 case OBJ_PEN: ret = dc->hPen; break;
1153 case OBJ_BRUSH: ret = dc->hBrush; break;
1154 case OBJ_PAL: ret = dc->hPalette; break;
1155 case OBJ_FONT: ret = dc->hFont; break;
1156 case OBJ_BITMAP: ret = dc->hBitmap; break;
1157 default:
1158 /* the SDK only mentions those above */
1159 FIXME("(%p,%d): unknown type.\n",hdc,type);
1160 break;
1162 GDI_ReleaseObj( hdc );
1164 return ret;
1168 /***********************************************************************
1169 * SelectObject (GDI32.@)
1171 HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ handle )
1173 HGDIOBJ ret = 0;
1174 GDIOBJHDR *header = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1175 if (!header) return 0;
1177 TRACE("hdc=%p %p\n", hdc, handle );
1179 if (header->funcs && header->funcs->pSelectObject)
1181 ret = header->funcs->pSelectObject( handle, header, hdc );
1182 if (ret && ret != handle && (INT)ret > COMPLEXREGION)
1184 inc_ref_count( handle );
1185 dec_ref_count( ret );
1188 GDI_ReleaseObj( handle );
1189 return ret;
1193 /***********************************************************************
1194 * UnrealizeObject (GDI32.@)
1196 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1198 BOOL result = TRUE;
1199 /* Check if object is valid */
1201 GDIOBJHDR * header = GDI_GetObjPtr( obj, MAGIC_DONTCARE );
1202 if (!header) return FALSE;
1204 TRACE("%p\n", obj );
1206 /* Unrealize object */
1208 if (header->funcs && header->funcs->pUnrealizeObject)
1209 result = header->funcs->pUnrealizeObject( obj, header );
1211 GDI_ReleaseObj( obj );
1212 return result;
1216 /* Solid colors to enumerate */
1217 static const COLORREF solid_colors[] =
1218 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1219 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1220 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1221 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1222 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1223 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1224 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1225 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1229 /***********************************************************************
1230 * EnumObjects (GDI32.@)
1232 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1233 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1235 INT i, retval = 0;
1236 LOGPEN pen;
1237 LOGBRUSH brush;
1239 TRACE("%p %d %p %08lx\n", hdc, nObjType, lpEnumFunc, lParam );
1240 switch(nObjType)
1242 case OBJ_PEN:
1243 /* Enumerate solid pens */
1244 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1246 pen.lopnStyle = PS_SOLID;
1247 pen.lopnWidth.x = 1;
1248 pen.lopnWidth.y = 0;
1249 pen.lopnColor = solid_colors[i];
1250 retval = lpEnumFunc( &pen, lParam );
1251 TRACE("solid pen %08lx, ret=%d\n",
1252 solid_colors[i], retval);
1253 if (!retval) break;
1255 break;
1257 case OBJ_BRUSH:
1258 /* Enumerate solid brushes */
1259 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1261 brush.lbStyle = BS_SOLID;
1262 brush.lbColor = solid_colors[i];
1263 brush.lbHatch = 0;
1264 retval = lpEnumFunc( &brush, lParam );
1265 TRACE("solid brush %08lx, ret=%d\n",
1266 solid_colors[i], retval);
1267 if (!retval) break;
1270 /* Now enumerate hatched brushes */
1271 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1273 brush.lbStyle = BS_HATCHED;
1274 brush.lbColor = RGB(0,0,0);
1275 brush.lbHatch = i;
1276 retval = lpEnumFunc( &brush, lParam );
1277 TRACE("hatched brush %d, ret=%d\n",
1278 i, retval);
1279 if (!retval) break;
1281 break;
1283 default:
1284 /* FIXME: implement Win32 types */
1285 WARN("(%d): Invalid type\n", nObjType );
1286 break;
1288 return retval;
1292 /***********************************************************************
1293 * IsGDIObject (GDI.462)
1295 * returns type of object if valid (W95 system programming secrets p. 264-5)
1297 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
1299 UINT16 magic = 0;
1300 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1302 GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1303 if (object)
1305 magic = GDIMAGIC(object->wMagic) - PEN_MAGIC + 1;
1306 GDI_ReleaseObj( handle );
1308 return magic;
1312 /***********************************************************************
1313 * SetObjectOwner (GDI32.@)
1315 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1317 /* Nothing to do */
1321 /***********************************************************************
1322 * MakeObjectPrivate (GDI.463)
1324 * What does that mean ?
1325 * Some little docu can be found in "Undocumented Windows",
1326 * but this is basically useless.
1327 * At least we know that this flags the GDI object's wMagic
1328 * with 0x2000 (OBJECT_PRIVATE), so we just do it.
1329 * But Wine doesn't react on that yet.
1331 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
1333 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1334 GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1335 if (!ptr)
1337 ERR("invalid GDI object %p !\n", handle);
1338 return;
1340 ptr->wMagic |= OBJECT_PRIVATE;
1341 GDI_ReleaseObj( handle );
1345 /***********************************************************************
1346 * GdiFlush (GDI32.@)
1348 BOOL WINAPI GdiFlush(void)
1350 return TRUE; /* FIXME */
1354 /***********************************************************************
1355 * GdiGetBatchLimit (GDI32.@)
1357 DWORD WINAPI GdiGetBatchLimit(void)
1359 return 1; /* FIXME */
1363 /***********************************************************************
1364 * GdiSetBatchLimit (GDI32.@)
1366 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1368 return 1; /* FIXME */
1372 /***********************************************************************
1373 * GdiSeeGdiDo (GDI.452)
1375 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
1376 WORD wParam3 )
1378 switch (wReqType)
1380 case 0x0001: /* LocalAlloc */
1381 return LOCAL_Alloc( GDI_HeapSel, wParam1, wParam3 );
1382 case 0x0002: /* LocalFree */
1383 return LOCAL_Free( GDI_HeapSel, wParam1 );
1384 case 0x0003: /* LocalCompact */
1385 return LOCAL_Compact( GDI_HeapSel, wParam3, 0 );
1386 case 0x0103: /* LocalHeap */
1387 return GDI_HeapSel;
1388 default:
1389 WARN("(wReqType=%04x): Unknown\n", wReqType);
1390 return ~0UL;
1394 /***********************************************************************
1395 * GdiSignalProc32 (GDI.610)
1397 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
1398 DWORD dwFlags, HMODULE16 hModule )
1400 return 0;
1403 /***********************************************************************
1404 * GdiInit2 (GDI.403)
1406 * See "Undocumented Windows"
1408 HANDLE16 WINAPI GdiInit216(
1409 HANDLE16 h1, /* [in] GDI object */
1410 HANDLE16 h2 /* [in] global data */
1413 FIXME("(%04x, %04x), stub.\n", h1, h2);
1414 if (h2 == 0xffff)
1415 return 0xffff; /* undefined return value */
1416 return h1; /* FIXME: should be the memory handle of h1 */
1419 /***********************************************************************
1420 * FinalGdiInit (GDI.405)
1422 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
1426 /***********************************************************************
1427 * GdiFreeResources (GDI.609)
1429 WORD WINAPI GdiFreeResources16( DWORD reserve )
1431 return (WORD)( (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
1432 (int)LOCAL_HeapSize( GDI_HeapSel ) );
1436 /*******************************************************************
1437 * GetColorAdjustment [GDI32.@]
1441 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1443 FIXME("GetColorAdjustment, stub\n");
1444 return 0;
1447 /*******************************************************************
1448 * GetMiterLimit [GDI32.@]
1452 BOOL WINAPI GetMiterLimit(HDC hdc, PFLOAT peLimit)
1454 FIXME("GetMiterLimit, stub\n");
1455 return 0;
1458 /*******************************************************************
1459 * SetMiterLimit [GDI32.@]
1463 BOOL WINAPI SetMiterLimit(HDC hdc, FLOAT eNewLimit, PFLOAT peOldLimit)
1465 FIXME("SetMiterLimit, stub\n");
1466 return 0;
1469 /*******************************************************************
1470 * GdiComment [GDI32.@]
1474 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1476 DC *dc = DC_GetDCPtr(hdc);
1477 BOOL ret = FALSE;
1478 if(dc)
1480 if (dc->funcs->pGdiComment)
1481 ret = dc->funcs->pGdiComment( dc->physDev, cbSize, lpData );
1483 GDI_ReleaseObj( hdc );
1484 return ret;
1487 /*******************************************************************
1488 * SetColorAdjustment [GDI32.@]
1492 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1494 FIXME("SetColorAdjustment, stub\n");
1495 return 0;