From 3d1a1a03ed267818f4ed5783506d9755c2cff4c5 Mon Sep 17 00:00:00 2001 From: unodgs Date: Mon, 21 May 2012 14:29:16 +0000 Subject: [PATCH] GridCtrl: Added explicitly enabling of clipboard cut, copy and paste operations git-svn-id: svn://ultimatepp.org/upp/trunk@4988 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/GridCtrl/GridCtrl.cpp | 13 ++++++++----- uppsrc/GridCtrl/GridCtrl.h | 7 +++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/uppsrc/GridCtrl/GridCtrl.cpp b/uppsrc/GridCtrl/GridCtrl.cpp index 413811756..e3d885485 100644 --- a/uppsrc/GridCtrl/GridCtrl.cpp +++ b/uppsrc/GridCtrl/GridCtrl.cpp @@ -132,6 +132,9 @@ GridCtrl::GridCtrl() : holder(*this) clipboard = false; extra_paste = true; fixed_paste = false; + copy_allowed = true; + cut_allowed = true; + paste_allowed = true; copy_column_names = false; draw_focus = false; ask_remove = false; @@ -624,9 +627,9 @@ void GridCtrl::ClipboardMenu(Bar &bar) { bool c = IsCursor(); bool s = c || IsSelection(); - bar.Add(t_("Copy"), THISBACK(DoCopy)).Image(CtrlImg::copy()).Key(K_CTRL_C).Enable(s); - bar.Add(t_("Cut"), THISBACK(Nothing)).Image(CtrlImg::cut()).Key(K_CTRL_X).Enable(s); - bar.Add(t_("Paste"), THISBACK(DoPaste)).Image(CtrlImg::paste()).Key(K_CTRL_V).Enable(c && IsClipboardAvailable()); + bar.Add(t_("Copy"), THISBACK(DoCopy)).Image(CtrlImg::copy()).Key(K_CTRL_C).Enable(s && copy_allowed); + bar.Add(t_("Cut"), THISBACK(Nothing)).Image(CtrlImg::cut()).Key(K_CTRL_X).Enable(s && cut_allowed); + bar.Add(t_("Paste"), THISBACK(DoPaste)).Image(CtrlImg::paste()).Key(K_CTRL_V).Enable(c && paste_allowed && IsClipboardAvailable()); if(extra_paste) bar.Add(t_("Paste as"), THISBACK(PasteAsMenu)); } @@ -635,8 +638,8 @@ void GridCtrl::PasteAsMenu(Bar &bar) { bool c = IsCursor(); bool s = IsClipboardAvailable() && !fixed_paste; - bar.Add(t_("appended"), THISBACK(DoPasteAppendedRows)).Key(K_CTRL_E).Enable(s); - bar.Add(t_("inserted"), THISBACK(DoPasteInsertedRows)).Key(K_CTRL_I).Enable(c && s); + bar.Add(t_("appended"), THISBACK(DoPasteAppendedRows)).Key(K_CTRL_E).Enable(s && paste_allowed); + bar.Add(t_("inserted"), THISBACK(DoPasteInsertedRows)).Key(K_CTRL_I).Enable(c && paste_allowed && s); } bool GridCtrl::IsClipboardAvailable() diff --git a/uppsrc/GridCtrl/GridCtrl.h b/uppsrc/GridCtrl/GridCtrl.h index 6fafe2c90..e54a0faf4 100644 --- a/uppsrc/GridCtrl/GridCtrl.h +++ b/uppsrc/GridCtrl/GridCtrl.h @@ -881,6 +881,9 @@ class GridCtrl : public Ctrl bool clipboard:1; bool extra_paste:1; bool fixed_paste:1; + bool copy_allowed:1; + bool cut_allowed:1; + bool paste_allowed:1; bool copy_column_names:1; bool draw_focus:1; bool cancel_all:1; @@ -1136,6 +1139,9 @@ class GridCtrl : public Ctrl GridCtrl& Clipboard(bool b = true) { clipboard = b; return *this; } GridCtrl& ExtraPaste(bool b = true) { extra_paste = b; return *this; } GridCtrl& FixedPaste(bool b = true) { fixed_paste = b; return *this; } + GridCtrl& ClipboardCopy(bool b = true) { copy_allowed = b; return *this; } + GridCtrl& ClipboardCut(bool b = true) { cut_allowed = b; return *this; } + GridCtrl& ClipboardPaste(bool b = true) { paste_allowed = b; return *this; } GridCtrl& CopyColumnNames(bool b = true) { copy_column_names = b; return *this; } GridCtrl& AskRemove(bool b = true) { ask_remove = b; return *this; } GridCtrl& RowChanging(bool b = true) { row_changing = b; return *this; } @@ -1843,6 +1849,7 @@ class GridText : Ctrl }; template<> void Xmlize(XmlIO& xml, GridCtrl& g); +template<> void Jsonize(JsonIO& json, GridCtrl& g); END_UPP_NAMESPACE