Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
int ctkMenuButtonTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QWidget topLevelWidget(0);
  QMenu* menu = new QMenu("menu");
  menu->addAction("extra choice 1");
  menu->addAction("extra choice 2");
  menu->addAction("extra choice 3");

  QPushButton button1("QPushButton with no menu");
  QPushButton button2("QPushButton with menu");
  button2.setMenu(menu);  
  ctkMenuButton button3("ctkMenuButton with no menu");
  ctkMenuButton button4("ctkMenuButton with menu");  
  button4.setMenu(menu);
  
  QVBoxLayout* layout = new QVBoxLayout;
  layout->addWidget(&button1);
  layout->addWidget(&button2);
  layout->addWidget(&button3);
  layout->addWidget(&button4);
  
  topLevelWidget.setLayout(layout);
  topLevelWidget.show();
  topLevelWidget.resize(200, 100);

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Ejemplo n.º 2
0
void tst_QRadioButton::task190739_focus()
{
    QWidget widget;
    QPushButton button1(&widget);
    button1.setText("button1");
    QLineEdit edit(&widget);
    edit.setFocus();

    QRadioButton radio1(&widget);
    radio1.setText("radio1");
    radio1.setFocusPolicy(Qt::TabFocus);
    radio1.setShortcut(QKeySequence("Ctrl+O"));

    QVBoxLayout layout(&widget);
    layout.addWidget(&button1);
    layout.addWidget(&edit);
    layout.addWidget(&radio1);

    widget.show();
    widget.activateWindow();
    QApplication::setActiveWindow(&widget);
    QTest::qWait(100);

    QVERIFY(edit.hasFocus());
    QVERIFY(!radio1.isChecked());

    QTest::keyClick(&edit, Qt::Key_O, Qt::ControlModifier, 20);
    QTest::qWait(200);
    QVERIFY(radio1.isChecked());
    QVERIFY(edit.hasFocus());
    QVERIFY(!radio1.hasFocus());
}
Ejemplo n.º 3
0
__interrupt void PORT2_ISR(void)
{
	if (P2IFG == BIT0)
		button0();

	if (P2IFG == BIT1)
		button1();

	if (P2IFG == BIT2)
		button2();

	if (P2IFG == BIT3)
		button3();

	if (P2IFG == BIT4)
		button4();

	if (P2IFG == BIT5)
		button5();

	if (P2IFG == BIT6)
		button6();

	if (P2IFG == BIT7)
		button7();
}
Ejemplo n.º 4
0
void TierWindow::openCategoryEdit(TierCategory *c)
{
    helper = new ConfigForm("Delete Category", "Apply", this);
    currentEdit = c->name();
    currentType = CategoryT;
    currentTierCat = c;

    helper->addConfigHelper(new ConfigLine("Name", currentEdit));

    {
        QStringList parents;
        parents << "";
        QList<TierCategory *> cats = dataTree->gatherCategories();
        foreach(TierCategory *c, cats) {
            parents << c->name();
        }
        parent = dataTree->getParentCategory(c)->name();
        helper->addConfigHelper(new ConfigCombo<QString>("Parent Category", parent, parents, parents));
    }

    helper->addConfigHelper(new ConfigSpin("Category display order", c->displayOrder, -100, 100));

    internalWidget = helper->generateConfigWidget();
    updateInternalWidget();

    connect(helper, SIGNAL(button1()), SLOT(deleteCurrent()));
    connect(helper, SIGNAL(button2()), SLOT(updateCategory()));
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  boost::scoped_ptr<MyDialog> dialog(new MyDialog);
  boost::scoped_ptr<QVBoxLayout> layout(new QVBoxLayout);
  boost::scoped_ptr<QPushButton> button1(new QPushButton);
  boost::scoped_ptr<QPushButton> button2(new QPushButton);

  button1->setText("Count");
  button1->connect(
    button1.get(),SIGNAL(clicked()),
    dialog.get(),SLOT(buttonClicked()));
  button2->setText("Quit");
  button2->connect(
    button2.get(),SIGNAL(clicked()),
    dialog.get(),SLOT(close()));
  layout->addWidget(button1.get());
  layout->addWidget(button2.get());

  dialog->setGeometry(0,0,300,100);
  dialog->setWindowTitle("CppQtExample12");
  dialog->setLayout(layout.get());

  dialog->show();
  return a.exec();
}
Ejemplo n.º 6
0
LRESULT CALLBACK EditableWindowProcedure(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {

	static HWND prevHwnd;
	static HWND hSettingEdit1;
	static string resultString1;
	static TCHAR* targetWinName;

	switch(Message) {

		case WM_CREATE: {
			// Create an edit box
			WinButton button1("OK",10,10,80,24,hwnd,(HMENU)IDC_SETTING_BUTTON_1);
			HWND hbutton = button1.getButton();
			WinEditbox editbox1("",110,10,80,24,hwnd,(HMENU)IDC_SETTING_EDITBOX_1);
			hSettingEdit1 = editbox1.getEditbox();
			break;
		}

		case WM_COMMAND: {

			switch(LOWORD(wParam)) {

				case IDC_SETTING_BUTTON_1:
				{
					char buffer[256];
					SendMessage(hSettingEdit1,
						WM_GETTEXT,
						sizeof(buffer)/sizeof(buffer[0]),
						reinterpret_cast<LPARAM>(buffer));
					string tmp(buffer);
					resultString1 = tmp;
					SendMessage(prevHwnd, WM_NOTIFY, 0, (LPARAM)tmp.c_str());
				}
				break;

			}

			break;
		}

		case WM_NOTIFY: {
            string tmp((char*)lParam);
            targetWinName = _T((char*)lParam);
            prevHwnd = FindWindow(targetWinName,0);
            break;
		}

		/* Upon destruction, tell the main thread to stop */
		case WM_CLOSE: {
			ShowWindow(hwnd, SW_HIDE);
			break;
		}

		/* All other messages (a lot of them) are processed using default procedures */
		default:
			return DefWindowProc(hwnd, Message, wParam, lParam);
	}
	return 0;
}
Ejemplo n.º 7
0
SoundConfigWindow::SoundConfigWindow()
{
    QSettings s;

    cryVolume = s.value("BattleAudio/CryVolume").toInt();
    musicVolume = s.value("BattleAudio/MusicVolume").toInt();
    musicPath = s.value("BattleAudio/MusicDirectory").toString();
    playMusic = s.value("BattleAudio/PlayMusic", false).toBool();
    playCries = s.value("BattleAudio/PlaySounds").toBool();

    ConfigForm *form = new ConfigForm(tr("&Apply sound settings"), "", this);

    QString message = tr("If you become stuck in your battles and have problems when pokemon faint, <b>disable the pokemon cries.</b>");
#ifdef _WIN32
    message = QString("%1<br><br>%2").arg(message, tr("Download the <a href=\"http://www.codecguide.com/download_kl.htm\">K-Lite"
                                                                 " Codec pack</a> if you want Pokemon online to be able to read all your music!"));
#endif
    form->addConfigHelper(new AbstractConfigHelper("<div>"+message+"</div>"));

    form->addConfigHelper(new ConfigFile(tr("Music path: "), musicPath));
    form->addConfigHelper(new ConfigCheck(tr("Play battle music"), playMusic));
    form->addConfigHelper(new ConfigSlider(tr("Music volume: "), musicVolume, 0, 100));
    form->addConfigHelper(new ConfigCheck(tr("Play pokemon cries"), playCries));
    form->addConfigHelper(new ConfigSlider(tr("Cries volume: "), cryVolume, 0, 100));

    QWidget *w = form->generateConfigWidget();
    w->setAttribute(Qt::WA_DeleteOnClose);
    w->layout()->setMargin(15);
    w->setWindowTitle(tr("Sound config window"));
    w->setObjectName("soundConfig");
    w->resize(500, 400);
    w->show();

    connect(w, SIGNAL(destroyed()), SLOT(deleteLater()));

    connect(form, SIGNAL(button1()), form, SLOT(applyVals()));
    connect(form, SIGNAL(button1()), this, SLOT(saveChanges()));
    connect(form, SIGNAL(button1()), w, SLOT(deleteLater()));
}
void ui_test()
{
	sbox::initSDL();
	GraphicEngine * graEngine = new GraphicEngine;
	UIEngine * uiEngine = new UIEngine;

	graEngine->init();

	//setup button1
	UIButton button1("resource/cp_button1");
	button1.setX(100);
	button1.setY(50);
	button1.setDepth(100);
	graEngine->addClipper(&button1);
	uiEngine->addUICom(&button1);

	SDL_Event event;
	vector<SDL_Event> events;
	bool quit = false;
	while(!quit)
	{
		events.clear();
		while(SDL_PollEvent(&event))
		{
			if(event.type == SDL_QUIT)
				quit = true;
			events.push_back(event);
		}
		uiEngine->loop(events);
		graEngine->loop();
		sbox::delay();
	}

	Clipper::clean();
	delete graEngine;
	delete uiEngine;
	sbox::cleanSDL();
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  boost::scoped_ptr<QDialog> dialog(new QDialog);
  boost::scoped_ptr<QVBoxLayout> layout(new QVBoxLayout);
  boost::scoped_ptr<QPushButton> button1(new QPushButton);
  boost::scoped_ptr<QPushButton> button2(new QPushButton);

  //Cannot let button1 do anything fancy,
  //without creating a derived class from QDialog
  button1->setText("Nothing");
  button2->setText("Quit");
  button2->connect(button2.get(),SIGNAL(clicked()),dialog.get(),SLOT(close()));
  layout->addWidget(button1.get());
  layout->addWidget(button2.get());

  dialog->setGeometry(0,0,200,100);
  dialog->setWindowTitle("CppQtExample11");
  dialog->setLayout(layout.get());

  dialog->show();
  return a.exec();
}
Ejemplo n.º 10
0
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    switch (message)                  /* handle the messages */
    {
        case WM_CREATE: {
            WinButton button1("GO",10,10,80,24,hwnd,(HMENU)IDC_MAIN_BUTTON);
			HWND hbutton = button1.getButton();
            break;
        }
        case WM_COMMAND: {
            switch(LOWORD(wParam)) {
				case IDC_MAIN_BUTTON: {
					ShowWindow (settingHwnd, SW_SHOWDEFAULT);
					char cName[256];
                    GetClassName(hwnd, cName, 256);
					SendMessage (settingHwnd, WM_NOTIFY, 0, (LPARAM)cName);
				}
				break;
			}
            break;
        }
        case WM_NOTIFY: {
            string tmp((char*)lParam);
            showMessage(tmp);
            break;
        }
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
//-----------------------------------------------------------------------------
int ctkCheckablePushButtonTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QWidget topLevel;
  ctkCheckablePushButton button1(QObject::tr("My very long text on button"));
  ctkCheckablePushButton button2(QObject::tr("Button2"));
  ctkCheckablePushButton button3(QObject::tr("Button3"));
  ctkCheckablePushButton button4(QObject::tr("Button4"));
  ctkCheckablePushButton button5(QObject::tr("Button5"));
  ctkCheckablePushButton button6(QObject::tr("Button6"));
  ctkCheckablePushButton button7(QObject::tr("Checkable PushButton"));
  ctkCheckablePushButton button8(QObject::tr("Connected, Not User Checkable"));
  ctkCheckablePushButton button9(QObject::tr("Connected, Not User Checkable"));
  ctkCheckablePushButton button10(QObject::tr("Not Connected, User Checkable"));
  ctkCheckablePushButton button11(QObject::tr("Not Connected, User Checkable"));
  ctkCheckablePushButton button12(QObject::tr("Checkbox Not User Checkable\nButton Checkable"));
  ctkCheckablePushButton button13(QObject::tr("Checkbox and Button User Checkable"));

  QVBoxLayout *layout= new QVBoxLayout;
  layout->addWidget(&button1);
  layout->addWidget(&button2);
  layout->addWidget(&button3);
  layout->addWidget(&button4);
  layout->addWidget(&button5);
  layout->addWidget(&button6);
  layout->addWidget(&button7);
  layout->addWidget(&button8);
  layout->addWidget(&button9);
  layout->addWidget(&button10);
  layout->addWidget(&button11);
  layout->addWidget(&button12);
  layout->addWidget(&button13);
  topLevel.setLayout(layout);

  topLevel.show();
  button1.setButtonTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

  if (button1.buttonTextAlignment() != (Qt::AlignRight | Qt::AlignVCenter))
    {
    std::cerr << "ctkCheckablePushButton::setButtonTextAlignment failed."
              << std::endl;
    return EXIT_FAILURE;
    }

  button2.setIndicatorAlignment(Qt::AlignRight);

  if (button2.indicatorAlignment() != Qt::AlignRight)
    {
    std::cerr << "ctkCheckablePushButton::setIndicatorAlignment failed."
              << std::endl;
    return EXIT_FAILURE;
    }

  button3.setButtonTextAlignment(Qt::AlignCenter);
  button3.setIndicatorAlignment(Qt::AlignCenter);
  button3.setCheckable(true);
  
  button4.setCheckable(true);
  button4.toggle();
  
  button5.setButtonTextAlignment(Qt::AlignCenter);
  button5.setIndicatorAlignment(Qt::AlignRight);
  
  button6.setIndicatorAlignment(Qt::AlignTop);
  button7.setButtonTextAlignment(Qt::AlignCenter);
  button7.setIndicatorAlignment(Qt::AlignLeft);
  
  // Connected to button, not user checkable:
  button8.setCheckBoxUserCheckable(false);
  button8.setCheckState(Qt::Checked);
  button9.setCheckBoxUserCheckable(false);
  button9.setCheckState(Qt::Unchecked);

  // Not connected to button, user checkable:
  button10.setCheckBoxControlsButton(false);
  button10.setCheckState(Qt::Checked);
  button11.setCheckBoxControlsButton(false);
  button11.setCheckState(Qt::PartiallyChecked);

  button12.setCheckBoxControlsButton(false);
  button12.setCheckBoxUserCheckable(false);
  button12.setCheckable(true);
  button13.setCheckBoxControlsButton(false);
  button13.setCheckBoxUserCheckable(true);
  button13.setCheckable(true);

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Ejemplo n.º 12
0
	int main(const std::vector<CL_String> &args)
	{
		CL_ConsoleWindow console("Console");

		try 
		{
			CL_ResourceManager resources("../../../Resources/GUIThemeLuna/resources.xml");

			CL_GUIManager gui; 
 
			CL_GUIWindowManagerSystem wm;
			gui.set_window_manager(wm);

			CL_GUIThemeDefault theme;
			theme.set_resources(resources);
			gui.set_theme(theme);
			gui.set_css_document("theme.css");
 
			CL_DisplayWindowDescription win_desc;
			win_desc.set_allow_resize(true);
			win_desc.set_title("The Amazing ProgressBar");
			win_desc.set_position(CL_Rect(200,200,600,600), false);
			CL_Window root(&gui, win_desc);
			root.func_close().set(this, &App::on_close, &root);

			CL_PushButton button1(&root);
			button1.set_geometry(CL_Rect(20, 20, 200, 60));
			button1.func_clicked().set(this, &App::on_button_clicked, &button1);
			button1.set_text("Click me!");

			progress1 = new CL_ProgressBar(&root);
			progress1->set_geometry(CL_Rect(20, 70, 200, 88));
			progress1->set_min(0);
			progress1->set_max(100);
			progress1->set_step_size(1);
			progress1->set_position(0);

			progress2 = new CL_ProgressBar(&root);
			progress2->set_geometry(CL_Rect(20, 90, 200, 108));
			progress2->set_min(0);
			progress2->set_max(100);
			progress2->set_step_size(1);
			progress2->set_position(100);

			progress3 = new CL_ProgressBar(&root);
			progress3->set_geometry(CL_Rect(20, 110, 200, 128));
			progress3->set_min(0);
			progress3->set_max(100);
			progress3->set_step_size(10);
			progress3->set_position(0);

 			gui.exec(); 
		}
		catch (CL_Exception e)
		{
 			CL_Console::write_line(e.message);
  			console.display_close_message();
		}
 
		return 0;
 	}
Ejemplo n.º 13
0
void QtCalculator::pb1toggled(bool myboolean){
  if(myboolean)
    button1();
  if(pb1->isOn() && (!key_pressed))
    pb1->setOn(FALSE);
}
Ejemplo n.º 14
0
    bool PlayerInputStruct::pollEvents(PlayerInputStruct &oldInputs, GameEvent &e)
    {
        //Check if the given event is already a game input event.
        if(e.type() != GameEvent::GameInput)
        {
            e = event::GameInput();
        }

        if(oldInputs.action() != action()) {
            e.gameInput.setControl(GameControl::ACTION);
            e.gameInput.setState(action());
            oldInputs.setAction(action());
            return true;
        }
        if(oldInputs.up() != up()) {
            e.gameInput.setControl(GameControl::UP);
            e.gameInput.setValue(up());
            oldInputs.setUp(up());
            return true;
        }
        if(oldInputs.down() != down()) {
            e.gameInput.setControl(GameControl::DOWN);
            e.gameInput.setValue(down());
            oldInputs.setDown(down());
            return true;
        }
        if(oldInputs.left() != left()) {
            e.gameInput.setControl(GameControl::LEFT);
            e.gameInput.setValue(left());
            oldInputs.setLeft(left());
            return true;
        }
        if(oldInputs.right() != right()) {
            e.gameInput.setControl(GameControl::RIGHT);
            e.gameInput.setValue(right());
            oldInputs.setRight(right());
            return true;
        }
        if(oldInputs.button1() != button1()) {
            e.gameInput.setControl(GameControl::BUTTON1);
            e.gameInput.setState(button1());
            oldInputs.setButton1(button1());
            return true;
        }
        if(oldInputs.button2() != button2()) {
            e.gameInput.setControl(GameControl::BUTTON2);
            e.gameInput.setState(button2());
            oldInputs.setButton2(button2());
            return true;
        }
        if(oldInputs.button3() != button3()) {
            e.gameInput.setControl(GameControl::BUTTON3);
            e.gameInput.setState(button3());
            oldInputs.setButton3(button3());
            return true;
        }
        if(oldInputs.button4() != button4()) {
            e.gameInput.setControl(GameControl::BUTTON4);
            e.gameInput.setState(button4());
            oldInputs.setButton4(button4());
            return true;
        }
        if(oldInputs.button5() != button5()) {
            e.gameInput.setControl(GameControl::BUTTON5);
            e.gameInput.setState(button5());
            oldInputs.setButton5(button5());
            return true;
        }
        if(oldInputs.button6() != button6()) {
            e.gameInput.setControl(GameControl::BUTTON6);
            e.gameInput.setState(button6());
            oldInputs.setButton6(button6());
            return true;
        }
        return false;
    }
Ejemplo n.º 15
0
Dialog::answer_t Dialog::BuyBoat(bool enable)
{
    Display & display = Display::Get();

    const ICN::icn_t system = Settings::Get().EvilInterface() ? ICN::SYSTEME : ICN::SYSTEM;

    Cursor & cursor = Cursor::Get();
    cursor.Hide();

    Resource::BoxSprite rbs(PaymentConditions::BuyBoat(), BOXAREA_WIDTH);

    const Sprite & sprite = AGG::GetICN(ICN::BOATWIND, 0);
    Text text(_("Build a new ship:"), Font::BIG);
    const u8 spacer = Settings::Get().QVGA() ? 5 : 10;

    Dialog::Box box(text.h() + spacer + sprite.h() + spacer + text.h() + spacer + rbs.GetArea().h - 20, true);

    const Rect & box_rt = box.GetArea();
    Point dst_pt;
    dst_pt.x = box_rt.x + (box_rt.w - text.w()) / 2;
    dst_pt.y = box_rt.y;
    text.Blit(dst_pt);

    dst_pt.x = box_rt.x + (box_rt.w - sprite.w()) / 2;
    dst_pt.y = box_rt.y + text.h() + spacer;
    display.Blit(sprite, dst_pt);

    text.Set(_("Resource cost:"), Font::BIG);
    dst_pt.x = box_rt.x + (box_rt.w - text.w()) / 2;
    dst_pt.y = dst_pt.y + sprite.h() + spacer;
    text.Blit(dst_pt);

    rbs.SetPos(box_rt.x, dst_pt.y + spacer);
    rbs.Redraw();

    // buttons
    dst_pt.x = box_rt.x;
    dst_pt.y = box_rt.y + box_rt.h - AGG::GetICN(system, 1).h();
    Button button1(dst_pt, system, 1, 2);

    dst_pt.x = box_rt.x + box_rt.w - AGG::GetICN(system, 3).w();
    dst_pt.y = box_rt.y + box_rt.h - AGG::GetICN(system, 3).h();
    Button button2(dst_pt, system, 3, 4);

    if(!enable)
    {
	button1.Press();
	button1.SetDisable(true);
    }

    button1.Draw();
    button2.Draw();
	
    cursor.Show();
    display.Flip();

    LocalEvent & le = LocalEvent::Get();

    // message loop
    while(le.HandleEvents())
    {
        if(button1.isEnable()) le.MousePressLeft(button1) ? button1.PressDraw() : button1.ReleaseDraw();
        le.MousePressLeft(button2) ? button2.PressDraw() : button2.ReleaseDraw();

        if(le.KeyPress(KEY_RETURN) ||
    	    (button1.isEnable() && le.MouseClickLeft(button1))) return Dialog::OK;

        if(le.KeyPress(KEY_ESCAPE) ||
    	    le.MouseClickLeft(button2)) return Dialog::CANCEL;
    }

    return Dialog::ZERO;
}
Ejemplo n.º 16
0
void TierWindow::openTierEdit(Tier *t)
{
    helper = new ConfigForm("Delete Tier", "Apply", this);
    currentEdit = t->name();
    currentType = TierT;
    currentTier = t;

    helper->addConfigHelper(new ConfigLine("Name", currentEdit));

    {
        QStringList parents;
        parents << "";
        QList<TierCategory *> cats = dataTree->gatherCategories();
        foreach(TierCategory *c, cats) {
            parents << c->name();
        }
        parent = dataTree->getParentCategory(t)->name();
        helper->addConfigHelper(new ConfigCombo<QString>("Parent Category", parent, parents, parents));
    }
    {
        QStringList parents;
        parents << "";
        QList<Tier *> tiers = dataTree->gatherTiers();
        foreach(Tier *t, tiers) {
            parents << t->name();
        }
        helper->addConfigHelper(new ConfigCombo<QString>("Parent Tier", t->banParentS, parents, parents));
    }

    QStringList genS = QStringList() << "Any";
    QList<Pokemon::gen> gens;
    gens.push_back(0);
    for (int i = GenInfo::GenMin(); i <= GenInfo::GenMax(); i++) {
        for (int j = 0; j < GenInfo::NumberOfSubgens(i); j++) {
            gens << Pokemon::gen(i, j);
            genS << QString("%1 (%2)").arg(GenInfo::Gen(gens.back().num), GenInfo::Version(gens.back()));
        }
    }

    helper->addConfigHelper(new ConfigCombo<Pokemon::gen>("Generation", t->m_gen, genS,  gens ));
    helper->addConfigHelper(new ConfigCheck("Ban pokemon/moves/items (uncheck to restrict the choice to them instead)", t->banPokes));
    helper->addConfigHelper(new ConfigSpin("Max number of pokemon", t->numberOfPokemons, 1, 6));
    helper->addConfigHelper(new ConfigText("Pokemon", pokemons));
    helper->addConfigHelper(new ConfigLine("Moves", moves));
    helper->addConfigHelper(new ConfigLine("Items", items));
    helper->addConfigHelper(new ConfigSpin("Max number of restricted pokemon", t->maxRestrictedPokes, 0, 6));
    helper->addConfigHelper(new ConfigLine("Restricted Pokemon", restrPokemons));
    helper->addConfigHelper(new ConfigSpin("Pokemon's max level", t->maxLevel, 1, 100));

    pokemons = t->getBannedPokes();
    moves = t->getBannedMoves();
    items = t->getBannedItems();
    restrPokemons = t->getRestrictedPokes();

    helper->addConfigHelper(new ConfigCombo<int>("Battle Mode in Find Battle", t->mode, QStringList() << "Singles" << "Doubles" << "Triples"
                                                 << "Rotation Battles",
                                                 QList<int>() << ChallengeInfo::Singles << ChallengeInfo::Doubles << ChallengeInfo::Triples
                                                 << ChallengeInfo::Rotation));

    int clauses = t->clauses;
    for (int i = 0; i < ChallengeInfo::numberOfClauses; i++) {
        this->clauses[i] = (clauses >> i) % 2;

        helper->addConfigHelper(new ConfigCheck(ChallengeInfo::clause(i), this->clauses[i]));
    }

    helper->addConfigHelper(new ConfigSpin("Tier display order", t->displayOrder, -100, 100));

    internalWidget = helper->generateConfigWidget();
    internalWidget->layout()->setMargin(0);
    internalWidget->layout()->setSpacing(0);
    updateInternalWidget();

    connect(helper, SIGNAL(button1()), SLOT(deleteCurrent()));
    connect(helper, SIGNAL(button2()), SLOT(updateTier()));
}
Ejemplo n.º 17
0
bool BuildingInfo::DialogBuyBuilding(bool buttons) const
{
    Display & display = Display::Get();

    const int system = (Settings::Get().ExtGameEvilInterface() ? ICN::SYSTEME : ICN::SYSTEM);

    Cursor & cursor = Cursor::Get();
    cursor.Hide();

    std::string box1str = description;

    if(ALLOW_BUILD != bcond)
    {
	const std::string & ext = GetConditionDescription();

	if(! ext.empty())
	{
	    box1str.append("\n \n");
	    box1str.append(ext);
	}
    }

    TextBox box1(box1str, Font::BIG, BOXAREA_WIDTH);

    // prepare requires build string
    std::string str;
    const u32 requires = castle.GetBuildingRequires(building);
    const char* sep = ", ";

    for(u32 itr = 0x00000001; itr; itr <<= 1)
        if((requires & itr) && ! castle.isBuild(itr))
    {
	str.append(Castle::GetStringBuilding(itr, castle.GetRace()));
	str.append(sep);
    }

    // replace end sep
    if(str.size())
	str.replace(str.size() - strlen(sep), strlen(sep), ".");

    bool requires_true = str.size();
    Text requires_text(_("Requires:"), Font::BIG);
    TextBox box2(str, Font::BIG, BOXAREA_WIDTH);

    Resource::BoxSprite rbs(PaymentConditions::BuyBuilding(castle.GetRace(), building), BOXAREA_WIDTH);

    const Sprite & window_icons = AGG::GetICN(ICN::BLDGXTRA, 0);
    const int space = Settings::Get().QVGA() ? 5 : 10;
    Dialog::FrameBox box(space + window_icons.h() + space + box1.h() + space + (requires_true ? requires_text.h() + box2.h() + space : 0) + rbs.GetArea().h, buttons);
    const Rect & box_rt = box.GetArea();
    LocalEvent & le = LocalEvent::Get();

    Point dst_pt;

    dst_pt.x = box_rt.x;
    dst_pt.y = box_rt.y + box_rt.h - AGG::GetICN(system, 1).h();
    Button button1(dst_pt.x, dst_pt.y, system, 1, 2);

    dst_pt.x = box_rt.x + box_rt.w - AGG::GetICN(system, 3).w();
    dst_pt.y = box_rt.y + box_rt.h - AGG::GetICN(system, 3).h();
    Button button2(dst_pt.x, dst_pt.y, system, 3, 4);

    dst_pt.x = box_rt.x + (box_rt.w - window_icons.w()) / 2;
    dst_pt.y = box_rt.y + space;
    window_icons.Blit(dst_pt);

    const Sprite & building_icons = AGG::GetICN(ICN::Get4Building(castle.GetRace()),
					    GetIndexBuildingSprite(building));
    dst_pt.x = box_rt.x + (box_rt.w - building_icons.w()) / 2;
    dst_pt.y += 1;
    building_icons.Blit(dst_pt);

    Text text(GetName(), Font::SMALL);
    dst_pt.x = box_rt.x + (box_rt.w - text.w()) / 2;
    dst_pt.y += 57;
    text.Blit(dst_pt);

    dst_pt.x = box_rt.x;
    dst_pt.y = box_rt.y + space + window_icons.h() + space;
    box1.Blit(dst_pt);

    dst_pt.y += box1.h() + space;
    if(requires_true)
    {
	dst_pt.x = box_rt.x + (box_rt.w - requires_text.w()) / 2;
	requires_text.Blit(dst_pt);

	dst_pt.x = box_rt.x;
	dst_pt.y += requires_text.h();
	box2.Blit(dst_pt);

	dst_pt.y += box2.h() + space;
    }

    rbs.SetPos(dst_pt.x, dst_pt.y);
    rbs.Redraw();

    if(buttons)
    {
	if(ALLOW_BUILD != castle.CheckBuyBuilding(building))
	    button1.SetDisable(true);

	button1.Draw();
	button2.Draw();
    }

    cursor.Show();
    display.Flip();

    // message loop
    while(le.HandleEvents())
    {
        if(!buttons && !le.MousePressRight()) break;

        le.MousePressLeft(button1) ? button1.PressDraw() : button1.ReleaseDraw();
        le.MousePressLeft(button2) ? button2.PressDraw() : button2.ReleaseDraw();

        if(button1.isEnable() &&
	    (Game::HotKeyPressEvent(Game::EVENT_DEFAULT_READY) ||
    	    le.MouseClickLeft(button1))) return true;

        if(Game::HotKeyPressEvent(Game::EVENT_DEFAULT_EXIT) ||
    	    le.MouseClickLeft(button2)) break;
    }

    return false;
}
PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name)
	: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE
		| B_CLOSE_ON_ESCAPE),
	webDirFilePanel(NULL),
	logFilePanel(NULL)
{
	frame = Bounds();

	prefView = new PoorManView(frame, STR_WIN_NAME_PREF);
	//prefView->SetViewColor(216,216,216,255);
	prefView->SetViewColor(BACKGROUND_COLOR);
	AddChild(prefView);


	// Button View
	BRect buttonRect;
	buttonRect = Bounds();
	buttonRect.top = buttonRect.bottom - 30;

	buttonView = new PoorManView(buttonRect, "Button View");
	buttonView->SetViewColor(BACKGROUND_COLOR);
	prefView->AddChild(buttonView);

	// Buttons
	float buttonTop = 0.0f;
	float buttonHeight = 26.0f;

	float widthCancel = prefView->StringWidth(B_TRANSLATE("Cancel")) + 24.0f;
	float widthDone = prefView->StringWidth(B_TRANSLATE("Done")) + 24.0f;

	float gap = 5.0f;

	BRect button1(prefView->Bounds().Width() - 2 * gap - widthCancel
		- widthDone, buttonTop, prefView->Bounds().Width() - 2 * gap - widthDone, 
		buttonTop + buttonHeight);
	cancelButton = new BButton(button1, "Cancel Button", B_TRANSLATE("Cancel"), 
		new BMessage(MSG_PREF_BTN_CANCEL));

	BRect button2(prefView->Bounds().Width() - gap - widthDone, buttonTop, 
		prefView->Bounds().Width() - gap, buttonTop + buttonHeight);
	doneButton = new BButton(button2, "Done Button", B_TRANSLATE("Done"), 
		new BMessage(MSG_PREF_BTN_DONE));

	buttonView->AddChild(cancelButton);
	buttonView->AddChild(doneButton);

	// Create tabs
	BRect r;
	r = Bounds();
	//r.InsetBy(5, 5);
	r.top	 += 8.0;
	r.bottom -= 38.0;

	prefTabView = new BTabView(r, "Pref Tab View");
	prefTabView->SetViewColor(BACKGROUND_COLOR);

	r = prefTabView->Bounds();
	r.InsetBy(5, 5);
	r.bottom -= prefTabView->TabHeight();

	// Site Tab
	siteTab = new BTab();
	siteView = new PoorManSiteView(r, "Site View");
	prefTabView->AddTab(siteView, siteTab);
	siteTab->SetLabel(STR_TAB_SITE);

	// Logging Tab
	loggingTab = new BTab();
	loggingView = new PoorManLoggingView(r, "Logging View");
	prefTabView->AddTab(loggingView, loggingTab);
	loggingTab->SetLabel(STR_TAB_LOGGING);

	// Advanced Tab
	advancedTab = new BTab();
	advancedView = new PoorManAdvancedView(r, "Advanced View");
	prefTabView->AddTab(advancedView, advancedTab);
	advancedTab->SetLabel(STR_TAB_ADVANCED);

	prefView->AddChild(prefTabView);

	// FilePanels
	BWindow * change_title;

	BMessenger messenger(this);
	BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR);
	webDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
		B_DIRECTORY_NODE, false, &message, NULL, true);

	webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html"));
	webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
	change_title = webDirFilePanel->Window();
	change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR);

	message.what = MSG_FILE_PANEL_CREATE_LOG_FILE;
	logFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,
		B_FILE_NODE, false, &message);
	logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create"));
	change_title = logFilePanel->Window();
	change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE);
}