Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
gdiplusstringformat.h
00001 /* 00002 * gdiplusstringformat.h 00003 * 00004 * GDI+ StringFormat class 00005 * 00006 * This file is part of the w32api package. 00007 * 00008 * Contributors: 00009 * Created by Markus Koenig <markus@stber-koenig.de> 00010 * 00011 * THIS SOFTWARE IS NOT COPYRIGHTED 00012 * 00013 * This source code is offered for use in the public domain. You may 00014 * use, modify or distribute it freely. 00015 * 00016 * This code is distributed in the hope that it will be useful but 00017 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 00018 * DISCLAIMED. This includes but is not limited to warranties of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00020 * 00021 */ 00022 00023 #ifndef __GDIPLUS_STRINGFORMAT_H 00024 #define __GDIPLUS_STRINGFORMAT_H 00025 #if __GNUC__ >=3 00026 #pragma GCC system_header 00027 #endif 00028 00029 #ifndef __cplusplus 00030 #error "A C++ compiler is required to include gdiplusstringformat.h." 00031 #endif 00032 00033 class StringFormat: public GdiplusBase 00034 { 00035 friend class Graphics; 00036 friend class GraphicsPath; 00037 00038 public: 00039 static const StringFormat* GenericDefault(); 00040 static const StringFormat* GenericTypographic(); 00041 00042 StringFormat(INT formatFlags = 0, LANGID language = LANG_NEUTRAL): 00043 nativeStringFormat(NULL), lastStatus(Ok) 00044 { 00045 lastStatus = DllExports::GdipCreateStringFormat( 00046 formatFlags, language, &nativeStringFormat); 00047 } 00048 StringFormat(const StringFormat *format): 00049 nativeStringFormat(NULL), lastStatus(Ok) 00050 { 00051 lastStatus = DllExports::GdipCloneStringFormat( 00052 format ? format->nativeStringFormat : NULL, 00053 &nativeStringFormat); 00054 } 00055 ~StringFormat() 00056 { 00057 DllExports::GdipDeleteStringFormat(nativeStringFormat); 00058 } 00059 StringFormat* Clone() const 00060 { 00061 GpStringFormat *cloneStringFormat = NULL; 00062 Status status = updateStatus(DllExports::GdipCloneStringFormat( 00063 nativeStringFormat, &cloneStringFormat)); 00064 if (status == Ok) { 00065 StringFormat *result = new StringFormat( 00066 cloneStringFormat, lastStatus); 00067 if (!result) { 00068 DllExports::GdipDeleteStringFormat(cloneStringFormat); 00069 lastStatus = OutOfMemory; 00070 } 00071 return result; 00072 } else { 00073 return NULL; 00074 } 00075 } 00076 00077 StringAlignment GetAlignment() const 00078 { 00079 StringAlignment result = StringAlignmentNear; 00080 updateStatus(DllExports::GdipGetStringFormatAlign( 00081 nativeStringFormat, &result)); 00082 return result; 00083 } 00084 LANGID GetDigitSubstitutionLanguage() const 00085 { 00086 LANGID result = 0; 00087 StringDigitSubstitute method; 00088 updateStatus(DllExports::GdipGetStringFormatDigitSubstitution( 00089 nativeStringFormat, &result, &method)); 00090 return result; 00091 } 00092 StringDigitSubstitute GetDigitSubstitutionMethod() const 00093 { 00094 LANGID language; 00095 StringDigitSubstitute result = StringDigitSubstituteUser; 00096 updateStatus(DllExports::GdipGetStringFormatDigitSubstitution( 00097 nativeStringFormat, &language, &result)); 00098 return result; 00099 } 00100 INT GetFormatFlags() const 00101 { 00102 INT result = 0; 00103 updateStatus(DllExports::GdipGetStringFormatFlags( 00104 nativeStringFormat, &result)); 00105 return result; 00106 } 00107 HotkeyPrefix GetHotkeyPrefix() const 00108 { 00109 HotkeyPrefix result = HotkeyPrefixNone; 00110 updateStatus(DllExports::GdipGetStringFormatHotkeyPrefix( 00111 nativeStringFormat, (INT*) &result)); 00112 return result; 00113 } 00114 Status GetLastStatus() const 00115 { 00116 Status result = lastStatus; 00117 lastStatus = Ok; 00118 return result; 00119 } 00120 StringAlignment GetLineAlignment() const 00121 { 00122 StringAlignment result = StringAlignmentNear; 00123 updateStatus(DllExports::GdipGetStringFormatLineAlign( 00124 nativeStringFormat, &result)); 00125 return result; 00126 } 00127 INT GetMeasurableCharacterRangeCount() const 00128 { 00129 INT result = 0; 00130 updateStatus(DllExports::GdipGetStringFormatMeasurableCharacterRangeCount( 00131 nativeStringFormat, &result)); 00132 return result; 00133 } 00134 INT GetTabStopCount() const 00135 { 00136 INT result = 0; 00137 updateStatus(DllExports::GdipGetStringFormatTabStopCount( 00138 nativeStringFormat, &result)); 00139 return result; 00140 } 00141 Status GetTabStops(INT count, REAL *firstTabOffset, REAL *tabStops) 00142 { 00143 return updateStatus(DllExports::GdipGetStringFormatTabStops( 00144 nativeStringFormat, count, 00145 firstTabOffset, tabStops)); 00146 } 00147 StringTrimming GetTrimming() const 00148 { 00149 StringTrimming result = StringTrimmingNone; 00150 updateStatus(DllExports::GdipGetStringFormatTrimming( 00151 nativeStringFormat, &result)); 00152 return result; 00153 } 00154 Status SetAlignment(StringAlignment align) 00155 { 00156 return updateStatus(DllExports::GdipSetStringFormatAlign( 00157 nativeStringFormat, align)); 00158 } 00159 Status SetDigitSubstitution(LANGID language, 00160 StringDigitSubstitute substitute) 00161 { 00162 return updateStatus(DllExports::GdipSetStringFormatDigitSubstitution( 00163 nativeStringFormat, language, substitute)); 00164 } 00165 Status SetFormatFlags(INT flags) 00166 { 00167 return updateStatus(DllExports::GdipSetStringFormatFlags( 00168 nativeStringFormat, flags)); 00169 } 00170 Status SetHotkeyPrefix(HotkeyPrefix hotkeyPrefix) 00171 { 00172 return updateStatus(DllExports::GdipSetStringFormatHotkeyPrefix( 00173 nativeStringFormat, (INT) hotkeyPrefix)); 00174 } 00175 Status SetLineAlignment(StringAlignment align) 00176 { 00177 return updateStatus(DllExports::GdipSetStringFormatLineAlign( 00178 nativeStringFormat, align)); 00179 } 00180 Status SetMeasurableCharacterRanges(INT rangeCount, 00181 const CharacterRange *ranges) 00182 { 00183 return updateStatus(DllExports::GdipSetStringFormatMeasurableCharacterRanges( 00184 nativeStringFormat, rangeCount, ranges)); 00185 } 00186 Status SetTabStops(REAL firstTabOffset, INT count, const REAL *tabStops) 00187 { 00188 return updateStatus(DllExports::GdipSetStringFormatTabStops( 00189 nativeStringFormat, firstTabOffset, 00190 count, tabStops)); 00191 } 00192 Status SetTrimming(StringTrimming trimming) 00193 { 00194 return updateStatus(DllExports::GdipSetStringFormatTrimming( 00195 nativeStringFormat, trimming)); 00196 } 00197 00198 private: 00199 StringFormat(GpStringFormat *stringFormat, Status status): 00200 nativeStringFormat(stringFormat), lastStatus(status) {} 00201 StringFormat(const StringFormat&); 00202 StringFormat& operator=(const StringFormat&); 00203 00204 Status updateStatus(Status newStatus) const 00205 { 00206 if (newStatus != Ok) lastStatus = newStatus; 00207 return newStatus; 00208 } 00209 00210 GpStringFormat *nativeStringFormat; 00211 mutable Status lastStatus; 00212 }; 00213 00214 00215 // FIXME: do StringFormat::GenericDefault() et al. need to be thread safe? 00216 // FIXME: maybe put this in gdiplus.c? 00217 00218 extern "C" void *_GdipStringFormatCachedGenericDefault; 00219 extern "C" void *_GdipStringFormatCachedGenericTypographic; 00220 00221 __inline__ const StringFormat* StringFormat::GenericDefault() 00222 { 00223 if (!_GdipStringFormatCachedGenericDefault) { 00224 GpStringFormat *nativeStringFormat = 0; 00225 Status status = DllExports::GdipStringFormatGetGenericDefault( 00226 &nativeStringFormat); 00227 if (status == Ok && nativeStringFormat) { 00228 _GdipStringFormatCachedGenericDefault = (void*) 00229 new StringFormat(nativeStringFormat, Ok); 00230 } 00231 } 00232 return (StringFormat*) _GdipStringFormatCachedGenericDefault; 00233 } 00234 00235 __inline__ const StringFormat* StringFormat::GenericTypographic() 00236 { 00237 if (!_GdipStringFormatCachedGenericTypographic) { 00238 GpStringFormat *nativeStringFormat = 0; 00239 Status status = DllExports::GdipStringFormatGetGenericTypographic( 00240 &nativeStringFormat); 00241 if (status == Ok && nativeStringFormat) { 00242 _GdipStringFormatCachedGenericTypographic = (void*) 00243 new StringFormat(nativeStringFormat, Ok); 00244 } 00245 } 00246 return (StringFormat*) _GdipStringFormatCachedGenericTypographic; 00247 } 00248 00249 00250 00251 #endif /* __GDIPLUS_STRINGFORMAT_H */
Generated on Tue Jul 12 2022 19:59:54 by
1.7.2