void CPropTreeItemFileEdit::OnContextMenu(CWnd *pWnd, CPoint point) { CMenu FloatingMenu; VERIFY(FloatingMenu.LoadMenu(IDR_ME_EDIT_MENU)); CMenu *pPopupMenu = FloatingMenu.GetSubMenu(0); if (CanUndo()) { pPopupMenu->EnableMenuItem(ID_EDIT_UNDO, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_EDIT_UNDO, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } DWORD dwSel = GetSel(); if (HIWORD(dwSel) != LOWORD(dwSel)) { pPopupMenu->EnableMenuItem(ID_EDIT_CUT, MF_BYCOMMAND | MF_ENABLED); pPopupMenu->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND | MF_ENABLED); pPopupMenu->EnableMenuItem(ID_EDIT_DELETE, MF_BYCOMMAND | MF_ENABLED); } else { pPopupMenu->EnableMenuItem(ID_EDIT_CUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); pPopupMenu->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); pPopupMenu->EnableMenuItem(ID_EDIT_DELETE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); }
// Undo the last command void PaintModel::Undo() { if (CanUndo()) { mRedoStack.push(mUndoStack.top()); mUndoStack.top()->Undo(shared_from_this()); mUndoStack.pop(); } }
void BatchCommand::Undo() { BBAssertDebug(CanUndo()); for (RestorableCommandCollection::reverse_iterator it = restorableCommands.rbegin(); it != restorableCommands.rend(); ++it) (*it)->Undo(); }
void wxTextCtrl::Undo() { if (CanUndo()) { ::SendMessage(GetBuddyHwnd(), EM_UNDO, 0, 0); } }
void CColorEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default switch (nChar) { case 0x01:// Ctrl-A => handle SELECT_ALL SetSel(0, -1); return; case 0x03:// Ctrl-C => handle WM_COPY Copy(); return; case 0x16:// Ctrl-V => handle WM_PASTE Paste(); return; case 0x18:// Ctrl-X => handle WM_CUT Cut(); return; case 0x1A:// Ctrl-Z => handle ID_EDIT_UNDO (EM_UNDO) if(CanUndo()) Undo(); return; } CEdit::OnChar(nChar, nRepCnt, nFlags); }
void wxTextEntry::Undo() { wxCHECK_RET( GetTextPeer(), "Must create the control first" ); if (CanUndo()) GetTextPeer()->Undo() ; }
bool UTransBuffer::Undo() { CheckState(); if (!CanUndo()) { UndoDelegate.Broadcast(FUndoSessionContext(), false); return false; } // Apply the undo changes. GIsTransacting = true; { FTransaction& Transaction = UndoBuffer[ UndoBuffer.Num() - ++UndoCount ]; UE_LOG(LogEditorTransaction, Log, TEXT("Undo %s"), *Transaction.GetTitle().ToString() ); BeforeRedoUndoDelegate.Broadcast(Transaction.GetContext()); Transaction.Apply(); UndoDelegate.Broadcast(Transaction.GetContext(), true); } GIsTransacting = false; CheckState(); return true; }
void CHistory::Undo() { if (CanUndo()) { m_commands[m_nextCommandIndex - 1]->Unexecute(); // может выбросить исключение --m_nextCommandIndex; } }
BString UndoContext::UndoLabel() const { if (CanUndo()) return ((Action*)fHistory->ItemAt(fAt - 1))->Label(); else return ""; }
void wxTextCtrl::Undo() { if (CanUndo()) { if (m_bIsMLE) ::WinSendMsg(GetHwnd(), MLM_UNDO, 0, 0); // Simple entryfields cannot be undone } } // end of wxTextCtrl::Undo
bool History::InternalRollBack(void) { if(!CanUndo())return false; Undoable *u; m_curpos--; u = *m_curpos; u->RollBack(); return true; }
void wxComboBox::Undo() { if (CanUndo()) { HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) ::SendMessage(hEditWnd, EM_UNDO, 0, 0); } }
void UndoContext::Undo() { if (!CanUndo()) return; fAt--; ((Action*)fHistory->ItemAt(fAt))->Undo(); }
void wxComboBox::Redo() { if (CanUndo()) { // Same as Undo, since Undo undoes the undo, i.e. a redo. HWND hEditWnd = (HWND) GetEditHWND() ; if ( hEditWnd ) ::SendMessage(hEditWnd, EM_UNDO, 0, 0); } }
void SnapshotManager::Undo() { Assert(CanUndo()); if (m_snapshots.size() > 1) { m_snapshots.pop_back(); } SetStateToSnapshot(*(m_snapshots.rbegin())); }
bool cActionManager::Undo() { if (CanUndo()) { cAction* action = mUndoList.front(); RemoveTopAction(UNDO); action->Accept(cUndoActionVisitor::Global()); AddAction(REDO, action); return true; } return false; }
void CUICommandHistory::UICommandAction(CommandType type) { CUICommandNode* pOldNode; CUICommandNode* pNewNode; if(type == cmdRedo) { if(!CanRedo()) return; pOldNode = m_lstCommandNodes.GetAt(m_lstCommandNodes.FindIndex(m_nCommandIndex)); pNewNode = new CUICommandNode(pOldNode->m_pBefore, pOldNode->m_pAfter, pOldNode->m_ActionType); m_nCommandIndex++; } else { if(!CanUndo()) return; m_nCommandIndex--; pOldNode = m_lstCommandNodes.GetAt(m_lstCommandNodes.FindIndex(m_nCommandIndex)); ActionType action; switch(pOldNode->m_ActionType) { case actionAdd: action = actionDelete; break; case actionModify: action = actionModify; break; case actionDelete: action = actionAdd; break; } pNewNode = new CUICommandNode(pOldNode->m_pAfter, pOldNode->m_pBefore, action); } switch(pNewNode->m_ActionType) { case actionAdd: ActionAdd(pNewNode->m_pAfter); break; case actionModify: ActionModify(pNewNode->m_pAfter); break; case actionDelete: ActionDelete(pNewNode->m_pBefore); break; } delete pNewNode; }
//----------------------------------------------------------------------------- // The display code is the only part of the program that knows how wide a // rung will be when it's displayed; so this is the only convenient place to // warn the user and undo their changes if they created something too wide. // This is not very clean. //----------------------------------------------------------------------------- static BOOL CheckBoundsUndoIfFails(int gx, int gy) { if(gx >= DISPLAY_MATRIX_X_SIZE || gx < 0 || gy >= DISPLAY_MATRIX_Y_SIZE || gy < 0) { if(CanUndo()) { UndoUndo(); Error(_("Too many elements in subcircuit!")); return TRUE; } } return FALSE; }
FUndoSessionContext UTransBuffer::GetUndoContext( bool bCheckWhetherUndoPossible ) { FUndoSessionContext Context; FText Title; if( bCheckWhetherUndoPossible && !CanUndo( &Title ) ) { Context.Title = Title; return Context; } const FTransaction* Transaction = &UndoBuffer[ UndoBuffer.Num() - (UndoCount + 1) ]; return Transaction->GetContext(); }
void CEditWnd::Undo() { if (!CanUndo()) return; CPoint ptCursorPos; if (m_pTextBuffer->Undo(ptCursorPos)) { ASSERT_VALIDTEXTPOS(ptCursorPos); SetAnchor(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *exp - //----------------------------------------------------------------------------- void CExpression::Undo( void ) { if ( !CanUndo() ) return; Assert( m_nUndoCurrent < undo.Size() ); CExpUndoInfo *u = undo[ m_nUndoCurrent++ ]; Assert( u ); memcpy( setting, u->setting, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) ); memcpy( weight, u->weight, GLOBAL_STUDIO_FLEX_CONTROL_COUNT * sizeof( float ) ); }
void CommandManager::Undo(std::string& feedback){ if (CanUndo()){ UndoRedoCount--; Command* pCommand = getLastUndoCommand(); undoList.pop_back(); if (pCommand->undo(_taskList, feedback)){ AddRedo(pCommand); } else { delete pCommand; pCommand = NULL; } } }
bool NativeTextfieldWin::IsCommandIdEnabled(int command_id) const { switch(command_id) { case IDS_APP_UNDO: return !textfield_->read_only() && !!CanUndo(); case IDS_APP_CUT: return !textfield_->read_only() && !textfield_->IsPassword() && !!CanCut(); case IDS_APP_COPY: return !!CanCopy() && !textfield_->IsPassword(); case IDS_APP_PASTE: return !textfield_->read_only() && !!CanPaste(); case IDS_APP_SELECT_ALL: return !!CanSelectAll(); default: NOTREACHED(); return false; } }
void CRichEditCtrlX::OnContextMenu(CWnd* pWnd, CPoint point) { long iSelStart, iSelEnd; GetSel(iSelStart, iSelEnd); int iTextLen = GetWindowTextLength(); // Context menu of standard edit control // // Undo // ---- // Cut // Copy // Paste // Delete // ------ // Select All bool bReadOnly = (GetStyle() & ES_READONLY); CMenu menu; menu.CreatePopupMenu(); if (!bReadOnly){ menu.AppendMenu(MF_STRING, MP_UNDO, GetResString(IDS_UNDO)); menu.AppendMenu(MF_SEPARATOR); } if (!bReadOnly) menu.AppendMenu(MF_STRING, MP_CUT, GetResString(IDS_CUT)); menu.AppendMenu(MF_STRING, MP_COPYSELECTED, GetResString(IDS_COPY)); if (!bReadOnly){ menu.AppendMenu(MF_STRING, MP_PASTE, GetResString(IDS_PASTE)); menu.AppendMenu(MF_STRING, MP_REMOVESELECTED, GetResString(IDS_DELETESELECTED)); } menu.AppendMenu(MF_SEPARATOR); menu.AppendMenu(MF_STRING, MP_SELECTALL, GetResString(IDS_SELECTALL)); menu.EnableMenuItem(MP_UNDO, CanUndo() ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_CUT, iSelEnd > iSelStart ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_COPYSELECTED, iSelEnd > iSelStart ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_PASTE, CanPaste() ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_REMOVESELECTED, iSelEnd > iSelStart ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_SELECTALL, iTextLen > 0 ? MF_ENABLED : MF_GRAYED); if (point.x == -1 && point.y == -1) { point.x = 16; point.y = 32; ClientToScreen(&point); } menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); }
void ProjectManager::OnMenuUndo() { //Si on peut annuler la modification if(CanUndo()) { if(currentHistoryNavigation==0) { PushModificationToHistory(true); currentHistoryNavigation++; } currentHistoryNavigation++; projetConfig=configHistory[configHistory.size()-currentHistoryNavigation]; LoadCurrentProject(false); Init(); } }
void wxCommandProcessor::SetMenuStrings() { #if wxUSE_MENUS if (m_commandEditMenu) { wxString undoLabel = GetUndoMenuLabel(); wxString redoLabel = GetRedoMenuLabel(); m_commandEditMenu->SetLabel(wxID_UNDO, undoLabel); m_commandEditMenu->Enable(wxID_UNDO, CanUndo()); m_commandEditMenu->SetLabel(wxID_REDO, redoLabel); m_commandEditMenu->Enable(wxID_REDO, CanRedo()); } #endif // wxUSE_MENUS }
bool cActionManager::Undo(int id) { while (42) { if (CanUndo()) { cAction* action = mUndoList.front(); RemoveTopAction(UNDO); action->Accept(cUndoActionVisitor::Global()); AddAction(REDO, action); if (action->m_Id == id) return true; } else return false; } return false; }
bool UTransBuffer::Undo() { CheckState(); if( !CanUndo() ) { return false; } // Apply the undo changes. FTransaction& Transaction = UndoBuffer[ UndoBuffer.Num() - ++UndoCount ]; UE_LOG(LogEditorTransaction, Log, TEXT("Undo %s"), *Transaction.GetTitle().ToString() ); Transaction.Apply(); CheckState(); return true; }
BOOL CCrystalTextBuffer::Undo(CPoint &ptCursorPos) { ASSERT(CanUndo()); ASSERT((m_aUndoBuf[0].m_dwFlags & UNDO_BEGINGROUP) != 0); for (;;) { m_nUndoPosition --; const SUndoRecord &ur = m_aUndoBuf[m_nUndoPosition]; if (ur.m_dwFlags & UNDO_INSERT) { #ifdef _ADVANCED_BUGCHECK // Try to ensure that we undoing correctly... // Just compare the text as it was before Undo operation CString text; GetText(ur.m_ptStartPos.y, ur.m_ptStartPos.x, ur.m_ptEndPos.y, ur.m_ptEndPos.x, text); ASSERT(lstrcmp(text, ur.m_pcText) == 0); #endif VERIFY(InternalDeleteText(NULL, ur.m_ptStartPos.y, ur.m_ptStartPos.x, ur.m_ptEndPos.y, ur.m_ptEndPos.x)); ptCursorPos = ur.m_ptStartPos; } else { int nEndLine, nEndChar; VERIFY(InternalInsertText(NULL, ur.m_ptStartPos.y, ur.m_ptStartPos.x, ur.m_pcText, nEndLine, nEndChar)); #ifdef _ADVANCED_BUGCHECK ASSERT(ur.m_ptEndPos.y == nEndLine); ASSERT(ur.m_ptEndPos.x == nEndChar); #endif ptCursorPos = ur.m_ptEndPos; } if (ur.m_dwFlags & UNDO_BEGINGROUP) break; } if (m_bModified && m_nSyncPosition == m_nUndoPosition) SetModified(FALSE); if (! m_bModified && m_nSyncPosition != m_nUndoPosition) SetModified(TRUE); return TRUE; }
void CMyRichEdit::OnRButtonDown(UINT nFlags, CPoint point) { //设置为焦点 SetFocus(); //创建一个弹出式菜单 CMenu popmenu; popmenu.CreatePopupMenu(); //添加菜单项目 popmenu.AppendMenu(0, ID_RICH_UNDO, _T("撤消(&U)")); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_CUT, _T("剪切(&T)")); popmenu.AppendMenu(0, ID_RICH_COPY, _T("复制(&T)")); popmenu.AppendMenu(0, ID_RICH_PASTE, _T("粘贴(&P)")); popmenu.AppendMenu(0, ID_RICH_CLEAR, _T("删除(&D)")); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_SELECTALL, _T("全选(&A)")); popmenu.AppendMenu(0, MF_SEPARATOR); popmenu.AppendMenu(0, ID_RICH_SETFONT, _T("设置字体(&F)")); //初始化菜单项 UINT nUndo=(CanUndo() ? 0 : MF_GRAYED ); popmenu.EnableMenuItem(ID_RICH_UNDO, MF_BYCOMMAND|nUndo); UINT nSel=((GetSelectionType()!=SEL_EMPTY) ? 0 : MF_GRAYED) ; popmenu.EnableMenuItem(ID_RICH_CUT, MF_BYCOMMAND|nSel); popmenu.EnableMenuItem(ID_RICH_COPY, MF_BYCOMMAND|nSel); popmenu.EnableMenuItem(ID_RICH_CLEAR, MF_BYCOMMAND|nSel); UINT nPaste=(CanPaste() ? 0 : MF_GRAYED) ; popmenu.EnableMenuItem(ID_RICH_PASTE, MF_BYCOMMAND|nPaste); //显示菜单 CPoint pt; GetCursorPos(&pt); popmenu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this); popmenu.DestroyMenu(); CRichEditCtrl::OnRButtonDown(nFlags, point); }