Пример #1
0
    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);
        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();
    }
Пример #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
    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
    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();
    }