📄 gui1.js
字号:
{this.setGroupBoxTitle(null);}
else {if(this._groupBoxTitle==null)
this.setGroupBoxTitle(new BiGroupBoxTitle(sText));else this._groupBoxTitle.setText(sText);}};_p.getText=function()
{if(this._groupBoxTitle)
return this._groupBoxTitle.getText();return null;};_p.layoutAllChildren=function()
{var cw=BiComponent.prototype.getClientWidth.call(this);var ch=BiComponent.prototype.getClientHeight.call(this);var changed;var headerPrefHeight=Math.max(this._headerLeft.getPreferredHeight(),this._headerRight.getPreferredHeight());if(!this._groupBoxTitle)
{var halfWidth=Math.ceil(cw/2);this._layoutChild2(this._headerLeft,0,0,halfWidth,headerPrefHeight);this._layoutChild2(this._headerRight,halfWidth,0,cw-halfWidth,headerPrefHeight);changed=this._layoutChild2(this._container,0,headerPrefHeight,cw,ch-headerPrefHeight);if(changed)
this._container.invalidateLayout();}
else {var titlePrefWidth=this._groupBoxTitle.getPreferredWidth();var titlePrefHeight=this._groupBoxTitle.getPreferredHeight();var leftMinLeft=this._headerLeft.getMinimumWidth();var rightMinLeft=this._headerRight.getMinimumWidth();var w=Math.max(0,Math.min(cw-leftMinLeft-rightMinLeft,titlePrefWidth));var h=Math.max(0,Math.min(ch-this._container.getMinimumHeight(),titlePrefHeight),headerPrefHeight);if(this._titlePosition=="center")
{this._layoutChild2(this._headerLeft,0,Math.floor(h/2),Math.ceil((cw-w)/2),Math.ceil(h/2));changed=this._layoutChild2(this._groupBoxTitle,Math.ceil((cw-w)/2),0,w,h);if(changed)
this._groupBoxTitle.invalidateLayout();this._layoutChild2(this._headerRight,cw-Math.floor((cw-w)/2),Math.floor(h/2),Math.floor((cw-w)/2),Math.ceil(h/2));}
else if(this._titlePosition=="left"||this.getRightToLeft())
{this._layoutChild2(this._headerLeft,0,Math.floor(h/2),leftMinLeft,Math.ceil(h/2));changed=this._layoutChild2(this._groupBoxTitle,leftMinLeft,0,w,h);if(changed)
this._groupBoxTitle.invalidateLayout();this._layoutChild2(this._headerRight,leftMinLeft+w,Math.floor(h/2),cw-leftMinLeft-w,Math.ceil(h/2));}
else {this._layoutChild2(this._headerLeft,0,Math.floor(h/2),cw-rightMinLeft-w,Math.ceil(h/2));changed=this._layoutChild2(this._groupBoxTitle,cw-rightMinLeft-w,0,w,h);if(changed)
this._groupBoxTitle.invalidateLayout();this._layoutChild2(this._headerRight,cw-rightMinLeft,Math.floor(h/2),rightMinLeft,Math.ceil(h/2));}
changed=this._layoutChild2(this._container,0,h,cw,ch-h);if(changed)
this._container.invalidateLayout();}};_p.invalidateChild=function(oChild,sHint)
{this.invalidateLayout();this._invalidateChild(oChild,sHint);};_p.add=function(oChild,oBefore,bAnon)
{this._container.add(oChild,oBefore,bAnon);};_p.remove=function(oChild)
{return this._container.remove(oChild);};_p.removeAll=function()
{return this._container.removeAll();};_p.hasChildren=function()
{return this._container.hasChildren();};_p.getChildren=function()
{return this._container.getChildren();};_p.getFirstChild=function()
{return this._container.getFirstChild();};_p.getLastChild=function()
{return this._container.getLastChild();};_p.getOverflow=function()
{return this._container.getOverflow();};_p.getOverflowX=function()
{return this._container.getOverflowX();};_p.getOverflowY=function()
{return this._container.getOverflowY();};_p.getScrollTop=function()
{return this._container.getScrollTop();};_p.getScrollLeft=function()
{return this._container.getScrollLeft();};_p.getScrollWidth=function()
{return this._container.getScrollWidth();};_p.getScrollHeight=function()
{return this._container.getScrollHeight();};_p.getInsetLeft=function()
{return this._container.getInsetLeft();};_p.getInsetRight=function()
{return this._container.getInsetRight();};_p.getInsetBottom=function()
{return this._container.getInsetBottom();};_p.setOverflow=function(v)
{this._container.setOverflow(v);};_p.setOverflowX=function(v)
{this._container.setOverflowX(v);};_p.setOverflowY=function(v)
{this._container.setOverflowY(v);};_p.setScrollTop=function(v)
{this._container.setScrollTop(v);};_p.setScrollLeft=function(v)
{this._container.setScrollLeft(v);};_p.getInsetTop=function()
{if(this._groupBoxTitle)
return this._groupBoxTitle.getPreferredHeight();return Math.max(this._headerLeft.getPreferredHeight(),this._headerRight.getPreferredHeight());};_p.setBorder=function(b)
{if(this._border)
{if(this._topLeftBorder)
this._topLeftBorder.removeBorder(this._headerLeft);if(this._topRightBorder)
this._topRightBorder.removeBorder(this._headerRight);if(this._containerBorder)
this._containerBorder.removeBorder(this._container);}
this._border=b;if(b)
{var tlb=new BiBorder;tlb.setTop(b.getTopWidth(),b.getTopStyle(),b.getTopColor());tlb.setLeft(b.getLeftWidth(),b.getLeftStyle(),b.getLeftColor());this._topLeftBorder=tlb;var trb=new BiBorder;trb.setTop(b.getTopWidth(),b.getTopStyle(),b.getTopColor());trb.setRight(b.getRightWidth(),b.getRightStyle(),b.getRightColor());this._topRightBorder=trb;var cb=new BiBorder;cb.setLeft(b.getLeftWidth(),b.getLeftStyle(),b.getLeftColor());cb.setRight(b.getRightWidth(),b.getRightStyle(),b.getRightColor());cb.setBottom(b.getBottomWidth(),b.getBottomStyle(),b.getBottomColor());this._containerBorder=cb;}
else {this._topLeftBorder=this._topRightBorder=this._containerBorder=null;}
this._headerLeft.setBorder(this._topLeftBorder);this._headerRight.setBorder(this._topRightBorder);this._container.setBorder(this._containerBorder);if(!this.getHasFixedWidth()||!this.getHasFixedHeight())
this.invalidateParentLayout("size");this.invalidateLayout();};_p.getPreferredHeight=function()
{if(this._preferredHeight!=null)
return this._preferredHeight;return this.getInsetTop()+this._container.getPreferredHeight()+this.getInsetBottom();};_p.getPreferredWidth=function()
{if(this._preferredWidth!=null)
return this._preferredWidth;return this.getInsetLeft()+this._container.getPreferredWidth()+this.getInsetRight();};function BiGroupBoxTitle(sText)
{if(_biInPrototype)return;BiLabel.call(this,sText);this.setAppearance("group-box-title");}
_p=_biExtend(BiGroupBoxTitle,BiLabel,"BiGroupBoxTitle");_p._titlePosition="left";_p.setTitlePosition=function(s)
{if(s!=this._titlePosition)
{this._titlePosition=s;if(this._parent instanceof BiGroupBox)
this._parent.setTitlePosition(s);}};BiGroupBoxTitle.prototype.getTitlePosition=function(){return this._titlePosition;};function BiRangeModel()
{if(_biInPrototype)return;BiEventTarget.call(this);}
_p=_biExtend(BiRangeModel,BiEventTarget,"BiRangeModel");_p._value=0;_p._minimum=0;_p._maximum=100;_p._extent=0;_p._isChanging=false;BiRangeModel.prototype.getValue=function(){return this._value;};_p.setValue=function(nValue)
{nValue=Math.floor(nValue);if(this._value!=nValue)
{if(nValue+this._extent>this._maximum)
this._value=this._maximum-this._extent;else if(nValue<this._minimum)
this._value=this._minimum;else this._value=nValue;if(!this._isChanging)
this.dispatchEvent(new BiEvent("change"));}};BiRangeModel.prototype.getMaximum=function(){return this._maximum;};_p.setMaximum=function(nMaximum)
{nMaximum=Math.floor(nMaximum);if(this._maximum!=nMaximum)
{var oldIsChanging=this._isChanging;this._isChanging=true;this._maximum=nMaximum;if(nMaximum<this._value)
this.setValue(nMaximum-this._extent);if(nMaximum<this._minimum)
{this._extent=0;this.setMinimum(nMaximum);this.setValue(nMaximum);}
if(nMaximum<this._minimum+this._extent)
this._extent=this._maximum-this._minimum;if(nMaximum<this._value+this._extent)
this._extent=this._maximum-this._value;this._isChanging=oldIsChanging;if(!this._isChanging)
this.dispatchEvent(new BiEvent("change"));}};BiRangeModel.prototype.getMinimum=function(){return this._minimum;};_p.setMinimum=function(nMinimum)
{nMinimum=Math.floor(nMinimum);if(this._minimum!=nMinimum)
{var oldIsChanging=this._isChanging;this._isChanging=true;this._minimum=nMinimum;if(nMinimum>this._value)
this.setValue(nMinimum);if(nMinimum>this._maximum)
{this._extent=0;this.setMaximum(nMinimum);this.setValue(nMinimum)}
if(nMinimum+this._extent>this._maximum)
this._extent=this._maximum-this._minimum;this._isChanging=oldIsChanging;if(!this._isChanging)
this.dispatchEvent(new BiEvent("change"));}};BiRangeModel.prototype.getExtent=function(){return this._extent;};_p.setExtent=function(nExtent)
{nExtent=Math.floor(nExtent);if(this._extent!=nExtent)
{if(nExtent<0)
this._extent=0;else if(this._value+nExtent>this._maximum)
this._extent=this._maximum-this._value;else this._extent=nExtent;if(!this._isChanging)
this.dispatchEvent(new BiEvent("change"));}};function BiProgressBar(nValue){if(_biInPrototype)return;BiComponent.call(this);this.setCssClassName("bi-progress-bar");this.setAppearance("progress-bar");this._rangeModel=new BiRangeModel();if(nValue)this.setValue(nValue);this._rangeModel.addEventListener("change",this._onchange,this);}
_p=_biExtend(BiProgressBar,BiComponent,"BiProgressBar");_p._preferredHeight=16;_p._preferredWidth=200;_p.setValue=function(nValue){this._rangeModel.setValue(nValue);};_p.getValue=function(){return this._rangeModel.getValue();};_p.setMaximum=function(nMaximum){this._rangeModel.setMaximum(nMaximum);};_p.getMaximum=function(){return this._rangeModel.getMaximum();};_p.setMinimum=function(nMinimum){this._rangeModel.setMinimum(nMinimum);};_p.getMinimum=function(){return this._rangeModel.getMinimum();};_p._layoutThumb=function(){if(this._thumb){this._thumb.style.width=100*(this.getValue()-this.getMinimum())/(this.getMaximum()-this.getMinimum())+"%";}};_p._create=function(oDocument){BiComponent.prototype._create.call(this,oDocument);this._thumb=this._document.createElement("DIV");this._thumb.className="bi-progress-bar-thumb progress-bar-thumb";this._element.insertBefore(this._thumb,this._element.firstChild);this._layoutThumb();};_p.dispose=function(){if(this._disposed)return;BiComponent.prototype.dispose.call(this);this._rangeModel.dispose();this._rangeModel=null;if(this._thumb)
this._thumb.style.filter="none";this._thumb=null;};_p._onchange=function(e){this._layoutThumb();this.dispatchEvent(new BiEvent("change"));};function BiUndeterminedProgressBar()
{if(_biInPrototype)return;BiProgressBar.call(this);this._rangeModel.setMaximum(50);this._timer=new BiTimer(50);this._timer.addEventListener("tick",this._ontick,this);this.addEventListener("create",this._layoutThumb);};_p=_biExtend(BiUndeterminedProgressBar,BiProgressBar,"BiUndeterminedProgressBar");_p.layoutComponent=function()
{this._layoutThumb();return BiProgressBar.prototype.layoutComponent.call(this);};_p._layoutThumb=function()
{if(this.getCreated())
{var max=this.getMaximum();var min=this.getMinimum();var size=max-min;var v=(this.getValue()-min)/size;var w=0.3;var left,right,width;if(v<=0.5)
{right=(v*2)*(1+w);left=right-w;this._thumb.className="bi-progress-bar-thumb progress-bar-thumb";}
else {left=1-(1+w)*2*(v-0.5);right=left+w;this._thumb.className="bi-progress-bar-reverse-thumb progress-bar-reverse-thumb";}
left=Math.max(0,Math.min(1,left));right=Math.max(0,Math.min(1,right));width=right-left;var cw=this.getClientWidth();this._thumb.style.marginLeft=Math.round(left*cw)+"px";this._thumb.style.width=Math.round(width*cw)+"px";}};_p._ontick=function(e)
{if(this.getValue()==this.getMaximum())
this.setValue(this.getMinimum());else this.setValue(this.getValue()+1);};_p.start=function()
{this._timer.start();};_p.stop=function()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -