📄 statefulcanvas.js
字号:
//> @attr statefulCanvas.showOverCanvas (boolean : false : [IRWA]) // When this property is set to true, this widget will create and show the // +link{StatefulCanvas.overCanvas} on user rollover. // @visibility external //< //> @attr statefulCanvas.overCanvas (AutoChild : null : [R]) // Auto generated child widget to be shown when the user rolls over this canvas if // +link{StatefulCanvas.showOverCanvas} is true. See documentation for +link{type:AutoChild} // for information on how to customize this canvas. // @visibility external //< //> @attr statefulCanvas.overCanvasConstructor (String : "Canvas" : [IRWA]) // Constructor class name for this widgets +link{statefulCanvas.overCanvas,overCanvas} // @visibility external //< overCanvasConstructor: "Canvas", //> @attr statefulCanvas.overCanvasDefaults (Canvas : { ... } : [IRWA]) // Default properties for this widgets +link{statefulCanvas.overCanvas,overCanvas}. To modify // these defaults, use +link{Class.changeDefaults()} // @visibility external //< overCanvasDefaults: { // override mouseOut to hide this canvas if the user rolls off it and out of the // parent/constructor mouseOut:function () { if (isc.EH.getTarget() != this.creator) this.clear(); return this.Super("mouseOut", arguments); } } });isc.StatefulCanvas.addMethods({//> @method statefulCanvas.init() (A)// Initialize this StatefulCanvas. Pass in objects with properties to add or override defaults.//// @param [all arguments] (object) objects with properties to override from default//<initWidget : function () { if (this.src == null) this.src = this.vertical ? this.vSrc : this.hSrc; var isEnabled = !this.isDisabled(); // the enabled property also affects the state of this object if (!isEnabled) { this._enabledState = this.state; this.state = isc.StatefulCanvas.STATE_DISABLED; } // if className has been specified and baseStyle has no default, copy className to // baseStyle. This is needed for the Label where you are expected to set className, not // baseStyle. // From then on the current className will be derived from the baseStyle setting plus the // current state, unless the widget suppresses className, which it may do if it has another // element the receives the baseStyle, and it leaves the handle unstyled. this.baseStyle = this.baseStyle || this.className; this.styleName = (this.suppressClassName ? null : this.getStateName()); this.className = this.styleName; // If this button has a radioGroup ID specified, update the array of widgets in the // radiogroup to include this one. if (this.radioGroup != null) { var rg = this.radioGroup; // clear out the property to avoid a no-op, then add with the standard setter this.radioGroup = null; this.addToRadioGroup(rg); } // Initialize autoFit this.setAutoFit(this.autoFit, true); if (this.shouldShowLabel()) this.makeLabel();},//> @method StatefulCanvas.shouldShowLabel()// Should this widget create a floating label for textual content - used for image based widgets.// Default implementation returns this.showTitle// @return (boolean) true if the floating label should be created//<shouldShowLabel : function () { return this.showTitle; },// State// ------------------------------------------------------------------------------------------------------// set the state for this object, and whether or not it is selected_$visualState:"visualState",stateChanged : function () { if (this.destroyed) return; if (this.logIsDebugEnabled(this._$visualState)) { this.logDebug("state changed to: " + this.getStateName(), "visualState"); } if (this.redrawOnStateChange) { this.markForRedraw("state change"); } // NOTE: a redraw doesn't update className if (!this.suppressClassName) { this.setClassName(this.getStateName()); } // set our label to the same state (note it potentially has independant styling) var label = this.label; if (label != null) { label.setState(this.getState()); label.setSelected(this.isSelected()); label.setCustomState(this.getCustomState()); }},//> @method statefulCanvas.setBaseStyle()// Sets the base CSS style. As the component changes state and/or is selected, suffixes will be// added to the base style.// @visibility external// @param style (className) new base style//< setBaseStyle : function (style) { this.baseStyle = style; if (this.label && this.titleStyle == null) this.label.setBaseStyle(style); // fall through to stateChanged to actually update the appearance this.stateChanged();},setTitleStyle : function (style) { this.titleStyle = style; if (this.label) { this.label.setBaseStyle(style || this.baseStyle); } this.stateChanged();},//> @method statefulCanvas.setState() (A)// Set the 'state' of this object, this changes it's appearance.//// @group state// @group appearance//// @see setDisabled() which also affects state values.//// @param newState (State) new state// @visibility external//<setState : function (newState) { if (this.state == newState) return; this.state = newState; this.stateChanged(); // update the appearance - redraw if necessary},_updateChildrenTopElement : function () { this.Super("_updateChildrenTopElement", arguments); this.setHandleDisabled(this.isDisabled());},//> @method statefulCanvas.getState() (A)// Return the state of this StatefulCanvas// @group state//// @visibility external// @return (State)//<getState : function () { return this.state;},//> @method statefulCanvas.setSelected()// Set this object to be selected or deselected.// @group state//// @param newIsSelected (boolean) new boolean value of whether or not the object is// selected.// @visibility external//<setSelected : function (newIsSelected) { if (this.selected == newIsSelected) return; // handle mutually exclusive radioGroups if (newIsSelected && this.radioGroup != null) { var groupArray = isc.StatefulCanvas._radioGroups[this.radioGroup]; // catch the (likely common) case of this.radioGroup being out of synch - implies // a developer has assigned directly to this.radioGroup without calling the setter if (groupArray == null) { this.logWarn("'radioGroup' property set for this widget, but no corresponding group " + "exists. To set up a new radioGroup containing this widget, or add this " + " widget to an existing radioGroup at runtime, call 'addToRadioGroup(groupID)'"); } else { for (var i = 0; i < groupArray.length; i++) { if (groupArray[i]!= this && groupArray[i].isSelected()) groupArray[i].setSelected(false); } } } this.selected = newIsSelected; if (this.label) this.label.setSelected(this.isSelected()); this.stateChanged();},//> @method statefulCanvas.select()// Select this object.// @group state// @visibility external//<select : function () { this.setSelected(true);},//> @method statefulCanvas.deselect()// Deselect this object.// @group state// @visibility external//<deselect : function () { this.setSelected(false);},//> @method statefulCanvas.isSelected()// Find out if this object is selected// @group state// @return (boolean)// @visibility external//<isSelected : function () { return this.selected;},// actionType - determines whether the button will select / deselect on activation//> @method statefulCanvas.getActionType() (A)// Return the 'actionType' for this canvas (radio / checkbox / button)// @group state// @group event handling// @visibility external//<getActionType : function () { return this.actionType;},//> @method statefulCanvas.setActionType() (A)// Update the 'actionType' for this canvas (radio / checkbox / button)// If the canvas is currently selected, and the passed in actionType is 'button'// this method will deselect the canvas.// @group state// @group event handling// @visibility external//<setActionType : function (actionType) { if (actionType == isc.StatefulCanvas.BUTTON && this.isSelected()) { this.setSelected(false); } this.actionType = actionType;},// radioGroups - automatic handling for mutually exclusive selection behavior between buttons//> @method statefulCanvas.addToRadioGroup(groupID) (A)// Add this widget to the specified mutually exclusive selection group with the ID// passed in.// Selecting this widget will then deselect any other StatefulCanvases with the same// radioGroup ID.// StatefulCanvases can belong to only one radioGroup, so this method will remove from // any other radiogroup of which this button is already a member.// @group state// @group event handling// @param groupID (string) - ID of the radiogroup to which this widget should be added// @visibility external//<addToRadioGroup : function (groupID) { // Bail if groupID is null, or if we already belong to the specified group, so we don't // get duplicated in the array if (groupID == null || this.radioGroup == groupID) return; if (this.radioGroup != null) this.removeFromRadioGroup(); this.radioGroup = groupID; // update the widget array for the specified group (stored on the Class object) if (isc.StatefulCanvas._radioGroups[this.radioGroup] == null) { isc.StatefulCanvas._radioGroups[this.radioGroup] = [this]; } else { isc.StatefulCanvas._radioGroups[this.radioGroup].add(this); } },//> @method statefulCanvas.removeFromRadioGroup(groupID) (A)// Remove this widget from the specified mutually exclusive selection group with the ID// passed in.// No-op's if this widget is not a member of the groupID passed in.// If no groupID is passed in, defaults to removing from whatever radioGroup this widget// is a member of.// @group state// @group event handling// @visibility external// @param [groupID] (string) - optional radio group ID (to ensure the widget is removed// from the appropriate group.//<removeFromRadioGroup : function (groupID) { // if we're passed the ID of a group we're not a member of, just bail if (this.radioGroup == null || (groupID != null && groupID != this.radioGroup)) return; var widgetArray = isc.StatefulCanvas._radioGroups[this.radioGroup]; widgetArray.remove(this); delete this.radioGroup; },// Enable/Disable// ------------------------------------------------------------------------------------------------------// to have an object redraw when it's enabled, set:// .redrawOnDisable = true//> @method statefulCanvas.setDisabled() (A)// Enable or disable this object// @group enable, state//// @param disabled (boolean) true if this widget is to be disabled// @visibility external//<setHandleDisabled : function (disabled,b,c,d) { this.invokeSuper(isc.StatefulCanvas, "setHandleDisabled", disabled,b,c,d); if (!this.showDisabled) return; // clear/restore the cursor and set the StatefulCanvas.STATE_DISABLED/StatefulCanvas.STATE_UP states. var handleIsDisabled = (this.state == isc.StatefulCanvas.STATE_DISABLED); if (handleIsDisabled == disabled) return; if (disabled == false) { if (this._savedCursor) this.setCursor(this._savedCursor); var enabledState = this._enabledState || isc.StatefulCanvas.STATE_UP; this.setState(enabledState); } else { this._savedCursor = this.cursor; this.setCursor(isc.StatefulCanvas.ARROW); // hang onto the enable state so that when we're next enabled we can reset to it. this._enabledState = this.state; this.setState(isc.StatefulCanvas.STATE_DISABLED); } },// CSS Style methods// ------------------------------------------------------------------------------------------// methods that allow style to change according to state.//> @method statefulCanvas.getStateName() (A)// Get the CSS styleName that should currently be applied to this component, reflecting// <code>this.baseStyle</code> and the widget's current state.// <P>// NOTE: this can differ from the style currently showing if the component has not yet updated// it's visual state after a state change.// // @group appearance// @return (CSSStyleName) name of the style to set the StatefulCanvas to//<getStateName : function () { var modifier = this._getStateNameModifier(); if (modifier) return this.baseStyle + modifier; return this.baseStyle;},//> @method statefulCanvas._getStateNameModifier() (A)// Return the modifier to the baseStyle that represents the CSS class for this StatefulCanvas.// @group appearance//// @return (CSSStyleName) name of the style to set the StatefulCanvas to//<_getStateNameModifier : function () { var state = this.getState(), selected = this.isSelected() ? isc.StatefulCanvas.SELECTED : null, focused = this.getFocusedState() ? isc.StatefulCanvas.FOCUSED : null, customState = this.getCustomState(); var modifier; if (selected || focused) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -