📄 statefulcanvas.js
字号:
modifier = (selected && focused) ? this._$SelectedFocused : selected ? selected : focused; } if (!customState) { if (modifier) return state ? modifier + state : modifier; else return state; } else if (modifier) { return state ? modifier + state + customState : modifier + customState; } else { return state ? state + customState : customState; }},_$SelectedFocused:"SelectedFocused",setCustomState : function (customState) { if (customState == this.customState) return; this.customState = customState; if (this.label) this.label.customState = customState; this.stateChanged();},getCustomState : function () { return this.customState },// Label// ---------------------------------------------------------------------------------------labelDefaults : { _canFocus: function () { return this.masterElement._canFocus(); }, focusChanged : function (hasFocus) { if (this.hasFocus) this.eventProxy.focus(); }, getContents : function () { return this.masterElement.getTitleHTML() }, // override adjustOverflow to notify us when this has it's overflow changed // (probably due to 'setContents') adjustOverflow : function (a,b,c,d) { this.invokeSuper(null, "adjustOverflow", a,b,c,d); this.masterElement._labelAdjustOverflow(); }}, _$label : "label", makeLabel : function () { var labelClass = this.getAutoChildClass(this._$label, null, isc.Label); var label = this.label = labelClass.createRaw(); label.align = this.align; label.valign = this.valign; label._resizeWithMaster = false; label._redrawWithMaster = false; label._redrawWithParent = false; // icon-related label.icon = this.icon; label.iconWidth = this.iconWidth; label.iconHeight = this.iconHeight; label.iconSize = this.iconSize; label.iconOrientation = this.iconOrientation; label.iconAlign = this.iconAlign; label.iconSpacing = this.iconSpacing; label.showDownIcon = this.showDownIcon; label.showSelectedIcon = this.showSelectedIcon; label.showRollOverIcon = this.showRollOverIcon; label.showFocusedIcon = this.showFocusedIcon; label.showDisabledIcon = this.showDisabledIcon; if (this.showIconState != null) label.showIconState = this.showIconState; // If we show 'focused' state, have our label show it too. label.getFocusedState = function () { var button = this.masterElement; if (button && button.getFocusedState) return button.getFocusedState(); } // see ScreenReader.js label.waiRole = this.waiRole; label.baseStyle = this.titleStyle || this.baseStyle; label.state = this.getState(); label.customState = this.getCustomState(); // if we're set to overflow:visible, that means the label should set to overflow:visible // and we should match its overflowed size label.overflow = this.overflow; label.width = this._getLabelSpecifiedWidth(); label.height = this._getLabelSpecifiedHeight(); label.left = this._getLabelLeft(); label.top = this._getLabelTop(); // NOTE: vertical always false where inapplicable, eg ImgButton label.wrap = this.wrap != null ? this.wrap : this.vertical; label.eventProxy = this; label.isMouseTransparent = true; label.zIndex = this.getZIndex(true) + 1; label.tabIndex = -1; // finish createRaw()/completeCreation() construction style, but allow autoChild defaults this._completeCreationWithDefaults(this._$label, label); this.addPeer(this.label, null, null, true);},// Label Sizing Handling// ---------------------------------------------------------------------------------------//> @method statefulCanvas.setIconOrientation// Changes the orientation of the icon relative to the text of the button.//// @param orientation ("left" or "right") The new orientation of the icon relative to the text// of the button.//// @group buttonIcon// @visibility external//<setIconOrientation : function (orientation) { this.iconOrientation = orientation; if (this.label) { this.label.iconOrientation = orientation; this.label.markForRedraw(); } else { this.markForRedraw(); }},//>@method statefulCanvas.setAutoFit()// Setter method for the +link{StatefulCanvas.autoFit} property. Pass in true or false to turn// autoFit on or off. When autoFit is set to <code>false</code>, canvas will be resized to// it's previously specified size.// @param autoFit (boolean) New autoFit setting.// @visibility external//<setAutoFit : function (autoFit, initializing) { // setAutoFit is called directly from resizeTo // If we're resizing before the autoFit property's initial setup, don't re-set the // autoFit property. if (initializing) { this._autoFitInitialized = true; // No need to make any changes if autoFit is false if (!autoFit) return; } // This can happen if 'setWidth()' et-al are called during 'init' for the statefulCanvas, // and should not effect the autoFit setting. if (!this._autoFitInitialized) return; // Typecast autoFit to a boolean autoFit = !!autoFit; // bail if no change to autoFit, unless this is the special init-time call if (!initializing && (!!this.autoFit == autoFit)) return; this._settingAutoFit = true; this.autoFit = autoFit; var horizontal = (this.autoFitDirection == isc.Canvas.BOTH) || (this.autoFitDirection == isc.Canvas.HORIZONTAL), vertical = (this.autoFitDirection == isc.Canvas.BOTH) || (this.autoFitDirection == isc.Canvas.VERTICAL); // advertise that we have inherent width/height in whatever directions we are autofitting, // iow, a Layout should not expand us along that axis. this.inherentWidth = autoFit && horizontal; this.inherentHeight = autoFit && vertical; if (autoFit) { // record original overflow, width and height settings so we can restore them if // setAutoFit(false) is called this._explicitOverflow = this.overflow; this.setOverflow(isc.Canvas.VISIBLE); if (horizontal) { this._explicitWidth = this.width; this.setWidth(1); } if (vertical) { this._explicitHeight = this.height; this.setHeight(1); } //this.logWarn("just set autoFit to:"+ autoFit + // ", width/height/overflow:"+ [this.width, this.height, this.overflow]); } else { // If we had an explicit height before being set to autoFit true, we should reset to // that size, otherwise reset to default. var width = this._explicitWidth || this.defaultWidth, height = this._explicitHeight || this.defaultHeight; if (horizontal) this.setWidth(width); if (vertical) this.setHeight(height); if (this.parentElement && isc.isA.Layout(this.parentElement)) { if (horizontal && !this._explicitWidth) this._userWidth = null; if (vertical && !this._explicitHeight) this._userHeight = null; } this._explicitWidth = null; this._explicitHeight = null; if (this._explicitOverflow) this.setOverflow(this._explicitOverflow); this._explicitOverflow = null; } delete this._settingAutoFit;},// override 'resizeBy()' / 'setOverflow()' - if these methods are called// we're essentially clearing out this.autoFit// Note we override resizeBy() as setWidth / setHeight / resizeTo all fall through to this method.resizeBy : function (dX, dY, a,b,c,d) { if (this.autoFit && this._autoFitInitialized && !this._settingAutoFit) { var changeAutoFit = false; if (dX != null && (this.autoFitDirection == isc.Canvas.BOTH || this.autoFitDirection == isc.Canvas.HORIZONTAL)) { this._explicitWidth = (1 + dX); changeAutoFit = true; } if (dY != null && (this.autoFitDirection == isc.Canvas.BOTH || this.autoFitDirection == isc.Canvas.VERTICAL)) { this._explicitHeight = (1 + dY); changeAutoFit = true; } // will call setWidth / height if (changeAutoFit) this.setAutoFit(false); return; } return this.invokeSuper(isc.StatefulCanvas, "resizeBy", dX,dY, a,b,c,d); },getLabelHPad : function () { if (this.labelHPad != null) return this.labelHPad; if (this.vertical) { return this.labelBreadthPad != null ? this.labelBreadthPad : 0; } else { return this.labelLengthPad != null ? this.labelLengthPad : this.capSize; }},getLabelVPad : function () { if (this.labelVPad != null) return this.labelVPad; if (!this.vertical) { return this.labelBreadthPad != null ? this.labelBreadthPad : 0; } else { return this.labelLengthPad != null ? this.labelLengthPad : this.capSize; }},_getLabelLeft : function () { var left; if (this.isDrawn()) { left = (this.position == isc.Canvas.RELATIVE && this.parentElement == null ? this.getPageLeft() : this.getOffsetLeft()); } else { left = this.getLeft(); } left += this.getLabelHPad(); return left;},_getLabelTop : function () { var top; if (this.isDrawn()) { top = (this.position == isc.Canvas.RELATIVE && this.parentElement == null ? this.getPageTop() : this.getOffsetTop()); } else { top = this.getTop(); } top += this.getLabelVPad(); return top;},_getLabelSpecifiedWidth : function () { var width = this.getInnerWidth(); width -= 2* this.getLabelHPad(); return Math.max(width, 1);},_getLabelSpecifiedHeight : function () { var height = this.getInnerHeight(); height -= 2 * this.getLabelVPad(); return Math.max(height, 1);},// if we are overflow:visible, match the drawn size of the label.// getImgBreadth/getImgLength return the sizes for the non-stretching and stretching axes// respectively.// NOTE that stretching on the breadth axis won't look right with most media sets, eg a// horizontally stretching rounded button is either going to tile its rounded caps vertically// (totally wrong) or stretch them, which will probably degrade the media.getImgBreadth : function () { if (this.overflow == isc.Canvas.VISIBLE && isc.isA.Canvas(this.label)) { return this.vertical ? this._getAutoInnerWidth() : this._getAutoInnerHeight(); } //return this.Super("getImgBreadth", arguments); // same as the Superclass behavior return (this.vertical ? this.getInnerWidth() : this.getInnerHeight());},getImgLength : function () { if (this.overflow == isc.Canvas.VISIBLE && isc.isA.Canvas(this.label)) { return this.vertical ? this._getAutoInnerHeight() : this._getAutoInnerWidth(); } return (this.vertical ? this.getInnerHeight() : this.getInnerWidth());},// get the inner breadth or height we should have if we are overflow:visible and want to size// to the label and the padding we leave around it_getAutoInnerHeight : function () { var innerHeight = this.getInnerHeight(); // use the normal inner height if we have no label if (!isc.isA.Canvas(this.label)) return innerHeight; // if the padding for this dimension is set, use that, otherwise assume the capSize as a // default padding for the stretch dimension var padding = this.getLabelVPad(); var labelSize = this.label.getVisibleHeight() + 2*padding; return Math.max(labelSize, innerHeight);},_getAutoInnerWidth : function () { var innerWidth = this.getInnerWidth(); if (!isc.isA.Canvas(this.label)) return innerWidth; var padding = this.getLabelHPad(); var labelSize = this.label.getVisibleWidth() + 2*padding; return Math.max(labelSize, innerWidth);},// If we are matching the label size, and it changes, resize images and redraw_$labelOverflowed:"Label overflowed.",_labelAdjustOverflow : function () { if (this.overflow != isc.Canvas.VISIBLE) return; //this.logWarn("our innerWidth:" + this.getInnerWidth() + // ", label visible width: " + this.label.getVisibleWidth() + // " padding: " + (this.labelHPad * 2) + // " resizing to width: " + this.getImgLength()); // by calling our adjustOveflow, we will re-check the scrollWidth / height which // will adjust our size if necessary this.adjustOverflow(this._$labelOverflowed);},// Override getScrollWidth / Height - if we are overflow:"visible", and have a label we're // going to size ourselves according to its drawn dimensionsgetScrollWidth : function (calcNewValue,B,C,D) { if (this.overflow != isc.Canvas.VISIBLE || !isc.isA.Canvas(this.label)) return this.invokeSuper(isc.StatefulCanvas, "getScrollWidth", calcNewValue,B,C,D); if (this._deferredOverflow) { this._deferredOverflow = null; this.adjustOverflow("widthCheckWhileDeferred"); } if (!calcNewValue && this._scrollWidth != null) return this._scrollWidth; // _getAutoInnerWidth() will give us back the greater of our specified size / the // label's visible size + our end caps. // This is basically our "scroll size" if overflow is visible var scrollWidth = this._getAutoInnerWidth() return (this._scrollWidth = scrollWidth);},getScrollHeight : function (calcNewValue,B,C,D) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -