Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * GDI functions |
| 3 | * |
| 4 | * Copyright 1993 Alexandre Julliard |
Alexandre Julliard | a2f2e01 | 1995-06-06 16:40:35 +0000 | [diff] [blame] | 5 | */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 6 | |
Patrik Stridvall | d96e1f1 | 1999-07-04 13:31:03 +0000 | [diff] [blame] | 7 | #include "config.h" |
| 8 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 9 | #include <assert.h> |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 10 | #include <stdlib.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 11 | #include <stdio.h> |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 12 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 13 | #include "windef.h" |
| 14 | #include "wingdi.h" |
| 15 | #include "winerror.h" |
| 16 | #include "wine/winbase16.h" |
| 17 | |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 18 | #include "bitmap.h" |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 19 | #include "brush.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 20 | #include "font.h" |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 21 | #include "heap.h" |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 22 | #include "options.h" |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 23 | #include "palette.h" |
| 24 | #include "pen.h" |
| 25 | #include "region.h" |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 26 | #include "debugtools.h" |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 27 | #include "gdi.h" |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 28 | #include "tweak.h" |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 29 | #include "syslevel.h" |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 30 | |
Alexandre Julliard | 58d5a0a | 2000-07-29 21:58:17 +0000 | [diff] [blame] | 31 | DEFAULT_DEBUG_CHANNEL(gdi); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 32 | |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 33 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 34 | /*********************************************************************** |
| 35 | * GDI stock objects |
| 36 | */ |
| 37 | |
| 38 | static BRUSHOBJ WhiteBrush = |
| 39 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 40 | { 0, BRUSH_MAGIC, 1 }, /* header */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 41 | { BS_SOLID, RGB(255,255,255), 0 } /* logbrush */ |
| 42 | }; |
| 43 | |
| 44 | static BRUSHOBJ LtGrayBrush = |
| 45 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 46 | { 0, BRUSH_MAGIC, 1 }, /* header */ |
Alexandre Julliard | 33072e1 | 1997-06-29 18:08:02 +0000 | [diff] [blame] | 47 | /* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 48 | { BS_SOLID, RGB(192,192,192), 0 } /* logbrush */ |
| 49 | }; |
| 50 | |
| 51 | static BRUSHOBJ GrayBrush = |
| 52 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 53 | { 0, BRUSH_MAGIC, 1 }, /* header */ |
Alexandre Julliard | 33072e1 | 1997-06-29 18:08:02 +0000 | [diff] [blame] | 54 | /* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 55 | { BS_SOLID, RGB(128,128,128), 0 } /* logbrush */ |
| 56 | }; |
| 57 | |
| 58 | static BRUSHOBJ DkGrayBrush = |
| 59 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 60 | { 0, BRUSH_MAGIC, 1 }, /* header */ |
Alexandre Julliard | 33072e1 | 1997-06-29 18:08:02 +0000 | [diff] [blame] | 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 | { BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES } /* logbrush */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | static BRUSHOBJ BlackBrush = |
| 67 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 68 | { 0, BRUSH_MAGIC, 1 }, /* header */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 69 | { BS_SOLID, RGB(0,0,0), 0 } /* logbrush */ |
| 70 | }; |
| 71 | |
| 72 | static BRUSHOBJ NullBrush = |
| 73 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 74 | { 0, BRUSH_MAGIC, 1 }, /* header */ |
| 75 | { BS_NULL, 0, 0 } /* logbrush */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | static PENOBJ WhitePen = |
| 79 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 80 | { 0, PEN_MAGIC, 1 }, /* header */ |
Francois Gouget | 78767e6 | 2000-10-31 01:36:09 +0000 | [diff] [blame] | 81 | { PS_SOLID, { 0, 0 }, RGB(255,255,255) } /* logpen */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | static PENOBJ BlackPen = |
| 85 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 86 | { 0, PEN_MAGIC, 1 }, /* header */ |
Francois Gouget | 78767e6 | 2000-10-31 01:36:09 +0000 | [diff] [blame] | 87 | { PS_SOLID, { 0, 0 }, RGB(0,0,0) } /* logpen */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | static PENOBJ NullPen = |
| 91 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 92 | { 0, PEN_MAGIC, 1 }, /* header */ |
Francois Gouget | 78767e6 | 2000-10-31 01:36:09 +0000 | [diff] [blame] | 93 | { PS_NULL, { 0, 0 }, 0 } /* logpen */ |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | static FONTOBJ OEMFixedFont = |
| 97 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 98 | { 0, FONT_MAGIC, 1 }, /* header */ |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 99 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET, |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 100 | 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" } |
| 101 | }; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 102 | /* Filler to make the location counter dword aligned again. This is necessary |
| 103 | since (a) FONTOBJ is packed, (b) gcc places initialised variables in the code |
| 104 | segment, and (c) Solaris assembler is stupid. */ |
| 105 | static UINT16 align_OEMFixedFont = 1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 106 | |
| 107 | static FONTOBJ AnsiFixedFont = |
| 108 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 109 | { 0, FONT_MAGIC, 1 }, /* header */ |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 110 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 111 | 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" } |
| 112 | }; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 113 | static UINT16 align_AnsiFixedFont = 1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 114 | |
| 115 | static FONTOBJ AnsiVarFont = |
| 116 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 117 | { 0, FONT_MAGIC, 1 }, /* header */ |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 118 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 119 | 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 120 | }; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 121 | static UINT16 align_AnsiVarFont = 1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 122 | |
| 123 | static FONTOBJ SystemFont = |
| 124 | { |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 125 | { 0, FONT_MAGIC, 1 }, |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 126 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 127 | 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "System" } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 128 | }; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 129 | static UINT16 align_SystemFont = 1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 130 | |
| 131 | static FONTOBJ DeviceDefaultFont = |
| 132 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 133 | { 0, FONT_MAGIC, 1 }, /* header */ |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 134 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 135 | 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "" } |
| 136 | }; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 137 | static UINT16 align_DeviceDefaultFont = 1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 138 | |
| 139 | static FONTOBJ SystemFixedFont = |
| 140 | { |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 141 | { 0, FONT_MAGIC, 1 }, /* header */ |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 142 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 143 | 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" } |
| 144 | }; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 145 | static UINT16 align_SystemFixedFont = 1; |
| 146 | |
| 147 | /* FIXME: Is this correct? */ |
| 148 | static FONTOBJ DefaultGuiFont = |
| 149 | { |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 150 | { 0, FONT_MAGIC, 1 }, /* header */ |
| 151 | { 0, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 152 | 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" } |
| 153 | }; |
| 154 | static UINT16 align_DefaultGuiFont = 1; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 155 | |
| 156 | |
| 157 | static GDIOBJHDR * StockObjects[NB_STOCK_OBJECTS] = |
| 158 | { |
| 159 | (GDIOBJHDR *) &WhiteBrush, |
| 160 | (GDIOBJHDR *) &LtGrayBrush, |
| 161 | (GDIOBJHDR *) &GrayBrush, |
| 162 | (GDIOBJHDR *) &DkGrayBrush, |
| 163 | (GDIOBJHDR *) &BlackBrush, |
| 164 | (GDIOBJHDR *) &NullBrush, |
| 165 | (GDIOBJHDR *) &WhitePen, |
| 166 | (GDIOBJHDR *) &BlackPen, |
| 167 | (GDIOBJHDR *) &NullPen, |
| 168 | NULL, |
| 169 | (GDIOBJHDR *) &OEMFixedFont, |
| 170 | (GDIOBJHDR *) &AnsiFixedFont, |
| 171 | (GDIOBJHDR *) &AnsiVarFont, |
| 172 | (GDIOBJHDR *) &SystemFont, |
| 173 | (GDIOBJHDR *) &DeviceDefaultFont, |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 174 | NULL, /* DEFAULT_PALETTE created by PALETTE_Init */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 175 | (GDIOBJHDR *) &SystemFixedFont, |
| 176 | (GDIOBJHDR *) &DefaultGuiFont |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 177 | }; |
| 178 | |
Gerard Patel | d1795f6 | 2000-01-09 20:52:53 +0000 | [diff] [blame] | 179 | HBITMAP hPseudoStockBitmap; /* 1x1 bitmap for memory DCs */ |
| 180 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 181 | static SYSLEVEL GDI_level; |
| 182 | static WORD GDI_HeapSel; |
| 183 | |
| 184 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 185 | /****************************************************************************** |
| 186 | * |
| 187 | * void ReadFontInformation( |
| 188 | * char const *fontName, |
| 189 | * FONTOBJ *font, |
| 190 | * int defHeight, |
| 191 | * int defBold, |
| 192 | * int defItalic, |
| 193 | * int defUnderline, |
| 194 | * int defStrikeOut ) |
| 195 | * |
| 196 | * ReadFontInformation() checks the Wine configuration file's Tweak.Fonts |
| 197 | * section for entries containing fontName.Height, fontName.Bold, etc., |
| 198 | * where fontName is the name specified in the call (e.g., "System"). It |
| 199 | * attempts to be user friendly by accepting 'n', 'N', 'f', 'F', or '0' as |
| 200 | * the first character in the boolean attributes (bold, italic, and |
| 201 | * underline). |
| 202 | *****************************************************************************/ |
| 203 | |
| 204 | static void ReadFontInformation( |
| 205 | char const *fontName, |
| 206 | FONTOBJ *font, |
| 207 | int defHeight, |
| 208 | int defBold, |
| 209 | int defItalic, |
| 210 | int defUnderline, |
| 211 | int defStrikeOut ) |
| 212 | { |
| 213 | char key[256]; |
| 214 | |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 215 | /* In order for the stock fonts to be independent of |
| 216 | * mapping mode, the height (& width) must be 0 |
| 217 | */ |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 218 | sprintf(key, "%s.Height", fontName); |
| 219 | font->logfont.lfHeight = |
| 220 | PROFILE_GetWineIniInt("Tweak.Fonts", key, defHeight); |
| 221 | |
| 222 | sprintf(key, "%s.Bold", fontName); |
| 223 | font->logfont.lfWeight = |
| 224 | (PROFILE_GetWineIniBool("Tweak.Fonts", key, defBold)) ? |
| 225 | FW_BOLD : FW_NORMAL; |
| 226 | |
| 227 | sprintf(key, "%s.Italic", fontName); |
| 228 | font->logfont.lfItalic = |
| 229 | PROFILE_GetWineIniBool("Tweak.Fonts", key, defItalic); |
| 230 | |
| 231 | sprintf(key, "%s.Underline", fontName); |
| 232 | font->logfont.lfUnderline = |
| 233 | PROFILE_GetWineIniBool("Tweak.Fonts", key, defUnderline); |
| 234 | |
| 235 | sprintf(key, "%s.StrikeOut", fontName); |
| 236 | font->logfont.lfStrikeOut = |
| 237 | PROFILE_GetWineIniBool("Tweak.Fonts", key, defStrikeOut); |
| 238 | |
| 239 | return; |
| 240 | } |
| 241 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 242 | /*********************************************************************** |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 243 | * Because the stock fonts have their structure initialized with |
| 244 | * a height of 0 to keep them independent of mapping mode, simply |
| 245 | * returning the LOGFONT as is will not work correctly. |
| 246 | * These "FixStockFontSizeXXX()" methods will get the correct |
| 247 | * size for the fonts. |
| 248 | */ |
| 249 | static void GetFontMetrics(HFONT handle, LPTEXTMETRICA lptm) |
| 250 | { |
Ian Schmidt | e04b3e9 | 1999-11-04 01:45:53 +0000 | [diff] [blame] | 251 | HDC hdc; |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 252 | HFONT hOldFont; |
| 253 | |
Ian Schmidt | e04b3e9 | 1999-11-04 01:45:53 +0000 | [diff] [blame] | 254 | hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); |
| 255 | |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 256 | hOldFont = (HFONT)SelectObject(hdc, handle); |
| 257 | |
| 258 | GetTextMetricsA(hdc, lptm); |
| 259 | |
| 260 | SelectObject(hdc, hOldFont); |
| 261 | |
Ian Schmidt | e04b3e9 | 1999-11-04 01:45:53 +0000 | [diff] [blame] | 262 | DeleteDC(hdc); |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | static inline void FixStockFontSize16( |
| 266 | HFONT handle, |
| 267 | INT16 count, |
| 268 | LPVOID buffer) |
| 269 | { |
| 270 | TEXTMETRICA tm; |
| 271 | LOGFONT16* pLogFont = (LOGFONT16*)buffer; |
| 272 | |
| 273 | /* |
| 274 | * Was the lfHeight field copied (it's the first field)? |
| 275 | * If it was and it was null, replace the height. |
| 276 | */ |
| 277 | if ( (count >= 2*sizeof(INT16)) && |
| 278 | (pLogFont->lfHeight == 0) ) |
| 279 | { |
| 280 | GetFontMetrics(handle, &tm); |
| 281 | |
| 282 | pLogFont->lfHeight = tm.tmHeight; |
| 283 | pLogFont->lfWidth = tm.tmAveCharWidth; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | static inline void FixStockFontSizeA( |
| 288 | HFONT handle, |
| 289 | INT count, |
| 290 | LPVOID buffer) |
| 291 | { |
| 292 | TEXTMETRICA tm; |
| 293 | LOGFONTA* pLogFont = (LOGFONTA*)buffer; |
| 294 | |
| 295 | /* |
| 296 | * Was the lfHeight field copied (it's the first field)? |
| 297 | * If it was and it was null, replace the height. |
| 298 | */ |
| 299 | if ( (count >= 2*sizeof(INT)) && |
| 300 | (pLogFont->lfHeight == 0) ) |
| 301 | { |
| 302 | GetFontMetrics(handle, &tm); |
| 303 | |
| 304 | pLogFont->lfHeight = tm.tmHeight; |
| 305 | pLogFont->lfWidth = tm.tmAveCharWidth; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Since the LOGFONTA and LOGFONTW structures are identical up to the |
| 311 | * lfHeight member (the one of interest in this case) we simply define |
| 312 | * the W version as the A version. |
| 313 | */ |
| 314 | #define FixStockFontSizeW FixStockFontSizeA |
| 315 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 316 | #define TRACE_SEC(handle,text) \ |
| 317 | TRACE("(%04x): " text " %ld\n", (handle), GDI_level.crst.RecursionCount) |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 318 | |
| 319 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 320 | * GDI_Init |
| 321 | * |
Alexandre Julliard | 1e9ac79 | 1996-06-06 18:38:27 +0000 | [diff] [blame] | 322 | * GDI initialization. |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 323 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 324 | BOOL GDI_Init(void) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 325 | { |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 326 | BOOL systemIsBold = (TWEAK_WineLook == WIN31_LOOK); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 327 | HPALETTE16 hpalette; |
| 328 | HINSTANCE16 instance; |
| 329 | |
| 330 | _CreateSysLevel( &GDI_level, 3 ); |
| 331 | |
| 332 | /* create GDI heap */ |
| 333 | if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE; |
| 334 | GDI_HeapSel = GlobalHandleToSel16( instance ); |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 335 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 336 | /* Kill some warnings. */ |
| 337 | (void)align_OEMFixedFont; |
| 338 | (void)align_AnsiFixedFont; |
| 339 | (void)align_AnsiVarFont; |
| 340 | (void)align_SystemFont; |
| 341 | (void)align_DeviceDefaultFont; |
| 342 | (void)align_SystemFixedFont; |
| 343 | (void)align_DefaultGuiFont; |
| 344 | |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 345 | /* TWEAK: Initialize font hints */ |
Richard Cohen | 05bf534 | 1999-09-03 15:16:23 +0000 | [diff] [blame] | 346 | ReadFontInformation("OEMFixed", &OEMFixedFont, 0, 0, 0, 0, 0); |
| 347 | ReadFontInformation("AnsiFixed", &AnsiFixedFont, 0, 0, 0, 0, 0); |
| 348 | ReadFontInformation("AnsiVar", &AnsiVarFont, 0, 0, 0, 0, 0); |
| 349 | ReadFontInformation("System", &SystemFont, 0, systemIsBold, 0, 0, 0); |
| 350 | ReadFontInformation("DeviceDefault", &DeviceDefaultFont, 0, 0, 0, 0, 0); |
| 351 | ReadFontInformation("SystemFixed", &SystemFixedFont, 0, systemIsBold, 0, 0, 0); |
| 352 | ReadFontInformation("DefaultGui", &DefaultGuiFont, 0, 0, 0, 0, 0); |
Alexandre Julliard | d37eb36 | 1997-07-20 16:23:21 +0000 | [diff] [blame] | 353 | |
Patrik Stridvall | b87fe2e | 1999-04-01 08:16:08 +0000 | [diff] [blame] | 354 | /* Create default palette */ |
| 355 | |
| 356 | /* DR well *this* palette can't be moveable (?) */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 357 | hpalette = PALETTE_Init(); |
| 358 | if( !hpalette ) return FALSE; |
| 359 | StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hpalette ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 360 | |
Gerard Patel | d1795f6 | 2000-01-09 20:52:53 +0000 | [diff] [blame] | 361 | hPseudoStockBitmap = CreateBitmap( 1, 1, 1, 1, NULL ); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 362 | return TRUE; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 365 | #define FIRST_LARGE_HANDLE 16 |
| 366 | #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE - FIRST_LARGE_HANDLE) >> 2) |
| 367 | static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES]; |
| 368 | static int next_large_handle; |
| 369 | |
| 370 | /*********************************************************************** |
| 371 | * alloc_large_heap |
| 372 | * |
| 373 | * Allocate a GDI handle from the large heap. Helper for GDI_AllocObject |
| 374 | */ |
| 375 | inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle ) |
| 376 | { |
| 377 | int i; |
| 378 | GDIOBJHDR *obj; |
| 379 | |
| 380 | for (i = next_large_handle + 1; i < MAX_LARGE_HANDLES; i++) |
| 381 | if (!large_handles[i]) goto found; |
| 382 | for (i = 0; i <= next_large_handle; i++) |
| 383 | if (!large_handles[i]) goto found; |
| 384 | *handle = 0; |
| 385 | return NULL; |
| 386 | |
| 387 | found: |
| 388 | if ((obj = HeapAlloc( GetProcessHeap(), 0, size ))) |
| 389 | { |
| 390 | large_handles[i] = obj; |
| 391 | *handle = (i + FIRST_LARGE_HANDLE) << 2; |
| 392 | next_large_handle = i; |
| 393 | } |
| 394 | return obj; |
| 395 | } |
| 396 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 397 | |
| 398 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 399 | * GDI_AllocObject |
| 400 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 401 | void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 402 | { |
| 403 | static DWORD count = 0; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 404 | GDIOBJHDR *obj; |
| 405 | |
| 406 | _EnterSysLevel( &GDI_level ); |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 407 | switch(magic) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 408 | { |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 409 | /* allocate DCs on the larger heap */ |
| 410 | case DC_MAGIC: |
| 411 | case DISABLED_DC_MAGIC: |
| 412 | case META_DC_MAGIC: |
| 413 | case METAFILE_MAGIC: |
| 414 | case METAFILE_DC_MAGIC: |
| 415 | case ENHMETAFILE_MAGIC: |
| 416 | case ENHMETAFILE_DC_MAGIC: |
| 417 | if (!(obj = alloc_large_heap( size, handle ))) goto error; |
| 418 | break; |
| 419 | default: |
| 420 | if (!(*handle = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error; |
| 421 | assert( *handle & 2 ); |
| 422 | obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, *handle ); |
| 423 | break; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 424 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 425 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 426 | obj->hNext = 0; |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 427 | obj->wMagic = magic|OBJECT_NOSYSTEM; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 428 | obj->dwCount = ++count; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 429 | |
| 430 | TRACE_SEC( *handle, "enter" ); |
| 431 | return obj; |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 432 | |
| 433 | error: |
| 434 | _LeaveSysLevel( &GDI_level ); |
| 435 | *handle = 0; |
| 436 | return NULL; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | |
| 440 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 441 | * GDI_ReallocObject |
| 442 | * |
| 443 | * The object ptr must have been obtained with GDI_GetObjPtr. |
| 444 | * The new pointer must be released with GDI_ReleaseObj. |
| 445 | */ |
| 446 | void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object ) |
| 447 | { |
| 448 | HGDIOBJ new_handle; |
| 449 | |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 450 | assert( handle & 2 ); /* no realloc for large handles */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 451 | LOCAL_Unlock( GDI_HeapSel, handle ); |
| 452 | if (!(new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE ))) |
| 453 | { |
| 454 | TRACE_SEC( handle, "leave" ); |
| 455 | _LeaveSysLevel( &GDI_level ); |
| 456 | return NULL; |
| 457 | } |
| 458 | assert( new_handle == handle ); /* moveable handle cannot change */ |
| 459 | return LOCAL_Lock( GDI_HeapSel, handle ); |
| 460 | } |
| 461 | |
| 462 | |
| 463 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 464 | * GDI_FreeObject |
| 465 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 466 | BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 467 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 468 | GDIOBJHDR *object = ptr; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 469 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 470 | /* can't free stock objects */ |
| 471 | if (handle < FIRST_STOCK_HANDLE) |
| 472 | { |
| 473 | object->wMagic = 0; /* Mark it as invalid */ |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 474 | if (handle & 2) /* GDI heap handle */ |
| 475 | { |
| 476 | LOCAL_Unlock( GDI_HeapSel, handle ); |
| 477 | LOCAL_Free( GDI_HeapSel, handle ); |
| 478 | } |
| 479 | else /* large heap handle */ |
| 480 | { |
| 481 | int i = (handle >> 2) - FIRST_LARGE_HANDLE; |
| 482 | if (i >= 0 && large_handles[i]) |
| 483 | { |
| 484 | HeapFree( GetProcessHeap(), 0, large_handles[i] ); |
| 485 | large_handles[i] = NULL; |
| 486 | } |
| 487 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 488 | } |
| 489 | TRACE_SEC( handle, "leave" ); |
| 490 | _LeaveSysLevel( &GDI_level ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 491 | return TRUE; |
| 492 | } |
| 493 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 494 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 495 | /*********************************************************************** |
| 496 | * GDI_GetObjPtr |
| 497 | * |
| 498 | * Return a pointer to the GDI object associated to the handle. |
| 499 | * Return NULL if the object has the wrong magic number. |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 500 | * The object must be released with GDI_ReleaseObj. |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 501 | */ |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 502 | void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 503 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 504 | GDIOBJHDR *ptr = NULL; |
| 505 | |
| 506 | _EnterSysLevel( &GDI_level ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 507 | |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 508 | if (handle >= FIRST_STOCK_HANDLE) |
| 509 | { |
| 510 | if (handle <= LAST_STOCK_HANDLE) ptr = StockObjects[handle - FIRST_STOCK_HANDLE]; |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 511 | if (ptr && (magic != MAGIC_DONTCARE) |
| 512 | && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL; |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 513 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 514 | else if (handle & 2) /* GDI heap handle */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 515 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 516 | ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle ); |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 517 | if (ptr && |
| 518 | (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 519 | { |
| 520 | LOCAL_Unlock( GDI_HeapSel, handle ); |
| 521 | ptr = NULL; |
| 522 | } |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 523 | } |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 524 | else /* large heap handle */ |
| 525 | { |
| 526 | int i = (handle >> 2) - FIRST_LARGE_HANDLE; |
| 527 | if (i >= 0) |
| 528 | { |
| 529 | ptr = large_handles[i]; |
| 530 | if (ptr && (magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ptr = NULL; |
| 531 | } |
| 532 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 533 | |
| 534 | if (!ptr) |
| 535 | { |
| 536 | _LeaveSysLevel( &GDI_level ); |
| 537 | SetLastError( ERROR_INVALID_HANDLE ); |
| 538 | } |
| 539 | else TRACE_SEC( handle, "enter" ); |
| 540 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 541 | return ptr; |
| 542 | } |
| 543 | |
| 544 | |
| 545 | /*********************************************************************** |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 546 | * GDI_ReleaseObj |
| 547 | * |
| 548 | */ |
| 549 | void GDI_ReleaseObj( HGDIOBJ handle ) |
| 550 | { |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 551 | if (handle < FIRST_STOCK_HANDLE && (handle & 2)) LOCAL_Unlock( GDI_HeapSel, handle ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 552 | TRACE_SEC( handle, "leave" ); |
| 553 | _LeaveSysLevel( &GDI_level ); |
| 554 | } |
| 555 | |
| 556 | |
| 557 | /*********************************************************************** |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 558 | * DeleteObject16 (GDI.69) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 559 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 560 | BOOL16 WINAPI DeleteObject16( HGDIOBJ16 obj ) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 561 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 562 | return DeleteObject( obj ); |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | |
| 566 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 567 | * DeleteObject (GDI32.70) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 568 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 569 | BOOL WINAPI DeleteObject( HGDIOBJ obj ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 570 | { |
| 571 | /* Check if object is valid */ |
| 572 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 573 | GDIOBJHDR * header; |
| 574 | if (HIWORD(obj)) return FALSE; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 575 | if ((obj >= FIRST_STOCK_HANDLE) && (obj <= LAST_STOCK_HANDLE)) { |
| 576 | TRACE("Preserving Stock object %04x\n", obj ); |
| 577 | /* NOTE: No GDI_Release is necessary */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 578 | return TRUE; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 579 | } |
Gerard Patel | 5faa5d7 | 2000-08-25 21:54:23 +0000 | [diff] [blame] | 580 | if (obj == hPseudoStockBitmap) return TRUE; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 581 | if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 582 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 583 | if (!(header->wMagic & OBJECT_NOSYSTEM) |
| 584 | && (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC)) |
| 585 | { |
| 586 | TRACE("Preserving system object %04x\n", obj); |
| 587 | GDI_ReleaseObj( obj ); |
| 588 | return TRUE; |
| 589 | } |
| 590 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 591 | TRACE("%04x\n", obj ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 592 | |
| 593 | /* Delete object */ |
| 594 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 595 | switch(GDIMAGIC(header->wMagic)) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 596 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 597 | case PEN_MAGIC: return GDI_FreeObject( obj, header ); |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 598 | case BRUSH_MAGIC: return BRUSH_DeleteObject( obj, (BRUSHOBJ*)header ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 599 | case FONT_MAGIC: return GDI_FreeObject( obj, header ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 600 | case PALETTE_MAGIC: return PALETTE_DeleteObject(obj,(PALETTEOBJ*)header); |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 601 | case BITMAP_MAGIC: return BITMAP_DeleteObject( obj, (BITMAPOBJ*)header); |
| 602 | case REGION_MAGIC: return REGION_DeleteObject( obj, (RGNOBJ*)header ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 603 | case DC_MAGIC: |
| 604 | GDI_ReleaseObj( obj ); |
| 605 | return DeleteDC(obj); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 606 | case 0 : |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 607 | WARN("Already deleted\n"); |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 608 | break; |
| 609 | default: |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 610 | WARN("Unknown magic number (%d)\n",GDIMAGIC(header->wMagic)); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 611 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 612 | GDI_ReleaseObj( obj ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 613 | return FALSE; |
| 614 | } |
| 615 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 616 | /*********************************************************************** |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 617 | * GetStockObject16 (GDI.87) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 618 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 619 | HGDIOBJ16 WINAPI GetStockObject16( INT16 obj ) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 620 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 621 | return (HGDIOBJ16)GetStockObject( obj ); |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | |
| 625 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 626 | * GetStockObject (GDI32.220) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 627 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 628 | HGDIOBJ WINAPI GetStockObject( INT obj ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 629 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 630 | HGDIOBJ ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 631 | if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0; |
| 632 | if (!StockObjects[obj]) return 0; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 633 | ret = (HGDIOBJ16)(FIRST_STOCK_HANDLE + obj); |
| 634 | TRACE("returning %4x\n", ret ); |
| 635 | return ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | |
| 639 | /*********************************************************************** |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 640 | * GetObject16 (GDI.82) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 641 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 642 | INT16 WINAPI GetObject16( HANDLE16 handle, INT16 count, LPVOID buffer ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 643 | { |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 644 | GDIOBJHDR * ptr; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 645 | INT16 result = 0; |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 646 | TRACE("%04x %d %p\n", handle, count, buffer ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 647 | if (!count) return 0; |
| 648 | |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 649 | if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 650 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 651 | switch(GDIMAGIC(ptr->wMagic)) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 652 | { |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 653 | case PEN_MAGIC: |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 654 | result = PEN_GetObject16( (PENOBJ *)ptr, count, buffer ); |
| 655 | break; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 656 | case BRUSH_MAGIC: |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 657 | result = BRUSH_GetObject16( (BRUSHOBJ *)ptr, count, buffer ); |
| 658 | break; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 659 | case BITMAP_MAGIC: |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 660 | result = BITMAP_GetObject16( (BITMAPOBJ *)ptr, count, buffer ); |
| 661 | break; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 662 | case FONT_MAGIC: |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 663 | result = FONT_GetObject16( (FONTOBJ *)ptr, count, buffer ); |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 664 | |
| 665 | /* |
| 666 | * Fix the LOGFONT structure for the stock fonts |
| 667 | */ |
| 668 | if ( (handle >= FIRST_STOCK_HANDLE) && |
| 669 | (handle <= LAST_STOCK_HANDLE) ) |
| 670 | FixStockFontSize16(handle, count, buffer); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 671 | break; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 672 | case PALETTE_MAGIC: |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 673 | result = PALETTE_GetObject( (PALETTEOBJ *)ptr, count, buffer ); |
| 674 | break; |
| 675 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 676 | GDI_ReleaseObj( handle ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 677 | return result; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | |
| 681 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 682 | * GetObjectA (GDI32.204) |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 683 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 684 | INT WINAPI GetObjectA( HANDLE handle, INT count, LPVOID buffer ) |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 685 | { |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 686 | GDIOBJHDR * ptr; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 687 | INT result = 0; |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 688 | TRACE("%08x %d %p\n", handle, count, buffer ); |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 689 | if (!count) return 0; |
| 690 | |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 691 | if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0; |
| 692 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 693 | switch(GDIMAGIC(ptr->wMagic)) |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 694 | { |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 695 | case PEN_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 696 | result = PEN_GetObject( (PENOBJ *)ptr, count, buffer ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 697 | break; |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 698 | case BRUSH_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 699 | result = BRUSH_GetObject( (BRUSHOBJ *)ptr, count, buffer ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 700 | break; |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 701 | case BITMAP_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 702 | result = BITMAP_GetObject( (BITMAPOBJ *)ptr, count, buffer ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 703 | break; |
Alexandre Julliard | 0e270f4 | 1996-08-24 18:26:35 +0000 | [diff] [blame] | 704 | case FONT_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 705 | result = FONT_GetObjectA( (FONTOBJ *)ptr, count, buffer ); |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 706 | |
| 707 | /* |
| 708 | * Fix the LOGFONT structure for the stock fonts |
| 709 | */ |
| 710 | if ( (handle >= FIRST_STOCK_HANDLE) && |
| 711 | (handle <= LAST_STOCK_HANDLE) ) |
| 712 | FixStockFontSizeA(handle, count, buffer); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 713 | break; |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 714 | case PALETTE_MAGIC: |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 715 | result = PALETTE_GetObject( (PALETTEOBJ *)ptr, count, buffer ); |
| 716 | break; |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 717 | |
| 718 | case REGION_MAGIC: |
| 719 | case DC_MAGIC: |
| 720 | case DISABLED_DC_MAGIC: |
| 721 | case META_DC_MAGIC: |
| 722 | case METAFILE_MAGIC: |
| 723 | case METAFILE_DC_MAGIC: |
| 724 | case ENHMETAFILE_MAGIC: |
| 725 | case ENHMETAFILE_DC_MAGIC: |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 726 | FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) ); |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 727 | break; |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 728 | |
| 729 | default: |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 730 | ERR("Invalid GDI Magic %04x\n", GDIMAGIC(ptr->wMagic)); |
Andreas Mohr | 024e881 | 2000-08-25 21:30:34 +0000 | [diff] [blame] | 731 | break; |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 732 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 733 | GDI_ReleaseObj( handle ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 734 | return result; |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 735 | } |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 736 | |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 737 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 738 | * GetObjectW (GDI32.206) |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 739 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 740 | INT WINAPI GetObjectW( HANDLE handle, INT count, LPVOID buffer ) |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 741 | { |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 742 | GDIOBJHDR * ptr; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 743 | INT result = 0; |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 744 | TRACE("%08x %d %p\n", handle, count, buffer ); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 745 | if (!count) return 0; |
| 746 | |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 747 | if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0; |
| 748 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 749 | switch(GDIMAGIC(ptr->wMagic)) |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 750 | { |
| 751 | case PEN_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 752 | result = PEN_GetObject( (PENOBJ *)ptr, count, buffer ); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 753 | break; |
| 754 | case BRUSH_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 755 | result = BRUSH_GetObject( (BRUSHOBJ *)ptr, count, buffer ); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 756 | break; |
| 757 | case BITMAP_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 758 | result = BITMAP_GetObject( (BITMAPOBJ *)ptr, count, buffer ); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 759 | break; |
| 760 | case FONT_MAGIC: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 761 | result = FONT_GetObjectW( (FONTOBJ *)ptr, count, buffer ); |
Francis Beaudet | 12668f5 | 1999-10-31 17:32:26 +0000 | [diff] [blame] | 762 | |
| 763 | /* |
| 764 | * Fix the LOGFONT structure for the stock fonts |
| 765 | */ |
| 766 | if ( (handle >= FIRST_STOCK_HANDLE) && |
| 767 | (handle <= LAST_STOCK_HANDLE) ) |
| 768 | FixStockFontSizeW(handle, count, buffer); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 769 | break; |
| 770 | case PALETTE_MAGIC: |
| 771 | result = PALETTE_GetObject( (PALETTEOBJ *)ptr, count, buffer ); |
| 772 | break; |
| 773 | default: |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 774 | FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) ); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 775 | break; |
| 776 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 777 | GDI_ReleaseObj( handle ); |
Juergen Schmied | cba8488 | 1998-10-23 13:27:36 +0000 | [diff] [blame] | 778 | return result; |
| 779 | } |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 780 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 781 | /*********************************************************************** |
| 782 | * GetObjectType (GDI32.205) |
| 783 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 784 | DWORD WINAPI GetObjectType( HANDLE handle ) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 785 | { |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 786 | GDIOBJHDR * ptr; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 787 | INT result = 0; |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 788 | TRACE("%08x\n", handle ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 789 | |
Matthew Cline | 20512fd | 2000-02-13 16:00:17 +0000 | [diff] [blame] | 790 | if (!(ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ))) return 0; |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 791 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 792 | switch(GDIMAGIC(ptr->wMagic)) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 793 | { |
| 794 | case PEN_MAGIC: |
| 795 | result = OBJ_PEN; |
| 796 | break; |
| 797 | case BRUSH_MAGIC: |
| 798 | result = OBJ_BRUSH; |
| 799 | break; |
| 800 | case BITMAP_MAGIC: |
| 801 | result = OBJ_BITMAP; |
| 802 | break; |
| 803 | case FONT_MAGIC: |
| 804 | result = OBJ_FONT; |
| 805 | break; |
| 806 | case PALETTE_MAGIC: |
| 807 | result = OBJ_PAL; |
| 808 | break; |
| 809 | case REGION_MAGIC: |
| 810 | result = OBJ_REGION; |
| 811 | break; |
| 812 | case DC_MAGIC: |
| 813 | result = OBJ_DC; |
| 814 | break; |
| 815 | case META_DC_MAGIC: |
| 816 | result = OBJ_METADC; |
| 817 | break; |
| 818 | case METAFILE_MAGIC: |
| 819 | result = OBJ_METAFILE; |
| 820 | break; |
| 821 | case METAFILE_DC_MAGIC: |
| 822 | result = OBJ_METADC; |
| 823 | break; |
Huw D M Davies | 7603dea | 1999-04-25 09:24:23 +0000 | [diff] [blame] | 824 | case ENHMETAFILE_MAGIC: |
| 825 | result = OBJ_ENHMETAFILE; |
| 826 | break; |
| 827 | case ENHMETAFILE_DC_MAGIC: |
| 828 | result = OBJ_ENHMETADC; |
| 829 | break; |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 830 | default: |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 831 | FIXME("Magic %04x not implemented\n", GDIMAGIC(ptr->wMagic) ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 832 | break; |
| 833 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 834 | GDI_ReleaseObj( handle ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 835 | return result; |
| 836 | } |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 837 | |
| 838 | /*********************************************************************** |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 839 | * GetCurrentObject (GDI32.166) |
| 840 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 841 | HANDLE WINAPI GetCurrentObject(HDC hdc,UINT type) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 842 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 843 | HANDLE ret = 0; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 844 | DC * dc = DC_GetDCPtr( hdc ); |
| 845 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 846 | if (dc) |
| 847 | { |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 848 | switch (type) { |
Alexandre Julliard | 2239abb | 2000-11-05 02:05:07 +0000 | [diff] [blame] | 849 | case OBJ_PEN: ret = dc->hPen; break; |
| 850 | case OBJ_BRUSH: ret = dc->hBrush; break; |
| 851 | case OBJ_PAL: ret = dc->hPalette; break; |
| 852 | case OBJ_FONT: ret = dc->hFont; break; |
| 853 | case OBJ_BITMAP: ret = dc->hBitmap; break; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 854 | default: |
| 855 | /* the SDK only mentions those above */ |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 856 | FIXME("(%08x,%d): unknown type.\n",hdc,type); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 857 | break; |
| 858 | } |
| 859 | GDI_ReleaseObj( hdc ); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 860 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 861 | return ret; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 862 | } |
| 863 | |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 864 | |
| 865 | /*********************************************************************** |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 866 | * SelectObject16 (GDI.45) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 867 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 868 | HGDIOBJ16 WINAPI SelectObject16( HDC16 hdc, HGDIOBJ16 handle ) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 869 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 870 | return (HGDIOBJ16)SelectObject( hdc, handle ); |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | |
| 874 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 875 | * SelectObject (GDI32.299) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 876 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 877 | HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ handle ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 878 | { |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 879 | HGDIOBJ ret = 0; |
| 880 | DC * dc = DC_GetDCUpdate( hdc ); |
| 881 | if (!dc) return 0; |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 882 | TRACE("hdc=%04x %04x\n", hdc, handle ); |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 883 | if (dc->funcs->pSelectObject) |
| 884 | ret = dc->funcs->pSelectObject( dc, handle ); |
| 885 | GDI_ReleaseObj( hdc ); |
| 886 | return ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 887 | } |
| 888 | |
| 889 | |
| 890 | /*********************************************************************** |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 891 | * UnrealizeObject16 (GDI.150) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 892 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 893 | BOOL16 WINAPI UnrealizeObject16( HGDIOBJ16 obj ) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 894 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 895 | return UnrealizeObject( obj ); |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | |
| 899 | /*********************************************************************** |
| 900 | * UnrealizeObject (GDI32.358) |
| 901 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 902 | BOOL WINAPI UnrealizeObject( HGDIOBJ obj ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 903 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 904 | BOOL result = TRUE; |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 905 | /* Check if object is valid */ |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 906 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 907 | GDIOBJHDR * header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 908 | if (!header) return FALSE; |
| 909 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 910 | TRACE("%04x\n", obj ); |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 911 | |
| 912 | /* Unrealize object */ |
| 913 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 914 | switch(GDIMAGIC(header->wMagic)) |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 915 | { |
| 916 | case PALETTE_MAGIC: |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 917 | result = PALETTE_UnrealizeObject( obj, (PALETTEOBJ *)header ); |
| 918 | break; |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 919 | |
| 920 | case BRUSH_MAGIC: |
| 921 | /* Windows resets the brush origin. We don't need to. */ |
| 922 | break; |
| 923 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 924 | GDI_ReleaseObj( obj ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 925 | return result; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 926 | } |
Alexandre Julliard | 1f57929 | 1994-05-25 16:25:21 +0000 | [diff] [blame] | 927 | |
| 928 | |
| 929 | /*********************************************************************** |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 930 | * EnumObjects16 (GDI.71) |
Alexandre Julliard | 1f57929 | 1994-05-25 16:25:21 +0000 | [diff] [blame] | 931 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 932 | INT16 WINAPI EnumObjects16( HDC16 hdc, INT16 nObjType, |
| 933 | GOBJENUMPROC16 lpEnumFunc, LPARAM lParam ) |
Alexandre Julliard | 1f57929 | 1994-05-25 16:25:21 +0000 | [diff] [blame] | 934 | { |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 935 | /* Solid colors to enumerate */ |
| 936 | static const COLORREF solid_colors[] = |
| 937 | { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff), |
| 938 | RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00), |
| 939 | RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00), |
| 940 | RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff), |
| 941 | RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00), |
| 942 | RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80), |
| 943 | RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80), |
| 944 | RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0) |
| 945 | }; |
| 946 | |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 947 | INT16 i, retval = 0; |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 948 | LOGPEN16 *pen; |
| 949 | LOGBRUSH16 *brush = NULL; |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 950 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 951 | TRACE("%04x %d %08lx %08lx\n", |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 952 | hdc, nObjType, (DWORD)lpEnumFunc, lParam ); |
| 953 | switch(nObjType) |
| 954 | { |
| 955 | case OBJ_PEN: |
| 956 | /* Enumerate solid pens */ |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 957 | if (!(pen = SEGPTR_NEW(LOGPEN16))) break; |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 958 | for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++) |
| 959 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 960 | pen->lopnStyle = PS_SOLID; |
| 961 | pen->lopnWidth.x = 1; |
| 962 | pen->lopnWidth.y = 0; |
| 963 | pen->lopnColor = solid_colors[i]; |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 964 | retval = lpEnumFunc( SEGPTR_GET(pen), lParam ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 965 | TRACE("solid pen %08lx, ret=%d\n", |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 966 | solid_colors[i], retval); |
| 967 | if (!retval) break; |
| 968 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 969 | SEGPTR_FREE(pen); |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 970 | break; |
| 971 | |
| 972 | case OBJ_BRUSH: |
| 973 | /* Enumerate solid brushes */ |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 974 | if (!(brush = SEGPTR_NEW(LOGBRUSH16))) break; |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 975 | for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++) |
| 976 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 977 | brush->lbStyle = BS_SOLID; |
| 978 | brush->lbColor = solid_colors[i]; |
| 979 | brush->lbHatch = 0; |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 980 | retval = lpEnumFunc( SEGPTR_GET(brush), lParam ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 981 | TRACE("solid brush %08lx, ret=%d\n", |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 982 | solid_colors[i], retval); |
| 983 | if (!retval) break; |
| 984 | } |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 985 | |
| 986 | /* Now enumerate hatched brushes */ |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 987 | if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++) |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 988 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 989 | brush->lbStyle = BS_HATCHED; |
| 990 | brush->lbColor = RGB(0,0,0); |
| 991 | brush->lbHatch = i; |
Alexandre Julliard | f1aa303 | 1996-08-05 17:42:43 +0000 | [diff] [blame] | 992 | retval = lpEnumFunc( SEGPTR_GET(brush), lParam ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 993 | TRACE("hatched brush %d, ret=%d\n", |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 994 | i, retval); |
| 995 | if (!retval) break; |
| 996 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 997 | SEGPTR_FREE(brush); |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 998 | break; |
| 999 | |
| 1000 | default: |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1001 | WARN("(%d): Invalid type\n", nObjType ); |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1002 | break; |
| 1003 | } |
| 1004 | return retval; |
| 1005 | } |
| 1006 | |
| 1007 | |
| 1008 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1009 | * EnumObjects (GDI32.89) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1010 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1011 | INT WINAPI EnumObjects( HDC hdc, INT nObjType, |
| 1012 | GOBJENUMPROC lpEnumFunc, LPARAM lParam ) |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1013 | { |
| 1014 | /* Solid colors to enumerate */ |
| 1015 | static const COLORREF solid_colors[] = |
| 1016 | { RGB(0x00,0x00,0x00), RGB(0xff,0xff,0xff), |
| 1017 | RGB(0xff,0x00,0x00), RGB(0x00,0xff,0x00), |
| 1018 | RGB(0x00,0x00,0xff), RGB(0xff,0xff,0x00), |
| 1019 | RGB(0xff,0x00,0xff), RGB(0x00,0xff,0xff), |
| 1020 | RGB(0x80,0x00,0x00), RGB(0x00,0x80,0x00), |
| 1021 | RGB(0x80,0x80,0x00), RGB(0x00,0x00,0x80), |
| 1022 | RGB(0x80,0x00,0x80), RGB(0x00,0x80,0x80), |
| 1023 | RGB(0x80,0x80,0x80), RGB(0xc0,0xc0,0xc0) |
| 1024 | }; |
| 1025 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1026 | INT i, retval = 0; |
| 1027 | LOGPEN pen; |
| 1028 | LOGBRUSH brush; |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1029 | |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1030 | TRACE("%04x %d %08lx %08lx\n", |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1031 | hdc, nObjType, (DWORD)lpEnumFunc, lParam ); |
| 1032 | switch(nObjType) |
| 1033 | { |
| 1034 | case OBJ_PEN: |
| 1035 | /* Enumerate solid pens */ |
| 1036 | for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++) |
| 1037 | { |
| 1038 | pen.lopnStyle = PS_SOLID; |
| 1039 | pen.lopnWidth.x = 1; |
| 1040 | pen.lopnWidth.y = 0; |
| 1041 | pen.lopnColor = solid_colors[i]; |
| 1042 | retval = lpEnumFunc( &pen, lParam ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1043 | TRACE("solid pen %08lx, ret=%d\n", |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1044 | solid_colors[i], retval); |
| 1045 | if (!retval) break; |
| 1046 | } |
| 1047 | break; |
| 1048 | |
| 1049 | case OBJ_BRUSH: |
| 1050 | /* Enumerate solid brushes */ |
| 1051 | for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++) |
| 1052 | { |
| 1053 | brush.lbStyle = BS_SOLID; |
| 1054 | brush.lbColor = solid_colors[i]; |
| 1055 | brush.lbHatch = 0; |
| 1056 | retval = lpEnumFunc( &brush, lParam ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1057 | TRACE("solid brush %08lx, ret=%d\n", |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1058 | solid_colors[i], retval); |
| 1059 | if (!retval) break; |
| 1060 | } |
| 1061 | |
| 1062 | /* Now enumerate hatched brushes */ |
| 1063 | if (retval) for (i = HS_HORIZONTAL; i <= HS_DIAGCROSS; i++) |
| 1064 | { |
| 1065 | brush.lbStyle = BS_HATCHED; |
| 1066 | brush.lbColor = RGB(0,0,0); |
| 1067 | brush.lbHatch = i; |
| 1068 | retval = lpEnumFunc( &brush, lParam ); |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1069 | TRACE("hatched brush %d, ret=%d\n", |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 1070 | i, retval); |
| 1071 | if (!retval) break; |
| 1072 | } |
| 1073 | break; |
| 1074 | |
| 1075 | default: |
| 1076 | /* FIXME: implement Win32 types */ |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1077 | WARN("(%d): Invalid type\n", nObjType ); |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 1078 | break; |
| 1079 | } |
| 1080 | return retval; |
Alexandre Julliard | 1f57929 | 1994-05-25 16:25:21 +0000 | [diff] [blame] | 1081 | } |
Alexandre Julliard | 7cc9c0c | 1994-06-15 15:45:11 +0000 | [diff] [blame] | 1082 | |
Alexandre Julliard | d7d4fdf | 1995-12-26 15:05:24 +0000 | [diff] [blame] | 1083 | |
Alexandre Julliard | 7cc9c0c | 1994-06-15 15:45:11 +0000 | [diff] [blame] | 1084 | /*********************************************************************** |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1085 | * IsGDIObject (GDI.462) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1086 | * |
| 1087 | * returns type of object if valid (W95 system programming secrets p. 264-5) |
Alexandre Julliard | 7cc9c0c | 1994-06-15 15:45:11 +0000 | [diff] [blame] | 1088 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1089 | BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle ) |
Alexandre Julliard | 7cc9c0c | 1994-06-15 15:45:11 +0000 | [diff] [blame] | 1090 | { |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1091 | UINT16 magic = 0; |
| 1092 | |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 1093 | GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE ); |
| 1094 | if (object) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1095 | { |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 1096 | magic = GDIMAGIC(object->wMagic) - PEN_MAGIC + 1; |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 1097 | GDI_ReleaseObj( handle ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1098 | } |
Alexandre Julliard | 2a2321b | 2000-08-19 21:38:55 +0000 | [diff] [blame] | 1099 | return magic; |
Alexandre Julliard | 7cc9c0c | 1994-06-15 15:45:11 +0000 | [diff] [blame] | 1100 | } |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1101 | |
| 1102 | |
| 1103 | /*********************************************************************** |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1104 | * SetObjectOwner16 (GDI.461) |
| 1105 | */ |
| 1106 | void WINAPI SetObjectOwner16( HGDIOBJ16 handle, HANDLE16 owner ) |
| 1107 | { |
| 1108 | /* Nothing to do */ |
| 1109 | } |
| 1110 | |
| 1111 | |
| 1112 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 1113 | * SetObjectOwner (GDI32.386) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1114 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1115 | void WINAPI SetObjectOwner( HGDIOBJ handle, HANDLE owner ) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1116 | { |
| 1117 | /* Nothing to do */ |
| 1118 | } |
| 1119 | |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 1120 | |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1121 | /*********************************************************************** |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1122 | * MakeObjectPrivate (GDI.463) |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 1123 | * |
| 1124 | * What does that mean ? |
| 1125 | * Some little docu can be found in "Undocumented Windows", |
| 1126 | * but this is basically useless. |
| 1127 | * At least we know that this flags the GDI object's wMagic |
| 1128 | * with 0x2000 (OBJECT_PRIVATE), so we just do it. |
| 1129 | * But Wine doesn't react on that yet. |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1130 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1131 | void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle, BOOL16 private ) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1132 | { |
Andreas Mohr | 007fb24 | 2000-09-16 20:53:51 +0000 | [diff] [blame] | 1133 | GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE ); |
| 1134 | if (!ptr) |
| 1135 | { |
| 1136 | ERR("invalid GDI object %04x !\n", handle); |
| 1137 | return; |
| 1138 | } |
| 1139 | ptr->wMagic |= OBJECT_PRIVATE; |
| 1140 | GDI_ReleaseObj( handle ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | |
| 1144 | /*********************************************************************** |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1145 | * GdiFlush (GDI32.128) |
| 1146 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1147 | BOOL WINAPI GdiFlush(void) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 1148 | { |
| 1149 | return TRUE; /* FIXME */ |
| 1150 | } |
| 1151 | |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 1152 | |
| 1153 | /*********************************************************************** |
| 1154 | * GdiGetBatchLimit (GDI32.129) |
| 1155 | */ |
| 1156 | DWORD WINAPI GdiGetBatchLimit(void) |
| 1157 | { |
| 1158 | return 1; /* FIXME */ |
| 1159 | } |
| 1160 | |
| 1161 | |
| 1162 | /*********************************************************************** |
| 1163 | * GdiSetBatchLimit (GDI32.139) |
| 1164 | */ |
| 1165 | DWORD WINAPI GdiSetBatchLimit( DWORD limit ) |
| 1166 | { |
| 1167 | return 1; /* FIXME */ |
| 1168 | } |
| 1169 | |
| 1170 | |
| 1171 | /*********************************************************************** |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 1172 | * GdiSeeGdiDo (GDI.452) |
| 1173 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1174 | DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2, |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 1175 | WORD wParam3 ) |
| 1176 | { |
| 1177 | switch (wReqType) |
| 1178 | { |
| 1179 | case 0x0001: /* LocalAlloc */ |
| 1180 | return LOCAL_Alloc( GDI_HeapSel, wParam1, wParam3 ); |
| 1181 | case 0x0002: /* LocalFree */ |
| 1182 | return LOCAL_Free( GDI_HeapSel, wParam1 ); |
| 1183 | case 0x0003: /* LocalCompact */ |
| 1184 | return LOCAL_Compact( GDI_HeapSel, wParam3, 0 ); |
| 1185 | case 0x0103: /* LocalHeap */ |
| 1186 | return GDI_HeapSel; |
| 1187 | default: |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1188 | WARN("(wReqType=%04x): Unknown\n", wReqType); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 1189 | return (DWORD)-1; |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | /*********************************************************************** |
Ulrich Weigand | 466cd44 | 1999-04-01 11:46:02 +0000 | [diff] [blame] | 1194 | * GdiSignalProc (GDI.610) |
| 1195 | */ |
| 1196 | WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID, |
| 1197 | DWORD dwFlags, HMODULE16 hModule ) |
| 1198 | { |
| 1199 | return 0; |
| 1200 | } |
| 1201 | |
Ulrich Weigand | 98c3053 | 1999-07-27 17:10:06 +0000 | [diff] [blame] | 1202 | /*********************************************************************** |
| 1203 | * FinalGdiInit16 (GDI.405) |
| 1204 | */ |
| 1205 | void WINAPI FinalGdiInit16( HANDLE16 unknown ) |
| 1206 | { |
| 1207 | } |
Ulrich Weigand | 466cd44 | 1999-04-01 11:46:02 +0000 | [diff] [blame] | 1208 | |
| 1209 | /*********************************************************************** |
Ulrich Weigand | 87dbaa9 | 1998-12-01 13:00:05 +0000 | [diff] [blame] | 1210 | * GdiFreeResources (GDI.609) |
| 1211 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1212 | WORD WINAPI GdiFreeResources16( DWORD reserve ) |
Ulrich Weigand | 87dbaa9 | 1998-12-01 13:00:05 +0000 | [diff] [blame] | 1213 | { |
| 1214 | return (WORD)( (int)LOCAL_CountFree( GDI_HeapSel ) * 100 / |
| 1215 | (int)LOCAL_HeapSize( GDI_HeapSel ) ); |
| 1216 | } |
| 1217 | |
| 1218 | /*********************************************************************** |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1219 | * MulDiv16 (GDI.128) |
| 1220 | */ |
Rein Klazes | ad5d10f | 2000-03-12 21:12:38 +0000 | [diff] [blame] | 1221 | INT16 WINAPI MulDiv16( |
| 1222 | INT16 nMultiplicand, |
| 1223 | INT16 nMultiplier, |
| 1224 | INT16 nDivisor) |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1225 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1226 | INT ret; |
Rein Klazes | ad5d10f | 2000-03-12 21:12:38 +0000 | [diff] [blame] | 1227 | if (!nDivisor) return -32768; |
| 1228 | /* We want to deal with a positive divisor to simplify the logic. */ |
| 1229 | if (nDivisor < 0) |
| 1230 | { |
| 1231 | nMultiplicand = - nMultiplicand; |
| 1232 | nDivisor = -nDivisor; |
| 1233 | } |
| 1234 | /* If the result is positive, we "add" to round. else, |
| 1235 | * we subtract to round. */ |
| 1236 | if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) || |
| 1237 | ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) ) |
| 1238 | ret = (((int)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor; |
| 1239 | else |
| 1240 | ret = (((int)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor; |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1241 | if ((ret > 32767) || (ret < -32767)) return -32768; |
Rein Klazes | ad5d10f | 2000-03-12 21:12:38 +0000 | [diff] [blame] | 1242 | return (INT16) ret; |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1246 | /******************************************************************* |
| 1247 | * GetColorAdjustment [GDI32.164] |
| 1248 | * |
| 1249 | * |
| 1250 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1251 | BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1252 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1253 | FIXME("GetColorAdjustment, stub\n"); |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1254 | return 0; |
| 1255 | } |
| 1256 | |
| 1257 | /******************************************************************* |
| 1258 | * GetMiterLimit [GDI32.201] |
| 1259 | * |
| 1260 | * |
| 1261 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1262 | BOOL WINAPI GetMiterLimit(HDC hdc, PFLOAT peLimit) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1263 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1264 | FIXME("GetMiterLimit, stub\n"); |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1265 | return 0; |
| 1266 | } |
| 1267 | |
| 1268 | /******************************************************************* |
| 1269 | * SetMiterLimit [GDI32.325] |
| 1270 | * |
| 1271 | * |
| 1272 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1273 | BOOL WINAPI SetMiterLimit(HDC hdc, FLOAT eNewLimit, PFLOAT peOldLimit) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1274 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1275 | FIXME("SetMiterLimit, stub\n"); |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1276 | return 0; |
| 1277 | } |
| 1278 | |
| 1279 | /******************************************************************* |
| 1280 | * GdiComment [GDI32.109] |
| 1281 | * |
| 1282 | * |
| 1283 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1284 | BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1285 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1286 | FIXME("GdiComment, stub\n"); |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1287 | return 0; |
| 1288 | } |
| 1289 | /******************************************************************* |
| 1290 | * SetColorAdjustment [GDI32.309] |
| 1291 | * |
| 1292 | * |
| 1293 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1294 | BOOL WINAPI SetColorAdjustment(HDC hdc, const COLORADJUSTMENT* lpca) |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1295 | { |
Alexandre Julliard | 1565709 | 1999-05-23 10:25:25 +0000 | [diff] [blame] | 1296 | FIXME("SetColorAdjustment, stub\n"); |
Paul Quinn | 1beaae5 | 1998-12-15 15:38:36 +0000 | [diff] [blame] | 1297 | return 0; |
| 1298 | } |
| 1299 | |