xlang v4.0 Release
程序设计语言基础库文档
载入中...
搜索中...
未找到
QPainter.xcsm
浏览该文件的文档.
1//xlang Source, Name:QPainter.xcsm
2//Date: Mon Oct 21:05:42 2018
3package Qt{
4
5 @SuppressWarnings public class QPainter {
6
7 public long hpaint;
8 bool bneed_delloc = false;
9
10
11
12 public static class Paint {
13 public static const int
14 FILL = 2,
15 STROKE = 1,
16 FILL_AND_STROKE = 3;
17 public int style;
18 public int color;
19 public double width;
20 public int textSize = -1;
21
22 public void setColor(int c) {
23 color = c;
24 }
25
26 public void setTextSize(double ts) {
27 textSize = ts;
28 }
29
30 public void setAlpha(int a) {
31 color = ((a & 0xff) << 24) | (color & 0x00ffffff);
32 }
33
34 public void setStrokeWidth(double sw) {
35 width = sw;
36 }
37
38 public void setStyle(int s) {
39 style = s;
40 }
41 };
42
43
44
45
46 public QPainter(long handle) {
47 hpaint = handle;
48 }
49
50 public QPainter(@NotNilptr QImage img) throws IllegalArgumentException{
51 hpaint = QtXnl.long_get(img.himage, Constant.PAINTERFROMIMG);
52 if (hpaint == 0) {
53 throw new IllegalArgumentException("paint is null");
54 }
55 bneed_delloc = true;
56 }
58 hpaint = QtXnl.long_get(0l, Constant.PAINTERFROMDEVICE);
59 if (hpaint == 0) {
60 throw new IllegalArgumentException("paint is null");
61 }
62 bneed_delloc = true;
63 }
64 public QPainter(@NotNilptr QPaintDevice device) throws IllegalArgumentException {
65 hpaint = QtXnl.long_get(device.nativehandle, Constant.PAINTERFROMDEVICE);
66 if (hpaint == 0) {
67 throw new IllegalArgumentException("paint is null");
68 }
69 bneed_delloc = true;
70 }
71 public void setPaint(@NotNilptr Paint p) {
72 if ((p.style & Paint.FILL) != 0) {
73 setBrush(p.color, QBrush.Style.SolidPattern);
74 }
75
76 if ((p.style & Paint.STROKE) != 0) {
77 setPen(p.color, PenStyle.SolidLine, p.width);
78 }
79
80 if (p.textSize >0 ) {
81 setFontPixelSize(p.textSize);
82 }
83 }
84
85 public void setFontPointSize(int size) {
86 QtXnl.widget_set_vint_value(hpaint, Constant.PAINTFONTPTSIZE, size);
87 }
88
89 public void setFontPixelSize(int size) {
90 QtXnl.widget_set_vint_value(hpaint, Constant.PAINTFONTPXSIZE, size);
91 }
92
93 public void setPen(int color, PenStyle penStyle, double width) {
94 QtXnl.widget_set_v2int_double_value(hpaint, Constant.SETPEN, color, width, penStyle);
95 }
96
97 public void setBrush(int color, QBrush.Style brushStyle) {
98 QtXnl.widget_set_v2int_value(hpaint, Constant.SETBRUSH, color, brushStyle);
99 }
100
101 public void setBrush(@NotNilptr QBrush brush) {
102 QtXnl.widget_set_native_value(hpaint, Constant.SETBRUSH, brush.nativehandle);
103 }
104
105 public void drawLine(int start_x, int start_y, int end_x, int end_y) {
106 QtXnl.native_int4(hpaint, Constant.QXPAINTDRAWLINE, start_x, start_y, end_x, end_y);
107 }
108
109 public void drawRect(int x, int y, int w, int h) {
110 QtXnl.native_int4(hpaint, Constant.QXPAINTDRAWRECT, x, y, w, h);
111 }
112
113 public void drawRect(@NotNilptr QRect r) {
114 QtXnl.native_int4(hpaint, Constant.QXPAINTDRAWRECT, r.left, r.top, r.width(), r.height());
115 }
116
117 public void fillRect(int x,int y, int w,int h, int color, int brushStyle) {
118 QtXnl.long_long_int9(hpaint, Constant.FILLRECT, 0, x, y, w, h, color, brushStyle, 0, 0, 0);
119 }
120
121 public void setClipRect(int x,int y, int w,int h, ClipOperation op) {
122 QtXnl.long_long_int9(hpaint, Constant.QXPAINTSETCLIPRECT, 0, x, y, w, h, op, 0, 0, 0, 0);
123 }
124
125 public void save() {
126 QtXnl.widget_slot(hpaint, Constant.PAINTERSAVE);
127 }
128
129 public void restore() {
130 QtXnl.widget_slot(hpaint, Constant.PAINTERRESTORE);
131 }
132
133 public void resetMatrix() {
134 QtXnl.widget_slot(hpaint, Constant.PAINTRESETMATRIX);
135 }
136
137 public QMatrix getMatrix() {
138 return new QMatrix(QtXnl.long_get(hpaint, Constant.PAINTERGETMATRIX));
139 }
140
141 public void setMatrix(@NotNilptr QMatrix m) {
142 QtXnl.widget_set_native_value(hpaint, Constant.PAINTSETMATRIX, m.nativehandle);
143 }
144
145 public bool begin(QPaintDevice m){
146 return 0 != QtXnl.long_intlong(hpaint, Constant.PAINTBEGIN, m.nativehandle);
147 }
148
149 public bool end(){
150 return QtXnl.widget_get_int_value(hpaint, Constant.PAINTEND) != 0;
151 }
152
153 public void resetTransform() {
154 QtXnl.widget_slot(hpaint, Constant.PAINTRESETTRANSFORM);
155 }
156
157 public void drawText(String text, int x,int y) {
158 QtXnl.widget_set_intintstring_value(hpaint, Constant.DRAWTEXT, x, y,text);
159 }
160
161 public void drawText(String text, int x,int y, Paint p) {
162 if (p != nilptr) {
163 setPen(p.color, PenStyle.SolidLine, p.width);
164 }
165 QtXnl.widget_set_intintstring_value(hpaint, Constant.DRAWTEXT, x, y,text);
166 }
167
168 public void fillRect(@NotNilptr QRect r, int color, int brushStyle) {
169 QtXnl.long_long_int9(hpaint, Constant.FILLRECT, 0, r.left, r.top, r.width(), r.height(), color, brushStyle, 0, 0, 0);
170 }
171
172 public void drawLines(@NotNilptr int [] points) throws IllegalArgumentException{
173 if ((points.length & 1) == 1 || points.length < 4) {
174 throw new IllegalArgumentException("points length must be Even numbers");
175 }
176 QtXnl.array_int2(hpaint, Constant.QXPAINTDRAWLINE, points, 0, 0);
177 }
178
179 public void setBackgroundBrush(int color, int brushStyle) {
180 QtXnl.widget_set_v2int_value(hpaint, Constant.SETBKBRUSH, color, brushStyle);
181 }
182
183 public void setOpacity(double fopacity) {
184 QtXnl.widget_set_double_value(hpaint, Constant.QXPAINTOPACITY, fopacity);
185 }
186
187 public void setBackMode(int mode) {
188 QtXnl.widget_set_vint_value(hpaint, Constant.QXPAINTBGMMODE, mode);
189 }
190
191 public void drawImage(@NotNilptr QImage image, @NotNilptr QRect dest, @NotNilptr QRect source, int converFlags) {
192 QtXnl.long_long_int9(hpaint, Constant.DRAWIMAGE, image.himage,
193 dest.left, dest.top, dest.width(), dest.height(),
194 source.left, source.top, source.width(), source.height(),
195 converFlags);
196 }
197
198 public void drawImage(@NotNilptr QImage image, int x,int y) {
199 QtXnl.widget_set_intlongint_value(hpaint, Constant.DRAWIMAGE, image.himage,x, y);
200 }
201
202 public void drawRoundRect(int x,int y, int w,int h, int rx, int ry, Paint p) {
203 if (p != nilptr) {
204 setPaint(p);
205 }
206 QtXnl.long_long_int9(hpaint, Constant.ROUNDRECT, 0, x, y, w, h, rx, ry, 0, 0, 0);
207 }
208
209 public void drawRoundedRect(int x,int y, int w,int h, int rx, int ry, Paint p) {
210 if (p != nilptr) {
211 setPaint(p);
212 }
213 QtXnl.long_long_int9(hpaint, Constant.ROUNDEDRECT, 0, x, y, w, h, rx, ry, 0, 0, 0);
214 }
215
216 public void drawRoundRect(@NotNilptr QRect r, int rx, int ry, Paint p) {
217 if (p != nilptr) {
218 setPaint(p);
219 }
220 QtXnl.long_long_int9(hpaint, Constant.ROUNDRECT, 0, r.left, r.top, r.width(), r.height(), rx, ry, 0, 0, 0);
221 }
222
223 public void drawRoundedRect(@NotNilptr QRect r, int rx, int ry, Paint p) {
224 if (p != nilptr) {
225 setPaint(p);
226 }
227 QtXnl.long_long_int9(hpaint, Constant.ROUNDEDRECT, 0, r.left, r.top, r.width(), r.height(), rx, ry, 0, 0, 0);
228 }
229
230 public void drawPath(@NotNilptr QPath path, Paint paint) {
231 setPaint(paint);
232 QtXnl.widget_set_native_value(hpaint, Constant.DRAWPATH, path.nativehandle);
233 }
234
235 public void drawPath(@NotNilptr QPath path) {
236 QtXnl.widget_set_native_value(hpaint, Constant.DRAWPATH, path.nativehandle);
237 }
238
239 public void rotate(double r, double cx, double cy) {
240 QMatrix m = getMatrix();
241 if (m != nilptr){
242 m.translate(cx, cy);
243 m.rotate(r);
244 m.translate(-cx, -cy);
245 setMatrix(m);
246 }
247 }
248
249 public void translate(double cx, double cy) {
250 QMatrix m = getMatrix();
251 if (m != nilptr){
252 m.translate(cx, cy);
253 setMatrix(m);
254 }
255 }
256
257 public void scale(double cx, double cy) {
258 QMatrix m = getMatrix();
259 if (m != nilptr){
260 m.scale(cx,cy);
261 setMatrix(m);
262 }
263 }
264
265 public int ascent() {
266 return QtXnl.widget_get_int_value(hpaint, Constant.PAINTFONTASCENT);
267 }
268 public int descent() {
269 return QtXnl.widget_get_int_value(hpaint, Constant.PAINTFONTDESCENT);
270 }
271 public void setCompositionMode(CompositionMode flag) {
272 QtXnl.widget_set_int_bool_value(hpaint, Constant.SETCOMPOSITIONMODE, flag, false);
273 }
274
275 public void setRenderHint(int flag, bool on) {
276 QtXnl.widget_set_int_bool_value(hpaint, Constant.SETRENDERHINT, flag, on);
277 }
278
279 public QFont getFont() {
280 return new QFont(QtXnl.long_get(hpaint, Constant.PAINTERGETFCONT));
281 }
282
283 public void setFont(@NotNilptr QFont f) {
284 QtXnl.widget_set_native_value(hpaint, Constant.PAINTERSETFONT, f.nativehandle);
285 }
286
287 public void setAntialiasing(bool ba) {
288 setRenderHint(RenderHint.Antialiasing, ba);
289 }
290
291 public void drawCircle(int x,int y,int r, Paint p) {
292 if (p != nilptr) {
293 setPaint(p);
294 }
295
296 QtXnl.native_int4(hpaint, Constant.DRAWELLIPSE, x - r, y - r, r *2, r * 2);
297 }
298
299 @NotNilptr public QRect measureText(int x, int y, String text) {
300 long pt= QtXnl.long_longstring(hpaint, Constant.PAINTMEASURETEXT, 0, text);
301 return new QRect(x, y, x + ((int)(pt >> 32) & 0xffffffff), y + (int)(pt & 0xffffffff));
302 }
303
304 public void finalize() {
305 if (bneed_delloc) {
306 QtXnl.widget_slot(hpaint, Constant.DELLOCPAINTER);
307 bneed_delloc = false;
308 }
309 }
310 };
311};
void setStyle(int s)
Definition QPainter.xcsm:38
void setColor(int c)
Definition QPainter.xcsm:22
void setStrokeWidth(double sw)
Definition QPainter.xcsm:34
void setAlpha(int a)
Definition QPainter.xcsm:30
void setTextSize(double ts)
Definition QPainter.xcsm:26
void drawImage(@NotNilptr QImage image, @NotNilptr QRect dest, @NotNilptr QRect source, int converFlags)
void setRenderHint(int flag, bool on)
int ascent()
int descent()
void restore()
void drawCircle(int x,int y,int r, Paint p)
QMatrix getMatrix()
void setFontPointSize(int size)
Definition QPainter.xcsm:85
void rotate(double r, double cx, double cy)
void setMatrix(@NotNilptr QMatrix m)
QPainter(long handle)
Definition QPainter.xcsm:46
void fillRect(@NotNilptr QRect r, int color, int brushStyle)
void setBackgroundBrush(int color, int brushStyle)
void resetTransform()
void setFontPixelSize(int size)
Definition QPainter.xcsm:89
void fillRect(int x,int y, int w,int h, int color, int brushStyle)
void drawLines(@NotNilptr int [] points)
void drawText(String text, int x,int y)
QPainter(@NotNilptr QPaintDevice device)
Definition QPainter.xcsm:64
void drawRoundRect(int x,int y, int w,int h, int rx, int ry, Paint p)
void setFont(@NotNilptr QFont f)
QPainter(@NotNilptr QImage img)
Definition QPainter.xcsm:50
void setBrush(@NotNilptr QBrush brush)
void setAntialiasing(bool ba)
void setBackMode(int mode)
void setClipRect(int x,int y, int w,int h, ClipOperation op)
void translate(double cx, double cy)
void scale(double cx, double cy)
void drawRect(@NotNilptr QRect r)
void finalize()
void resetMatrix()
void drawPath(@NotNilptr QPath path)
void drawRoundedRect(int x,int y, int w,int h, int rx, int ry, Paint p)
void drawRect(int x, int y, int w, int h)
void drawImage(@NotNilptr QImage image, int x,int y)
void drawRoundRect(@NotNilptr QRect r, int rx, int ry, Paint p)
void setPaint(@NotNilptr Paint p)
Definition QPainter.xcsm:71
void drawRoundedRect(@NotNilptr QRect r, int rx, int ry, Paint p)
bool begin(QPaintDevice m)
QRect measureText(int x, int y, String text)
void setCompositionMode(CompositionMode flag)
void save()
void setOpacity(double fopacity)
void setPen(int color, PenStyle penStyle, double width)
Definition QPainter.xcsm:93
void setBrush(int color, QBrush.Style brushStyle)
Definition QPainter.xcsm:97
void drawLine(int start_x, int start_y, int end_x, int end_y)
void drawText(String text, int x,int y, Paint p)
QFont getFont()
void drawPath(@NotNilptr QPath path, Paint paint)
字符串类