本文整理汇总了C++中setSelection函数的典型用法代码示例。如果您正苦于以下问题:C++ setSelection函数的具体用法?C++ setSelection怎么用?C++ setSelection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setSelection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setText
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>());
}
}
示例2: wxGetApp
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;
}
示例3: GetFileType
//===================>>> 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;
}
}
示例4: setSelection
void SonicPiScintilla::replaceLine(int lineNumber, QString newLine)
{
setSelection(lineNumber, 0, lineNumber + 1, 0);
replaceSelectedText(newLine);
}
示例5: resetSelection
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);
}
}
示例6: t2
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;
}
}
//.........这里部分代码省略.........
示例7: XY_TO_COORD
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();
}
}
}
示例8: setCursorPos
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);
//.........这里部分代码省略.........
示例9: getParentWindow
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;
}
//.........这里部分代码省略.........
示例10: getSelectionIds
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
//.........这里部分代码省略.........
示例11: setSelection
void MGuiEditText::setPressed(bool pressed)
{
MGui2d::setPressed(pressed);
if(! pressed)
setSelection(0, 0);
}
示例12: QWidget
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);
}
示例13: setSelection
void ZealSearchEdit::selectQuery()
{
setSelection(queryStart(), text().size());
}
示例14: selection
void McaEditorReferenceArea::sl_selectionChanged(const MaEditorSelection ¤t, const MaEditorSelection &) {
U2Region selection(current.x(), current.width());
setSelection(selection);
}
示例15: setSelection
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() );
}