0
我试图用dojo.gfx创建一些简单的UI组件。我已经设法扩展了dojo.gfx.Group,但是我没有深入了解任何绘制到曲面的默认形状。在Firebug中检查渲染的SVG,有一个节点,但没有正确的。使用默认实例化形状扩展dojo.gfx.Group
简化类看起来是这样的:
dojo.provide("gfxui.SimpleButton");
dojo.require("dojox.gfx.shape");//-¿ needed?
dojo.require("dojox.gfx.svg");
dojo.require("dojox.gfx._base");
dojo.declare("gfxui.SimpleButton", dojox.gfx.Group, {
constructor: function(){
this.draw();
},
draw:function(){
var bg = this.createRect(this.rect_props);
//var bg = this.createObject(dojox.gfx.Rect);
}
}
gfxui.SimpleButton.nodeType = dojox.gfx.Group.nodeType;
dojo.extend(dojox.gfx.Surface, {
createButton: function(){
var button = this.createObject(gfxui.SimpleButton, null, true);
this.add(button);
return button;
}
});
而在HTML的JavaScript是这样的:
dojo.require("dojox.gfx");
dojo.require("gfxui.SimpleButton");
function init(){
var g = dojox.gfx;
var surface = dojox.gfx.createSurface(dojo.byId("gfx_holder"), 800, 280, "#eee");
var button = container.createButton();
};
dojo.addOnLoad(init);
是的,这确实不错,因为,你说,它只使用发布的gfx API。在创建小型UI库的情况下(原型设计目的),我会放弃使用getBoundingBox和直接矩阵操作等属性来访问属性,这对于自动定位有好处。此外,序列化会更棘手。 与此同时,虽然我发现它更有利于使用小部件并让CSS执行定位工作,然后使用gfx在此处演示绘制界面: http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/gfx/演示/ tooltip.html – droid001 2009-12-14 00:44:51