void SceneTree::ShowContextMenu(const QPoint &pos) { QModelIndex index = indexAt(pos); DAVA::Entity *clickedEntity = treeModel->GetEntity(index); if(NULL != clickedEntity) { QMenu contextMenu; contextMenu.addAction(QIcon(":/QtIcons/zoom.png"), "Look at", this, SLOT(LookAtSelection())); contextMenu.addSeparator(); contextMenu.addAction(QIcon(":/QtIcons/remove.png"), "Remove", this, SLOT(RemoveSelection())); contextMenu.addSeparator(); QAction *lockAction = contextMenu.addAction(QIcon(":/QtIcons/lock_add.png"), "Lock", this, SLOT(LockEntities())); QAction *unlockAction = contextMenu.addAction(QIcon(":/QtIcons/lock_delete.png"), "Unlock", this, SLOT(UnlockEntities())); if(clickedEntity->GetLocked()) { lockAction->setDisabled(true); } else { unlockAction->setDisabled(true); } contextMenu.exec(mapToGlobal(pos)); } }
void VisualToolDrag::OnFrameChanged() { if (primary && !IsDisplayed(primary->line)) primary = 0; feature_iterator feat = features.begin(); feature_iterator end = features.end(); for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) { if (IsDisplayed(diag)) { // Features don't exist and should if (feat == end || feat->line != diag) MakeFeatures(diag, feat); // Move past already existing features for the line else while (feat != end && feat->line == diag) ++feat; } else { // Remove all features for this line (if any) while (feat != end && feat->line == diag) { if (feat == active_feature) active_feature = features.end(); feat->line = 0; RemoveSelection(feat); feat = features.erase(feat); } } } }
/** * Wechselt zwischen selektiert/nicht selektiert * * @author jh */ void ctrlMultiSelectGroup::ToggleSelection(unsigned short selection, bool notify) { if (IsSelected(selection)) RemoveSelection(selection, notify); else AddSelection(selection, notify); }
void LineEdit::DragAndDrop(Point p, PasteClip& d) { if(IsReadOnly()) return; int c = GetMousePos(p); if(AcceptText(d)) { NextUndo(); int a = sb.y; int sell, selh; WString text = GetWString(d); if(GetSelection(sell, selh)) { if(c >= sell && c < selh) { if(!IsReadOnly()) RemoveSelection(); if(IsDragAndDropSource()) d.SetAction(DND_COPY); c = sell; } else if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) { if(c > sell) c -= selh - sell; if(!IsReadOnly()) RemoveSelection(); d.SetAction(DND_COPY); } } int count = Insert(c, text); sb.y = a; SetFocus(); SetSelection(c, c + count); Action(); return; } if(!d.IsAccepted()) return; if(!isdrag) { isdrag = true; ScrollIntoCursor(); } Point dc = Null; if(c >= 0) dc = GetColumnLine(c); if(dc != dropcaret) { RefreshDropCaret(); dropcaret = dc; RefreshDropCaret(); } }
void DocEdit::DragAndDrop(Point p, PasteClip& d) { if(IsReadOnly()) return; int c = GetMousePos(p); if(AcceptText(d)) { NextUndo(); int a = sb; int sell, selh; WString txt = GetWString(d); if(GetSelection(sell, selh)) { if(c >= sell && c < selh) { if(!IsReadOnly()) RemoveSelection(); if(IsDragAndDropSource()) d.SetAction(DND_COPY); c = sell; } else if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) { if(c > sell) c -= selh - sell; if(!IsReadOnly()) RemoveSelection(); d.SetAction(DND_COPY); } } int count = Insert(c, txt); sb = a; SetFocus(); SetSelection(c, c + count); Action(); return; } if(!d.IsAccepted()) return; Point dc = Null; if(c >= 0) { Point cr = GetCaret(c); dc = Point(cr.x + 1, cr.y); } if(dc != dropcaret) { RefreshDropCaret(); dropcaret = dc; RefreshDropCaret(); } }
void LineEdit::DeleteChar() { if(IsReadOnly() || RemoveSelection()) { Action(); return; } if(cursor < total) { Remove(cursor, 1); Action(); } }
void LineEdit::DeleteLine() { int b, e; if(GetSelection(b, e) && GetLine(b) != GetLine(e)) { RemoveSelection(); return; } int i = GetLine(cursor); int p = GetPos(i); Remove(p, line[i].GetLength() + 1); PlaceCaret(p); Action(); }
void LineEdit::PasteColumn(const WString& text) { Vector<WString> cl = Split(text, '\n', false); if(cl.GetCount() && cl.Top().IsEmpty()) cl.Drop(); if(cl.GetCount() == 0) return; int pos; if(IsRectSelection()) { Rect t = GetRectSelection(); RemoveSelection(); Point p = t.TopLeft(); pos = cursor; for(int i = 0; i < t.bottom - t.top + 1; i++) { CacheLinePos(i + p.y); int l = GetGPos(i + p.y, p.x); pos = l + Insert(l, cl[i % cl.GetCount()]); } } else { RemoveSelection(); Point p = GetColumnLine(cursor); pos = cursor; for(int i = 0; i < cl.GetCount(); i++) { CacheLinePos(i + p.y); int li = p.y + i; if(li < line.GetCount()) { int l = GetGPos(i + p.y, p.x); pos = l + Insert(l, cl[i]); } else { Insert(GetLength(), cl[i] + "\n"); pos = GetLength(); } } } PlaceCaret(pos); }
LRESULT CElementPropPage::OnClickedRemoveSelbutton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { HRESULT hr; CComPtr<IDMGraphCtrl> spGraph; if(FAILED(GetGraphCtrl(&spGraph))) { return 0; } CComPtr<IDMGraphCollection> spGraphCollection; hr = spGraph->get_Elements(&spGraphCollection); RemoveSelection(spGraphCollection); UpdateControls(spGraph); return 0; }
void PanelObjectsList::NewObject(MyGUI::WidgetPtr) { RemoveSelection(); MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui(); if (ObjectDescription) { //ObjectDescription->Hide(); //gui->destroyWidget(ObjectDescription.get()); ObjectDescription->Destroy(); delete ObjectDescription; ObjectDescription = NULL; } ObjectDescription = new ObjectDescriptionLayout("EditorObjectOptions.layout"); ObjectDescription->Load(); ObjectDescription->Show(); }
void LineEdit::LeftDrag(Point p, dword flags) { int c = GetMousePos(p); int l, h; if(!HasCapture() && GetSelection(l, h) && c >= l && c < h) { WString sample = GetW(l, min(h - l, 3000)); Size sz = StdSampleSize(); ImageDraw iw(sz); iw.DrawRect(sz, Black()); iw.Alpha().DrawRect(sz, Black()); DrawTLText(iw.Alpha(), 0, 0, 9999, sample, font, White()); NextUndo(); if(DoDragAndDrop(ClipFmtsText(), iw) == DND_MOVE) { RemoveSelection(); Action(); } } }
void ListControlExtendedMultipleSelectStrategy::SelectItemsByMouseEventWithControlKey(std::size_t current_index, bool is_mouse_moving) { if (! is_mouse_moving) { focused_index_ = current_index; orginally_recorded_index_ = 0; orginally_recorded_count_ = 0; orginally_selected_indexes_.clear(); } std::size_t select_index = 0; std::size_t select_count = 0; MakeSelectionRange(current_index, focused_index_, select_index, select_count); //Recover orginally selection states not in current selection range. RecoverSelectionStatesNotInRange(select_index, select_count); //Record orginally selection states in current selection range. RecordSelectionStatesInRange(select_index, select_count); if (! is_mouse_moving) { is_focused_index_orginally_selected_ = orginally_selected_indexes_.find(current_index) != orginally_selected_indexes_.end(); } auto list_control = GetListControl(); if (list_control != nullptr) { //Add or remove newly selection. if (is_focused_index_orginally_selected_) { list_control->RemoveSelection(select_index, select_count); } else { list_control->AddSelection(select_index, select_count); } list_control->ScrollToItemAtIndex(current_index); } }
void ListControlExtendedMultipleSelectStrategy::RecoverSelectionStatesNotInRange(std::size_t index, std::size_t count) { auto list_control = GetListControl(); if (list_control == nullptr) { return; } for (std::size_t current_index = orginally_recorded_index_; current_index != orginally_recorded_index_ + orginally_recorded_count_; ++current_index) { if ((current_index < index) || (index + count <= current_index)) { if (orginally_selected_indexes_.find(current_index) == orginally_selected_indexes_.end()) { list_control->RemoveSelection(current_index, 1); } else { list_control->AddSelection(current_index, 1); } } } }
bool LineEdit::InsertChar(dword key, int count, bool canow) { if(key == K_TAB && !processtab) return false; if(filter && key >= 32 && key < 65535) key = (*filter)(key); if(!IsReadOnly() && (key >= 32 && key < 65536 || key == '\t' || key == '\n' || key == K_ENTER && processenter || key == K_SHIFT_SPACE)) { if(key >= 128 && key < 65536 && (charset != CHARSET_UNICODE && charset != CHARSET_UTF8_BOM) && FromUnicode((wchar)key, charset) == DEFAULTCHAR) return true; if(!RemoveSelection() && overwrite && key != '\n' && key != K_ENTER && canow) { int q = cursor; int i = GetLinePos(q); if(q + count - 1 < GetLineLength(i)) Remove(cursor, count); } WString text(key == K_ENTER ? '\n' : key == K_SHIFT_SPACE ? ' ' : key, count); Insert(cursor, text, true); PlaceCaret(cursor + count); Action(); return true; } return false; }
void EScene::CutSelection( ObjClassID classfilter ) { CopySelection( classfilter ); RemoveSelection( classfilter ); }
void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event)) { RemoveSelection(); }
void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) { bool left_click = event.LeftDown(); bool left_double = event.LeftDClick(); shift_down = event.ShiftDown(); ctrl_down = event.CmdDown(); alt_down = event.AltDown(); mouse_pos = event.GetPosition(); if (event.Leaving()) { mouse_pos = Vector2D(); parent->Render(); return; } if (!dragging) { int max_layer = INT_MIN; active_feature = nullptr; for (auto& feature : features) { if (feature.IsMouseOver(mouse_pos) && feature.layer >= max_layer) { active_feature = &feature; max_layer = feature.layer; } } } if (dragging) { // continue drag if (event.LeftIsDown()) { for (auto sel : sel_features) sel->UpdateDrag(mouse_pos - drag_start, shift_down); for (auto sel : sel_features) UpdateDrag(sel); Commit(); } // end drag else { dragging = false; // mouse didn't move, fiddle with selection if (active_feature && !active_feature->HasMoved()) { // Don't deselect stuff that was selected in this click's mousedown event if (!sel_changed) { if (ctrl_down) RemoveSelection(active_feature); else SetSelection(active_feature, true); } } active_feature = nullptr; parent->ReleaseMouse(); parent->SetFocus(); } } else if (holding) { if (!event.LeftIsDown()) { holding = false; parent->ReleaseMouse(); parent->SetFocus(); } UpdateHold(); Commit(); } else if (left_click) { drag_start = mouse_pos; // start drag if (active_feature) { if (!sel_features.count(active_feature)) { sel_changed = true; SetSelection(active_feature, !ctrl_down); } else sel_changed = false; if (active_feature->line) c->selectionController->SetActiveLine(active_feature->line); if (InitializeDrag(active_feature)) { for (auto sel : sel_features) sel->StartDrag(); dragging = true; parent->CaptureMouse(); } } // start hold else { if (!alt_down && features.size() > 1) { sel_features.clear(); c->selectionController->SetSelectedSet({ c->selectionController->GetActiveLine() }); } if (active_line && InitializeHold()) { holding = true; parent->CaptureMouse(); } } } if (active_line && left_double) OnDoubleClick(); parent->Render(); // Only coalesce the changes made in a single drag if (!event.LeftIsDown()) commit_id = -1; }
bool DocEdit::Key(dword key, int cnt) { NextUndo(); bool h; int q; bool select = key & K_SHIFT; int pgsk = max(8, 6 * GetSize().cy / 8); switch(key & ~K_SHIFT) { case K_CTRL_LEFT: PlaceCaret(GetPrevWord(cursor), select); break; case K_CTRL_RIGHT: PlaceCaret(GetNextWord(cursor), select); break; case K_HOME: HomeEnd(0, select); break; case K_END: HomeEnd(cx, select); break; case K_CTRL_HOME: case K_CTRL_PAGEUP: PlaceCaret(0, select); break; case K_CTRL_END: case K_CTRL_PAGEDOWN: PlaceCaret(total, select); break; case K_UP: if(GetCursor() == 0) return !updownleave; VertMove(-8, select, false); return true; case K_DOWN: if(GetCursor() == GetLength()) return !updownleave; VertMove(8, select, false); return true; case K_PAGEUP: VertMove(-pgsk, select, true); return true; case K_PAGEDOWN: VertMove(pgsk, select, true); return true; case K_LEFT: if(cursor) PlaceCaret(cursor - 1, select); break; case K_RIGHT: if(cursor < total) PlaceCaret(cursor + 1, select); break; default: if(IsReadOnly()) return MenuBar::Scan(WhenBar, key); switch(key) { case K_BACKSPACE: case K_SHIFT|K_BACKSPACE: if(RemoveSelection()) break; if(cursor == 0) return true; cursor--; Remove(cursor, 1); break; case K_CTRL_BACKSPACE: if(RemoveSelection()) break; if(cursor <= 0) return true; q = cursor - 1; h = IsLetter(GetChar(q)); while(q > 0 && IsLetter(GetChar(q - 1)) == h) q--; Remove(q, cursor - q); SetCursor(q); break; case K_DELETE: if(RemoveSelection()) break; if(cursor >= total) return true; if(cursor < total) Remove(cursor, 1); break; case K_CTRL_DELETE: if(RemoveSelection()) break; if(cursor >= total) return true; q = cursor; h = IsLetter(GetChar(q)); while(IsLetter(GetChar(q)) == h && q < total) q++; Remove(cursor, q - cursor); break; case K_ENTER: if(!processenter) return true; key = '\n'; default: if(filter && key >= 32 && key < 65535) key = (*filter)(key); if(key >= ' ' && key < 65536 || key == '\n' || key == '\t' || key == K_SHIFT_SPACE) { if(key == K_TAB && !processtab) return false; if(key >= 128 && key < 65536 && (charset != CHARSET_UNICODE && charset != CHARSET_UTF8_BOM) && FromUnicode((wchar)key, charset) == DEFAULTCHAR) return true; RemoveSelection(); Insert(cursor, WString(key == K_SHIFT_SPACE ? ' ' : key, cnt), true); cursor += cnt; break; } return MenuBar::Scan(WhenBar, key); } UpdateAction(); } PlaceCaret(true); return true; }
void LineEdit::Backspace() { if(IsReadOnly() || RemoveSelection() || cursor == 0) return; MoveLeft(); DeleteChar(); Action(); }