-
Notifications
You must be signed in to change notification settings - Fork 3
/
gdiplusstringformat.go
208 lines (170 loc) · 5.08 KB
/
gdiplusstringformat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package gdiplus
import (
. "github.com/tryor/winapi"
)
type StringFormat struct {
GdiplusBase
nativeFormat *GpStringFormat
}
func NewStringFormat() (*StringFormat, error) {
var formatFlags INT = 0
var language LANGID = LANG_NEUTRAL
return NewStringFormat2(formatFlags, language)
}
func NewStringFormat2(formatFlags INT, language LANGID) (*StringFormat, error) {
format := &StringFormat{}
format.setStatus(GdipCreateStringFormat(formatFlags, language, &format.nativeFormat))
return format, format.LastError
}
func NewStringFormat3(strfmt *StringFormat) (*StringFormat, error) {
format := &StringFormat{}
if strfmt == nil {
format.setStatus(InvalidParameter, nil)
return format, format.LastError
}
format.setStatus(GdipCloneStringFormat(
strfmt.nativeFormat,
&format.nativeFormat))
return format, format.LastError
}
func (this *StringFormat) Release() {
if this.nativeFormat != nil {
this.setStatus(GdipDeleteStringFormat(this.nativeFormat))
this.nativeFormat = nil
}
}
func (this *StringFormat) Clone() *StringFormat {
format := &StringFormat{}
status, _ := GdipCloneStringFormat(
this.nativeFormat, &format.nativeFormat)
if status == Ok {
return format
}
return nil
}
//StringFormatFlags
func (this *StringFormat) SetFormatFlags(flags INT) Status {
return this.setStatus(GdipSetStringFormatFlags(
this.nativeFormat,
flags))
}
func (this *StringFormat) GetFormatFlags() (flags INT) {
this.setStatus(GdipGetStringFormatFlags(this.nativeFormat, &flags))
return
}
func (this *StringFormat) SetAlignment(align StringAlignment) Status {
return this.setStatus(GdipSetStringFormatAlign(
this.nativeFormat,
align))
}
func (this *StringFormat) GetAlignment() (align StringAlignment) {
this.setStatus(GdipGetStringFormatAlign(
this.nativeFormat, &align))
return
}
func (this *StringFormat) SetLineAlignment(align StringAlignment) Status {
return this.setStatus(GdipSetStringFormatLineAlign(
this.nativeFormat,
align))
}
func (this *StringFormat) GetLineAlignment() (align StringAlignment) {
this.setStatus(GdipGetStringFormatLineAlign(
this.nativeFormat,
&align))
return
}
func (this *StringFormat) SetHotkeyPrefix(hotkeyPrefix HotkeyPrefix) Status {
return this.setStatus(GdipSetStringFormatHotkeyPrefix(
this.nativeFormat,
INT(hotkeyPrefix)))
}
func (this *StringFormat) GetHotkeyPrefix() (hotkeyPrefix HotkeyPrefix) {
this.setStatus(GdipGetStringFormatHotkeyPrefix(
this.nativeFormat, (*INT)(&hotkeyPrefix)))
return
}
func (this *StringFormat) SetTabStops(
firstTabOffset REAL,
tabStops []REAL) Status {
return this.setStatus(GdipSetStringFormatTabStops(
this.nativeFormat,
firstTabOffset,
tabStops))
}
func (this *StringFormat) GetTabStopCount() (count INT) {
this.setStatus(GdipGetStringFormatTabStopCount(this.nativeFormat, &count))
return
}
func (this *StringFormat) GetTabStops(
count INT) (firstTabOffset REAL, tabStops []REAL, status Status) {
tabStops = make([]REAL, count)
status = this.setStatus(GdipGetStringFormatTabStops(
this.nativeFormat,
count,
&firstTabOffset,
tabStops))
return
}
func (this *StringFormat) SetDigitSubstitution(
language LANGID,
substitute StringDigitSubstitute) Status {
return this.setStatus(GdipSetStringFormatDigitSubstitution(
this.nativeFormat,
language,
substitute))
}
func (this *StringFormat) GetDigitSubstitutionLanguage() (language LANGID) {
this.setStatus(GdipGetStringFormatDigitSubstitution(
this.nativeFormat,
&language,
nil))
return
}
func (this *StringFormat) GetDigitSubstitutionMethod() (substitute StringDigitSubstitute) {
this.setStatus(GdipGetStringFormatDigitSubstitution(
this.nativeFormat,
nil,
&substitute))
return
}
func (this *StringFormat) SetTrimming(trimming StringTrimming) Status {
return this.setStatus(GdipSetStringFormatTrimming(
this.nativeFormat,
trimming))
}
func (this *StringFormat) GetTrimming() (trimming StringTrimming) {
this.setStatus(GdipGetStringFormatTrimming(
this.nativeFormat,
&trimming))
return
}
func (this *StringFormat) SetMeasurableCharacterRanges(ranges []CharacterRange) Status {
return this.setStatus(GdipSetStringFormatMeasurableCharacterRanges(
this.nativeFormat,
INT(len(ranges)),
&ranges[0]))
}
func (this *StringFormat) GetMeasurableCharacterRangeCount() (count INT) {
this.setStatus(GdipGetStringFormatMeasurableCharacterRangeCount(
this.nativeFormat,
&count))
return
}
var genericTypographicStringFormat *StringFormat
var genericDefaultStringFormat *StringFormat
func GenericDefault() *StringFormat {
if genericDefaultStringFormat != nil {
return genericDefaultStringFormat
}
genericDefaultStringFormat = &StringFormat{}
genericDefaultStringFormat.setStatus(GdipStringFormatGetGenericDefault(&genericDefaultStringFormat.nativeFormat))
return genericDefaultStringFormat
}
func GenericTypographic() *StringFormat {
if genericTypographicStringFormat != nil {
return genericTypographicStringFormat
}
genericTypographicStringFormat = &StringFormat{}
genericTypographicStringFormat.setStatus(GdipStringFormatGetGenericTypographic(&genericTypographicStringFormat.nativeFormat))
return genericTypographicStringFormat
}