Misc fixes.
[wine/gsoc_dplay.git] / objects / gdiobj.c
blobf55a308e8253a55bf46739fe27ac953be94670da
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"
32 #include "bitmap.h"
33 #include "local.h"
34 #include "palette.h"
35 #include "gdi.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(gdi);
40 #define HGDIOBJ_32(h16) ((HGDIOBJ)(ULONG_PTR)(h16))
42 /***********************************************************************
43 * GDI stock objects
46 static const LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 };
47 static const LOGBRUSH BlackBrush = { BS_SOLID, RGB(0,0,0), 0 };
48 static const LOGBRUSH NullBrush = { BS_NULL, 0, 0 };
50 /* FIXME: these should perhaps be BS_HATCHED, at least for 1 bitperpixel */
51 static const LOGBRUSH LtGrayBrush = { BS_SOLID, RGB(192,192,192), 0 };
52 static const LOGBRUSH GrayBrush = { BS_SOLID, RGB(128,128,128), 0 };
54 /* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
55 /* See HatchBrushes in x11drv for the HS_DIAGCROSS+1 hack */
56 static const LOGBRUSH DkGrayBrush = { BS_HATCHED, RGB(0,0,0), (HS_DIAGCROSS+1) };
58 static const LOGPEN WhitePen = { PS_SOLID, { 0, 0 }, RGB(255,255,255) };
59 static const LOGPEN BlackPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
60 static const LOGPEN NullPen = { PS_NULL, { 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 = { CRITICAL_SECTION_INIT("GDI_level"), 3 };
70 static WORD GDI_HeapSel;
72 inline static BOOL get_bool(char *buffer)
74 return (buffer[0] == 'y' || buffer[0] == 'Y' ||
75 buffer[0] == 't' || buffer[0] == 'T' ||
76 buffer[0] == '1');
80 /****************************************************************************
82 * language-independent stock fonts
86 static const LOGFONTW OEMFixedFont =
87 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
88 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
90 static const LOGFONTW AnsiFixedFont =
91 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
92 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, {'\0'} };
94 static const LOGFONTW AnsiVarFont =
95 { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
96 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
97 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
99 /******************************************************************************
101 * language-dependent stock fonts
103 * 'ANSI' charset and 'DEFAULT' charset is not same.
104 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
105 * 'ANSI' charset seems to be identical with ISO-8859-1.
106 * 'DEFAULT' charset is a language-dependent charset.
108 * 'System' font seems to be an alias for language-dependent font.
112 * language-dependenet stock fonts for all known charsets
113 * please see TranslateCharsetInfo (objects/font.c) and
114 * CharsetBindingInfo (graphics/x11drv/xfont.c),
115 * and modify entries for your language if needed.
117 struct DefaultFontInfo
119 UINT charset;
120 LOGFONTW SystemFont;
121 LOGFONTW DeviceDefaultFont;
122 LOGFONTW SystemFixedFont;
123 LOGFONTW DefaultGuiFont;
126 static const struct DefaultFontInfo default_fonts[] =
128 { ANSI_CHARSET,
129 { /* System */
130 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
131 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
132 {'S','y','s','t','e','m','\0'}
134 { /* Device Default */
135 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
136 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
137 {'\0'}
139 { /* System Fixed */
140 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
141 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
142 {'\0'}
144 { /* DefaultGuiFont */
145 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
146 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
147 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
150 { EASTEUROPE_CHARSET,
151 { /* System */
152 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
153 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
154 {'S','y','s','t','e','m','\0'}
156 { /* Device Default */
157 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
158 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
159 {'\0'}
161 { /* System Fixed */
162 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
163 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
164 {'\0'}
166 { /* DefaultGuiFont */
167 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, EASTEUROPE_CHARSET,
168 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
169 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
172 { RUSSIAN_CHARSET,
173 { /* System */
174 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
175 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
176 {'S','y','s','t','e','m','\0'}
178 { /* Device Default */
179 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
180 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
181 {'\0'}
183 { /* System Fixed */
184 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
185 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
186 {'\0'}
188 { /* DefaultGuiFont */
189 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, RUSSIAN_CHARSET,
190 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
191 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
194 { GREEK_CHARSET,
195 { /* System */
196 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
197 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
198 {'S','y','s','t','e','m','\0'}
200 { /* Device Default */
201 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
202 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
203 {'\0'}
205 { /* System Fixed */
206 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
207 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
208 {'\0'}
210 { /* DefaultGuiFont */
211 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GREEK_CHARSET,
212 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
213 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
216 { TURKISH_CHARSET,
217 { /* System */
218 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
219 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
220 {'S','y','s','t','e','m','\0'}
222 { /* Device Default */
223 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
224 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
225 {'\0'}
227 { /* System Fixed */
228 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
229 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
230 {'\0'}
232 { /* DefaultGuiFont */
233 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, TURKISH_CHARSET,
234 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
235 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
238 { HEBREW_CHARSET,
239 { /* System */
240 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
241 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
242 {'S','y','s','t','e','m','\0'}
244 { /* Device Default */
245 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
246 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
247 {'\0'}
249 { /* System Fixed */
250 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
251 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
252 {'\0'}
254 { /* DefaultGuiFont */
255 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HEBREW_CHARSET,
256 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
257 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
260 { ARABIC_CHARSET,
261 { /* System */
262 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
263 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
264 {'S','y','s','t','e','m','\0'}
266 { /* Device Default */
267 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
268 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
269 {'\0'}
271 { /* System Fixed */
272 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
273 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
274 {'\0'}
276 { /* DefaultGuiFont */
277 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ARABIC_CHARSET,
278 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
279 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
282 { BALTIC_CHARSET,
283 { /* System */
284 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
285 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
286 {'S','y','s','t','e','m','\0'}
288 { /* Device Default */
289 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
290 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
291 {'\0'}
293 { /* System Fixed */
294 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
295 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
296 {'\0'}
298 { /* DefaultGuiFont */
299 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, BALTIC_CHARSET,
300 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
301 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
304 { THAI_CHARSET,
305 { /* System */
306 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
307 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
308 {'S','y','s','t','e','m','\0'}
310 { /* Device Default */
311 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
312 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
313 {'\0'}
315 { /* System Fixed */
316 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
317 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
318 {'\0'}
320 { /* DefaultGuiFont */
321 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, THAI_CHARSET,
322 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
323 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
326 { SHIFTJIS_CHARSET,
327 { /* System */
328 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
329 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
330 {'S','y','s','t','e','m','\0'}
332 { /* Device Default */
333 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
334 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
335 {'\0'}
337 { /* System Fixed */
338 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
339 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
340 {'\0'}
342 { /* DefaultGuiFont */
343 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, SHIFTJIS_CHARSET,
344 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
345 {'M','S',' ','P',' ','g','o','t','h','i','c','\0'} /* FIXME: Is this correct? */
348 { GB2312_CHARSET,
349 { /* System */
350 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
351 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
352 {'S','y','s','t','e','m','\0'}
354 { /* Device Default */
355 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
356 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
357 {'\0'}
359 { /* System Fixed */
360 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
361 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
362 {'\0'}
364 { /* DefaultGuiFont */
365 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, GB2312_CHARSET,
366 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
367 {'M','S',' ','S','o','n','g','\0'} /* FIXME: Is this correct? */
370 { HANGEUL_CHARSET,
371 { /* System */
372 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
373 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
374 {'S','y','s','t','e','m','\0'}
376 { /* Device Default */
377 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
378 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
379 {'\0'}
381 { /* System Fixed */
382 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
383 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
384 {'\0'}
386 { /* DefaultGuiFont */
387 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, HANGEUL_CHARSET,
388 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
389 {'G','u','l','i','m'},
392 { CHINESEBIG5_CHARSET,
393 { /* System */
394 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
395 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
396 {'S','y','s','t','e','m','\0'}
398 { /* Device Default */
399 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
400 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
401 {'\0'}
403 { /* System Fixed */
404 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
405 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
406 {'\0'}
408 { /* DefaultGuiFont */
409 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, CHINESEBIG5_CHARSET,
410 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
411 {'\0'} /* FIXME - what is the native font??? */
414 { JOHAB_CHARSET,
415 { /* System */
416 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
417 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
418 {'S','y','s','t','e','m','\0'}
420 { /* Device Default */
421 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
422 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
423 {'\0'}
425 { /* System Fixed */
426 16, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
427 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
428 {'\0'}
430 { /* DefaultGuiFont */
431 -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, JOHAB_CHARSET,
432 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS,
433 {'M','S',' ','M','i','n','g','l','i','u','\0'} /* FIXME: Is this correct? */
439 /******************************************************************************
440 * get_default_fonts
442 static const struct DefaultFontInfo* get_default_fonts(UINT charset)
444 int n;
446 for(n=0;n<(sizeof(default_fonts)/sizeof(default_fonts[0]));n++)
448 if ( default_fonts[n].charset == charset )
449 return &default_fonts[n];
452 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset );
453 return &default_fonts[0];
457 /******************************************************************************
458 * get_default_charset (internal)
460 * get the language-dependent charset that can handle CP_ACP correctly.
462 static UINT get_default_charset( void )
464 CHARSETINFO csi;
465 UINT uACP;
467 uACP = GetACP();
468 csi.ciCharset = ANSI_CHARSET;
469 if ( ! TranslateCharsetInfo( (LPDWORD)uACP, &csi, TCI_SRCCODEPAGE ) )
471 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP );
472 return ANSI_CHARSET;
475 return csi.ciCharset;
479 /******************************************************************************
480 * create_stock_font
482 static HFONT create_stock_font( char const *fontName, const LOGFONTW *font, HKEY hkey )
484 LOGFONTW lf;
485 char key[256];
486 char buffer[MAX_PATH];
487 DWORD type, count;
489 if (!hkey) return CreateFontIndirectW( font );
491 lf = *font;
492 sprintf(key, "%s.Height", fontName);
493 count = sizeof(buffer);
494 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
495 lf.lfHeight = atoi(buffer);
497 sprintf(key, "%s.Bold", fontName);
498 count = sizeof(buffer);
499 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
500 lf.lfWeight = get_bool(buffer) ? FW_BOLD : FW_NORMAL;
502 sprintf(key, "%s.Italic", fontName);
503 count = sizeof(buffer);
504 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
505 lf.lfItalic = get_bool(buffer);
507 sprintf(key, "%s.Underline", fontName);
508 count = sizeof(buffer);
509 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
510 lf.lfUnderline = get_bool(buffer);
512 sprintf(key, "%s.StrikeOut", fontName);
513 count = sizeof(buffer);
514 if(!RegQueryValueExA(hkey, key, 0, &type, buffer, &count))
515 lf.lfStrikeOut = get_bool(buffer);
516 return CreateFontIndirectW( &lf );
520 #define TRACE_SEC(handle,text) \
521 TRACE("(%p): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
524 /***********************************************************************
525 * inc_ref_count
527 * Increment the reference count of a GDI object.
529 inline static void inc_ref_count( HGDIOBJ handle )
531 GDIOBJHDR *header;
533 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
535 header->dwCount++;
536 GDI_ReleaseObj( handle );
541 /***********************************************************************
542 * dec_ref_count
544 * Decrement the reference count of a GDI object.
546 inline static void dec_ref_count( HGDIOBJ handle )
548 GDIOBJHDR *header;
550 if ((header = GDI_GetObjPtr( handle, MAGIC_DONTCARE )))
552 if (header->dwCount) header->dwCount--;
553 if (header->dwCount != 0x80000000) GDI_ReleaseObj( handle );
554 else
556 /* handle delayed DeleteObject*/
557 header->dwCount = 0;
558 GDI_ReleaseObj( handle );
559 TRACE( "executing delayed DeleteObject for %p\n", handle );
560 DeleteObject( handle );
566 /***********************************************************************
567 * GDI_Init
569 * GDI initialization.
571 BOOL GDI_Init(void)
573 HINSTANCE16 instance;
574 HKEY hkey;
575 GDIOBJHDR *ptr;
576 const struct DefaultFontInfo* deffonts;
577 int i;
579 if (RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey))
580 hkey = 0;
582 /* create GDI heap */
583 if ((instance = LoadLibrary16( "GDI.EXE" )) >= 32) GDI_HeapSel = instance | 7;
585 /* create stock objects */
586 stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
587 stock_objects[LTGRAY_BRUSH] = CreateBrushIndirect( &LtGrayBrush );
588 stock_objects[GRAY_BRUSH] = CreateBrushIndirect( &GrayBrush );
589 stock_objects[DKGRAY_BRUSH] = CreateBrushIndirect( &DkGrayBrush );
590 stock_objects[BLACK_BRUSH] = CreateBrushIndirect( &BlackBrush );
591 stock_objects[NULL_BRUSH] = CreateBrushIndirect( &NullBrush );
593 stock_objects[WHITE_PEN] = CreatePenIndirect( &WhitePen );
594 stock_objects[BLACK_PEN] = CreatePenIndirect( &BlackPen );
595 stock_objects[NULL_PEN] = CreatePenIndirect( &NullPen );
597 stock_objects[DEFAULT_PALETTE] = PALETTE_Init();
598 stock_objects[DEFAULT_BITMAP] = CreateBitmap( 1, 1, 1, 1, NULL );
600 /* language-independent stock fonts */
601 stock_objects[OEM_FIXED_FONT] = create_stock_font( "OEMFixed", &OEMFixedFont, hkey );
602 stock_objects[ANSI_FIXED_FONT] = create_stock_font( "AnsiFixed", &AnsiFixedFont, hkey );
603 stock_objects[ANSI_VAR_FONT] = create_stock_font( "AnsiVar", &AnsiVarFont, hkey );
605 /* language-dependent stock fonts */
606 deffonts = get_default_fonts(get_default_charset());
607 stock_objects[SYSTEM_FONT] = create_stock_font( "System", &deffonts->SystemFont, hkey );
608 stock_objects[DEVICE_DEFAULT_FONT] = create_stock_font( "DeviceDefault", &deffonts->DeviceDefaultFont, hkey );
609 stock_objects[SYSTEM_FIXED_FONT] = create_stock_font( "SystemFixed", &deffonts->SystemFixedFont, hkey );
610 stock_objects[DEFAULT_GUI_FONT] = create_stock_font( "DefaultGui", &deffonts->DefaultGuiFont, hkey );
613 /* clear the NOSYSTEM bit on all stock objects*/
614 for (i = 0; i < NB_STOCK_OBJECTS; i++)
616 if (!stock_objects[i])
618 if (i == 9) continue; /* there's no stock object 9 */
619 ERR( "could not create stock object %d\n", i );
620 return FALSE;
622 ptr = GDI_GetObjPtr( stock_objects[i], MAGIC_DONTCARE );
623 ptr->wMagic &= ~OBJECT_NOSYSTEM;
624 GDI_ReleaseObj( stock_objects[i] );
627 if (hkey) RegCloseKey( hkey );
629 WineEngInit();
631 return TRUE;
634 #define FIRST_LARGE_HANDLE 16
635 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
636 static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES];
637 static int next_large_handle;
639 /***********************************************************************
640 * alloc_large_heap
642 * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject
644 inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle )
646 int i;
647 GDIOBJHDR *obj;
649 for (i = next_large_handle + 1; i < MAX_LARGE_HANDLES; i++)
650 if (!large_handles[i]) goto found;
651 for (i = 0; i <= next_large_handle; i++)
652 if (!large_handles[i]) goto found;
653 *handle = 0;
654 return NULL;
656 found:
657 if ((obj = HeapAlloc( GetProcessHeap(), 0, size )))
659 large_handles[i] = obj;
660 *handle = (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
661 next_large_handle = i;
663 return obj;
667 /***********************************************************************
668 * GDI_AllocObject
670 void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_obj_funcs *funcs )
672 GDIOBJHDR *obj;
673 HLOCAL16 hlocal;
675 _EnterSysLevel( &GDI_level );
676 switch(magic)
678 default:
679 if (GDI_HeapSel)
681 if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error;
682 assert( hlocal & 2 );
683 obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hlocal );
684 *handle = (HGDIOBJ)(ULONG_PTR)hlocal;
685 break;
687 /* fall through */
688 case DC_MAGIC:
689 case DISABLED_DC_MAGIC:
690 case META_DC_MAGIC:
691 case METAFILE_MAGIC:
692 case METAFILE_DC_MAGIC:
693 case ENHMETAFILE_MAGIC:
694 case ENHMETAFILE_DC_MAGIC:
695 case MEMORY_DC_MAGIC:
696 case BITMAP_MAGIC:
697 case PALETTE_MAGIC:
698 if (!(obj = alloc_large_heap( size, handle ))) goto error;
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 if ((UINT_PTR)handle & 2) /* GDI heap handle */
729 HLOCAL16 h = LOWORD(handle);
730 LOCAL_Unlock( GDI_HeapSel, h );
731 if ((new_handle = (HGDIOBJ)(ULONG_PTR)LOCAL_ReAlloc( GDI_HeapSel, h, size, LMEM_MOVEABLE )))
733 assert( new_handle == handle ); /* moveable handle cannot change */
734 return LOCAL_Lock( GDI_HeapSel, h );
737 else
739 int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
740 if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
742 void *new_ptr = HeapReAlloc( GetProcessHeap(), 0, large_handles[i], size );
743 if (new_ptr)
745 large_handles[i] = new_ptr;
746 return new_ptr;
749 else ERR( "Invalid handle %p\n", handle );
751 TRACE_SEC( handle, "leave" );
752 _LeaveSysLevel( &GDI_level );
753 return NULL;
757 /***********************************************************************
758 * GDI_FreeObject
760 BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
762 GDIOBJHDR *object = ptr;
764 object->wMagic = 0; /* Mark it as invalid */
765 object->funcs = NULL;
766 if ((UINT_PTR)handle & 2) /* GDI heap handle */
768 HLOCAL16 h = LOWORD(handle);
769 LOCAL_Unlock( GDI_HeapSel, h );
770 LOCAL_Free( GDI_HeapSel, h );
772 else /* large heap handle */
774 int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
775 if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
777 HeapFree( GetProcessHeap(), 0, large_handles[i] );
778 large_handles[i] = NULL;
780 else ERR( "Invalid handle %p\n", handle );
782 TRACE_SEC( handle, "leave" );
783 _LeaveSysLevel( &GDI_level );
784 return TRUE;
788 /***********************************************************************
789 * GDI_GetObjPtr
791 * Return a pointer to the GDI object associated to the handle.
792 * Return NULL if the object has the wrong magic number.
793 * The object must be released with GDI_ReleaseObj.
795 void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
797 GDIOBJHDR *ptr = NULL;
799 _EnterSysLevel( &GDI_level );
801 if ((UINT_PTR)handle & 2) /* GDI heap handle */
803 HLOCAL16 h = LOWORD(handle);
804 ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, h );
805 if (ptr)
807 if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ||
808 (GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) ||
809 (GDIMAGIC(ptr->wMagic) > LAST_MAGIC))
811 LOCAL_Unlock( GDI_HeapSel, h );
812 ptr = NULL;
816 else /* large heap handle */
818 int i = ((UINT_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
819 if (i >= 0 && i < MAX_LARGE_HANDLES)
821 ptr = large_handles[i];
822 if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL;
826 if (!ptr)
828 _LeaveSysLevel( &GDI_level );
829 SetLastError( ERROR_INVALID_HANDLE );
830 WARN( "Invalid handle %p\n", handle );
832 else TRACE_SEC( handle, "enter" );
834 return ptr;
838 /***********************************************************************
839 * GDI_ReleaseObj
842 void GDI_ReleaseObj( HGDIOBJ handle )
844 if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, LOWORD(handle) );
845 TRACE_SEC( handle, "leave" );
846 _LeaveSysLevel( &GDI_level );
850 /***********************************************************************
851 * GDI_CheckNotLock
853 void GDI_CheckNotLock(void)
855 _CheckNotSysLevel( &GDI_level );
859 /***********************************************************************
860 * DeleteObject (GDI32.@)
862 BOOL WINAPI DeleteObject( HGDIOBJ obj )
864 /* Check if object is valid */
866 GDIOBJHDR * header;
867 if (HIWORD(obj)) return FALSE;
869 if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE;
871 if (!(header->wMagic & OBJECT_NOSYSTEM)
872 && (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC))
874 TRACE("Preserving system object %p\n", obj);
875 GDI_ReleaseObj( obj );
876 return TRUE;
879 if (header->dwCount)
881 TRACE("delayed for %p because object in use, count %ld\n", obj, header->dwCount );
882 header->dwCount |= 0x80000000; /* mark for delete */
883 GDI_ReleaseObj( obj );
884 return TRUE;
887 TRACE("%p\n", obj );
889 /* Delete object */
891 if (header->funcs && header->funcs->pDeleteObject)
892 return header->funcs->pDeleteObject( obj, header );
894 GDI_ReleaseObj( obj );
895 return FALSE;
899 /***********************************************************************
900 * GetStockObject (GDI32.@)
902 HGDIOBJ WINAPI GetStockObject( INT obj )
904 HGDIOBJ ret;
905 if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0;
906 ret = stock_objects[obj];
907 TRACE("returning %p\n", ret );
908 return ret;
912 /***********************************************************************
913 * GetObject (GDI.82)
915 INT16 WINAPI GetObject16( HANDLE16 handle16, INT16 count, LPVOID buffer )
917 GDIOBJHDR * ptr;
918 HGDIOBJ handle = HGDIOBJ_32( handle16 );
919 INT16 result = 0;
921 TRACE("%p %d %p\n", handle, count, buffer );
922 if (!count) return 0;
924 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
926 if (ptr->funcs && ptr->funcs->pGetObject16)
927 result = ptr->funcs->pGetObject16( handle, ptr, count, buffer );
928 else
929 SetLastError( ERROR_INVALID_HANDLE );
931 GDI_ReleaseObj( handle );
932 return result;
936 /***********************************************************************
937 * GetObjectA (GDI32.@)
939 INT WINAPI GetObjectA( HANDLE handle, INT count, LPVOID buffer )
941 GDIOBJHDR * ptr;
942 INT result = 0;
943 TRACE("%p %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->pGetObjectA)
949 result = ptr->funcs->pGetObjectA( handle, ptr, count, buffer );
950 else
951 SetLastError( ERROR_INVALID_HANDLE );
953 GDI_ReleaseObj( handle );
954 return result;
957 /***********************************************************************
958 * GetObjectW (GDI32.@)
960 INT WINAPI GetObjectW( HANDLE handle, INT count, LPVOID buffer )
962 GDIOBJHDR * ptr;
963 INT result = 0;
964 TRACE("%p %d %p\n", handle, count, buffer );
965 if (!count) return 0;
967 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
969 if (ptr->funcs && ptr->funcs->pGetObjectW)
970 result = ptr->funcs->pGetObjectW( handle, ptr, count, buffer );
971 else
972 SetLastError( ERROR_INVALID_HANDLE );
974 GDI_ReleaseObj( handle );
975 return result;
978 /***********************************************************************
979 * GetObjectType (GDI32.@)
981 DWORD WINAPI GetObjectType( HANDLE handle )
983 GDIOBJHDR * ptr;
984 INT result = 0;
985 TRACE("%p\n", handle );
987 if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0;
989 switch(GDIMAGIC(ptr->wMagic))
991 case PEN_MAGIC:
992 result = OBJ_PEN;
993 break;
994 case BRUSH_MAGIC:
995 result = OBJ_BRUSH;
996 break;
997 case BITMAP_MAGIC:
998 result = OBJ_BITMAP;
999 break;
1000 case FONT_MAGIC:
1001 result = OBJ_FONT;
1002 break;
1003 case PALETTE_MAGIC:
1004 result = OBJ_PAL;
1005 break;
1006 case REGION_MAGIC:
1007 result = OBJ_REGION;
1008 break;
1009 case DC_MAGIC:
1010 result = OBJ_DC;
1011 break;
1012 case META_DC_MAGIC:
1013 result = OBJ_METADC;
1014 break;
1015 case METAFILE_MAGIC:
1016 result = OBJ_METAFILE;
1017 break;
1018 case METAFILE_DC_MAGIC:
1019 result = OBJ_METADC;
1020 break;
1021 case ENHMETAFILE_MAGIC:
1022 result = OBJ_ENHMETAFILE;
1023 break;
1024 case ENHMETAFILE_DC_MAGIC:
1025 result = OBJ_ENHMETADC;
1026 break;
1027 case MEMORY_DC_MAGIC:
1028 result = OBJ_MEMDC;
1029 break;
1030 default:
1031 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) );
1032 break;
1034 GDI_ReleaseObj( handle );
1035 return result;
1038 /***********************************************************************
1039 * GetCurrentObject (GDI32.@)
1041 HANDLE WINAPI GetCurrentObject(HDC hdc,UINT type)
1043 HANDLE ret = 0;
1044 DC * dc = DC_GetDCPtr( hdc );
1046 if (dc)
1048 switch (type) {
1049 case OBJ_PEN: ret = dc->hPen; break;
1050 case OBJ_BRUSH: ret = dc->hBrush; break;
1051 case OBJ_PAL: ret = dc->hPalette; break;
1052 case OBJ_FONT: ret = dc->hFont; break;
1053 case OBJ_BITMAP: ret = dc->hBitmap; break;
1054 default:
1055 /* the SDK only mentions those above */
1056 FIXME("(%p,%d): unknown type.\n",hdc,type);
1057 break;
1059 GDI_ReleaseObj( hdc );
1061 return ret;
1065 /***********************************************************************
1066 * SelectObject (GDI32.@)
1068 HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ handle )
1070 HGDIOBJ ret = 0;
1071 GDIOBJHDR *header = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1072 if (!header) return 0;
1074 TRACE("hdc=%p %p\n", hdc, handle );
1076 if (header->funcs && header->funcs->pSelectObject)
1078 ret = header->funcs->pSelectObject( handle, header, hdc );
1079 if (ret && ret != handle && (INT)ret > COMPLEXREGION)
1081 inc_ref_count( handle );
1082 dec_ref_count( ret );
1085 GDI_ReleaseObj( handle );
1086 return ret;
1090 /***********************************************************************
1091 * UnrealizeObject (GDI32.@)
1093 BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
1095 BOOL result = TRUE;
1096 /* Check if object is valid */
1098 GDIOBJHDR * header = GDI_GetObjPtr( obj, MAGIC_DONTCARE );
1099 if (!header) return FALSE;
1101 TRACE("%p\n", obj );
1103 /* Unrealize object */
1105 if (header->funcs && header->funcs->pUnrealizeObject)
1106 result = header->funcs->pUnrealizeObject( obj, header );
1108 GDI_ReleaseObj( obj );
1109 return result;
1113 /* Solid colors to enumerate */
1114 static const COLORREF solid_colors[] =
1115 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1116 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1117 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1118 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1119 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1120 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1121 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1122 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1126 /***********************************************************************
1127 * EnumObjects (GDI32.@)
1129 INT WINAPI EnumObjects( HDC hdc, INT nObjType,
1130 GOBJENUMPROC lpEnumFunc, LPARAM lParam )
1132 INT i, retval = 0;
1133 LOGPEN pen;
1134 LOGBRUSH brush;
1136 TRACE("%p %d %p %08lx\n", hdc, nObjType, lpEnumFunc, lParam );
1137 switch(nObjType)
1139 case OBJ_PEN:
1140 /* Enumerate solid pens */
1141 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1143 pen.lopnStyle = PS_SOLID;
1144 pen.lopnWidth.x = 1;
1145 pen.lopnWidth.y = 0;
1146 pen.lopnColor = solid_colors[i];
1147 retval = lpEnumFunc( &pen, lParam );
1148 TRACE("solid pen %08lx, ret=%d\n",
1149 solid_colors[i], retval);
1150 if (!retval) break;
1152 break;
1154 case OBJ_BRUSH:
1155 /* Enumerate solid brushes */
1156 for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
1158 brush.lbStyle = BS_SOLID;
1159 brush.lbColor = solid_colors[i];
1160 brush.lbHatch = 0;
1161 retval = lpEnumFunc( &brush, lParam );
1162 TRACE("solid brush %08lx, ret=%d\n",
1163 solid_colors[i], retval);
1164 if (!retval) break;
1167 /* Now enumerate hatched brushes */
1168 if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++)
1170 brush.lbStyle = BS_HATCHED;
1171 brush.lbColor = RGB(0,0,0);
1172 brush.lbHatch = i;
1173 retval = lpEnumFunc( &brush, lParam );
1174 TRACE("hatched brush %d, ret=%d\n",
1175 i, retval);
1176 if (!retval) break;
1178 break;
1180 default:
1181 /* FIXME: implement Win32 types */
1182 WARN("(%d): Invalid type\n", nObjType );
1183 break;
1185 return retval;
1189 /***********************************************************************
1190 * IsGDIObject (GDI.462)
1192 * returns type of object if valid (W95 system programming secrets p. 264-5)
1194 BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
1196 UINT16 magic = 0;
1197 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1199 GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1200 if (object)
1202 magic = GDIMAGIC(object->wMagic) - PEN_MAGIC + 1;
1203 GDI_ReleaseObj( handle );
1205 return magic;
1209 /***********************************************************************
1210 * SetObjectOwner (GDI32.@)
1212 void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner )
1214 /* Nothing to do */
1218 /***********************************************************************
1219 * MakeObjectPrivate (GDI.463)
1221 * What does that mean ?
1222 * Some little docu can be found in "Undocumented Windows",
1223 * but this is basically useless.
1224 * At least we know that this flags the GDI object's wMagic
1225 * with 0x2000 (OBJECT_PRIVATE), so we just do it.
1226 * But Wine doesn't react on that yet.
1228 void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
1230 HGDIOBJ handle = HGDIOBJ_32( handle16 );
1231 GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
1232 if (!ptr)
1234 ERR("invalid GDI object %p !\n", handle);
1235 return;
1237 ptr->wMagic |= OBJECT_PRIVATE;
1238 GDI_ReleaseObj( handle );
1242 /***********************************************************************
1243 * GdiFlush (GDI32.@)
1245 BOOL WINAPI GdiFlush(void)
1247 return TRUE; /* FIXME */
1251 /***********************************************************************
1252 * GdiGetBatchLimit (GDI32.@)
1254 DWORD WINAPI GdiGetBatchLimit(void)
1256 return 1; /* FIXME */
1260 /***********************************************************************
1261 * GdiSetBatchLimit (GDI32.@)
1263 DWORD WINAPI GdiSetBatchLimit( DWORD limit )
1265 return 1; /* FIXME */
1269 /***********************************************************************
1270 * GdiSeeGdiDo (GDI.452)
1272 DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
1273 WORD wParam3 )
1275 switch (wReqType)
1277 case 0x0001: /* LocalAlloc */
1278 return LOCAL_Alloc( GDI_HeapSel, wParam1, wParam3 );
1279 case 0x0002: /* LocalFree */
1280 return LOCAL_Free( GDI_HeapSel, wParam1 );
1281 case 0x0003: /* LocalCompact */
1282 return LOCAL_Compact( GDI_HeapSel, wParam3, 0 );
1283 case 0x0103: /* LocalHeap */
1284 return GDI_HeapSel;
1285 default:
1286 WARN("(wReqType=%04x): Unknown\n", wReqType);
1287 return (DWORD)-1;
1291 /***********************************************************************
1292 * GdiSignalProc32 (GDI.610)
1294 WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
1295 DWORD dwFlags, HMODULE16 hModule )
1297 return 0;
1300 /***********************************************************************
1301 * GdiInit2 (GDI.403)
1303 * See "Undocumented Windows"
1305 HANDLE16 WINAPI GdiInit216(
1306 HANDLE16 h1, /* [in] GDI object */
1307 HANDLE16 h2 /* [in] global data */
1310 FIXME("(%04x, %04x), stub.\n", h1, h2);
1311 if (h2 == 0xffff)
1312 return 0xffff; /* undefined return value */
1313 return h1; /* FIXME: should be the memory handle of h1 */
1316 /***********************************************************************
1317 * FinalGdiInit (GDI.405)
1319 void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ )
1323 /***********************************************************************
1324 * GdiFreeResources (GDI.609)
1326 WORD WINAPI GdiFreeResources16( DWORD reserve )
1328 return (WORD)( (int)LOCAL_CountFree( GDI_HeapSel ) * 100 /
1329 (int)LOCAL_HeapSize( GDI_HeapSel ) );
1333 /*******************************************************************
1334 * GetColorAdjustment [GDI32.@]
1338 BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
1340 FIXME("GetColorAdjustment, stub\n");
1341 return 0;
1344 /*******************************************************************
1345 * GetMiterLimit [GDI32.@]
1349 BOOL WINAPI GetMiterLimit(HDC hdc, PFLOAT peLimit)
1351 FIXME("GetMiterLimit, stub\n");
1352 return 0;
1355 /*******************************************************************
1356 * SetMiterLimit [GDI32.@]
1360 BOOL WINAPI SetMiterLimit(HDC hdc, FLOAT eNewLimit, PFLOAT peOldLimit)
1362 FIXME("SetMiterLimit, stub\n");
1363 return 0;
1366 /*******************************************************************
1367 * GdiComment [GDI32.@]
1371 BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
1373 DC *dc = DC_GetDCPtr(hdc);
1374 BOOL ret = FALSE;
1375 if(dc)
1377 if (dc->funcs->pGdiComment)
1378 ret = dc->funcs->pGdiComment( dc->physDev, cbSize, lpData );
1380 GDI_ReleaseObj( hdc );
1381 return ret;
1384 /*******************************************************************
1385 * SetColorAdjustment [GDI32.@]
1389 BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca)
1391 FIXME("SetColorAdjustment, stub\n");
1392 return 0;