int command2(int keycode, t_box *box) { if (keycode == KEY_ESC) exit(0); else if (keycode == KEY_RIGHT) box->pos_x += 0.1; else if (keycode == KEY_LEFT) box->pos_x -= 0.1; else if (keycode == KEY_UP) box->pos_y -= 0.1; else if (keycode == KEY_DOWN) box->pos_y += 0.1; else if (keycode == KEY_H) box->b_info = box->b_info == 1 ? 0 : 1; else if (keycode == KEY_PLUS) { box->ite_max++; box->color_tab = cut_color(box->color_1, box->color_2, box->ite_max); } else if (keycode == KEY_MINUS && box->ite_max > 1) { free(box->color_tab); box->ite_max--; box->color_tab = cut_color(box->color_1, box->color_2, box->ite_max); } command3(keycode, box); return (1); }
int main() { while (1) { scanf("%s",inst); if (inst[0] == '8') break; pos = 0; int over = 0; A = B = 0; while (1) { switch (inst[pos]) { case '0':command0();break; case '1':command1();break; case '2':command2();break; case '3':command3();break; case '4':command4();break; case '5':command5();break; case '6':command6();break; case '7':command7();break; case '8':over = 1;break; default:over = 1;break; } if (over || pos > 255) break; } printf("%s\n",inst); } return 0; }
void TestPageCommands::testInsertPageCommand() // move of frames { KWDocument document; KWPageInsertCommand command1(&document, 0); QCOMPARE(document.pageCount(), 0); QCOMPARE(document.frameSetCount(), 0); command1.redo(); QCOMPARE(document.pageCount(), 1); QCOMPARE(document.frameSetCount(), 0); KWFrameSet *fs = new KWFrameSet(); MockShape *shape = new MockShape(); KWFrame *frame = new KWFrame(shape, fs); Q_UNUSED(frame); document.addFrameSet(fs); QPointF startPos = shape->position(); KWPageInsertCommand command2(&document, 0); QCOMPARE(document.pageCount(), 1); QCOMPARE(document.frameSetCount(), 1); command2.redo(); QCOMPARE(document.pageCount(), 2); QCOMPARE(document.frameSetCount(), 1); QCOMPARE(fs->frameCount(), 1); QCOMPARE(command2.page().pageNumber(), 1); QCOMPARE(command1.page().pageNumber(), 2); QPointF newPos = shape->position(); QCOMPARE(newPos, QPointF(0, command2.page().height()) + startPos); // it moved ;) KWPageInsertCommand command3(&document, 2); command3.redo(); QCOMPARE(document.pageCount(), 3); QCOMPARE(document.frameSetCount(), 1); QCOMPARE(fs->frameCount(), 1); QCOMPARE(newPos, shape->position()); // it has not moved from page 2 command3.undo(); QCOMPARE(document.pageCount(), 2); QCOMPARE(document.frameSetCount(), 1); QCOMPARE(fs->frameCount(), 1); QCOMPARE(newPos, shape->position()); // it has not moved from page 2 QCOMPARE(command2.page().pageNumber(), 1); QCOMPARE(command1.page().pageNumber(), 2); command2.undo(); QCOMPARE(document.pageCount(), 1); QCOMPARE(document.frameSetCount(), 1); QCOMPARE(fs->frameCount(), 1); QCOMPARE(command1.page().pageNumber(), 1); QCOMPARE(startPos, shape->position()); // it has been moved back command2.redo(); QCOMPARE(document.pageCount(), 2); QCOMPARE(document.frameSetCount(), 1); QCOMPARE(fs->frameCount(), 1); QCOMPARE(command2.page().pageNumber(), 1); QCOMPARE(command1.page().pageNumber(), 2); QCOMPARE(QPointF(0, command2.page().height()) + startPos, newPos); // it moved again ;) }
int _tmain(int argc, _TCHAR* argv[]) { ActiveObjectEngine active_objevt_engine; std::unique_ptr<ICommand> command1(new SleepDelayCommand( 1000, &active_objevt_engine, 'A' ) ); std::unique_ptr<ICommand> command2(new SleepDelayCommand( 5000, &active_objevt_engine, 'B' ) ); std::unique_ptr<ICommand> command3( new SleepDelayCommand( 500, &active_objevt_engine, 'C' ) ); std::unique_ptr<ICommand> command4(new SleepDelayCommand( 10, &active_objevt_engine, 'E' ) ); std::unique_ptr<ICommand> command5(new SleepDelayCommand( 4500, &active_objevt_engine, 'D' ) ); active_objevt_engine.AddCommand( std::move( command1 ) ); active_objevt_engine.AddCommand( std::move( command2 ) ); active_objevt_engine.AddCommand( std::move( command3 ) ); active_objevt_engine.AddCommand( std::move( command4 ) ); active_objevt_engine.AddCommand( std::move( command5 ) ); active_objevt_engine.Run(); return 0; }