Example #1
0
    public MyWidget(QWidget parent) : base(parent)
    {
        QPushButton quit = new QPushButton("&Quit");

        quit.Font = new QFont("Times", 18, (int)QFont.Weight.Bold);

        Connect(quit, SIGNAL("clicked()"), qApp, SLOT("quit()"));

        LCDRange angle = new LCDRange(null);

        angle.setRange(5,70);

        LCDRange force = new LCDRange(null);

        force.setRange(10,50);

        CannonField cannonField = new CannonField(null);

        Connect(angle,SIGNAL("valueChanged(int)"),
                cannonField,SLOT("setAngle(int)"));
        Connect(cannonField,SIGNAL("angleChanged(int)"),
                angle,SLOT("setValue(int)"));

        Connect(force,SIGNAL("valueChanged(int)"),
                cannonField,SLOT("setForce(int)"));
        Connect(cannonField,SIGNAL("forceChanged(int)"),
                force,SLOT("setValue(int)"));

        QPushButton shoot = new QPushButton("&Shoot");

        shoot.Font = new QFont("Times",18,(int)QFont.Weight.Bold);

        Connect(shoot,SIGNAL("clicked()"),cannonField,SLOT("shoot()"));

        QHBoxLayout topLayout = new QHBoxLayout();

        topLayout.AddWidget(shoot);
        topLayout.AddStretch(1);

        QVBoxLayout leftLayout = new QVBoxLayout();

        leftLayout.AddWidget(angle);
        leftLayout.AddWidget(force);

        QGridLayout gridLayout = new QGridLayout();

        gridLayout.AddWidget(quit,0,0);
        gridLayout.AddLayout(topLayout,0,1);
        gridLayout.AddLayout(leftLayout,1,0);
        gridLayout.AddWidget(cannonField,1,1,2,1);
        gridLayout.SetColumnStretch(1,10);
        SetLayout(gridLayout);

        angle.setValue(60);
        force.setValue(25);
        angle.SetFocus();
    }
Example #2
0
File: main.cs Project: KDE/qyoto
    public MyWidget(QWidget parent)
        : base(parent)
    {
        QPushButton quit = new QPushButton("&Quit");
        quit.Font = new QFont("Times", 18, (int) QFont.Weight.Bold);

        Connect(quit, SIGNAL("clicked()"), qApp, SLOT("quit()"));

        LCDRange angle = new LCDRange(null);
        angle.setRange(5, 70);

        LCDRange force = new LCDRange(null);
        force.setRange(10, 50);

        CannonField cannonField = new CannonField(null);

        Connect(angle, SIGNAL("valueChanged(int)"),
            cannonField, SLOT("setAngle(int)"));
        Connect(cannonField, SIGNAL("angleChanged(int)"),
            angle, SLOT("setValue(int)"));

        Connect(force, SIGNAL("valueChanged(int)"),
            cannonField, SLOT("setForce(int)"));
        Connect(cannonField, SIGNAL("forceChanged(int)"),
            force, SLOT("setValue(int)"));

        QPushButton shoot = new QPushButton("&Shoot");
        shoot.Font = new QFont("Times", 18, (int) QFont.Weight.Bold);

        Connect(shoot, SIGNAL("clicked()"), cannonField, SLOT("shoot()"));

        QHBoxLayout topLayout = new QHBoxLayout();
        topLayout.AddWidget(shoot);
        topLayout.AddStretch(1);

        QVBoxLayout leftLayout = new QVBoxLayout();
        leftLayout.AddWidget(angle);
        leftLayout.AddWidget(force);

        QGridLayout gridLayout = new QGridLayout();
        gridLayout.AddWidget(quit, 0, 0);
        gridLayout.AddLayout(topLayout, 0, 1);
        gridLayout.AddLayout(leftLayout, 1, 0);
        gridLayout.AddWidget(cannonField, 1, 1, 2, 1);
        gridLayout.SetColumnStretch(1, 10);
        SetLayout(gridLayout);

        angle.setValue(60);
        force.setValue(25);
        angle.SetFocus();
    }
