xlang v4.0 Release
程序设计语言基础库文档
载入中...
搜索中...
未找到
结构体 | Public 成员函数 | 静态 Public 成员函数 | 静态 Public 属性 | 包属性 | 静态包属性 | Private 成员函数
ProgressView类 参考
类 ProgressView 继承关系图:
QWidget

结构体

interface  OnDismissListener
 

Public 成员函数

静态 Public 成员函数

静态 Public 属性

包属性

静态包属性

Private 成员函数

额外继承的成员函数

详细描述

在文件 ProgressView.xcsm4 行定义.

构造及析构函数说明

◆ ProgressView() [1/2]

ProgressView ( )

在文件 ProgressView.xcsm30 行定义.

30{}

◆ ProgressView() [2/2]

ProgressView ( QWidget  parent)

在文件 ProgressView.xcsm31 行定义.

31{_parent_widget = parent;}

成员函数说明

◆ _dismiss()

void _dismiss ( )
private

在文件 ProgressView.xcsm377 行定义.

377 {
378 double opacity = 1.f;
379 try{
380 new Timer().schedule(new TimerTask() {
381 bool closed = false;
382 void run()override {
383 runOnUi(new Runnable() {
384 void run() override{
385 opacity -= 0.1;
386 if (closed == false){
387 setOpacity(opacity);
388 if (opacity < 0.1) {
389 closed = true;
390 close();
391 }
392 }
393 }
394 }/*, __file__ + ":" + __line__*/);
395 }
396 }, 20, 10);
397 }catch(Exception e){
398
399 }
400 }
异常类
void runOnUi(Runnable task)
Definition QObject.xcsm:10
void setOpacity(double v)
Definition QWidget.xcsm:105
void close()
Definition QWidget.xcsm:286
定时器类
bool schedule(TimerTask, int)
定时器任务类

引用了 Timer.schedule().

◆ beginAnimation()

void beginAnimation ( long  millionSecond)

在文件 ProgressView.xcsm238 行定义.

238 {
239 synchronized(_timeObj) {
240 if (_animator != nilptr) {
241 return ;
242 }
243 _dismissMillionSecond = millionSecond;
244 _animator = new Timer();
245 try{
247 long beginTime = _system_.currentTimeMillis();
248 long waitTime = millionSecond;
249
250 void run() override{
251 _angle += 20;
252 _angle = (_angle) % 360;
253
254 synchronized(_timeObj) {
255 if (_animator != nilptr){
256 ProgressView.this.postUpdate();
257 if (waitTime != WAIT_INFINITE) {
258 if (_system_.currentTimeMillis() - beginTime > waitTime) {
260 _animator = nilptr;
261 runOnUi(new Runnable() {
262 void run() override{
263 _dismiss();
264 }
265 }/*, __file__ + ":" + __line__*/);
266 }
267 } else if (_dismissMillionSecond != waitTime) {
268 waitTime = _dismissMillionSecond;
269 beginTime = _beginMillionSecond;
270 }
271 }
272 }
273 }
274 }, 50,-1);
275 }catch(Exception e){
276
277 }
278
279 }
280 }
系统和IO相关
static final long currentTimeMillis()
void cancel()

引用了 Timer.cancel(), _system_.currentTimeMillis() , 以及 Timer.schedule().

◆ calcTitlePosition()

void calcTitlePosition ( @NotNilptr QPainter  canvas,
double  padding,
@NotNilptr QPainter.Paint  paint 
)

在文件 ProgressView.xcsm150 行定义.

150 {
151
152 paint.setTextSize(dip2px(_fontSize));
153 //paint.setFakeBoldText(true);
154 paint.setColor(_titleColor);
155 QFont qf = canvas.getFont();
156 if (qf != nilptr){
157 //QXReqf.measure(_titleText);
158 QRect rect = qf.measure(_titleText);//BitmapUtils.getStringRect(_titleText,paint);
159 _textHeight= rect.height();
160 _textWidth = rect.width();
161
162 paint.setStyle(QPainter.Paint.FILL);
163 paint.setAlpha(0xff);
164 }
165 }
int dip2px(double dpValue)

◆ dip2px()

int dip2px ( double  dpValue)

在文件 ProgressView.xcsm40 行定义.

40 {
41 return (int) (dpValue * _scale + 0.5f);
42 }

◆ dismiss() [1/2]

