int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: backgroundButtonGroupClicked((*reinterpret_cast< QAbstractButton*(*)>(_a[1]))); break;
        case 1: buttonGroupClicked((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: deleteItem(); break;
        case 3: pointerGroupClicked((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: bringToFront(); break;
        case 5: sendToBack(); break;
        case 6: itemInserted((*reinterpret_cast< DiagramItem*(*)>(_a[1]))); break;
        case 7: textInserted((*reinterpret_cast< QGraphicsTextItem*(*)>(_a[1]))); break;
        case 8: currentFontChanged((*reinterpret_cast< const QFont(*)>(_a[1]))); break;
        case 9: fontSizeChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 10: sceneScaleChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 11: textColorChanged(); break;
        case 12: itemColorChanged(); break;
        case 13: lineColorChanged(); break;
        case 14: textButtonTriggered(); break;
        case 15: fillButtonTriggered(); break;
        case 16: lineButtonTriggered(); break;
        case 17: handleFontChange(); break;
        case 18: itemSelected((*reinterpret_cast< QGraphicsItem*(*)>(_a[1]))); break;
        case 19: about(); break;
        default: ;
        }
        _id -= 20;
    }
    return _id;
}
Exemple #2
0
/**
 * Instantiates, configures, and returns label for scoreboard.
 */
GLabel initScoreboard(GWindow window)
{
    GLabel label = newGLabel("");
    setFont(label, "SansSerif-72");
    setColor(label, "GRAY");
    add(window, label);
    sendToBack(label);
    return label;
}
Exemple #3
0
 DubLL(const DubLL<T>& original) {
   frnt = NULL;
   bak = NULL;
   Node<T> *temp = original.frnt;
   while (temp != NULL) {
     sendToBack(temp->data);
     temp = temp->next;
   }
 }
/**
 * Instantiates, configures, and returns label for scoreboard.
 */
GLabel initScoreboard(GWindow window)
{
  GLabel label = newGLabel("CLICK");
  double x = (WIDTH - getWidth(label)) / 2;
  double y = (HEIGHT + getFontAscent(label)) / 2;
  setFont(label, "Courier 10 Pitch-bold-50");
  setColor(label, "#cccccc");
  setLocation(label, x, y);
  sendToBack(label);
  return label;
}
Exemple #5
0
/*
 * Instantiates, configures, and returns label for scoreboard.
 */
GLabel initScoreboard(GWindow window)
{	
    GLabel label = newGLabel("0");
    double x = (WIDTH / 2) - (getWidth(label) + 4.5);
    double y = ((HEIGHT - getHeight(label)) / 2) - RADIUS;
    setLocation(label, x, y);
    setColor(label, "GRAY");
    setFont(label, "Dialog-40");
    add(window, label);
    sendToBack(label);
    return label;
}
void DiagramWindow::createActions()
{
    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    addNodeAction = new QAction(QIcon(":/images/node.png"), tr("Add &Node"), this);
    addNodeAction->setShortcut(QKeySequence::New);
    connect(addNodeAction, SIGNAL(triggered()), this, SLOT(addNode()));

    addLinkAction = new QAction(QIcon(":/images/link.png"), tr("Add &Link"), this);
    addLinkAction->setShortcut(tr("Ctrl+L"));
    connect(addLinkAction, SIGNAL(triggered()), this, SLOT(addLink()));

    deleteAction = new QAction(QIcon(":/images/delete.png"), tr("&Delete"), this);
    deleteAction->setShortcut(tr("Del"));
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(del()));

    cutAction = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
    cutAction->setShortcut(QKeySequence::Cut);
    connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));

    copyAction = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
    copyAction->setShortcut(QKeySequence::Copy);
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));

    pasteAction = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
    pasteAction->setShortcut(QKeySequence::Paste);
    connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));

    bringToFrontAction = new QAction(QIcon(":/images/bringtofront.png"), tr("Bring to &Front"), this);
    connect(bringToFrontAction, SIGNAL(triggered()), this, SLOT(bringToFront()));

    sendToBackAction = new QAction(QIcon(":/images/sendtoback.png"), tr("&Send to Back"), this);
    connect(sendToBackAction, SIGNAL(triggered()), this, SLOT(sendToBack()));

    propertiesAction = new QAction(tr("P&roperties..."),this);
    connect(propertiesAction, SIGNAL(triggered()), this, SLOT(properties()));
}
Exemple #7
0
void MainWindow::createActions()
{

    toFrontAction = new QAction(QIcon(":/images/bringtofront.png"),
                                tc->toUnicode("Bring to &Front"), this);
    toFrontAction->setShortcut(tc->toUnicode("Ctrl+F"));
    toFrontAction->setStatusTip(tc->toUnicode("Bring item to front"));
    connect(toFrontAction, SIGNAL(triggered()),
            this, SLOT(bringToFront()));


    sendBackAction = new QAction(QIcon(":/images/sendtoback.png"),
                                 tc->toUnicode("Send to &Back"), this);
    sendBackAction->setShortcut(tc->toUnicode("Ctrl+B"));
    sendBackAction->setStatusTip(tc->toUnicode("Send item to back"));
    connect(sendBackAction, SIGNAL(triggered()),
        this, SLOT(sendToBack()));

	checkAction = new QAction(QIcon(":/images/check.png"),
								tc->toUnicode("Check"), this);

	checkAction->setShortcut(tc->toUnicode("Ctrl+M"));
	checkAction->setStatusTip(tc->toUnicode("Check Model"));
    connect(checkAction, SIGNAL(triggered()),
        this, SLOT(check()));

	BHAct = new QAction(QIcon(":/images/BH.png"),
								tc->toUnicode("clear"), this);

	BHAct->setShortcut(tc->toUnicode("Ctrl+K"));
	BHAct->setStatusTip(tc->toUnicode("Clear Body"));
    connect(BHAct, SIGNAL(triggered()),
        this, SLOT(setBH()));

	JHAct = new QAction(QIcon(":/images/JH.png"),
								tc->toUnicode("not clear"), this);

	JHAct->setShortcut(tc->toUnicode("Ctrl+L"));
	JHAct->setStatusTip(tc->toUnicode("Not Clear Body"));

    connect(JHAct, SIGNAL(triggered()),
        this, SLOT(setJH()));

    deleteAction = new QAction(QIcon(":/images/delete.png"),
                               tc->toUnicode("&Delete"), this);
    deleteAction->setShortcut(tc->toUnicode("Delete"));
    deleteAction->setStatusTip(tc->toUnicode("Delete item from diagram"));
    connect(deleteAction, SIGNAL(triggered()),
        this, SLOT(deleteItem()));
	
	exitAction = new QAction(tc->toUnicode("E&xit"), this);
    exitAction->setShortcuts(QKeySequence::Quit);
    exitAction->setStatusTip(tc->toUnicode("Quit Scenediagram example"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

	aboutAction = new QAction(tc->toUnicode("A&bout"), this);
    aboutAction->setShortcut(tc->toUnicode("Ctrl+B"));
    connect(aboutAction, SIGNAL(triggered()),
            this, SLOT(about()));

	saveAct = new QAction(tc->toUnicode("&Save"), this);
    saveAct->setShortcuts(QKeySequence::Save);
    saveAct->setStatusTip(tc->toUnicode("Save the document to disk"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

	saveVRMLAct = new QAction(tc->toUnicode("&SaveVRML"), this);
	saveVRMLAct->setStatusTip(tc->toUnicode("Save the vrml to disk"));
	connect(saveVRMLAct, SIGNAL(triggered()), this, SLOT(saveVRML()));

	openAct = new QAction(tc->toUnicode("&Open"), this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tc->toUnicode("Open the document to disk"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));

    saveAsAct = new QAction(tc->toUnicode("Save &As..."), this);
    saveAsAct->setShortcuts(QKeySequence::SaveAs);
    saveAsAct->setStatusTip(tc->toUnicode("Save the document under a new name"));
    connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));



}
int main(void)
{
    // seed pseudorandom number generator
    srand48(time(NULL));

    // instantiate window
    GWindow window = newGWindow(WIDTH, HEIGHT);

    // instantiate bricks
    initBricks(window);

    // instantiate ball, centered in middle of window
    GOval ball = initBall(window);

    // instantiate paddle, centered at bottom of window
    GRect paddle = initPaddle(window);

    // instantiate scoreboard, centered in middle of window, just above ball
    GLabel label = initScoreboard(window);

    // number of bricks initially
    int bricks = COLS * ROWS;

    // number of lives initially
    int lives = LIVES;

    // number of points initially
    int points = 0;
	
	//  make the ball’s initial velocity along its (horizontal) x-axis random.
	srand48((long int) time(NULL));
	double velocityX = -BALL_VELOCITY + 2 * BALL_VELOCITY * drand48();
	double velocityY = BALL_VELOCITY;
	
	while (true)
	{ 
	    GEvent event = getNextEvent(MOUSE_EVENT);
		if (event != NULL)
		{
		    if (getEventType(event) == MOUSE_CLICKED)
			{
			    break;
			}
						
		}
	}

    // keep playing until game over
    while (lives > 0 && bricks > 0)
    {
        // TODO		
		move(ball, velocityX, velocityY);
		
		GEvent event = getNextEvent(MOUSE_EVENT);
		if (event != NULL)
		{			
			if (getEventType(event) == MOUSE_MOVED)
			{
				double x = 0;
				if (getX(event) - PADDLE_WIDTH / 2 <= 0)
				{
				    x = 0;	
				} 
				else if (getX(event) + PADDLE_WIDTH / 2 >= WIDTH)
				{
					x = WIDTH - PADDLE_WIDTH;
				}
				else
			    {
					x = getX(event) - PADDLE_WIDTH / 2;
				}			
				
				double y = getY(paddle);
				setLocation(paddle, x, y);
			}
		}		
		
		if (getX(ball) + 2 * RADIUS >= WIDTH)
		{
			velocityX = -velocityX;
		}
		else if (getX(ball) <= 0)
		{
			velocityX = -velocityX;
		}
		/*// the bottom edge condition
		else if (getY(ball) + 2 * RADIUS >= HEIGHT)
		{
			velocityY = -velocityY;
		}
		*/		
		else if (getY(ball) > getY(paddle) + PADDLE_WIDTH / 2)
		{
			lives--;
			if (lives > 0)
		    {				
			    while (true)
				{ 
			        GEvent event = getNextEvent(MOUSE_EVENT);
				    if (event != NULL)
					{
						if (getEventType(event) == MOUSE_CLICKED)
						{
						    break;
						}
						
					}
			    }
                				
			    setLocation(ball, (getWidth(window) - 2 * RADIUS) / 2,
                                   (getHeight(window) - 2 * RADIUS) / 2);
			    move(ball, velocityX, velocityY);
		    }			
		}		
		else if (getY(ball) <= 0)
		{
			velocityY = -velocityY;
		}
		
		GObject object = detectCollision(window, ball);
		
		if (object != NULL)
        {
            if (object == paddle)
            {
                // TODO
		        velocityY = -velocityY;   
            }		
		    /*// More generally with the same functionality
		    if (strcmp(getType(object), "GRect") == 0)
            {
                // TODO
            }
		    */
		    if (strcmp(getType(object), "GLabel") == 0)
            {
                // TODO
				sendToBack(object);
            }
		
		    if (strcmp(getType(object), "GRect") == 0 && object != paddle)
            {
                // TODO
				bricks--;				
			    removeGWindow(window, object);				
				updateScoreboard(window, label, ++points);
				velocityY = -velocityY;
            }
        }
		
		pause(8);
    }

    // wait for click before exiting
    waitForClick();

    // game over
    closeGWindow(window);
    return 0;
}
void MainWindow::creatActions()
{
    //LogicItem

    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    addAndGateAction = new QAction(tr("Insert AND"), this);
    addAndGateAction->setCheckable(true);
    addAndGateAction->setIcon(QIcon(":/images/node.png"));
    addAndGateAction->setShortcut(tr("Ctrl+N"));

    addOrGateAction = new QAction(tr("OR"), this);
    addOrGateAction->setCheckable (true);

    addNotGateAction = new QAction(tr("NOT"), this);
    addNotGateAction->setCheckable(true);
    addNotGateAction->setIcon(QIcon());

    addTextAction = new QAction(tr("Insert Text"),this);
    addTextAction->setCheckable(true);

    actionGroup = new QActionGroup(this);
    actionGroup->addAction(addAndGateAction);
    actionGroup->addAction(addOrGateAction);
    actionGroup->addAction(addNotGateAction);
    actionGroup->setExclusive(true);
    connect(actionGroup,SIGNAL(triggered(QAction*)),this,SLOT(actionGroupClicked(QAction*)));

    deleteAction = new QAction(tr("&Delete"), this);
    deleteAction->setIcon(QIcon(":/images/delete.png"));
    deleteAction->setShortcut(tr("Del"));
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItem()));

    cutAction = new QAction(tr("Cu&t"), this);
    cutAction->setIcon(QIcon(":/images/cut.png"));
    cutAction->setShortcut(tr("Ctrl+X"));
    connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));

    copyAction = new QAction(tr("&Copy"), this);
    copyAction->setIcon(QIcon(":/images/copy.png"));
    copyAction->setShortcut(tr("Ctrl+C"));
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));

    pasteAction = new QAction(tr("&Paste"), this);
    pasteAction->setIcon(QIcon(":/images/paste.png"));
    pasteAction->setShortcut(tr("Ctrl+V"));
    connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));

    bringToFrontAction = new QAction(tr("Bring to &Front"), this);
    bringToFrontAction->setIcon(QIcon(":/images/bringtofront.png"));
    connect(bringToFrontAction, SIGNAL(triggered()),
            this, SLOT(bringToFront()));

    sendToBackAction = new QAction(tr("&Send to Back"), this);
    sendToBackAction->setIcon(QIcon(":/images/sendtoback.png"));
    connect(sendToBackAction, SIGNAL(triggered()),
            this, SLOT(sendToBack()));

    propertiesAction = new QAction(tr("P&roperties..."), this);
    connect(propertiesAction, SIGNAL(triggered()),
            this, SLOT(properties()));

}