[WIN32K:NTUSER] Correctly delete menus in failure cases in MENU_GetSystemMenu. CORE...
[reactos.git] / win32ss / gdi / gdi32 / objects / icm.c
1 #include <precomp.h>
2
3 #define NDEBUG
4 #include <debug.h>
5
6
7 HCOLORSPACE
8 FASTCALL
9 IntCreateColorSpaceW(
10 LPLOGCOLORSPACEW lplcpw,
11 BOOL Ascii
12 )
13 {
14 LOGCOLORSPACEEXW lcpeexw;
15
16 if ((lplcpw->lcsSignature != LCS_SIGNATURE) ||
17 (lplcpw->lcsVersion != 0x400) ||
18 (lplcpw->lcsSize != sizeof(LOGCOLORSPACEW)))
19 {
20 SetLastError(ERROR_INVALID_COLORSPACE);
21 return NULL;
22 }
23 RtlCopyMemory(&lcpeexw.lcsColorSpace, lplcpw, sizeof(LOGCOLORSPACEW));
24
25 return NtGdiCreateColorSpace(&lcpeexw);
26 }
27
28 /*
29 * @implemented
30 */
31 HCOLORSPACE
32 WINAPI
33 CreateColorSpaceW(
34 LPLOGCOLORSPACEW lplcpw
35 )
36 {
37 return IntCreateColorSpaceW(lplcpw, FALSE);
38 }
39
40
41 /*
42 * @implemented
43 */
44 HCOLORSPACE
45 WINAPI
46 CreateColorSpaceA(
47 LPLOGCOLORSPACEA lplcpa
48 )
49 {
50 LOGCOLORSPACEW lcpw;
51
52 if ((lplcpa->lcsSignature != LCS_SIGNATURE) ||
53 (lplcpa->lcsVersion != 0x400) ||
54 (lplcpa->lcsSize != sizeof(LOGCOLORSPACEA)))
55 {
56 SetLastError(ERROR_INVALID_COLORSPACE);
57 return NULL;
58 }
59
60 lcpw.lcsSignature = lplcpa->lcsSignature;
61 lcpw.lcsVersion = lplcpa->lcsVersion;
62 lcpw.lcsSize = sizeof(LOGCOLORSPACEW);
63 lcpw.lcsCSType = lplcpa->lcsCSType;
64 lcpw.lcsIntent = lplcpa->lcsIntent;
65 lcpw.lcsEndpoints = lplcpa->lcsEndpoints;
66 lcpw.lcsGammaRed = lplcpa->lcsGammaRed;
67 lcpw.lcsGammaGreen = lplcpa->lcsGammaGreen;
68 lcpw.lcsGammaBlue = lplcpa->lcsGammaBlue;
69
70 RtlMultiByteToUnicodeN( lcpw.lcsFilename,
71 MAX_PATH,
72 NULL,
73 lplcpa->lcsFilename,
74 strlen(lplcpa->lcsFilename) + 1);
75
76 return IntCreateColorSpaceW(&lcpw, FALSE);
77 }
78
79 /*
80 * @implemented
81 */
82 HCOLORSPACE
83 WINAPI
84 GetColorSpace(HDC hDC)
85 {
86 PDC_ATTR pDc_Attr;
87
88 if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
89 {
90 SetLastError(ERROR_INVALID_HANDLE);
91 return NULL;
92 }
93 return pDc_Attr->hColorSpace;
94 }
95
96
97 /*
98 * @implemented
99 */
100 HCOLORSPACE
101 WINAPI
102 SetColorSpace(
103 HDC hDC,
104 HCOLORSPACE hCS
105 )
106 {
107 HCOLORSPACE rhCS = GetColorSpace(hDC);
108
109 if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
110 {
111 if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
112 }
113 #if 0
114 if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
115 {
116 PLDC pLDC = GdiGetLDC(hDC);
117 if ( !pLDC )
118 {
119 SetLastError(ERROR_INVALID_HANDLE);
120 return NULL;
121 }
122 if (pLDC->iType == LDC_EMFLDC)
123 {
124 return NULL;
125 }
126 }
127 #endif
128 return NULL;
129 }
130
131
132 /*
133 * @unimplemented
134 */
135 BOOL
136 WINAPI
137 GetICMProfileA(
138 HDC hdc,
139 LPDWORD pBufSize,
140 LPSTR pszFilename
141 )
142 {
143 WCHAR filenameW[MAX_PATH];
144 DWORD buflen = MAX_PATH;
145 BOOL ret = FALSE;
146
147 if (!hdc || !pBufSize) return FALSE;
148
149 if (GetICMProfileW(hdc, &buflen, filenameW))
150 {
151 ULONG len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
152
153 if (!pszFilename)
154 {
155 *pBufSize = len;
156 return FALSE;
157 }
158
159 if (*pBufSize >= len)
160 {
161 WideCharToMultiByte(CP_ACP, 0, filenameW, -1, pszFilename, *pBufSize, NULL, NULL);
162 ret = TRUE;
163 }
164 else SetLastError(ERROR_INSUFFICIENT_BUFFER);
165 *pBufSize = len;
166 }
167
168 return ret;
169 }
170
171
172 /*
173 * @unimplemented
174 */
175 BOOL
176 WINAPI
177 GetICMProfileW(
178 HDC hdc,
179 LPDWORD size,
180 LPWSTR filename
181 )
182 {
183 if (!hdc || !size || !filename) return FALSE;
184
185 UNIMPLEMENTED;
186 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
187 return FALSE;
188 }
189
190
191 /*
192 * @unimplemented
193 */
194 BOOL
195 WINAPI
196 SetICMProfileA(
197 HDC a0,
198 LPSTR a1
199 )
200 {
201 UNIMPLEMENTED;
202 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
203 return FALSE;
204 }
205
206
207 /*
208 * @unimplemented
209 */
210 BOOL
211 WINAPI
212 SetICMProfileW(
213 HDC a0,
214 LPWSTR a1
215 )
216 {
217 UNIMPLEMENTED;
218 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
219 return FALSE;
220 }
221
222
223 /*
224 * @unimplemented
225 */
226 int
227 WINAPI
228 EnumICMProfilesA(
229 HDC a0,
230 ICMENUMPROCA a1,
231 LPARAM a2
232 )
233 {
234 /*
235 * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer
236 * to find out how big a buffer we need. Then allocate that buffer
237 * and call NtGdiEnumICMProfiles again to have the buffer filled.
238 *
239 * Finally, step through the buffer ( MULTI-SZ recommended for format ),
240 * and convert each string to ANSI, calling the user's callback function
241 * until we run out of strings or the user returns FALSE
242 */
243
244 UNIMPLEMENTED;
245 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
246 return 0;
247 }
248
249
250 /*
251 * @unimplemented
252 */
253 int
254 WINAPI
255 EnumICMProfilesW(
256 HDC hDC,
257 ICMENUMPROCW lpEnumICMProfilesFunc,
258 LPARAM lParam
259 )
260 {
261 /*
262 * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer
263 * to find out how big a buffer we need. Then allocate that buffer
264 * and call NtGdiEnumICMProfiles again to have the buffer filled.
265 *
266 * Finally, step through the buffer ( MULTI-SZ recommended for format ),
267 * and call the user's callback function until we run out of strings or
268 * the user returns FALSE
269 */
270 UNIMPLEMENTED;
271 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
272 return 0;
273 }
274
275
276 /*
277 * @unimplemented
278 */
279 BOOL
280 WINAPI
281 UpdateICMRegKeyA(
282 DWORD a0,
283 LPSTR a1,
284 LPSTR a2,
285 UINT a3
286 )
287 {
288 UNIMPLEMENTED;
289 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
290 return FALSE;
291 }
292
293
294 /*
295 * @unimplemented
296 */
297 BOOL
298 WINAPI
299 UpdateICMRegKeyW(
300 DWORD a0,
301 LPWSTR a1,
302 LPWSTR a2,
303 UINT a3
304 )
305 {
306 UNIMPLEMENTED;
307 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
308 return FALSE;
309 }
310
311 /*
312 * @unimplemented
313 */
314 int
315 WINAPI
316 SetICMMode(
317 HDC hdc,
318 int iEnableICM
319 )
320 {
321 /*FIXME: Assume that ICM is always off, and cannot be turned on */
322 if (iEnableICM == ICM_OFF) return ICM_OFF;
323 if (iEnableICM == ICM_ON) return 0;
324 if (iEnableICM == ICM_QUERY) return ICM_OFF;
325
326 UNIMPLEMENTED;
327 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
328 return 0;
329 }