3 * Copyright (C) 2007 Google (Evan Stade)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "gdiplus_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus
);
35 GpStatus WINGDIPAPI
GdipCreateStringFormat(INT attr
, LANGID lang
,
36 GpStringFormat
**format
)
39 return InvalidParameter
;
41 *format
= GdipAlloc(sizeof(GpStringFormat
));
42 if(!*format
) return OutOfMemory
;
44 (*format
)->attr
= attr
;
45 (*format
)->lang
= lang
;
46 (*format
)->digitlang
= LANG_NEUTRAL
;
47 (*format
)->trimming
= StringTrimmingCharacter
;
48 (*format
)->digitsub
= StringDigitSubstituteUser
;
50 (*format
)->tabcount
= 0;
51 (*format
)->firsttab
= 0.0;
52 (*format
)->tabs
= NULL
;
57 GpStatus WINGDIPAPI
GdipDeleteStringFormat(GpStringFormat
*format
)
60 return InvalidParameter
;
62 GdipFree(format
->tabs
);
68 GpStatus WINGDIPAPI
GdipStringFormatGetGenericDefault(GpStringFormat
**format
)
73 return InvalidParameter
;
75 stat
= GdipCreateStringFormat(0, LANG_NEUTRAL
, format
);
79 (*format
)->align
= StringAlignmentNear
;
80 (*format
)->vertalign
= StringAlignmentNear
;
85 GpStatus WINGDIPAPI
GdipGetStringFormatAlign(GpStringFormat
*format
,
86 StringAlignment
*align
)
89 return InvalidParameter
;
91 *align
= format
->align
;
96 GpStatus WINGDIPAPI
GdipGetStringFormatDigitSubstitution(GDIPCONST GpStringFormat
*format
,
97 LANGID
*language
, StringDigitSubstitute
*substitute
)
100 return InvalidParameter
;
102 if(language
) *language
= format
->digitlang
;
103 if(substitute
) *substitute
= format
->digitsub
;
108 GpStatus WINGDIPAPI
GdipGetStringFormatFlags(GDIPCONST GpStringFormat
* format
,
111 if (!(format
&& flags
))
112 return InvalidParameter
;
114 *flags
= format
->attr
;
119 GpStatus WINGDIPAPI
GdipGetStringFormatHotkeyPrefix(GDIPCONST GpStringFormat
123 return InvalidParameter
;
125 *hkpx
= (INT
)format
->hkprefix
;
130 GpStatus WINGDIPAPI
GdipGetStringFormatLineAlign(GpStringFormat
*format
,
131 StringAlignment
*align
)
133 if(!format
|| !align
)
134 return InvalidParameter
;
136 *align
= format
->vertalign
;
141 GpStatus WINGDIPAPI
GdipGetStringFormatMeasurableCharacterRangeCount(
142 GDIPCONST GpStringFormat
* format
, INT
* count
)
144 if (!(format
&& count
))
145 return InvalidParameter
;
147 FIXME("stub: %p %p\n", format
, count
);
149 return NotImplemented
;
152 GpStatus WINGDIPAPI
GdipGetStringFormatTabStopCount(GDIPCONST GpStringFormat
*format
,
155 if(!format
|| !count
)
156 return InvalidParameter
;
158 *count
= format
->tabcount
;
163 GpStatus WINGDIPAPI
GdipGetStringFormatTabStops(GDIPCONST GpStringFormat
*format
, INT count
,
164 REAL
*firsttab
, REAL
*tabs
)
166 if(!format
|| !firsttab
|| !tabs
)
167 return InvalidParameter
;
169 /* native simply crashes on count < 0 */
171 memcpy(tabs
, format
->tabs
, sizeof(REAL
)*count
);
173 *firsttab
= format
->firsttab
;
178 GpStatus WINGDIPAPI
GdipGetStringFormatTrimming(GpStringFormat
*format
,
179 StringTrimming
*trimming
)
181 if(!format
|| !trimming
)
182 return InvalidParameter
;
184 *trimming
= format
->trimming
;
189 GpStatus WINGDIPAPI
GdipSetStringFormatAlign(GpStringFormat
*format
,
190 StringAlignment align
)
193 return InvalidParameter
;
195 format
->align
= align
;
200 /*FIXME: digit substitution actually not implemented, get/set only */
201 GpStatus WINGDIPAPI
GdipSetStringFormatDigitSubstitution(GpStringFormat
*format
,
202 LANGID language
, StringDigitSubstitute substitute
)
205 return InvalidParameter
;
207 format
->digitlang
= language
;
208 format
->digitsub
= substitute
;
213 GpStatus WINGDIPAPI
GdipSetStringFormatHotkeyPrefix(GpStringFormat
*format
,
216 if(!format
|| hkpx
< 0 || hkpx
> 2)
217 return InvalidParameter
;
219 format
->hkprefix
= (HotkeyPrefix
) hkpx
;
224 GpStatus WINGDIPAPI
GdipSetStringFormatLineAlign(GpStringFormat
*format
,
225 StringAlignment align
)
228 return InvalidParameter
;
230 format
->vertalign
= align
;
235 GpStatus WINGDIPAPI
GdipSetStringFormatMeasurableCharacterRanges(GpStringFormat
*
236 format
, INT rangeCount
, GDIPCONST CharacterRange
* ranges
)
238 if (!(format
&& rangeCount
&& ranges
))
239 return InvalidParameter
;
241 FIXME("stub: %p, %d, %p\n", format
, rangeCount
, ranges
);
243 return NotImplemented
;
246 GpStatus WINGDIPAPI
GdipSetStringFormatTabStops(GpStringFormat
*format
, REAL firsttab
,
247 INT count
, GDIPCONST REAL
*tabs
)
250 return InvalidParameter
;
253 if(firsttab
< 0.0) return NotImplemented
;
254 /* first time allocation */
255 if(format
->tabcount
== 0){
256 format
->tabs
= GdipAlloc(sizeof(REAL
)*count
);
261 if((format
->tabcount
< count
) && (format
->tabcount
> 0)){
263 ptr
= HeapReAlloc(GetProcessHeap(), 0, format
->tabs
, sizeof(REAL
)*count
);
268 format
->firsttab
= firsttab
;
269 format
->tabcount
= count
;
270 memcpy(format
->tabs
, tabs
, sizeof(REAL
)*count
);
276 GpStatus WINGDIPAPI
GdipSetStringFormatTrimming(GpStringFormat
*format
,
277 StringTrimming trimming
)
280 return InvalidParameter
;
282 format
->trimming
= trimming
;
287 GpStatus WINGDIPAPI
GdipSetStringFormatFlags(GDIPCONST GpStringFormat
*format
, INT flags
)
289 FIXME("format (%p) flags (%d)\n", format
, flags
);
294 GpStatus WINGDIPAPI
GdipCloneStringFormat(GDIPCONST GpStringFormat
*format
, GpStringFormat
**newFormat
)
296 if(!format
|| !newFormat
)
297 return InvalidParameter
;
299 *newFormat
= GdipAlloc(sizeof(GpStringFormat
));
300 if(!*newFormat
) return OutOfMemory
;
302 **newFormat
= *format
;
304 if(format
->tabcount
> 0){
305 (*newFormat
)->tabs
= GdipAlloc(sizeof(REAL
) * format
->tabcount
);
306 if(!(*newFormat
)->tabs
){
307 GdipFree(*newFormat
);
310 memcpy((*newFormat
)->tabs
, format
->tabs
, sizeof(REAL
) * format
->tabcount
);
313 (*newFormat
)->tabs
= NULL
;
315 TRACE("%p %p\n",format
,newFormat
);
320 GpStatus WINGDIPAPI
GdipStringFormatGetGenericTypographic(GpStringFormat
**format
)
325 return InvalidParameter
;
327 stat
= GdipCreateStringFormat(StringFormatFlagsNoFitBlackBox
|
328 StringFormatFlagsLineLimit
|
329 StringFormatFlagsNoClip
, LANG_NEUTRAL
, format
);
333 (*format
)->digitlang
= LANG_NEUTRAL
;
334 (*format
)->digitsub
= StringDigitSubstituteUser
;
335 (*format
)->trimming
= StringTrimmingNone
;
336 (*format
)->hkprefix
= HotkeyPrefixNone
;
337 (*format
)->align
= StringAlignmentNear
;
338 (*format
)->vertalign
= StringAlignmentNear
;