//
// form1.cpp
//

#include "interface.h"

#ifdef graphicOut

#include "form1.h"

#include <qvariant.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qtextedit.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>

#include "PaintPane.h"
#include "form1.ui.h"
/*
 *  Constructs a Form1 as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  TRUE to construct a modal dialog.
 */
Form1::Form1( QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "Form1" );

    textLabel1_2 = new QLabel( this, "textLabel1_2" );
    textLabel1_2->setGeometry( QRect( 10, 69, 88, 20 ) );

    textLabel1_3 = new QLabel( this, "textLabel1_3" );
    textLabel1_3->setGeometry( QRect( 10, 109, 99, 20 ) );

    textLabel1_5_3_2_2 = new QLabel( this, "textLabel1_5_3_2_2" );
    textLabel1_5_3_2_2->setGeometry( QRect( 10, 359, 105, 20 ) );

    textLabel1_5_5 = new QLabel( this, "textLabel1_5_5" );
    textLabel1_5_5->setGeometry( QRect( 10, 269, 80, 20 ) );

    gencountEdit = new QLineEdit( this, "gencountEdit" );
    gencountEdit->setGeometry( QRect( 120, 59, 101, 31 ) );

    textLabel1_4 = new QLabel( this, "textLabel1_4" );
    textLabel1_4->setGeometry( QRect( 10, 149, 93, 20 ) );

    eliteEdit = new QLineEdit( this, "eliteEdit" );
    eliteEdit->setEnabled( TRUE );
    eliteEdit->setGeometry( QRect( 120, 179, 100, 31 ) );

    pushButton5 = new QPushButton( this, "pushButton5" );
    pushButton5->setGeometry( QRect( 120, 389, 31, 31 ) );

    mutationEdit = new QLineEdit( this, "mutationEdit" );
    mutationEdit->setGeometry( QRect( 120, 139, 101, 31 ) );

    textLabel1_5 = new QLabel( this, "textLabel1_5" );
    textLabel1_5->setGeometry( QRect( 10, 189, 80, 20 ) );

    textLabel1_5_4 = new QLabel( this, "textLabel1_5_4" );
    textLabel1_5_4->setGeometry( QRect( 10, 229, 80, 20 ) );

    comboBox1 = new QComboBox( FALSE, this, "comboBox1" );
    comboBox1->setGeometry( QRect( 120, 299, 100, 20 ) );

    textLabel1_5_3_2 = new QLabel( this, "textLabel1_5_3_2" );
    textLabel1_5_3_2->setGeometry( QRect( 10, 329, 105, 20 ) );

    crossoverEdit = new QLineEdit( this, "crossoverEdit" );
    crossoverEdit->setGeometry( QRect( 120, 99, 101, 31 ) );

    textLabel1_5_3 = new QLabel( this, "textLabel1_5_3" );
    textLabel1_5_3->setGeometry( QRect( 10, 299, 105, 20 ) );

    paintPane = new PaintPane( this, "paintPane" );
    paintPane->setGeometry( QRect( 240, 19, 420, 340 ) );
    paintPane->setPaletteBackgroundColor( QColor( 255, 255, 255 ) );

    bestUnchanged = new QLineEdit( this, "bestUnchanged" );
    bestUnchanged->setGeometry( QRect( 120, 219, 101, 31 ) );

    comboBox3 = new QComboBox( FALSE, this, "comboBox3" );
    comboBox3->setGeometry( QRect( 120, 359, 100, 20 ) );

    textLabel1 = new QLabel( this, "textLabel1" );
    textLabel1->setGeometry( QRect( 10, 29, 80, 20 ) );

    tournamentSize = new QLineEdit( this, "tournamentSize" );
    tournamentSize->setGeometry( QRect( 120, 260, 101, 31 ) );

    comboBox2 = new QComboBox( FALSE, this, "comboBox2" );
    comboBox2->setGeometry( QRect( 120, 329, 100, 20 ) );

    pathEdit = new QLineEdit( this, "pathEdit" );
    pathEdit->setEnabled( FALSE );
    pathEdit->setGeometry( QRect( 160, 389, 500, 31 ) );

    stopButton = new QPushButton( this, "stopButton" );
    stopButton->setGeometry( QRect( 330, 590, 91, 31 ) );

    startButton = new QPushButton( this, "startButton" );
    startButton->setGeometry( QRect( 210, 590, 91, 31 ) );

    exitButton = new QPushButton( this, "exitButton" );
    exitButton->setGeometry( QRect( 450, 590, 91, 31 ) );

    messageEdit = new QTextEdit( this, "messageEdit" );
    messageEdit->setGeometry( QRect( 120, 470, 540, 110 ) );

    lineEdit9 = new QLineEdit( this, "lineEdit9" );
    lineEdit9->setGeometry( QRect( 120, 430, 540, 30 ) );

    textLabel1_5_2 = new QLabel( this, "textLabel1_5_2" );
    textLabel1_5_2->setGeometry( QRect( 20, 399, 90, 20 ) );

    textLabel1_5_2_2 = new QLabel( this, "textLabel1_5_2_2" );
    textLabel1_5_2_2->setGeometry( QRect( 20, 430, 90, 28 ) );

    popSizeEdit = new QLineEdit( this, "popSizeEdit" );
    popSizeEdit->setGeometry( QRect( 120, 19, 101, 31 ) );
    languageChange();
    resize( QSize(747, 623).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( exitButton, SIGNAL( clicked() ), this, SLOT( clickedExit() ) );
    connect( startButton, SIGNAL( clicked() ), this, SLOT( clickedStart() ) );
    connect( stopButton, SIGNAL( clicked() ), this, SLOT( clickedStop() ) );
    connect( pushButton5, SIGNAL( clicked() ), this, SLOT( openFile() ) );
    connect( exitButton, SIGNAL( clicked() ), this, SLOT( clickedExit() ) );

    // tab order
    setTabOrder( popSizeEdit, gencountEdit );
    setTabOrder( gencountEdit, crossoverEdit );
    setTabOrder( crossoverEdit, mutationEdit );
    setTabOrder( mutationEdit, eliteEdit );
    setTabOrder( eliteEdit, bestUnchanged );
    setTabOrder( bestUnchanged, tournamentSize );
    setTabOrder( tournamentSize, comboBox1 );
    setTabOrder( comboBox1, comboBox2 );
    setTabOrder( comboBox2, comboBox3 );
    setTabOrder( comboBox3, pushButton5 );
    setTabOrder( pushButton5, lineEdit9 );
    setTabOrder( lineEdit9, messageEdit );
    setTabOrder( messageEdit, startButton );
    setTabOrder( startButton, stopButton );
    setTabOrder( stopButton, exitButton );
    setTabOrder( exitButton, pathEdit );
}

