Code:
Ext.application({
name : 'RedBalloon',
viewport: {
autoMaximize: false
},
launch : function() {
Ext.create("Ext.TabPanel", {
fullscreen: true,
tabBarPosition: 'bottom',
items: [
{
title: 'Home',
iconCls: 'home',
cls: 'home',
html: [
'<img width="30%" src="http://staging.sencha.com/img/sencha.png" />',
'<h1>Welcome to Sencha Touch</h1>',
"<p>You're creating the Getting Started app. This demonstrates how ",
"to use tabs, lists and forms to create a simple app</p>",
'<h2>Sencha Touch (2.0.0pr1)</h2>'
].join("")
},
{
xtype: 'list',
title: 'List',
iconCls: 'star',
itemTpl: '{title}',
store: {
fields: ['title', 'url'],
data: [
{title: 'Ext Scheduler 2.0', url: 'ext-scheduler-2-0-upgrading-to-ext-js-4'},
{title: 'Previewing Sencha Touch 2', url: 'sencha-touch-2-what-to-expect'},
{title: 'Sencha Con 2011', url: 'senchacon-2011-now-packed-with-more-goodness'},
{title: 'Documentation in Ext JS 4', url: 'new-ext-js-4-documentation-center'}
]
}
},
{
title: 'Canvas',
iconCls: 'info',
xtype : 'panel',
layout : 'hbox',
items : [{
html : '<canvas id="TEST_CANVAS" width="320" height="280"></canvas>'
},
{
xtype : 'panel',
id : 'logger',
scrollable : true,
width : 320,
height : 280,
html : '<span>TEST CANVAS LOG</span>'
}]
}
]
}).setActiveItem(0);
this.canvas = document.getElementById('TEST_CANVAS');
this.ctx = this.canvas.getContext("2d");
this.pageX = 35;
this.pageY = 80;
var eventDispatcher = this.getEventDispatcher();
eventDispatcher.addListener('element', '#TEST_CANVAS', '*', this.logging, this);
var nTimer = setInterval(Ext.Function.bind(this.drawTest, this), 16);
},
logging : function(a, b, c, d) {
this.pageX = a.touch.point.x;
this.pageY = a.touch.point.y;
var logger = Ext.getCmp('logger'),
scroller = logger.getScrollable().getScroller();
logger.innerHtmlElement.createChild({
html : a.type + '[' + this.pageX + ', ' + this.pageY + ']' + ' : ' + d.info.eventName
});
scroller.scrollTo(0, scroller.getSize().y - scroller.getContainerSize().y);
},
drawTest : function() {
this.ctx.strokeStyle = '#' + parseInt(Math.random() * 0x1000000);
this.ctx.fillStyle = '#000';
this.ctx.font = '30px sans-serif bold';
this.ctx.textBaseline = 'top';
this.ctx.fillRect(0, 0, 320, 280);
this.ctx.fillStyle = '#FFF';
this.ctx.fillText('DoubleTab Here !!!', this.pageX, this.pageY);
this.ctx.strokeText('DoubleTab Here !!!', this.pageX, this.pageY);
}
});