📄 canvasitem.js
字号:
/*
* Isomorphic SmartClient
* Version 6.5 (2008-04-30)
* Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
* "SmartClient" is a trademark of Isomorphic Software, Inc.
*
* licensing@smartclient.com
*
* http://smartclient.com/license
*/
//> @class CanvasItem// Form item which renders a Canvas inline in a DynamicForm instance.// @treeLocation Client Reference/Forms/Form Items// @visibility external//<isc.ClassFactory.defineClass("CanvasItem", "FormItem");isc.CanvasItem.addProperties({ width:"*", height:null, shouldSaveValue:false, // ------------------------ // Methods applied directly to this.canvas (fired in the scope of the canvas, not the // canvasItem- use this.canvasItem to point back to the item). // set up observation of resizing _canvas_resized : function (deltaX, deltaY, reason) { if (this.Super("resized", arguments) == false) return; // CanvasResized will cause a form redraw - only call this if we're not drag // resizing to avoid redrawing repeatedly during drag resize interactions. if (!this.dragResizing()) { this.canvasItem.canvasResized(deltaX, deltaY, reason); } }, _canvas_dragResized : function () { this.canvasItem.canvasResized(1,1); // HACK: return this.Super("dragResized", arguments); }, _canvas_focusInNextTabElement : function (forward, mask) { return this.canvasItem.form._focusInNextTabElement(forward, mask); } //> @attr canvasItem.canvas (Canvas : null : [IRW]) // // The canvas that will be displayed inside this item. You can pass an instance you've // already created, or its global ID as a String. If none is passed, one will be // auto-created using the overrideable defaults: +link{attr:CanvasItem.canvasProperties} and // +link{attr:CanvasItem.canvasConstructor} // // @visibility external //< //> @attr canvasItem.canvasConstructor (String : "Canvas" : [IRW]) // // If +link{canvasItem.canvas, this.canvas} is not specified as a canvas instance at init // time, a canvas will be created instead. This property denotes the class of that widget // (Should be set to the name of a subclass of Canvas). // // @visibility external //< //> @attr canvasItem.canvasDefaults (Object : {} : [IRW]) // // Default properties for the canvas if this.canvas is not already a canvas instance. // // @visibility external //< //> @attr canvasItem.canvasProperties (Object : {} : [IRW]) // // Properties to apply to this canvas on creation if this.canvas is not already a canvas // instance. // // @visibility external //< // whether to destroy our Canvas when we are destroyed. Appropriate for most CanvasItems // that auto-create a Canvas. // //autoDestroy: false //showTitle:false});isc.CanvasItem.addMethods({ init : function () { this.Super("init", arguments); this._createCanvas(); }, // A straight canvasItem is non-editable. Subclasses that allow editing (such as the sliderItem) // will override this method to return true isEditable : function () { return false; }, // _createCanvas Method to ensure that the canvas for this item has been instantiated // with appropriate properties, and added to the containerWidget as a child. _createCanvas : function () { //>DEBUG if (!isc.isAn.Object(this.canvas) && !this.canvasProperties) { this.logWarn("CanvasItem: " + (this.getFieldName() ? this.getFieldName() : this.getID()) + " defined with no canvas property - creating a default " + "canvas for this item."); } //<DEBUG var canvasProps = { // don't redraw when the form redraws - if the developer wishes to redraw this canvas // they will have to call redraw() on this form item, or on the Canvas directly. _redrawWithParent: false, // one time flag to suppress automatic drawing on addChild(). Very key, as a form // that has setItems() called on it after creation recreates all items with the // form already drawn. _dontDrawOnAddChild: true, // Always set initial tabIndex to -1. This will avoid the canvas from ever getting // an auto-assigned tab index and having a prev/next tab-widget. // Note that as part of 'setElementTabIndex()' we will explicitly assign the // desired tabIndex. tabIndex:-1, //hideUsingDisplayNone:true, // Hang a pointer on the canvas back to this form item. canvasItem: this, disabled: this.isDisabled() }; canvasProps.resized = this._canvas_resized; canvasProps.dragResized = this._canvas_dragResized; // Override synthetic focus manipulation methods to fall back to the DF, since that // already manages moving focus between form items on tab / shift tab keypress when // the clickMask is up canvasProps._focusInNextTabElement = this._canvas_focusInNextTabElement; // pass our datasource, if any to the CanvasItem if (this.dataSource) canvasProps.dataSource = this.dataSource; // pass on our prompt (if any) to the CanvasItem if (this.prompt) canvasProps.prompt = this.prompt; // We'll set the tabIndex on the canvas when we write out our innerHTML. // pass on our accessKey if appropriate if (this.accessKey != null) canvasProps.accessKey = this.accessKey; // pass on 'showFocused' if (this.showFocused != null) canvasProps.showFocused = this.showFocused; if (this.showFocusedAsOver != null) canvasProps.showFocusedAsOver = this.showFocusedAsOver; if (isc.isA.String(this.canvas) && window[this.canvas]) this.canvas = window[this.canvas]; // if the canvas hasn't been instantiated for us, use the autoChild method to create it // otherwise we have to do a bunch of manual patching to achieve the same effect. if (!isc.isA.Canvas(this.canvas)) { // pick up any properties specified directly on the 'this.canvas' object isc.addProperties(canvasProps, this.canvas); if (canvasProps.ID == null) canvasProps.ID = null; // since we're auto-creating it's appropriate to autoDestroy this.autoDestroy = true; this.addAutoChild("canvas", canvasProps, isc.Canvas, this.containerWidget); } else { // apply dynamic properties to existing canvas // (Call setter methods wherever necessary). this.canvas.setTabIndex(-1); this.canvas.setPrompt(this.prompt); this.canvas.setAccessKey(this.accessKey); isc.addProperties(this.canvas, canvasProps); if (canvasProps.dataSource) this.canvas.bindToDataSource(); this.canvas.setDisabled(this.isDisabled()); this.containerWidget.addChild(this.canvas); } }, /* // Ensure redraw on this item redraws the Canvas. redraw : function (suppressCanvasRedraw) { // redraw the canvas before redrawing our innerHTML - allows us to calculate sizes // accurately, if they change. if (!suppressCanvasRedraw && this.canvas.isDrawn()) { this.canvas.redraw("canvasItem.redraw"); } this.Super("redraw", arguments); }, */ // clear the pointer on this item's canvas back to this item on destroy() destroy : function () { if (this.canvas) { delete this.canvas.canvasItem; if (this.autoDestroy) this.canvas.destroy(true); else if (this.canvas.visibility != isc.Canvas.HIDDEN) this.canvas.hide(); } return this.Super("destroy", arguments); }, placeCanvas : function (delayed) { var canvas = this.canvas; // show or hide the Canvas according to whether this item is visible, so that showIfs work if (this.visible == false) { canvas.hide(); canvas.moveTo(0,0); return; } if (this.form && !this.form.isDrawn() && this.form.position == isc.Canvas.RELATIVE) { //this.logWarn("hiding Canvas during initial relative draw"); canvas.hide(); return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -