summaryrefslogtreecommitdiff
path: root/wx+/context_menu.h
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-12-16 21:08:02 -0500
committerB. Stack <bgstack15@gmail.com>2022-12-16 21:08:02 -0500
commitd35a4795f16e51f5773d00dce796f6948f82dae2 (patch)
treeb37279f6f8b354407507cc1a0e44691d6c63ffe8 /wx+/context_menu.h
parentadd upstream 11.28 (diff)
downloadFreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.tar.gz
FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.tar.bz2
FreeFileSync-d35a4795f16e51f5773d00dce796f6948f82dae2.zip
add upstream 11.2911.29
Diffstat (limited to 'wx+/context_menu.h')
-rw-r--r--wx+/context_menu.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/wx+/context_menu.h b/wx+/context_menu.h
index 05dd58b8..d1d2bd9f 100644
--- a/wx+/context_menu.h
+++ b/wx+/context_menu.h
@@ -10,8 +10,9 @@
#include <map>
#include <vector>
#include <functional>
-#include <wx/menu.h>
#include <wx/app.h>
+#include <wx/clipbrd.h>
+#include <wx/menu.h>
#include "dc.h"
@@ -123,6 +124,39 @@ void fixMenuIcons(wxMenu& menu)
if (!menu.Insert(pos, menu.Remove(item))) //detach + reinsert
assert(false);
}
+
+
+inline
+void setClipboardText(const wxString& txt)
+{
+ wxClipboard& clip = *wxClipboard::Get();
+ if (clip.Open())
+ {
+ ZEN_ON_SCOPE_EXIT(clip.Close());
+ [[maybe_unused]] const bool rv1 = clip.SetData(new wxTextDataObject(txt)); //ownership passed
+ [[maybe_unused]] const bool rv2 = clip.Flush();
+ assert(rv1 && rv2);
+ }
+ else assert(false);
+}
+
+
+inline
+std::optional<wxString> getClipboardText()
+{
+ wxClipboard& clip = *wxClipboard::Get();
+ if (clip.Open())
+ {
+ ZEN_ON_SCOPE_EXIT(clip.Close());
+
+ //if (clip.IsSupported(wxDF_TEXT or wxDF_UNICODETEXT !???)) - superfluous? already handled by wxClipboard::GetData()!?
+ wxTextDataObject data;
+ if (clip.GetData(data))
+ return data.GetText();
+ }
+ else assert(false);
+ return std::nullopt;
+}
}
#endif //CONTEXT_MENU_H_18047302153418174632141234
bgstack15