From e360746265c05e215ce6f665962e8b176ee5d71c Mon Sep 17 00:00:00 2001 From: luxsie <877033040@qq.com> Date: Sun, 17 Aug 2014 00:03:31 +0800 Subject: [PATCH 1/2] Give Log Console (ConLogFrame) a Context Menu with Copy and Clear actions. --- rpcs3/Gui/ConLogFrame.cpp | 47 +++++++++++++++++++++++++++++++++++++++ rpcs3/Gui/ConLogFrame.h | 4 ++++ 2 files changed, 51 insertions(+) diff --git a/rpcs3/Gui/ConLogFrame.cpp b/rpcs3/Gui/ConLogFrame.cpp index be7f4fc6ef..c1e2c6f370 100644 --- a/rpcs3/Gui/ConLogFrame.cpp +++ b/rpcs3/Gui/ConLogFrame.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include +#include #include #include #include @@ -24,6 +25,12 @@ const int BUFFER_MAX_SIZE = 1024 * 1024; //amount of characters in the TextCtrl text-buffer for the emulation log const int GUI_BUFFER_MAX_SIZE = 1024 * 1024; +enum +{ + id_log_copy, //Copy log to ClipBoard + id_log_clear //Clear log +}; + struct wxWriter : Log::LogListener { wxTextCtrl *m_log; @@ -146,6 +153,10 @@ LogFrame::LogFrame(wxWindow* parent) SetSizer(s_main); Layout(); + m_log->Bind(wxEVT_RIGHT_DOWN, &LogFrame::OnRightClick, this); + Bind(wxEVT_MENU, &LogFrame::OnContextMenu, this, id_log_clear); + Bind(wxEVT_MENU, &LogFrame::OnContextMenu, this, id_log_copy); + Show(); } @@ -162,4 +173,40 @@ bool LogFrame::Close(bool force) void LogFrame::OnQuit(wxCloseEvent& event) { event.Skip(); +} + +//Deals with the RightClick on Log Console, shows up the Context Menu. +void LogFrame::OnRightClick(wxMouseEvent& event) +{ + wxMenu* menu = new wxMenu(); + + menu->Append(id_log_copy, "&Copy Ctrl+C"); + menu->AppendSeparator(); + menu->Append(id_log_clear, "C&lear"); + + PopupMenu(menu); +} +//Well you can bind more than one control to a single handler. +void LogFrame::OnContextMenu(wxCommandEvent& event) +{ + int id = event.GetId(); + switch (id) + { + case id_log_clear: + m_log->Clear(); + break; + case id_log_copy: + if (wxTheClipboard->Open()) + { + m_tdo = new wxTextDataObject(m_log->GetStringSelection()); + if (m_tdo->GetTextLength() > 0) + { + wxTheClipboard->SetData(new wxTextDataObject(m_log->GetStringSelection())); + } + wxTheClipboard->Close(); + } + break; + default: + event.Skip(); + } } \ No newline at end of file diff --git a/rpcs3/Gui/ConLogFrame.h b/rpcs3/Gui/ConLogFrame.h index df5e4d25ff..b9733da8c6 100644 --- a/rpcs3/Gui/ConLogFrame.h +++ b/rpcs3/Gui/ConLogFrame.h @@ -9,6 +9,8 @@ class LogFrame wxAuiNotebook m_tabs; wxTextCtrl *m_log; wxTextCtrl *m_tty; + //Copy Action in Context Menu + wxTextDataObject* m_tdo; public: LogFrame(wxWindow* parent); @@ -21,6 +23,8 @@ private: virtual void Task(){}; void OnQuit(wxCloseEvent& event); + void OnRightClick(wxMouseEvent& event); //Show context menu + void OnContextMenu(wxCommandEvent& event); //After select DECLARE_EVENT_TABLE(); }; \ No newline at end of file From b82d2caa6bee14366be4806d9e31ee90315a990b Mon Sep 17 00:00:00 2001 From: luxsie <877033040@qq.com> Date: Sun, 17 Aug 2014 00:33:24 +0800 Subject: [PATCH 2/2] typo fix: added missing header. really sorry for that. --- rpcs3/Gui/ConLogFrame.h | 1 + 1 file changed, 1 insertion(+) diff --git a/rpcs3/Gui/ConLogFrame.h b/rpcs3/Gui/ConLogFrame.h index b9733da8c6..da7749b619 100644 --- a/rpcs3/Gui/ConLogFrame.h +++ b/rpcs3/Gui/ConLogFrame.h @@ -1,4 +1,5 @@ #pragma once +#include #include "Utilities/Log.h"