xlang v5.1 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 setPen(int color) {
98 QtXnl.widget_set_v2int_double_value(hpaint, Constant.SETPENCLR, color, 0, 0);
99 }
100
101 public void setBrush(int color, QBrush.Style brushStyle) {
102 QtXnl.widget_set_v2int_value(hpaint, Constant.SETBRUSH, color, brushStyle);
103 }
104
105 public void setBrush(@NotNilptr QBrush brush) {
106 QtXnl.widget_set_native_value(hpaint, Constant.SETBRUSH, brush.nativehandle);
107 }
108
109 public void drawLine(int start_x, int start_y, int end_x, int end_y) {
110 QtXnl.native_int4(hpaint, Constant.QXPAINTDRAWLINE, start_x, start_y, end_x, end_y);
111 }
112
113 public void drawRect(int x, int y, int w, int h) {
114 QtXnl.native_int4(hpaint, Constant.QXPAINTDRAWRECT, x, y, w, h);
115 }
116
117 public void drawRect(@NotNilptr QRect r) {
118 QtXnl.native_int4(hpaint, Constant.QXPAINTDRAWRECT, r.left, r.top, r.width(), r.height());
119 }
120
121 public void fillRect(int x,int y, int w,int h, int color, int brushStyle) {
122 QtXnl.long_long_int9(hpaint, Constant.FILLRECT, 0, x, y, w, h, color, brushStyle, 0, 0, 0);
123 }
124
125 public void setClipRect(int x,int y, int w,int h, ClipOperation op) {
126 QtXnl.long_long_int9(hpaint, Constant.QXPAINTSETCLIPRECT, 0, x, y, w, h, op, 0, 0, 0, 0);
127 }
128
129 public void save() {
130 QtXnl.widget_slot(hpaint, Constant.PAINTERSAVE);
131 }
132
133 public void restore() {
134 QtXnl.widget_slot(hpaint, Constant.PAINTERRESTORE);
135 }
136
137 public void resetMatrix() {
138 QtXnl.widget_slot(hpaint, Constant.PAINTRESETMATRIX);
139 }
140
141 public QMatrix getMatrix() {
142 return new QMatrix(QtXnl.long_get(hpaint, Constant.PAINTERGETMATRIX));
143 }
144
145 public void setMatrix(@NotNilptr QMatrix m) {
146 QtXnl.widget_set_native_value(hpaint, Constant.PAINTSETMATRIX, m.nativehandle);
147 }
148
149 public bool begin(QPaintDevice m){
150 return 0 != QtXnl.long_intlong(hpaint, Constant.PAINTBEGIN, m.nativehandle);
151 }
152
153 public bool end(){
154 return QtXnl.widget_get_int_value(hpaint, Constant.PAINTEND) != 0;
155 }
156
157 public void resetTransform() {
158 QtXnl.widget_slot(hpaint, Constant.PAINTRESETTRANSFORM);
159 }
160
161 public void drawText(String text, int x,int y) {
162 QtXnl.widget_set_intintstring_value(hpaint, Constant.DRAWTEXT, x, y,text);
163 }
164
165 public void drawText(String text, QRect rect, int align) {
166 long x = (((long)rect.left) << 32) | ((long)rect.right& 0xffffffffl), y = (((long)rect.top) << 32) | ((long)rect.bottom & 0xffffffffl);
167 QtXnl.native_long2_string(hpaint, Constant.DRAWTEXT, x, y,align, text);
168 }
169
170 public void drawText(String text, int x,int y, Paint p) {
171 if (p != nilptr) {
172 setPen(p.color, PenStyle.SolidLine, p.width);
173 }
174 QtXnl.widget_set_intintstring_value(hpaint, Constant.DRAWTEXT, x, y,text);
175 }
176
177 public void fillRect(@NotNilptr QRect r, int color, int brushStyle) {
178 QtXnl.long_long_int9(hpaint, Constant.FILLRECT, 0, r.left, r.top, r.width(), r.height(), color, brushStyle, 0, 0, 0);
179 }
180
181 public void drawLines(@NotNilptr int [] points) throws IllegalArgumentException{
182 if ((points.length & 1) == 1 || points.length < 4) {
183 throw new IllegalArgumentException("points length must be Even numbers");
184 }
185 QtXnl.array_int2(hpaint, Constant.QXPAINTDRAWLINE, points, 0, 0);
186 }
187
188 public void setBold(bool bb){
189 QtXnl.widget_set_bool_value(hpaint, Constant.PAINTER_SETBOLD, bb);
190 }
191
192 public void setItalic(bool bi){
193 QtXnl.widget_set_bool_value(hpaint, Constant.PAINTER_SETITALIC, bi);
194 }
195
196 public void translate(double x, double y){
197 (QtXnl.long_double2(hpaint, Constant.PAINTER_TRANSLATE, x, y));
198 }
199
200 public void scale(double sx, double sy){
201 (QtXnl.long_double2(hpaint, Constant.PAINTER_SCALE, sx, sy));
202 }
203
204 public void shear(double sh, double sv){
205 (QtXnl.long_double2(hpaint, Constant.PAINTER_SHEAR, sh, sv));
206 }
207
208 public void rotate(double a){
209 (QtXnl.long_double2(hpaint, Constant.PAINTER_ROTATE, a, 0));
210 }
211 public void rotate(double r, double cx, double cy) {
212 (QtXnl.native_double4(r, cx, cy, 0, hpaint, Constant.PAINTER_ROTATE));
213 }
214 public void setBackgroundBrush(int color, int brushStyle) {
215 QtXnl.widget_set_v2int_value(hpaint, Constant.SETBKBRUSH, color, brushStyle);
216 }
217
218 public void setOpacity(double fopacity) {
219 QtXnl.widget_set_double_value(hpaint, Constant.QXPAINTOPACITY, fopacity);
220 }
221
222 public void setBackMode(int mode) {
223 QtXnl.widget_set_vint_value(hpaint, Constant.QXPAINTBGMMODE, mode);
224 }
225
226 public void drawImage(@NotNilptr QImage image, @NotNilptr QRect dest, @NotNilptr QRect source, int converFlags) {
227 QtXnl.long_long_int9(hpaint, Constant.DRAWIMAGE, image.himage,
228 dest.left, dest.top, dest.width(), dest.height(),
229 source.left, source.top, source.width(), source.height(),
230 converFlags);
231 }
232
233 public void drawImage(@NotNilptr QImage image, int x,int y) {
234 QtXnl.widget_set_intlongint_value(hpaint, Constant.DRAWIMAGE, image.himage,x, y);
235 }
236
237 public void drawRoundRect(int x,int y, int w,int h, int rx, int ry, Paint p) {
238 if (p != nilptr) {
239 setPaint(p);
240 }
241 QtXnl.long_long_int9(hpaint, Constant.ROUNDRECT, 0, x, y, w, h, rx, ry, 0, 0, 0);
242 }
243
244 public void drawRoundedRect(int x,int y, int w,int h, int rx, int ry, Paint p) {
245 if (p != nilptr) {
246 setPaint(p);
247 }
248 QtXnl.long_long_int9(hpaint, Constant.ROUNDEDRECT, 0, x, y, w, h, rx, ry, 0, 0, 0);
249 }
250
251 public void drawRoundRect(@NotNilptr QRect r, int rx, int ry, Paint p) {
252 if (p != nilptr) {
253 setPaint(p);
254 }
255 QtXnl.long_long_int9(hpaint, Constant.ROUNDRECT, 0, r.left, r.top, r.width(), r.height(), rx, ry, 0, 0, 0);
256 }
257
258 public void drawRoundedRect(@NotNilptr QRect r, int rx, int ry, Paint p) {
259 if (p != nilptr) {
260 setPaint(p);
261 }
262 QtXnl.long_long_int9(hpaint, Constant.ROUNDEDRECT, 0, r.left, r.top, r.width(), r.height(), rx, ry, 0, 0, 0);
263 }
264
265 public void drawPath(@NotNilptr QPath path, Paint paint) {
266 setPaint(paint);
267 QtXnl.widget_set_native_value(hpaint, Constant.DRAWPATH, path.nativehandle);
268 }
269
270 public void drawPath(double [] ys, int xstep, int w, int h){
271 int wh = ((w << 16) & 0xffff0000) | (h & 0x0000ffff);
272 long v1 = ys.length;
273 v1 = ((v1 << 48) & 0xffff000000000000l) | ((((long)xstep) << 32) & 0x0000ffff00000000l) | (wh & 0x00ffffffffl);
274 QtXnl.pointer_intlong2(ys, Constant.QXPAINTDRAWFLINE, hpaint, v1);
275 }
276
277 public void drawPathf3i(double [] ys, float start, float xstep, float yadd, float ymul, int pos , int length ){
278 QtXnl.pointer_intf3i(hpaint, ys, Constant.QXPAINTDRAWFLINE, start, xstep, yadd, ymul, pos, length);
279 }
280
281 public void drawPath(@NotNilptr QPath path) {
282 QtXnl.widget_set_native_value(hpaint, Constant.DRAWPATH, path.nativehandle);
283 }
284
285 public int ascent() {
286 return QtXnl.widget_get_int_value(hpaint, Constant.PAINTFONTASCENT);
287 }
288 public int descent() {
289 return QtXnl.widget_get_int_value(hpaint, Constant.PAINTFONTDESCENT);
290 }
291 public void setCompositionMode(CompositionMode flag) {
292 QtXnl.widget_set_int_bool_value(hpaint, Constant.SETCOMPOSITIONMODE, flag, false);
293 }
294
295 public void setRenderHint(int flag, bool on) {
296 QtXnl.widget_set_int_bool_value(hpaint, Constant.SETRENDERHINT, flag, on);
297 }
298
299 public QFont getFont() {
300 return new QFont(QtXnl.long_get(hpaint, Constant.PAINTERGETFCONT));
301 }
302
303 public void setFont(@NotNilptr QFont f) {
304 QtXnl.widget_set_native_value(hpaint, Constant.PAINTERSETFONT, f.nativehandle);
305 }
306
307 public void setAntialiasing(bool ba) {
308 setRenderHint(RenderHint.Antialiasing, ba);
309 }
310
311 public void drawCircle(int x,int y,int r, Paint p) {
312 if (p != nilptr) {
313 setPaint(p);
314 }
315
316 QtXnl.native_int4(hpaint, Constant.DRAWELLIPSE, x - r, y - r, r *2, r * 2);
317 }
318
319 @NotNilptr public QRect measureText(int x, int y, String text) {
320 long pt= QtXnl.long_longstring(hpaint, Constant.PAINTMEASURETEXT, 0, text);
321 return new QRect(x, y, x + ((int)(pt >> 32) & 0xffffffff), y + (int)(pt & 0xffffffff));
322 }
323
324 public void finalize() {
325 if (bneed_delloc) {
326 QtXnl.widget_slot(hpaint, Constant.DELLOCPAINTER);
327 bneed_delloc = false;
328 }
329 }
330 };
331};
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)
void setBold(bool bb)
int ascent()
int descent()
void restore()
void drawPathf3i(double [] ys, float start, float xstep, float yadd, float ymul, int pos , int length )
void shear(double sh, double sv)
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 drawPath(double [] ys, int xstep, int w, int h)
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 scale(double sx, double sy)
void rotate(double a)
void setBackMode(int mode)
void setClipRect(int x,int y, int w,int h, ClipOperation op)
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 drawText(String text, QRect rect, int align)
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 setItalic(bool bi)
void setBrush(int color, QBrush.Style brushStyle)
void drawLine(int start_x, int start_y, int end_x, int end_y)
void translate(double x, double y)
void setPen(int color)
Definition QPainter.xcsm:97
void drawText(String text, int x,int y, Paint p)
QFont getFont()
void drawPath(@NotNilptr QPath path, Paint paint)
Definition String.x:5