예제 #1
0
파일: main.cs 프로젝트: 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();
    }
예제 #2
0
파일: t10.cs 프로젝트: KDE/qyoto
    public MyWidget(QWidget parent)
        : base(parent)
    {
        QPushButton quit = new QPushButton("Quit");

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

        LCDRange angle = new LCDRange();
        angle.SetRange(5,70);

        LCDRange force = new LCDRange();
        force.SetRange(10,50);

        CannonField field = new CannonField();
        Connect(angle, SIGNAL("valueChanged(int)"), field, SLOT("setAngle(int)"));
        Connect(field, SIGNAL("angleChanged(int)"), angle, SLOT("setValue(int)"));

        Connect(force, SIGNAL("valueChanged(int)"), field, SLOT("setForce(int)"));

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

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

        SetLayout(gridLayout);

        force.SetValue(25);
        angle.SetValue(60);
        angle.SetFocus();
    }
예제 #3
0
파일: gameboard.cs 프로젝트: KDE/qyoto
    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);

        QFrame cannonBox = new QFrame();
        cannonBox.SetFrameStyle((int) QFrame.Shape.WinPanel | (int) QFrame.Shadow.Sunken);

        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"));

        new QShortcut(Qt.Key.Key_Enter, this, SLOT("Fire()"));
        new QShortcut(Qt.Key.Key_Return, this, SLOT("Fire()"));
        new QShortcut((int) Qt.Modifier.CTRL + (int) Qt.Key.Key_Q, this, SLOT("close()"));

        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);

        QVBoxLayout cannonLayout = new QVBoxLayout();
        cannonLayout.AddWidget(cannonField);
        cannonBox.SetLayout(cannonLayout);

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

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

        NewGame();
    }
예제 #4
0
파일: t8.cs 프로젝트: 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();
        angle.SetRange(5,70);

        CannonField field = new CannonField();

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

        QGridLayout gridLayout = new QGridLayout();
        gridLayout.AddWidget(quit, 0, 0);
        gridLayout.AddWidget(angle, 1, 0);
        gridLayout.AddWidget(field, 1, 1, 2, 1);
        gridLayout.SetColumnStretch(1, 10);
        SetLayout(gridLayout);

        angle.SetValue(60);
        angle.SetFocus();
    }
예제 #5
0
파일: gameboard.cs 프로젝트: KDE/qyoto
    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();
    }