void TabPanel::mousePressed(MouseEventDetails* const e) { bool isContained; for(Int32 i(getMFTabs()->size()-1) ; i>=0 ; --i) { // going backwards through through elements, so only top button is pressed isContained = getTabs(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTabs(i),isContained,e->getViewport()); if(isContained) { //Give myself temporary focus takeFocus(true); if(!getTabs(i)->getType().isDerivedFrom(ComponentContainer::getClassType())) { getTabs(i)->takeFocus(); } getTabs(i)->mousePressed(e); break; } } if(isContained) { //Remove my temporary focus giveFocus(NULL, false); } else { //Give myself permanant focus takeFocus(); } // now do it for the content tab isContained = getTabContents(getSelectedIndex())->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getTabContents(getSelectedIndex()),isContained,e->getViewport()); if(isContained) { //Give myself temporary focus takeFocus(true); if(!getTabContents(getSelectedIndex())->getType().isDerivedFrom(ComponentContainer::getClassType())) { getTabContents(getSelectedIndex())->takeFocus(); } getTabContents(getSelectedIndex())->mousePressed(e); giveFocus(NULL, false); } else { //Give myself permanent focus takeFocus(); } Component::mousePressed(e); }
bool CursesBase::processEvent(QEvent* ev) { switch(ev->type()) { case GUIEvent::GUISizeChanged: setSize(geom().size()); break; case GUIEvent::GUIGeometryChanged: { GUIContainer* container = widget()->parentContainer(); if(container) container->markLayoutDirty(); break; } case GUIEvent::GUITextChanged: markDirty(); break; case GUIEvent::GUIPositionChanged: widget()->simEvent(GUIEvent::GUIScreenPositionChanged); case GUIEvent::GUIVisibilityChanged: repaint(); break; case GUIEvent::GUIMouseClicked: if(widget()->wattr().testFlag(GUIWidget::Focusable)) giveFocus(); break; case GUIEvent::GUIKeyTyped: { GUIContainer* container; if(container = widget()->parentContainer()) container->internal<CursesBase>()->pushEvent(ev); break; } case GUIEvent::GUIWAttrChanged: if(widget()->wattr().testFlag(GUIWidget::Focused)) { if(!widget()->wattr().testFlag(GUIWidget::Focusable)) widget()->setWAttr(GUIWidget::Focused, false); else giveFocus(); } break; default: break; } return false; }
void RotatedComponent::mousePressed(MouseEventDetails* const e) { bool isContained(false); for(Int32 i(getMFChildren()->size()-1) ; i>=0 ; --i) { isContained = getChildren(i)->isContained(e->getLocation(), true); checkMouseEnterExit(e,e->getLocation(),getChildren(i),isContained,e->getViewport()); if(isContained) { //Give myself temporary focus takeFocus(true); if(!getChildren(i)->getType().isDerivedFrom(ComponentContainer::getClassType())) { getChildren(i)->takeFocus(); } getChildren(i)->mousePressed(e); break; } } if(isContained) { //Remove my temporary focus giveFocus(NULL, false); } else { //Give myself permenant focus takeFocus(); } Component::mousePressed(e); }
CTextInput::CTextInput( const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB ) :cb(CB) { focus = false; pos += Pos; captureAllKeys = true; OBJ_CONSTRUCTION; bg = new CPicture(bgName, bgOffset.x, bgOffset.y); addUsedEvents(LCLICK | KEYBOARD); giveFocus(); }
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB): CLabel(Pos.x, Pos.y, font, CENTER), cb(CB) { type |= REDRAW_PARENT; focus = false; pos.h = Pos.h; pos.w = Pos.w; textOffset = Point(pos.w/2, pos.h/2); captureAllKeys = true; bg = nullptr; addUsedEvents(LCLICK | KEYBOARD); giveFocus(); }
CTextInput::CTextInput(const Rect &Pos, SDL_Surface *srf) { focus = false; pos += Pos; captureAllKeys = true; OBJ_CONSTRUCTION; bg = new CPicture(Pos, 0, true); Rect hlp = Pos; if(srf) CSDL_Ext::blitSurface(srf, &hlp, *bg, NULL); else SDL_FillRect(*bg, NULL, 0); pos.w = bg->pos.w; pos.h = bg->pos.h; bg->pos = pos; addUsedEvents(LCLICK | KEYBOARD); giveFocus(); }
// static void LLPanelLogin::setFields(const LLSavedLoginEntry& entry, bool takeFocus) { if (!sInstance) { llwarns << "Attempted setFields with no login view shown" << llendl; return; } LLCheckBoxCtrl* remember_pass_check = sInstance->getChild<LLCheckBoxCtrl>("remember_check"); std::string fullname = nameJoin(entry.getFirstName(), entry.getLastName(), entry.isSecondLife()); LLComboBox* login_combo = sInstance->getChild<LLComboBox>("username_combo"); login_combo->setTextEntry(fullname); login_combo->resetTextDirty(); //sInstance->childSetText("username_combo", fullname); std::string grid = entry.getGrid(); //grid comes via LLSavedLoginEntry, which uses full grid names, not nicks if(!grid.empty() && gHippoGridManager->getGrid(grid) && grid != gHippoGridManager->getCurrentGridName()) { gHippoGridManager->setCurrentGrid(grid); } if (entry.getPassword().empty()) { sInstance->childSetText("password_edit", std::string("")); remember_pass_check->setValue(LLSD(false)); } else { const std::string filler("123456789!123456"); sInstance->childSetText("password_edit", filler); sInstance->mIncomingPassword = filler; sInstance->mMungedPassword = entry.getPassword(); remember_pass_check->setValue(LLSD(true)); } if (takeFocus) { giveFocus(); } }
void Button::update(){ updateDrawableTextPosition(); m_lastState = m_state; sf::FloatRect rect(getRealPosition().x, getRealPosition().y, getSize().x, getSize().y); if (!rect.contains(GUICore::events()->getMousePosition().x, GUICore::events()->getMousePosition().y)){ m_state = Normal; return; } if (rect.contains(GUICore::events()->getMousePosition().x, GUICore::events()->getMousePosition().y) && GUICore::events()->getMouseBoutonState(sf::Mouse::Left) == GUIEvents::StateReleased){ m_state = Hovered; return; } if (GUICore::events()->getMouseBoutonState(sf::Mouse::Left) == GUIEvents::StatePressed && m_state == Hovered){ m_state = Clicked; giveFocus(); } }
// static void LLPanelLogin::setFields(const LLSavedLoginEntry& entry, bool takeFocus) { if (!sInstance) { llwarns << "Attempted setFields with no login view shown" << llendl; return; } LLCheckBoxCtrl* remember_pass_check = sInstance->getChild<LLCheckBoxCtrl>("remember_check"); LLComboBox* login_combo = sInstance->getChild<LLComboBox>("first_name_combo"); login_combo->setLabel(entry.getFirstName()); login_combo->resetDirty(); login_combo->resetTextDirty(); LLLineEditor* last_name = sInstance->getChild<LLLineEditor>("last_name_edit"); last_name->setText(entry.getLastName()); last_name->resetDirty(); if (entry.getPassword().empty()) { sInstance->childSetText("password_edit", std::string("")); remember_pass_check->setValue(LLSD(false)); } else { const std::string filler("123456789!123456"); sInstance->childSetText("password_edit", filler); sInstance->mIncomingPassword = filler; sInstance->mMungedPassword = entry.getPassword(); remember_pass_check->setValue(LLSD(true)); } LLComboBox* server_combo = sInstance->getChild<LLComboBox>("server_combo"); if (server_combo->getSimple() != entry.getGridName()) // Avoid loops. { server_combo->setSimple(entry.getGridName()); // Same string as used in login_show(). } LLViewerLogin* vl = LLViewerLogin::getInstance(); if (entry.getGrid() == GRID_INFO_OTHER) { vl->setGridURI(entry.getGridURI().asString()); vl->setHelperURI(entry.getHelperURI().asString()); vl->setLoginPageURI(entry.getLoginPageURI().asString()); } EGridInfo entry_grid = entry.getGrid(); if (entry_grid == GRID_INFO_OTHER || entry_grid != vl->getGridChoice()) { vl->setGridChoice(entry_grid); // grid changed so show new splash screen (possibly) loadLoginPage(); } if (takeFocus) { giveFocus(); } }
void CTextInput::clickLeft( tribool down, bool previousState ) { if(down && !focus) giveFocus(); }
//----------------------------------------------------------------------------- // // Class MainWindow // //----------------------------------------------------------------------------- MainWindow::MainWindow(QWidget *wp) : QMainWindow(wp) { QAction *a; setWindowTitle(_("untitled - UDAV")); setAttribute(Qt::WA_DeleteOnClose); split = new QSplitter(this); ltab = new QTabWidget(split); ltab->setMovable(true); ltab->setTabPosition(QTabWidget::South); // ltab->setTabsClosable(true); rtab = new QTabWidget(split); rtab->setMovable(true); rtab->setTabPosition(QTabWidget::South); messWnd = new QDockWidget(_("Messages and warnings"),this); mess = new QTextEdit(this); messWnd->setWidget(mess); messWnd->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, messWnd); messWnd->resize(size().width(), 0); new MessSyntax(mess); // connect(mess,SIGNAL(cursorPositionChanged()),this,SLOT(messClicked())); connect(mess,SIGNAL(selectionChanged()),this,SLOT(messClicked())); hideWnd = new QDockWidget(_("Hidden plots"),this); hidden = new TextEdit(this); hideWnd->setWidget(hidden); hideWnd->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, hideWnd); hideWnd->resize(size().width(), 0); hidden->setReadOnly(true); connect(hidden,SIGNAL(selectionChanged()),this,SLOT(hiddenClicked())); // TODO // connect(hidden,SIGNAL(cursorPositionChanged()),this,SLOT(hiddenClicked())); calcWnd = new QDockWidget(_("Calculator"),this); aload = a = new QAction(QPixmap(":/png/document-open.png"), _("Open file"), this); connect(a, SIGNAL(triggered()), this, SLOT(choose())); a->setToolTip(_("Open and execute/show script or data from file (Ctrl+O).\nYou may switch off automatic exection in UDAV properties.")); a->setShortcut(Qt::CTRL+Qt::Key_O); asave = a = new QAction(QPixmap(":/png/document-save.png"), _("Save script"), this); connect(a, SIGNAL(triggered()), this, SLOT(save())); a->setToolTip(_("Save script to a file (Ctrl+S)")); a->setShortcut(Qt::CTRL+Qt::Key_S); acalc = a = new QAction(QPixmap(":/png/accessories-calculator.png"), _("Calculator"), this); a->setShortcut(Qt::Key_F4); a->setCheckable(true); connect(a, SIGNAL(toggled(bool)), calcWnd, SLOT(setVisible(bool))); connect(calcWnd, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); a->setToolTip(_("Show calculator which evaluate and help to type textual formulas.\nTextual formulas may contain data variables too.")); a->setChecked(false); calcWnd->setVisible(false); ainfo = a = new QAction(_("Show info"), this); a->setShortcut(Qt::Key_F2); a->setCheckable(true); connect(a, SIGNAL(toggled(bool)), messWnd, SLOT(setVisible(bool))); connect(messWnd, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); a->setChecked(false); messWnd->setVisible(false); ahide = a = new QAction(QPixmap(":/png/layer-visible-on.png"), _("Show hidden plots"), this); a->setShortcut(Qt::Key_F8); a->setCheckable(true); connect(a, SIGNAL(toggled(bool)), hideWnd, SLOT(setVisible(bool))); connect(hideWnd, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); a->setChecked(false); hideWnd->setVisible(false); graph = new PlotPanel(this); rtab->addTab(graph,QPixmap(":/png/office-chart-line.png"),_("Canvas")); // connect(info,SIGNAL(addPanel(QWidget*)),this,SLOT(addPanel(QWidget*))); info = createMemPanel(this); rtab->addTab(info,QPixmap(":/png/system-file-manager.png"),_("Info")); hlp = createHlpPanel(this); rtab->addTab(hlp,QPixmap(":/png/help-contents.png"),_("Help")); edit = new TextPanel(this); edit->graph = graph; graph->textMGL = edit->edit; connect(graph->mgl,SIGNAL(showWarn(QString)),mess,SLOT(setText(QString))); connect(graph->mgl,SIGNAL(showWarn(QString)),edit->edit,SLOT(setErrMessage(QString))); connect(graph,SIGNAL(clearWarn()),mess,SLOT(clear())); ltab->addTab(edit,QPixmap(":/png/text-plain.png"),_("Script")); calcWnd->setWidget(createCalcDlg(this, edit->edit)); calcWnd->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, calcWnd); calcWnd->resize(size().width(), 200); makeMenu(); setCentralWidget(split); setWindowIcon(QIcon(":/udav.png")); readSettings(); if(!propDlg) propDlg = new PropDialog; connect(graph, SIGNAL(save()), this, SLOT(save())); connect(graph, SIGNAL(setStatus(const QString &)), this, SLOT(setStatus(const QString &))); connect(graph, SIGNAL(animPutText(const QString &)), edit, SLOT(animPutText(const QString &))); connect(graph,SIGNAL(giveFocus()),edit->edit,SLOT(setFocus())); connect(graph->mgl, SIGNAL(objChanged(int)), edit, SLOT(setCursorPosition(int))); // connect(graph->mgl, SIGNAL(posChanged(QString)), statusBar(), SLOT(showMessage(QString))); connect(graph->mgl, SIGNAL(refreshData()), this, SLOT(refresh())); connect(graph->mgl, SIGNAL(refreshData()), edit, SLOT(refreshData())); connect(graph->mgl,SIGNAL(doubleClick(int)),edit,SLOT(newCmd(int))); connect(edit->edit,SIGNAL(textChanged()),this,SLOT(updateHidden())); connect(mess, SIGNAL(textChanged()), this, SLOT(warnChanged())); connect(propDlg, SIGNAL(sizeChanged(int,int)), graph->mgl, SLOT(imgSize(int,int))); connect(edit->edit,SIGNAL(textChanged()), this, SLOT(setAsterix())); connect(edit->edit, SIGNAL(cursorPositionChanged()), this, SLOT(editPosChanged())); connect(edit,SIGNAL(setCurrentFile(QString)),this,SLOT(setCurrentFile(QString))); connect(edit,SIGNAL(setStatus(QString)),this,SLOT(setStatus(QString))); setStatus(_("Ready")); num_wnd++; edit->setAcceptDrops(false); // for disabling default action by 'edit' setAcceptDrops(true); }