void dismiss ( )

在文件 ProgressView.xcsm368 行定义.

368 {
369 dismissAfter(0);
370 }
void dismissAfter(int millionSecond)

◆ dismiss() [2/2]

void dismiss ( OnDismissListener  _l)

在文件 ProgressView.xcsm372 行定义.

372 {
374 dismissAfter(0);
375 }
OnDismissListener __dismissListener

◆ dismissAfter()

void dismissAfter ( int  millionSecond)

在文件 ProgressView.xcsm363 行定义.

363 {
365 _dismissMillionSecond = millionSecond;
366 }

引用了 _system_.currentTimeMillis().

◆ DrawComplete()

void DrawComplete ( @NotNilptr QPainter  canvas,
double  padding,
@NotNilptr QPainter.Paint  paint,
double  subCenterX,
double  subCenterY,
double  minCenterY,
double  subwidth,
double  subheight 
)

在文件 ProgressView.xcsm61 行定义.

62 {
63 double width = subwidth * 5.f;
64 double height = width / 6;
65 subCenterX -= height;
66 subCenterY -= height;
67 QRect progsub = new QRect();
68 progsub.left = subCenterX - (width / 2.f);
69 progsub.top = subCenterY - (height / 2 );
70 progsub.bottom = (progsub.top + height);
71 progsub.right = progsub.left + width;
72
73 paint.setColor(0xffffffff);
74
75 paint.setStyle(QPainter.Paint.FILL);
76 canvas.save();
77
78 double roundXY = subheight / 2;
79
80 canvas.rotate(90.f,subCenterX,subCenterY);
81 canvas.rotate(45.f,subCenterX + (width / 2.f),subCenterY );
82
83 canvas.drawRoundedRect(progsub, (int)roundXY,(int)roundXY, paint);
84
85 canvas.restore();
86 canvas.save();
87 canvas.translate(1,width / 2);
88 canvas.rotate(45,subCenterX,subCenterY);
89 progsub.right = progsub.left + (progsub.width() / 2.f) + (height / 2.f);
90
91 canvas.drawRoundedRect(progsub, (int)roundXY,(int)roundXY, paint);
92 canvas.restore();
93 }
int width()
Definition QWidget.xcsm:180
int height()
Definition QWidget.xcsm:184

◆ DrawFatal()

void DrawFatal ( @NotNilptr QPainter  canvas,
double  padding,
@NotNilptr QPainter.Paint  paint,
double  subCenterX,
double  subCenterY,
double  minCenterY,
double  subwidth,
double  subheight 
)

在文件 ProgressView.xcsm95 行定义.

96 {
97 double width = subwidth * 5.f;
98 double height = width / 5;
99
100 QRect progsub = new QRect();
101 progsub.left = subCenterX - (width / 2.f);
102 progsub.top = subCenterY - (height / 2 );
103 progsub.bottom = (progsub.top + height);
104 progsub.right = progsub.left + width;
105
106 paint.setColor(0xffffffff);
107 paint.setStyle(QPainter.Paint.FILL);
108 canvas.save();
109
110 double roundXY = subheight / 2;
111 canvas.rotate(45.f,subCenterX,subCenterY);
112 for (int i = 0 ; i < 2; i ++) {
113 canvas.rotate(90,subCenterX,subCenterY);
114 canvas.drawRoundedRect(progsub,(int) roundXY,(int)roundXY, paint);
115 }
116 canvas.restore();
117 }

◆ drawProgress()

void drawProgress ( @NotNilptr QPainter  canvas,
double  padding,
@NotNilptr QPainter.Paint  paint,
double  progressX,
double  progressY,
double  progressCX,
double  progressCY 
)

在文件 ProgressView.xcsm167 行定义.

169 {
170
171 QRect progressRect = new QRect();
172 progressRect.left = progressX;
173 progressRect.top = progressY;
174 progressRect.right = progressX + progressCX;
175 progressRect.bottom = progressY + progressCY;
176
177 double prxy = progressRect.height() / 2.f;
178 paint.setStyle(QPainter.Paint.STROKE);
179 paint.setStrokeWidth(dip2px(1));
180 canvas.drawRoundedRect(progressRect, (int)prxy, (int)prxy, paint);
181
182 paint.setStyle(QPainter.Paint.FILL);
183 progressRect.right = 2 + progressRect.left + (_progressPersent * progressCX );
184 canvas.drawRoundedRect(progressRect, (int)prxy, (int)prxy, paint);
185 }

