__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(); }
//----------------------------------------------------------------------------- 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(); }
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())); }
static int checkmouse(void) /* return button touched if any */ { int c, b; char *p; extern int confirm(int); b = waitdown(); last_but = 0; last_hit = -1; c = 0; if (button3(b)) { last_hit = emenuhit(3, &mouse, &mbut3); last_but = 3; } else if (button2(b)) { last_hit = emenuhit(2, &mouse, &mbut2); last_but = 2; } else { /* button1() */ pan(); last_but = 1; } waitup(); if (last_but == 3 && last_hit >= 0) { p = m3[last_hit]; c = p[strlen(p) - 1]; } if (c == '?' && !confirm(last_but)) last_hit = -1; return last_but; }
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(); }
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(); }
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; }
//----------------------------------------------------------------------------- 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(); }
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())); }
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); }
//----------------------------------------------------------------------------- int ctkDirectoryButtonTest1(int argc, char * argv [] ) { QApplication app(argc, argv); QWidget topLevel; ctkDirectoryButton button; QIcon defaultIcon = button.style()->standardIcon(QStyle::SP_DirIcon); QIcon icon = button.style()->standardIcon(QStyle::SP_MessageBoxQuestion); QIcon icon2 = button.style()->standardIcon(QStyle::SP_DesktopIcon); ctkDirectoryButton button2("."); ctkDirectoryButton button3(icon, ".."); QVBoxLayout* layout = new QVBoxLayout; layout->addWidget(&button); layout->addWidget(&button2); layout->addWidget(&button3); topLevel.setLayout(layout); button.setCaption("Select a directory"); if (button.caption() != "Select a directory") { std::cerr << "ctkDirectoryButton::setCaption() failed." << std::endl; return EXIT_FAILURE; } if (button.icon().pixmap(20).toImage() != defaultIcon.pixmap(20).toImage()) { std::cerr << "ctkDirectoryButton::icon() failed." << std::endl; return EXIT_FAILURE; } button3.setIcon(icon2); if (button3.icon().pixmap(20).toImage() != icon2.pixmap(20).toImage()) { std::cerr << "ctkDirectoryButton::setIcon() failed." << std::endl; return EXIT_FAILURE; } #ifdef USE_QFILEDIALOG_OPTIONS button.setOptions(QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly); if (button.options() != (QFileDialog::ShowDirsOnly | QFileDialog::ReadOnly)) #else button.setOptions(ctkDirectoryButton::ShowDirsOnly | ctkDirectoryButton::ReadOnly); if (button.options() != (ctkDirectoryButton::ShowDirsOnly | ctkDirectoryButton::ReadOnly)) #endif { std::cerr<< "ctkDirectoryButton::setOptions failed" << std::endl; return EXIT_FAILURE; } QSignalSpy spyDirectoryChanged(&button, SIGNAL(directoryChanged(const QString&))); QSignalSpy spyDirectorySelected(&button, SIGNAL(directorySelected(const QString&))); button.setDirectory(QDir::home().absolutePath()); if ( QDir(button.directory()) != QDir::home() || spyDirectoryChanged.count() != 1 || spyDirectorySelected.count() != 1) { std::cerr<< "ctkDirectoryButton::setDirectory failed" << button.directory().toStdString() << std::endl; return EXIT_FAILURE; } spyDirectoryChanged.clear(); spyDirectorySelected.clear(); // set it again... just to check that it doesn't fire a new signal button.setDirectory(QDir::home().absolutePath()); if ( QDir(button.directory()) != QDir::home() || spyDirectoryChanged.count() != 0 || spyDirectorySelected.count() != 1) { std::cerr<< "ctkDirectoryButton::setDirectory failed" << button.directory().toStdString() << std::endl; return EXIT_FAILURE; } topLevel.show(); if (argc < 2 || QString(argv[1]) != "-I" ) { QTimer::singleShot(200, &app, SLOT(quit())); } QTimer::singleShot(100, &button, SLOT(browse())); return app.exec(); }
void QtCalculator::pb2toggled(bool myboolean){ if(myboolean) button2(); if(pb2->isOn() && (!key_pressed)) pb2->setOn(FALSE); }
int main(const std::vector<CL_String> &args) { try { CL_GUIManager gui; CL_ResourceManager resources("../../../Resources/GUIThemeLuna/resources.xml"); 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"); gui.set_css_document("../../../Resources/GUIThemeLuna/theme.css"); CL_DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("Button WM System Test Application"); win_desc.set_position(CL_RectPS(200, 200, 320, 240), false); CL_Window window(&gui, win_desc); window.func_close().set(this, &App::on_close, &window); CL_PushButton button(&window); button.set_geometry(CL_RectPS(10, 10, 160, 40)); button.set_text("Button 1"); CL_PushButton button2(&window); button2.set_geometry(CL_RectPS(10, 50, 160, 40)); button2.set_text("Button 2"); button2.set_enabled(false); CL_PushButton button3(&window); button3.set_geometry(CL_RectPS(10, 90, 160, 40)); button3.set_text("Button 3"); CL_CheckBox check1(&window); check1.set_geometry(CL_RectPS(10, 130, 160, 21)); check1.set_text("Check Box 1"); CL_CheckBox check2(&window); check2.set_geometry(CL_RectPS(10, 160, 160, 21)); check2.set_text("Check Box 2"); check2.set_enabled(false); CL_CheckBox check3(&window); check3.set_geometry(CL_RectPS(10, 190, 160, 21)); check3.set_text("Check Box 3"); gui.exec(); } catch (CL_Exception e) { CL_ConsoleWindow console("Console"); CL_Console::write_line(e.message); console.display_close_message(); } return 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; }
int waitchar(void) { Event e; int c; char c2; int newmouse; int wasblocked; int kbdchar = -1; char echobuf[3*BSIZE]; static int lastc = -1; for(;;) { if(resize_flag) resize(); wasblocked = blocked; if(backp) return(0); if(ecanmouse() && (button2() || button3())) readmenu(); if(snarffp) { if((c = Bgetc(snarffp)) < 0) { if(lastc != '\n') write(outfd,"\n",1); Bterm(snarffp); snarffp = 0; if(lastc != '\n') { lastc = -1; return('\n'); } lastc = -1; continue; } lastc = c; c2 = c; write(outfd, &c2, 1); return(c); } if(!blocked && host_avail()) return(rcvchar()); if(kbdchar > 0) { if(blocked) resize(); if(cs->raw) { switch(kbdchar){ case Kup: sendfk("up key"); break; case Kdown: sendfk("down key"); break; case Kleft: sendfk("left key"); break; case Kright: sendfk("right key"); break; case Kpgup: sendfk("page up"); break; case Kpgdown: sendfk("page down"); break; case KF|1: sendfk("F1"); break; case KF|2: sendfk("F2"); break; case KF|3: sendfk("F3"); break; case KF|4: sendfk("F4"); break; case KF|5: sendfk("F5"); break; case KF|6: sendfk("F6"); break; case KF|7: sendfk("F7"); break; case KF|8: sendfk("F8"); break; case KF|9: sendfk("F9"); break; case KF|10: sendfk("F10"); break; case KF|11: sendfk("F11"); break; case KF|12: sendfk("F12"); break; case '\n': echobuf[0] = '\r'; sendnchars(1, echobuf); break; case '\r': echobuf[0] = '\n'; sendnchars(1, echobuf); break; default: echobuf[0] = kbdchar; sendnchars(1, echobuf); break; } } else if(canon(echobuf,kbdchar) == SCROLL) { if(!blocked) bigscroll(); } else strcat(echo_input,echobuf); blocked = 0; kbdchar = -1; continue; } curson(wasblocked); /* turn on cursor while we're waiting */ do { newmouse = 0; switch(eread(blocked ? Emouse|Ekeyboard : Emouse|Ekeyboard|Ehost, &e)) { case Emouse: mouse = e.mouse; if(button2() || button3()) readmenu(); else if(resize_flag == 0) { /* eresized() is triggered by special mouse event */ newmouse = 1; } break; case Ekeyboard: kbdchar = e.kbdc; break; case Ehost: set_host(&e); break; default: perror("protocol violation"); exits("protocol violation"); } } while(newmouse == 1); cursoff(); /* turn cursor back off */ } }
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; }
void button(XButtonEvent *e) { int n, shift; Client *c; Window dw; ScreenInfo *s; curtime = e->time; s = getscreen(e->root); if(s == 0) return; c = getclient(e->window, 0); if(c) { if(debug) fprintf(stderr, "but: e x=%d y=%d c x=%d y=%d dx=%d dy=%d BORDR %d\n", e->x, e->y, c->x, c->y, c->dx, c->dy, BORDER); if(borderorient(c, e->x, e->y) != BorderUnknown) { switch (e->button) { case Button1: case Button2: reshape(c, e->button, pull, e); return; case Button3: move(c, Button3); return; default: return; } } e->x += c->x - BORDER; e->y += c->y - BORDER; } else if(e->window != e->root) { if(debug) fprintf(stderr, "but no client: e x=%d y=%d\n", e->x, e->y); XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw); } switch (e->button) { case Button1: if(c) { XMapRaised(dpy, c->parent); top(c); active(c); } return; case Button2: if(c) { XMapRaised(dpy, c->parent); active(c); XAllowEvents (dpy, ReplayPointer, curtime); } else if((e->state&(ShiftMask|ControlMask))==(ShiftMask|ControlMask)) { menuhit(e, &egg); } else if(numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1) button2(n); return; case Button3: break; case Button4: /* scroll up changes to previous virtual screen */ if(!c && e->type == ButtonPress) if(numvirtuals > 1 && virt > 0) switch_to(virt - 1); return; case Button5: /* scroll down changes to next virtual screen */ if(!c && e->type == ButtonPress) if(numvirtuals > 1 && virt < numvirtuals - 1) switch_to(virt + 1); return; default: return; } if(current && current->screen == s) cmapnofocus(s); switch (n = menuhit(e, &b3menu)) { case New: spawn(s, termFn); break; case Acme: spawn(s, editorFn); break; case Launcher: spawn(s, launcherFn); break; case Reshape: reshape(selectwin(1, 0, s), Button3, sweep, 0); break; case Move: move(selectwin(0, 0, s), Button3); break; case Delete: shift = 0; c = selectwin(1, &shift, s); delete(c, shift); break; case Hide: hide(selectwin(1, 0, s)); break; default: /* unhide window */ unhide(n - B3FIXED, 1); break; case -1: /* nothing */ break; } if(current && current->screen == s) cmapfocus(current); }