void keyboardGui(int key, int unicode, int x, int y) { int i; switch(key) { case 27: #ifdef SOUND if(game->settings->playEffects) playMenuFX(fx_action); #endif if(pCurrent->parent == NULL) restoreCallbacks(); else pCurrent = pCurrent->parent; break; case 13: case ' ': #ifdef SOUND if(game->settings->playEffects) playMenuFX(fx_action); #endif menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_ACTION); break; case SYSTEM_KEY_LEFT: menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_LEFT); break; case SYSTEM_KEY_RIGHT: menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_RIGHT); break; /* case 'q': SystemExit(); break; */ case SYSTEM_KEY_DOWN: #ifdef SOUND if(game->settings->playEffects) playMenuFX(fx_highlight); #endif pCurrent->iHighlight = (pCurrent->iHighlight + 1) % pCurrent->nEntries; break; case SYSTEM_KEY_UP: #ifdef SOUND if(game->settings->playEffects) playMenuFX(fx_highlight); #endif pCurrent->iHighlight = (pCurrent->iHighlight - 1) % pCurrent->nEntries; if(pCurrent->iHighlight < 0) pCurrent->iHighlight = pCurrent->nEntries - 1; break; case SYSTEM_KEY_F11: doBmpScreenShot(); break; case SYSTEM_KEY_F12: doScreenShot(); break; /* debug code follows */ case 'l': printf("%d entries:\n", pCurrent->nEntries); for(i = 0; i < pCurrent->nEntries; i++) printf("printing '%s' - %d entries\n", ((Menu*)*(pCurrent->pEntries + i))->szName, ((Menu*)*(pCurrent->pEntries + i))->nEntries); break; default: printf("got key %d\n", key); } SystemPostRedisplay(); }
EventMode & EventMode::operator = (editmode m) { mode = m; if (!areawin) return *this; // disable actions that only apply in text mode bool inTextMode = m == TEXT_MODE || m == ETEXT_MODE; setEnabled(menuAction("Style_Subscript"), inTextMode); setEnabled(menuAction("Style_Underline"), inTextMode); setEnabled(menuAction("Text_Insert"), inTextMode); return *this; }
void PopupMenu::init() { _contextMenu = 0; _lastHoveredAction = 0; _highlightedAction = 0; // Menus will trigger! Set to make sure our trigger handlers ignore menus. menuAction()->setData(-1); _cur_menu = this; _cur_menu_count = 1; _cur_item_width = 0; _cur_col_count = 0; moveDelta = 0; timer = 0; connect(this, SIGNAL(hovered(QAction*)), SLOT(popHovered(QAction*))); if(MusEGlobal::config.scrollableSubMenus) { setStyleSheet("QMenu { menu-scrollable: 1; }"); return; } #ifndef POPUP_MENU_DISABLE_AUTO_SCROLL timer = new QTimer(this); timer->setInterval(100); timer->setSingleShot(false); connect(timer, SIGNAL(timeout()), SLOT(timerHandler())); #endif // POPUP_MENU_DISABLE_AUTO_SCROLL }
QAction *colormarkaction() { QAction *action = NULL; int i = colorlist.indexOf(areawin->color); action = menuAction("Elements_Color")->menu()->actions()[i+3]; return action; }
void PopupMenu::closeUp() { if(isVisible()) { DEBUG_PRST_ROUTES(stderr, "PopupMenu::closeUp() this:%p closing\n", this); close(); } QAction* act = menuAction(); if(act) { DEBUG_PRST_ROUTES(stderr, "PopupMenu::closeUp() this:%p menuAction:%p\n", this, act); const int sz = act->associatedWidgets().size(); for(int i = 0; i < sz; ++i) { DEBUG_PRST_ROUTES(stderr, " associated widget#:%d\n", i); if(PopupMenu* pup = qobject_cast<PopupMenu*>(act->associatedWidgets().at(i))) { DEBUG_PRST_ROUTES(stderr, " associated popup:%p\n", pup); DEBUG_PRST_ROUTES(stderr, " closing...\n"); pup->closeUp(); } } } }
void setcolormark(QRgb colorval) { int i; if (colorval != DEFAULTCOLOR) { i = 3 + colorlist.indexOf(colorval); if (i<3) return; // no such color :( } else { i = 2; // index of the "Inherit Color" action } // 1. mark the color in the menu toggleexcl(menuAction("Elements_Color")->menu()->actions()[i]); // 2. mark the color on the toolbar QAbstractButton *button = toolbar->findChild<QAbstractButton*>("Colors"); int toolIndex = button->property("index").toInt(); QImage img(ToolBar[toolIndex].icon_data); QPixmap pix(img.size()); QPainter p(&pix); if (i==2) { // inherit color -- default pixmap p.drawImage(0, 0, img); } else { // color pixmap p.fillRect(img.rect(), QColor(colorval)); } button->actions().first()->setIcon(QIcon(pix)); }
void Menu::checkMenu(){ int xValue = Esplora.readJoystickX(); int yValue = Esplora.readJoystickY(); int button = Esplora.readJoystickSwitch(); int x = map(xValue, -512, 512, 10, -10); int y = map(yValue, -512, 512, -10, 10); if(x > 4){ if(_currentButton + 1 > (_numberOfButtons - 1)) setCurrentButton(0); else setCurrentButton(_currentButton + 1); delay(100); } else if(x < -4){ if(_currentButton -1 < 0) setCurrentButton(_numberOfButtons - 1); else setCurrentButton(_currentButton - 1); delay(100); } else if(y > 4){ if(_currentButton + 2 > (_numberOfButtons - 1)) setCurrentButton(0); else setCurrentButton(_currentButton + EsploraTFT.width() / _buttons[0].getSizeX()); delay(100); } else if(y < -4){ if(_currentButton -2 < 0) setCurrentButton(_numberOfButtons - 1); else setCurrentButton(_currentButton - EsploraTFT.width() / _buttons[0].getSizeX()); delay(100); } if(Esplora.readButton(SWITCH_DOWN) == 0) menuAction(SWITCH_DOWN, _currentButton); if(Esplora.readButton(SWITCH_UP) == 0) menuAction(SWITCH_UP, _currentButton); if(Esplora.readButton(SWITCH_RIGHT) == 0) menuAction(SWITCH_RIGHT, _currentButton); if(Esplora.readButton(SWITCH_LEFT) == 0) menuAction(SWITCH_LEFT, _currentButton); }
void ClientWindow::cascade_menu_selected(int id,Point point) { menuAction(id,point); menuOff(); editor.setFocus(); }
/* Permet de choisir un element du menu donne en parametre sans pouvoir retourner en arriere ou de quitter le jeu et execute le choix du joueur */ void menuChoisirSansOperationPossible(const Menu *menu, const char *messageAvantMenu) { unsigned int choixJoueur; if(messageAvantMenu != NULL) printf("%s\n\n", messageAvantMenu); /* On affiche le menu */ menuAfficher(menu); /* On demande au joueur ce qu'il veut */ choixJoueur = choisirMenuSansOperationPossible(menu->nbComposant); /* On execute le choix du joueur */ menuAction(menu, choixJoueur); }
void guiMouse(int buttons, int state, int x, int y) { fprintf(stderr, "Mouse buttons: %d, State %d, Position (%d, %d)\n", buttons, state, x, y); /* fprintf(stderr, "testing for state == %d\n", SYSTEM_MOUSEPRESSED); */ if (state == SYSTEM_MOUSEPRESSED) { #ifdef SOUND if(game->settings->playEffects) playMenuFX(fx_action); #endif menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_ACTION); SystemPostRedisplay(); } }
void ClientWindow::react_Key(VKey vkey,KeyMod kmod) { switch( vkey ) { case VKey_F2 : { menuAction(MenuFileSave); } break; case VKey_F3 : { menuAction(MenuFileOpen); } break; case VKey_F10 : { menu.setFocus(); } break; case VKey_Esc : { menuOff(); editor.setFocus(); } break; default: { wlist.put_Key(vkey,kmod); } } }
void TermTab::SetupColorsButton () { auto colorMenu = new QMenu { tr ("Color scheme"), this }; colorMenu->menuAction ()->setProperty ("ActionIcon", "fill-color"); connect (colorMenu, SIGNAL (triggered (QAction*)), this, SLOT (setColorScheme (QAction*))); connect (colorMenu, SIGNAL (hovered (QAction*)), this, SLOT (previewColorScheme (QAction*))); connect (colorMenu, SIGNAL (aboutToHide ()), this, SLOT (stopColorSchemePreview ())); const auto& lastScheme = XmlSettingsManager::Instance () .Property ("LastColorScheme", "Linux").toString (); const auto colorActionGroup = new QActionGroup { colorMenu }; for (const auto& colorScheme : ColorSchemesMgr_->GetSchemes ()) { auto act = colorMenu->addAction (colorScheme.Name_); act->setCheckable (true); act->setProperty ("ER/ColorScheme", colorScheme.ID_); if (colorScheme.ID_ == lastScheme) { act->setChecked (true); setColorScheme (act); } colorActionGroup->addAction (act); } auto colorButton = new QToolButton { Toolbar_ }; colorButton->setPopupMode (QToolButton::InstantPopup); colorButton->setMenu (colorMenu); colorButton->setProperty ("ActionIcon", "fill-color"); Toolbar_->addWidget (colorButton); }
/*-------------------------------------------------------------------------------------------------------------------------- --FUNCTION: WndProcMain -- --DATE : Sep 26, 2015 -- --REVISIONS : Sep 26, 2015 - actions after connecting port. -- Oct 20, 2015 - added edit box, added listener for window resize -- Jan 18, 2016 - add font for textbox -- --DESIGNER : Eunwon Moon -- --PROGRAMMER : Eunwon Moon -- --INTERFACE : LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) -- HWND hwnd : a handle to the winmain window procedure which received the message. -- UNIT Message : the received control message which is generated by user action. -- WPARAM wParam : tha additional message information de -- LPARAM lParam : the additional message information -- --RETURNS : LRESULT -- --NOTES : -- Call this functions depending on users action after connecting. initialize dialog information -- and detect menu item use or event which is set using WSAAsycSelect. -- ----------------------------------------------------------------------------------------------------------------------*/ INT_PTR CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: dialogInit(hwnd); return TRUE; case WM_COMMAND: menuAction(hwnd, wParam); break; case WM_TCPSERV: case WM_UDPSERV: case WM_TCPSERVCONN: ServWinProc(hwnd, Message, wParam, lParam, &server_sock); break; case WM_TCPCLENT: case WM_UDPCLENT: ClientProc(hwnd, Message, wParam, lParam, &client_sock); break; // Terminate program case WM_DESTROY: PostQuitMessage(0); shutdown(op_type == SERVER ? server_sock : client_sock, SD_BOTH); closesocket(op_type == CLIENT ? server_sock : client_sock); WSACleanup(); break; default: return DefWindowProc(hwnd, Message, wParam, lParam); break; } return 0; }
int addnewcolorentry(QRgb ccolor, QMenu* mainMenu) { static const int iconWidth = 24; static const int iconHeight = 24; int i = colorlist.indexOf(ccolor); if (i >= 0) return i; /* color icon */ QPixmap pm(iconWidth, iconHeight); QPainter p(&pm); p.fillRect(pm.rect(), QColor(ccolor)); /* add action to the main menu */ if (!mainMenu) mainMenu = menuAction("Elements_Color")->menu(); QAction * action = mainMenu->addAction(QIcon(pm), ""); action->setCheckable(true); XtAddCallback (action, setcolor, NULL); colorlist.append(ccolor); return colorlist.count()-1; }
void Menu::clearModelMenu() { const int offset = ((m_role == BookmarksMenuRole && menuAction() && !menuAction()->data().toModelIndex().isValid()) ? 3 : 0); for (int i = (actions().count() - 1); i >= offset; --i) { actions().at(i)->deleteLater(); removeAction(actions().at(i)); } if (m_role != BookmarksMenuRole && menuAction()) { const QAbstractItemModel *model = menuAction()->data().toModelIndex().model(); if (model) { menuAction()->setEnabled(model->rowCount(menuAction()->data().toModelIndex()) > 0); } } connect(this, SIGNAL(aboutToShow()), this, SLOT(populateModelMenu())); }
void UserContextMenu::onMultiUserPresence(IMultiUser *AUser, int AShow, const QString &/*AStatus*/) { if (AUser->nickName() == FChatWindow->contactJid().resource()) menuAction()->setVisible(AShow!=IPresence::Offline && AShow!=IPresence::Error); }
void SimulationExperimentViewInformationParametersWidget::populateContextMenu(CellMLSupport::CellmlFileRuntime *pRuntime) { // Create our two main menu items if (mVoiAccessible) { mPlotAgainstVoiMenuAction = mContextMenu->addAction(QString()); } mPlotAgainstMenu = new QMenu(mContextMenu); mContextMenu->addMenu(mPlotAgainstMenu); // Initialise our two main menu items retranslateContextMenu(); // Create a connection to handle the graph requirement against our VOI, and // keep track of the parameter associated with our first main menu item if (mVoiAccessible) { connect(mPlotAgainstVoiMenuAction, &QAction::triggered, this, &SimulationExperimentViewInformationParametersWidget::emitGraphRequired); mParameterActions.insert(mPlotAgainstVoiMenuAction, pRuntime->voi()); } // Populate our context menu with the parameters QString componentHierarchy = QString(); QMenu *componentMenu = nullptr; for (auto parameter : pRuntime->parameters()) { // Check whether the current parameter is in the same component // hierarchy as the previous one QString crtComponentHierarchy = parameter->formattedComponentHierarchy(); if (crtComponentHierarchy != componentHierarchy) { // The current parameter is in a different component hierarchy, so // create a new menu hierarchy for our 'new' component, reusing // existing menus, whenever possible QMenu *menu = mPlotAgainstMenu; for (const auto &component : parameter->componentHierarchy()) { // Check whether we already have a menu for our current // component componentMenu = nullptr; for (auto object : menu->children()) { auto subMenu = qobject_cast<QMenu *>(object); if ( (subMenu != nullptr) && (subMenu->menuAction()->text() == component)) { componentMenu = subMenu; break; } } // Create a new menu for our current component, if none could be // found if (componentMenu == nullptr) { componentMenu = new QMenu(component, menu); menu->addMenu(componentMenu); } // Get ready for the next component in our component hierarchy menu = componentMenu; } // Keep track of the new component hierarchy componentHierarchy = crtComponentHierarchy; } // Make sure that we have a 'current' component menu // Note: this should never happen, but we never know... if (componentMenu == nullptr) { continue; } // Add the current parameter to the 'current' component menu QAction *parameterAction = componentMenu->addAction(CellMLSupport::CellmlFileRuntimeParameter::icon(parameter->type()), parameter->formattedName()); // Create a connection to handle the graph requirement against our // parameter connect(parameterAction, &QAction::triggered, this, &SimulationExperimentViewInformationParametersWidget::emitGraphRequired); // Keep track of the parameter associated with our parameter action mParameterActions.insert(parameterAction, parameter); } }
void KMenu::keyPressEvent(QKeyEvent* e) { d->mouseButtons = Qt::NoButton; d->keyboardModifiers = Qt::NoModifier; if (!d->shortcuts) { d->keyboardModifiers = e->modifiers(); QMenu::keyPressEvent(e); if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down) { d->skipTitles(e); } return; } QAction* a = 0L; bool firstpass = true; QString keyString = e->text(); // check for common commands dealt with by QMenu int key = e->key(); if (key == Qt::Key_Escape || key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Up || key == Qt::Key_Down || key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_F1 || key == Qt::Key_PageUp || key == Qt::Key_PageDown || key == Qt::Key_Back || key == Qt::Key_Select) { d->resetKeyboardVars(); // continue event processing by QMenu //e->ignore(); d->keyboardModifiers = e->modifiers(); QMenu::keyPressEvent(e); if (key == Qt::Key_Up || key == Qt::Key_Down) { d->skipTitles(e); } return; } else if ( key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt || key == Qt::Key_Meta ) return QMenu::keyPressEvent(e); // check to see if the user wants to remove a key from the sequence (backspace) // or clear the sequence (delete) if (!d->keySeq.isNull()) { if (key == Qt::Key_Backspace) { if (d->keySeq.length() == 1) { d->resetKeyboardVars(); return; } // keep the last sequence in keyString keyString = d->keySeq.left(d->keySeq.length() - 1); // allow sequence matching to be tried again d->resetKeyboardVars(); } else if (key == Qt::Key_Delete) { d->resetKeyboardVars(); // clear active item setActiveAction(0L); return; } else if (d->noMatches) { // clear if there are no matches d->resetKeyboardVars(); // clear active item setActiveAction(0L); } else { // the key sequence is not a null string // therefore the lastHitAction is valid a = d->lastHitAction; } } else if (key == Qt::Key_Backspace && menuAction()) { // backspace with no chars in the buffer... go back a menu. hide(); d->resetKeyboardVars(); return; } d->keySeq += keyString; const int seqLen = d->keySeq.length(); foreach (a, actions()) { // don't search disabled entries if (!a->isEnabled()) continue; QString thisText; // retrieve the right text // (the last selected item one may have additional ampersands) if (a == d->lastHitAction) thisText = d->originalText; else thisText = a->text(); // if there is an accelerator present, remove it thisText = KGlobal::locale()->removeAcceleratorMarker(thisText); // chop text to the search length thisText = thisText.left(seqLen); // do the search if (!thisText.indexOf(d->keySeq, 0, Qt::CaseInsensitive)) { if (firstpass) { // match setActiveAction(a); // check to see if we're underlining a different item if (d->lastHitAction && d->lastHitAction != a) // yes; revert the underlining d->lastHitAction->setText(d->originalText); // set the original text if it's a different item if (d->lastHitAction != a || d->lastHitAction == 0L) d->originalText = a->text(); // underline the currently selected item a->setText(underlineText(d->originalText, d->keySeq.length())); // remember what's going on d->lastHitAction = a; // start/restart the clear timer d->clearTimer.setSingleShot(true); d->clearTimer.start(5000); // go around for another try, to see if we can execute firstpass = false; } else { // don't allow execution return; } } // fall through to allow execution } if (!firstpass) { if (d->autoExec) { // activate anything d->lastHitAction->activate(QAction::Trigger); d->resetKeyboardVars(); } else if (d->lastHitAction && d->lastHitAction->menu()) { // only activate sub-menus d->lastHitAction->activate(QAction::Trigger); d->resetKeyboardVars(); } return; } // no matches whatsoever, clean up d->resetKeyboardVars(true); //e->ignore(); QMenu::keyPressEvent(e); }
void ClientWindow::menuAction(int id) { menuAction(id,toScreen(action_base)); }