◆ DrawWaiting()

void DrawWaiting ( @NotNilptr QPainter  canvas,
double  padding,
@NotNilptr QPainter.Paint  paint,
double  subCenterX,
double  subCenterY,
double  minCenterY,
double  subwidth,
double  subheight 
)

在文件 ProgressView.xcsm119 行定义.

120 {
121 QRect progsub = new QRect();
122
123 if (_bShowProgress) {
124 subCenterY = Math.max((double)minCenterY,height() / 3.f);
125 }
126
127 progsub.left = subCenterX - (subwidth * 1.75f);
128 progsub.top = subCenterY - (subheight / 2);
129 progsub.bottom = progsub.top + subheight;
130 progsub.right = progsub.left + subwidth;
131
132 paint.setColor(0xbfffffff);
133 paint.setStyle(QPainter.Paint.FILL);
134 canvas.save();
135
136 double roundXY = subheight / 2;
137
138 for (int i = 0 ; i < 12; i ++) {
139 canvas.rotate((360 / 12),subCenterX,subCenterY);
140 int dis = _angle - (i * (360 / 12));
141 if (dis < 0) {
142 dis += 360;
143 }
144 paint.setAlpha(255 * (360 - dis) / 360);
145 canvas.drawRoundedRect(progsub, (int)roundXY, (int)roundXY, paint);
146 }
147 canvas.restore();
148 }
Math类
static final int max(int, int)

引用了 Math.max().

◆ EnableProgress()

void EnableProgress ( bool  bEnable,
double  persent 
)

在文件 ProgressView.xcsm349 行定义.

349 {
350 _bShowProgress = bEnable;
351
352 _progressPersent = Math.max(0.f, persent);
353 _progressPersent = Math.min(1.f, _progressPersent);
354
355 }
static final int min(int, int)

引用了 Math.max() , 以及 Math.min().

◆ getTitleText()

String getTitleText ( )

在文件 ProgressView.xcsm322 行定义.

322 {
323 return _titleText;
324 }

◆ onClose()

bool onClose ( )
override

重载 QObject .

在文件 ProgressView.xcsm406 行定义.

406 {
407 if (__dismissListener != nilptr) {
409 }
410 return true;
411 }
void onDismissListener(ProgressView v)

◆ onDraw()

void onDraw ( @NotNilptr QPainter  canvas)

在文件 ProgressView.xcsm189 行定义.

189 {
190
191 canvas.setPen(0, PenStyle.NoPen, 0);
192
193 double padding = dip2px(5);
194 QPainter.Paint paint = new QPainter.Paint();
195
196 //paint.setShadowLayer(0,0,0, Color.BLACK);
197 onDrawBackground(canvas,padding,paint);
198
199 double subwidth = dip2px(12);
200 double subheight = dip2px(3);
201 double minCenterY = padding + (subheight * 2.f);
202 double subCenterX = width() / 2.f;
203 double subCenterY = Math.max(minCenterY,height() * 2.f / 5.f);
204 if (_bShowResult) {
205 if (_bResult) {
206 DrawComplete(canvas,padding,paint,subCenterX,subCenterY,minCenterY,subwidth,subheight);
207 } else {
208 DrawFatal(canvas,padding,paint,subCenterX,subCenterY,minCenterY,subwidth,subheight);
209 }
210 } else {
211 DrawWaiting(canvas,padding,paint,subCenterX,subCenterY,minCenterY,subwidth,subheight);
212 }
213
214 calcTitlePosition(canvas,padding,paint);
215 double textX = subCenterX - (_textWidth / 2.f);
216 double textY = (subCenterY + (subwidth * 1.75f)) + (((height() - padding) - (subCenterY + (subwidth * 1.75f))) / 2);
217
218
219 if (_bShowProgress) {
220 textY = subCenterY + (subwidth * 1.75f) + (_textHeight * 1.2f) ;
221 }
222 canvas.drawText(_titleText, (int)textX, (int)(textY + (_textHeight * 0.8f)), paint);
223
224 paint.setColor(0xbfffffff);
225
226 if (_bShowProgress) {
227 double progressCX = (width() - padding) * 2 / 3;
228 double progressCY = progressCX / 12.f;
229 if (progressCY == 0) {
230 progressCY = dip2px(1);
231 }
232 double progressX = subCenterX - (width() - padding) / 3;
233 double progressY = ((textY) + ((height() - padding) - (textY)) / 2.f) - (progressCY / 2.f);
234 drawProgress(canvas,padding,paint,progressX,progressY,progressCX,progressCY);
235 }
236 }
void calcTitlePosition(@NotNilptr QPainter canvas,double padding,@NotNilptr QPainter.Paint paint)
void DrawWaiting(@NotNilptr QPainter canvas,double padding,@NotNilptr QPainter.Paint paint,double subCenterX, double subCenterY,double minCenterY,double subwidth,double subheight)
void DrawFatal(@NotNilptr QPainter canvas,double padding,@NotNilptr QPainter.Paint paint,double subCenterX, double subCenterY,double minCenterY,double subwidth,double subheight)
void onDrawBackground(@NotNilptr QPainter canvas, double padding, @NotNilptr QPainter.Paint paint)
void drawProgress(@NotNilptr QPainter canvas,double padding, @NotNilptr QPainter.Paint paint,double progressX,double progressY, double progressCX,double progressCY)
void DrawComplete(@NotNilptr QPainter canvas,double padding,@NotNilptr QPainter.Paint paint,double subCenterX, double subCenterY,double minCenterY,double subwidth,double subheight)

