/* * displays a dialog with text and a close button */ void WebDialogProvider::showInfoDialog(QWidget *parent, const QString &label) { int buttonIndex(-1); QStringList buttons(tr("Close")); WebDialogProvider dlg(label, parent, buttons, &buttonIndex); dlg.exec(); }
void dumpMouseRelatedParams(QTextStream &s, const Event &ev) { s << "btn: " << button(ev) << " "; s << "btns: " << buttons(ev) << " "; s << "pos: " << qSetFieldWidth(4) << ev.x() << qSetFieldWidth(0) << "," << qSetFieldWidth(4) << ev.y() << qSetFieldWidth(0) << " "; s << "gpos: " << qSetFieldWidth(4) << ev.globalX() << qSetFieldWidth(0) << "," << qSetFieldWidth(4) << ev.globalY() << qSetFieldWidth(0) << " "; }
void main() // Main function { badge_setup(); // Call badge setup oledprint("BUTTONS"); // Large display heading text_size(SMALL); // Switch to small text cursor(0, 4); // Small cursor row 4 oledprint("PAD: 6543210"); // Display bit index cursor(0, 5); // Next line oledprint("STATE:"); // Display state cursor(0, 7); // Next line oledprint("EXIT: Press OSH"); // User prompt to exit while(1) // States loop { states = buttons(); // Load buttons output to states leds(states); // Light up corresponding LEDs cursor(7, 5); // Position cursor oledprint("%07b", states); // Display states as binary number if(states == 0b1000000) break; // If OSH pressed, exit loop } pause(400); // Wait for 4/10 s text_size(LARGE); // Large text clear(); // Clear display oledprint("ALL DONE"); // Done message }
bool GlobalEventFilter::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { case QEvent::MouseButtonPress: { manager_.beginInteraction(); break; } case QEvent::MouseButtonRelease: { auto me = static_cast<QMouseEvent *>(event); if (me->buttons() == Qt::NoButton) { manager_.endInteraction(); } break; } case QEvent::TouchBegin: { manager_.beginInteraction(); break; } case QEvent::TouchEnd: { auto te = static_cast<QTouchEvent *>(event); if (util::all_of(te->touchPoints(), [](const QTouchEvent::TouchPoint &tp) { return tp.state() == Qt::TouchPointReleased; })) { manager_.endInteraction(); } break; } default: break; } return QObject::eventFilter(obj, event); }
int main () { CreateMyWindow (); // pictures_t pictures; // LoadPictures (pictures); // array_t <dyn, button_t> buttons (0); // SetButtons (buttons, pictures); // int buttonPressed = NothingPressed; // txBegin (); // while (!Exit ()) { DrawBackground (pictures); // DoOperationsWithButtons (buttons, &buttonPressed); // txSleep (1); } txEnd (); DeletePictures (pictures); _txExit = true; return 0; }
void Gui::warningDialog(const std::string & title, const std::string & text, bool useHtml) { ///don't show dialogs when about to close, otherwise we could enter in a deadlock situation { QMutexLocker l(&_imp->aboutToCloseMutex); if (_imp->_aboutToClose) { return; } } StandardButtons buttons(eStandardButtonYes | eStandardButtonNo); if ( QThread::currentThread() != QCoreApplication::instance()->thread() ) { QMutexLocker locker(&_imp->_uiUsingMainThreadMutex); while (_imp->_uiUsingMainThread) { _imp->_uiUsingMainThreadCond.wait(&_imp->_uiUsingMainThreadMutex); } ++_imp->_uiUsingMainThread; locker.unlock(); Q_EMIT doDialog(1, QString::fromUtf8( title.c_str() ), QString::fromUtf8( text.c_str() ), useHtml, buttons, (int)eStandardButtonYes); locker.relock(); while (_imp->_uiUsingMainThread) { _imp->_uiUsingMainThreadCond.wait(&_imp->_uiUsingMainThreadMutex); } } else { { QMutexLocker locker(&_imp->_uiUsingMainThreadMutex); ++_imp->_uiUsingMainThread; } Q_EMIT doDialog(1, QString::fromUtf8( title.c_str() ), QString::fromUtf8( text.c_str() ), useHtml, buttons, (int)eStandardButtonYes); } }
void MetavoxelEditor::createNewAttribute() { QDialog dialog(this); dialog.setWindowTitle("New Attribute"); QVBoxLayout layout; dialog.setLayout(&layout); QFormLayout form; layout.addLayout(&form); QLineEdit name; form.addRow("Name:", &name); SharedObjectEditor editor(&Attribute::staticMetaObject, false); editor.setObject(new QRgbAttribute()); layout.addWidget(&editor); QDialogButtonBox buttons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog.connect(&buttons, SIGNAL(accepted()), SLOT(accept())); dialog.connect(&buttons, SIGNAL(rejected()), SLOT(reject())); layout.addWidget(&buttons); if (!dialog.exec()) { return; } QString nameText = name.text().trimmed(); SharedObjectPointer attribute = editor.getObject(); attribute->setObjectName(nameText); AttributeRegistry::getInstance()->registerAttribute(attribute.staticCast<Attribute>()); updateAttributes(nameText); }
// Get player input, rotate the ship, fire shots, move active shots void Play(void) { int But = buttons(); if( But & (1<<2) ) { led(2,1); ShipAng = (ShipAng + RotSpeed) & 0x1fff; } else led(2,0); if( But & (1<<0) ) { led(0,1); ShipAng = (ShipAng - RotSpeed) & 0x1fff; } else led(0,0); if( ShotTimer > 0 ) { ShotTimer--; } if( But & ((1<<1) | (1<<4)) ) { Shoot(); } MoveShots(); }
/* * displays a dialog with text. closes after 2 second interval */ void WebDialogProvider::showTimedDialog(QWidget *parent, const QString &label) { int buttonIndex(-1); QStringList buttons(tr("Ok")); WebDialogProvider dlg(label, parent, buttons, &buttonIndex); QTimer::singleShot(2000, &dlg, SLOT(accept())); dlg.exec(); }
logical pc_ADK_Button :: SetupButton ( ) { PropertyHandle *pbc = GetParentProperty(); char *names = NULL; logical term = NO; DBObjectHandle dbo; names = strdup(GPH("sys_ident")->GetString()); SetupFromParent(); *GPH("auto_open") = YES; dbo = GetObjectHandle(); PropertyHandle buttons(dbo,"ADK_EventActionControl",PI_Read); PropertyHandle ph_default("_default"); if ( buttons(*GPH("sys_ident")) || buttons.Get(ph_default) ) GPH("button_control")->Add(buttons.ExtractKey()); return(term); }
void apply(void (*f)(Icon*)) { Icon *icon; esetcursor(&sight); buttons(Down); if(mouse.buttons == 4) for(icon = h.first; icon; icon = icon->next) if(ptinrect(mouse.xy, icon->sr)){ buttons(Up); f(icon); break; } buttons(Up); esetcursor(0); }
// ---------------------------------------------------------------------- void EventInputQueue::push_RelativePointerEventCallback(OSObject* target, int buttons_raw, int dx, int dy, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (!lk) return; Params_RelativePointerEventCallback::log(true, Buttons(buttons_raw), dx, dy); // ------------------------------------------------------------ Buttons buttons(buttons_raw); Buttons justPressed; Buttons justReleased; IOHIPointing* device = OSDynamicCast(IOHIPointing, sender); if (!device) return; ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get(device)); if (!item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ justPressed = buttons.justPressed(item->get_previousbuttons()); justReleased = buttons.justReleased(item->get_previousbuttons()); item->set_previousbuttons(buttons); // ------------------------------------------------------------ // divide an event into button and cursormove events. for (int i = 0; i < ButtonStatus::MAXNUM; ++i) { PointingButton btn(1 << i); if (justPressed.isOn(btn)) { Params_RelativePointerEventCallback params(buttons, 0, 0, btn, true); bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } if (justReleased.isOn(btn)) { Params_RelativePointerEventCallback params(buttons, 0, 0, btn, false); bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } } // If (dx == 0 && dy == 0), the event is either needless event or just pressing/releasing buttons event. // About just pressing/releasing buttons event, we handled these in the above processes. // So, we can drop (dx == 0 && dy == 0) events in here. if (dx != 0 || dy != 0) { Params_RelativePointerEventCallback params(buttons, dx, dy, PointingButton::NONE, false); bool retainFlagStatusTemporaryCount = true; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } setTimer(); }
void FEHWONKA::InitializeMenu() { ButtonBoard buttons( FEHIO::Bank3 ); char region = 'A'; LCD.Clear(); LCD.WriteLine( "Use LEFT / RIGHT to change region" ); LCD.WriteLine( "Use MIDDLE to select" ); LCD.Write( "Region: " ); LCD.WriteLine( region ); // wait for user to press middle button while( !buttons.MiddlePressed() ) { if( buttons.LeftPressed() ) { region--; if( region < 'A' ) { region = 'L'; } LCD.Clear(); LCD.WriteLine( "Use LEFT / RIGHT to change region" ); LCD.WriteLine( "Use MIDDLE to select" ); LCD.Write( "Region: " ); LCD.WriteLine( region ); while( buttons.LeftPressed() ); Sleep( 100 ); } if( buttons.RightPressed() ) { region++; if( region > 'L' ) { region = 'A'; } LCD.Clear(); LCD.WriteLine( "Use LEFT / RIGHT to change region" ); LCD.WriteLine( "Use MIDDLE to select" ); LCD.Write( "Region: " ); LCD.WriteLine( region ); while( buttons.RightPressed() ); Sleep( 100 ); } } Initialize( region ); while( buttons.MiddlePressed() ); Sleep( 1000 ); }
void AboutDialog::enableButtons(void) { const QList<QAbstractButton*> buttonList = buttons(); for(int i = 0; i < buttonList.count(); i++) { buttonList.at(i)->setEnabled(true); } setCursor(QCursor(Qt::ArrowCursor)); }
Module::Module(QWidget *parent, const QVariantList &args) : KCModule(parent, args) , ui(new Ui::Module) , m_manager(new DriverManager(this)) { KAboutData *aboutData = new KAboutData("kcm-driver-manager", i18n("Driver Manager"), global_s_versionStringFull, QStringLiteral(""), KAboutLicense::LicenseKey::GPL_V3, i18n("Copyright 2013 Rohan Garg")); aboutData->addAuthor(i18n("Rohan Garg"), i18n("Author"), QStringLiteral("*****@*****.**")); aboutData->addAuthor(i18n("Harald Sitter"), i18n("Qt 5 port"), QStringLiteral("*****@*****.**")); setAboutData(aboutData); // We have no help so remove the button from the buttons. setButtons(buttons() ^ KCModule::Help); ui->setupUi(this); ui->progressBar->setVisible(false); connect(ui->reloadButton, SIGNAL(clicked(bool)), SLOT(load())); m_overlay = new KPixmapSequenceOverlayPainter(this); m_overlay->setWidget(this); #warning variable name QString label = xi18nc("@title/rich", "<title>Your computer requires no proprietary drivers</title>"); m_label = new QLabel(label, this); m_label->hide(); ui->driverOptionsVLayout->addWidget(m_label); //Debconf handling QString uuid = QUuid::createUuid().toString(); uuid.remove('{').remove('}').remove('-'); m_pipe = QDir::tempPath() % QLatin1String("/qapt-sock-") % uuid; m_debconfGui = new DebconfKde::DebconfGui(m_pipe, this); m_debconfGui->connect(m_debconfGui, SIGNAL(activated()), this, SLOT(showDebconf())); m_debconfGui->connect(m_debconfGui, SIGNAL(deactivated()), this, SLOT(hideDebconf())); m_debconfGui->hide(); connect(m_manager, SIGNAL(refreshFailed()), this, SLOT(onRefreshFailed())); connect(m_manager, SIGNAL(devicesReady(DeviceList)), this, SLOT(onDevicesReady(DeviceList))); connect(m_manager, SIGNAL(changeProgressChanged(int)), this, SLOT(progressChanged(int))); connect(m_manager, SIGNAL(changeFinished()), this, SLOT(finished())); connect(m_manager, SIGNAL(changeFailed(QString)), this, SLOT(failed(QString))); }
void ManageFlarmDialog(Device &_device) { device = (FlarmDevice *)&_device; /* create the dialog */ WindowStyle dialog_style; dialog_style.Hide(); dialog_style.ControlParent(); SingleWindow &parent = UIGlobals::GetMainWindow(); const DialogLook &look = UIGlobals::GetDialogLook(); dialog = new WndForm(parent, look, parent.get_client_rect(), _T("FLARM"), dialog_style); ContainerWindow &client_area = dialog->GetClientAreaWindow(); /* create buttons */ ButtonPanel buttons(client_area, look); buttons.Add(_("Close"), OnCloseClicked); const PixelRect rc = buttons.UpdateLayout(); /* create the command buttons */ const UPixelScalar margin = 0; const UPixelScalar height = Layout::Scale(30); ButtonWindowStyle button_style; button_style.TabStop(); WndButton *button; PixelRect brc = rc; brc.left += margin; brc.top += margin; brc.right -= margin; brc.bottom = brc.top + height; button = new WndButton(client_area, look, _("Reboot"), brc, button_style, OnRebootClicked); dialog->AddDestruct(button); /* run it */ dialog->ShowModal(); delete dialog; }
ISR(INT2_vect, ISR_BLOCK) { cli(); if(GIFR & (1 << INTF2)) { if(state == ST_SLEEP) { reset(); } buttons(); GIFR &= ~(1 << INTF2); } sei(); }
void Simon_Says_lib::oldSequence(buttons* sequence, int nRound) { nRound++; for (int i = 0; i < nRound; i++){ buttons light = readNextLight(); if (light == NONE) { // Do nothing } else if (light != buttons(sequence[i])){ // Do nothing } } }
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); this->setWindowTitle("RagaEditor"); connect(ui->textEdit,SIGNAL(cursorPositionChanged()), this,SLOT(buttons())); connect(ui->textEdit,SIGNAL(textChanged()),this,SLOT(Save_check())); ui->textEdit->setFontFamily("Courier"); ui->textEdit->setFontPointSize(10); ui->textEdit->setTabStopWidth(30); save_check = false; save_done = false; }
DirectoryListDialog::DirectoryListDialog(String const &name) : MessageDialog(name) , d(new Impl(this)) { area().add(d->list); buttons() << new DialogButtonItem(Default | Accept) << new DialogButtonItem(Reject) << new DialogButtonItem(Action, style().images().image("create"), tr("Add Folder"), new SignalAction(&d->list->addButton(), SLOT(trigger()))); updateLayout(); }
InputDialog::InputDialog(String const &name) : MessageDialog(name), d(new Instance) { // Create the editor. area().add(d->editor = new LineEditWidget); d->editor->setSignalOnEnter(true); connect(d->editor, SIGNAL(enterPressed(QString)), this, SLOT(accept())); buttons() << new DialogButtonItem(Default | Accept) << new DialogButtonItem(Reject); updateLayout(); }
void ShowPortMonitor(SingleWindow &parent, const DialogLook &dialog_look, const TerminalLook &terminal_look, DeviceDescriptor &_device) { device = &_device; /* create the dialog */ WindowStyle dialog_style; dialog_style.Hide(); dialog_style.ControlParent(); TCHAR buffer[64]; StaticString<128> caption; caption.Format(_T("%s: %s"), _("Port monitor"), device->GetConfig().GetPortName(buffer, ARRAY_SIZE(buffer))); dialog = new WndForm(parent, dialog_look, parent.GetClientRect(), caption, dialog_style); ContainerWindow &client_area = dialog->GetClientAreaWindow(); ButtonPanel buttons(client_area, dialog_look); buttons.Add(_("Close"), OnCloseClicked); buttons.Add(_("Clear"), OnClearClicked); buttons.Add(_("Reconnect"), OnReconnectClicked); buttons.Add(_("Pause"), OnPauseClicked); const PixelRect rc = buttons.UpdateLayout(); /* create the terminal */ terminal = new TerminalWindow(terminal_look); terminal->set(dialog->GetClientAreaWindow(), rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); bridge = new PortTerminalBridge(*terminal); device->SetMonitor(bridge); paused = false; /* run it */ dialog->ShowModal(); device->SetMonitor(NULL); delete bridge; delete terminal; delete dialog; }
bool Vrpn::sample() { if ( mTrackerNumber > 0 ) { std::vector<PositionData> positions(mTrackerNumber); vpr::Guard<vpr::Mutex> g(mTrackerMutex); for ( int i = 0; i < mTrackerNumber; ++i ) { gmtl::Matrix44f pos; gmtl::setRot(pos, mQuats[i]); gmtl::setTrans(pos, mPositions[i]); positions[i].setValue(pos); positions[i].setTime(); } addPositionSample(positions); } if ( mButtonNumber > 0 ) { std::vector<DigitalData> buttons(mButtonNumber); vpr::Guard<vpr::Mutex> g(mButtonMutex); for ( int i = 0; i < mButtonNumber; ++i ) { buttons[i] = mButtons[i]; buttons[i].setTime(); } addDigitalSample(buttons); } if ( mAnalogNumber > 0 ) { std::vector<AnalogData> analogs(mAnalogNumber); vpr::Guard<vpr::Mutex> g(mAnalogMutex); for ( int i = 0; i < mAnalogNumber; ++i ) { analogs[i] = mAnalogs[i]; analogs[i].setTime(); } addAnalogSample(analogs); } return true; }
void ToEvent::fire_downup(Flags flags, bool add_to_keyrepeat) { switch (type_) { case Type::NONE: break; case Type::KEY: { KeyboardType keyboardType = CommonData::getcurrent_keyboardType(); EventOutputQueue::FireKey::fire_downup(flags, key_, keyboardType); if (add_to_keyrepeat) { KeyboardRepeat::primitive_add_downup(flags, key_, keyboardType); } break; } case Type::CONSUMER_KEY: { EventOutputQueue::FireConsumer::fire_downup(flags, consumer_); if (add_to_keyrepeat) { KeyboardRepeat::primitive_add(EventType::DOWN, flags, consumer_); KeyboardRepeat::primitive_add(EventType::UP, flags, consumer_); } break; } case Type::POINTING_BUTTON: { FlagStatus::ScopedTemporaryFlagsChanger stfc(FlagStatus::globalFlagStatus(), flags); for (int i = 0; i < 2; ++i) { if (i == 0) { ButtonStatus::increase(button_); } else { ButtonStatus::decrease(button_); } Buttons buttons(ButtonStatus::makeButtons()); EventOutputQueue::FireRelativePointer::fire(buttons); if (add_to_keyrepeat) { KeyboardRepeat::primitive_add(buttons); } } break; } } }
int MenuSelection::select(sf::RenderWindow* window, std::vector<std::string> &buttonNames){ int qttyButtons = buttonNames.size(); sf::Vector2f buttonSize(window->getSize().x/(qttyButtons+2), window->getSize().y/6); sf::Font font; sf::Texture text; if(!font.loadFromFile("res/fonts/font.otf")){ std::cerr << "Can't find the font file" << std::endl; } std::vector<Button> buttons(qttyButtons); for(int i = 0; i < qttyButtons; ++i){ buttons[i].setFont(font); buttons[i].setTexture("res/pics/buttons/button.png"); buttons[i].setPressedTexture("res/pics/buttons/buttonPres.png"); buttons[i].setText(buttonNames[i]); buttons[i].setSize(buttonSize.x, buttonSize.y); buttons[i].setPosition(buttonSize.x*(i+1), buttonSize.y*3-buttonSize.y/2); } open = true; while(open){ sf::Event event; while (window->pollEvent(event)) { for(int i = 0; i < qttyButtons; ++i){ buttons[i].handleEvent(event); } switch (event.type) { case sf::Event::Closed: window->close(); exit(0); break; case sf::Event::KeyPressed: if (event.key.code == sf::Keyboard::Escape) { window->close(); exit(0); } break; default: break; } for(int i = 0; i < qttyButtons; ++i){ if(!buttons[i].isClicked() && buttons[i].hasBeenClicked()){ return i; } } } window->clear(); for(int i = 0; i < qttyButtons; ++i){ buttons[i].draw(*window); } window->display(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { isAdmin = true; connecting = new connectDtabase(); dialHall = new dialogHallType(); dialBldg = new dialogBldg(); dialShow = new dialogShow(); dialTimes = new dialogTimes(); dialMap = new dialogMap(); dialZone = new dialogZone(); dialTicket = new dialogTicket(); GUI(); buttons(); validateConnect(); }
virtual i4_bool mouse_down() { if (buttons() & moving) { if (!i4_current_app->get_window_manager()->shift_pressed() && m1_info.preselect_poly>=0) { li_call("select_none"); } m1_render_window->select_poly(m1_info.preselect_poly); m1_st_edit->select_point(m1_info.preselect_point); return i4_T; } return i4_F; }
Simon_Says_lib::buttons Simon_Says_lib::readNextLight() { unsigned long timer = millis(); while (millis() < (timer + MAX_LIGHT_WAIT)){ // Don't block the whole robot if we miss the light. We've lost :( for (int i = RED; i < NUM_BUTTONS - 1; i++){ if (actuators[i]->isActive()){ // Read sensor, check if it's above threshhold. timer = millis(); while (actuators[i]->isActive() && (millis() < (timer + MAX_LIGHT_OFF))){ // Wait for the light to turn off. } return buttons(i); } } } return NONE; }
bool TabWidget::eventFilter(QObject* o, QEvent* e) { // Handle middle mouse click on closable tabs bool isTabBar = o == tabBar(); bool isMouseButtonPress = e->type() == QEvent::MouseButtonPress; bool tabsAreClosable = tabBar()->tabsClosable(); if (isTabBar && isMouseButtonPress && tabsAreClosable) { auto me = static_cast<QMouseEvent*>(e); if (me->buttons() == Qt::MiddleButton) { auto tabIdx = tabBar()->tabAt(me->pos()); if (tabIdx >= 0) { emit tabCloseRequested(tabIdx); return true; } } } return QTabWidget::eventFilter(o, e); }
void current(Flayer *nw) { Text *t; if(which) flborder(which, 0); if(nw){ flushtyping(1); flupfront(nw); flborder(nw, 1); buttons(Up); t = (Text *)nw->user1; t->front = nw-&t->l[0]; if(t != &cmd) work = nw; } which = nw; }