本文整理汇总了C++中Selection类的典型用法代码示例。如果您正苦于以下问题:C++ Selection类的具体用法?C++ Selection怎么用?C++ Selection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Selection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: g_warning
gint Selection::TimeOutCallback(gpointer data)
{
Selection *oSelection = (Selection *)data;
if (oSelection->Enable()) {
if (conf->get_bool("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key")) {
bool do_scan = gpAppFrame->unlock_keys->is_pressed();
if (!do_scan)
return true;
}
if (oSelection->IsBusy) {
oSelection->IsBusy++;
if (oSelection->IsBusy*SELECTION_INTERVAL > 8000 ) {
//"selection_received" signal is not received for 8 seconds.
//there encounter some error,and i find that this often take a long time (serveral minutes) to get the signal at last,
//during this perioed,if you call gtk_selection_convert(),the "selection_received" signal will not be received also,
//and at last these signals are received at almost the same time...BAD.
//so here create a new selection_widget, then call gtk_selection_convert()...this should can throw that error selection.
//!!!:
//But this seems(i am not sure) will make the widgets in StarDict become unselectable! see BUGS.
g_warning("Error, selection data didn't received, retring!\n");
oSelection->create_selection_widget();
oSelection->IsBusy = 0;
}
} else {
oSelection->IsBusy = 1;
gtk_selection_convert (oSelection->selection_widget, GDK_SELECTION_PRIMARY, oSelection->UTF8_STRING_Atom, GDK_CURRENT_TIME);
}
}
return true;
}
示例2: GetSelection
void Viewer::Update () {
Selection* s = GetSelection();
GraphicView* view = GetGraphicView();
Component* viewComp = view->GetGraphicComp();
Component* edComp = _editor->GetComponent();
if (viewComp != edComp) {
ComponentView* newView = edComp->Create(ViewCategory());
if (newView->IsA(GRAPHIC_VIEW)) {
edComp->Attach(newView);
newView->Update();
SetGraphicView((GraphicView*) newView);
} else {
delete newView;
}
} else {
s->Hide(this);
_viewerView->Update();
GraphicBlock::UpdatePerspective();
_damage->Repair();
s->Show(this);
}
}
示例3: selectThisLine
Selection selectThisLine (const Document & document, const Selection & basis) {
Location origin(0, basis.origin().row());
std::uint64_t row = basis.extent().row();
Location extent(document.row(row).size() - 1, row);
return Selection(origin, extent);
}
示例4: newItemsInspected
void InspectorPanel::newItemsInspected(const Selection& objects)
{
// Ignore items in both
// Create items in objects and not in current
// Delete items in current and not in objects
Selection toCreate, toDelete;
std::set_difference(objects.begin(), objects.end(),
m_currentSel.begin(), m_currentSel.end(),
std::inserter(toCreate, toCreate.begin()));
std::set_difference(m_currentSel.begin(), m_currentSel.end(),
objects.begin(), objects.end(),
std::inserter(toDelete, toDelete.begin()));
for(const auto& object : toDelete)
{
auto widget_it = m_map.get<0>().find(object);
if(widget_it != m_map.get<0>().end())
{
(*widget_it)->deleteLater();
*m_map.get<0>().erase(widget_it);
}
}
for(const auto& object : toCreate)
{
auto widget = InspectorWidgetList::makeInspectorWidget(object->objectName(),
object,
m_tabWidget);
m_tabWidget->addTab(widget, widget->tabName());
m_map.insert(widget);
}
m_currentSel = objects;
}
示例5: fillContextMenu
void PlayContextMenu::fillContextMenu(
QMenu *menu,
const Selection & s,
const TemporalScenarioPresenter& pres,
const QPoint& pt,
const QPointF& scenept)
{
menu->addAction(m_playFromHere);
auto scenPoint = Scenario::ConvertToScenarioPoint(scenept, pres.zoomRatio(), pres.view().height());
m_playFromHere->setData(QVariant::fromValue(scenPoint.date));
if(s.empty())
{
menu->addAction(m_recordAction);
m_recordAction->setData(QVariant::fromValue(ScenarioRecordInitData{&pres, scenept}));
}
else
{
if(std::any_of(s.cbegin(), s.cend(), [] (auto obj) { return dynamic_cast<const StateModel*>(obj.data());}))
{
menu->addAction(m_playStates);
}
/*
if(std::any_of(s.cbegin(), s.cend(), [] (auto obj) { return dynamic_cast<const ConstraintModel*>(obj);}))
{
menu->addAction(m_playConstraints);
}
if(std::any_of(s.cbegin(), s.cend(), [] (auto obj) { return dynamic_cast<const EventModel*>(obj);}))
{
menu->addAction(m_playEvents);
}
*/
}
}
示例6: g_warning
gint Selection::TimeOutCallback(gpointer data)
{
Selection *oSelection = (Selection *)data;
if (oSelection->IsBusy) {
oSelection->IsBusy++;
if (oSelection->IsBusy*SELECTION_INTERVAL > 8000 ) {
//"selection_received" signal is not received for 8 seconds.
//there encounter some error,and i find that this often take a long time (serveral minutes) to get the signal at last,
//during this perioed,if you call gtk_selection_convert(),the "selection_received" signal will not be received also,
//and at last these signals are received at almost the same time...BAD.
//so here create a new selection_widget, then call gtk_selection_convert(). this should can throw that
//error selection.
g_warning("Error, selection data didn't received, retring!\n");
oSelection->create_selection_widget();
oSelection->IsBusy = 0;
}
} else {
oSelection->IsBusy = 1;
gtk_selection_convert (oSelection->selection_widget, GDK_SELECTION_PRIMARY, oSelection->UTF8_STRING_Atom,
GDK_CURRENT_TIME);
}
return TRUE;
}
示例7: CreateManipulator
Manipulator* ExamineTool::CreateManipulator (
Viewer* v, Event& e, Transformer* t
){
GraphicView* views = v->GetGraphicView();
Selection* s = v->GetSelection();
_selPath = new Selection;
Manipulator* m = nil;
s->Clear();
ComputeViewPath(e, views, _selPath);
_shift = e.shift_is_down();
if (!_selPath->IsEmpty()) {
Iterator i;
_selPath->First(i);
GraphicView* gv = _selPath->GetView(i);
s->Append(gv);
s->Update();
_selPath->Last(i);
gv = _selPath->GetView(i);
m = gv->CreateManipulator(v, e, t, this);
}
delete _selPath;
return m;
}
示例8: getSelection
void QDesignerIntegrationPrivate::getSelection(Selection &s)
{
QDesignerFormEditorInterface *core = q->core();
// Get multiselection from object inspector
if (QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(core->objectInspector())) {
designerObjectInspector->getSelection(s);
// Action editor puts actions that are not on the form yet
// into the property editor only.
if (s.empty())
if (QObject *object = core->propertyEditor()->object())
s.objects.push_back(object);
} else {
// Just in case someone plugs in an old-style object inspector: Emulate selection
s.clear();
QDesignerFormWindowInterface *formWindow = core->formWindowManager()->activeFormWindow();
if (!formWindow)
return;
QObject *object = core->propertyEditor()->object();
if (object->isWidgetType()) {
QWidget *widget = static_cast<QWidget*>(object);
QDesignerFormWindowCursorInterface *cursor = formWindow->cursor();
if (cursor->isWidgetSelected(widget)) {
s.managed.push_back(widget);
} else {
s.unmanaged.push_back(widget);
}
} else {
s.objects.push_back(object);
}
}
}
示例9: tr
void
TimeInstantLayer::moveSelection(Selection s, size_t newStartFrame)
{
if (!m_model) return;
SparseOneDimensionalModel::EditCommand *command =
new SparseOneDimensionalModel::EditCommand(m_model,
tr("Drag Selection"));
SparseOneDimensionalModel::PointList points =
m_model->getPoints(s.getStartFrame(), s.getEndFrame());
for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
i != points.end(); ++i) {
if (s.contains(i->frame)) {
SparseOneDimensionalModel::Point newPoint(*i);
newPoint.frame = i->frame + newStartFrame - s.getStartFrame();
command->deletePoint(*i);
command->addPoint(newPoint);
}
}
finish(command);
}
示例10: endingSelection
// This avoids the expense of a full fledged delete operation, and avoids a layout that typically results
// from text removal.
bool InsertTextCommand::performTrivialReplace(const String& text, bool selectInsertedText)
{
if (!endingSelection().isRange())
return false;
if (text.contains('\t') || text.contains(' ') || text.contains('\n'))
return false;
Position start = endingSelection().start();
Position end = endingSelection().end();
if (start.node() != end.node() || !start.node()->isTextNode() || isTabSpanTextNode(start.node()))
return false;
replaceTextInNode(static_cast<Text*>(start.node()), start.offset(), end.offset() - start.offset(), text);
Position endPosition(start.node(), start.offset() + text.length());
// We could have inserted a part of composed character sequence,
// so we are basically treating ending selection as a range to avoid validation.
// <http://bugs.webkit.org/show_bug.cgi?id=15781>
Selection forcedEndingSelection;
forcedEndingSelection.setWithoutValidation(start, endPosition);
setEndingSelection(forcedEndingSelection);
if (!selectInsertedText)
setEndingSelection(Selection(endingSelection().visibleEnd()));
return true;
}
示例11: filterSelections
Selection filterSelections(
T* pressedModel,
Selection sel,
bool cumulation)
{
if(!cumulation)
{
sel.clear();
}
// If the pressed element is selected
if(pressedModel->selection.get())
{
if(cumulation)
{
sel.erase(pressedModel);
}
else
{
sel.insert(pressedModel);
}
}
else
{
sel.insert(pressedModel);
}
return sel;
}
示例12: ClearControlSelectionListener
void
SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
{
// When focus moves such that the caret is part of a new frame selection
// this removes the old selection listener and attaches a new one for
// the current focus.
ClearControlSelectionListener();
mLastTextAccessible = nullptr;
mCurrCtrlFrame = aFocusedElm->GetPrimaryFrame();
if (!mCurrCtrlFrame)
return;
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for focused element!");
if (!frameSel)
return;
// Register 'this' as selection listener for the normal selection.
Selection* normalSel =
frameSel->GetSelection(nsISelectionController::SELECTION_NORMAL);
normalSel->AddSelectionListener(this);
// Register 'this' as selection listener for the spell check selection.
Selection* spellSel =
frameSel->GetSelection(nsISelectionController::SELECTION_SPELLCHECK);
spellSel->AddSelectionListener(this);
}
示例13: endingSelection
void MoveSelectionCommand::doApply()
{
Selection selection = endingSelection();
ASSERT(selection.isRange());
Position pos = m_position;
if (pos.isNull())
return;
// Update the position otherwise it may become invalid after the selection is deleted.
Node *positionNode = m_position.node();
int positionOffset = m_position.offset();
Position selectionEnd = selection.end();
int selectionEndOffset = selectionEnd.offset();
if (selectionEnd.node() == positionNode && selectionEndOffset < positionOffset) {
positionOffset -= selectionEndOffset;
Position selectionStart = selection.start();
if (selectionStart.node() == positionNode) {
positionOffset += selectionStart.offset();
}
pos = Position(positionNode, positionOffset);
}
deleteSelection(m_smartMove);
// If the node for the destination has been removed as a result of the deletion,
// set the destination to the ending point after the deletion.
// Fixes: <rdar://problem/3910425> REGRESSION (Mail): Crash in ReplaceSelectionCommand;
// selection is empty, leading to null deref
if (!pos.node()->inDocument())
pos = endingSelection().start();
setEndingSelection(Selection(pos, endingSelection().affinity()));
applyCommandToComposite(ReplaceSelectionCommand::create(positionNode->document(), m_fragment, true, m_smartMove));
}
示例14: downcast_accEvent
void
SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
{
AccTextSelChangeEvent* event = downcast_accEvent(aEvent);
Selection* sel = static_cast<Selection*>(event->mSel.get());
// Fire selection change event if it's not pure caret-move selection change.
if (sel->GetRangeCount() != 1 || !sel->IsCollapsed())
nsEventShell::FireEvent(aEvent);
// Fire caret move event if there's a caret in the selection.
nsINode* caretCntrNode =
nsCoreUtils::GetDOMNodeFromDOMPoint(sel->GetFocusNode(),
sel->GetFocusOffset());
if (!caretCntrNode)
return;
HyperTextAccessible* caretCntr = nsAccUtils::GetTextContainer(caretCntrNode);
NS_ASSERTION(caretCntr,
"No text container for focus while there's one for common ancestor?!");
if (!caretCntr)
return;
int32_t caretOffset = -1;
if (NS_SUCCEEDED(caretCntr->GetCaretOffset(&caretOffset)) && caretOffset != -1) {
nsRefPtr<AccCaretMoveEvent> caretMoveEvent =
new AccCaretMoveEvent(caretCntr, caretOffset, aEvent->FromUserInput());
nsEventShell::FireEvent(caretMoveEvent);
}
}
示例15: if
/**
* Scripter.activeDocument.selection
* Property
* List of selected Item objects on active document
*/
QList<QVariant> DocumentAPI::selection()
{
QList<QVariant> l;
Selection *sel = ScCore->primaryMainWindow()->doc->m_Selection;
for (int i=0; i < sel->count(); i++)
{
/**
* Checking whether it is a textframe. If yes, we are trying to cast
* it onto TextWrapper class, which can effectively perform all
* the text operations
*/
PageItem *item = sel->itemAt(i);
if (item->asTextFrame())
{
TextAPI *textItem = new TextAPI(item->asTextFrame());
l.append(qVariantFromValue((QObject *)(textItem)));
}
else if(item->asImageFrame())
{
ImageAPI *imageItem = new ImageAPI(item->asImageFrame());
l.append(qVariantFromValue((QObject *)(imageItem)));
}
else
{
ItemAPI *otherItem = new ItemAPI(item);
l.append(qVariantFromValue(
(QObject *)(otherItem)
));
}
}
return l;
}