引用了 Math.max().

◆ onDrawBackground()

void onDrawBackground ( @NotNilptr QPainter  canvas,
double  padding,
@NotNilptr QPainter.Paint  paint 
)

在文件 ProgressView.xcsm44 行定义.

44 {
45 QRect rect = new QRect();
46 canvas.setRenderHint(RenderHint.Antialiasing, true);
47 rect.left = rect.top = padding;
48 rect.right = width() - padding;
49 rect.bottom = height() - padding;
50
51 //paint.setAntiAlias(true);
52 paint.setColor(0xaf000000);
53 paint.setStyle(QPainter.Paint.FILL);
54 //paint.setShadowLayer(dip2px(5), 4, 4, Color.BLACK);
55 double rxy = Math.min(width(), height()) / 12.f;
56
57 canvas.drawRoundedRect(rect, (int)rxy, (int)rxy, paint);
58 }

引用了 Math.min().

◆ onPaint()

void onPaint ( int  l,
int  t,
int  r,
int  b,
long  hpaint 
)
override

重载 QObject .

在文件 ProgressView.xcsm402 行定义.

402 {
403 onDraw(new QPainter(hpaint));
404 }
void onDraw(@NotNilptr QPainter canvas)

◆ setOnDismissListener()

void setOnDismissListener ( OnDismissListener  _dismissListener)

在文件 ProgressView.xcsm36 行定义.

36 {
37 __dismissListener = _dismissListener;
38 }

◆ setProgress()

void setProgress ( double  persent)

在文件 ProgressView.xcsm357 行定义.

357 {
358 if (persent >= 0 && persent <= 1) {
359 _progressPersent = persent;
360 }
361 }

◆ setTitle()

void setTitle ( String  szTitle,
int  nColor,
int  sp 
)

在文件 ProgressView.xcsm338 行定义.

338 {
339 _titleText = szTitle;
340 _titleColor = nColor;
341 _fontSize = sp;
342 }

◆ setTitleColor()

void setTitleColor ( int  nColor)

在文件 ProgressView.xcsm330 行定义.

330 {
331 _titleColor = nColor;
332 }

◆ setTitleFontSize()

void setTitleFontSize ( int  sp)

在文件 ProgressView.xcsm334 行定义.

334 {
335 _fontSize = sp;
336 }

◆ setTitleText()

void setTitleText ( String  szTitle)

在文件 ProgressView.xcsm326 行定义.

326 {
327 _titleText = szTitle;
328 }

◆ showModal()

void showModal ( long  millionSecond,
bool  bModal 
)

在文件 ProgressView.xcsm283 行定义.

