blob: 77223ab96859fbf1d52c08d4d4eaea73c4de8f98 [file] [log] [blame]
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#ifndef _GDIPLUSSTRINGFORMAT_H
#define _GDIPLUSSTRINGFORMAT_H
class StringFormat : public GdiplusBase {
public:
friend class Graphics;
friend class GraphicsPath;
StringFormat(INT formatFlags = 0,LANGID language = LANG_NEUTRAL) {
nativeFormat = NULL;
lastError = DllExports::GdipCreateStringFormat(formatFlags,language,&nativeFormat);
}
static const StringFormat *GenericDefault();
static const StringFormat *GenericTypographic();
StringFormat(const StringFormat *format) {
nativeFormat = NULL;
lastError = DllExports::GdipCloneStringFormat(format ? format->nativeFormat : NULL,&nativeFormat);
}
StringFormat *Clone() const {
GpStringFormat *clonedStringFormat = NULL;
lastError = DllExports::GdipCloneStringFormat(nativeFormat,&clonedStringFormat);
if(lastError==Ok) return new StringFormat(clonedStringFormat,lastError);
return NULL;
}
~StringFormat() { DllExports::GdipDeleteStringFormat(nativeFormat); }
Status SetFormatFlags(INT flags) { return SetStatus(DllExports::GdipSetStringFormatFlags(nativeFormat,flags)); }
INT GetFormatFlags() const {
INT flags;
SetStatus(DllExports::GdipGetStringFormatFlags(nativeFormat,&flags));
return flags;
}
Status SetAlignment(StringAlignment align) { return SetStatus(DllExports::GdipSetStringFormatAlign(nativeFormat,align)); }
StringAlignment GetAlignment() const {
StringAlignment alignment;
SetStatus(DllExports::GdipGetStringFormatAlign(nativeFormat,&alignment));
return alignment;
}
Status SetLineAlignment(StringAlignment align) { return SetStatus(DllExports::GdipSetStringFormatLineAlign(nativeFormat,align)); }
StringAlignment GetLineAlignment() const {
StringAlignment alignment;
SetStatus(DllExports::GdipGetStringFormatLineAlign(nativeFormat,&alignment));
return alignment;
}
Status SetHotkeyPrefix(HotkeyPrefix hotkeyPrefix) { return SetStatus(DllExports::GdipSetStringFormatHotkeyPrefix(nativeFormat,(INT)hotkeyPrefix)); }
HotkeyPrefix GetHotkeyPrefix() const {
HotkeyPrefix hotkeyPrefix;
SetStatus(DllExports::GdipGetStringFormatHotkeyPrefix(nativeFormat,(INT*)&hotkeyPrefix));
return hotkeyPrefix;
}
Status SetTabStops(REAL firstTabOffset,INT count,const REAL *tabStops) { return SetStatus(DllExports::GdipSetStringFormatTabStops(nativeFormat,firstTabOffset,count,tabStops)); }
INT GetTabStopCount() const {
INT count;
SetStatus(DllExports::GdipGetStringFormatTabStopCount(nativeFormat,&count));
return count;
}
Status GetTabStops(INT count,REAL *firstTabOffset,REAL *tabStops) const { return SetStatus(DllExports::GdipGetStringFormatTabStops(nativeFormat,count,firstTabOffset,tabStops)); }
Status SetDigitSubstitution(LANGID language,StringDigitSubstitute substitute) { return SetStatus(DllExports::GdipSetStringFormatDigitSubstitution(nativeFormat,language,substitute)); }
LANGID GetDigitSubstitutionLanguage() const {
LANGID language;
SetStatus(DllExports::GdipGetStringFormatDigitSubstitution(nativeFormat,&language,NULL));
return language;
}
StringDigitSubstitute GetDigitSubstitutionMethod() const {
StringDigitSubstitute substitute;
SetStatus(DllExports::GdipGetStringFormatDigitSubstitution(nativeFormat,NULL,&substitute));
return substitute;
}
Status SetTrimming(StringTrimming trimming) { return SetStatus(DllExports::GdipSetStringFormatTrimming(nativeFormat,trimming)); }
StringTrimming StringFormat::GetTrimming() const {
StringTrimming trimming;
SetStatus(DllExports::GdipGetStringFormatTrimming(nativeFormat,&trimming));
return trimming;
}
Status SetMeasurableCharacterRanges(INT rangeCount,const CharacterRange *ranges) { return SetStatus(DllExports::GdipSetStringFormatMeasurableCharacterRanges(nativeFormat,rangeCount,ranges)); }
INT GetMeasurableCharacterRangeCount() {
INT count;
SetStatus(DllExports::GdipGetStringFormatMeasurableCharacterRangeCount(nativeFormat,&count));
return count;
}
Status GetLastStatus() const {
Status lastStatus = lastError;
lastError = Ok;
return lastStatus;
}
protected:
Status SetStatus(GpStatus newStatus) const {
if(newStatus==Ok) return Ok;
return lastError = newStatus;
}
StringFormat(const StringFormat &source) {
nativeFormat = NULL;
lastError = DllExports::GdipCloneStringFormat(source.nativeFormat,&nativeFormat);
}
StringFormat &operator=(const StringFormat &source) {
DllExports::GdipDeleteStringFormat(nativeFormat);
lastError = DllExports::GdipCloneStringFormat(source.nativeFormat,&nativeFormat);
return *this;
}
StringFormat(GpStringFormat *clonedStringFormat,Status status) {
lastError = status;
nativeFormat = clonedStringFormat;
}
GpStringFormat *nativeFormat;
mutable Status lastError;
};
static BYTE GenericTypographicStringFormatBuffer[sizeof(StringFormat)] = {0};
static BYTE GenericDefaultStringFormatBuffer[sizeof(StringFormat)] = {0};
inline const StringFormat *StringFormat::GenericDefault() {
StringFormat *genericDefaultStringFormat = (StringFormat*)GenericDefaultStringFormatBuffer;
genericDefaultStringFormat->lastError = DllExports::GdipStringFormatGetGenericDefault(&(genericDefaultStringFormat->nativeFormat));
return genericDefaultStringFormat;
}
inline const StringFormat *StringFormat::GenericTypographic() {
StringFormat *genericTypographicStringFormat = (StringFormat*)GenericTypographicStringFormatBuffer;
genericTypographicStringFormat->lastError = DllExports::GdipStringFormatGetGenericTypographic(&genericTypographicStringFormat->nativeFormat);
return genericTypographicStringFormat;
}
#endif