tbx  0.7.6
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
tbx::Clipboard Class Reference

Class to handler the global RISC OS clipboard. More...

#include <clipboard.h>

Public Member Functions

void clear ()
 Clear all the local clipboard data.
 
void copy (int file_type, ClipboardData *data, bool add=false)
 Copy the given data to the local clipboard and make if available to the global clipboard. More...
 
void copy (const std::string &text, int file_type=0xFFF)
 Convenience method to make it easy to copy text to the clipboard. More...
 
void copy (int file_type, char *bytes, int size, bool copy_bytes=true)
 Convenience method to place bytes on to the clipboard. More...
 
void paste (int file_type, Gadget &gadget, int x=0, int y=0)
 Paste data from global clipboard. More...
 
void paste (int *file_types, int num_types, Gadget &gadget, int x=0, int y=0)
 Paste data from global clipboard. More...
 
void paste (int file_type, Window &window, int x=0, int y=0)
 Paste data from global clipboard. More...
 
void paste (int *file_types, int num_types, Window &window, int x=0, int y=0)
 Paste data from global clipboard. More...
 
void check (int file_type, Window &window)
 Check the global clipboard for a given file type. More...
 
void check (int *file_types, int num_types, Window &window)
 Check the global clipboard for once of thegiven file type. More...
 
void claim_caret ()
 Claim the caret/selection for this application. More...
 
void add_claimed_listener (ClipboardClaimedListener *listener)
 Add a listener for when the clipboard has been claimed by another application. More...
 
void remove_claimed_listener (ClipboardClaimedListener *listener)
 Remove a listener for when the clipboard has been claimed by another application. More...
 
void add_format_listener (ClipboardFormatListener *listener)
 Add a listener for the result of a Clipboard::check call. More...
 
void remove_format_listener (ClipboardFormatListener *listener)
 Remove a listener for the result of a Clipboard::check call. More...
 
bool owns_clipboard () const
 Check if global clipboard is currently owned by this application. More...
 
ClipboardDatadata (int file_type) const
 Get data stored locally of the given file type. More...
 
ClipboardDatanative_data () const
 Get the native data from the data stored locally. More...
 
int native_file_type () const
 Return the native file type. More...
 

Static Public Member Functions

static Clipboardinstance ()
 Return the global clipboard instance, creating it if it does not exist.
 

Friends

class MessageHandler
 

Detailed Description

Class to handler the global RISC OS clipboard.

Member Function Documentation

◆ add_claimed_listener()

void tbx::Clipboard::add_claimed_listener ( ClipboardClaimedListener listener)

Add a listener for when the clipboard has been claimed by another application.

Parameters
listenerlistener to add

◆ add_format_listener()

void tbx::Clipboard::add_format_listener ( ClipboardFormatListener listener)

Add a listener for the result of a Clipboard::check call.

Parameters
listenerlistener to add

◆ check() [1/2]

void tbx::Clipboard::check ( int *  file_types,
int  num_types,
Window window 
)

Check the global clipboard for once of thegiven file type.

The result of the check is returned via the ClipboardFormatListener.

Parameters
file_typesan array of file types to check for.
num_typesthe number of types in the array.
windowa window to use for checking.

◆ check() [2/2]

void tbx::Clipboard::check ( int  file_type,
Window window 
)

Check the global clipboard for a given file type.

The result of the check is returned via the ClipboardFormatListener.

Parameters
file_typethe file type to check for
windowa window to use for checking.

◆ claim_caret()

void tbx::Clipboard::claim_caret ( )

Claim the caret/selection for this application.

An application should call this when it gains the focus to allow it to paste data and inform other applications they no longer have the input focus

This can be called safely multiple times, the caret is only claimed from the system if this application doesn't already have it.

◆ copy() [1/3]

void tbx::Clipboard::copy ( const std::string &  text,
int  file_type = 0xFFF 
)

Convenience method to make it easy to copy text to the clipboard.

Parameters
textthe text to copy.
file_type(default 0xFFF - Text)

◆ copy() [2/3]

void tbx::Clipboard::copy ( int  file_type,
char *  bytes,
int  size,
bool  copy_bytes = true 
)

Convenience method to place bytes on to the clipboard.

Parameters
file_typefile type for the bytes
bytesbytes to place on the clipboard
sizesize of the bytes to place on the clipboard
copy_bytestrue to make a copy of the bytes, false to take ownership and delete them with delete[] bytes when no longer required.