283 {
284 setPalette(ColorRole.Background, 0x7fffffff);
285 setOpacity(1);
286 setWindowFlags(WindowType.FramelessWindowHint | WindowType.WindowStaysOnTopHint | WindowType.Tool);
287 setAttribute(Constant.WA_TranslucentBackground, true);
288
289 double width = 150;// dm.widthPixels / WIDTH_RATE;//宽度
290 double height = width * HEIGHT_RATE ;//高度
291 resize((int)width, (int)height);
292 if (_parent_widget != nilptr){
293 move(_parent_widget.x() + (_parent_widget.width() - width) / 2, _parent_widget.y() + (_parent_widget.height() - height) / 2);
294 }else{
295 centerScreen();
296 }
297 beginAnimation(millionSecond);
298 if (bModal) {
299 setModal(true);
300 }
301 show();
302 }
void beginAnimation(long millionSecond)
static const double HEIGHT_RATE
void centerScreen()
Definition QWidget.xcsm:416
void setWindowFlags(int flag)
Definition QWidget.xcsm:232
void setPalette(int flags, int color)
Definition QWidget.xcsm:271
void show()
Definition QWidget.xcsm:318
void setAttribute(int flag, bool bOn)
Definition QWidget.xcsm:20
void move(int x,int y)
Definition QWidget.xcsm:220
void setModal(bool bm)
Definition QWidget.xcsm:75
void resize(int w,int h)
Definition QWidget.xcsm:204

◆ showResult()

void showResult ( bool  bShowResult,
bool  bSuccess 
)

在文件 ProgressView.xcsm344 行定义.

344 {
345 _bShowResult = bShowResult;
346 _bResult = bSuccess;
347 }

◆ showWait() [1/2]

static ProgressView showWait ( @NotNilptr QWidget  p,
long  millionSecond 
)
static

在文件 ProgressView.xcsm313 行定义.

313 {
314 ProgressView _progView = new ProgressView(p);
315 if (_progView.create(p)) {
316 _progView.showModal(millionSecond, true);
317 return _progView;
318 }
319 return nilptr;
320 }

◆ showWait() [2/2]

static ProgressView showWait ( long  millionSecond)
static

在文件 ProgressView.xcsm304 行定义.

304 {
305 ProgressView _progView = new ProgressView();
306 if (_progView.create()) {
307 _progView.showModal(millionSecond, false);
308 return _progView;
309 }
310 return nilptr;
311 }

结构体成员变量说明

◆ __dismissListener

OnDismissListener __dismissListener = nilptr
package

在文件 ProgressView.xcsm26 行定义.

◆ _angle

int _angle = 0
package

在文件 ProgressView.xcsm17 行定义.

◆ _animator

Timer _animator = nilptr
package

在文件 ProgressView.xcsm15 行定义.

◆ _beginMillionSecond

long _beginMillionSecond = 0
package

在文件 ProgressView.xcsm25 行定义.

◆ _bResult

bool _bResult = false
package

在文件 ProgressView.xcsm23 行定义.

◆ _bShowProgress

bool _bShowProgress = false
package

在文件 ProgressView.xcsm21 行定义.

◆ _bShowResult

bool _bShowResult = false
package

在文件 ProgressView.xcsm22 行定义.

◆ _dismissMillionSecond

long _dismissMillionSecond = WAIT_INFINITE
package

在文件 ProgressView.xcsm24 行定义.

◆ _fontSize

double _fontSize = 18
package

在文件 ProgressView.xcsm11 行定义.

◆ _parent_widget

QWidget _parent_widget = nilptr
package

在文件 ProgressView.xcsm27 行定义.

◆ _progressPersent

double _progressPersent = 0.f
package

在文件 ProgressView.xcsm20 行定义.

◆ _scale

double _scale = 1.f
package

在文件 ProgressView.xcsm6 行定义.

◆ _textHeight

double _textHeight = 0
package

在文件 ProgressView.xcsm14 行定义.

◆ _textWidth

double _textWidth = 0
package

在文件 ProgressView.xcsm13 行定义.

◆ _timeObj

Object _timeObj = new Object()
package

在文件 ProgressView.xcsm16 行定义.

◆ _titleColor

int _titleColor = 0xceffffff
package

在文件 ProgressView.xcsm10 行定义.

◆ _titleText

String _titleText = "loading"
package

在文件 ProgressView.xcsm8 行定义.

◆ HEIGHT_RATE

const double HEIGHT_RATE = 1.15f
staticpackage

在文件 ProgressView.xcsm28 行定义.

◆ WAIT_INFINITE

const int WAIT_INFINITE = -1
static

在文件 ProgressView.xcsm19 行定义.