wintrust: Don't prefer native version.
[wine/multimedia.git] / dlls / gdi32 / gdiobj.c
blob0388c71b941624cfc1f2619f13f8e94e62232660
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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"
33 #include "winternl.h"
35 #include "gdi_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
40 #define HGDIOBJ_32(h16) ((HGDIOBJ)(ULONG_PTR)(h16))
42 #define GDI_HEAP_SIZE 0xffe0
44 /***********************************************************************
45 * GDI stock objects
48 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
49 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
50 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
52 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
53 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
54 static const LOGBRUSH DkGrayBrush = { BS_SOLID, RGB(64,64,64), 0 };
56 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
57 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
58 static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
60 static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 };
61 static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
63 /* reserve one extra entry for the stock default bitmap */
64 /* this is what Windows does too */
65 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
67 static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
69 static SYSLEVEL GDI_level;
70 static CRITICAL_SECTION_DEBUG critsect_debug =
72 0, 0, &GDI_level.crst,
73 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
74 0, 0, { (DWORD_PTR)(__FILE__ ": GDI_level") }
76 static SYSLEVEL GDI_level = { { &critsect_debug, -1, 0, 0, 0, 0 }, 3 };
79 /****************************************************************************
81 * language-independent stock fonts
85 static const LOGFONTW OEMFixedFont =
86 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
87 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
89 static const LOGFONTW AnsiFixedFont =
90 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
91 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
93 static const LOGFONTW AnsiVarFont =
94 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
95 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
96 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
98 /******************************************************************************
100 * language-dependent stock fonts
102 * 'ANSI' charset and 'DEFAULT' charset is not same.
103 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
104 * 'ANSI' charset seems to be identical with ISO-8859-1.
105 * 'DEFAULT' charset is a language-dependent charset.
107 * 'System' font seems to be an alias for language-dependent font.
111 * language-dependent stock fonts for all known charsets
112 * please see TranslateCharsetInfo (dlls/gdi/font.c) and
113 * CharsetBindingInfo (dlls/x11drv/xfont.c),
114 * and modify entries for your language if needed.
116 struct DefaultFontInfo
118 UINT charset;
119 LOGFONTW SystemFont;
120 LOGFONTW DeviceDefaultFont;
121 LOGFONTW SystemFixedFont;
122 LOGFONTW DefaultGuiFont; /* Note for this font the lfHeight member should be the point size */
125 static const struct DefaultFontInfo default_fonts[] =
127 { ANSI_CHARSET,
128 { /* System */
129 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
130 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
131 {'S','y','s','t','e','m','\0'}
133 { /* Device Default */
134 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
135 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
136 {'\0'}
138 { /* System Fixed */
139 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
140 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
141 {'\0'}
143 { /* DefaultGuiFont */
144 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
145 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
146 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
149 { EASTEUROPE_CHARSET,
150 { /* System */
151 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
152 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
153 {'S','y','s','t','e','m','\0'}
155 { /* Device Default */
156 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
157 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
158 {'\0'}
160 { /* System Fixed */
161 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
162 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
163 {'\0'}
165 { /* DefaultGuiFont */
166 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
167 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
168 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
171 { RUSSIAN_CHARSET,
172 { /* System */
173 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
174 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
175 {'S','y','s','t','e','m','\0'}
177 { /* Device Default */
178 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
179 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
180 {'\0'}
182 { /* System Fixed */
183 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
184 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
185 {'\0'}
187 { /* DefaultGuiFont */
188 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
189 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
190 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
193 { GREEK_CHARSET,
194 { /* System */
195 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
196 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
197 {'S','y','s','t','e','m','\0'}
199 { /* Device Default */
200 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
201 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
202 {'\0'}
204 { /* System Fixed */
205 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
206 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
207 {'\0'}
209 { /* DefaultGuiFont */
210 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
211 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
212 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
215 { TURKISH_CHARSET,
216 { /* System */
217 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
218 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
219 {'S','y','s','t','e','m','\0'}
221 { /* Device Default */
222 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
223 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
224 {'\0'}
226 { /* System Fixed */
227 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
228 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
229 {'\0'}
231 { /* DefaultGuiFont */
232 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
233 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
234 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
237 { HEBREW_CHARSET,
238 { /* System */
239 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
240 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
241 {'S','y','s','t','e','m','\0'}
243 { /* Device Default */
244 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
245 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
246 {'\0'}
248 { /* System Fixed */
249 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
250 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
251 {'\0'}
253 { /* DefaultGuiFont */
254 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
255 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
256 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
259 { ARABIC_CHARSET,
260 { /* System */
261 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
262 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
263 {'S','y','s','t','e','m','\0'}
265 { /* Device Default */
266 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
267 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
268 {'\0'}
270 { /* System Fixed */
271 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
272 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
273 {'\0'}
275 { /* DefaultGuiFont */
276 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
277 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
278 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
281 { BALTIC_CHARSET,
282 { /* System */
283 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
284 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
285 {'S','y','s','t','e','m','\0'}
287 { /* Device Default */
288 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
289 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
290 {'\0'}
292 { /* System Fixed */
293 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
294 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
295 {'\0'}
297 { /* DefaultGuiFont */
298 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
299 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
300 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
303 { THAI_CHARSET,
304 { /* System */
305 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
306 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
307 {'S','y','s','t','e','m','\0'}
309 { /* Device Default */
310 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
311 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
312 {'\0'}
314 { /* System Fixed */
315 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
316 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
317 {'\0'}
319 { /* DefaultGuiFont */
320 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
321 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
322 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
325 { SHIFTJIS_CHARSET,
326 { /* System */
327 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
328 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
329 {'S','y','s','t','e','m','\0'}
331 { /* Device Default */
332 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
333 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
334 {'\0'}
336 { /* System Fixed */
337 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
338 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
339 {'\0'}
341 { /* DefaultGuiFont */
342 9, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
343 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
344 {'M','S',' ','U','I',' ','G','o','t','h','i','c','\0'}
347 { GB2312_CHARSET,
348 { /* System */
349 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
350 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
351 {'S','y','s','t','e','m','\0'}
353 { /* Device Default */
354 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
355 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
356 {'\0'}
358 { /* System Fixed */
359 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
360 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
361 {'\0'}
363 { /* DefaultGuiFont */
364 9, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
365 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
366 {'M','S',' ','S','o','n','g','\0'} /* FIXME: Is this correct? */
369 { HANGEUL_CHARSET,
370 { /* System */
371 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
372 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
373 {'S','y','s','t','e','m','\0'}
375 { /* Device Default */
376 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
377 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
378 {'\0'}
380 { /* System Fixed */
381 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
382 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
383 {'\0'}
385 { /* DefaultGuiFont */
386 9, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
387 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
388 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
391 { CHINESEBIG5_CHARSET,
392 { /* System */
393 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
394 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
395 {'S','y','s','t','e','m','\0'}
397 { /* Device Default */
398 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
399 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
400 {'\0'}
402 { /* System Fixed */
403 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
404 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
405 {'\0'}
407 { /* DefaultGuiFont */
408 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
409 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
410 {'\0'} /* FIXME - what is the native font??? */
413 { JOHAB_CHARSET,
414 { /* System */
415 16, 7, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
416 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
417 {'S','y','s','t','e','m','\0'}
419 { /* Device Default */
420 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
421 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
422 {'\0'}
424 { /* System Fixed */
425 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
426 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
427 {'\0'}
429 { /* DefaultGuiFont */
430 8, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
431 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
432 {'M','S',' ','S','h','e','l','l',' ','D','l','g','\0'}
438 /*************************************************************************
439 * __wine_make_gdi_object_system (GDI32.@)
441 * USER has to tell GDI that its system brushes and pens are non-deletable.
442 * For a description of the GDI object magics and their flags,
443 * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though).
445 void __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set)
447 GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
449 /* touch the "system" bit of the wMagic field of a GDIOBJHDR */
450 if (set)
451 ptr->wMagic &= ~OBJECT_NOSYSTEM;
452 else
453 ptr->wMagic |= OBJECT_NOSYSTEM;
455 GDI_ReleaseObj( handle );
458 /******************************************************************************
459 * get_default_fonts
461 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
463 unsigned int n;
465 for(n=0;n<(sizeof(default_fonts)/sizeof(default_fonts[0]));n++)
467 if ( default_fonts[n].charset == charset )
468 return &default_fonts[n];
471 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
472 return &default_fonts[0];
476 /******************************************************************************
477 * get_default_charset (internal)
479 * get the language-dependent charset that can handle CP_ACP correctly.
481 static UINT get_default_charset( void )
483 CHARSETINFO csi;
484 UINT uACP;
486 uACP = GetACP();
487 csi.ciCharset = ANSI_CHARSET;
488 if ( !TranslateCharsetInfo( ULongToPtr(uACP), &csi, TCI_SRCCODEPAGE ) )
490 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
491 return ANSI_CHARSET;
494 return csi.ciCharset;
497 static const WCHAR dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
498 static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s','\0'};
500 /******************************************************************************
501 * get_dpi (internal)
503 * get the dpi from the registry
505 static DWORD get_dpi( void )
507 DWORD dpi = 96;
508 HKEY hkey;
510 if (RegOpenKeyW(HKEY_CURRENT_CONFIG, dpi_key_name, &hkey) == ERROR_SUCCESS)
512 DWORD type, size, new_dpi;
514 size = sizeof(new_dpi);
515 if(RegQueryValueExW(hkey, dpi_value_name, NULL, &type, (void *)&new_dpi, &size) == ERROR_SUCCESS)
517 if(type == REG_DWORD && new_dpi != 0)
518 dpi = new_dpi;
520 RegCloseKey(hkey);
522 return dpi;
526 /***********************************************************************
527 * inc_ref_count
529 * Increment the reference count of a GDI object.
531 static inline void inc_ref_count( GDIOBJHDR *header )
533 header->dwCount++;
537 /***********************************************************************
538 * dec_ref_count
540 * Decrement the reference count of a GDI object.
542 static inline void dec_ref_count( HGDIOBJ handle )
544 GDIOBJHDR *header;
546 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
548 if (header->dwCount) header->dwCount--;
549 if (header->dwCount != 0x80000000) GDI_ReleaseObj( handle );
550 else
552 /* handle delayed DeleteObject*/
553 header->dwCount = 0;
554 GDI_ReleaseObj( handle );
555 TRACE( "executing delayed DeleteObject for %p\n", handle );
556 DeleteObject( handle );
562 /***********************************************************************
563 * GDI_Init
565 * GDI initialization.
567 BOOL GDI_Init(void)
569 LOGFONTW default_gui_font;
570 const struct DefaultFontInfo* deffonts;
571 int i;
573 WineEngInit();
575 /* create stock objects */
576 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
577 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
578 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
579 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
580 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
581 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
583 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
584 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
585 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
587 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
588 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
590 /* language-independent stock fonts */
591 stock_objects[OEM_FIXED_FONT] = CreateFontIndirectW( &OEMFixedFont );
592 stock_objects[ANSI_FIXED_FONT] = CreateFontIndirectW( &AnsiFixedFont );
593 stock_objects[ANSI_VAR_FONT] = CreateFontIndirectW( &AnsiVarFont );
595 /* language-dependent stock fonts */
596 deffonts = get_default_fonts(get_default_charset());
597 stock_objects[SYSTEM_FONT] = CreateFontIndirectW( &deffonts->SystemFont );
598 stock_objects[DEVICE_DEFAULT_FONT] = CreateFontIndirectW( &deffonts->DeviceDefaultFont );
599 stock_objects[SYSTEM_FIXED_FONT] = CreateFontIndirectW( &deffonts->SystemFixedFont );
601 /* For the default gui font, we use the lfHeight member in deffonts as a place-holder
602 for the point size so we must convert this into a true height */
603 memcpy(&default_gui_font, &deffonts->DefaultGuiFont, sizeof(default_gui_font));
604 default_gui_font.lfHeight = -MulDiv(default_gui_font.lfHeight, get_dpi(), 72);
605 stock_objects[DEFAULT_GUI_FONT] = CreateFontIndirectW( &default_gui_font );
607 stock_objects[DC_BRUSH] = CreateBrushIndirect( &DCBrush );
608 stock_objects[DC_PEN] = CreatePenIndirect( &DCPen );
610 /* clear the NOSYSTEM bit on all stock objects*/
611 for (i = 0; i < NB_STOCK_OBJECTS; i++)
613 if (!stock_objects[i])
615 if (i == 9) continue; /* there's no stock object 9 */
616 ERR( "could not create stock object %d\n", i );
617 return FALSE;
619 __wine_make_gdi_object_system( stock_objects[i], TRUE );
622 return TRUE;
625 #define FIRST_LARGE_HANDLE 16
626 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
627 static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES];
628 static int next_large_handle;
630 /***********************************************************************
631 * alloc_large_heap
633 * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject
635 static inline GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle )
637 int i;
638 GDIOBJHDR *obj;
640 for (i = next_large_handle + 1; i < MAX_LARGE_HANDLES; i++)
641 if (!large_handles[i]) goto found;
642 for (i = 0; i <= next_large_handle; i++)
643 if (!large_handles[i]) goto found;
644 *handle = 0;
645 return NULL;
647 found:
648 if ((obj = HeapAlloc( GetProcessHeap(), 0, size )))
650 large_handles[i] = obj;
651 *handle = (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
652 next_large_handle = i;
654 return obj;
658 /***********************************************************************
659 * GDI_AllocObject
661 void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_obj_funcs *funcs )
663 GDIOBJHDR *obj = NULL;
665 _EnterSysLevel( &GDI_level );
666 if (!(obj = alloc_large_heap( size, handle ))) goto error;
668 obj->wMagic = magic|OBJECT_NOSYSTEM;
669 obj->dwCount = 0;
670 obj->funcs = funcs;
671 obj->hdcs = NULL;
673 TRACE("(%p): enter %d\n", *handle, GDI_level.crst.RecursionCount);
674 return obj;
676 error:
677 _LeaveSysLevel( &GDI_level );
678 *handle = 0;
679 return NULL;
683 /***********************************************************************
684 * GDI_ReallocObject
686 * The object ptr must have been obtained with GDI_GetObjPtr.
687 * The new pointer must be released with GDI_ReleaseObj.
689 void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object )
691 void *new_ptr = NULL;
692 int i;
694 i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
695 if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
697 new_ptr = HeapReAlloc( GetProcessHeap(), 0, large_handles[i], size );
698 if (new_ptr) large_handles[i] = new_ptr;
700 else ERR( "Invalid handle %p\n", handle );
701 if (!new_ptr)
703 TRACE("(%p): leave %d\n", handle, GDI_level.crst.RecursionCount);
704 _LeaveSysLevel( &GDI_level );
706 return new_ptr;
710 /***********************************************************************
711 * GDI_FreeObject
713 BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
715 GDIOBJHDR *object = ptr;
716 int i;
718 object->wMagic = 0; /* Mark it as invalid */
719 object->funcs = NULL;
720 i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
721 if (i >= 0 && i < MAX_LARGE_HANDLES)
723 HeapFree( GetProcessHeap(), 0, large_handles[i] );
724 large_handles[i] = NULL;
726 else ERR( "Invalid handle %p\n", handle );
727 TRACE("(%p): leave %d\n", handle, GDI_level.crst.RecursionCount);
728 _LeaveSysLevel( &GDI_level );
729 return TRUE;
733 /***********************************************************************
734 * GDI_GetObjPtr
736 * Return a pointer to the GDI object associated to the handle.
737 * Return NULL if the object has the wrong magic number.
738 * The object must be released with GDI_ReleaseObj.
740 void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
742 GDIOBJHDR *ptr = NULL;
743 int i;
745 _EnterSysLevel( &GDI_level );
747 i = ((UINT_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
748 if (i >= 0 && i < MAX_LARGE_HANDLES)
750 ptr = large_handles[i];
751 if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL;
754 if (!ptr)
756 _LeaveSysLevel( &GDI_level );
757 WARN( "Invalid handle %p\n", handle );
759 else TRACE("(%p): enter %d\n", handle, GDI_level.crst.RecursionCount);
761 return ptr;
765 /***********************************************************************
766 * GDI_ReleaseObj
769 void GDI_ReleaseObj( HGDIOBJ handle )
771 TRACE("(%p): leave %d\n", handle, GDI_level.crst.RecursionCount);
772 _LeaveSysLevel( &GDI_level );
776 /***********************************************************************
777 * GDI_CheckNotLock
779 void GDI_CheckNotLock(void)
781 _CheckNotSysLevel( &GDI_level );
785 /***********************************************************************
786 * DeleteObject (GDI32.@)
788 * Delete a Gdi object.
790 * PARAMS
791 * obj [I] Gdi object to delete
793 * RETURNS
794 * Success: TRUE. If obj was not returned from GetStockObject(), any resources
795 * it consumed are released.
796 * Failure: FALSE, if obj is not a valid Gdi object, or is currently selected
797 * into a DC.
799 BOOL WINAPI DeleteObject( HGDIOBJ obj )
801 /* Check if object is valid */
803 GDIOBJHDR * header;
804 if (HIWORD(obj)) return FALSE;
806 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
808 if (!(header->wMagic & OBJECT_NOSYSTEM)
809 && (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
811 TRACE("Preserving system object %p\n", obj);
812 GDI_ReleaseObj( obj );
813 return TRUE;
816 while (header->hdcs)
818 DC *dc = DC_GetDCPtr(header->hdcs->hdc);
819 struct hdc_list *tmp;
821 TRACE("hdc %p has interest in %p\n", header->hdcs->hdc, obj);
822 if(dc)
824 if(dc->funcs->pDeleteObject)
825 dc->funcs->pDeleteObject( dc->physDev, obj );
826 DC_ReleaseDCPtr( dc );
828 tmp = header->hdcs;
829 header->hdcs = header->hdcs->next;
830 HeapFree(GetProcessHeap(), 0, tmp);
833 if (header->dwCount)
835 TRACE("delayed for %p because object in use, count %d\n", obj, header->dwCount );
836 header->dwCount |= 0x80000000; /* mark for delete */
837 GDI_ReleaseObj( obj );
838 return TRUE;
841 TRACE("%p\n", obj );
843 /* Delete object */
845 if (header->funcs && header->funcs->pDeleteObject)
846 return header->funcs->pDeleteObject( obj, header );
848 GDI_ReleaseObj( obj );
849 return FALSE;
852 /***********************************************************************
853 * GDI_hdc_using_object
855 * Call this if the dc requires DeleteObject notification
857 BOOL GDI_hdc_using_object(HGDIOBJ obj, HDC hdc)
859 GDIOBJHDR * header;
860 struct hdc_list **pphdc;
862 TRACE("obj %p hdc %p\n", obj, hdc);
864 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
866 if (!(header->wMagic & OBJECT_NOSYSTEM) &&
867 (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
869 GDI_ReleaseObj(obj);
870 return FALSE;
873 for(pphdc = &header->hdcs; *pphdc; pphdc = &(*pphdc)->next)
874 if((*pphdc)->hdc == hdc)
875 break;
877 if(!*pphdc) {
878 *pphdc = HeapAlloc(GetProcessHeap(), 0, sizeof(**pphdc));
879 (*pphdc)->hdc = hdc;
880 (*pphdc)->next = NULL;
883 GDI_ReleaseObj(obj);
884 return TRUE;
887 /***********************************************************************
888 * GDI_hdc_not_using_object
891 BOOL GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc)
893 GDIOBJHDR * header;
894 struct hdc_list *phdc, **prev;
896 TRACE("obj %p hdc %p\n", obj, hdc);
898 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
900 if (!(header->wMagic & OBJECT_NOSYSTEM) &&
901 (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
903 GDI_ReleaseObj(obj);
904 return FALSE;
907 phdc = header->hdcs;
908 prev = &header->hdcs;
910 while(phdc) {
911 if(phdc->hdc == hdc) {
912 *prev = phdc->next;
913 HeapFree(GetProcessHeap(), 0, phdc);
914 phdc = *prev;
915 } else {
916 prev = &phdc->next;
917 phdc = phdc->next;
921 GDI_ReleaseObj(obj);
922 return TRUE;
925 /***********************************************************************
926 * GetStockObject (GDI32.@)
928 HGDIOBJ WINAPI GetStockObject( INT obj )
930 HGDIOBJ ret;
931 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
932 ret = stock_objects[obj];
933 TRACE("returning %p\n", ret );
934 return ret;
938 /***********************************************************************
939 * GetObject (GDI.82)
941 INT16 WINAPI GetObject16( HGDIOBJ16 handle16, INT16 count, LPVOID buffer )
943 GDIOBJHDR * ptr;
944 HGDIOBJ handle = HGDIOBJ_32( handle16 );
945 INT16 result = 0;
947 TRACE("%p %d %p\n", handle, count, buffer );
948 if (!count) return 0;
950 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
952 if (ptr->funcs && ptr->funcs->pGetObject16)
953 result = ptr->funcs->pGetObject16( handle, ptr, count, buffer );
954 else
955 SetLastError( ERROR_INVALID_HANDLE );
957 GDI_ReleaseObj( handle );
958 return result;
962 /***********************************************************************
963 * GetObjectA (GDI32.@)
965 INT WINAPI GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer )
967 GDIOBJHDR * ptr;
968 INT result = 0;
969 TRACE("%p %d %p\n", handle, count, buffer );
971 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
973 if (ptr->funcs && ptr->funcs->pGetObjectA)
974 result = ptr->funcs->pGetObjectA( handle, ptr, count, buffer );
975 else
976 SetLastError( ERROR_INVALID_HANDLE );
978 GDI_ReleaseObj( handle );
979 return result;
982 /***********************************************************************
983 * GetObjectW (GDI32.@)
985 INT WINAPI GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer )
987 GDIOBJHDR * ptr;
988 INT result = 0;
989 TRACE("%p %d %p\n", handle, count, buffer );
991 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
993 if (ptr->funcs && ptr->funcs->pGetObjectW)
994 result = ptr->funcs->pGetObjectW( handle, ptr, count, buffer );
995 else
996 SetLastError( ERROR_INVALID_HANDLE );
998 GDI_ReleaseObj( handle );
999 return result;
1002 /***********************************************************************
1003 * GetObjectType (GDI32.@)
1005 DWORD WINAPI GetObjectType( HGDIOBJ handle )
1007 GDIOBJHDR * ptr;
1008 INT result = 0;
1009 TRACE("%p\n", handle );
1011 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
1013 SetLastError( ERROR_INVALID_HANDLE );
1014 return 0;
1017 switch(GDIMAGIC(ptr->wMagic))
1019 case PEN_MAGIC:
1020 result = OBJ_PEN;
1021 break;
1022 case EXT_PEN_MAGIC:
1023 result = OBJ_EXTPEN;
1024 break;
1025 case BRUSH_MAGIC:
1026 result = OBJ_BRUSH;
1027 break;
1028 case BITMAP_MAGIC:
1029 result = OBJ_BITMAP;
1030 break;
1031 case FONT_MAGIC:
1032 result = OBJ_FONT;
1033 break;
1034 case PALETTE_MAGIC:
1035 result = OBJ_PAL;
1036 break;
1037 case REGION_MAGIC:
1038 result = OBJ_REGION;
1039 break;
1040 case DC_MAGIC:
1041 result = OBJ_DC;
1042 break;
1043 case META_DC_MAGIC:
1044 result = OBJ_METADC;
1045 break;
1046 case METAFILE_MAGIC:
1047 result = OBJ_METAFILE;
1048 break;
1049 case METAFILE_DC_MAGIC:
1050 result = OBJ_METADC;
1051 break;
1052 case ENHMETAFILE_MAGIC:
1053 result = OBJ_ENHMETAFILE;
1054 break;
1055 case ENHMETAFILE_DC_MAGIC:
1056 result = OBJ_ENHMETADC;
1057 break;
1058 case MEMORY_DC_MAGIC:
1059 result = OBJ_MEMDC;
1060 break;
1061 default:
1062 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) );
1063 break;
1065 GDI_ReleaseObj( handle );
1066 return result;
1069 /***********************************************************************
1070 * GetCurrentObject (GDI32.@)
1072 * Get the currently selected object of a given type in a device context.
1074 * PARAMS
1075 * hdc [I] Device context to get the current object from
1076 * type [I] Type of current object to get (OBJ_* defines from "wingdi.h")
1078 * RETURNS
1079 * Success: The current object of the given type selected in hdc.
1080 * Failure: A NULL handle.
1082 * NOTES
1083 * - only the following object types are supported:
1084 *| OBJ_PEN
1085 *| OBJ_BRUSH
1086 *| OBJ_PAL
1087 *| OBJ_FONT
1088 *| OBJ_BITMAP
1090 HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
1092 HGDIOBJ ret = 0;
1093 DC * dc = DC_GetDCPtr( hdc );
1095 if (dc)
1097 switch (type) {
1098 case OBJ_EXTPEN: /* fall through */
1099 case OBJ_PEN: ret = dc->hPen; break;
1100 case OBJ_BRUSH: ret = dc->hBrush; break;
1101 case OBJ_PAL: ret = dc->hPalette; break;
1102 case OBJ_FONT: ret = dc->hFont; break;
1103 case OBJ_BITMAP: ret = dc->hBitmap; break;
1105 /* tests show that OBJ_REGION is explicitly ignored */
1106 case OBJ_REGION: break;
1107 default:
1108 /* the SDK only mentions those above */
1109 FIXME("(%p,%d): unknown type.\n",hdc,type);
1110 break;
1112 DC_ReleaseDCPtr( dc );
1114 return ret;
1118 /***********************************************************************
1119 * SelectObject (GDI32.@)
1121 * Select a Gdi object into a device context.
1123 * PARAMS
1124 * hdc [I] Device context to associate the object with
1125 * hObj [I] Gdi object to associate with hdc
1127 * RETURNS
1128 * Success: A non-NULL handle representing the previously selected object of
1129 * the same type as hObj.
1130 * Failure: A NULL object. If hdc is invalid, GetLastError() returns ERROR_INVALID_HANDLE.
1131 * if hObj is not a valid object handle, no last error is set. In either
1132 * case, hdc is unaffected by the call.
1134 HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ hObj )
1136 HGDIOBJ ret = 0;
1137 GDIOBJHDR *header;
1138 DC *dc;
1140 TRACE( "(%p,%p)\n", hdc, hObj );
1142 if (!(dc = DC_GetDCPtr( hdc )))
1143 SetLastError( ERROR_INVALID_HANDLE );
1144 else
1146 DC_ReleaseDCPtr( dc );
1148 header = GDI_GetObjPtr( hObj, MAGIC_DONTCARE );
1149 if (header)
1151 if (header->funcs && header->funcs->pSelectObject)
1153 ret = header->funcs->pSelectObject( hObj, header, hdc );
1154 if (ret && ret != hObj && HandleToULong(ret) > COMPLEXREGION)
1156 inc_ref_count( header );
1157 dec_ref_count( ret );
1160 GDI_ReleaseObj( hObj );
1163 return ret;
1167 /***********************************************************************
1168 * UnrealizeObject (GDI32.@)
1170 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1172 BOOL result = TRUE;
1173 /* Check if object is valid */
1175 GDIOBJHDR * header = GDI_GetObjPtr( obj, MAGIC_DONTCARE );
1176 if (!header) return FALSE;
1178 TRACE("%p\n", obj );
1180 /* Unrealize object */
1182 if (header->funcs && header->funcs->pUnrealizeObject)
1183 result = header->funcs->pUnrealizeObject( obj, header );
1185 GDI_ReleaseObj( obj );
1186 return result;
1190 /* Solid colors to enumerate */
1191 static const COLORREF solid_colors[] =
1192 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1193 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1194 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1195 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1196 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1197 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1198 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1199 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1203 /***********************************************************************
1204 * EnumObjects (GDI32.@)
1206 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1207 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1209 UINT i;
1210 INT retval = 0;
1211 LOGPEN pen;
1212 LOGBRUSH brush;
1214 TRACE("%p %d %p %08lx\n", hdc, nObjType, lpEnumFunc, lParam );
1215 switch(nObjType)
1217 case OBJ_PEN:
1218 /* Enumerate solid pens */
1219 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1221 pen.lopnStyle = PS_SOLID;
1222 pen.lopnWidth.x = 1;
1223 pen.lopnWidth.y = 0;
1224 pen.lopnColor = solid_colors[i];
1225 retval = lpEnumFunc( &pen, lParam );
1226 TRACE("solid pen %08x, ret=%d\n",
1227 solid_colors[i], retval);
1228 if (!retval) break;
1230 break;
1232 case OBJ_BRUSH:
1233 /* Enumerate solid brushes */
1234 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1236 brush.lbStyle = BS_SOLID;
1237 brush.lbColor = solid_colors[i];
1238 brush.lbHatch = 0;
1239 retval = lpEnumFunc( &brush, lParam );
1240 TRACE("solid brush %08x, ret=%d\n",
1241 solid_colors[i], retval);
1242 if (!retval) break;
1245 /* Now enumerate hatched brushes */
1246 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1248 brush.lbStyle = BS_HATCHED;
1249 brush.lbColor = RGB(0,0,0);
1250 brush.lbHatch = i;
1251 retval = lpEnumFunc( &brush, lParam );
1252 TRACE("hatched brush %d, ret=%d\n",
1253 i, retval);
1254 if (!retval) break;
1256 break;
1258 default:
1259 /* FIXME: implement Win32 types */
1260 WARN("(%d): Invalid type\n", nObjType );
1261 break;
1263 return retval;
1267 /***********************************************************************
1268 * IsGDIObject (GDI.462)
1270 * returns type of object if valid (W95 system programming secrets p. 264-5)
1272 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
1274 UINT16 magic = 0;
1275 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1277 GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1278 if (object)
1280 magic = GDIMAGIC(object->wMagic) - FIRST_MAGIC + 1;
1281 GDI_ReleaseObj( handle );
1283 return magic;
1287 /***********************************************************************
1288 * SetObjectOwner (GDI32.@)
1290 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1292 /* Nothing to do */
1296 /***********************************************************************
1297 * MakeObjectPrivate (GDI.463)
1299 * What does that mean ?
1300 * Some little docu can be found in "Undocumented Windows",
1301 * but this is basically useless.
1302 * At least we know that this flags the GDI object's wMagic
1303 * with 0x2000 (OBJECT_PRIVATE), so we just do it.
1304 * But Wine doesn't react on that yet.
1306 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
1308 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1309 GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1310 if (!ptr)
1312 ERR("invalid GDI object %p !\n", handle);
1313 return;
1315 ptr->wMagic |= OBJECT_PRIVATE;
1316 GDI_ReleaseObj( handle );
1320 /***********************************************************************
1321 * GdiFlush (GDI32.@)
1323 BOOL WINAPI GdiFlush(void)
1325 return TRUE; /* FIXME */
1329 /***********************************************************************
1330 * GdiGetBatchLimit (GDI32.@)
1332 DWORD WINAPI GdiGetBatchLimit(void)
1334 return 1; /* FIXME */
1338 /***********************************************************************
1339 * GdiSetBatchLimit (GDI32.@)
1341 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1343 return 1; /* FIXME */
1347 /***********************************************************************
1348 * GdiSeeGdiDo (GDI.452)
1350 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
1351 WORD wParam3 )
1353 DWORD ret = ~0U;
1355 switch (wReqType)
1357 case 0x0001: /* LocalAlloc */
1358 WARN("LocalAlloc16(%x, %x): ignoring\n", wParam1, wParam3);
1359 ret = 0;
1360 break;
1361 case 0x0002: /* LocalFree */
1362 WARN("LocalFree16(%x): ignoring\n", wParam1);
1363 ret = 0;
1364 break;
1365 case 0x0003: /* LocalCompact */
1366 WARN("LocalCompact16(%x): ignoring\n", wParam3);
1367 ret = 65000; /* lie about the amount of free space */
1368 break;
1369 case 0x0103: /* LocalHeap */
1370 WARN("LocalHeap16(): ignoring\n");
1371 break;
1372 default:
1373 WARN("(wReqType=%04x): Unknown\n", wReqType);
1374 break;
1376 return ret;
1379 /***********************************************************************
1380 * GdiSignalProc32 (GDI.610)
1382 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
1383 DWORD dwFlags, HMODULE16 hModule )
1385 return 0;
1388 /***********************************************************************
1389 * GdiInit2 (GDI.403)
1391 * See "Undocumented Windows"
1393 * PARAMS
1394 * h1 [I] GDI object
1395 * h2 [I] global data
1397 HANDLE16 WINAPI GdiInit216( HANDLE16 h1, HANDLE16 h2 )
1399 FIXME("(%04x, %04x), stub.\n", h1, h2);
1400 if (h2 == 0xffff)
1401 return 0xffff; /* undefined return value */
1402 return h1; /* FIXME: should be the memory handle of h1 */
1405 /***********************************************************************
1406 * FinalGdiInit (GDI.405)
1408 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
1412 /***********************************************************************
1413 * GdiFreeResources (GDI.609)
1415 WORD WINAPI GdiFreeResources16( DWORD reserve )
1417 return 90; /* lie about it, it shouldn't matter */
1421 /*******************************************************************
1422 * GetColorAdjustment [GDI32.@]
1426 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1428 FIXME("GetColorAdjustment, stub\n");
1429 return 0;
1432 /*******************************************************************
1433 * GdiComment [GDI32.@]
1437 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1439 DC *dc = DC_GetDCPtr(hdc);
1440 BOOL ret = FALSE;
1441 if(dc)
1443 if (dc->funcs->pGdiComment)
1444 ret = dc->funcs->pGdiComment( dc->physDev, cbSize, lpData );
1445 DC_ReleaseDCPtr( dc );
1447 return ret;
1450 /*******************************************************************
1451 * SetColorAdjustment [GDI32.@]
1455 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1457 FIXME("SetColorAdjustment, stub\n");
1458 return 0;