mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 07:21:25 +12:00
Merge pull request #760 from Syphurith/patch-UI
UI: Clear command for Log Console
This commit is contained in:
commit
2b4f44c0b2
2 changed files with 52 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
|
#include <wx/clipbrd.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -24,6 +25,12 @@ const int BUFFER_MAX_SIZE = 1024 * 1024;
|
||||||
//amount of characters in the TextCtrl text-buffer for the emulation log
|
//amount of characters in the TextCtrl text-buffer for the emulation log
|
||||||
const int GUI_BUFFER_MAX_SIZE = 1024 * 1024;
|
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
|
struct wxWriter : Log::LogListener
|
||||||
{
|
{
|
||||||
wxTextCtrl *m_log;
|
wxTextCtrl *m_log;
|
||||||
|
@ -146,6 +153,10 @@ LogFrame::LogFrame(wxWindow* parent)
|
||||||
SetSizer(s_main);
|
SetSizer(s_main);
|
||||||
Layout();
|
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();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,4 +173,40 @@ bool LogFrame::Close(bool force)
|
||||||
void LogFrame::OnQuit(wxCloseEvent& event)
|
void LogFrame::OnQuit(wxCloseEvent& event)
|
||||||
{
|
{
|
||||||
event.Skip();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <wx/dataobj.h>
|
||||||
#include "Utilities/Log.h"
|
#include "Utilities/Log.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +10,8 @@ class LogFrame
|
||||||
wxAuiNotebook m_tabs;
|
wxAuiNotebook m_tabs;
|
||||||
wxTextCtrl *m_log;
|
wxTextCtrl *m_log;
|
||||||
wxTextCtrl *m_tty;
|
wxTextCtrl *m_tty;
|
||||||
|
//Copy Action in Context Menu
|
||||||
|
wxTextDataObject* m_tdo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LogFrame(wxWindow* parent);
|
LogFrame(wxWindow* parent);
|
||||||
|
@ -21,6 +24,8 @@ private:
|
||||||
virtual void Task(){};
|
virtual void Task(){};
|
||||||
|
|
||||||
void OnQuit(wxCloseEvent& event);
|
void OnQuit(wxCloseEvent& event);
|
||||||
|
void OnRightClick(wxMouseEvent& event); //Show context menu
|
||||||
|
void OnContextMenu(wxCommandEvent& event); //After select
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
Loading…
Add table
Add a link
Reference in a new issue