=begin
/****************************************************************************
** $Id: qt/examples/xmlquotes/main.cpp   2.2.2   edited 2000-08-31 $
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
**
** This file is part of an example program for Qt.  This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
=end
#include "richtext.h"
#include "quoteparser.h"
#include <qapplication.h>
#include <qfile.h>
#include <qmessagebox.h>
require "qt2"
include Qt2
require "qt2xml"
include Qt2xml

require "richtext.rb"
require "quoteparser.rb"

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

    #// parse xml file
    handler = QuoteHandler.new
    file = File.new( "quotes.xml" )
    source = QXmlInputSource.new() #("quotes.xml")
    source.setData( QString.new(file.read) )
    reader = QXmlSimpleReader.new
    reader.setContentHandler( handler )
    reader.setErrorHandler( handler )
    ok = reader.parse( source )
    file.close()
    if ( !ok ) 
	QMessageBox::criticalButtonText( nil, a.tr( "Parse Error" ),a.tr( handler.errorProtocol() ) )
#		a.tr( "Parse Error" ),
#		a.tr( handler.errorProtocol() ) )
	false
    end

    richtext = MyRichText.new(nil,"")
    richtext.setString( handler.quotes() )
    richtext.resize( 450, 350 )
    richtext.setCaption( "Fortune" )
    a.setMainWidget( richtext )
    richtext.show()

    a.exec()

