Exemple #1
0
int main()
{
	System::GetFactory()->Init();

	System::Window::Instance()->SetTitle(L"OpenGL object test");
	System::Mouse::Instance()->LockInWindow(false);
	OpenGL::Driver::Instance()->Start();

	System::EventManager::Instance()->SubscribeHandler(System::EVENT_IDLE, System::EventHandler(Idle));
	System::EventManager::Instance()->SubscribeHandler(System::EVENT_MOUSE_LBUTTON_DOWN, System::EventHandler(OnMouseLeftButtonDown));
	System::EventManager::Instance()->SubscribeHandler(System::EVENT_MOUSE_LBUTTON_UP, System::EventHandler(OnMouseLeftButtonUp));
	System::EventManager::Instance()->SubscribeHandler(System::EVENT_MOUSE_MOVE, System::EventHandler(OnMouseMove));
	System::EventManager::Instance()->SubscribeHandler(System::EVENT_KEY_DOWN, System::EventHandler(OnKeyDown));

	//scene = System::GetFactory()->CreateFromTextFile(System::Environment::Instance()->GetModelFolder() + L"engineer4.pmd");

	System::Proxy<GUI::Widget> widget(new GUI::Widget(0.1, 0.1, 0.4, 0.4));
	widget->FixPosition(false);
	GUI::Manager::Instance()->AddRootWidget(widget);
	widget->SetText(L"Hello world!");

	System::Proxy<GUI::Widget> widget2(new GUI::Widget(0.2, 0.2, 0.4, 0.4, L"Вітаю, спадарства!", widget));
	widget2->FixPosition(false);
	widget->Add(widget2);

	render.SetGUIHud(widget);
	render.SetScene(scene);
	updater.SetScene(scene);

	System::Window::Instance()->Loop(); 

	return 0;
}
void Ut_LauncherPageView::testUpdateData()
{
    QSharedPointer<LauncherButton> widget1(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget2(new LauncherButton(""));
    LauncherPageModel::LauncherButtonList widgets;
    widgets.append(widget1);
    widgets.append(widget2);
    controller->model()->setLauncherButtons(widgets);

    MLayout* mainLayout = dynamic_cast<MLayout *>(controller->layout());
    QVERIFY(mainLayout != NULL);
    QCOMPARE(mainLayout->count(), 2);
    mainLayout->removeItem(widget1.data());
    mainLayout->removeItem(widget2.data());
    QCOMPARE(mainLayout->count(), 0);

    QList<const char*> modifications;
    modifications.append(LauncherPageModel::LauncherButtons);
    emit updateDataRequested(modifications);
    QCOMPARE(mainLayout->count(), 2);

    mainLayout->removeItem(widget1.data());
    mainLayout->removeItem(widget2.data());
    QCOMPARE(mainLayout->count(), 0);

    QList<const char*> modifications2;
    modifications.append("does not match");
    emit updateDataRequested(modifications2);
    QCOMPARE(mainLayout->count(), 0);
}
void Ut_LauncherPageView::testRemovingButtonFromLayout()
{
    QSharedPointer<LauncherButton> widget1(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget2(new LauncherButton(""));
    LauncherPageModel::LauncherButtonList widgets;
    widgets.append(widget1);
    widgets.append(widget2);
    controller->model()->setLauncherButtons(widgets);

    widgets.removeOne(widget1);
    controller->model()->setLauncherButtons(widgets);

    MLayout* mainLayout = dynamic_cast<MLayout *>(controller->layout());
    QVERIFY(mainLayout != NULL);
    QCOMPARE(mainLayout->count(), 1);
    QCOMPARE(mainLayout->itemAt(0), widget2.data());
    // verify that button destructor has not been called when there is still ref in QSharedPointer
    QCOMPARE(gLauncherButtonStub->stubCallCount("~LauncherButton"), 0);
}
void Ut_LauncherPageView::testAddButtonsToPage()
{
    QSharedPointer<LauncherButton> widget1(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget2(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget3(new LauncherButton(""));
    QSharedPointer<LauncherButton> widget4(new LauncherButton(""));
    LauncherPageModel::LauncherButtonList widgets;
    widgets.append(widget1);
    controller->model()->setLauncherButtons(widgets);
    // add several widgets so that the order is tested better
    widgets.append(widget2);
    widgets.append(widget3);
    widgets.append(widget4);
    controller->model()->setLauncherButtons(widgets);

    MLayout* mainLayout = dynamic_cast<MLayout *>(controller->layout());
    QVERIFY(mainLayout != NULL);

    QCOMPARE(mainLayout->count(), widgets.count());
    for (int i = 0; i < mainLayout->count(); i++) {
        QCOMPARE(mainLayout->itemAt(i), widgets.at(i).data());
    }
}
Exemple #5
0
//-----------------------------------------------------------------------------
int ctkFlowLayoutTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QWidget widget1(0);
  widget1.setWindowTitle("1) Horizontal");
  ctkFlowLayout* flowLayout1 = new ctkFlowLayout(&widget1);
  flowLayout1->setAlignItems(false);
  
  flowLayout1->addWidget(new QPushButton("1 text text text text"));
  flowLayout1->addWidget(new QPushButton("2 text text text text text text text text"));
  flowLayout1->addWidget(new QPushButton("3 text"));
  flowLayout1->addWidget(new QPushButton("4 text text text text text text"));
  flowLayout1->addWidget(new QPushButton("5 text text"));
  flowLayout1->addWidget(new QPushButton("6 text text text text"));
  flowLayout1->addWidget(new QPushButton("7 text text text text text text text"));
  flowLayout1->addWidget(new QPushButton("8 text text text"));
  flowLayout1->addWidget(new QPushButton("9"));
  flowLayout1->addWidget(new QPushButton("10 text text text text text text text text text"));
 
  widget1.setLayout(flowLayout1);
  widget1.show();
  
  QWidget widget2(0);
  widget2.setWindowTitle("2) Horizontal");
  ctkFlowLayout* flowLayout2 = new ctkFlowLayout;
  
  flowLayout2->addWidget(new QPushButton("one"));
  flowLayout2->addWidget(new QPushButton("two"));
  flowLayout2->addWidget(new QPushButton("three"));
  flowLayout2->addWidget(new QPushButton("four"));
  flowLayout2->addWidget(new QPushButton("five"));
  flowLayout2->addWidget(new QPushButton("six"));
  flowLayout2->addWidget(new QPushButton("seven"));
  //flowLayout2->setHorizontalSpacing(20);
  
  widget2.setLayout(flowLayout2);
  widget2.show();
  
  QWidget widget3(0);
  widget3.setWindowTitle("3) Vertical");
  ctkFlowLayout* flowLayout3 = new ctkFlowLayout(Qt::Vertical);
  
  flowLayout3->addWidget(new QPushButton("one"));
  flowLayout3->addWidget(new QPushButton("two"));
  flowLayout3->addWidget(new QPushButton("three"));
  flowLayout3->addWidget(new QPushButton("four"));
  flowLayout3->addWidget(new QPushButton("five"));
  flowLayout3->addWidget(new QPushButton("six"));
  flowLayout3->addWidget(new QPushButton("seven"));
  flowLayout3->setHorizontalSpacing(20);
  widget3.setLayout(flowLayout3);
  widget3.show();
  
  QWidget widget4(0);
  widget4.setWindowTitle("4) Horizontal -> Vertical");
  ctkFlowLayout* flowLayout4 = new ctkFlowLayout();
  
  flowLayout4->addWidget(new QPushButton("one"));
  flowLayout4->addWidget(new QPushButton("two"));
  flowLayout4->addWidget(new QPushButton("three"));
  flowLayout4->addWidget(new QPushButton("four"));
  flowLayout4->addWidget(new QPushButton("five"));
  flowLayout4->addWidget(new QPushButton("six"));
  flowLayout4->addWidget(new QPushButton("seven"));
  
  widget4.setLayout(flowLayout4);
  widget4.show();
  flowLayout4->setOrientation(Qt::Vertical);
  flowLayout4->setVerticalSpacing(0);
  flowLayout4->setHorizontalSpacing(0);
  
  if (argc < 2 || QString(argv[1]) != "-I")
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }
  return app.exec();
}