/*
 *  SPL - The SPL Programming Language
 *  Copyright (C) 2004, 2005  Clifford Wolf <clifford@clifford.at>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  qtdemo005.spl: A demo for the QCanvas class
 */

load "qt";

var a = new qt.QApplication();
var c = new qt.QCanvas(300, 150);
var cv = new qt.QCanvasView(c);

var col, brush, e;

col[0] = qt_autodelete(new qt.QColor(200, 100, 100));
col[1] = qt_autodelete(new qt.QColor(100,  50, 250));
col[2] = qt_autodelete(new qt.QColor(100, 100,   0));
col[3] = qt_autodelete(new qt.QColor(200,   0, 150));
col[4] = qt_autodelete(new qt.QColor( 50, 250,   0));
col[5] = qt_autodelete(new qt.QColor( 20, 100,  10));

e[0] = new qt.QCanvasEllipse(200, 100,  12*16,  90*16, c);
e[1] = new qt.QCanvasEllipse(200, 100, 102*16,  70*16, c);
e[2] = new qt.QCanvasEllipse(200, 100, 172*16, 100*16, c);
e[3] = new qt.QCanvasEllipse(200, 100, 272*16,  58*16, c);
e[4] = new qt.QCanvasEllipse(200, 100, 330*16,  42*16, c);

for (var i=0; i<5; i++) {
	brush[i] = new qt.QBrush(col[i]);
	e[i].setBrush(brush[i]);
	e[i].setX(150);
	e[i].setY(75);
	e[i].show();
}

c.setAdvancePeriod(20);
c.setBackgroundColor(col[5]);

a.setMainWidget(cv);
cv.show();
a.exec();

// QBrush objects are not derived from QObject, so they are not deleted
// automatically. We eighter need to do it manually or use qt_autodelete()
// as we have done with the QColor objects in this example.
foreach[] o (brush) qt_delete(o);

