#include <qmainwindow.h>
#include <qstatusbar.h>
#include <qmessagebox.h>
#include <qmenubar.h>
#include <qapplication.h>
#include <qkeycode.h>
#include <qimage.h>

#include "canvas.h"

#include <stdlib.h>
require "qt2"
include Qt2
require "canvas_lib.rb"

#extern QString butterfly_fn
#extern QString logo_fn

    app = QApplication.new([$0]+ARGV)

#    /*
#    qDebug("sizeof(QCanvasPolygonalItem)=%d",sizeof(QCanvasPolygonalItem))
#    qDebug("sizeof(QCanvasText)=%d",sizeof(QCanvasText))
#    qDebug("sizeof(QWidget)=%d",sizeof(QWidget))
#    qDebug("sizeof(QLabel)=%d",sizeof(QLabel))
#    */

    
    
    if ( ARGV.size > 1 )
	$butterfly_fn = argv[1]
    else
	$butterfly_fn = "butterfly.png"
    end		
    
    if ( ARGV.size > 2 )
	$logo_fn = argv[2]
    else
	$logo_fn = "qtlogo.png"
    end

    canvas = QCanvas.new(800,450)
    canvas.setAdvancePeriod(30)
    m = Main.new()
    $main = m
    m.setCanvas(canvas)

    m.resize(m.sizeHint())

    #QApplication::qApp.setMainWidget(m)
    app.setMainWidget(m)

    
 #   if ( (QApplication::desktop().width() > m.width() + 10) && (QApplication::desktop().height() > m.height() +30) )
#	m.show()
 #   else
#	m.showMaximized()
  #  end

    m.show()
    #//    m.help()
    QApplication::qApp.setMainWidget(nil)

    Qt2::connect( QApplication::qApp, QSIGNAL("lastWindowClosed()"), QApplication::qApp, QSLOT("quit()") )

    app.exec()

