mousetrap v0.2.0
Loading...
Searching...
No Matches
mousetrap::Clipboard Class Reference

object representing the data in the systems clipboard More...

#include <clipboard.hpp>

Public Member Functions

 Clipboard ()=delete
 has no public constructor, use Widget::get_clipboard to create a clipboard
 
 Clipboard (detail::ClipboardInternal *)
 construct from internal
 
 ~Clipboard ()
 destructor
 
NativeObject get_internal () const
 expose internal
 
 operator GdkClipboard * ()
 expose as GdkClipboard \for_internal_use_only
 
bool contains_string () const
 check if the clipboard contains a string
 
bool contains_image () const
 check if the cliboard contains an image
 
bool contains_file () const
 check if the clipboard contains a file, use get_string to retrieve the file path
 
bool get_is_local () const
 check if the clipboards content was set from within the same application the widget belongs to
 
void set_string (const std::string &string)
 override the data in the clipboard with a string
 
template<typename Function_t , typename Data_t >
bool get_string (Function_t on_string_read, Data_t data)
 concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned string
 
template<typename Function_t >
bool get_string (Function_t on_string_read)
 concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned string
 
void set_image (const Image &image)
 override data in clipboard with an image
 
template<typename Function_t , typename Data_t >
bool get_image (Function_t on_image_read, Data_t data)
 concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned image
 
template<typename Function_t >
bool get_image (Function_t on_image_read)
 concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned image
 
void set_file (const FileDescriptor &file)
 override data with a file
 

Protected Member Functions

 Clipboard (const Widget *)
 constructor from widget, usually a window
 

Friends

class Widget
 

Detailed Description

object representing the data in the systems clipboard

Member Function Documentation

◆ contains_file()

bool mousetrap::Clipboard::contains_file ( ) const

check if the clipboard contains a file, use get_string to retrieve the file path

Returns
true if file, false otherwise

◆ contains_image()

bool mousetrap::Clipboard::contains_image ( ) const

check if the cliboard contains an image

Returns
true if image, false otherwise

Referenced by get_image().

◆ contains_string()

bool mousetrap::Clipboard::contains_string ( ) const

check if the clipboard contains a string

Returns
true if string, false otherwise

Referenced by get_string().

◆ get_image() [1/2]

template<typename Function_t >
bool mousetrap::Clipboard::get_image ( Function_t  on_image_read)

concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned image

Parameters
on_image_readlamdba with signature (Clipboard*, const Image&) -> void
Returns
true if data can be serialized into an image, false otherwise

References contains_image().

◆ get_image() [2/2]

template<typename Function_t , typename Data_t >
bool mousetrap::Clipboard::get_image ( Function_t  on_image_read,
Data_t  data 
)

concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned image

Parameters
on_image_readlamdba with signature (Clipboard*, const Image&, Data_t) -> void
dataarbitrary data
Returns
true if data can be serialized into an image, false otherwise

References contains_image().

◆ get_is_local()

bool mousetrap::Clipboard::get_is_local ( ) const

check if the clipboards content was set from within the same application the widget belongs to

Returns
boolean

◆ get_string() [1/2]

template<typename Function_t >
bool mousetrap::Clipboard::get_string ( Function_t  on_string_read)

concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned string

Parameters
on_string_readlamdba with signature (Clipboard*, const std::string&) -> void
Returns
true if data can be serialized into a string, false otherwise

References contains_string().

◆ get_string() [2/2]

template<typename Function_t , typename Data_t >
bool mousetrap::Clipboard::get_string ( Function_t  on_string_read,
Data_t  data 
)

concurrently read the data in the clipboard. Once reading is done, on_string_read> will be called with the returned string

Parameters
on_string_readlamdba with signature (Clipboard*, const std::string&, Data_t) -> void
dataarbitrary data
Returns
true if data can be serialized into a string, false otherwise

References contains_string().

◆ set_file()

void mousetrap::Clipboard::set_file ( const FileDescriptor file)

override data with a file

Parameters
file

◆ set_image()

void mousetrap::Clipboard::set_image ( const Image image)

override data in clipboard with an image

Parameters
image

◆ set_string()

void mousetrap::Clipboard::set_string ( const std::string &  string)

override the data in the clipboard with a string

Parameters
string

The documentation for this class was generated from the following files: