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"
37 #include "wine/debug.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 /***********************************************************************
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' ||
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
125 LOGFONTW DeviceDefaultFont
;
126 LOGFONTW SystemFixedFont
;
127 LOGFONTW DefaultGuiFont
;
130 static const struct DefaultFontInfo default_fonts
[] =
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
,
144 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ANSI_CHARSET
,
145 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
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
,
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
,
166 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, EASTEUROPE_CHARSET
,
167 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
170 { /* DefaultGuiFont */
171 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, EASTEUROPE_CHARSET
,
172 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
173 {'\0'} /* FIXME - what is the native font??? */
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
,
188 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, RUSSIAN_CHARSET
,
189 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
192 { /* DefaultGuiFont */
193 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, RUSSIAN_CHARSET
,
194 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
195 {'\0'} /* FIXME - what is the native font??? */
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
,
210 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GREEK_CHARSET
,
211 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
214 { /* DefaultGuiFont */
215 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GREEK_CHARSET
,
216 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
217 {'\0'} /* FIXME - what is the native font??? */
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
,
232 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, TURKISH_CHARSET
,
233 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
236 { /* DefaultGuiFont */
237 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, TURKISH_CHARSET
,
238 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
239 {'\0'} /* FIXME - what is the native font??? */
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
,
254 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HEBREW_CHARSET
,
255 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
258 { /* DefaultGuiFont */
259 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HEBREW_CHARSET
,
260 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
261 {'\0'} /* FIXME - what is the native font??? */
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
,
276 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ARABIC_CHARSET
,
277 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
280 { /* DefaultGuiFont */
281 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, ARABIC_CHARSET
,
282 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
283 {'\0'} /* FIXME - what is the native font??? */
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
,
298 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, BALTIC_CHARSET
,
299 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
302 { /* DefaultGuiFont */
303 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, BALTIC_CHARSET
,
304 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
305 {'\0'} /* FIXME - what is the native font??? */
311 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
312 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
313 {'S','y','s','t','e','m','\0'}
315 { /* Device Default */
316 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
317 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
321 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
322 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
325 { /* DefaultGuiFont */
326 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, THAI_CHARSET
,
327 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
328 {'\0'} /* FIXME - what is the native font??? */
333 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
334 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
335 {'S','y','s','t','e','m','\0'}
337 { /* Device Default */
338 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
339 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
343 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
344 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
347 { /* DefaultGuiFont */
348 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, SHIFTJIS_CHARSET
,
349 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
350 {'\0'} /* FIXME - mbtowc of native ("MS P gothic") */
355 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
356 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
357 {'S','y','s','t','e','m','\0'}
359 { /* Device Default */
360 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
361 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
365 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
366 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
369 { /* DefaultGuiFont */
370 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, GB2312_CHARSET
,
371 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
372 {'M','S',' ','S','o','n','g','\0'} /* FIXME: Is this correct? */
377 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
378 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
379 {'S','y','s','t','e','m','\0'}
381 { /* Device Default */
382 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
383 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
387 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
388 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
391 { /* DefaultGuiFont */
392 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, HANGEUL_CHARSET
,
393 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
394 {'G','u','l','i','m','C','h','e'}, /* FIXME: Is this correct? */
397 { CHINESEBIG5_CHARSET
,
399 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
400 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
401 {'S','y','s','t','e','m','\0'}
403 { /* Device Default */
404 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
405 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
409 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
410 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
413 { /* DefaultGuiFont */
414 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, CHINESEBIG5_CHARSET
,
415 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
416 {'\0'} /* FIXME - what is the native font??? */
421 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
422 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
423 {'S','y','s','t','e','m','\0'}
425 { /* Device Default */
426 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
427 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
431 16, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
432 0, 0, DEFAULT_QUALITY
, FIXED_PITCH
| FF_MODERN
,
435 { /* DefaultGuiFont */
436 -11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
, FALSE
, JOHAB_CHARSET
,
437 0, 0, DEFAULT_QUALITY
, VARIABLE_PITCH
| FF_SWISS
,
438 {'\0'} /* FIXME - what is the native font??? mbtowc of native ("MS Mingliu")??? */
444 /******************************************************************************
447 static const struct DefaultFontInfo
* get_default_fonts(UINT charset
)
451 for(n
=0;n
<(sizeof(default_fonts
)/sizeof(default_fonts
[0]));n
++)
453 if ( default_fonts
[n
].charset
== charset
)
454 return &default_fonts
[n
];
457 FIXME( "unhandled charset 0x%08x - use ANSI_CHARSET for default stock objects\n", charset
);
458 return &default_fonts
[0];
462 /******************************************************************************
463 * get_default_charset (internal)
465 * get the language-dependent charset that can handle CP_ACP correctly.
467 static UINT
get_default_charset( void )
473 csi
.ciCharset
= ANSI_CHARSET
;
474 if ( ! TranslateCharsetInfo( (LPDWORD
)uACP
, &csi
, TCI_SRCCODEPAGE
) )
476 FIXME( "unhandled codepage %u - use ANSI_CHARSET for default stock objects\n", uACP
);
480 return csi
.ciCharset
;
484 /******************************************************************************
487 static HFONT
create_stock_font( char const *fontName
, const LOGFONTW
*font
, HKEY hkey
)
491 char buffer
[MAX_PATH
];
494 if (!hkey
) return CreateFontIndirectW( font
);
497 sprintf(key
, "%s.Height", fontName
);
498 count
= sizeof(buffer
);
499 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
500 lf
.lfHeight
= atoi(buffer
);
502 sprintf(key
, "%s.Bold", fontName
);
503 count
= sizeof(buffer
);
504 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
505 lf
.lfWeight
= get_bool(buffer
) ? FW_BOLD
: FW_NORMAL
;
507 sprintf(key
, "%s.Italic", fontName
);
508 count
= sizeof(buffer
);
509 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
510 lf
.lfItalic
= get_bool(buffer
);
512 sprintf(key
, "%s.Underline", fontName
);
513 count
= sizeof(buffer
);
514 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
515 lf
.lfUnderline
= get_bool(buffer
);
517 sprintf(key
, "%s.StrikeOut", fontName
);
518 count
= sizeof(buffer
);
519 if(!RegQueryValueExA(hkey
, key
, 0, &type
, buffer
, &count
))
520 lf
.lfStrikeOut
= get_bool(buffer
);
521 return CreateFontIndirectW( &lf
);
525 #define TRACE_SEC(handle,text) \
526 TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount)
529 /***********************************************************************
532 * Increment the reference count of a GDI object.
534 inline static void inc_ref_count( HGDIOBJ handle
)
538 if ((header
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
)))
541 GDI_ReleaseObj( handle
);
546 /***********************************************************************
549 * Decrement the reference count of a GDI object.
551 inline static void dec_ref_count( HGDIOBJ handle
)
555 if ((header
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
)))
557 if (header
->dwCount
) header
->dwCount
--;
558 if (header
->dwCount
!= 0x80000000) GDI_ReleaseObj( handle
);
561 /* handle delayed DeleteObject*/
563 GDI_ReleaseObj( handle
);
564 TRACE( "executing delayed DeleteObject for %04x\n", handle
);
565 DeleteObject( handle
);
571 /***********************************************************************
574 * GDI initialization.
578 HINSTANCE16 instance
;
581 const struct DefaultFontInfo
* deffonts
;
584 if (RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Software\\Wine\\Wine\\Config\\Tweak.Fonts", &hkey
))
587 /* create GDI heap */
588 if ((instance
= LoadLibrary16( "GDI.EXE" )) < 32) return FALSE
;
589 GDI_HeapSel
= instance
| 7;
591 /* create stock objects */
592 stock_objects
[WHITE_BRUSH
] = CreateBrushIndirect( &WhiteBrush
);
593 stock_objects
[LTGRAY_BRUSH
] = CreateBrushIndirect( &LtGrayBrush
);
594 stock_objects
[GRAY_BRUSH
] = CreateBrushIndirect( &GrayBrush
);
595 stock_objects
[DKGRAY_BRUSH
] = CreateBrushIndirect( &DkGrayBrush
);
596 stock_objects
[BLACK_BRUSH
] = CreateBrushIndirect( &BlackBrush
);
597 stock_objects
[NULL_BRUSH
] = CreateBrushIndirect( &NullBrush
);
599 stock_objects
[WHITE_PEN
] = CreatePenIndirect( &WhitePen
);
600 stock_objects
[BLACK_PEN
] = CreatePenIndirect( &BlackPen
);
601 stock_objects
[NULL_PEN
] = CreatePenIndirect( &NullPen
);
603 stock_objects
[DEFAULT_PALETTE
] = PALETTE_Init();
604 stock_objects
[DEFAULT_BITMAP
] = CreateBitmap( 1, 1, 1, 1, NULL
);
606 /* language-independent stock fonts */
607 stock_objects
[OEM_FIXED_FONT
] = create_stock_font( "OEMFixed", &OEMFixedFont
, hkey
);
608 stock_objects
[ANSI_FIXED_FONT
] = create_stock_font( "AnsiFixed", &AnsiFixedFont
, hkey
);
609 stock_objects
[ANSI_VAR_FONT
] = create_stock_font( "AnsiVar", &AnsiVarFont
, hkey
);
611 /* language-dependent stock fonts */
612 deffonts
= get_default_fonts(get_default_charset());
613 stock_objects
[SYSTEM_FONT
] = create_stock_font( "System", &deffonts
->SystemFont
, hkey
);
614 stock_objects
[DEVICE_DEFAULT_FONT
] = create_stock_font( "DeviceDefault", &deffonts
->DeviceDefaultFont
, hkey
);
615 stock_objects
[SYSTEM_FIXED_FONT
] = create_stock_font( "SystemFixed", &deffonts
->SystemFixedFont
, hkey
);
616 stock_objects
[DEFAULT_GUI_FONT
] = create_stock_font( "DefaultGui", &deffonts
->DefaultGuiFont
, hkey
);
619 /* clear the NOSYSTEM bit on all stock objects*/
620 for (i
= 0; i
< NB_STOCK_OBJECTS
; i
++)
622 if (!stock_objects
[i
])
624 if (i
== 9) continue; /* there's no stock object 9 */
625 ERR( "could not create stock object %d\n", i
);
628 ptr
= GDI_GetObjPtr( stock_objects
[i
], MAGIC_DONTCARE
);
629 ptr
->wMagic
&= ~OBJECT_NOSYSTEM
;
630 GDI_ReleaseObj( stock_objects
[i
] );
633 if (hkey
) RegCloseKey( hkey
);
640 #define FIRST_LARGE_HANDLE 16
641 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
642 static GDIOBJHDR
*large_handles
[MAX_LARGE_HANDLES
];
643 static int next_large_handle
;
645 /***********************************************************************
648 * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject
650 inline static GDIOBJHDR
*alloc_large_heap( WORD size
, HGDIOBJ
*handle
)
655 for (i
= next_large_handle
+ 1; i
< MAX_LARGE_HANDLES
; i
++)
656 if (!large_handles
[i
]) goto found
;
657 for (i
= 0; i
<= next_large_handle
; i
++)
658 if (!large_handles
[i
]) goto found
;
663 if ((obj
= HeapAlloc( GetProcessHeap(), 0, size
)))
665 large_handles
[i
] = obj
;
666 *handle
= (i
+ FIRST_LARGE_HANDLE
) << 2;
667 next_large_handle
= i
;
673 /***********************************************************************
676 void *GDI_AllocObject( WORD size
, WORD magic
, HGDIOBJ
*handle
, const struct gdi_obj_funcs
*funcs
)
680 _EnterSysLevel( &GDI_level
);
683 /* allocate DCs on the larger heap */
685 case DISABLED_DC_MAGIC
:
688 case METAFILE_DC_MAGIC
:
689 case ENHMETAFILE_MAGIC
:
690 case ENHMETAFILE_DC_MAGIC
:
692 if (!(obj
= alloc_large_heap( size
, handle
))) goto error
;
695 if (!(*handle
= LOCAL_Alloc( GDI_HeapSel
, LMEM_MOVEABLE
, size
))) goto error
;
696 assert( *handle
& 2 );
697 obj
= (GDIOBJHDR
*)LOCAL_Lock( GDI_HeapSel
, *handle
);
702 obj
->wMagic
= magic
|OBJECT_NOSYSTEM
;
706 TRACE_SEC( *handle
, "enter" );
710 _LeaveSysLevel( &GDI_level
);
716 /***********************************************************************
719 * The object ptr must have been obtained with GDI_GetObjPtr.
720 * The new pointer must be released with GDI_ReleaseObj.
722 void *GDI_ReallocObject( WORD size
, HGDIOBJ handle
, void *object
)
726 assert( handle
& 2 ); /* no realloc for large handles */
727 LOCAL_Unlock( GDI_HeapSel
, handle
);
728 if (!(new_handle
= LOCAL_ReAlloc( GDI_HeapSel
, handle
, size
, LMEM_MOVEABLE
)))
730 TRACE_SEC( handle
, "leave" );
731 _LeaveSysLevel( &GDI_level
);
734 assert( new_handle
== handle
); /* moveable handle cannot change */
735 return LOCAL_Lock( GDI_HeapSel
, handle
);
739 /***********************************************************************
742 BOOL
GDI_FreeObject( HGDIOBJ handle
, void *ptr
)
744 GDIOBJHDR
*object
= ptr
;
746 object
->wMagic
= 0; /* Mark it as invalid */
747 object
->funcs
= NULL
;
748 if (handle
& 2) /* GDI heap handle */
750 LOCAL_Unlock( GDI_HeapSel
, handle
);
751 LOCAL_Free( GDI_HeapSel
, handle
);
753 else /* large heap handle */
755 int i
= (handle
>> 2) - FIRST_LARGE_HANDLE
;
756 if (i
>= 0 && i
< MAX_LARGE_HANDLES
&& large_handles
[i
])
758 HeapFree( GetProcessHeap(), 0, large_handles
[i
] );
759 large_handles
[i
] = NULL
;
761 else ERR( "Invalid handle %x\n", handle
);
763 TRACE_SEC( handle
, "leave" );
764 _LeaveSysLevel( &GDI_level
);
769 /***********************************************************************
772 * Return a pointer to the GDI object associated to the handle.
773 * Return NULL if the object has the wrong magic number.
774 * The object must be released with GDI_ReleaseObj.
776 void *GDI_GetObjPtr( HGDIOBJ handle
, WORD magic
)
778 GDIOBJHDR
*ptr
= NULL
;
780 _EnterSysLevel( &GDI_level
);
782 if (handle
& 2) /* GDI heap handle */
784 ptr
= (GDIOBJHDR
*)LOCAL_Lock( GDI_HeapSel
, handle
);
787 if (((magic
!= MAGIC_DONTCARE
) && (GDIMAGIC(ptr
->wMagic
) != magic
)) ||
788 (GDIMAGIC(ptr
->wMagic
) < FIRST_MAGIC
) ||
789 (GDIMAGIC(ptr
->wMagic
) > LAST_MAGIC
))
791 LOCAL_Unlock( GDI_HeapSel
, handle
);
796 else /* large heap handle */
798 int i
= (handle
>> 2) - FIRST_LARGE_HANDLE
;
799 if (i
>= 0 && i
< MAX_LARGE_HANDLES
)
801 ptr
= large_handles
[i
];
802 if (ptr
&& (magic
!= MAGIC_DONTCARE
) && (GDIMAGIC(ptr
->wMagic
) != magic
)) ptr
= NULL
;
808 _LeaveSysLevel( &GDI_level
);
809 SetLastError( ERROR_INVALID_HANDLE
);
810 WARN( "Invalid handle %x\n", handle
);
812 else TRACE_SEC( handle
, "enter" );
818 /***********************************************************************
822 void GDI_ReleaseObj( HGDIOBJ handle
)
824 if (handle
& 2) LOCAL_Unlock( GDI_HeapSel
, handle
);
825 TRACE_SEC( handle
, "leave" );
826 _LeaveSysLevel( &GDI_level
);
830 /***********************************************************************
833 void GDI_CheckNotLock(void)
835 _CheckNotSysLevel( &GDI_level
);
839 /***********************************************************************
840 * DeleteObject (GDI.69)
841 * SysDeleteObject (GDI.605)
843 BOOL16 WINAPI
DeleteObject16( HGDIOBJ16 obj
)
845 return DeleteObject( obj
);
849 /***********************************************************************
850 * DeleteObject (GDI32.@)
852 BOOL WINAPI
DeleteObject( HGDIOBJ obj
)
854 /* Check if object is valid */
857 if (HIWORD(obj
)) return FALSE
;
859 if (!(header
= GDI_GetObjPtr( obj
, MAGIC_DONTCARE
))) return FALSE
;
861 if (!(header
->wMagic
& OBJECT_NOSYSTEM
)
862 && (header
->wMagic
>= FIRST_MAGIC
) && (header
->wMagic
<= LAST_MAGIC
))
864 TRACE("Preserving system object %04x\n", obj
);
865 GDI_ReleaseObj( obj
);
871 TRACE("delayed for %04x because object in use, count %ld\n", obj
, header
->dwCount
);
872 header
->dwCount
|= 0x80000000; /* mark for delete */
873 GDI_ReleaseObj( obj
);
877 TRACE("%04x\n", obj
);
882 header
->funcs
->pDeleteObject
&&
883 header
->funcs
->pDeleteObject( obj
, header
))
886 GDI_ReleaseObj( obj
);
890 /***********************************************************************
891 * GetStockObject (GDI.87)
893 HGDIOBJ16 WINAPI
GetStockObject16( INT16 obj
)
895 return (HGDIOBJ16
)GetStockObject( obj
);
899 /***********************************************************************
900 * GetStockObject (GDI32.@)
902 HGDIOBJ WINAPI
GetStockObject( INT obj
)
905 if ((obj
< 0) || (obj
>= NB_STOCK_OBJECTS
)) return 0;
906 ret
= stock_objects
[obj
];
907 TRACE("returning %4x\n", ret
);
912 /***********************************************************************
915 INT16 WINAPI
GetObject16( HANDLE16 handle
, INT16 count
, LPVOID buffer
)
919 TRACE("%04x %d %p\n", handle
, count
, buffer
);
920 if (!count
) return 0;
922 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
924 if (ptr
->funcs
&& ptr
->funcs
->pGetObject16
)
925 result
= ptr
->funcs
->pGetObject16( handle
, ptr
, count
, buffer
);
927 SetLastError( ERROR_INVALID_HANDLE
);
929 GDI_ReleaseObj( handle
);
934 /***********************************************************************
935 * GetObjectA (GDI32.@)
937 INT WINAPI
GetObjectA( HANDLE handle
, INT count
, LPVOID buffer
)
941 TRACE("%08x %d %p\n", handle
, count
, buffer
);
942 if (!count
) return 0;
944 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
946 if (ptr
->funcs
&& ptr
->funcs
->pGetObjectA
)
947 result
= ptr
->funcs
->pGetObjectA( handle
, ptr
, count
, buffer
);
949 SetLastError( ERROR_INVALID_HANDLE
);
951 GDI_ReleaseObj( handle
);
955 /***********************************************************************
956 * GetObjectW (GDI32.@)
958 INT WINAPI
GetObjectW( HANDLE handle
, INT count
, LPVOID buffer
)
962 TRACE("%08x %d %p\n", handle
, count
, buffer
);
963 if (!count
) return 0;
965 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
967 if (ptr
->funcs
&& ptr
->funcs
->pGetObjectW
)
968 result
= ptr
->funcs
->pGetObjectW( handle
, ptr
, count
, buffer
);
970 SetLastError( ERROR_INVALID_HANDLE
);
972 GDI_ReleaseObj( handle
);
976 /***********************************************************************
977 * GetObjectType (GDI32.@)
979 DWORD WINAPI
GetObjectType( HANDLE handle
)
983 TRACE("%08x\n", handle
);
985 if (!(ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
))) return 0;
987 switch(GDIMAGIC(ptr
->wMagic
))
1005 result
= OBJ_REGION
;
1011 result
= OBJ_METADC
;
1013 case METAFILE_MAGIC
:
1014 result
= OBJ_METAFILE
;
1016 case METAFILE_DC_MAGIC
:
1017 result
= OBJ_METADC
;
1019 case ENHMETAFILE_MAGIC
:
1020 result
= OBJ_ENHMETAFILE
;
1022 case ENHMETAFILE_DC_MAGIC
:
1023 result
= OBJ_ENHMETADC
;
1026 FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr
->wMagic
) );
1029 GDI_ReleaseObj( handle
);
1033 /***********************************************************************
1034 * GetCurrentObject (GDI32.@)
1036 HANDLE WINAPI
GetCurrentObject(HDC hdc
,UINT type
)
1039 DC
* dc
= DC_GetDCPtr( hdc
);
1044 case OBJ_PEN
: ret
= dc
->hPen
; break;
1045 case OBJ_BRUSH
: ret
= dc
->hBrush
; break;
1046 case OBJ_PAL
: ret
= dc
->hPalette
; break;
1047 case OBJ_FONT
: ret
= dc
->hFont
; break;
1048 case OBJ_BITMAP
: ret
= dc
->hBitmap
; break;
1050 /* the SDK only mentions those above */
1051 FIXME("(%08x,%d): unknown type.\n",hdc
,type
);
1054 GDI_ReleaseObj( hdc
);
1060 /***********************************************************************
1061 * SelectObject (GDI.45)
1063 HGDIOBJ16 WINAPI
SelectObject16( HDC16 hdc
, HGDIOBJ16 handle
)
1065 return (HGDIOBJ16
)SelectObject( hdc
, handle
);
1069 /***********************************************************************
1070 * SelectObject (GDI32.@)
1072 HGDIOBJ WINAPI
SelectObject( HDC hdc
, HGDIOBJ handle
)
1075 GDIOBJHDR
*header
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
);
1076 if (!header
) return 0;
1078 TRACE("hdc=%04x %04x\n", hdc
, handle
);
1080 if (header
->funcs
&& header
->funcs
->pSelectObject
)
1082 ret
= header
->funcs
->pSelectObject( handle
, header
, hdc
);
1083 if (ret
&& ret
!= handle
&& (INT
)ret
> COMPLEXREGION
)
1085 inc_ref_count( handle
);
1086 dec_ref_count( ret
);
1089 GDI_ReleaseObj( handle
);
1094 /***********************************************************************
1095 * UnrealizeObject (GDI.150)
1097 BOOL16 WINAPI
UnrealizeObject16( HGDIOBJ16 obj
)
1099 return UnrealizeObject( obj
);
1103 /***********************************************************************
1104 * UnrealizeObject (GDI32.@)
1106 BOOL WINAPI
UnrealizeObject( HGDIOBJ obj
)
1109 /* Check if object is valid */
1111 GDIOBJHDR
* header
= GDI_GetObjPtr( obj
, MAGIC_DONTCARE
);
1112 if (!header
) return FALSE
;
1114 TRACE("%04x\n", obj
);
1116 /* Unrealize object */
1118 if (header
->funcs
&& header
->funcs
->pUnrealizeObject
)
1119 result
= header
->funcs
->pUnrealizeObject( obj
, header
);
1121 GDI_ReleaseObj( obj
);
1126 /* Solid colors to enumerate */
1127 static const COLORREF solid_colors
[] =
1128 { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff),
1129 RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00),
1130 RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00),
1131 RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff),
1132 RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00),
1133 RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80),
1134 RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80),
1135 RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0)
1138 /***********************************************************************
1139 * EnumObjects (GDI.71)
1141 INT16 WINAPI
EnumObjects16( HDC16 hdc
, INT16 nObjType
,
1142 GOBJENUMPROC16 lpEnumFunc
, LPARAM lParam
)
1144 INT16 i
, retval
= 0;
1149 TRACE("%04x %d %08lx %08lx\n",
1150 hdc
, nObjType
, (DWORD
)lpEnumFunc
, lParam
);
1154 /* Enumerate solid pens */
1155 segptr
= MapLS( &pen
);
1156 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1158 pen
.lopnStyle
= PS_SOLID
;
1159 pen
.lopnWidth
.x
= 1;
1160 pen
.lopnWidth
.y
= 0;
1161 pen
.lopnColor
= solid_colors
[i
];
1162 retval
= GDI_CallTo16_word_ll( lpEnumFunc
, segptr
, lParam
);
1163 TRACE("solid pen %08lx, ret=%d\n", solid_colors
[i
], retval
);
1170 /* Enumerate solid brushes */
1171 segptr
= MapLS( &brush
);
1172 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1174 brush
.lbStyle
= BS_SOLID
;
1175 brush
.lbColor
= solid_colors
[i
];
1177 retval
= GDI_CallTo16_word_ll( lpEnumFunc
, segptr
, lParam
);
1178 TRACE("solid brush %08lx, ret=%d\n", solid_colors
[i
], retval
);
1182 /* Now enumerate hatched brushes */
1183 if (retval
) for (i
= HS_HORIZONTAL
; i
<= HS_DIAGCROSS
; i
++)
1185 brush
.lbStyle
= BS_HATCHED
;
1186 brush
.lbColor
= RGB(0,0,0);
1188 retval
= GDI_CallTo16_word_ll( lpEnumFunc
, segptr
, lParam
);
1189 TRACE("hatched brush %d, ret=%d\n", i
, retval
);
1196 WARN("(%d): Invalid type\n", nObjType
);
1203 /***********************************************************************
1204 * EnumObjects (GDI32.@)
1206 INT WINAPI
EnumObjects( HDC hdc
, INT nObjType
,
1207 GOBJENUMPROC lpEnumFunc
, LPARAM lParam
)
1213 TRACE("%04x %d %08lx %08lx\n",
1214 hdc
, nObjType
, (DWORD
)lpEnumFunc
, lParam
);
1218 /* Enumerate solid pens */
1219 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1221 pen
.lopnStyle
= PS_SOLID
;
1222 pen
.lopnWidth
.x
= 1;
1223 pen
.lopnWidth
.y
= 0;
1224 pen
.lopnColor
= solid_colors
[i
];
1225 retval
= lpEnumFunc( &pen
, lParam
);
1226 TRACE("solid pen %08lx, ret=%d\n",
1227 solid_colors
[i
], retval
);
1233 /* Enumerate solid brushes */
1234 for (i
= 0; i
< sizeof(solid_colors
)/sizeof(solid_colors
[0]); i
++)
1236 brush
.lbStyle
= BS_SOLID
;
1237 brush
.lbColor
= solid_colors
[i
];
1239 retval
= lpEnumFunc( &brush
, lParam
);
1240 TRACE("solid brush %08lx, ret=%d\n",
1241 solid_colors
[i
], retval
);
1245 /* Now enumerate hatched brushes */
1246 if (retval
) for (i
= HS_HORIZONTAL
; i
<= HS_DIAGCROSS
; i
++)
1248 brush
.lbStyle
= BS_HATCHED
;
1249 brush
.lbColor
= RGB(0,0,0);
1251 retval
= lpEnumFunc( &brush
, lParam
);
1252 TRACE("hatched brush %d, ret=%d\n",
1259 /* FIXME: implement Win32 types */
1260 WARN("(%d): Invalid type\n", nObjType
);
1267 /***********************************************************************
1268 * IsGDIObject (GDI.462)
1270 * returns type of object if valid (W95 system programming secrets p. 264-5)
1272 BOOL16 WINAPI
IsGDIObject16( HGDIOBJ16 handle
)
1276 GDIOBJHDR
*object
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
);
1279 magic
= GDIMAGIC(object
->wMagic
) - PEN_MAGIC
+ 1;
1280 GDI_ReleaseObj( handle
);
1286 /***********************************************************************
1287 * SetObjectOwner (GDI.461)
1289 void WINAPI
SetObjectOwner16( HGDIOBJ16 handle
, HANDLE16 owner
)
1295 /***********************************************************************
1296 * SetObjectOwner (GDI32.@)
1298 void WINAPI
SetObjectOwner( HGDIOBJ handle
, HANDLE owner
)
1304 /***********************************************************************
1305 * MakeObjectPrivate (GDI.463)
1307 * What does that mean ?
1308 * Some little docu can be found in "Undocumented Windows",
1309 * but this is basically useless.
1310 * At least we know that this flags the GDI object's wMagic
1311 * with 0x2000 (OBJECT_PRIVATE), so we just do it.
1312 * But Wine doesn't react on that yet.
1314 void WINAPI
MakeObjectPrivate16( HGDIOBJ16 handle
, BOOL16
private )
1316 GDIOBJHDR
*ptr
= GDI_GetObjPtr( handle
, MAGIC_DONTCARE
);
1319 ERR("invalid GDI object %04x !\n", handle
);
1322 ptr
->wMagic
|= OBJECT_PRIVATE
;
1323 GDI_ReleaseObj( handle
);
1327 /***********************************************************************
1328 * GdiFlush (GDI32.@)
1330 BOOL WINAPI
GdiFlush(void)
1332 return TRUE
; /* FIXME */
1336 /***********************************************************************
1337 * GdiGetBatchLimit (GDI32.@)
1339 DWORD WINAPI
GdiGetBatchLimit(void)
1341 return 1; /* FIXME */
1345 /***********************************************************************
1346 * GdiSetBatchLimit (GDI32.@)
1348 DWORD WINAPI
GdiSetBatchLimit( DWORD limit
)
1350 return 1; /* FIXME */
1354 /***********************************************************************
1355 * GdiSeeGdiDo (GDI.452)
1357 DWORD WINAPI
GdiSeeGdiDo16( WORD wReqType
, WORD wParam1
, WORD wParam2
,
1362 case 0x0001: /* LocalAlloc */
1363 return LOCAL_Alloc( GDI_HeapSel
, wParam1
, wParam3
);
1364 case 0x0002: /* LocalFree */
1365 return LOCAL_Free( GDI_HeapSel
, wParam1
);
1366 case 0x0003: /* LocalCompact */
1367 return LOCAL_Compact( GDI_HeapSel
, wParam3
, 0 );
1368 case 0x0103: /* LocalHeap */
1371 WARN("(wReqType=%04x): Unknown\n", wReqType
);
1376 /***********************************************************************
1377 * GdiSignalProc32 (GDI.610)
1379 WORD WINAPI
GdiSignalProc( UINT uCode
, DWORD dwThreadOrProcessID
,
1380 DWORD dwFlags
, HMODULE16 hModule
)
1385 /***********************************************************************
1386 * GdiInit2 (GDI.403)
1388 * See "Undocumented Windows"
1390 HANDLE16 WINAPI
GdiInit216(
1391 HANDLE16 h1
, /* [in] GDI object */
1392 HANDLE16 h2
/* [in] global data */
1395 FIXME("(%04x, %04x), stub.\n", h1
, h2
);
1397 return 0xffff; /* undefined return value */
1398 return h1
; /* FIXME: should be the memory handle of h1 */
1401 /***********************************************************************
1402 * FinalGdiInit (GDI.405)
1404 void WINAPI
FinalGdiInit16( HBRUSH16 hPattern
/* [in] fill pattern of desktop */ )
1408 /***********************************************************************
1409 * GdiFreeResources (GDI.609)
1411 WORD WINAPI
GdiFreeResources16( DWORD reserve
)
1413 return (WORD
)( (int)LOCAL_CountFree( GDI_HeapSel
) * 100 /
1414 (int)LOCAL_HeapSize( GDI_HeapSel
) );
1417 /***********************************************************************
1420 INT16 WINAPI
MulDiv16(
1421 INT16 nMultiplicand
,
1426 if (!nDivisor
) return -32768;
1427 /* We want to deal with a positive divisor to simplify the logic. */
1430 nMultiplicand
= - nMultiplicand
;
1431 nDivisor
= -nDivisor
;
1433 /* If the result is positive, we "add" to round. else,
1434 * we subtract to round. */
1435 if ( ( (nMultiplicand
< 0) && (nMultiplier
< 0) ) ||
1436 ( (nMultiplicand
>= 0) && (nMultiplier
>= 0) ) )
1437 ret
= (((int)nMultiplicand
* nMultiplier
) + (nDivisor
/2)) / nDivisor
;
1439 ret
= (((int)nMultiplicand
* nMultiplier
) - (nDivisor
/2)) / nDivisor
;
1440 if ((ret
> 32767) || (ret
< -32767)) return -32768;
1445 /*******************************************************************
1446 * GetColorAdjustment [GDI32.@]
1450 BOOL WINAPI
GetColorAdjustment(HDC hdc
, LPCOLORADJUSTMENT lpca
)
1452 FIXME("GetColorAdjustment, stub\n");
1456 /*******************************************************************
1457 * GetMiterLimit [GDI32.@]
1461 BOOL WINAPI
GetMiterLimit(HDC hdc
, PFLOAT peLimit
)
1463 FIXME("GetMiterLimit, stub\n");
1467 /*******************************************************************
1468 * SetMiterLimit [GDI32.@]
1472 BOOL WINAPI
SetMiterLimit(HDC hdc
, FLOAT eNewLimit
, PFLOAT peOldLimit
)
1474 FIXME("SetMiterLimit, stub\n");
1478 /*******************************************************************
1479 * GdiComment [GDI32.@]
1483 BOOL WINAPI
GdiComment(HDC hdc
, UINT cbSize
, const BYTE
*lpData
)
1485 FIXME("GdiComment, stub\n");
1488 /*******************************************************************
1489 * SetColorAdjustment [GDI32.@]
1493 BOOL WINAPI
SetColorAdjustment(HDC hdc
, const COLORADJUSTMENT
* lpca
)
1495 FIXME("SetColorAdjustment, stub\n");