Release 20020904.
[wine/gsoc-2012-control.git] / objects / gdiobj.c
blob2a3c8422e45e959ed519b8eec6620b50b4dbb516
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 <stdio.h>
27 #include "windef.h"
28 #include "wingdi.h"
29 #include "winreg.h"
30 #include "winerror.h"
31 #include "wine/winbase16.h"
33 #include "bitmap.h"
34 #include "font.h"
35 #include "local.h"
36 #include "palette.h"
37 #include "wine/debug.h"
38 #include "gdi.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
42 /* ### start build ### */
43 extern WORD CALLBACK GDI_CallTo16_word_ll(GOBJENUMPROC16,LONG,LONG);
44 /* ### stop build ### */
46 /***********************************************************************
47 * GDI stock objects
50 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
51 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
52 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
54 /* FIXME: these should perhaps be BS_HATCHED, at least for 1 bitperpixel */
55 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
56 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
58 /* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
59 /* See HatchBrushes in x11drv for the HS_DIAGCROSS+1 hack */
60 static const LOGBRUSH DkGrayBrush = { BS_HATCHED, RGB(0,0,0), (HS_DIAGCROSS+1) };
62 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
63 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
64 static const LOGPEN NullPen = { PS_NULL, { 0, 0 }, 0 };
67 /* reserve one extra entry for the stock default bitmap */
68 /* this is what Windows does too */
69 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
71 static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
73 static SYSLEVEL GDI_level = { CRITICAL_SECTION_INIT("GDI_level"), 3 };
74 static WORD GDI_HeapSel;
76 inline static BOOL get_bool(char *buffer)
78 return (buffer[0] == 'y' || buffer[0] == 'Y' ||
79 buffer[0] == 't' || buffer[0] == 'T' ||
80 buffer[0] == '1');
84 /****************************************************************************
86 * language-independent stock fonts
90 static const LOGFONTW OEMFixedFont =
91 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
92 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
94 static const LOGFONTW AnsiFixedFont =
95 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
96 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
98 static const LOGFONTW AnsiVarFont =
99 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
100 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
101 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
103 /******************************************************************************
105 * language-dependent stock fonts
107 * 'ANSI' charset and 'DEFAULT' charset is not same.
108 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
109 * 'ANSI' charset seems to be identical with ISO-8859-1.
110 * 'DEFAULT' charset is a language-dependent charset.
112 * 'System' font seems to be an alias for language-dependent font.
116 * language-dependenet stock fonts for all known charsets
117 * please see TranslateCharsetInfo (objects/font.c) and
118 * CharsetBindingInfo (graphics/x11drv/xfont.c),
119 * and modify entries for your language if needed.
121 struct DefaultFontInfo
123 UINT charset;
124 LOGFONTW SystemFont;
125 LOGFONTW DeviceDefaultFont;
126 LOGFONTW SystemFixedFont;
127 LOGFONTW DefaultGuiFont;
130 static const struct DefaultFontInfo default_fonts[] =
132 { ANSI_CHARSET,
133 { /* System */
134 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
135 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
136 {'S','y','s','t','e','m','\0'}
138 { /* Device Default */
139 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
140 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
141 {'\0'}
143 { /* System Fixed */
144 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
145 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
146 {'\0'}
148 { /* DefaultGuiFont */
149 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
150 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
151 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
154 { EASTEUROPE_CHARSET,
155 { /* System */
156 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
157 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
158 {'S','y','s','t','e','m','\0'}
160 { /* Device Default */
161 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
162 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
163 {'\0'}
165 { /* System Fixed */
166 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
167 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
168 {'\0'}
170 { /* DefaultGuiFont */
171 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
172 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
173 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
176 { RUSSIAN_CHARSET,
177 { /* System */
178 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
179 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
180 {'S','y','s','t','e','m','\0'}
182 { /* Device Default */
183 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
184 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
185 {'\0'}
187 { /* System Fixed */
188 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
189 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
190 {'\0'}
192 { /* DefaultGuiFont */
193 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
194 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
195 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
198 { GREEK_CHARSET,
199 { /* System */
200 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
201 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
202 {'S','y','s','t','e','m','\0'}
204 { /* Device Default */
205 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
206 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
207 {'\0'}
209 { /* System Fixed */
210 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
211 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
212 {'\0'}
214 { /* DefaultGuiFont */
215 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
216 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
217 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
220 { TURKISH_CHARSET,
221 { /* System */
222 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
223 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
224 {'S','y','s','t','e','m','\0'}
226 { /* Device Default */
227 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
228 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
229 {'\0'}
231 { /* System Fixed */
232 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
233 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
234 {'\0'}
236 { /* DefaultGuiFont */
237 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
238 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
239 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
242 { HEBREW_CHARSET,
243 { /* System */
244 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
245 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
246 {'S','y','s','t','e','m','\0'}
248 { /* Device Default */
249 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
250 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
251 {'\0'}
253 { /* System Fixed */
254 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
255 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
256 {'\0'}
258 { /* DefaultGuiFont */
259 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
260 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
261 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
264 { ARABIC_CHARSET,
265 { /* System */
266 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
267 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
268 {'S','y','s','t','e','m','\0'}
270 { /* Device Default */
271 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
272 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
273 {'\0'}
275 { /* System Fixed */
276 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
277 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
278 {'\0'}
280 { /* DefaultGuiFont */
281 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
282 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
283 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
286 { BALTIC_CHARSET,
287 { /* System */
288 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
289 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
290 {'S','y','s','t','e','m','\0'}
292 { /* Device Default */
293 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
294 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
295 {'\0'}
297 { /* System Fixed */
298 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
299 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
300 {'\0'}
302 { /* DefaultGuiFont */
303 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
304 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
305 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
308 { THAI_CHARSET,
309 { /* System */
310 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
311 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
312 {'S','y','s','t','e','m','\0'}
314 { /* Device Default */
315 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
316 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
317 {'\0'}
319 { /* System Fixed */
320 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
321 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
322 {'\0'}
324 { /* DefaultGuiFont */
325 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
326 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
327 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
330 { SHIFTJIS_CHARSET,
331 { /* System */
332 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
333 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
334 {'S','y','s','t','e','m','\0'}
336 { /* Device Default */
337 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
338 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
339 {'\0'}
341 { /* System Fixed */
342 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
343 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
344 {'\0'}
346 { /* DefaultGuiFont */
347 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
348 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
349 {'M','S',' ','P',' ','g','o','t','h','i','c','\0'} /* FIXME: Is this correct? */
352 { GB2312_CHARSET,
353 { /* System */
354 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
355 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
356 {'S','y','s','t','e','m','\0'}
358 { /* Device Default */
359 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
360 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
361 {'\0'}
363 { /* System Fixed */
364 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
365 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
366 {'\0'}
368 { /* DefaultGuiFont */
369 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
370 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
371 {'M','S',' ','S','o','n','g','\0'} /* FIXME: Is this correct? */
374 { HANGEUL_CHARSET,
375 { /* System */
376 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
377 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
378 {'S','y','s','t','e','m','\0'}
380 { /* Device Default */
381 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
382 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
383 {'\0'}
385 { /* System Fixed */
386 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
387 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
388 {'\0'}
390 { /* DefaultGuiFont */
391 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
392 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
393 {'G','u','l','i','m'},
396 { CHINESEBIG5_CHARSET,
397 { /* System */
398 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
399 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
400 {'S','y','s','t','e','m','\0'}
402 { /* Device Default */
403 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
404 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
405 {'\0'}
407 { /* System Fixed */
408 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
409 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
410 {'\0'}
412 { /* DefaultGuiFont */
413 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
414 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
415 {'\0'} /* FIXME - what is the native font??? */
418 { JOHAB_CHARSET,
419 { /* System */
420 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
421 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
422 {'S','y','s','t','e','m','\0'}
424 { /* Device Default */
425 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
426 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
427 {'\0'}
429 { /* System Fixed */
430 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
431 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
432 {'\0'}
434 { /* DefaultGuiFont */
435 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
436 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
437 {'M','S',' ','M','i','n','g','l','i','u','\0'} /* FIXME: Is this correct? */
443 /******************************************************************************
444 * get_default_fonts
446 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
448 int n;
450 for(n=0;n<(sizeof(default_fonts)/sizeof(default_fonts[0]));n++)
452 if ( default_fonts[n].charset == charset )
453 return &default_fonts[n];
456 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
457 return &default_fonts[0];
461 /******************************************************************************
462 * get_default_charset (internal)
464 * get the language-dependent charset that can handle CP_ACP correctly.
466 static UINT get_default_charset( void )
468 CHARSETINFO csi;
469 UINT uACP;
471 uACP = GetACP();
472 csi.ciCharset = ANSI_CHARSET;
473 if ( ! TranslateCharsetInfo( (LPDWORD)uACP, &csi, TCI_SRCCODEPAGE ) )
475 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
476 return ANSI_CHARSET;
479 return csi.ciCharset;
483 /******************************************************************************
484 * create_stock_font
486 static HFONT create_stock_font( char const *fontName, const LOGFONTW *font, HKEY hkey )
488 LOGFONTW lf;
489 char key[256];
490 char buffer[MAX_PATH];
491 DWORD type, count;
493 if (!hkey) return CreateFontIndirectW( font );
495 lf = *font;
496 sprintf(key, "%s.Height", fontName);
497 count = sizeof(buffer);
498 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
499 lf.lfHeight = atoi(buffer);
501 sprintf(key, "%s.Bold", fontName);
502 count = sizeof(buffer);
503 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
504 lf.lfWeight = get_bool(buffer) ? FW_BOLD : FW_NORMAL;
506 sprintf(key, "%s.Italic", fontName);
507 count = sizeof(buffer);
508 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
509 lf.lfItalic = get_bool(buffer);
511 sprintf(key, "%s.Underline", fontName);
512 count = sizeof(buffer);
513 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
514 lf.lfUnderline = get_bool(buffer);
516 sprintf(key, "%s.StrikeOut", fontName);
517 count = sizeof(buffer);
518 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
519 lf.lfStrikeOut = get_bool(buffer);
520 return CreateFontIndirectW( &lf );
524 #define TRACE_SEC(handle,text) \
525 TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
528 /***********************************************************************
529 * inc_ref_count
531 * Increment the reference count of a GDI object.
533 inline static void inc_ref_count( HGDIOBJ handle )
535 GDIOBJHDR *header;
537 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
539 header->dwCount++;
540 GDI_ReleaseObj( handle );
545 /***********************************************************************
546 * dec_ref_count
548 * Decrement the reference count of a GDI object.
550 inline static void dec_ref_count( HGDIOBJ handle )
552 GDIOBJHDR *header;
554 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
556 if (header->dwCount) header->dwCount--;
557 if (header->dwCount != 0x80000000) GDI_ReleaseObj( handle );
558 else
560 /* handle delayed DeleteObject*/
561 header->dwCount = 0;
562 GDI_ReleaseObj( handle );
563 TRACE( "executing delayed DeleteObject for %04x\n", handle );
564 DeleteObject( handle );
570 /***********************************************************************
571 * GDI_Init
573 * GDI initialization.
575 BOOL GDI_Init(void)
577 HINSTANCE16 instance;
578 HKEY hkey;
579 GDIOBJHDR *ptr;
580 const struct DefaultFontInfo* deffonts;
581 int i;
583 if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey))
584 hkey = 0;
586 /* create GDI heap */
587 if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE;
588 GDI_HeapSel = instance | 7;
590 /* create stock objects */
591 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
592 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
593 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
594 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
595 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
596 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
598 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
599 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
600 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
602 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
603 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
605 /* language-independent stock fonts */
606 stock_objects[OEM_FIXED_FONT] = create_stock_font( "OEMFixed", &OEMFixedFont, hkey );
607 stock_objects[ANSI_FIXED_FONT] = create_stock_font( "AnsiFixed", &AnsiFixedFont, hkey );
608 stock_objects[ANSI_VAR_FONT] = create_stock_font( "AnsiVar", &AnsiVarFont, hkey );
610 /* language-dependent stock fonts */
611 deffonts = get_default_fonts(get_default_charset());
612 stock_objects[SYSTEM_FONT] = create_stock_font( "System", &deffonts->SystemFont, hkey );
613 stock_objects[DEVICE_DEFAULT_FONT] = create_stock_font( "DeviceDefault", &deffonts->DeviceDefaultFont, hkey );
614 stock_objects[SYSTEM_FIXED_FONT] = create_stock_font( "SystemFixed", &deffonts->SystemFixedFont, hkey );
615 stock_objects[DEFAULT_GUI_FONT] = create_stock_font( "DefaultGui", &deffonts->DefaultGuiFont, hkey );
618 /* clear the NOSYSTEM bit on all stock objects*/
619 for (i = 0; i < NB_STOCK_OBJECTS; i++)
621 if (!stock_objects[i])
623 if (i == 9) continue; /* there's no stock object 9 */
624 ERR( "could not create stock object %d\n", i );
625 return FALSE;
627 ptr = GDI_GetObjPtr( stock_objects[i], MAGIC_DONTCARE );
628 ptr->wMagic &= ~OBJECT_NOSYSTEM;
629 GDI_ReleaseObj( stock_objects[i] );
632 if (hkey) RegCloseKey( hkey );
634 WineEngInit();
636 return TRUE;
639 #define FIRST_LARGE_HANDLE 16
640 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
641 static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES];
642 static int next_large_handle;
644 /***********************************************************************
645 * alloc_large_heap
647 * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject
649 inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle )
651 int i;
652 GDIOBJHDR *obj;
654 for (i = next_large_handle + 1; i < MAX_LARGE_HANDLES; i++)
655 if (!large_handles[i]) goto found;
656 for (i = 0; i <= next_large_handle; i++)
657 if (!large_handles[i]) goto found;
658 *handle = 0;
659 return NULL;
661 found:
662 if ((obj = HeapAlloc( GetProcessHeap(), 0, size )))
664 large_handles[i] = obj;
665 *handle = (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
666 next_large_handle = i;
668 return obj;
672 /***********************************************************************
673 * GDI_AllocObject
675 void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_obj_funcs *funcs )
677 GDIOBJHDR *obj;
678 HLOCAL16 hlocal;
680 _EnterSysLevel( &GDI_level );
681 switch(magic)
683 /* allocate DCs on the larger heap */
684 case DC_MAGIC:
685 case DISABLED_DC_MAGIC:
686 case META_DC_MAGIC:
687 case METAFILE_MAGIC:
688 case METAFILE_DC_MAGIC:
689 case ENHMETAFILE_MAGIC:
690 case ENHMETAFILE_DC_MAGIC:
691 case BITMAP_MAGIC:
692 if (!(obj = alloc_large_heap( size, handle ))) goto error;
693 break;
694 default:
695 if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error;
696 assert( hlocal & 2 );
697 obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hlocal );
698 *handle = (HGDIOBJ)(ULONG_PTR)hlocal;
699 break;
702 obj->hNext = 0;
703 obj->wMagic = magic|OBJECT_NOSYSTEM;
704 obj->dwCount = 0;
705 obj->funcs = funcs;
707 TRACE_SEC( *handle, "enter" );
708 return obj;
710 error:
711 _LeaveSysLevel( &GDI_level );
712 *handle = 0;
713 return NULL;
717 /***********************************************************************
718 * GDI_ReallocObject
720 * The object ptr must have been obtained with GDI_GetObjPtr.
721 * The new pointer must be released with GDI_ReleaseObj.
723 void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object )
725 HGDIOBJ new_handle;
727 assert( handle & 2 ); /* no realloc for large handles */
728 LOCAL_Unlock( GDI_HeapSel, handle );
729 if (!(new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE )))
731 TRACE_SEC( handle, "leave" );
732 _LeaveSysLevel( &GDI_level );
733 return NULL;
735 assert( new_handle == handle ); /* moveable handle cannot change */
736 return LOCAL_Lock( GDI_HeapSel, handle );
740 /***********************************************************************
741 * GDI_FreeObject
743 BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
745 GDIOBJHDR *object = ptr;
747 object->wMagic = 0; /* Mark it as invalid */
748 object->funcs = NULL;
749 if (handle & 2) /* GDI heap handle */
751 LOCAL_Unlock( GDI_HeapSel, handle );
752 LOCAL_Free( GDI_HeapSel, handle );
754 else /* large heap handle */
756 int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
757 if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
759 HeapFree( GetProcessHeap(), 0, large_handles[i] );
760 large_handles[i] = NULL;
762 else ERR( "Invalid handle %x\n", handle );
764 TRACE_SEC( handle, "leave" );
765 _LeaveSysLevel( &GDI_level );
766 return TRUE;
770 /***********************************************************************
771 * GDI_GetObjPtr
773 * Return a pointer to the GDI object associated to the handle.
774 * Return NULL if the object has the wrong magic number.
775 * The object must be released with GDI_ReleaseObj.
777 void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
779 GDIOBJHDR *ptr = NULL;
781 _EnterSysLevel( &GDI_level );
783 if (handle & 2) /* GDI heap handle */
785 ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle );
786 if (ptr)
788 if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ||
789 (GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) ||
790 (GDIMAGIC(ptr->wMagic) > LAST_MAGIC))
792 LOCAL_Unlock( GDI_HeapSel, handle );
793 ptr = NULL;
797 else /* large heap handle */
799 int i = (handle >> 2) - FIRST_LARGE_HANDLE;
800 if (i >= 0 && i < MAX_LARGE_HANDLES)
802 ptr = large_handles[i];
803 if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL;
807 if (!ptr)
809 _LeaveSysLevel( &GDI_level );
810 SetLastError( ERROR_INVALID_HANDLE );
811 WARN( "Invalid handle %x\n", handle );
813 else TRACE_SEC( handle, "enter" );
815 return ptr;
819 /***********************************************************************
820 * GDI_ReleaseObj
823 void GDI_ReleaseObj( HGDIOBJ handle )
825 if (handle & 2) LOCAL_Unlock( GDI_HeapSel, handle );
826 TRACE_SEC( handle, "leave" );
827 _LeaveSysLevel( &GDI_level );
831 /***********************************************************************
832 * GDI_CheckNotLock
834 void GDI_CheckNotLock(void)
836 _CheckNotSysLevel( &GDI_level );
840 /***********************************************************************
841 * DeleteObject (GDI32.@)
843 BOOL WINAPI DeleteObject( HGDIOBJ obj )
845 /* Check if object is valid */
847 GDIOBJHDR * header;
848 if (HIWORD(obj)) return FALSE;
850 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
852 if (!(header->wMagic & OBJECT_NOSYSTEM)
853 && (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
855 TRACE("Preserving system object %04x\n", obj);
856 GDI_ReleaseObj( obj );
857 return TRUE;
860 if (header->dwCount)
862 TRACE("delayed for %04x because object in use, count %ld\n", obj, header->dwCount );
863 header->dwCount |= 0x80000000; /* mark for delete */
864 GDI_ReleaseObj( obj );
865 return TRUE;
868 TRACE("%04x\n", obj );
870 /* Delete object */
872 if (header->funcs && header->funcs->pDeleteObject)
873 return header->funcs->pDeleteObject( obj, header );
875 GDI_ReleaseObj( obj );
876 return FALSE;
880 /***********************************************************************
881 * GetStockObject (GDI32.@)
883 HGDIOBJ WINAPI GetStockObject( INT obj )
885 HGDIOBJ ret;
886 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
887 ret = stock_objects[obj];
888 TRACE("returning %4x\n", ret );
889 return ret;
893 /***********************************************************************
894 * GetObject (GDI.82)
896 INT16 WINAPI GetObject16( HANDLE16 handle, INT16 count, LPVOID buffer )
898 GDIOBJHDR * ptr;
899 INT16 result = 0;
900 TRACE("%04x %d %p\n", handle, count, buffer );
901 if (!count) return 0;
903 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
905 if (ptr->funcs && ptr->funcs->pGetObject16)
906 result = ptr->funcs->pGetObject16( handle, ptr, count, buffer );
907 else
908 SetLastError( ERROR_INVALID_HANDLE );
910 GDI_ReleaseObj( handle );
911 return result;
915 /***********************************************************************
916 * GetObjectA (GDI32.@)
918 INT WINAPI GetObjectA( HANDLE handle, INT count, LPVOID buffer )
920 GDIOBJHDR * ptr;
921 INT result = 0;
922 TRACE("%08x %d %p\n", handle, count, buffer );
923 if (!count) return 0;
925 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
927 if (ptr->funcs && ptr->funcs->pGetObjectA)
928 result = ptr->funcs->pGetObjectA( handle, ptr, count, buffer );
929 else
930 SetLastError( ERROR_INVALID_HANDLE );
932 GDI_ReleaseObj( handle );
933 return result;
936 /***********************************************************************
937 * GetObjectW (GDI32.@)
939 INT WINAPI GetObjectW( HANDLE handle, INT count, LPVOID buffer )
941 GDIOBJHDR * ptr;
942 INT result = 0;
943 TRACE("%08x %d %p\n", handle, count, buffer );
944 if (!count) return 0;
946 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
948 if (ptr->funcs && ptr->funcs->pGetObjectW)
949 result = ptr->funcs->pGetObjectW( handle, ptr, count, buffer );
950 else
951 SetLastError( ERROR_INVALID_HANDLE );
953 GDI_ReleaseObj( handle );
954 return result;
957 /***********************************************************************
958 * GetObjectType (GDI32.@)
960 DWORD WINAPI GetObjectType( HANDLE handle )
962 GDIOBJHDR * ptr;
963 INT result = 0;
964 TRACE("%08x\n", handle );
966 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
968 switch(GDIMAGIC(ptr->wMagic))
970 case PEN_MAGIC:
971 result = OBJ_PEN;
972 break;
973 case BRUSH_MAGIC:
974 result = OBJ_BRUSH;
975 break;
976 case BITMAP_MAGIC:
977 result = OBJ_BITMAP;
978 break;
979 case FONT_MAGIC:
980 result = OBJ_FONT;
981 break;
982 case PALETTE_MAGIC:
983 result = OBJ_PAL;
984 break;
985 case REGION_MAGIC:
986 result = OBJ_REGION;
987 break;
988 case DC_MAGIC:
989 result = OBJ_DC;
990 break;
991 case META_DC_MAGIC:
992 result = OBJ_METADC;
993 break;
994 case METAFILE_MAGIC:
995 result = OBJ_METAFILE;
996 break;
997 case METAFILE_DC_MAGIC:
998 result = OBJ_METADC;
999 break;
1000 case ENHMETAFILE_MAGIC:
1001 result = OBJ_ENHMETAFILE;
1002 break;
1003 case ENHMETAFILE_DC_MAGIC:
1004 result = OBJ_ENHMETADC;
1005 break;
1006 default:
1007 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) );
1008 break;
1010 GDI_ReleaseObj( handle );
1011 return result;
1014 /***********************************************************************
1015 * GetCurrentObject (GDI32.@)
1017 HANDLE WINAPI GetCurrentObject(HDC hdc,UINT type)
1019 HANDLE ret = 0;
1020 DC * dc = DC_GetDCPtr( hdc );
1022 if (dc)
1024 switch (type) {
1025 case OBJ_PEN: ret = dc->hPen; break;
1026 case OBJ_BRUSH: ret = dc->hBrush; break;
1027 case OBJ_PAL: ret = dc->hPalette; break;
1028 case OBJ_FONT: ret = dc->hFont; break;
1029 case OBJ_BITMAP: ret = dc->hBitmap; break;
1030 default:
1031 /* the SDK only mentions those above */
1032 FIXME("(%08x,%d): unknown type.\n",hdc,type);
1033 break;
1035 GDI_ReleaseObj( hdc );
1037 return ret;
1041 /***********************************************************************
1042 * SelectObject (GDI32.@)
1044 HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ handle )
1046 HGDIOBJ ret = 0;
1047 GDIOBJHDR *header = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1048 if (!header) return 0;
1050 TRACE("hdc=%04x %04x\n", hdc, handle );
1052 if (header->funcs && header->funcs->pSelectObject)
1054 ret = header->funcs->pSelectObject( handle, header, hdc );
1055 if (ret && ret != handle && (INT)ret > COMPLEXREGION)
1057 inc_ref_count( handle );
1058 dec_ref_count( ret );
1061 GDI_ReleaseObj( handle );
1062 return ret;
1066 /***********************************************************************
1067 * UnrealizeObject (GDI32.@)
1069 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1071 BOOL result = TRUE;
1072 /* Check if object is valid */
1074 GDIOBJHDR * header = GDI_GetObjPtr( obj, MAGIC_DONTCARE );
1075 if (!header) return FALSE;
1077 TRACE("%04x\n", obj );
1079 /* Unrealize object */
1081 if (header->funcs && header->funcs->pUnrealizeObject)
1082 result = header->funcs->pUnrealizeObject( obj, header );
1084 GDI_ReleaseObj( obj );
1085 return result;
1089 /* Solid colors to enumerate */
1090 static const COLORREF solid_colors[] =
1091 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1092 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1093 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1094 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1095 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1096 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1097 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1098 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1101 /***********************************************************************
1102 * EnumObjects (GDI.71)
1104 INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 nObjType,
1105 GOBJENUMPROC16 lpEnumFunc, LPARAM lParam )
1107 INT16 i, retval = 0;
1108 LOGPEN16 pen;
1109 LOGBRUSH16 brush;
1110 SEGPTR segptr;
1112 TRACE("%04x %d %08lx %08lx\n",
1113 hdc, nObjType, (DWORD)lpEnumFunc, lParam );
1114 switch(nObjType)
1116 case OBJ_PEN:
1117 /* Enumerate solid pens */
1118 segptr = MapLS( &pen );
1119 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1121 pen.lopnStyle = PS_SOLID;
1122 pen.lopnWidth.x = 1;
1123 pen.lopnWidth.y = 0;
1124 pen.lopnColor = solid_colors[i];
1125 retval = GDI_CallTo16_word_ll( lpEnumFunc, segptr, lParam );
1126 TRACE("solid pen %08lx, ret=%d\n", solid_colors[i], retval);
1127 if (!retval) break;
1129 UnMapLS( segptr );
1130 break;
1132 case OBJ_BRUSH:
1133 /* Enumerate solid brushes */
1134 segptr = MapLS( &brush );
1135 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1137 brush.lbStyle = BS_SOLID;
1138 brush.lbColor = solid_colors[i];
1139 brush.lbHatch = 0;
1140 retval = GDI_CallTo16_word_ll( lpEnumFunc, segptr, lParam );
1141 TRACE("solid brush %08lx, ret=%d\n", solid_colors[i], retval);
1142 if (!retval) break;
1145 /* Now enumerate hatched brushes */
1146 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1148 brush.lbStyle = BS_HATCHED;
1149 brush.lbColor = RGB(0,0,0);
1150 brush.lbHatch = i;
1151 retval = GDI_CallTo16_word_ll( lpEnumFunc, segptr, lParam );
1152 TRACE("hatched brush %d, ret=%d\n", i, retval);
1153 if (!retval) break;
1155 UnMapLS( segptr );
1156 break;
1158 default:
1159 WARN("(%d): Invalid type\n", nObjType );
1160 break;
1162 return retval;
1166 /***********************************************************************
1167 * EnumObjects (GDI32.@)
1169 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1170 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1172 INT i, retval = 0;
1173 LOGPEN pen;
1174 LOGBRUSH brush;
1176 TRACE("%04x %d %08lx %08lx\n",
1177 hdc, nObjType, (DWORD)lpEnumFunc, lParam );
1178 switch(nObjType)
1180 case OBJ_PEN:
1181 /* Enumerate solid pens */
1182 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1184 pen.lopnStyle = PS_SOLID;
1185 pen.lopnWidth.x = 1;
1186 pen.lopnWidth.y = 0;
1187 pen.lopnColor = solid_colors[i];
1188 retval = lpEnumFunc( &pen, lParam );
1189 TRACE("solid pen %08lx, ret=%d\n",
1190 solid_colors[i], retval);
1191 if (!retval) break;
1193 break;
1195 case OBJ_BRUSH:
1196 /* Enumerate solid brushes */
1197 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1199 brush.lbStyle = BS_SOLID;
1200 brush.lbColor = solid_colors[i];
1201 brush.lbHatch = 0;
1202 retval = lpEnumFunc( &brush, lParam );
1203 TRACE("solid brush %08lx, ret=%d\n",
1204 solid_colors[i], retval);
1205 if (!retval) break;
1208 /* Now enumerate hatched brushes */
1209 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1211 brush.lbStyle = BS_HATCHED;
1212 brush.lbColor = RGB(0,0,0);
1213 brush.lbHatch = i;
1214 retval = lpEnumFunc( &brush, lParam );
1215 TRACE("hatched brush %d, ret=%d\n",
1216 i, retval);
1217 if (!retval) break;
1219 break;
1221 default:
1222 /* FIXME: implement Win32 types */
1223 WARN("(%d): Invalid type\n", nObjType );
1224 break;
1226 return retval;
1230 /***********************************************************************
1231 * IsGDIObject (GDI.462)
1233 * returns type of object if valid (W95 system programming secrets p. 264-5)
1235 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle )
1237 UINT16 magic = 0;
1239 GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1240 if (object)
1242 magic = GDIMAGIC(object->wMagic) - PEN_MAGIC + 1;
1243 GDI_ReleaseObj( handle );
1245 return magic;
1249 /***********************************************************************
1250 * SetObjectOwner (GDI32.@)
1252 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1254 /* Nothing to do */
1258 /***********************************************************************
1259 * MakeObjectPrivate (GDI.463)
1261 * What does that mean ?
1262 * Some little docu can be found in "Undocumented Windows",
1263 * but this is basically useless.
1264 * At least we know that this flags the GDI object's wMagic
1265 * with 0x2000 (OBJECT_PRIVATE), so we just do it.
1266 * But Wine doesn't react on that yet.
1268 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle, BOOL16 private )
1270 GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1271 if (!ptr)
1273 ERR("invalid GDI object %04x !\n", handle);
1274 return;
1276 ptr->wMagic |= OBJECT_PRIVATE;
1277 GDI_ReleaseObj( handle );
1281 /***********************************************************************
1282 * GdiFlush (GDI32.@)
1284 BOOL WINAPI GdiFlush(void)
1286 return TRUE; /* FIXME */
1290 /***********************************************************************
1291 * GdiGetBatchLimit (GDI32.@)
1293 DWORD WINAPI GdiGetBatchLimit(void)
1295 return 1; /* FIXME */
1299 /***********************************************************************
1300 * GdiSetBatchLimit (GDI32.@)
1302 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1304 return 1; /* FIXME */
1308 /***********************************************************************
1309 * GdiSeeGdiDo (GDI.452)
1311 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
1312 WORD wParam3 )
1314 switch (wReqType)
1316 case 0x0001: /* LocalAlloc */
1317 return LOCAL_Alloc( GDI_HeapSel, wParam1, wParam3 );
1318 case 0x0002: /* LocalFree */
1319 return LOCAL_Free( GDI_HeapSel, wParam1 );
1320 case 0x0003: /* LocalCompact */
1321 return LOCAL_Compact( GDI_HeapSel, wParam3, 0 );
1322 case 0x0103: /* LocalHeap */
1323 return GDI_HeapSel;
1324 default:
1325 WARN("(wReqType=%04x): Unknown\n", wReqType);
1326 return (DWORD)-1;
1330 /***********************************************************************
1331 * GdiSignalProc32 (GDI.610)
1333 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
1334 DWORD dwFlags, HMODULE16 hModule )
1336 return 0;
1339 /***********************************************************************
1340 * GdiInit2 (GDI.403)
1342 * See "Undocumented Windows"
1344 HANDLE16 WINAPI GdiInit216(
1345 HANDLE16 h1, /* [in] GDI object */
1346 HANDLE16 h2 /* [in] global data */
1349 FIXME("(%04x, %04x), stub.\n", h1, h2);
1350 if (h2 == 0xffff)
1351 return 0xffff; /* undefined return value */
1352 return h1; /* FIXME: should be the memory handle of h1 */
1355 /***********************************************************************
1356 * FinalGdiInit (GDI.405)
1358 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
1362 /***********************************************************************
1363 * GdiFreeResources (GDI.609)
1365 WORD WINAPI GdiFreeResources16( DWORD reserve )
1367 return (WORD)( (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
1368 (int)LOCAL_HeapSize( GDI_HeapSel ) );
1372 /*******************************************************************
1373 * GetColorAdjustment [GDI32.@]
1377 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1379 FIXME("GetColorAdjustment, stub\n");
1380 return 0;
1383 /*******************************************************************
1384 * GetMiterLimit [GDI32.@]
1388 BOOL WINAPI GetMiterLimit(HDC hdc, PFLOAT peLimit)
1390 FIXME("GetMiterLimit, stub\n");
1391 return 0;
1394 /*******************************************************************
1395 * SetMiterLimit [GDI32.@]
1399 BOOL WINAPI SetMiterLimit(HDC hdc, FLOAT eNewLimit, PFLOAT peOldLimit)
1401 FIXME("SetMiterLimit, stub\n");
1402 return 0;
1405 /*******************************************************************
1406 * GdiComment [GDI32.@]
1410 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1412 FIXME("GdiComment, stub\n");
1413 return 0;
1415 /*******************************************************************
1416 * SetColorAdjustment [GDI32.@]
1420 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1422 FIXME("SetColorAdjustment, stub\n");
1423 return 0;