◆ copy() [3/3]

void tbx::Clipboard::copy ( int  file_type,
ClipboardData data,
bool  add = false 
)

Copy the given data to the local clipboard and make if available to the global clipboard.

The data is not copied to another application until, a paste request is received.

Parameters
file_typethe file type of the data
dataobject to provide the data to the clipboard (the clipboard takes ownership of this object and will delete it when it is no longer required)
addif false (the default) the data will replace existing data and the native file type is set to file_type. if true the file_type will be added the list of supported types.

◆ data()

ClipboardData * tbx::Clipboard::data ( int  file_type) const

Get data stored locally of the given file type.

Parameters
file_typefile type of data to get
Returns
pointer to the clipboard data (or 0 if no data of the given type)

◆ native_data()

ClipboardData * tbx::Clipboard::native_data ( ) const

Get the native data from the data stored locally.

The native data is the first that was copied to the clipboard with copy.

Returns
clipboard data for the native file type (or 0 if none)

◆ native_file_type()

int tbx::Clipboard::native_file_type ( ) const

Return the native file type.

This is set when the first data is copied to the clipboard

Returns
native file type (or -1) if nothing has been put on the clipboard

◆ owns_clipboard()

bool tbx::Clipboard::owns_clipboard ( ) const
inline

Check if global clipboard is currently owned by this application.

Returns
true if global clipboard is owned.

◆ paste() [1/4]

void tbx::Clipboard::paste ( int *  file_types,
int  num_types,
Gadget gadget,
int  x = 0,
int  y = 0 
)

Paste data from global clipboard.

The Gadget to paste to must have a Loader with add loader to receive the data. To receive data when this application owns the clipboard the loader must support ram transfer.

Parameters
file_typeslist of file type to paste in order of preference. If none of these types are on the clipboard it will try to load the native format stored on the clipboard. This means the gadget loader routine may receive a different format if it is set to load all types.
num_typesnumber of file types in the list.
gadgetgadget to paste to (must be in window or null)
xx-coordinate for paste
yy-coordinate for paste

◆ paste() [2/4]

void tbx::Clipboard::paste ( int *  file_types,
int  num_types,
Window window,
int  x = 0,
int  y = 0 
)

Paste data from global clipboard.

The window to paste to must have a Loader with add loader to receive the data. To receive data when this application owns the clipboard the loader must support ram transfer.

Parameters
file_typefile type to paste. If this type is not on the clipboard it will try to load the native format stored on the clipboard. This means the gadget loader routine may receive a different format if it is set to load all types.
num_typesnumber of file types in the list.
windowwindow to paste to
xx-coordinate for paste (defaults to 0)
yy-coordinate for paste (defaults to 0)

◆ paste() [3/4]

void tbx::Clipboard::paste ( int  file_type,
tbx::Gadget gadget,
int  x = 0,
int  y = 0 
)

Paste data from global clipboard.

The Gadget to paste to must have a Loader with add loader to receive the data. To receive data when this application owns the clipboard the loader must support ram transfer.

Parameters
file_typefile type to paste. If this type is not on the clipboard it will try to load the native format stored on the clipboard. This means the gadget loader routine may receive a different format if it is set to load all types.
gadgetgadget to paste to
xx-coordinate for paste (defaults to 0)
yy-coordinate for paste (defaults to 0)

◆ paste() [4/4]

void tbx::Clipboard::paste ( int  file_type,
Window window,
int  x = 0,
int  y = 0 
)

Paste data from global clipboard.

The window to paste to must have a Loader with add loader to receive the data. To receive data when this application owns the clipboard the loader must support ram transfer.

Parameters
file_typefile type to paste. If this type is not on the clipboard it will try to load the native format stored on the clipboard. This means the gadget loader routine may receive a different format if it is set to load all types.
windowwindow to paste to
xx-coordinate for paste (defaults to 0)
yy-coordinate for paste (defaults to 0)

◆ remove_claimed_listener()

void tbx::Clipboard::remove_claimed_listener ( ClipboardClaimedListener listener)

Remove a listener for when the clipboard has been claimed by another application.

Parameters
listenerlistener to remove

◆ remove_format_listener()

void tbx::Clipboard::remove_format_listener ( ClipboardFormatListener listener)

Remove a listener for the result of a Clipboard::check call.

Parameters
listenerlistener to remove

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