gdi32: Use handle layout compatible with GdiSharedHandleTable to store handles.
[wine.git] / dlls / gdi32 / gdiobj.c
blobd0c1f0c823074d359d1ecc4ae59ab37933d97e2b
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 <assert.h>
22 #include <stdlib.h>
23 #include <stdarg.h>
24 #include <stdio.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winreg.h"
30 #include "winnls.h"
31 #include "winerror.h"
32 #include "winternl.h"
34 #include "gdi_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
39 #define FIRST_GDI_HANDLE 32
41 static GDI_SHARED_MEMORY gdi_shared;
42 static GDI_HANDLE_ENTRY *next_free;
43 static GDI_HANDLE_ENTRY *next_unused = gdi_shared.Handles + FIRST_GDI_HANDLE;
44 static LONG debug_count;
45 HMODULE gdi32_module = 0;
47 static inline HGDIOBJ entry_to_handle( GDI_HANDLE_ENTRY *entry )
49 unsigned int idx = entry - gdi_shared.Handles;
50 return LongToHandle( idx | (entry->Unique << 16) );
53 static inline GDI_HANDLE_ENTRY *handle_entry( HGDIOBJ handle )
55 unsigned int idx = LOWORD(handle);
57 if (idx < GDI_MAX_HANDLE_COUNT && gdi_shared.Handles[idx].Type)
59 if (!HIWORD( handle ) || HIWORD( handle ) == gdi_shared.Handles[idx].Unique)
60 return &gdi_shared.Handles[idx];
62 if (handle) WARN( "invalid handle %p\n", handle );
63 return NULL;
66 static inline struct gdi_obj_header *entry_obj( GDI_HANDLE_ENTRY *entry )
68 return (struct gdi_obj_header *)(ULONG_PTR)entry->Object;
71 /***********************************************************************
72 * GDI stock objects
75 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
76 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
77 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
79 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
80 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
81 static const LOGBRUSH DkGrayBrush = { BS_SOLID, RGB(64,64,64), 0 };
83 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
84 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
85 static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
87 static const LOGBRUSH DCBrush = { BS_SOLID, RGB(255,255,255), 0 };
88 static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
90 /* reserve one extra entry for the stock default bitmap */
91 /* this is what Windows does too */
92 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
94 static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
95 static HGDIOBJ scaled_stock_objects[NB_STOCK_OBJECTS];
97 static CRITICAL_SECTION gdi_section;
98 static CRITICAL_SECTION_DEBUG critsect_debug =
100 0, 0, &gdi_section,
101 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
102 0, 0, { (DWORD_PTR)(__FILE__ ": gdi_section") }
104 static CRITICAL_SECTION gdi_section = { &critsect_debug, -1, 0, 0, 0, 0 };
107 /****************************************************************************
109 * language-independent stock fonts
113 static const LOGFONTW OEMFixedFont =
114 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
115 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" };
117 static const LOGFONTW AnsiFixedFont =
118 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
119 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier" };
121 static const LOGFONTW AnsiVarFont =
122 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
123 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" };
125 /******************************************************************************
127 * language-dependent stock fonts
129 * 'ANSI' charset and 'DEFAULT' charset is not same.
130 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
131 * 'ANSI' charset seems to be identical with ISO-8859-1.
132 * 'DEFAULT' charset is a language-dependent charset.
134 * 'System' font seems to be an alias for language-dependent font.
138 * language-dependent stock fonts for all known charsets
139 * please see TranslateCharsetInfo (dlls/gdi/font.c) and
140 * CharsetBindingInfo (dlls/x11drv/xfont.c),
141 * and modify entries for your language if needed.
143 struct DefaultFontInfo
145 UINT charset;
146 LOGFONTW SystemFont;
147 LOGFONTW DeviceDefaultFont;
148 LOGFONTW SystemFixedFont;
149 LOGFONTW DefaultGuiFont;
152 static const struct DefaultFontInfo default_fonts[] =
154 { ANSI_CHARSET,
155 { /* System */
156 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
157 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
159 { /* Device Default */
160 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
161 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
163 { /* System Fixed */
164 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
165 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
167 { /* DefaultGuiFont */
168 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
169 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
172 { EASTEUROPE_CHARSET,
173 { /* System */
174 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
175 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
177 { /* Device Default */
178 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
179 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
181 { /* System Fixed */
182 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
183 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
185 { /* DefaultGuiFont */
186 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
187 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
190 { RUSSIAN_CHARSET,
191 { /* System */
192 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
193 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
195 { /* Device Default */
196 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
197 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
199 { /* System Fixed */
200 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
201 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
203 { /* DefaultGuiFont */
204 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
205 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
208 { GREEK_CHARSET,
209 { /* System */
210 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
211 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
213 { /* Device Default */
214 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GREEK_CHARSET,
215 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
217 { /* System Fixed */
218 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
219 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
221 { /* DefaultGuiFont */
222 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
223 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
226 { TURKISH_CHARSET,
227 { /* System */
228 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, TURKISH_CHARSET,
229 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
231 { /* Device Default */
232 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, TURKISH_CHARSET,
233 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
235 { /* System Fixed */
236 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
237 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
239 { /* DefaultGuiFont */
240 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
241 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
244 { HEBREW_CHARSET,
245 { /* System */
246 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, HEBREW_CHARSET,
247 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
249 { /* Device Default */
250 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, HEBREW_CHARSET,
251 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
253 { /* System Fixed */
254 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
255 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
257 { /* DefaultGuiFont */
258 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
259 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
262 { ARABIC_CHARSET,
263 { /* System */
264 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ARABIC_CHARSET,
265 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
267 { /* Device Default */
268 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ARABIC_CHARSET,
269 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
271 { /* System Fixed */
272 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
273 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
275 { /* DefaultGuiFont */
276 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
277 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
280 { BALTIC_CHARSET,
281 { /* System */
282 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, BALTIC_CHARSET,
283 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
285 { /* Device Default */
286 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, BALTIC_CHARSET,
287 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
289 { /* System Fixed */
290 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
291 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
293 { /* DefaultGuiFont */
294 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
295 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
298 { THAI_CHARSET,
299 { /* System */
300 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, THAI_CHARSET,
301 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
303 { /* Device Default */
304 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, THAI_CHARSET,
305 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
307 { /* System Fixed */
308 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
309 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
311 { /* DefaultGuiFont */
312 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
313 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
316 { SHIFTJIS_CHARSET,
317 { /* System */
318 18, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
319 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
321 { /* Device Default */
322 18, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
323 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
325 { /* System Fixed */
326 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
327 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
329 { /* DefaultGuiFont */
330 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
331 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
334 { GB2312_CHARSET,
335 { /* System */
336 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GB2312_CHARSET,
337 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
339 { /* Device Default */
340 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, GB2312_CHARSET,
341 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
343 { /* System Fixed */
344 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
345 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
347 { /* DefaultGuiFont */
348 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
349 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
352 { HANGEUL_CHARSET,
353 { /* System */
354 16, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
355 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
357 { /* Device Default */
358 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
359 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
361 { /* System Fixed */
362 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
363 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
365 { /* DefaultGuiFont */
366 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
367 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
370 { CHINESEBIG5_CHARSET,
371 { /* System */
372 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
373 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
375 { /* Device Default */
376 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
377 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
379 { /* System Fixed */
380 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
381 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
383 { /* DefaultGuiFont */
384 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
385 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
388 { JOHAB_CHARSET,
389 { /* System */
390 16, 7, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, JOHAB_CHARSET,
391 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
393 { /* Device Default */
394 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, JOHAB_CHARSET,
395 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System"
397 { /* System Fixed */
398 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
399 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Courier"
401 { /* DefaultGuiFont */
402 -12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
403 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Shell Dlg"
409 /*************************************************************************
410 * __wine_make_gdi_object_system (GDI32.@)
412 * USER has to tell GDI that its system brushes and pens are non-deletable.
413 * For a description of the GDI object magics and their flags,
414 * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though).
416 void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set)
418 GDI_HANDLE_ENTRY *entry;
420 EnterCriticalSection( &gdi_section );
421 if ((entry = handle_entry( handle ))) entry_obj( entry )->system = !!set;
422 LeaveCriticalSection( &gdi_section );
425 /******************************************************************************
426 * get_default_fonts
428 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
430 unsigned int n;
432 for(n = 0; n < ARRAY_SIZE( default_fonts ); n++)
434 if ( default_fonts[n].charset == charset )
435 return &default_fonts[n];
438 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
439 return &default_fonts[0];
443 /******************************************************************************
444 * get_default_charset (internal)
446 * get the language-dependent charset that can handle CP_ACP correctly.
448 static UINT get_default_charset( void )
450 CHARSETINFO csi;
451 UINT uACP;
453 uACP = GetACP();
454 csi.ciCharset = ANSI_CHARSET;
455 if ( !TranslateCharsetInfo( ULongToPtr(uACP), &csi, TCI_SRCCODEPAGE ) )
457 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
458 return ANSI_CHARSET;
461 return csi.ciCharset;
465 /***********************************************************************
466 * GDI_get_ref_count
468 * Retrieve the reference count of a GDI object.
469 * Note: the object must be locked otherwise the count is meaningless.
471 UINT GDI_get_ref_count( HGDIOBJ handle )
473 GDI_HANDLE_ENTRY *entry;
474 UINT ret = 0;
476 EnterCriticalSection( &gdi_section );
477 if ((entry = handle_entry( handle ))) ret = entry_obj( entry )->selcount;
478 LeaveCriticalSection( &gdi_section );
479 return ret;
483 /***********************************************************************
484 * GDI_inc_ref_count
486 * Increment the reference count of a GDI object.
488 HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle )
490 GDI_HANDLE_ENTRY *entry;
492 EnterCriticalSection( &gdi_section );
493 if ((entry = handle_entry( handle ))) entry_obj( entry )->selcount++;
494 else handle = 0;
495 LeaveCriticalSection( &gdi_section );
496 return handle;
500 /***********************************************************************
501 * GDI_dec_ref_count
503 * Decrement the reference count of a GDI object.
505 BOOL GDI_dec_ref_count( HGDIOBJ handle )
507 GDI_HANDLE_ENTRY *entry;
509 EnterCriticalSection( &gdi_section );
510 if ((entry = handle_entry( handle )))
512 assert( entry_obj( entry )->selcount );
513 if (!--entry_obj( entry )->selcount && entry_obj( entry )->deleted)
515 /* handle delayed DeleteObject*/
516 entry_obj( entry )->deleted = 0;
517 LeaveCriticalSection( &gdi_section );
518 TRACE( "executing delayed DeleteObject for %p\n", handle );
519 DeleteObject( handle );
520 return TRUE;
523 LeaveCriticalSection( &gdi_section );
524 return entry != NULL;
528 /******************************************************************************
529 * get_reg_dword
531 * Read a DWORD value from the registry
533 static BOOL get_reg_dword(HKEY base, const WCHAR *key_name, const WCHAR *value_name, DWORD *value)
535 HKEY key;
536 DWORD type, data, size = sizeof(data);
537 BOOL ret = FALSE;
539 if (RegOpenKeyW(base, key_name, &key) == ERROR_SUCCESS)
541 if (RegQueryValueExW(key, value_name, NULL, &type, (void *)&data, &size) == ERROR_SUCCESS &&
542 type == REG_DWORD)
544 *value = data;
545 ret = TRUE;
547 RegCloseKey(key);
549 return ret;
552 /******************************************************************************
553 * get_dpi
555 * get the dpi from the registry
557 DWORD get_dpi(void)
559 DWORD dpi;
561 if (get_reg_dword(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", &dpi))
562 return dpi;
563 if (get_reg_dword(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", &dpi))
564 return dpi;
565 return 0;
568 /******************************************************************************
569 * get_system_dpi
571 * Get the system DPI, based on the DPI awareness mode.
573 DWORD get_system_dpi(void)
575 static UINT (WINAPI *pGetDpiForSystem)(void);
577 if (!pGetDpiForSystem)
579 HMODULE user = GetModuleHandleW( L"user32.dll" );
580 if (user) pGetDpiForSystem = (void *)GetProcAddress( user, "GetDpiForSystem" );
582 return pGetDpiForSystem ? pGetDpiForSystem() : 96;
585 static HFONT create_scaled_font( const LOGFONTW *deffont )
587 LOGFONTW lf;
588 static DWORD dpi;
590 if (!dpi)
592 dpi = get_dpi();
593 if (!dpi) dpi = 96;
596 lf = *deffont;
597 lf.lfHeight = MulDiv( lf.lfHeight, dpi, 96 );
598 return CreateFontIndirectW( &lf );
601 /***********************************************************************
602 * DllMain
604 * GDI initialization.
606 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
608 const struct DefaultFontInfo* deffonts;
609 int i;
611 if (reason != DLL_PROCESS_ATTACH) return TRUE;
613 gdi32_module = inst;
614 DisableThreadLibraryCalls( inst );
615 font_init();
617 /* create stock objects */
618 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
619 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
620 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
621 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
622 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
623 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
625 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
626 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
627 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
629 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
630 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
632 /* language-independent stock fonts */
633 stock_objects[OEM_FIXED_FONT] = CreateFontIndirectW( &OEMFixedFont );
634 stock_objects[ANSI_FIXED_FONT] = CreateFontIndirectW( &AnsiFixedFont );
635 stock_objects[ANSI_VAR_FONT] = CreateFontIndirectW( &AnsiVarFont );
637 /* language-dependent stock fonts */
638 deffonts = get_default_fonts(get_default_charset());
639 stock_objects[SYSTEM_FONT] = CreateFontIndirectW( &deffonts->SystemFont );
640 stock_objects[DEVICE_DEFAULT_FONT] = CreateFontIndirectW( &deffonts->DeviceDefaultFont );
641 stock_objects[SYSTEM_FIXED_FONT] = CreateFontIndirectW( &deffonts->SystemFixedFont );
642 stock_objects[DEFAULT_GUI_FONT] = CreateFontIndirectW( &deffonts->DefaultGuiFont );
644 scaled_stock_objects[OEM_FIXED_FONT] = create_scaled_font( &OEMFixedFont );
645 scaled_stock_objects[SYSTEM_FONT] = create_scaled_font( &deffonts->SystemFont );
646 scaled_stock_objects[SYSTEM_FIXED_FONT] = create_scaled_font( &deffonts->SystemFixedFont );
647 scaled_stock_objects[DEFAULT_GUI_FONT] = create_scaled_font( &deffonts->DefaultGuiFont );
649 stock_objects[DC_BRUSH] = CreateBrushIndirect( &DCBrush );
650 stock_objects[DC_PEN] = CreatePenIndirect( &DCPen );
652 /* clear the NOSYSTEM bit on all stock objects*/
653 for (i = 0; i < NB_STOCK_OBJECTS; i++)
655 if (stock_objects[i]) __wine_make_gdi_object_system( stock_objects[i], TRUE );
656 if (scaled_stock_objects[i]) __wine_make_gdi_object_system( scaled_stock_objects[i], TRUE );
658 return TRUE;
662 /***********************************************************************
663 * GdiDllInitialize
665 * Stub entry point, some games (CoD: Black Ops 3) call it directly.
667 BOOL WINAPI GdiDllInitialize( HINSTANCE inst, DWORD reason, LPVOID reserved )
669 FIXME("stub\n");
670 return TRUE;
674 static const char *gdi_obj_type( unsigned type )
676 switch ( type )
678 case OBJ_PEN: return "OBJ_PEN";
679 case OBJ_BRUSH: return "OBJ_BRUSH";
680 case OBJ_DC: return "OBJ_DC";
681 case OBJ_METADC: return "OBJ_METADC";
682 case OBJ_PAL: return "OBJ_PAL";
683 case OBJ_FONT: return "OBJ_FONT";
684 case OBJ_BITMAP: return "OBJ_BITMAP";
685 case OBJ_REGION: return "OBJ_REGION";
686 case OBJ_METAFILE: return "OBJ_METAFILE";
687 case OBJ_MEMDC: return "OBJ_MEMDC";
688 case OBJ_EXTPEN: return "OBJ_EXTPEN";
689 case OBJ_ENHMETADC: return "OBJ_ENHMETADC";
690 case OBJ_ENHMETAFILE: return "OBJ_ENHMETAFILE";
691 case OBJ_COLORSPACE: return "OBJ_COLORSPACE";
692 default: return "UNKNOWN";
696 static void dump_gdi_objects( void )
698 GDI_HANDLE_ENTRY *entry;
700 TRACE( "%u objects:\n", GDI_MAX_HANDLE_COUNT );
702 EnterCriticalSection( &gdi_section );
703 for (entry = gdi_shared.Handles; entry < next_unused; entry++)
705 if (!entry->Type)
706 TRACE( "handle %p FREE\n", entry_to_handle( entry ));
707 else
708 TRACE( "handle %p obj %s type %s selcount %u deleted %u\n",
709 entry_to_handle( entry ), wine_dbgstr_longlong( entry->Object ),
710 gdi_obj_type( entry->Type ), entry_obj( entry )->selcount,
711 entry_obj( entry )->deleted );
713 LeaveCriticalSection( &gdi_section );
716 /***********************************************************************
717 * alloc_gdi_handle
719 * Allocate a GDI handle for an object, which must have been allocated on the process heap.
721 HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, WORD type, const struct gdi_obj_funcs *funcs )
723 GDI_HANDLE_ENTRY *entry;
724 HGDIOBJ ret;
726 assert( type ); /* type 0 is reserved to mark free entries */
728 EnterCriticalSection( &gdi_section );
730 entry = next_free;
731 if (entry)
732 next_free = (GDI_HANDLE_ENTRY *)(UINT_PTR)entry->Object;
733 else if (next_unused < gdi_shared.Handles + GDI_MAX_HANDLE_COUNT)
734 entry = next_unused++;
735 else
737 LeaveCriticalSection( &gdi_section );
738 ERR( "out of GDI object handles, expect a crash\n" );
739 if (TRACE_ON(gdi)) dump_gdi_objects();
740 return 0;
742 obj->funcs = funcs;
743 obj->hdcs = NULL;
744 obj->selcount = 0;
745 obj->system = 0;
746 obj->deleted = 0;
747 entry->Object = (UINT_PTR)obj;
748 /* FIXME: Native uses ntgdi types, which are different that gdi OBJ_ types */
749 entry->Type = type;
750 if (++entry->Unique == 0xffff) entry->Unique = 1;
751 ret = entry_to_handle( entry );
752 LeaveCriticalSection( &gdi_section );
753 TRACE( "allocated %s %p %u/%u\n", gdi_obj_type(type), ret,
754 InterlockedIncrement( &debug_count ), GDI_MAX_HANDLE_COUNT );
755 return ret;
759 /***********************************************************************
760 * free_gdi_handle
762 * Free a GDI handle and return a pointer to the object.
764 void *free_gdi_handle( HGDIOBJ handle )
766 void *object = NULL;
767 GDI_HANDLE_ENTRY *entry;
769 EnterCriticalSection( &gdi_section );
770 if ((entry = handle_entry( handle )))
772 TRACE( "freed %s %p %u/%u\n", gdi_obj_type( entry->Type ), handle,
773 InterlockedDecrement( &debug_count ) + 1, GDI_MAX_HANDLE_COUNT );
774 object = entry_obj( entry );
775 entry->Type = 0;
776 entry->Object = (UINT_PTR)next_free;
777 next_free = entry;
779 LeaveCriticalSection( &gdi_section );
780 return object;
784 /***********************************************************************
785 * get_full_gdi_handle
787 * Return the full GDI handle from a possibly truncated value.
789 HGDIOBJ get_full_gdi_handle( HGDIOBJ handle )
791 GDI_HANDLE_ENTRY *entry;
793 if (!HIWORD( handle ))
795 EnterCriticalSection( &gdi_section );
796 if ((entry = handle_entry( handle ))) handle = entry_to_handle( entry );
797 LeaveCriticalSection( &gdi_section );
799 return handle;
802 /***********************************************************************
803 * get_any_obj_ptr
805 * Return a pointer to, and the type of, the GDI object
806 * associated with the handle.
807 * The object must be released with GDI_ReleaseObj.
809 void *get_any_obj_ptr( HGDIOBJ handle, WORD *type )
811 void *ptr = NULL;
812 GDI_HANDLE_ENTRY *entry;
814 EnterCriticalSection( &gdi_section );
816 if ((entry = handle_entry( handle )))
818 ptr = entry_obj( entry );
819 *type = entry->Type;
822 if (!ptr) LeaveCriticalSection( &gdi_section );
823 return ptr;
826 /***********************************************************************
827 * GDI_GetObjPtr
829 * Return a pointer to the GDI object associated with the handle.
830 * Return NULL if the object has the wrong type.
831 * The object must be released with GDI_ReleaseObj.
833 void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
835 WORD ret_type;
836 void *ptr = get_any_obj_ptr( handle, &ret_type );
837 if (ptr && ret_type != type)
839 GDI_ReleaseObj( handle );
840 ptr = NULL;
842 return ptr;
845 /***********************************************************************
846 * GDI_ReleaseObj
849 void GDI_ReleaseObj( HGDIOBJ handle )
851 LeaveCriticalSection( &gdi_section );
855 /***********************************************************************
856 * GDI_CheckNotLock
858 void GDI_CheckNotLock(void)
860 if (RtlIsCriticalSectionLockedByThread(&gdi_section))
862 ERR( "BUG: holding GDI lock\n" );
863 DebugBreak();
868 /***********************************************************************
869 * DeleteObject (GDI32.@)
871 * Delete a Gdi object.
873 * PARAMS
874 * obj [I] Gdi object to delete
876 * RETURNS
877 * Success: TRUE. If obj was not returned from GetStockObject(), any resources
878 * it consumed are released.
879 * Failure: FALSE, if obj is not a valid Gdi object, or is currently selected
880 * into a DC.
882 BOOL WINAPI DeleteObject( HGDIOBJ obj )
884 GDI_HANDLE_ENTRY *entry;
885 struct hdc_list *hdcs_head;
886 const struct gdi_obj_funcs *funcs = NULL;
887 struct gdi_obj_header *header;
889 EnterCriticalSection( &gdi_section );
890 if (!(entry = handle_entry( obj )))
892 LeaveCriticalSection( &gdi_section );
893 return FALSE;
896 header = entry_obj( entry );
897 if (header->system)
899 TRACE("Preserving system object %p\n", obj);
900 LeaveCriticalSection( &gdi_section );
901 return TRUE;
904 obj = entry_to_handle( entry ); /* make it a full handle */
906 hdcs_head = header->hdcs;
907 header->hdcs = NULL;
909 if (header->selcount)
911 TRACE("delayed for %p because object in use, count %u\n", obj, header->selcount );
912 header->deleted = 1; /* mark for delete */
914 else funcs = header->funcs;
916 LeaveCriticalSection( &gdi_section );
918 while (hdcs_head)
920 struct hdc_list *next = hdcs_head->next;
921 DC *dc = get_dc_ptr(hdcs_head->hdc);
923 TRACE("hdc %p has interest in %p\n", hdcs_head->hdc, obj);
924 if(dc)
926 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeleteObject );
927 physdev->funcs->pDeleteObject( physdev, obj );
928 release_dc_ptr( dc );
930 HeapFree(GetProcessHeap(), 0, hdcs_head);
931 hdcs_head = next;
934 TRACE("%p\n", obj );
936 if (funcs && funcs->pDeleteObject) return funcs->pDeleteObject( obj );
937 return TRUE;
940 /***********************************************************************
941 * GDI_hdc_using_object
943 * Call this if the dc requires DeleteObject notification
945 void GDI_hdc_using_object(HGDIOBJ obj, HDC hdc)
947 GDI_HANDLE_ENTRY *entry;
948 struct hdc_list *phdc;
950 TRACE("obj %p hdc %p\n", obj, hdc);
952 EnterCriticalSection( &gdi_section );
953 if ((entry = handle_entry( obj )) && !entry_obj( entry )->system)
955 struct gdi_obj_header *header = entry_obj( entry );
956 for (phdc = header->hdcs; phdc; phdc = phdc->next)
957 if (phdc->hdc == hdc) break;
959 if (!phdc)
961 phdc = HeapAlloc(GetProcessHeap(), 0, sizeof(*phdc));
962 phdc->hdc = hdc;
963 phdc->next = header->hdcs;
964 header->hdcs = phdc;
967 LeaveCriticalSection( &gdi_section );
970 /***********************************************************************
971 * GDI_hdc_not_using_object
974 void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc)
976 GDI_HANDLE_ENTRY *entry;
977 struct hdc_list **pphdc;
979 TRACE("obj %p hdc %p\n", obj, hdc);
981 EnterCriticalSection( &gdi_section );
982 if ((entry = handle_entry( obj )) && !entry_obj( entry )->system)
984 for (pphdc = &entry_obj( entry )->hdcs; *pphdc; pphdc = &(*pphdc)->next)
985 if ((*pphdc)->hdc == hdc)
987 struct hdc_list *phdc = *pphdc;
988 *pphdc = phdc->next;
989 HeapFree(GetProcessHeap(), 0, phdc);
990 break;
993 LeaveCriticalSection( &gdi_section );
996 /***********************************************************************
997 * GetStockObject (GDI32.@)
999 HGDIOBJ WINAPI GetStockObject( INT obj )
1001 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
1002 switch (obj)
1004 case OEM_FIXED_FONT:
1005 case SYSTEM_FONT:
1006 case SYSTEM_FIXED_FONT:
1007 case DEFAULT_GUI_FONT:
1008 if (get_system_dpi() != 96) return scaled_stock_objects[obj];
1009 break;
1011 return stock_objects[obj];
1015 /***********************************************************************
1016 * GetObjectA (GDI32.@)
1018 INT WINAPI GetObjectA( HGDIOBJ handle, INT count, LPVOID buffer )
1020 GDI_HANDLE_ENTRY *entry;
1021 const struct gdi_obj_funcs *funcs = NULL;
1022 INT result = 0;
1024 TRACE("%p %d %p\n", handle, count, buffer );
1026 EnterCriticalSection( &gdi_section );
1027 if ((entry = handle_entry( handle )))
1029 funcs = entry_obj( entry )->funcs;
1030 handle = entry_to_handle( entry ); /* make it a full handle */
1032 LeaveCriticalSection( &gdi_section );
1034 if (funcs)
1036 if (!funcs->pGetObjectA)
1037 SetLastError( ERROR_INVALID_HANDLE );
1038 else if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
1039 SetLastError( ERROR_NOACCESS );
1040 else
1041 result = funcs->pGetObjectA( handle, count, buffer );
1043 return result;
1046 /***********************************************************************
1047 * GetObjectW (GDI32.@)
1049 INT WINAPI GetObjectW( HGDIOBJ handle, INT count, LPVOID buffer )
1051 GDI_HANDLE_ENTRY *entry;
1052 const struct gdi_obj_funcs *funcs = NULL;
1053 INT result = 0;
1055 TRACE("%p %d %p\n", handle, count, buffer );
1057 EnterCriticalSection( &gdi_section );
1058 if ((entry = handle_entry( handle )))
1060 funcs = entry_obj( entry )->funcs;
1061 handle = entry_to_handle( entry ); /* make it a full handle */
1063 LeaveCriticalSection( &gdi_section );
1065 if (funcs)
1067 if (!funcs->pGetObjectW)
1068 SetLastError( ERROR_INVALID_HANDLE );
1069 else if (buffer && ((ULONG_PTR)buffer >> 16) == 0) /* catch apps getting argument order wrong */
1070 SetLastError( ERROR_NOACCESS );
1071 else
1072 result = funcs->pGetObjectW( handle, count, buffer );
1074 return result;
1077 /***********************************************************************
1078 * GetObjectType (GDI32.@)
1080 DWORD WINAPI GetObjectType( HGDIOBJ handle )
1082 GDI_HANDLE_ENTRY *entry;
1083 DWORD result = 0;
1085 EnterCriticalSection( &gdi_section );
1086 if ((entry = handle_entry( handle ))) result = entry->Type;
1087 LeaveCriticalSection( &gdi_section );
1089 TRACE("%p -> %u\n", handle, result );
1090 if (!result) SetLastError( ERROR_INVALID_HANDLE );
1091 return result;
1094 /***********************************************************************
1095 * GetCurrentObject (GDI32.@)
1097 * Get the currently selected object of a given type in a device context.
1099 * PARAMS
1100 * hdc [I] Device context to get the current object from
1101 * type [I] Type of current object to get (OBJ_* defines from "wingdi.h")
1103 * RETURNS
1104 * Success: The current object of the given type selected in hdc.
1105 * Failure: A NULL handle.
1107 * NOTES
1108 * - only the following object types are supported:
1109 *| OBJ_PEN
1110 *| OBJ_BRUSH
1111 *| OBJ_PAL
1112 *| OBJ_FONT
1113 *| OBJ_BITMAP
1115 HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
1117 HGDIOBJ ret = 0;
1118 DC * dc = get_dc_ptr( hdc );
1120 if (!dc) return 0;
1122 switch (type) {
1123 case OBJ_EXTPEN: /* fall through */
1124 case OBJ_PEN: ret = dc->hPen; break;
1125 case OBJ_BRUSH: ret = dc->hBrush; break;
1126 case OBJ_PAL: ret = dc->hPalette; break;
1127 case OBJ_FONT: ret = dc->hFont; break;
1128 case OBJ_BITMAP: ret = dc->hBitmap; break;
1130 /* tests show that OBJ_REGION is explicitly ignored */
1131 case OBJ_REGION: break;
1132 default:
1133 /* the SDK only mentions those above */
1134 FIXME("(%p,%d): unknown type.\n",hdc,type);
1135 break;
1137 release_dc_ptr( dc );
1138 return ret;
1142 /***********************************************************************
1143 * SelectObject (GDI32.@)
1145 * Select a Gdi object into a device context.
1147 * PARAMS
1148 * hdc [I] Device context to associate the object with
1149 * hObj [I] Gdi object to associate with hdc
1151 * RETURNS
1152 * Success: A non-NULL handle representing the previously selected object of
1153 * the same type as hObj.
1154 * Failure: A NULL object. If hdc is invalid, GetLastError() returns ERROR_INVALID_HANDLE.
1155 * if hObj is not a valid object handle, no last error is set. In either
1156 * case, hdc is unaffected by the call.
1158 HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ hObj )
1160 GDI_HANDLE_ENTRY *entry;
1161 const struct gdi_obj_funcs *funcs = NULL;
1163 TRACE( "(%p,%p)\n", hdc, hObj );
1165 EnterCriticalSection( &gdi_section );
1166 if ((entry = handle_entry( hObj )))
1168 funcs = entry_obj( entry )->funcs;
1169 hObj = entry_to_handle( entry ); /* make it a full handle */
1171 LeaveCriticalSection( &gdi_section );
1173 if (funcs && funcs->pSelectObject) return funcs->pSelectObject( hObj, hdc );
1174 return 0;
1178 /***********************************************************************
1179 * UnrealizeObject (GDI32.@)
1181 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1183 const struct gdi_obj_funcs *funcs = NULL;
1184 GDI_HANDLE_ENTRY *entry;
1186 EnterCriticalSection( &gdi_section );
1187 if ((entry = handle_entry( obj )))
1189 funcs = entry_obj( entry )->funcs;
1190 obj = entry_to_handle( entry ); /* make it a full handle */
1192 LeaveCriticalSection( &gdi_section );
1194 if (funcs && funcs->pUnrealizeObject) return funcs->pUnrealizeObject( obj );
1195 return funcs != NULL;
1199 /* Solid colors to enumerate */
1200 static const COLORREF solid_colors[] =
1201 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1202 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1203 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1204 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1205 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1206 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1207 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1208 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1212 /***********************************************************************
1213 * EnumObjects (GDI32.@)
1215 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1216 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1218 UINT i;
1219 INT retval = 0;
1220 LOGPEN pen;
1221 LOGBRUSH brush;
1223 TRACE("%p %d %p %08lx\n", hdc, nObjType, lpEnumFunc, lParam );
1224 switch(nObjType)
1226 case OBJ_PEN:
1227 /* Enumerate solid pens */
1228 for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
1230 pen.lopnStyle = PS_SOLID;
1231 pen.lopnWidth.x = 1;
1232 pen.lopnWidth.y = 0;
1233 pen.lopnColor = solid_colors[i];
1234 retval = lpEnumFunc( &pen, lParam );
1235 TRACE("solid pen %08x, ret=%d\n",
1236 solid_colors[i], retval);
1237 if (!retval) break;
1239 break;
1241 case OBJ_BRUSH:
1242 /* Enumerate solid brushes */
1243 for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
1245 brush.lbStyle = BS_SOLID;
1246 brush.lbColor = solid_colors[i];
1247 brush.lbHatch = 0;
1248 retval = lpEnumFunc( &brush, lParam );
1249 TRACE("solid brush %08x, ret=%d\n",
1250 solid_colors[i], retval);
1251 if (!retval) break;
1254 /* Now enumerate hatched brushes */
1255 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1257 brush.lbStyle = BS_HATCHED;
1258 brush.lbColor = RGB(0,0,0);
1259 brush.lbHatch = i;
1260 retval = lpEnumFunc( &brush, lParam );
1261 TRACE("hatched brush %d, ret=%d\n",
1262 i, retval);
1263 if (!retval) break;
1265 break;
1267 default:
1268 /* FIXME: implement Win32 types */
1269 WARN("(%d): Invalid type\n", nObjType );
1270 break;
1272 return retval;
1276 /***********************************************************************
1277 * SetObjectOwner (GDI32.@)
1279 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1281 /* Nothing to do */
1284 /***********************************************************************
1285 * GdiInitializeLanguagePack (GDI32.@)
1287 DWORD WINAPI GdiInitializeLanguagePack( DWORD arg )
1289 FIXME("stub\n");
1290 return 0;
1293 /***********************************************************************
1294 * GdiFlush (GDI32.@)
1296 BOOL WINAPI GdiFlush(void)
1298 return TRUE; /* FIXME */
1302 /***********************************************************************
1303 * GdiGetBatchLimit (GDI32.@)
1305 DWORD WINAPI GdiGetBatchLimit(void)
1307 return 1; /* FIXME */
1311 /***********************************************************************
1312 * GdiSetBatchLimit (GDI32.@)
1314 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1316 return 1; /* FIXME */
1320 /*******************************************************************
1321 * GetColorAdjustment [GDI32.@]
1325 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1327 FIXME("stub\n");
1328 return FALSE;
1331 /*******************************************************************
1332 * GdiComment [GDI32.@]
1336 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1338 DC *dc = get_dc_ptr(hdc);
1339 BOOL ret = FALSE;
1341 if(dc)
1343 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGdiComment );
1344 ret = physdev->funcs->pGdiComment( physdev, cbSize, lpData );
1345 release_dc_ptr( dc );
1347 return ret;
1350 /*******************************************************************
1351 * SetColorAdjustment [GDI32.@]
1355 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1357 FIXME("stub\n");
1358 return FALSE;