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
31 #include "wine/winbase16.h"
40 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(gdi
);
45 /* ### start build ### */
46 extern WORD CALLBACK
GDI_CallTo16_word_ll(GOBJENUMPROC16
,LONG
,LONG
);
47 /* ### stop build ### */
49 /***********************************************************************
53 static const LOGBRUSH WhiteBrush
= { BS_SOLID
, RGB(255,255,255), 0 };
54 static const LOGBRUSH BlackBrush
= { BS_SOLID
, RGB(0,0,0), 0 };
55 static const LOGBRUSH NullBrush
= { BS_NULL
, 0, 0 };
57 /* FIXME: these should perhaps be BS_HATCHED, at least for 1 bitperpixel */
58 static const LOGBRUSH LtGrayBrush
= { BS_SOLID
, RGB(192,192,192), 0 };
59 static const LOGBRUSH GrayBrush
= { BS_SOLID
, RGB(128,128,128), 0 };
61 /* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
62 /* NB_HATCH_STYLES is an index into HatchBrushes */
63 static const LOGBRUSH DkGrayBrush
= { BS_HATCHED
, RGB(0,0,0), NB_HATCH_STYLES
};
65 static const LOGPEN WhitePen
= { PS_SOLID
, { 0, 0 }, RGB(255,255,255) };
66 static const LOGPEN BlackPen
= { PS_SOLID
, { 0, 0 }, RGB(0,0,0) };
67 static const LOGPEN NullPen
= { PS_NULL
, { 0, 0 }, 0 };
70 /* reserve one extra entry for the stock default bitmap */
71 /* this is what Windows does too */
72 #define NB_STOCK_OBJECTS (STOCK_LAST+2)
74 static HGDIOBJ stock_objects
[NB_STOCK_OBJECTS
];
76 static SYSLEVEL GDI_level
= { CRITICAL_SECTION_INIT("GDI_level"), 3 };
77 static WORD GDI_HeapSel
;
79 inline static BOOL
get_bool(char *buffer
)
81 return (buffer
[0] == 'y' || buffer
[0] == 'Y' ||
82 buffer
[0] == 't' || buffer
[0] == 'T' ||
87 /****************************************************************************
89 * language-independent stock fonts
93 static const LOGFONTW OEMFixedFont
=
94 { 12, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, OEM_CHARSET
,
95 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, {'\0'} };
97 static const LOGFONTW AnsiFixedFont
=
98 { 12, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
99 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
, {'\0'} };
101 static const LOGFONTW AnsiVarFont
=
102 { 12, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
103 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
104 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'} };
106 /******************************************************************************
108 * language-dependent stock fonts
110 * 'ANSI' charset and 'DEFAULT' charset is not same.
111 * The chars in CP_ACP should be drawn with 'DEFAULT' charset.
112 * 'ANSI' charset seems to be identical with ISO-8859-1.
113 * 'DEFAULT' charset is a language-dependent charset.
115 * 'System' font seems to be an alias for language-dependent font.
119 * language-dependenet stock fonts for all known charsets
120 * please see TranslateCharsetInfo (objects/font.c) and
121 * CharsetBindingInfo (graphics/x11drv/xfont.c),
122 * and modify entries for your language if needed.
124 struct DefaultFontInfo
128 LOGFONTW DeviceDefaultFont
;
129 LOGFONTW SystemFixedFont
;
130 LOGFONTW DefaultGuiFont
;
133 static const struct DefaultFontInfo default_fonts
[] =
137 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
138 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
139 {'S','y','s','t','e','m','\0'}
141 { /* Device Default */
142 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
143 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
147 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
148 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
151 { /* DefaultGuiFont */
152 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
153 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
154 {'M','S',' ','S','a','n','s',' ','S','e','r','i','f','\0'}
157 { EASTEUROPE_CHARSET
,
159 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, EASTEUROPE_CHARSET
,
160 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
161 {'S','y','s','t','e','m','\0'}
163 { /* Device Default */
164 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, EASTEUROPE_CHARSET
,
165 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
169 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, EASTEUROPE_CHARSET
,
170 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
173 { /* DefaultGuiFont */
174 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, EASTEUROPE_CHARSET
,
175 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
176 {'\0'} /* FIXME - what is the native font??? */
181 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, RUSSIAN_CHARSET
,
182 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
183 {'S','y','s','t','e','m','\0'}
185 { /* Device Default */
186 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, RUSSIAN_CHARSET
,
187 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
191 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, RUSSIAN_CHARSET
,
192 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
195 { /* DefaultGuiFont */
196 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, RUSSIAN_CHARSET
,
197 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
198 {'\0'} /* FIXME - what is the native font??? */
203 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GREEK_CHARSET
,
204 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
205 {'S','y','s','t','e','m','\0'}
207 { /* Device Default */
208 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GREEK_CHARSET
,
209 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
213 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GREEK_CHARSET
,
214 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
217 { /* DefaultGuiFont */
218 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GREEK_CHARSET
,
219 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
220 {'\0'} /* FIXME - what is the native font??? */
225 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, TURKISH_CHARSET
,
226 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
227 {'S','y','s','t','e','m','\0'}
229 { /* Device Default */
230 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, TURKISH_CHARSET
,
231 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
235 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, TURKISH_CHARSET
,
236 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
239 { /* DefaultGuiFont */
240 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, TURKISH_CHARSET
,
241 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
242 {'\0'} /* FIXME - what is the native font??? */
247 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HEBREW_CHARSET
,
248 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
249 {'S','y','s','t','e','m','\0'}
251 { /* Device Default */
252 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HEBREW_CHARSET
,
253 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
257 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HEBREW_CHARSET
,
258 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
261 { /* DefaultGuiFont */
262 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HEBREW_CHARSET
,
263 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
264 {'\0'} /* FIXME - what is the native font??? */
269 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ARABIC_CHARSET
,
270 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
271 {'S','y','s','t','e','m','\0'}
273 { /* Device Default */
274 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ARABIC_CHARSET
,
275 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
279 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ARABIC_CHARSET
,
280 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
283 { /* DefaultGuiFont */
284 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ARABIC_CHARSET
,
285 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
286 {'\0'} /* FIXME - what is the native font??? */
291 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, BALTIC_CHARSET
,
292 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
293 {'S','y','s','t','e','m','\0'}
295 { /* Device Default */
296 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, BALTIC_CHARSET
,
297 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
301 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, BALTIC_CHARSET
,
302 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
305 { /* DefaultGuiFont */
306 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, BALTIC_CHARSET
,
307 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
308 {'\0'} /* FIXME - what is the native font??? */
314 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
315 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
316 {'S','y','s','t','e','m','\0'}
318 { /* Device Default */
319 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
320 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
324 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
325 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
328 { /* DefaultGuiFont */
329 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
330 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
331 {'\0'} /* FIXME - what is the native font??? */
336 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
337 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
338 {'S','y','s','t','e','m','\0'}
340 { /* Device Default */
341 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
342 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
346 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
347 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
350 { /* DefaultGuiFont */
351 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
352 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
353 {'\0'} /* FIXME - mbtowc of native ("MS P gothic") */
358 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
359 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
360 {'S','y','s','t','e','m','\0'}
362 { /* Device Default */
363 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
364 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
368 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
369 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
372 { /* DefaultGuiFont */
373 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
374 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
375 {'M','S',' ','S','o','n','g','\0'} /* FIXME: Is this correct? */
380 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
381 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
382 {'S','y','s','t','e','m','\0'}
384 { /* Device Default */
385 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
386 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
390 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
391 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
394 { /* DefaultGuiFont */
395 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
396 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
397 {'G','u','l','i','m','C','h','e'}, /* FIXME: Is this correct? */
400 { CHINESEBIG5_CHARSET
,
402 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
403 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
404 {'S','y','s','t','e','m','\0'}
406 { /* Device Default */
407 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
408 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
412 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
413 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
416 { /* DefaultGuiFont */
417 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
418 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
419 {'\0'} /* FIXME - what is the native font??? */
424 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
425 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
426 {'S','y','s','t','e','m','\0'}
428 { /* Device Default */
429 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
430 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
434 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
435 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
438 { /* DefaultGuiFont */
439 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
440 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
441 {'\0'} /* FIXME - what is the native font??? mbtowc of native ("MS Mingliu")??? */
447 /******************************************************************************
450 static const struct DefaultFontInfo
* get_default_fonts(UINT charset
)
454 for(n
=0;n
<(sizeof(default_fonts
)/sizeof(default_fonts
[0]));n
++)
456 if ( default_fonts
[n
].charset
== charset
)
457 return &default_fonts
[n
];
460 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset
);
461 return &default_fonts
[0];
465 /******************************************************************************
466 * get_default_charset (internal)
468 * get the language-dependent charset that can handle CP_ACP correctly.
470 static UINT
get_default_charset( void )
476 csi
.ciCharset
= ANSI_CHARSET
;
477 if ( ! TranslateCharsetInfo( (LPDWORD
)uACP
, &csi
, TCI_SRCCODEPAGE
) )
479 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP
);
483 return csi
.ciCharset
;
487 /******************************************************************************
490 static HFONT
create_stock_font( char const *fontName
, const LOGFONTW
*font
, HKEY hkey
)
494 char buffer
[MAX_PATH
];
497 if (!hkey
) return CreateFontIndirectW( font
);
500 sprintf(key
, "%s.Height", fontName
);
501 count
= sizeof(buffer
);
502 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
503 lf
.lfHeight
= atoi(buffer
);
505 sprintf(key
, "%s.Bold", fontName
);
506 count
= sizeof(buffer
);
507 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
508 lf
.lfWeight
= get_bool(buffer
) ? FW_BOLD
: FW_NORMAL
;
510 sprintf(key
, "%s.Italic", fontName
);
511 count
= sizeof(buffer
);
512 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
513 lf
.lfItalic
= get_bool(buffer
);
515 sprintf(key
, "%s.Underline", fontName
);
516 count
= sizeof(buffer
);
517 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
518 lf
.lfUnderline
= get_bool(buffer
);
520 sprintf(key
, "%s.StrikeOut", fontName
);
521 count
= sizeof(buffer
);
522 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
523 lf
.lfStrikeOut
= get_bool(buffer
);
524 return CreateFontIndirectW( &lf
);
528 #define TRACE_SEC(handle,text) \
529 TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
532 /***********************************************************************
535 * Increment the reference count of a GDI object.
537 inline static void inc_ref_count( HGDIOBJ handle
)
541 if ((header
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
)))
544 GDI_ReleaseObj( handle
);
549 /***********************************************************************
552 * Decrement the reference count of a GDI object.
554 inline static void dec_ref_count( HGDIOBJ handle
)
558 if ((header
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
)))
560 if (header
->dwCount
) header
->dwCount
--;
561 if (header
->dwCount
!= 0x80000000) GDI_ReleaseObj( handle
);
564 /* handle delayed DeleteObject*/
566 GDI_ReleaseObj( handle
);
567 TRACE( "executing delayed DeleteObject for %04x\n", handle
);
568 DeleteObject( handle
);
574 /***********************************************************************
577 * GDI initialization.
581 HINSTANCE16 instance
;
584 const struct DefaultFontInfo
* deffonts
;
587 if (RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey
))
590 /* create GDI heap */
591 if ((instance
= LoadLibrary16( "GDI.EXE" )) < 32) return FALSE
;
592 GDI_HeapSel
= instance
| 7;
594 /* create stock objects */
595 stock_objects
[WHITE_BRUSH
] = CreateBrushIndirect( &WhiteBrush
);
596 stock_objects
[LTGRAY_BRUSH
] = CreateBrushIndirect( &LtGrayBrush
);
597 stock_objects
[GRAY_BRUSH
] = CreateBrushIndirect( &GrayBrush
);
598 stock_objects
[DKGRAY_BRUSH
] = CreateBrushIndirect( &DkGrayBrush
);
599 stock_objects
[BLACK_BRUSH
] = CreateBrushIndirect( &BlackBrush
);
600 stock_objects
[NULL_BRUSH
] = CreateBrushIndirect( &NullBrush
);
602 stock_objects
[WHITE_PEN
] = CreatePenIndirect( &WhitePen
);
603 stock_objects
[BLACK_PEN
] = CreatePenIndirect( &BlackPen
);
604 stock_objects
[NULL_PEN
] = CreatePenIndirect( &NullPen
);
606 stock_objects
[DEFAULT_PALETTE
] = PALETTE_Init();
607 stock_objects
[DEFAULT_BITMAP
] = CreateBitmap( 1, 1, 1, 1, NULL
);
609 /* language-independent stock fonts */
610 stock_objects
[OEM_FIXED_FONT
] = create_stock_font( "OEMFixed", &OEMFixedFont
, hkey
);
611 stock_objects
[ANSI_FIXED_FONT
] = create_stock_font( "AnsiFixed", &AnsiFixedFont
, hkey
);
612 stock_objects
[ANSI_VAR_FONT
] = create_stock_font( "AnsiVar", &AnsiVarFont
, hkey
);
614 /* language-dependent stock fonts */
615 deffonts
= get_default_fonts(get_default_charset());
616 stock_objects
[SYSTEM_FONT
] = create_stock_font( "System", &deffonts
->SystemFont
, hkey
);
617 stock_objects
[DEVICE_DEFAULT_FONT
] = create_stock_font( "DeviceDefault", &deffonts
->DeviceDefaultFont
, hkey
);
618 stock_objects
[SYSTEM_FIXED_FONT
] = create_stock_font( "SystemFixed", &deffonts
->SystemFixedFont
, hkey
);
619 stock_objects
[DEFAULT_GUI_FONT
] = create_stock_font( "DefaultGui", &deffonts
->DefaultGuiFont
, hkey
);
622 /* clear the NOSYSTEM bit on all stock objects*/
623 for (i
= 0; i
< NB_STOCK_OBJECTS
; i
++)
625 if (!stock_objects
[i
])
627 if (i
== 9) continue; /* there's no stock object 9 */
628 ERR( "could not create stock object %d\n", i
);
631 ptr
= GDI_GetObjPtr( stock_objects
[i
], MAGIC_DONTCARE
);
632 ptr
->wMagic
&= ~OBJECT_NOSYSTEM
;
633 GDI_ReleaseObj( stock_objects
[i
] );
636 if (hkey
) RegCloseKey( hkey
);
643 #define FIRST_LARGE_HANDLE 16
644 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
645 static GDIOBJHDR
*large_handles
[MAX_LARGE_HANDLES
];
646 static int next_large_handle
;
648 /***********************************************************************
651 * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject
653 inline static GDIOBJHDR
*alloc_large_heap( WORD size
, HGDIOBJ
*handle
)
658 for (i
= next_large_handle
+ 1; i
< MAX_LARGE_HANDLES
; i
++)
659 if (!large_handles
[i
]) goto found
;
660 for (i
= 0; i
<= next_large_handle
; i
++)
661 if (!large_handles
[i
]) goto found
;
666 if ((obj
= HeapAlloc( GetProcessHeap(), 0, size
)))
668 large_handles
[i
] = obj
;
669 *handle
= (i
+ FIRST_LARGE_HANDLE
) << 2;
670 next_large_handle
= i
;
676 /***********************************************************************
679 void *GDI_AllocObject( WORD size
, WORD magic
, HGDIOBJ
*handle
)
683 _EnterSysLevel( &GDI_level
);
686 /* allocate DCs on the larger heap */
688 case DISABLED_DC_MAGIC
:
691 case METAFILE_DC_MAGIC
:
692 case ENHMETAFILE_MAGIC
:
693 case ENHMETAFILE_DC_MAGIC
:
695 if (!(obj
= alloc_large_heap( size
, handle
))) goto error
;
698 if (!(*handle
= LOCAL_Alloc( GDI_HeapSel
, LMEM_MOVEABLE
, size
))) goto error
;
699 assert( *handle
& 2 );
700 obj
= (GDIOBJHDR
*)LOCAL_Lock( GDI_HeapSel
, *handle
);
705 obj
->wMagic
= magic
|OBJECT_NOSYSTEM
;
708 TRACE_SEC( *handle
, "enter" );
712 _LeaveSysLevel( &GDI_level
);
718 /***********************************************************************
721 * The object ptr must have been obtained with GDI_GetObjPtr.
722 * The new pointer must be released with GDI_ReleaseObj.
724 void *GDI_ReallocObject( WORD size
, HGDIOBJ handle
, void *object
)
728 assert( handle
& 2 ); /* no realloc for large handles */
729 LOCAL_Unlock( GDI_HeapSel
, handle
);
730 if (!(new_handle
= LOCAL_ReAlloc( GDI_HeapSel
, handle
, size
, LMEM_MOVEABLE
)))
732 TRACE_SEC( handle
, "leave" );
733 _LeaveSysLevel( &GDI_level
);
736 assert( new_handle
== handle
); /* moveable handle cannot change */
737 return LOCAL_Lock( GDI_HeapSel
, handle
);
741 /***********************************************************************
744 BOOL
GDI_FreeObject( HGDIOBJ handle
, void *ptr
)
746 GDIOBJHDR
*object
= ptr
;
748 object
->wMagic
= 0; /* Mark it as invalid */
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
= (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
);
770 /***********************************************************************
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
);
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
);
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
;
809 _LeaveSysLevel( &GDI_level
);
810 SetLastError( ERROR_INVALID_HANDLE
);
811 WARN( "Invalid handle %x\n", handle
);
813 else TRACE_SEC( handle
, "enter" );
819 /***********************************************************************
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 /***********************************************************************
834 void GDI_CheckNotLock(void)
836 _CheckNotSysLevel( &GDI_level
);
840 /***********************************************************************
844 static BOOL
FONT_DeleteObject(HGDIOBJ hfont
, FONTOBJ
*fontobj
)
846 WineEngDestroyFontInstance( hfont
);
847 return GDI_FreeObject( hfont
, fontobj
);
851 /***********************************************************************
852 * DeleteObject (GDI.69)
853 * SysDeleteObject (GDI.605)
855 BOOL16 WINAPI
DeleteObject16( HGDIOBJ16 obj
)
857 return DeleteObject( obj
);
861 /***********************************************************************
862 * DeleteObject (GDI32.@)
864 BOOL WINAPI
DeleteObject( HGDIOBJ obj
)
866 /* Check if object is valid */
869 if (HIWORD(obj
)) return FALSE
;
871 if (!(header
= GDI_GetObjPtr( obj
, MAGIC_DONTCARE
))) return FALSE
;
873 if (!(header
->wMagic
& OBJECT_NOSYSTEM
)
874 && (header
->wMagic
>= FIRST_MAGIC
) && (header
->wMagic
<= LAST_MAGIC
))
876 TRACE("Preserving system object %04x\n", obj
);
877 GDI_ReleaseObj( obj
);
883 TRACE("delayed for %04x because object in use, count %ld\n", obj
, header
->dwCount
);
884 header
->dwCount
|= 0x80000000; /* mark for delete */
885 GDI_ReleaseObj( obj
);
889 TRACE("%04x\n", obj
);
893 switch(GDIMAGIC(header
->wMagic
))
895 case PEN_MAGIC
: return GDI_FreeObject( obj
, header
);
896 case BRUSH_MAGIC
: return BRUSH_DeleteObject( obj
, (BRUSHOBJ
*)header
);
897 case FONT_MAGIC
: return FONT_DeleteObject( obj
, (FONTOBJ
*)header
);
898 case PALETTE_MAGIC
: return PALETTE_DeleteObject(obj
,(PALETTEOBJ
*)header
);
899 case BITMAP_MAGIC
: return BITMAP_DeleteObject( obj
, (BITMAPOBJ
*)header
);
900 case REGION_MAGIC
: return REGION_DeleteObject( obj
, (RGNOBJ
*)header
);
902 GDI_ReleaseObj( obj
);
903 return DeleteDC(obj
);
905 WARN("Already deleted\n");
908 WARN("Unknown magic number (%04x)\n",GDIMAGIC(header
->wMagic
));
910 GDI_ReleaseObj( obj
);
914 /***********************************************************************
915 * GetStockObject (GDI.87)
917 HGDIOBJ16 WINAPI
GetStockObject16( INT16 obj
)
919 return (HGDIOBJ16
)GetStockObject( obj
);
923 /***********************************************************************
924 * GetStockObject (GDI32.@)
926 HGDIOBJ WINAPI
GetStockObject( INT obj
)
929 if ((obj
< 0) || (obj
>= NB_STOCK_OBJECTS
)) return 0;
930 ret
= stock_objects
[obj
];
931 TRACE("returning %4x\n", ret
);
936 /***********************************************************************
939 INT16 WINAPI
GetObject16( HANDLE16 handle
, INT16 count
, LPVOID buffer
)
943 TRACE("%04x %d %p\n", handle
, count
, buffer
);
944 if (!count
) return 0;
946 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
948 switch(GDIMAGIC(ptr
->wMagic
))
951 result
= PEN_GetObject16( (PENOBJ
*)ptr
, count
, buffer
);
954 result
= BRUSH_GetObject16( (BRUSHOBJ
*)ptr
, count
, buffer
);
957 result
= BITMAP_GetObject16( (BITMAPOBJ
*)ptr
, count
, buffer
);
960 result
= FONT_GetObject16( (FONTOBJ
*)ptr
, count
, buffer
);
963 result
= PALETTE_GetObject( (PALETTEOBJ
*)ptr
, count
, buffer
);
966 GDI_ReleaseObj( handle
);
971 /***********************************************************************
972 * GetObjectA (GDI32.@)
974 INT WINAPI
GetObjectA( HANDLE handle
, INT count
, LPVOID buffer
)
978 TRACE("%08x %d %p\n", handle
, count
, buffer
);
979 if (!count
) return 0;
981 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
983 switch(GDIMAGIC(ptr
->wMagic
))
986 result
= PEN_GetObject( (PENOBJ
*)ptr
, count
, buffer
);
989 result
= BRUSH_GetObject( (BRUSHOBJ
*)ptr
, count
, buffer
);
992 result
= BITMAP_GetObject( (BITMAPOBJ
*)ptr
, count
, buffer
);
995 result
= FONT_GetObjectA( (FONTOBJ
*)ptr
, count
, buffer
);
998 result
= PALETTE_GetObject( (PALETTEOBJ
*)ptr
, count
, buffer
);
1003 case DISABLED_DC_MAGIC
:
1005 case METAFILE_MAGIC
:
1006 case METAFILE_DC_MAGIC
:
1007 case ENHMETAFILE_MAGIC
:
1008 case ENHMETAFILE_DC_MAGIC
:
1009 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr
->wMagic
) );
1013 ERR("Invalid GDI Magic %04x\n", GDIMAGIC(ptr
->wMagic
));
1016 GDI_ReleaseObj( handle
);
1020 /***********************************************************************
1021 * GetObjectW (GDI32.@)
1023 INT WINAPI
GetObjectW( HANDLE handle
, INT count
, LPVOID buffer
)
1027 TRACE("%08x %d %p\n", handle
, count
, buffer
);
1028 if (!count
) return 0;
1030 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
1032 switch(GDIMAGIC(ptr
->wMagic
))
1035 result
= PEN_GetObject( (PENOBJ
*)ptr
, count
, buffer
);
1038 result
= BRUSH_GetObject( (BRUSHOBJ
*)ptr
, count
, buffer
);
1041 result
= BITMAP_GetObject( (BITMAPOBJ
*)ptr
, count
, buffer
);
1044 result
= FONT_GetObjectW( (FONTOBJ
*)ptr
, count
, buffer
);
1047 result
= PALETTE_GetObject( (PALETTEOBJ
*)ptr
, count
, buffer
);
1050 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr
->wMagic
) );
1053 GDI_ReleaseObj( handle
);
1057 /***********************************************************************
1058 * GetObjectType (GDI32.@)
1060 DWORD WINAPI
GetObjectType( HANDLE handle
)
1064 TRACE("%08x\n", handle
);
1066 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
1068 switch(GDIMAGIC(ptr
->wMagic
))
1077 result
= OBJ_BITMAP
;
1086 result
= OBJ_REGION
;
1092 result
= OBJ_METADC
;
1094 case METAFILE_MAGIC
:
1095 result
= OBJ_METAFILE
;
1097 case METAFILE_DC_MAGIC
:
1098 result
= OBJ_METADC
;
1100 case ENHMETAFILE_MAGIC
:
1101 result
= OBJ_ENHMETAFILE
;
1103 case ENHMETAFILE_DC_MAGIC
:
1104 result
= OBJ_ENHMETADC
;
1107 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr
->wMagic
) );
1110 GDI_ReleaseObj( handle
);
1114 /***********************************************************************
1115 * GetCurrentObject (GDI32.@)
1117 HANDLE WINAPI
GetCurrentObject(HDC hdc
,UINT type
)
1120 DC
* dc
= DC_GetDCPtr( hdc
);
1125 case OBJ_PEN
: ret
= dc
->hPen
; break;
1126 case OBJ_BRUSH
: ret
= dc
->hBrush
; break;
1127 case OBJ_PAL
: ret
= dc
->hPalette
; break;
1128 case OBJ_FONT
: ret
= dc
->hFont
; break;
1129 case OBJ_BITMAP
: ret
= dc
->hBitmap
; break;
1131 /* the SDK only mentions those above */
1132 FIXME("(%08x,%d): unknown type.\n",hdc
,type
);
1135 GDI_ReleaseObj( hdc
);
1139 /***********************************************************************
1142 * If the driver supports vector fonts we create a gdi font first and
1143 * then call the driver to give it a chance to supply its own device
1144 * font. If the driver wants to do this it returns TRUE and we can
1145 * delete the gdi font, if the driver wants to use the gdi font it
1146 * should return FALSE, to signal an error return GDI_ERROR. For
1147 * drivers that don't support vector fonts they must supply their own
1150 static HGDIOBJ
FONT_SelectObject(DC
*dc
, HGDIOBJ hFont
)
1152 HGDIOBJ ret
= FALSE
;
1154 if(dc
->hFont
!= hFont
|| dc
->gdiFont
== NULL
) {
1155 if(GetDeviceCaps(dc
->hSelf
, TEXTCAPS
) & TC_VA_ABLE
)
1156 dc
->gdiFont
= WineEngCreateFontInstance(dc
, hFont
);
1159 if(dc
->funcs
->pSelectFont
)
1160 ret
= dc
->funcs
->pSelectFont(dc
->physDev
, hFont
);
1162 if(ret
&& dc
->gdiFont
) {
1166 if(ret
== GDI_ERROR
)
1167 ret
= FALSE
; /* SelectObject returns FALSE on error */
1177 /***********************************************************************
1180 static HGDIOBJ
select_bitmap( DC
*dc
, HBITMAP handle
)
1183 HGDIOBJ ret
= handle
;
1185 if (!(dc
->flags
& DC_MEMORY
)) return 0;
1186 if (handle
== dc
->hBitmap
) return handle
; /* nothing to do */
1187 if (!(bitmap
= GDI_GetObjPtr( handle
, BITMAP_MAGIC
))) return 0;
1189 if (bitmap
->header
.dwCount
&& (handle
!= GetStockObject(DEFAULT_BITMAP
)))
1191 WARN( "Bitmap already selected in another DC\n" );
1192 GDI_ReleaseObj( handle
);
1196 if (dc
->funcs
->pSelectBitmap
) ret
= dc
->funcs
->pSelectBitmap( dc
->physDev
, handle
);
1201 dc
->totalExtent
.left
= 0;
1202 dc
->totalExtent
.top
= 0;
1203 dc
->totalExtent
.right
= bitmap
->bitmap
.bmWidth
;
1204 dc
->totalExtent
.bottom
= bitmap
->bitmap
.bmHeight
;
1205 dc
->flags
&= ~DC_DIRTY
;
1206 SetRectRgn( dc
->hVisRgn
, 0, 0, bitmap
->bitmap
.bmWidth
, bitmap
->bitmap
.bmHeight
);
1207 CLIPPING_UpdateGCRegion( dc
);
1209 if (dc
->bitsPerPixel
!= bitmap
->bitmap
.bmBitsPixel
)
1211 /* depth changed, reinitialize the DC */
1212 dc
->bitsPerPixel
= bitmap
->bitmap
.bmBitsPixel
;
1216 GDI_ReleaseObj( handle
);
1221 /***********************************************************************
1222 * SelectObject (GDI.45)
1224 HGDIOBJ16 WINAPI
SelectObject16( HDC16 hdc
, HGDIOBJ16 handle
)
1226 return (HGDIOBJ16
)SelectObject( hdc
, handle
);
1230 /***********************************************************************
1231 * SelectObject (GDI32.@)
1233 HGDIOBJ WINAPI
SelectObject( HDC hdc
, HGDIOBJ handle
)
1236 DC
* dc
= DC_GetDCPtr( hdc
);
1238 TRACE("hdc=%04x %04x\n", hdc
, handle
);
1240 /* Fonts get a rather different treatment so we'll handle them
1242 switch(GetObjectType( handle
))
1246 handle
= select_bitmap( dc
, handle
);
1247 if (!handle
) ret
= 0;
1251 if (dc
->funcs
->pSelectBrush
) handle
= dc
->funcs
->pSelectBrush( dc
->physDev
, handle
);
1252 if (handle
) dc
->hBrush
= handle
;
1257 if (dc
->funcs
->pSelectPen
) handle
= dc
->funcs
->pSelectPen( dc
->physDev
, handle
);
1258 if (handle
) dc
->hPen
= handle
;
1262 ret
= FONT_SelectObject(dc
, handle
);
1265 GDI_ReleaseObj( hdc
);
1266 return (HGDIOBJ
)SelectClipRgn( hdc
, handle
);
1268 GDI_ReleaseObj( hdc
);
1270 if (ret
&& ret
!= handle
)
1272 inc_ref_count( handle
);
1273 dec_ref_count( ret
);
1279 /***********************************************************************
1280 * UnrealizeObject (GDI.150)
1282 BOOL16 WINAPI
UnrealizeObject16( HGDIOBJ16 obj
)
1284 return UnrealizeObject( obj
);
1288 /***********************************************************************
1289 * UnrealizeObject (GDI32.@)
1291 BOOL WINAPI
UnrealizeObject( HGDIOBJ obj
)
1294 /* Check if object is valid */
1296 GDIOBJHDR
* header
= GDI_GetObjPtr( obj
, MAGIC_DONTCARE
);
1297 if (!header
) return FALSE
;
1299 TRACE("%04x\n", obj
);
1301 /* Unrealize object */
1303 switch(GDIMAGIC(header
->wMagic
))
1306 result
= PALETTE_UnrealizeObject( obj
, (PALETTEOBJ
*)header
);
1310 /* Windows resets the brush origin. We don't need to. */
1313 GDI_ReleaseObj( obj
);
1318 /* Solid colors to enumerate */
1319 static const COLORREF solid_colors
[] =
1320 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1321 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1322 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1323 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1324 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1325 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1326 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1327 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1330 /***********************************************************************
1331 * EnumObjects (GDI.71)
1333 INT16 WINAPI
EnumObjects16( HDC16 hdc
, INT16 nObjType
,
1334 GOBJENUMPROC16 lpEnumFunc
, LPARAM lParam
)
1336 INT16 i
, retval
= 0;
1341 TRACE("%04x %d %08lx %08lx\n",
1342 hdc
, nObjType
, (DWORD
)lpEnumFunc
, lParam
);
1346 /* Enumerate solid pens */
1347 segptr
= MapLS( &pen
);
1348 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1350 pen
.lopnStyle
= PS_SOLID
;
1351 pen
.lopnWidth
.x
= 1;
1352 pen
.lopnWidth
.y
= 0;
1353 pen
.lopnColor
= solid_colors
[i
];
1354 retval
= GDI_CallTo16_word_ll( lpEnumFunc
, segptr
, lParam
);
1355 TRACE("solid pen %08lx, ret=%d\n", solid_colors
[i
], retval
);
1362 /* Enumerate solid brushes */
1363 segptr
= MapLS( &brush
);
1364 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1366 brush
.lbStyle
= BS_SOLID
;
1367 brush
.lbColor
= solid_colors
[i
];
1369 retval
= GDI_CallTo16_word_ll( lpEnumFunc
, segptr
, lParam
);
1370 TRACE("solid brush %08lx, ret=%d\n", solid_colors
[i
], retval
);
1374 /* Now enumerate hatched brushes */
1375 if (retval
) for (i
= HS_HORIZONTAL
; i
<= HS_DIAGCROSS
; i
++)
1377 brush
.lbStyle
= BS_HATCHED
;
1378 brush
.lbColor
= RGB(0,0,0);
1380 retval
= GDI_CallTo16_word_ll( lpEnumFunc
, segptr
, lParam
);
1381 TRACE("hatched brush %d, ret=%d\n", i
, retval
);
1388 WARN("(%d): Invalid type\n", nObjType
);
1395 /***********************************************************************
1396 * EnumObjects (GDI32.@)
1398 INT WINAPI
EnumObjects( HDC hdc
, INT nObjType
,
1399 GOBJENUMPROC lpEnumFunc
, LPARAM lParam
)
1405 TRACE("%04x %d %08lx %08lx\n",
1406 hdc
, nObjType
, (DWORD
)lpEnumFunc
, lParam
);
1410 /* Enumerate solid pens */
1411 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1413 pen
.lopnStyle
= PS_SOLID
;
1414 pen
.lopnWidth
.x
= 1;
1415 pen
.lopnWidth
.y
= 0;
1416 pen
.lopnColor
= solid_colors
[i
];
1417 retval
= lpEnumFunc( &pen
, lParam
);
1418 TRACE("solid pen %08lx, ret=%d\n",
1419 solid_colors
[i
], retval
);
1425 /* Enumerate solid brushes */
1426 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1428 brush
.lbStyle
= BS_SOLID
;
1429 brush
.lbColor
= solid_colors
[i
];
1431 retval
= lpEnumFunc( &brush
, lParam
);
1432 TRACE("solid brush %08lx, ret=%d\n",
1433 solid_colors
[i
], retval
);
1437 /* Now enumerate hatched brushes */
1438 if (retval
) for (i
= HS_HORIZONTAL
; i
<= HS_DIAGCROSS
; i
++)
1440 brush
.lbStyle
= BS_HATCHED
;
1441 brush
.lbColor
= RGB(0,0,0);
1443 retval
= lpEnumFunc( &brush
, lParam
);
1444 TRACE("hatched brush %d, ret=%d\n",
1451 /* FIXME: implement Win32 types */
1452 WARN("(%d): Invalid type\n", nObjType
);
1459 /***********************************************************************
1460 * IsGDIObject (GDI.462)
1462 * returns type of object if valid (W95 system programming secrets p. 264-5)
1464 BOOL16 WINAPI
IsGDIObject16( HGDIOBJ16 handle
)
1468 GDIOBJHDR
*object
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
);
1471 magic
= GDIMAGIC(object
->wMagic
) - PEN_MAGIC
+ 1;
1472 GDI_ReleaseObj( handle
);
1478 /***********************************************************************
1479 * SetObjectOwner (GDI.461)
1481 void WINAPI
SetObjectOwner16( HGDIOBJ16 handle
, HANDLE16 owner
)
1487 /***********************************************************************
1488 * SetObjectOwner (GDI32.@)
1490 void WINAPI
SetObjectOwner( HGDIOBJ handle
, HANDLE owner
)
1496 /***********************************************************************
1497 * MakeObjectPrivate (GDI.463)
1499 * What does that mean ?
1500 * Some little docu can be found in "Undocumented Windows",
1501 * but this is basically useless.
1502 * At least we know that this flags the GDI object's wMagic
1503 * with 0x2000 (OBJECT_PRIVATE), so we just do it.
1504 * But Wine doesn't react on that yet.
1506 void WINAPI
MakeObjectPrivate16( HGDIOBJ16 handle
, BOOL16
private )
1508 GDIOBJHDR
*ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
);
1511 ERR("invalid GDI object %04x !\n", handle
);
1514 ptr
->wMagic
|= OBJECT_PRIVATE
;
1515 GDI_ReleaseObj( handle
);
1519 /***********************************************************************
1520 * GdiFlush (GDI32.@)
1522 BOOL WINAPI
GdiFlush(void)
1524 return TRUE
; /* FIXME */
1528 /***********************************************************************
1529 * GdiGetBatchLimit (GDI32.@)
1531 DWORD WINAPI
GdiGetBatchLimit(void)
1533 return 1; /* FIXME */
1537 /***********************************************************************
1538 * GdiSetBatchLimit (GDI32.@)
1540 DWORD WINAPI
GdiSetBatchLimit( DWORD limit
)
1542 return 1; /* FIXME */
1546 /***********************************************************************
1547 * GdiSeeGdiDo (GDI.452)
1549 DWORD WINAPI
GdiSeeGdiDo16( WORD wReqType
, WORD wParam1
, WORD wParam2
,
1554 case 0x0001: /* LocalAlloc */
1555 return LOCAL_Alloc( GDI_HeapSel
, wParam1
, wParam3
);
1556 case 0x0002: /* LocalFree */
1557 return LOCAL_Free( GDI_HeapSel
, wParam1
);
1558 case 0x0003: /* LocalCompact */
1559 return LOCAL_Compact( GDI_HeapSel
, wParam3
, 0 );
1560 case 0x0103: /* LocalHeap */
1563 WARN("(wReqType=%04x): Unknown\n", wReqType
);
1568 /***********************************************************************
1569 * GdiSignalProc32 (GDI.610)
1571 WORD WINAPI
GdiSignalProc( UINT uCode
, DWORD dwThreadOrProcessID
,
1572 DWORD dwFlags
, HMODULE16 hModule
)
1577 /***********************************************************************
1578 * GdiInit2 (GDI.403)
1580 * See "Undocumented Windows"
1582 HANDLE16 WINAPI
GdiInit216(
1583 HANDLE16 h1
, /* [in] GDI object */
1584 HANDLE16 h2
/* [in] global data */
1587 FIXME("(%04x, %04x), stub.\n", h1
, h2
);
1589 return 0xffff; /* undefined return value */
1590 return h1
; /* FIXME: should be the memory handle of h1 */
1593 /***********************************************************************
1594 * FinalGdiInit (GDI.405)
1596 void WINAPI
FinalGdiInit16( HBRUSH16 hPattern
/* [in] fill pattern of desktop */ )
1600 /***********************************************************************
1601 * GdiFreeResources (GDI.609)
1603 WORD WINAPI
GdiFreeResources16( DWORD reserve
)
1605 return (WORD
)( (int)LOCAL_CountFree( GDI_HeapSel
) * 100 /
1606 (int)LOCAL_HeapSize( GDI_HeapSel
) );
1609 /***********************************************************************
1612 INT16 WINAPI
MulDiv16(
1613 INT16 nMultiplicand
,
1618 if (!nDivisor
) return -32768;
1619 /* We want to deal with a positive divisor to simplify the logic. */
1622 nMultiplicand
= - nMultiplicand
;
1623 nDivisor
= -nDivisor
;
1625 /* If the result is positive, we "add" to round. else,
1626 * we subtract to round. */
1627 if ( ( (nMultiplicand
< 0) && (nMultiplier
< 0) ) ||
1628 ( (nMultiplicand
>= 0) && (nMultiplier
>= 0) ) )
1629 ret
= (((int)nMultiplicand
* nMultiplier
) + (nDivisor
/2)) / nDivisor
;
1631 ret
= (((int)nMultiplicand
* nMultiplier
) - (nDivisor
/2)) / nDivisor
;
1632 if ((ret
> 32767) || (ret
< -32767)) return -32768;
1637 /*******************************************************************
1638 * GetColorAdjustment [GDI32.@]
1642 BOOL WINAPI
GetColorAdjustment(HDC hdc
, LPCOLORADJUSTMENT lpca
)
1644 FIXME("GetColorAdjustment, stub\n");
1648 /*******************************************************************
1649 * GetMiterLimit [GDI32.@]
1653 BOOL WINAPI
GetMiterLimit(HDC hdc
, PFLOAT peLimit
)
1655 FIXME("GetMiterLimit, stub\n");
1659 /*******************************************************************
1660 * SetMiterLimit [GDI32.@]
1664 BOOL WINAPI
SetMiterLimit(HDC hdc
, FLOAT eNewLimit
, PFLOAT peOldLimit
)
1666 FIXME("SetMiterLimit, stub\n");
1670 /*******************************************************************
1671 * GdiComment [GDI32.@]
1675 BOOL WINAPI
GdiComment(HDC hdc
, UINT cbSize
, const BYTE
*lpData
)
1677 FIXME("GdiComment, stub\n");
1680 /*******************************************************************
1681 * SetColorAdjustment [GDI32.@]
1685 BOOL WINAPI
SetColorAdjustment(HDC hdc
, const COLORADJUSTMENT
* lpca
)
1687 FIXME("SetColorAdjustment, stub\n");