|
KiCad PCB EDA Suite
|
#include "clipboard.h"#include <wx/clipbrd.h>#include <wx/dataobj.h>#include <wx/image.h>#include <wx/log.h>#include <wx/mstream.h>#include <wx/string.h>#include <wx/sstream.h>#include <io/csv.h>Go to the source code of this file.
Functions | |
| bool | SaveClipboard (const std::string &aTextUTF8) |
| Store information to the system clipboard. | |
| bool | SaveClipboard (const std::string &aTextUTF8, const std::vector< CLIPBOARD_MIME_DATA > &aMimeData) |
| Store information to the system clipboard with additional MIME types. | |
| std::string | GetClipboardUTF8 () |
| Return the information currently stored in the system clipboard. | |
| std::unique_ptr< wxBitmap > | GetImageFromClipboard () |
| Get image data from the clipboard, if there is any. | |
| bool | SaveTabularDataToClipboard (const std::vector< std::vector< wxString > > &aData) |
| Store tabular data to the system clipboard. | |
| bool | GetTabularDataFromClipboard (std::vector< std::vector< wxString > > &aData) |
| Attempt to get tabular data from the clipboard. | |
| bool | EncodeImageToPng (const wxImage &aImage, wxMemoryBuffer &aOutput) |
| Encode an image to PNG format with fast compression settings optimized for clipboard use. | |
| bool | AddPngToClipboardData (wxDataObjectComposite *aData, const wxMemoryBuffer &aPngData, const wxImage *aFallbackImage) |
| Adds pre-encoded PNG data to clipboard in a platform-specific way. | |
| bool | AddTransparentImageToClipboardData (wxDataObjectComposite *aData, wxImage aImage) |
| Adds an image to clipboard data in a platform-specific way such that transparency is supported. | |
| bool AddPngToClipboardData | ( | wxDataObjectComposite * | aData, |
| const wxMemoryBuffer & | aPngData, | ||
| const wxImage * | aFallbackImage = nullptr ) |
Adds pre-encoded PNG data to clipboard in a platform-specific way.
On Windows: Adds empty CF_BITMAP marker and "PNG" format entry On GTK: Adds as wxDF_BITMAP (which maps to image/png) On macOS: Falls back to wxBitmapDataObject with the provided image
| aData | Clipboard composite to add PNG to |
| aPngData | Pre-encoded PNG bytes |
| aFallbackImage | Optional image for macOS fallback (required on macOS) |
Definition at line 324 of file clipboard.cpp.
Referenced by AddTransparentImageToClipboardData(), and SCH_EDITOR_CONTROL::doCopy().
| bool AddTransparentImageToClipboardData | ( | wxDataObjectComposite * | aData, |
| wxImage | aImage ) |
Adds an image to clipboard data in a platform-specific way such that transparency is supported.
Convenience function that encodes PNG internally.
Definition at line 349 of file clipboard.cpp.
References AddPngToClipboardData(), and EncodeImageToPng().
Referenced by SCH_EDITOR_CONTROL::DrawSheetOnClipboard().
| bool EncodeImageToPng | ( | const wxImage & | aImage, |
| wxMemoryBuffer & | aOutput ) |
Encode an image to PNG format with fast compression settings optimized for clipboard use.
| aImage | Source image to encode |
| aOutput | Buffer to receive PNG data |
Definition at line 293 of file clipboard.cpp.
Referenced by AddTransparentImageToClipboardData(), and SCH_EDITOR_CONTROL::doCopy().
| std::string GetClipboardUTF8 | ( | ) |
Return the information currently stored in the system clipboard.
If data stored in the clipboard is in non-text format, empty string is returned.
Definition at line 120 of file clipboard.cpp.
References result.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), SYMBOL_EDIT_FRAME::DuplicateSymbol(), PCB_CONTROL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), and SYMBOL_EDITOR_EDIT_TOOL::Paste().
| std::unique_ptr< wxBitmap > GetImageFromClipboard | ( | ) |
Get image data from the clipboard, if there is any.
If there's a filename there, and it can be loaded as an image, do that.
Definition at line 168 of file clipboard.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_CONTROL::Paste(), PL_EDIT_TOOL::Paste(), and SCH_EDITOR_CONTROL::Paste().
| bool GetTabularDataFromClipboard | ( | std::vector< std::vector< wxString > > & | aData | ) |
Attempt to get tabular data from the clipboard.
Definition at line 260 of file clipboard.cpp.
References AutoDecodeCSV().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and PIN_TABLE_IMPORT::ImportData().
| bool SaveClipboard | ( | const std::string & | aTextUTF8 | ) |
Store information to the system clipboard.
| aText | is the information to be stored, expected UTF8 encoding. The text will be stored as Unicode string (not stored as UTF8 string). |
Definition at line 36 of file clipboard.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), SCH_EDITOR_CONTROL::CopyAsText(), SYMBOL_EDITOR_EDIT_TOOL::CopyAsText(), EDIT_TOOL::copyToClipboardAsText(), and SaveClipboard().
| bool SaveClipboard | ( | const std::string & | aTextUTF8, |
| const std::vector< CLIPBOARD_MIME_DATA > & | aMimeData ) |
Store information to the system clipboard with additional MIME types.
Creates a composite clipboard object with text as the primary format and additional custom MIME type data. When aMimeData is empty, falls back to SaveClipboard(aTextUTF8).
| aTextUTF8 | is the text to store, expected UTF8 encoding. Stored as primary text format. |
| aMimeData | is additional data to store by MIME type (e.g., image/svg+xml, image/png). |
Definition at line 56 of file clipboard.cpp.
References SaveClipboard().
| bool SaveTabularDataToClipboard | ( | const std::vector< std::vector< wxString > > & | aData | ) |
Store tabular data to the system clipboard.
Definition at line 226 of file clipboard.cpp.
References CSV_WRITER::WriteLines().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and PIN_TABLE_EXPORT::ExportData().