/*
 *  Destroys the object and frees any allocated resources
 */
Form1::~Form1()
{
    // no need to delete child widgets, Qt does it all for us
}

/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void Form1::languageChange()
{
    setCaption( tr( "satGen v 1.0    by-=yaaara=- (c) 2k6" ) );
    textLabel1_2->setText( tr( "generations count:" ) );
    textLabel1_3->setText( tr( "crossover probability:" ) );
    textLabel1_5_3_2_2->setText( tr( "Crossover operator:" ) );
    textLabel1_5_5->setText( tr( "tournament size:" ) );
    textLabel1_4->setText( tr( "mutation probability:" ) );
    pushButton5->setText( tr( "..." ) );
    textLabel1_5->setText( tr( "elite strings:" ) );
    textLabel1_5_4->setText( tr( "best unchanged:" ) );
    comboBox1->clear();
    comboBox1->insertItem( tr( "Roulette wheel" ) );
    comboBox1->insertItem( tr( "Tournament selection" ) );
    comboBox1->insertItem( tr( "Random selection" ) );
    textLabel1_5_3_2->setText( tr( "Fitness method:" ) );
    textLabel1_5_3->setText( tr( "Selection method:" ) );
    comboBox3->clear();
    comboBox3->insertItem( tr( "Simple crossover" ) );
    comboBox3->insertItem( tr( "Two-point crossover" ) );
    comboBox3->insertItem( tr( "Uniform crossover" ) );
    comboBox3->insertItem( tr( "Improvement" ) );
    textLabel1->setText( tr( "population size:" ) );
    tournamentSize->setText( tr( "2" ) );
    comboBox2->clear();
    comboBox2->insertItem( tr( "Standard SAT" ) );
    comboBox2->insertItem( tr( "Weighted SAT" ) );
    stopButton->setText( tr( "info" ) );
    startButton->setText( tr( "start" ) );
    exitButton->setText( tr( "exit" ) );
    textLabel1_5_2->setText( tr( "input file:" ) );
    textLabel1_5_2_2->setText( tr( "weighted SAT\n"
"(parameters):" ) );
}

#endif
