void UITextEdit::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode) { UIWidget::onStyleApply(styleName, styleNode); for(const OTMLNodePtr& node : styleNode->children()) { if(node->tag() == "text") { setText(node->value()); setCursorPos(m_text.length()); } else if(node->tag() == "text-hidden") setTextHidden(node->value<bool>()); else if(node->tag() == "shift-navigation") setShiftNavigation(node->value<bool>()); else if(node->tag() == "multiline") setMultiline(node->value<bool>()); else if(node->tag() == "max-length") setMaxLength(node->value<int>()); else if(node->tag() == "editable") setEditable(node->value<bool>()); else if(node->tag() == "selectable") setSelectable(node->value<bool>()); else if(node->tag() == "selection-color") setSelectionColor(node->value<Color>()); else if(node->tag() == "selection-background-color") setSelectionBackgroundColor(node->value<Color>()); else if(node->tag() == "selection") { Point selectionRange = node->value<Point>(); setSelection(selectionRange.x, selectionRange.y); } else if(node->tag() == "cursor-visible") setCursorVisible(node->value<bool>()); else if(node->tag() == "change-cursor-image") setChangeCursorImage(node->value<bool>()); else if(node->tag() == "auto-scroll") setAutoScroll(node->value<bool>()); } }
bool AccDecDlg::initIndex() { TraceOp.trc( "accdecdlg", TRCLEVEL_INFO, __LINE__, 9999, "initIndex" ); iONode model = wxGetApp().getModel(); if( model != NULL ) { iONode declist = wPlan.getdeclist( model ); if( declist == NULL ) { declist = NodeOp.inst(wDecList.name(), model, ELEMENT_NODE); NodeOp.addChild(model, declist); } if( declist != NULL ) { fillIndex(declist); if( m_Props != NULL ) { setIDSelection(wDec.getid( m_Props )); return true; } else { m_Props = setSelection(0); } } } return false; }
//===================>>> vedTextEditor::TextMouseDown <<<==================== void vedTextEditor::TextMouseDown(int row, int col, int button) { static int clicks = 0; int btn = (GetFileType() == gccError || GetFileType() == bccError) ? 1 : button; long oldLine = GetCurLine(); // remember current position int oldCol = getColPos(); vTextEditor::TextMouseDown(row, col, btn); // translate to left if (button == 1 && oldLine == GetCurLine() && oldCol == getColPos()) // double click... { ++clicks; if (clicks > 3) clicks = 1; setSelection(clicks); } else { clicks = 0; } }
void SonicPiScintilla::replaceLine(int lineNumber, QString newLine) { setSelection(lineNumber, 0, lineNumber + 1, 0); replaceSelectedText(newLine); }
void *MsgViewBase::processEvent(Event *e) { if (e->type() == EventMessageRead){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_HREF); if (n < 0) continue; s = s.mid(n + strlen(MSG_HREF)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); if (id != msg->id()) continue; getToken(s, ','); if (s != msg->client()) continue; int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, i, 0xFFFF); setBold(false); if ((paraFrom == -1) && (paraTo == -1)){ removeSelection(); scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventHistoryConfig){ unsigned id = (unsigned)(e->param()); if (id && (id != m_id)) return NULL; QString t; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_HREF); if (n < 0) continue; s = s.mid(n + strlen(MSG_HREF)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); getToken(s, ','); Message *msg = History::load(id, s.utf8(), m_id); if (msg == NULL) continue; t += messageText(msg); delete msg; } QPoint p = QPoint(0, height()); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setText(t); setBackground(0); if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ unsigned type = msg->type(); delete msg; for (;;){ CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL){ return NULL; } MessageDef *mdef = (MessageDef*)(def->param); if (mdef->base_type){ type = mdef->base_type; continue; } cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg){ Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; if (msg->getFlags() & MESSAGE_RECEIVED){ unsigned type = msg->type(); for (;;){ CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd == NULL) break; mdef = (MessageDef*)(msgCmd->param); if (mdef->base_type == 0) break; type = mdef->base_type; } } if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++){ cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL){ CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ Event eOpen(EventOpenMessage, msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg){ if (cmd->id >= CmdMsgSpecial){ MessageDef *mdef = NULL; unsigned type = msg->type(); for (;;){ CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd == NULL) break; mdef = (MessageDef*)(msgCmd->param); if (mdef->base_type == 0) break; type = mdef->base_type; } if (mdef && mdef->cmd){ unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = mdef->cmd; d->text; d++){ if (n-- == 0){ CommandDef cmd = *d; cmd.param = msg; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
void UIHexEditorWnd::keyPressSelect(QKeyEvent *event) { if (event->matches(QKeySequence::SelectAll)) { resetSelection(0); setSelection(2*endAddress + 1); } if (event->matches(QKeySequence::SelectNextChar)) { if (cursorY + (fontHeight*2) > viewport()->height() && (cursorAddr + 2) % (bytesPerLine * 2) == 0) verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd); s64 pos = (cursorAddr & ~1) + 2; setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousChar)) { if (cursorAddr <= (s64)verticalScrollBar()->value() * bytesPerLine * 2) verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepSub); s64 pos = (cursorAddr & ~1) - 2; setSelection(pos); setCursorPos(pos); } if (event->matches(QKeySequence::SelectEndOfLine)) { s64 pos = (cursorAddr & ~1) - (cursorAddr % (2 * bytesPerLine)) + (2 * bytesPerLine); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfLine)) { s64 pos = (cursorAddr & ~1) - (cursorAddr % (2 * bytesPerLine)); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousLine)) { if (cursorAddr <= (s64)verticalScrollBar()->value() * bytesPerLine * 2) verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepSub); s64 pos = (cursorAddr & ~1) - (2 * bytesPerLine); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextLine)) { if (cursorY + (fontHeight*2) > viewport()->height()) verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd); s64 pos = (cursorAddr & ~1) + (2 * bytesPerLine); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextPage)) { verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd); s64 pos = (cursorAddr & ~1) + (verticalScrollBar()->pageStep() * 2 * bytesPerLine); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousPage)) { verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub); int pos = (cursorAddr & ~1) - (verticalScrollBar()->pageStep() * 2 * bytesPerLine); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectEndOfDocument)) { int pos = endAddress * 2; setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfDocument)) { int pos = 0; setCursorPos(pos); setSelection(pos); } }
void LLInventoryPanel::modelChanged(U32 mask) { LLFastTimer t2(LLFastTimer::FTM_REFRESH); bool handled = false; if(mask & LLInventoryObserver::LABEL) { handled = true; // label change - empty out the display name for each object // in this change set. const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); std::set<LLUUID>::const_iterator id_it = changed_items.begin(); std::set<LLUUID>::const_iterator id_end = changed_items.end(); LLFolderViewItem* view = NULL; LLInvFVBridge* bridge = NULL; for (;id_it != id_end; ++id_it) { view = mFolders->getItemByID(*id_it); if(view) { // request refresh on this item (also flags for filtering) bridge = (LLInvFVBridge*)view->getListener(); if(bridge) { // Clear the display name first, so it gets properly re-built during refresh() bridge->clearDisplayName(); } view->refresh(); } } } if((mask & (LLInventoryObserver::STRUCTURE | LLInventoryObserver::ADD | LLInventoryObserver::REMOVE)) != 0) { handled = true; // Record which folders are open by uuid. LLInventoryModel* model = getModel(); if (model) { const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); std::set<LLUUID>::const_iterator id_it = changed_items.begin(); std::set<LLUUID>::const_iterator id_end = changed_items.end(); for (;id_it != id_end; ++id_it) { // sync view with model LLInventoryObject* model_item = model->getObject(*id_it); LLFolderViewItem* view_item = mFolders->getItemByID(*id_it); if (model_item) { if (!view_item) { // this object was just created, need to build a view for it if ((mask & LLInventoryObserver::ADD) != LLInventoryObserver::ADD) { llwarns << *id_it << " is in model but not in view, but ADD flag not set" << llendl; } buildNewViews(*id_it); // select any newly created object // that has the auto rename at top of folder // root set if(mFolders->getRoot()->needsAutoRename()) { setSelection(*id_it, FALSE); } } else { // this object was probably moved, check its parent if ((mask & LLInventoryObserver::STRUCTURE) != LLInventoryObserver::STRUCTURE) { llwarns << *id_it << " is in model and in view, but STRUCTURE flag not set" << llendl; } LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolders->getItemByID(model_item->getParentUUID()); if (view_item->getParentFolder() != new_parent) { view_item->getParentFolder()->extractItem(view_item); view_item->addToFolder(new_parent, mFolders); } } } else { if (view_item) { if ((mask & LLInventoryObserver::REMOVE) != LLInventoryObserver::REMOVE) { llwarns << *id_it << " is not in model but in view, but REMOVE flag not set" << llendl; } // item in view but not model, need to delete view view_item->destroyView(); } else { llwarns << *id_it << "Item does not exist in either view or model, but notification triggered" << llendl; } } } } } if (!handled) { // it's a small change that only requires a refresh. // *TODO: figure out a more efficient way to do the refresh // since it is expensive on large inventories mFolders->refresh(); } }
void EditInteraction::snapMouseReleaseEvent(QMouseEvent * ev , Feature* aLast) { Qt::KeyboardModifiers modifiers = ev->modifiers(); if (ev->button() != Qt::LeftButton) return; if (Dragging) { QList<Feature*> List; EndDrag = XY_TO_COORD(ev->pos()); CoordBox DragBox(StartDrag, EndDrag); for (VisibleFeatureIterator it(document()); !it.isEnd(); ++it) { if (it.get()->isReadonly()) continue; if (modifiersForGreedyAdd(modifiers)) { if (!DragBox.intersects(it.get()->boundingBox())) continue; if (DragBox.contains(it.get()->boundingBox())) List.push_back(it.get()); else { Coord A, B; if (Way* R = dynamic_cast<Way*>(it.get())) { for (int j=1; j<R->size(); ++j) { A = R->getNode(j-1)->position(); B = R->getNode(j)->position(); if (CoordBox::visibleLine(DragBox, A, B)) { List.push_back(R); break; } } } else if (Relation* r = dynamic_cast<Relation*>(it.get())) { for (int k=0; k<r->size(); ++k) { if (Way* R = dynamic_cast<Way*>(r->get(k))) { for (int j=1; j<R->size(); ++j) { A = R->getNode(j-1)->position(); B = R->getNode(j)->position(); if (CoordBox::visibleLine(DragBox, A, B)) { List.push_back(r); break; } } } } } } } else { if (DragBox.contains(it.get()->boundingBox())) List.push_back(it.get()); } } if (!List.isEmpty() || (!modifiersForAdd(modifiers) && !modifiersForToggle(modifiers))) PROPERTIES(setSelection(List)); PROPERTIES(checkMenuStatus()); Dragging = false; view()->update(); } else { if (!panning() && !modifiers) { PROPERTIES(setSelection(aLast)); PROPERTIES(checkMenuStatus()); view()->update(); } } }
void QHexEditPrivate::keyPressEvent(QKeyEvent *event) { int charX = (_cursorX - _xPosHex) / _charWidth; int posX = (charX / 3) * 2 + (charX % 3); int posBa = (_cursorY / _charHeight) * BYTES_PER_LINE + posX / 2; /*****************************************************************************/ /* Cursor movements */ /*****************************************************************************/ if (event->matches(QKeySequence::MoveToNextChar)) { setCursorPos(_cursorPosition + 1); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousChar)) { setCursorPos(_cursorPosition - 1); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToEndOfLine)) { setCursorPos(_cursorPosition | (2 * BYTES_PER_LINE -1)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToStartOfLine)) { setCursorPos(_cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE))); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousLine)) { setCursorPos(_cursorPosition - (2 * BYTES_PER_LINE)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToNextLine)) { setCursorPos(_cursorPosition + (2 * BYTES_PER_LINE)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToNextPage)) { setCursorPos(_cursorPosition + (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousPage)) { setCursorPos(_cursorPosition - (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToEndOfDocument)) { setCursorPos(_xData.size() * 2); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToStartOfDocument)) { setCursorPos(0); resetSelection(_cursorPosition); } /*****************************************************************************/ /* Select commands */ /*****************************************************************************/ if (event->matches(QKeySequence::SelectAll)) { resetSelection(0); setSelection(2*_xData.size() + 1); } if (event->matches(QKeySequence::SelectNextChar)) { int pos = _cursorPosition + 1; setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousChar)) { int pos = _cursorPosition - 1; setSelection(pos); setCursorPos(pos); } if (event->matches(QKeySequence::SelectEndOfLine)) { int pos = _cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE)) + (2 * BYTES_PER_LINE); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfLine)) { int pos = _cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE)); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousLine)) { int pos = _cursorPosition - (2 * BYTES_PER_LINE); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextLine)) { int pos = _cursorPosition + (2 * BYTES_PER_LINE); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextPage)) { int pos = _cursorPosition + (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousPage)) { int pos = _cursorPosition - (((_scrollArea->viewport()->height() / _charHeight) - 1) * 2 * BYTES_PER_LINE); setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectEndOfDocument)) { int pos = _xData.size() * 2; setCursorPos(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfDocument)) { int pos = 0; setCursorPos(pos); setSelection(pos); } /*****************************************************************************/ /* Edit Commands */ /*****************************************************************************/ if (!_readOnly) { /* Hex input */ int key = int(event->text()[0].toAscii()); if ((key>='0' && key<='9') || (key>='a' && key <= 'f')) { if (getSelectionBegin() != getSelectionEnd()) { posBa = getSelectionBegin(); remove(posBa, getSelectionEnd() - posBa); setCursorPos(2*posBa); resetSelection(2*posBa); } // If insert mode, then insert a byte if (_overwriteMode == false) if ((charX % 3) == 0) { insert(posBa, char(0)); } // Change content if (_xData.size() > 0) { QByteArray hexValue = _xData.data().mid(posBa, 1).toHex(); if ((charX % 3) == 0) hexValue[0] = key; else hexValue[1] = key; replace(posBa, QByteArray().fromHex(hexValue)[0]); setCursorPos(_cursorPosition + 1); resetSelection(_cursorPosition); } } /* Cut & Paste */ if (event->matches(QKeySequence::Cut)) { QString result = QString(); for (int idx = getSelectionBegin(); idx < getSelectionEnd(); idx++) { result += _xData.data().mid(idx, 1).toHex() + " "; if ((idx % 16) == 15) result.append("\n"); } remove(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()); QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(result); setCursorPos(getSelectionBegin()); resetSelection(getSelectionBegin()); } if (event->matches(QKeySequence::Paste)) { QClipboard *clipboard = QApplication::clipboard(); QByteArray ba = QByteArray().fromHex(clipboard->text().toLatin1()); insert(_cursorPosition / 2, ba); setCursorPos(_cursorPosition + 2 * ba.length()); resetSelection(getSelectionBegin()); } /* Delete char */ if (event->matches(QKeySequence::Delete)) { if (getSelectionBegin() != getSelectionEnd()) { posBa = getSelectionBegin(); remove(posBa, getSelectionEnd() - posBa); setCursorPos(2*posBa); resetSelection(2*posBa); } else { if (_overwriteMode) replace(posBa, char(0)); else remove(posBa, 1); } } /* Backspace */ if ((event->key() == Qt::Key_Backspace) && (event->modifiers() == Qt::NoModifier)) { if (getSelectionBegin() != getSelectionEnd()) { posBa = getSelectionBegin(); remove(posBa, getSelectionEnd() - posBa); setCursorPos(2*posBa); resetSelection(2*posBa); } else { if (posBa > 0) { if (_overwriteMode) replace(posBa - 1, char(0)); else remove(posBa - 1, 1); setCursorPos(_cursorPosition - 2); } } } /* undo */ if (event->matches(QKeySequence::Undo)) { undo(); } /* redo */ if (event->matches(QKeySequence::Redo)) { redo(); } } if (event->matches(QKeySequence::Copy)) { QString result = QString(); for (int idx = getSelectionBegin(); idx < getSelectionEnd(); idx++) { result += _xData.data().mid(idx, 1).toHex() + " "; if ((idx % 16) == 15) result.append('\n'); } QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(result.toUpper()); } // Switch between insert/overwrite mode if ((event->key() == Qt::Key_Insert) && (event->modifiers() == Qt::NoModifier)) { _overwriteMode = !_overwriteMode; setCursorPos(_cursorPosition); overwriteModeChanged(_overwriteMode); } ensureVisible(); update(); }
void MsgViewBase::update() { if (m_updated.empty()) return; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = m_updated.begin(); it != m_updated.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != m_updated.end()) break; } m_updated.clear(); if (i >= (unsigned)paragraphs()) return; int x = contentsX(); int y = contentsY(); viewport()->setUpdatesEnabled(false); unsigned start = i; list<Msg_Id> msgs; for (; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = msgs.begin(); it != msgs.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != msgs.end()) continue; Msg_Id m_id; m_id.id = id; m_id.client = client; msgs.push_back(m_id); } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setReadOnly(false); setSelection(start, 0, paragraphs() - 1, 0xFFFF, 0); removeSelectedText(); setReadOnly(true); QString text; for (list<Msg_Id>::iterator it = msgs.begin(); it != msgs.end(); ++it){ Message *msg = History::load((*it).id, (*it).client.c_str(), m_id); if (msg == NULL) continue; bool bUnread = false; for (list<msg_id>::iterator itu = CorePlugin::m_plugin->unread.begin(); itu != CorePlugin::m_plugin->unread.end(); ++itu){ msg_id &m = (*itu); if ((m.contact == msg->contact()) && (m.id == msg->id()) && (m.client == msg->client())){ bUnread = true; break; } } text += messageText(msg, bUnread); } viewport()->setUpdatesEnabled(true); append(text); if (!CorePlugin::m_plugin->getOwnColors()) setBackground(i); if ((paraFrom != paraTo) || (indexFrom != indexTo)) setSelection(paraFrom, indexFrom, paraTo, indexTo, 0); TextShow::sync(); setContentsPos(x, y); viewport()->repaint(); }
inline void tst_setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) { setSelection(rect, command); }
void MGuiEditText::onEvent(MWinEvent * windowEvent) { MGuiWindow * parent = getParentWindow(); MMouse * mouse = MMouse::getInstance(); switch(windowEvent->type) { case MWIN_EVENT_MOUSE_WHEEL_MOVE: case MWIN_EVENT_MOUSE_MOVE: if(parent->isHighLight() && isMouseInside()) { setHighLight(true); if(m_pointerEvent) // send mouse move gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_MOVE; guiEvent.data[0] = windowEvent->data[0]; guiEvent.data[1] = windowEvent->data[1]; m_pointerEvent(this, &guiEvent); } // break events if(parent->breakEvents()) return; } else { setHighLight(false); } if(isPressed() && mouse->isLeftButtonPushed()) { m_endSelectionId = getFont()->findPointedCharacter( getText(), getPosition(), getTextSize(), getMouseLocalPosition() ); autoScrolling(); } break; case MWIN_EVENT_MOUSE_BUTTON_DOWN: if(isHighLight()) { if(windowEvent->data[0] == MMOUSE_BUTTON_LEFT) { // unpress all edit text unsigned int i; unsigned int size = parent->getEditTextsNumber(); for(i=0; i<size; i++) parent->getEditText(i)->setPressed(false); setPressed(true); setCharId( getFont()->findPointedCharacter( getText(), getPosition(), getTextSize(), getMouseLocalPosition() ) ); // start select setSelection(getCharId(), getCharId()); } if(m_pointerEvent) // send mouse button down gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_BUTTON_DOWN; guiEvent.data[0] = windowEvent->data[0]; m_pointerEvent(this, &guiEvent); } } else { if(isPressed() && windowEvent->data[0] == MMOUSE_BUTTON_LEFT) { setPressed(false); sendVariable(); } } break; case MWIN_EVENT_CHAR: case MWIN_EVENT_KEY_DOWN: if(isPressed()) { editText(windowEvent); autoScrolling(); } break; } }
void MGuiEditText::editText(MWinEvent * windowEvent) { unsigned int sStart; unsigned int sEnd; bool selection = getSelectionIds(&sStart, &sEnd); if(selection) setCharId(sStart); // events if(windowEvent->type == MWIN_EVENT_KEY_DOWN) { switch(windowEvent->data[0]) { case MKEY_UP: if(! isSingleLine()) upCharId(-1); setSelection(0, 0); return; case MKEY_DOWN: if(! isSingleLine()) upCharId(1); setSelection(0, 0); return; case MKEY_RIGHT: addCharId(); setSelection(0, 0); return; case MKEY_LEFT: subCharId(); setSelection(0, 0); return; case MKEY_SPACE: if(selection) { m_text.erase(m_text.begin() + sStart, m_text.begin() + sEnd); setSelection(0, 0); } if(! canAddCharacter()) return; m_text.insert(getCharId(), " ", 1); addCharId(); autoScaleFromText(); onChange(); return; case MKEY_TAB: if(! isSingleLine()) { if(selection) { m_text.erase(m_text.begin() + sStart, m_text.begin() + sEnd); setSelection(0, 0); } if(! canAddCharacter()) return; m_text.insert(getCharId(), " ", 1); addCharId(); autoScaleFromText(); onChange(); } return; case MKEY_BACKSPACE: if(selection) { m_text.erase(m_text.begin() + sStart, m_text.begin() + sEnd); setSelection(0, 0); autoScaleFromText(); onChange(); } else if(getCharId() > 0) { m_text.erase(m_text.begin() + getCharId() - 1); subCharId(); autoScaleFromText(); onChange(); } return; case MKEY_DELETE: if(getCharId() < m_text.size()) { if(selection) { m_text.erase(m_text.begin() + sStart, m_text.begin() + sEnd); setSelection(0, 0); } else { m_text.erase(m_text.begin() + getCharId()); } autoScaleFromText(); onChange(); } return; case MKEY_RETURN: if(! isSingleLine()) { if(selection) { m_text.erase(m_text.begin() + sStart, m_text.begin() + sEnd); setSelection(0, 0); } if(! canAddCharacter()) return; m_text.insert(getCharId(), "\n", 1); addCharId(); autoScaleFromText(); onChange(); } else { setHighLight(false); autoScaleFromText(); setSelection(0, 0); sendVariable(); } return; } } if(windowEvent->type == MWIN_EVENT_CHAR) { char character = windowEvent->data[0]; if(character >= 0 && character < 33) return; // add character if(character) { if(selection) { m_text.erase(m_text.begin() + sStart, m_text.begin() + sEnd); setSelection(0, 0); } if(! canAddCharacter()) return; m_text.insert(getCharId(), &character, 1); addCharId(); autoScaleFromText(); onChange(); } } }
void MGuiEditText::setPressed(bool pressed) { MGui2d::setPressed(pressed); if(! pressed) setSelection(0, 0); }
CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget) { ui->setupUi(this); setDefaultDisposition(); mDisas = new CPUDisassembly(0); mSideBar = new CPUSideBar(mDisas); connect(mDisas, SIGNAL(tableOffsetChanged(int_t)), mSideBar, SLOT(changeTopmostAddress(int_t))); connect(mDisas, SIGNAL(viewableRows(int)), mSideBar, SLOT(setViewableRows(int))); connect(mDisas, SIGNAL(repainted()), mSideBar, SLOT(repaint())); connect(mDisas, SIGNAL(selectionChanged(int_t)), mSideBar, SLOT(setSelection(int_t))); connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE))); connect(Bridge::getBridge(), SIGNAL(updateSideBar()), mSideBar, SLOT(repaint())); QSplitter* splitter = new QSplitter(this); splitter->addWidget(mSideBar); splitter->addWidget(mDisas); splitter->setChildrenCollapsible(false); splitter->setHandleWidth(1); ui->mTopLeftUpperFrameLayout->addWidget(splitter); mInfo = new CPUInfoBox(); ui->mTopLeftLowerFrameLayout->addWidget(mInfo); int height = mInfo->getHeight(); ui->mTopLeftLowerFrame->setMinimumHeight(height + 2); ui->mTopLeftLowerFrame->setMaximumHeight(height + 2); connect(mDisas, SIGNAL(selectionChanged(int_t)), mInfo, SLOT(disasmSelectionChanged(int_t))); mGeneralRegs = new RegistersView(0); mGeneralRegs->setFixedWidth(1000); mGeneralRegs->setFixedHeight(1400); mGeneralRegs->ShowFPU(true); QScrollArea* scrollArea = new QScrollArea; scrollArea->setWidget(mGeneralRegs); scrollArea->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal{border:1px solid grey;background:#f1f1f1;height:10px}QScrollBar::handle:horizontal{background:#aaa;min-width:20px;margin:1px}QScrollBar::add-line:horizontal,QScrollBar::sub-line:horizontal{width:0;height:0}"); scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{border:1px solid grey;background:#f1f1f1;width:10px}QScrollBar::handle:vertical{background:#aaa;min-height:20px;margin:1px}QScrollBar::add-line:vertical,QScrollBar::sub-line:vertical{width:0;height:0}"); QPushButton* button_changeview = new QPushButton(""); mGeneralRegs->SetChangeButton(button_changeview); button_changeview->setStyleSheet("Text-align:left;padding: 4px;padding-left: 10px;"); QFont font = QFont("Lucida Console"); font.setStyleHint(QFont::Monospace); font.setPointSize(8); button_changeview->setFont(font); connect(button_changeview, SIGNAL(clicked()), mGeneralRegs, SLOT(onChangeFPUViewAction())); ui->mTopRightFrameLayout->addWidget(button_changeview); ui->mTopRightFrameLayout->addWidget(scrollArea); mDump = new CPUDump(mDisas, 0); //dump widget ui->mBotLeftFrameLayout->addWidget(mDump); mStack = new CPUStack(0); //stack widget ui->mBotRightFrameLayout->addWidget(mStack); }
void ZealSearchEdit::selectQuery() { setSelection(queryStart(), text().size()); }
void McaEditorReferenceArea::sl_selectionChanged(const MaEditorSelection ¤t, const MaEditorSelection &) { U2Region selection(current.x(), current.width()); setSelection(selection); }
void MsgViewBase::update() { if (m_updated.empty()) return; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = m_updated.begin(); it != m_updated.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != m_updated.end()) break; } m_updated.clear(); if (i >= (unsigned)paragraphs()) return; QPoint p = QPoint(0, 0); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); p = QPoint(0, viewport()->height()); p = viewport()->mapToGlobal(p); p = mapFromGlobal(p); if (p.y() + 2 == height()) pos = -1; unsigned start = i; list<Msg_Id> msgs; for (; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = msgs.begin(); it != msgs.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != msgs.end()) continue; Msg_Id m_id; m_id.id = id; m_id.client = client; msgs.push_back(m_id); } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setReadOnly(false); setSelection(start, 0, paragraphs() - 1, 0xFFFF); removeSelectedText(); setReadOnly(true); QString text; for (list<Msg_Id>::iterator it = msgs.begin(); it != msgs.end(); ++it){ Message *msg = History::load((*it).id, (*it).client.c_str(), m_id); if (msg == NULL) continue; bool bUnread = false; for (list<msg_id>::iterator itu = CorePlugin::m_plugin->unread.begin(); itu != CorePlugin::m_plugin->unread.end(); ++itu){ msg_id &m = (*itu); if ((m.contact == msg->contact()) && (m.id == msg->id()) && (m.client == msg->client())){ bUnread = true; break; } } text += messageText(msg, bUnread); } append(text); if (!CorePlugin::m_plugin->getOwnColors()) setBackground(0); if ((paraFrom != paraTo) || (indexFrom != indexTo)) setSelection(paraFrom, indexFrom, paraTo, indexTo); if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } }
void QMultiLineEdit::insertAt( const QString &s, int line, int col, bool mark ) { QTextEdit::insertAt( s, line, col ); if ( mark ) setSelection( line, col, line, col + s.length() ); }
void *MsgViewBase::processEvent(Event *e) { if ((e->type() == EventRewriteMessage) || (e->type() == EventMessageRead)){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) == msg->id()) && (client == msg->client())) break; } if (i >= (unsigned)paragraphs()) return NULL; Msg_Id id; id.id = msg->id(); id.client = msg->client(); m_updated.push_back(id); QTimer::singleShot(0, this, SLOT(update())); return NULL; } if (e->type() == EventCutHistory){ CutHistory *ch = (CutHistory*)(e->param()); if (ch->contact != m_id) return NULL; bool bDelete = false; vector<unsigned> start_pos; vector<unsigned> end_pos; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); if ((client == ch->client) && (id >= ch->from) && (id < ch->from + ch->size)){ if (!bDelete){ bDelete = true; start_pos.push_back(i); } }else{ if (bDelete){ bDelete = false; end_pos.push_back(i); } } } if (bDelete) end_pos.push_back(paragraphs()); if (start_pos.size()){ int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); QPoint p = QPoint(0, 0); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setReadOnly(false); for (unsigned i = 0; i < start_pos.size(); i++){ setSelection(start_pos[i], 0, end_pos[i], 0); removeSelectedText(); if ((unsigned)pos >= start_pos[i]) pos = end_pos[i] - start_pos[i]; } if ((paraFrom == -1) && (paraTo == -1)){ if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } setReadOnly(true); repaint(); } m_cut.push_back(*ch); return NULL; } if (e->type() == EventMessageDeleted){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client())) continue; string ss; ss = text(i).local8Bit(); log(L_DEBUG, "?: %s", ss.c_str()); unsigned j; for (j = i + 1; j < (unsigned)paragraphs(); j++){ QString s = text(j); ss = text(j).local8Bit(); log(L_DEBUG, ">: %s", ss.c_str()); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client())) break; } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); unsigned pos = 0xFFFF; if (j == (unsigned)paragraphs()){ j++; pos = 0; } setSelection(i, 0, j - 1, pos); setReadOnly(false); removeSelectedText(); setReadOnly(true); if ((paraFrom == -1) && (paraTo == -1)){ scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventHistoryConfig){ unsigned id = (unsigned)(e->param()); if (id && (id != m_id)) return NULL; reload(); } if (e->type() == EventHistoryColors) setColors(); if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ unsigned type = msg->baseType(); delete msg; CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL) return NULL; cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg){ Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; unsigned type = msg->baseType(); const CommandDef *cmdsSpecial = NULL; CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); if (mdef){ if (msg->getFlags() & MESSAGE_RECEIVED){ cmdsSpecial = mdef->cmdReceived; }else{ cmdsSpecial = mdef->cmdSent; } if (cmdsSpecial) for (const CommandDef *d = cmdsSpecial; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (cmdsSpecial){ for (const CommandDef *d = cmdsSpecial; d->text; d++){ cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL){ CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCutHistory: msg = currentMessage(); if (msg){ History::cut(msg, 0, 0); delete msg; return e->param(); } return NULL; case CmdDeleteMessage: msg = currentMessage(); if (msg){ History::del(msg); delete msg; return e->param(); } return NULL; case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ msg->setFlags(msg->getFlags() | MESSAGE_OPEN); Event eOpen(EventOpenMessage, &msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg){ if (cmd->id >= CmdMsgSpecial){ MessageDef *mdef = NULL; unsigned type = msg->baseType(); CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); const CommandDef *cmds = NULL; if (mdef){ if (msg->getFlags() & MESSAGE_RECEIVED){ cmds = mdef->cmdReceived; }else{ cmds = mdef->cmdSent; } } if (cmds){ unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = cmds; d->text; d++){ if (n-- == 0){ CommandDef cmd = *d; cmd.param = msg; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
void QcWaveform::mouseDoubleClickEvent ( QMouseEvent * ) { setSelection( _curSel, _rangeBeg, _rangeEnd ); Q_EMIT( action() ); }
void AMScanThumbnailGridView::onSelectionRectangleEnded(const QRect& selectionRectangle, QItemSelectionModel::SelectionFlags flags) { setSelection(selectionRectangle, flags); rubberBand_->setVisible(false); }
void VariableDlg::initIndex() { SetTitle(wxGetApp().getMsg( "variable" )); m_VarList->DeleteAllItems(); iONode model = wxGetApp().getModel(); if( model != NULL ) { iONode varlist = wPlan.getvrlist( model ); if( varlist != NULL ) { iOList list = ListOp.inst(); int cnt = NodeOp.getChildCnt( varlist ); for( int i = 0; i < cnt; i++ ) { iONode var = NodeOp.getChild( varlist, i ); const char* id = wVariable.getid( var ); if( id != NULL ) { ListOp.add(list, (obj)var); } } if( m_SortCol == 1 ) ListOp.sort(list, &__sortGroup); else if( m_SortCol == 2 ) ListOp.sort(list, &__sortValue); else if( m_SortCol == 3 ) ListOp.sort(list, &__sortText); else ListOp.sort(list, &__sortID); cnt = ListOp.size( list ); for( int i = 0; i < cnt; i++ ) { iONode var = (iONode)ListOp.get( list, i ); m_VarList->InsertItem( i, wxString( wVariable.getid( var ), wxConvUTF8) ); m_VarList->SetItem( i, 1, wxString( wVariable.getgroup( var ), wxConvUTF8) ); m_VarList->SetItem( i, 2, wxString::Format(wxT("%d"), wVariable.getvalue( var )) ); m_VarList->SetItem( i, 3, wxString( wVariable.gettext( var ), wxConvUTF8) ); m_VarList->SetItemPtrData(i, (wxUIntPtr)var); } // resize for( int n = 0; n < 4; n++ ) { m_VarList->SetColumnWidth(n, wxLIST_AUTOSIZE_USEHEADER); int autoheadersize = m_VarList->GetColumnWidth(n); m_VarList->SetColumnWidth(n, wxLIST_AUTOSIZE); int autosize = m_VarList->GetColumnWidth(n); if(autoheadersize > autosize ) m_VarList->SetColumnWidth(n, wxLIST_AUTOSIZE_USEHEADER); else if( autosize > 120 ) m_VarList->SetColumnWidth(n, autoheadersize > 120 ? autoheadersize:120); } /* clean up the temp. list */ ListOp.base.del(list); if( m_Props != NULL ) { char* title = StrOp.fmt( "%s %s", (const char*)wxGetApp().getMsg("variable").mb_str(wxConvUTF8), wVariable.getid( m_Props ) ); SetTitle( wxString(title,wxConvUTF8) ); StrOp.free( title ); setSelection(wVariable.getid( m_Props )); } else if(m_VarList->GetItemCount() > 0 ) { m_VarList->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); m_Props = (iONode)m_VarList->GetItemData(0); } } } }
// common function for wheel up/down and key up/down // delta is in wheel units: a delta of 120 means to increment by 1 void SpinBox::increment(int delta, int shift) // shift = 1 means to increment * 10, shift = -1 means / 10 { bool ok; QString str = text(); //qDebug() << "increment from " << str; const double oldVal = str.toDouble(&ok); if (!ok) { // Not a valid double value, don't do anything return; } bool useCursorPositionIncr = appPTR->getCurrentSettings()->useCursorPositionIncrements(); // First, treat the standard case: use the Knob increment if (!useCursorPositionIncr) { double val = oldVal; _imp->currentDelta += delta; double inc = std::pow(10., shift) * _imp->currentDelta * _imp->increment / 120.; double maxiD = 0.; double miniD = 0.; switch (_imp->type) { case eSpinBoxTypeDouble: { maxiD = _imp->maxi.toDouble(); miniD = _imp->mini.toDouble(); val += inc; _imp->currentDelta = 0; break; } case eSpinBoxTypeInt: { maxiD = _imp->maxi.toInt(); miniD = _imp->mini.toInt(); val += (int)inc; // round towards zero // Update the current delta, which contains the accumulated error _imp->currentDelta -= ( (int)inc ) * 120. / _imp->increment; assert(std::abs(_imp->currentDelta) < 120); break; } } val = std::max( miniD, std::min(val, maxiD) ); if (val != oldVal) { setValue(val); Q_EMIT valueChanged(val); } return; } // From here on, we treat the positin-based increment. if ( (str.indexOf( QLatin1Char('e') ) != -1) || (str.indexOf( QLatin1Char('E') ) != -1) ) { // Sorry, we don't handle numbers with an exponent, although these are valid doubles return; } _imp->currentDelta += delta; int inc_int = _imp->currentDelta / 120; // the number of integert increments // Update the current delta, which contains the accumulated error _imp->currentDelta -= inc_int * 120; if (inc_int == 0) { // Nothing is changed, just return return; } // Within the value, we modify: // - if there is no selection, the first digit right after the cursor (or if it is an int and the cursor is at the end, the last digit) // - if there is a selection, the first digit after the start of the selection int len = str.size(); // used for chopping spurious characters if (len <= 0) { return; // should never happen } // The position in str of the digit to modify in str() (may be equal to str.size()) int pos = ( hasSelectedText() ? selectionStart() : cursorPosition() ); //if (pos == len) { // select the last character? // pos = len - 1; //} // The position of the decimal dot int dot = str.indexOf( QLatin1Char('.') ); if (dot == -1) { dot = str.size(); } // Now, chop trailing and leading whitespace (and update len, pos and dot) // Leading whitespace while ( len > 0 && str[0].isSpace() ) { str.remove(0, 1); --len; if (pos > 0) { --pos; } --dot; assert(dot >= 0); assert(len > 0); } // Trailing whitespace while ( len > 0 && str[len - 1].isSpace() ) { str.remove(len - 1, 1); --len; if (pos > len) { --pos; } if (dot > len) { --dot; } assert(len > 0); } assert( oldVal == str.toDouble() ); // check that the value hasn't changed due to whitespace manipulation // On int types, there should not be any dot if ( (_imp->type == eSpinBoxTypeInt) && (len > dot) ) { // Remove anything after the dot, including the dot str.resize(dot); len = dot; } // Adjust pos so that it doesn't point to a dot or a sign assert( 0 <= pos && pos <= str.size() ); while ( pos < str.size() && ( pos == dot || str[pos] == QLatin1Char('+') || str[pos] == QLatin1Char('-') ) ) { ++pos; } assert(len >= pos); // Set the shift (may have to be done twice due to the dot) pos -= shift; if (pos == dot) { pos -= shift; } // Now, add leading and trailing zeroes so that pos is a valid digit position // (beware of the sign!) // Trailing zeroes: // (No trailing zeroes on int, of course) assert( len == str.size() ); if ( (_imp->type == eSpinBoxTypeInt) && (pos >= len) ) { // If this is an int and we are beyond the last position, change the last digit pos = len - 1; // also reset the shift if it was negative if (shift < 0) { shift = 0; } } while ( pos >= str.size() ) { assert(_imp->type == eSpinBoxTypeDouble); // Add trailing zero, maybe preceded by a dot if (pos == dot) { str.append( QLatin1Char('.') ); ++pos; // increment pos, because we just added a '.', and next iteration will add a '0' ++len; } else { assert(pos > dot); str.append( QLatin1Char('0') ); ++len; } assert( pos >= (str.size() - 1) ); } // Leading zeroes: bool hasSign = ( str[0] == QLatin1Char('-') || str[0] == QLatin1Char('+') ); while ( pos < 0 || ( pos == 0 && ( str[0] == QLatin1Char('-') || str[0] == QLatin1Char('+') ) ) ) { // Add leading zero str.insert( hasSign ? 1 : 0, QLatin1Char('0') ); ++pos; ++dot; ++len; } assert( len == str.size() ); assert( 0 <= pos && pos < str.size() && str[pos].isDigit() ); QString noDotStr = str; int noDotLen = len; if (dot != len) { // Remove the dot noDotStr.remove(dot, 1); --noDotLen; } assert( (_imp->type == eSpinBoxTypeInt && noDotLen == dot) || noDotLen >= dot ); double val = oldVal; // The value, as a double if ( (noDotLen > 16) && (16 >= dot) ) { // don't handle more than 16 significant digits (this causes over/underflows in the following) assert( noDotLen == noDotStr.size() ); noDotLen = 16; noDotStr.resize(noDotLen); } qlonglong llval = noDotStr.toLongLong(&ok); // The value, as a long long int if (!ok) { // Not a valid long long value, don't do anything return; } int llpowerOfTen = dot - noDotLen; // llval must be post-multiplied by this power of ten assert(llpowerOfTen <= 0); // check that val and llval*10^llPowerOfTen are close enough (relative error should be less than 1e-8) assert(std::abs(val * std::pow(10., -llpowerOfTen) - llval) / std::max( qlonglong(1), std::abs(llval) ) < 1e-8); // If pos is at the end if ( pos == str.size() ) { switch (_imp->type) { case eSpinBoxTypeDouble: if ( dot == str.size() ) { str += QString::fromUtf8(".0"); len += 2; ++pos; } else { str += QLatin1Char('0'); ++len; } break; case eSpinBoxTypeInt: // take the character before --pos; break; } } // Compute the full value of the increment assert( len == str.size() ); assert(pos != dot); assert( 0 <= pos && pos < len && str[pos].isDigit() ); int powerOfTen = dot - pos - (pos < dot); // the power of ten assert( (_imp->type == eSpinBoxTypeDouble) || ( powerOfTen >= 0 && dot == str.size() ) ); if (powerOfTen - llpowerOfTen > 16) { // too many digits to handle, don't do anything // (may overflow when adjusting llval) return; } double inc = inc_int * std::pow(10., (double)powerOfTen); // Check that we are within the authorized range double maxiD, miniD; switch (_imp->type) { case eSpinBoxTypeInt: maxiD = _imp->maxi.toInt(); miniD = _imp->mini.toInt(); break; case eSpinBoxTypeDouble: default: maxiD = _imp->maxi.toDouble(); miniD = _imp->mini.toDouble(); break; } val += inc; if ( (val < miniD) || (maxiD < val) ) { // out of the authorized range, don't do anything return; } // Adjust llval so that the increment becomes an int, and avoid rounding errors if (powerOfTen >= llpowerOfTen) { llval += inc_int * std::pow(10., powerOfTen - llpowerOfTen); } else { llval *= std::pow(10., llpowerOfTen - powerOfTen); llpowerOfTen -= llpowerOfTen - powerOfTen; llval += inc_int; } // check that val and llval*10^llPowerOfTen are still close enough (relative error should be less than 1e-8) assert(std::abs(val * std::pow(10., -llpowerOfTen) - llval) / std::max( qlonglong(1), std::abs(llval) ) < 1e-8); QString newStr; newStr.setNum(llval); bool newStrHasSign = newStr[0] == QLatin1Char('+') || newStr[0] == QLatin1Char('-'); // the position of the decimal dot int newDot = newStr.size() + llpowerOfTen; // add leading zeroes if newDot is not a valid position (beware of sign!) while ( newDot <= int(newStrHasSign) ) { newStr.insert( int(newStrHasSign), QLatin1Char('0') ); ++newDot; } assert( 0 <= newDot && newDot <= newStr.size() ); assert( newDot == newStr.size() || newStr[newDot].isDigit() ); if ( newDot != newStr.size() ) { assert(_imp->type == eSpinBoxTypeDouble); newStr.insert( newDot, QLatin1Char('.') ); } // Check that the backed string is close to the wanted value (relative error should be less than 1e-8) assert( (newStr.toDouble() - val) / std::max( 1e-8, std::abs(val) ) < 1e-8 ); // The new cursor position int newPos = newDot + (pos - dot); // Remove the shift (may have to be done twice due to the dot) newPos += shift; if (newPos == newDot) { // adjust newPos newPos += shift; } assert( 0 <= newDot && newDot <= newStr.size() ); // Now, add leading and trailing zeroes so that newPos is a valid digit position // (beware of the sign!) // Trailing zeroes: while ( newPos >= newStr.size() ) { assert(_imp->type == eSpinBoxTypeDouble); // Add trailing zero, maybe preceded by a dot if (newPos == newDot) { newStr.append( QLatin1Char('.') ); } else { assert(newPos > newDot); newStr.append( QLatin1Char('0') ); } assert( newPos >= (newStr.size() - 1) ); } // Leading zeroes: bool newHasSign = ( newStr[0] == QLatin1Char('-') || newStr[0] == QLatin1Char('+') ); while ( newPos < 0 || ( newPos == 0 && ( newStr[0] == QLatin1Char('-') || newStr[0] == QLatin1Char('+') ) ) ) { // add leading zero newStr.insert( newHasSign ? 1 : 0, QLatin1Char('0') ); ++newPos; ++newDot; } assert( 0 <= newPos && newPos < newStr.size() && newStr[newPos].isDigit() ); // Set the text and cursor position //qDebug() << "increment setting text to " << newStr; setText(newStr, newPos); // Set the selection assert( newPos + 1 <= newStr.size() ); setSelection(newPos + 1, -1); Q_EMIT valueChanged( value() ); } // increment
void LLInventoryPanel::modelChanged(U32 mask) { static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh"); LLFastTimer t2(FTM_REFRESH); if (!mViewsInitialized) return; const LLInventoryModel* model = getModel(); if (!model) return; const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs(); if (changed_items.empty()) return; for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); items_iter != changed_items.end(); ++items_iter) { const LLUUID& item_id = (*items_iter); const LLInventoryObject* model_item = model->getObject(item_id); LLFolderViewItem* view_item = mFolderRoot.get()->getItemByID(item_id); // LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item // to folder is the fast way to get a folder without searching through folders tree. LLFolderViewFolder* view_folder = dynamic_cast<LLFolderViewFolder*>(view_item); ////////////////////////////// // LABEL Operation // Empty out the display name for relabel. if (mask & LLInventoryObserver::LABEL) { if (view_item) { // Request refresh on this item (also flags for filtering) LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getListener(); if(bridge) { // Clear the display name first, so it gets properly re-built during refresh() bridge->clearDisplayName(); view_item->refresh(); } // Singu note: Needed to propagate name change to wearables. view_item->nameOrDescriptionChanged(); } } ////////////////////////////// // DESCRIPTION Operation (singu only) // Alert listener. if ((mask & LLInventoryObserver::DESCRIPTION)) { if (view_item) { view_item->nameOrDescriptionChanged(); } } ////////////////////////////// // REBUILD Operation // Destroy and regenerate the UI. if (mask & LLInventoryObserver::REBUILD) { if (model_item && view_item) { view_item->destroyView(); } view_item = buildNewViews(item_id); view_folder = dynamic_cast<LLFolderViewFolder *>(view_item); } ////////////////////////////// // INTERNAL Operation // This could be anything. For now, just refresh the item. if (mask & LLInventoryObserver::INTERNAL) { if (view_item) { view_item->refresh(); } } ////////////////////////////// // SORT Operation // Sort the folder. if (mask & LLInventoryObserver::SORT) { if (view_folder) { view_folder->requestSort(); } } // We don't typically care which of these masks the item is actually flagged with, since the masks // may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into // Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks // panel). What's relevant is that the item and UI are probably out of sync and thus need to be // resynchronized. if (mask & (LLInventoryObserver::STRUCTURE | LLInventoryObserver::ADD | LLInventoryObserver::REMOVE)) { ////////////////////////////// // ADD Operation // Item exists in memory but a UI element hasn't been created for it. if (model_item && !view_item) { // Add the UI element for this item. buildNewViews(item_id); // Select any newly created object that has the auto rename at top of folder root set. if(mFolderRoot.get()->getRoot()->needsAutoRename()) { setSelection(item_id, FALSE); } } ////////////////////////////// // STRUCTURE Operation // This item already exists in both memory and UI. It was probably reparented. else if (model_item && view_item) { // Don't process the item if it is the root if (view_item->getRoot() != view_item) { LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot.get()->getItemByID(model_item->getParentUUID()); // Item has been moved. if (view_item->getParentFolder() != new_parent) { if (new_parent != NULL) { // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. view_item->getParentFolder()->extractItem(view_item); view_item->addToFolder(new_parent, mFolderRoot.get()); if (mInventory) { const LLUUID trash_id = mInventory->findCategoryUUIDForType(LLFolderType::FT_TRASH); if (trash_id != model_item->getParentUUID() && (mask & LLInventoryObserver::INTERNAL) && new_parent->isOpen()) { setSelection(item_id, FALSE); } } } else { // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that // doesn't include trash). Just remove the item's UI. view_item->destroyView(); } } } } ////////////////////////////// // REMOVE Operation // This item has been removed from memory, but its associated UI element still exists. else if (!model_item && view_item) { // Remove the item's UI. view_item->destroyView(); } } } }
void PropertiesDock::executePendingSelectionChange() { if (PendingSelectionChange < FullSelection.size()) setSelection(FullSelection[PendingSelectionChange]); }
void W32ComboBox::setSelection(const std::string &value) { std::vector<std::string>::const_iterator it = std::find(myList.begin(), myList.end(), value); if (it != myList.end()) { setSelection(it - myList.begin()); } }
void HudSchedulerMenu::update(float elapsed) { //If its time for recess if(globals.manRecessEnabled) { if(globals.manRecessCount == globals.manRecessLevelLimit) { //Maybe do this when I deallocate! //globals.manRecessCount = 0; //Mandatory Recess Time! //std::cout<<"Show GUI for Mandatory Recess Time!"<<std::endl; //Show schedulerManRecessMessageBackground->show(); schedulerManRecessDisableBackground->show(); schedulerManRecessMessageText->show(); schedulerManRecessPlayButtonBackground->show(); } else{ //Hide schedulerManRecessMessageBackground->hide(); schedulerManRecessDisableBackground->hide(); schedulerManRecessMessageText->hide(); schedulerManRecessPlayButtonBackground->hide(); } } else { //hide schedulerManRecessMessageBackground->hide(); schedulerManRecessDisableBackground->hide(); schedulerManRecessMessageText->hide(); schedulerManRecessPlayButtonBackground->hide(); } //End Man Recess clearSelection(); float averageMemoryScore = (player->scheduler->nBackLevelA + player->scheduler->nBackLevelB + player->scheduler->nBackLevelC + player->scheduler->nBackLevelD) / 4; float gameScore = player->scheduler->scoreCurr; if (player->levelRequest) setSelection(); schedulerMenuAverageMemoryText->setCaption(Util::toStringFloat(averageMemoryScore)); schedulerMenuScoreCurrText->setCaption(Util::toStringInt(gameScore)); if (player->rerollCounter > 0) rerollButtonBackground->setMaterialName("General/RerollButton"); else rerollButtonBackground->setMaterialName("General/RerollButtonDisabled"); sessionDisplay->setCaption("Session\n" + Util::toStringInt(player->getSessionID())); timeRemainingTotal = globals.sessionTime - player->getTotalElapsed(); if(globals.OverallTimerEnabled) { timeRemainingTotal = globals.sessionTime - player->totalElapsedGeneral; } if(timeRemainingTotal < 0) { timeRemainingTotal = 0; } timeRemainingMins = int(timeRemainingTotal + 0.5); timeRemainingSecs = timeRemainingMins % 60; timeRemainingMins = timeRemainingMins/60; timeRemainingString = "Time Remaining: "+ Util::toStringInt(timeRemainingMins) + ":"; if(timeRemainingSecs < 10) // 1 digit { timeRemainingString += "0"; } timeRemainingString += Util::toStringInt(timeRemainingSecs); sessionTimeRemainingTextDisplay->setCaption(timeRemainingString); }
void SonicPiScintilla::replaceLines(int lineStart, int lineFinish, QString newLines) { setSelection(lineStart, 0, lineFinish + 1, 0); replaceSelectedText(newLines); }
void RebindWidget::setBind(KbBind* newBind, KbProfile* newProfile){ bind = newBind; profile = newProfile; setSelection(QStringList()); // Populate typing keys by position ui->typingBox->clear(); ui->typingBox->addItem(" "); typingKeys.clear(); // Use the K95 map as it has all keys const KeyMap& map = KeyMap(KeyMap::K95, bind->map().layout()); foreach(const QString& name, map.byPosition()){ KeyAction action(KbBind::defaultAction(name)); if(action.isNormal() && !modKeys.contains(name) && !fnKeys.contains(name) && !numKeys.contains(name) && !mediaKeys.contains(name) && name != "enter" && name != "tab" && name != "bspace"){ const Key& pos = map[name]; QString friendly = pos.friendlyName(); ui->typingBox->addItem(friendly); typingKeys.append(name); } } typingKeys << "enter" << "tab" << "bspace"; ui->typingBox->addItem("Enter"); ui->typingBox->addItem("Tab"); ui->typingBox->addItem("Backspace"); if(!map.isISO()){ // Add ISO backslash (aka KEY_102ND) to ANSI options typingKeys << "bslash_iso"; ui->typingBox->addItem("Backslash (ISO layout)"); } // Populate mode list ui->modeBox->clear(); ui->modeBox->addItem(" "); ui->modeBox->addItem("(Previous)"); ui->modeBox->addItem("(Next)"); int idx = 1; foreach(KbMode* mode, newProfile->modes()) ui->modeBox->addItem(QString("%1: %2").arg(idx++).arg(mode->name())); // Enable/disable DPI based on device if(bind->isMouse()){ ui->dpiButton->setEnabled(true); ui->dpiBox->setEnabled(true); ui->dpiWarning->hide(); // Fill DPI slots const KbPerf* perf = bind->perf(); for(int i = 0; i < KbPerf::DPI_COUNT; i++){ bool sniper = (i == 0); int boxIdx = i + 3; QPoint dpi = perf->dpi(i); QString text = tr(sniper ? "Sniper:\t%1 x %2" : "%3:\t%1 x %2").arg(dpi.x()).arg(dpi.y()); if(!sniper) text = text.arg(i); ui->dpiBox->setItemText(boxIdx, text); } } else { ui->dpiButton->setEnabled(false); ui->dpiBox->setEnabled(false); ui->dpiWarning->show(); } // Always disable custom DPI boxes until selected ui->dpiCustXBox->setEnabled(false); ui->dpiCustYBox->setEnabled(false); ui->dpiCustLabel->setEnabled(false); }