Example #3
0
    public GameBoard(QWidget parent) : base(parent)
    {
        QPushButton quit = new QPushButton("&Quit");

        quit.Font = new QFont("Times", 18, (int)QFont.Weight.Bold);

        Connect(quit, SIGNAL("clicked()"), qApp, SLOT("quit()"));

        LCDRange angle = new LCDRange(Tr("ANGLE"));

        angle.setRange(5,70);

        LCDRange force = new LCDRange(Tr("FORCE"));

        force.setRange(10,50);

        cannonField = new CannonField();

        Connect(angle,SIGNAL("valueChanged(int)"),
                cannonField,SLOT("setAngle(int)"));
        Connect(cannonField,SIGNAL("angleChanged(int)"),
                angle,SLOT("setValue(int)"));

        Connect(force,SIGNAL("valueChanged(int)"),
                cannonField,SLOT("setForce(int)"));
        Connect(cannonField,SIGNAL("forceChanged(int)"),
                force,SLOT("setValue(int)"));

        Connect(cannonField,SIGNAL("hit()"),
                this,SLOT("hit()"));
        Connect(cannonField,SIGNAL("missed()"),
                this,SLOT("missed()"));

        QPushButton shoot = new QPushButton("&Shoot");

        shoot.Font = new QFont("Times",18,(int)QFont.Weight.Bold);

        Connect(shoot,SIGNAL("clicked()"),
                this,SLOT("fire()"));
        Connect(cannonField,SIGNAL("canShoot(bool)"),
                shoot,SLOT("setEnabled(bool)"));

        QPushButton restart = new QPushButton(Tr("&New Game"));

        restart.Font = new QFont("Times",18,(int)QFont.Weight.Bold);

        Connect(restart,SIGNAL("clicked()"),this,SLOT("newGame()"));

        hits = new QLCDNumber(2);
        hits.segmentStyle = QLCDNumber.SegmentStyle.Filled;

        shotsLeft = new QLCDNumber(2);
        shotsLeft.segmentStyle = QLCDNumber.SegmentStyle.Filled;

        QLabel hitsLabel      = new QLabel(Tr("HITS"));
        QLabel shotsLeftLabel = new QLabel(Tr("SHOTS LEFT"));

        QHBoxLayout topLayout = new QHBoxLayout();

        topLayout.AddWidget(shoot);
        topLayout.AddWidget(hits);
        topLayout.AddWidget(hitsLabel);
        topLayout.AddWidget(shotsLeft);
        topLayout.AddWidget(shotsLeftLabel);
        topLayout.AddStretch(1);
        topLayout.AddWidget(restart);

        QVBoxLayout leftLayout = new QVBoxLayout();

        leftLayout.AddWidget(angle);
        leftLayout.AddWidget(force);

        QGridLayout gridLayout = new QGridLayout();

        gridLayout.AddWidget(quit,0,0);
        gridLayout.AddLayout(topLayout,0,1);
        gridLayout.AddLayout(leftLayout,1,0);
        gridLayout.AddWidget(cannonField,1,1,2,1);
        gridLayout.SetColumnStretch(1,10);
        SetLayout(gridLayout);

        angle.setValue(60);
        force.setValue(25);
        angle.SetFocus();

        newGame();
    }
Example #4
0
    public GameBoard(QWidget parent)
        : base(parent)
    {
        QPushButton quit = new QPushButton("&Quit");
        quit.Font = new QFont("Times", 18, (int) QFont.Weight.Bold);

        Connect(quit, SIGNAL("clicked()"), qApp, SLOT("quit()"));

        LCDRange angle = new LCDRange(Tr("ANGLE"));
        angle.setRange(5, 70);

        LCDRange force = new LCDRange(Tr("FORCE"));
        force.setRange(10, 50);

        cannonField = new CannonField();

        Connect(angle, SIGNAL("valueChanged(int)"),
            cannonField, SLOT("setAngle(int)"));
        Connect(cannonField, SIGNAL("angleChanged(int)"),
            angle, SLOT("setValue(int)"));

        Connect(force, SIGNAL("valueChanged(int)"),
            cannonField, SLOT("setForce(int)"));
        Connect(cannonField, SIGNAL("forceChanged(int)"),
            force, SLOT("setValue(int)"));

        Connect(cannonField, SIGNAL("hit()"),
            this, SLOT("hit()"));
        Connect(cannonField, SIGNAL("missed()"),
            this, SLOT("missed()"));

        QPushButton shoot = new QPushButton("&Shoot");
        shoot.Font = new QFont("Times", 18, (int) QFont.Weight.Bold);

        Connect(shoot, SIGNAL("clicked()"),
            this, SLOT("fire()"));
        Connect(cannonField, SIGNAL("canShoot(bool)"),
            shoot, SLOT("setEnabled(bool)"));

        QPushButton restart = new QPushButton(Tr("&New Game"));
        restart.Font = new QFont("Times", 18, (int) QFont.Weight.Bold);

        Connect(restart, SIGNAL("clicked()"), this, SLOT("newGame()"));

        hits = new QLCDNumber(2);
        hits.segmentStyle = QLCDNumber.SegmentStyle.Filled;

        shotsLeft = new QLCDNumber(2);
        shotsLeft.segmentStyle = QLCDNumber.SegmentStyle.Filled;

        QLabel hitsLabel = new QLabel(Tr("HITS"));
        QLabel shotsLeftLabel = new QLabel(Tr("SHOTS LEFT"));

        QHBoxLayout topLayout = new QHBoxLayout();
        topLayout.AddWidget(shoot);
        topLayout.AddWidget(hits);
        topLayout.AddWidget(hitsLabel);
        topLayout.AddWidget(shotsLeft);
        topLayout.AddWidget(shotsLeftLabel);
        topLayout.AddStretch(1);
        topLayout.AddWidget(restart);

        QVBoxLayout leftLayout = new QVBoxLayout();
        leftLayout.AddWidget(angle);
        leftLayout.AddWidget(force);

        QGridLayout gridLayout = new QGridLayout();
        gridLayout.AddWidget(quit, 0, 0);
        gridLayout.AddLayout(topLayout, 0, 1);
        gridLayout.AddLayout(leftLayout, 1, 0);
        gridLayout.AddWidget(cannonField, 1, 1, 2, 1);
        gridLayout.SetColumnStretch(1, 10);
        SetLayout(gridLayout);

        angle.setValue(60);
        force.setValue(25);
        angle.SetFocus();

        newGame();
    }