// // eventFilter - filter events looking for a rightclick // // on a right mouseclick we edit the button // bool MyButton::eventFilter(QObject *o, QEvent *e) { switch (e->type()) { case QEvent::MouseButtonPress: { QMouseEvent *m = (QMouseEvent *) e; if (m->button() == 2) // right click { // pass on to the dialog owning us return m_pOwner->eventFilter(o, e); } } case QEvent::Enter: emit setButton(this, TRUE); break; case QEvent::Leave: emit setButton(this, FALSE); break; default: break; } return QCheckBox::eventFilter(o, e); } // end eventFilter
FirstRunWizard::FirstRunWizard(QWidget* parent, Qt::WindowFlags flags) : QWizard(parent, flags) { setWindowTitle(tr("Shaman first run")); addPage(new IntroPage); addPage(new SecurityPage); addPage(new ConfigurationPage); #ifdef KDE4_INTEGRATION addPage(new KDEPage); #endif addPage(new FinishPage); #ifdef KDE4_INTEGRATION QAbstractButton *bt = button(CancelButton); bt->setIcon(KIcon("dialog-close")); setButton(CancelButton, bt); bt = button(BackButton); bt->setIcon(KIcon("go-previous")); setButton(BackButton, bt); bt = button(NextButton); bt->setIcon(KIcon("go-next")); bt->setLayoutDirection(Qt::RightToLeft); setButton(NextButton, bt); #endif setButtonText(CancelButton, tr("Skip wizard")); setButtonText(NextButton, tr("Next")); setButtonText(BackButton, tr("Back")); }
void ImageWidget::mouseMoveEvent(QMouseEvent *event) { mousePos = event->pos(); if((mousePos.x() > (rect().width()-16-25)) & (mousePos.x() < (rect().width()-25)) & (mousePos.y() > (rect().height()-22)) & (mousePos.y() < (rect().height()-6))) { if (!i_image.isNull()){ setCursor(Qt::PointingHandCursor); setButton(Open); } }else if((mousePos.x() > (rect().width()-16-5)) & (mousePos.x() < (rect().width()-5)) & (mousePos.y() > (rect().height()-22)) & (mousePos.y() < (rect().height()-6))) { setCursor(Qt::PointingHandCursor); if (!i_image.isNull()){ setButton(Clear); }else{ setButton(Open); } }else{ setCursor(Qt::ArrowCursor); setButton(None); } update(); }
void Theme::modCurrentTheme(std::string filename){ debug_out("void modCurrentTheme(std::string "+filename+")"); if(!load(filename,false)){return;} setButton(filename,"ButtonMin"); setButton(filename,"ButtonMax"); setButton(filename,"ButtonMaxActive"); setButton(filename,"ButtonClose"); std::string WindowStyle="WindowStyle"; std::string Active="Active"; std::string Background="Background"; std::string Foreground="Foreground"; std::string ActiveBackground="ActiveBackground"; std::string ActiveForeground="ActiveForeground"; std::string TrayStyle="TrayStyle"; std::string TrayButtonStyle="TrayButtonStyle"; std::string TaskListStyle="TaskListStyle"; std::string MenuStyle="MenuStyle"; if(themeNewStyle(filename)<0){ setThemeElementTextwithSub(filename,WindowStyle,ActiveBackground); setThemeElementTextwithSub(filename,WindowStyle,ActiveForeground); } else{ setThemeElementTextwithSub(filename,WindowStyle,Active,Background); setThemeElementTextwithSub(filename,WindowStyle,Active,Foreground); } setThemeElementTextwithSub(filename,WindowStyle,Background); setThemeElementTextwithSub(filename,WindowStyle,Foreground); setThemeElementTextwithSub(filename,TrayStyle,Background); if(themeNewStyle(filename)<0){setThemeElementTextwithSub(filename,TrayStyle,"Text");} else{setThemeElementTextwithSub(filename,TrayStyle,Foreground);} /// /////Don't do this if we are using the newest version.. because it doesn't exist if(themeNewStyle(filename)<1){ ///panel Button modCurrentTheme setThemeElementTextwithSub(filename,TrayButtonStyle,Background); setThemeElementTextwithSub(filename,TrayButtonStyle,Foreground); ///tasklist modCurrentTheme setThemeElementTextwithSub(filename,TaskListStyle,Background); setThemeElementTextwithSub(filename,TaskListStyle,Foreground); setThemeElementTextwithSub(filename,TaskListStyle,Active,Background); setThemeElementTextwithSub(filename,TaskListStyle,Active,Foreground); } ///menus modCurrentTheme setThemeElementTextwithSub(filename,MenuStyle,Background); setThemeElementTextwithSub(filename,MenuStyle,Foreground); setThemeElementTextwithSub(filename,MenuStyle,Active,Background); setThemeElementTextwithSub(filename,MenuStyle,Active,Foreground); }
SelectPokemonMenuOption::SelectPokemonMenuOption(Pokemon *pokemon, int numOfOptions){ setPokemon(pokemon); setLocation(numOfOptions); setImage(pokemon->getImageLocation()); setButton(pokemon->getName()); }
Robot::Robot(QWidget* w) : QWidget(w) , panel(this) , send("Send") , clear("Clear") , screenshot("Screenshot") { setWindowTitle(QStringLiteral("图灵机器人")); network = Network::instance(); Answer *answer = new Answer(QStringLiteral("你好,我是机器人图灵,有什么可以帮您"),&*panel); panel->addDialog(answer); setButton(); setLine(); setPanel(); QGridLayout* lay = new QGridLayout(this); lay->addWidget(&panel, 0, 0, 1, 3); lay->addWidget(&line, 1, 0, 1, 3); lay->addWidget(&screenshot, 2, 0); lay->addWidget(&clear, 2, 1); lay->addWidget(&send, 2, 2); setStyleSheet("background-color:rgb(61, 61, 61);"); my::moveToScrCenter(this); connect(&send, SIGNAL(clicked()), this, SLOT(newQuestion())); connect(&clear, SIGNAL(clicked()), this, SLOT(clearAllContents())); connect(&screenshot, SIGNAL(clicked()), this, SLOT(saveScreenshot())); connect(network, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleDownload(QNetworkReply*))); }
ChatImageItem::ChatImageItem(FMessage message, QWidget *parent) : QWidget(parent), ui(new Ui::ChatImageItem) { ui->setupUi(this); waiting = retryButton = false; this->message = message; setImage(); ui->progressBar->setRange(0,100); ui->progressBar->setValue(0); ui->progressBar->hide(); ui->nameLabel->hide(); ui->timeLabel->hide(); connect(ui->viewImageButton,SIGNAL(clicked()),this,SLOT(downloadOrViewImage())); setButton(); setNickname(message); setTimestamp(message); if(message.media_caption.length()>0) { ui->imageCaption->setText(message.media_caption); } else { ui->imageCaption->hide(); } }
void MouseButton::wheelEvent(QWheelEvent *event) { if (!mouseGrabber()) { KPushButton::wheelEvent(event); } else { const Button oldButton = m_button; releaseMouse(); if (event->delta() > 0) { setButton(WheelUp); } else { setButton(WheelDown); } setChecked(false); emit buttonChanged(oldButton, m_button); } }
static void setOptions(HWND hwndDlg) { UCHAR title[256] ; sprintf(title, "Session Options for <%s>", SessServerName) ; WinSetWindowText(hwndDlg, title) ; setFormat(hwndDlg) ; setEncode(hwndDlg) ; setButton(hwndDlg, IDD_OPT_SHARED, SessOptShared) ; setButton(hwndDlg, IDD_OPT_VONLY, SessOptViewonly) ; setButton(hwndDlg, IDD_OPT_DEICON, SessOptDeiconify) ; if (! initialSetup) { WinEnableWindow(WinWindowFromID(hwndDlg, IDD_OPT_FORMAT), FALSE) ; WinEnableWindow(WinWindowFromID(hwndDlg, IDD_OPT_SHARED), FALSE) ; } }
void CSVWidget::SceneToolMode::setButton (const std::string& id) { for (std::map<ModeButton *, std::string>::iterator iter = mButtons.begin(); iter!=mButtons.end(); ++iter) if (iter->second==id) { setButton (iter); break; } }
void slop::Mouse::update() { XEvent event; while ( XCheckTypedEvent( x11->display, ButtonPress, &event ) ) { setButton( event.xbutton.button, 1 ); } bool findNewWindow = false; while ( XCheckTypedEvent( x11->display, MotionNotify, &event ) ) { findNewWindow = true; } if ( findNewWindow ) { hoverWindow = findWindow(x11->root); } while ( XCheckTypedEvent( x11->display, ButtonRelease, &event ) ) { setButton( event.xbutton.button, 0 ); } while ( XCheckTypedEvent( x11->display, EnterNotify, &event ) ) { hoverWindow = event.xcrossing.window; } }
MouseButton::MouseButton(QWidget *parent) : KPushButton(parent) { setCheckable(true); connect(this, SIGNAL(clicked()), this, SLOT(getButton())); setIcon(KIcon("input-mouse")); setButton(NoButton); }
stompbox_cs::stompbox_cs(QWidget *parent) : stompBox(parent) { /* COMP */ setImage(":/images/cs.png"); setLSB("00", "00"); setKnob1("00", "00", "42"); setKnob2("00", "00", "47"); setComboBox("00", "00", "41"); setButton("00", "00", "40"); editDetails()->patchPos(150, 16, "00", "40"); setEditPages(); };
void CSVWidget::SceneToolMode::selected() { std::map<ModeButton *, std::string>::iterator iter = mButtons.find (dynamic_cast<ModeButton *> (sender())); if (iter!=mButtons.end()) { if (!iter->first->hasKeepOpen()) mPanel->hide(); setButton (iter); } }
void MouseButton::setXButton(const int &button) { switch (button) { case 1: setButton(LeftButton); break; case 2: setButton(MiddleButton); break; case 3: setButton(RightButton); break; case 4: setButton(WheelUp); break; case 5: setButton(WheelDown); break; case 8: setButton(SpecialButton1); break; case 9: setButton(SpecialButton2); break; default: setButton(NoButton); break; } }
void Input::HandleInputEvent(SDL_Event event) { switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: auto iter = keyboardBindings.find(event.key.keysym.scancode); if (iter != keyboardBindings.end()) { bool pressed = event.key.state == SDL_PRESSED; setButton(&data, iter->second, pressed ? 0 : 1); // Enable interrupt if button pressed buttonPressed = pressed; } break; } }
ButtonContact::ButtonContact( NodeWindow * pParent, Noun * pNoun ) : m_IsObjective( false ), m_bGroupLeader( false ), m_bGroupPending( false ) { m_Flags |= NOCLIP; m_Style = HAS_BACK | EFFECT_HIGHLIGHT | SMOOTH_LL | EFFECT_FADEIN; m_Alpha = 0.75f; setWindow( RectInt( PointInt(0,0), SizeInt( BUTTON_WIDTH, BUTTON_HEIGHT ) ) ); // attach this button to the parent pParent->attachNode( this ); // set this button setButton( pNoun ); }
void welcomeWizard::programInit( ) { checkDisableWelcome = new QCheckBox(); checkDisableWelcome->setText(tr("Don't show on next startup")); setButton(QWizard::CustomButton1, checkDisableWelcome); QList<QWizard::WizardButton> layout; layout << QWizard::CustomButton1 << QWizard::Stretch << QWizard::BackButton << QWizard::NextButton << QWizard::FinishButton; setButtonLayout(layout); button(QWizard::NextButton)->setText(tr("&Next")); button(QWizard::BackButton)->setText(tr("&Back")); button(QWizard::FinishButton)->setText(tr("&Finish")); connect(checkDisableWelcome, SIGNAL(clicked()), this, SLOT(slotCheckDisabled()) ); }
ThumbnailController::ThumbnailController( QWidget * parent, ThumbnailList * list ) : KToolBar( parent, "ThumbsControlBar" ) { // change toolbar appearance setMargin( 3 ); setFlat( true ); setIconSize( 16 ); setMovingEnabled( false ); // insert a togglebutton [show only bookmarked pages] //insertSeparator(); insertButton( "bookmark", FILTERB_ID, SIGNAL( toggled( bool ) ), list, SLOT( slotFilterBookmarks( bool ) ), true, i18n( "Show bookmarked pages only" ) ); setToggle( FILTERB_ID ); setButton( FILTERB_ID, KpdfSettings::filterBookmarks() ); //insertLineSeparator(); }
ImageWidget::ImageWidget(QWidget *parent): i_manager(0) { setButton(None); setMouseTracking(true); setAttribute(Qt::WA_StaticContents); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setAcceptDrops(true); setAttribute(Qt::WA_StaticContents, true); setAttribute(Qt::WA_OpaquePaintEvent, true); setAttribute(Qt::WA_NoSystemBackground, true); pic_add =QImage(":/images/image_add.png"); pic_del =QImage(":/images/image_delete.png"); connect(&i_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleNetworkData(QNetworkReply*))); connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool))); }
void ThemePreview::reload() { if (m_color.isEmpty() || m_filename.isEmpty()) return; delete themedView; themedView = new ThemedView; themedView->setPalette(m_palette); themedView->loadSource(m_filename); themedView->resize(m_width, m_height); if (m_name == "contextbar") { QList<QSoftMenuBar::StandardLabel> labels; if (QApplication::isLeftToRight()) labels << QSoftMenuBar::Options << QSoftMenuBar::Select << QSoftMenuBar::Back; else labels << QSoftMenuBar::Back << QSoftMenuBar::Select << QSoftMenuBar::Options; for (int i=0; i<labels.size(); i++) setButton(m_buttonIcons, i, labels[i]); } }
int QMouseEventTransition::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QEventTransition::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< Qt::MouseButton*>(_v) = button(); break; case 1: *reinterpret_cast< Qt::KeyboardModifiers*>(_v) = modifierMask(); break; } _id -= 2; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setButton(*reinterpret_cast< Qt::MouseButton*>(_v)); break; case 1: setModifierMask(*reinterpret_cast< Qt::KeyboardModifiers*>(_v)); break; } _id -= 2; } else if (_c == QMetaObject::ResetProperty) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 2; } #endif // QT_NO_PROPERTIES return _id; }
void MouseButton::mouseReleaseEvent(QMouseEvent *event) { if (!mouseGrabber()) { KPushButton::mouseReleaseEvent(event); } else { releaseMouse(); const Button oldButton = m_button; switch (event->button()) { case Qt::NoButton: setButton(NoButton); break; case Qt::LeftButton: setButton(LeftButton); break; case Qt::RightButton: setButton(RightButton); break; case Qt::MidButton: setButton(MiddleButton); break; case Qt::XButton1: setButton(SpecialButton1); break; case Qt::XButton2: setButton(SpecialButton2); break; default: setButton(NoButton); break; } setChecked(false); emit buttonChanged(oldButton, m_button); } }
CompleteWiz::CompleteWiz(ProcessDF* df,QWidget* parent) :QWizard(parent) { for(int i=0; i<7; i++) Operate.push_back(true); addPage(new NoiseFillPage(df)); addPage(new PeakFilterPage); addPage(new QAssurancePage(df)); addPage(new NormPage(df)); addPage(new ImputationPage); addPage(new TransfPage(df)); addPage(new ScalPage); QPushButton *but = new QPushButton("Skip"); setButton(QWizard::CustomButton1,but); setOption(QWizard::HaveCustomButton1); DF=df; connect(this,SIGNAL(accepted()),this,SLOT(finalise())); connect(but,SIGNAL(clicked(bool)),this,SLOT(skip())); connect(button(QWizard::NextButton),SIGNAL(clicked(bool)),this,SLOT(NextBut())); }
void WMediaPlayer::addAnchor(WTemplate *t, ButtonControlId id, const char *bindId, const std::string& styleClass, const std::string& altText) { std::string text; if (altText.empty()) text = styleClass.substr(3).c_str(); else text = altText; text = "Wt.WMediaPlayer." + text; WAnchor *anchor = new WAnchor(WLink("javascript:;"), WString::tr(text)); anchor->setStyleClass(styleClass); anchor->setAttributeValue("tabindex", "1"); anchor->setToolTip(WString::tr(text)); anchor->setInline(false); t->bindWidget(bindId, anchor); setButton(id, anchor); }
void CGUIMessageBox::refreshControls() { // Layout can be seen as 4 boxes (a layoutmanager would be nice) // One box at top over the whole width for title // Two boxes with same height at the middle beside each other for icon and for text // One box at the bottom for the buttons const IGUISkin* skin = Environment->getSkin(); const s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT); const s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH); const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; // titlebar has no own constant const s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); const s32 borderWidth = skin->getSize(EGDS_MESSAGE_BOX_GAP_SPACE); // add the static text for the message core::rect<s32> staticRect; staticRect.UpperLeftCorner.X = borderWidth; staticRect.UpperLeftCorner.Y = titleHeight + borderWidth; staticRect.LowerRightCorner.X = staticRect.UpperLeftCorner.X + skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH); staticRect.LowerRightCorner.Y = staticRect.UpperLeftCorner.Y + skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT); if (!StaticText) { StaticText = Environment->addStaticText(MessageText.c_str(), staticRect, false, false, this); StaticText->setWordWrap(true); StaticText->setSubElement(true); StaticText->grab(); } else { StaticText->setRelativePosition(staticRect); StaticText->setText(MessageText.c_str()); } s32 textHeight = StaticText->getTextHeight(); s32 textWidth = StaticText->getTextWidth() + 6; // +6 because the static itself needs that const s32 iconHeight = IconTexture ? IconTexture->getOriginalSize().Height : 0; if ( textWidth < skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH) ) textWidth = skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH) + 6; // no neeed to check for max because it couldn't get larger due to statictextbox. if ( textHeight < skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT) ) textHeight = skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT); if ( textHeight > skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT) ) textHeight = skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT); // content is text + icons + borders (but not titlebar) s32 contentHeight = textHeight > iconHeight ? textHeight : iconHeight; contentHeight += borderWidth; s32 contentWidth = 0; // add icon if ( IconTexture ) { core::position2d<s32> iconPos; iconPos.Y = titleHeight + borderWidth; if ( iconHeight < textHeight ) iconPos.Y += (textHeight-iconHeight) / 2; iconPos.X = borderWidth; if (!Icon) { Icon = Environment->addImage(IconTexture, iconPos, true, this); Icon->setSubElement(true); Icon->grab(); } else { core::rect<s32> iconRect( iconPos.X, iconPos.Y, iconPos.X + IconTexture->getOriginalSize().Width, iconPos.Y + IconTexture->getOriginalSize().Height ); Icon->setRelativePosition(iconRect); } contentWidth += borderWidth + IconTexture->getOriginalSize().Width; } else if ( Icon ) { Icon->drop(); Icon->remove(); Icon = 0; } // position text core::rect<s32> textRect; textRect.UpperLeftCorner.X = contentWidth + borderWidth; textRect.UpperLeftCorner.Y = titleHeight + borderWidth; if ( textHeight < iconHeight ) textRect.UpperLeftCorner.Y += (iconHeight-textHeight) / 2; textRect.LowerRightCorner.X = textRect.UpperLeftCorner.X + textWidth; textRect.LowerRightCorner.Y = textRect.UpperLeftCorner.Y + textHeight; contentWidth += 2*borderWidth + textWidth; StaticText->setRelativePosition( textRect ); // find out button size needs s32 countButtons = 0; if (Flags & EMBF_OK) ++countButtons; if (Flags & EMBF_CANCEL) ++countButtons; if (Flags & EMBF_YES) ++countButtons; if (Flags & EMBF_NO) ++countButtons; s32 buttonBoxWidth = countButtons * buttonWidth + 2 * borderWidth; if ( countButtons > 1 ) buttonBoxWidth += (countButtons-1) * buttonDistance; s32 buttonBoxHeight = buttonHeight + 2 * borderWidth; // calc new message box sizes core::rect<s32> tmp = getRelativePosition(); s32 msgBoxHeight = titleHeight + contentHeight + buttonBoxHeight; s32 msgBoxWidth = contentWidth > buttonBoxWidth ? contentWidth : buttonBoxWidth; // adjust message box position tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2; tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight; tmp.UpperLeftCorner.X = (Parent->getAbsolutePosition().getWidth() - msgBoxWidth) / 2; tmp.LowerRightCorner.X = tmp.UpperLeftCorner.X + msgBoxWidth; setRelativePosition(tmp); // add buttons core::rect<s32> btnRect; btnRect.UpperLeftCorner.Y = titleHeight + contentHeight + borderWidth; btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight; btnRect.UpperLeftCorner.X = borderWidth; if ( contentWidth > buttonBoxWidth ) btnRect.UpperLeftCorner.X += (contentWidth - buttonBoxWidth) / 2; // center buttons btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth; IGUIElement* focusMe = 0; setButton(OkButton, (Flags & EMBF_OK) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_OK), focusMe); if ( Flags & EMBF_OK ) btnRect += core::position2d<s32>(buttonWidth + buttonDistance, 0); setButton(CancelButton, (Flags & EMBF_CANCEL) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_CANCEL), focusMe); if ( Flags & EMBF_CANCEL ) btnRect += core::position2d<s32>(buttonWidth + buttonDistance, 0); setButton(YesButton, (Flags & EMBF_YES) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_YES), focusMe); if ( Flags & EMBF_YES ) btnRect += core::position2d<s32>(buttonWidth + buttonDistance, 0); setButton(NoButton, (Flags & EMBF_NO) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_NO), focusMe); if (Environment->hasFocus(this) && focusMe) Environment->setFocus(focusMe); }
void updateButtons(bool collectEvents) { DIDEVICEOBJECTDATA data[inputBufferSize]; DWORD inOut; HRESULT hr; RECT rect; ::GetClientRect(window, &rect); bool ignoreClicks = mouseX < 0 || mouseX > rect.right || mouseY < 0 || mouseY > rect.bottom; inOut = inputBufferSize; hr = mouse->GetDeviceData(sizeof data[0], data, &inOut, 0); switch(hr) { case DI_OK: case DI_BUFFEROVERFLOW: { // Everything's ok: Update buttons and fire events. for (unsigned i = 0; i < inOut; ++i) { bool down = (data[i].dwData & 0x80) != 0 && !ignoreClicks; switch (data[i].dwOfs) { case DIMOFS_BUTTON0: { unsigned id = swapMouse ? msRight : msLeft; setButton(id, down, collectEvents); break; } case DIMOFS_BUTTON1: { unsigned id = swapMouse ? msLeft : msRight; setButton(id, down, collectEvents); break; } case DIMOFS_BUTTON2: { setButton(msMiddle, down, collectEvents); break; } case DIMOFS_Z: { if (!collectEvents || data[i].dwData == 0) break; EventInfo event; event.action = EventInfo::buttonDown; if (int(data[i].dwData) < 0) event.id = msWheelDown; else event.id = msWheelUp; events.push_back(event); event.action = EventInfo::buttonUp; events.push_back(event); break; } } } break; } case DIERR_NOTACQUIRED: case DIERR_INPUTLOST: { // Cannot fetch new events: Release all buttons. for (unsigned id = msRangeBegin; id < msRangeEnd; ++id) setButton(id, false, collectEvents); mouse->Acquire(); break; } } keyboard: inOut = inputBufferSize; hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0); switch (hr) { case DI_OK: case DI_BUFFEROVERFLOW: { for (unsigned i = 0; i < inOut; ++i) forceButton(data[i].dwOfs, (data[i].dwData & 0x80) != 0, collectEvents); break; } case DIERR_NOTACQUIRED: case DIERR_INPUTLOST: { for (unsigned id = kbRangeBegin; id < kbRangeEnd; ++id) setButton(id, false, collectEvents); keyboard->Acquire(); break; } } boost::array<bool, gpNum> gpBuffer; gpBuffer.assign(false); for (unsigned gp = 0; gp < gamepads.size(); ++gp) { gamepads[gp]->Poll(); DIJOYSTATE joy; hr = gamepads[gp]->GetDeviceState(sizeof joy, &joy); switch (hr) { case DI_OK: { if (joy.lX < -stickThreshold) gpBuffer[gpLeft - gpRangeBegin] = true; else if (joy.lX > stickThreshold) gpBuffer[gpRight - gpRangeBegin] = true; if (joy.lY < -stickThreshold) gpBuffer[gpUp - gpRangeBegin] = true; else if (joy.lY > stickThreshold) gpBuffer[gpDown - gpRangeBegin] = true; for (unsigned id = gpButton0; id < gpRangeEnd; ++id) if (joy.rgbButtons[id - gpButton0]) gpBuffer[id - gpRangeBegin] = true; break; } case DIERR_NOTACQUIRED: case DIERR_INPUTLOST: { gamepads[gp]->Acquire(); break; } } } for (unsigned id = gpRangeBegin; id < gpRangeEnd; ++id) setButton(id, gpBuffer[id - gpRangeBegin], collectEvents); }
LRESULT CALLBACK WindowProc( HWND hwnd, unsigned msg, UINT wParam, LONG lParam ) { int d,v,k,last; switch( msg ) { case WM_DESTROY: exit(0);//PostQuitMessage(0); break; case WM_PAINT: winrepaint(); break; case WM_MOUSEMOVE : d=LOWORD(lParam)-lastmovex; movesimu+=(d>0)?d:-d; d=HIWORD(lParam)-lastmovey; movesimu+=(d>0)?d:-d; lastmovex=LOWORD(lParam); lastmovey=HIWORD(lParam); if (rclicsimu) { xclicsimu=LOWORD(lParam)*1000/width; yclicsimu=HIWORD(lParam)*1000/height; d=-1; if ((yclicsimu>=250)&&(yclicsimu<750)) { if (xclicsimu<150) d=0; if (xclicsimu>850) d=1; } if (d>=0) { v=MAXMOTORVAL*(yclicsimu-250)/500; if (v<motorval[d]) for(k=motorval[d];k>v;k--) { last=motorwheel[motorval[d]]; motorval[d]--; if (last<motorwheel[motorval[d]]) motorcount[d]++; } else for(k=motorval[d];k<v;k++) { last=motorwheel[motorval[d]]; motorval[d]++; if (last<motorwheel[motorval[d]]) motorcount[d]++; } // printf("move ear %d - %d\n",motorval[d],motorcount[d]); } } break; case WM_LBUTTONDOWN : rclicsimu=1; xclicsimu=LOWORD(lParam)*1000/width; yclicsimu=HIWORD(lParam)*1000/height; if ((xclicsimu>150)&&(xclicsimu<850)) { setButton(1); } break; case WM_LBUTTONUP : rclicsimu=0; setButton(0); xclicsimu=-1; yclicsimu=-1; break; case MM_WOM_DONE: audioEventPlayData(msg,wParam,lParam); break; case MM_WIM_DATA: audioEventRecData(msg,wParam,lParam); break; case UDPEVENT: udpevent(msg,wParam,lParam); break; case TCPEVENT: tcpevent(msg,wParam,lParam); break; default: return( DefWindowProc( hwnd, msg, wParam, lParam ) ); } return 0; }
void OsuPauseMenu::updateButtons() { setButton(0, m_osu->getSkin()->getPauseContinue()); setButton(1, m_osu->getSkin()->getPauseRetry()); setButton(2, m_osu->getSkin()->getPauseBack()); }
void updateButtons(bool collectEvents) { DIDEVICEOBJECTDATA data[inputBufferSize]; DWORD inOut; HRESULT hr; RECT rect; ::GetClientRect(window, &rect); bool ignoreClicks = mouseX < 0 || mouseX > rect.right || mouseY < 0 || mouseY > rect.bottom; inOut = inputBufferSize; hr = mouse->GetDeviceData(sizeof data[0], data, &inOut, 0); switch(hr) { case DI_OK: case DI_BUFFEROVERFLOW: { // Everything's ok: Update buttons and fire events. for (unsigned i = 0; i < inOut; ++i) { bool down = (data[i].dwData & 0x80) != 0 && !ignoreClicks; // No switch statement here because it breaks compilation with MinGW. if (data[i].dwOfs == DIMOFS_BUTTON0) { unsigned id = swapMouse ? msRight : msLeft; setButton(id, down, collectEvents); } else if (data[i].dwOfs == DIMOFS_BUTTON1) { unsigned id = swapMouse ? msLeft : msRight; setButton(id, down, collectEvents); } else if (data[i].dwOfs == DIMOFS_BUTTON2) { setButton(msMiddle, down, collectEvents); } else if (data[i].dwOfs == DIMOFS_Z && collectEvents && data[i].dwData) { EventInfo event; event.action = EventInfo::buttonDown; if (int(data[i].dwData) < 0) event.id = msWheelDown; else event.id = msWheelUp; events.push_back(event); event.action = EventInfo::buttonUp; events.push_back(event); } } break; } case DIERR_NOTACQUIRED: case DIERR_INPUTLOST: { // Cannot fetch new events: Release all buttons. for (unsigned id = msRangeBegin; id <= msRangeEnd; ++id) setButton(id, false, collectEvents); mouse->Acquire(); break; } } inOut = inputBufferSize; hr = keyboard->GetDeviceData(sizeof data[0], data, &inOut, 0); switch (hr) { case DI_OK: case DI_BUFFEROVERFLOW: { for (unsigned i = 0; i < inOut; ++i) forceButton(data[i].dwOfs, (data[i].dwData & 0x80) != 0, collectEvents); break; } case DIERR_NOTACQUIRED: case DIERR_INPUTLOST: { for (unsigned id = kbRangeBegin; id <= kbRangeEnd; ++id) setButton(id, false, collectEvents); keyboard->Acquire(); break; } } std::tr1::array<bool, gpNum> gpBuffer = { false }; for (unsigned gp = 0; gp < gamepads.size() && gp < numGamepads; ++gp) { gamepads[gp]->Poll(); int rangeOffset = (gp + 1) * gpNumPerGamepad - gpRangeBegin; DIJOYSTATE joy; hr = gamepads[gp]->GetDeviceState(sizeof joy, &joy); switch (hr) { case DI_OK: { if (joy.lX < -stickThreshold) gpBuffer[gpLeft + rangeOffset] = true; else if (joy.lX > stickThreshold) gpBuffer[gpRight + rangeOffset] = true; if (joy.lY < -stickThreshold) gpBuffer[gpUp + rangeOffset] = true; else if (joy.lY > stickThreshold) gpBuffer[gpDown + rangeOffset] = true; for (unsigned id = gpButton0; id <= gpButton15; ++id) if (joy.rgbButtons[id - gpButton0]) gpBuffer[id + rangeOffset] = true; break; } case DIERR_NOTACQUIRED: case DIERR_INPUTLOST: { gamepads[gp]->Acquire(); break; } } // Merge these results into the area for "all gamepads OR'ed together" for (int index = 0; index < gpNumPerGamepad; ++index) gpBuffer[index] = (gpBuffer[index] || gpBuffer[index + (gp + 1) * gpNumPerGamepad]); } for (unsigned id = gpRangeBegin; id <= gpRangeEnd; ++id) setButton(id, gpBuffer[id - gpRangeBegin], collectEvents); }