Commit 456eeaba authored by Maciej Suminski's avatar Maciej Suminski

Routines for handling clipboard with TOOL_MANAGER.

parent d73ab976
......@@ -34,6 +34,7 @@
#include <boost/range/adaptor/map.hpp>
#include <wx/event.h>
#include <wx/clipbrd.h>
#include <view/view.h>
......@@ -598,6 +599,41 @@ void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu,
}
bool TOOL_MANAGER::SaveClipboard( const std::string& aText )
{
if( wxTheClipboard->Open() )
{
wxTheClipboard->SetData( new wxTextDataObject( aText ) );
wxTheClipboard->Close();
return true;
}
return false;
}
std::string TOOL_MANAGER::GetClipboard() const
{
std::string result;
if( wxTheClipboard->Open() )
{
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
{
wxTextDataObject data;
wxTheClipboard->GetData( data );
result = data.GetText().mb_str();
}
wxTheClipboard->Close();
}
return result;
}
TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
{
static int currentId;
......
......@@ -257,6 +257,19 @@ public:
m_passEvent = true;
}
/**
* Stores an information to the system clipboard.
* @param aText is the information to be stored.
* @return False if error occured.
*/
bool SaveClipboard( const std::string& aText );
/**
* Returns the information currently stored in the system clipboard. If data stored in the
* clipboard is in non-text format, empty string is returned.
*/
std::string GetClipboard() const;
/**
* Returns list of TOOL_ACTIONs. TOOL_ACTIONs add themselves to the list upon their
* creation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment