2001-11-13 23:34:12 +00:00
|
|
|
#ifndef ICLIPBOARD_H
|
|
|
|
#define ICLIPBOARD_H
|
|
|
|
|
|
|
|
#include "IInterface.h"
|
2002-06-10 22:06:45 +00:00
|
|
|
#include "CString.h"
|
2001-11-13 23:34:12 +00:00
|
|
|
#include "BasicTypes.h"
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Clipboard interface
|
|
|
|
/*!
|
|
|
|
This interface defines the methods common to all clipboards.
|
|
|
|
*/
|
2001-11-13 23:34:12 +00:00
|
|
|
class IClipboard : public IInterface {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Timestamp type
|
|
|
|
/*!
|
|
|
|
Timestamp type. Timestamps are in milliseconds from some
|
|
|
|
arbitrary starting time. Timestamps will wrap around to 0
|
|
|
|
after about 49 3/4 days.
|
|
|
|
*/
|
2002-04-29 13:31:44 +00:00
|
|
|
typedef UInt32 Time;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Clipboard formats
|
|
|
|
/*!
|
|
|
|
The list of known clipboard formats. kNumFormats must be last and
|
|
|
|
formats must be sequential starting from zero. Clipboard data set
|
|
|
|
via add() and retrieved via get() must be in one of these formats.
|
|
|
|
Platform dependent clipboard subclasses can and should present any
|
|
|
|
suitable formats derivable from these formats.
|
|
|
|
*/
|
|
|
|
enum EFormat {
|
|
|
|
kText, //!< Text format, UTF-8, newline is LF
|
|
|
|
kNumFormats //!< The number of clipboard formats
|
|
|
|
};
|
2001-11-13 23:34:12 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2001-11-13 23:34:12 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Empty clipboard
|
|
|
|
/*!
|
|
|
|
Take ownership of the clipboard and clear all data from it.
|
|
|
|
This must be called between a successful open() and close().
|
|
|
|
Return false if the clipboard ownership could not be taken;
|
|
|
|
the clipboard should not be emptied in this case.
|
|
|
|
*/
|
2002-05-27 16:22:59 +00:00
|
|
|
virtual bool empty() = 0;
|
2001-11-13 23:34:12 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Add data
|
|
|
|
/*!
|
|
|
|
Add data in the given format to the clipboard. May only be
|
|
|
|
called after a successful empty().
|
|
|
|
*/
|
2001-11-13 23:34:12 +00:00
|
|
|
virtual void add(EFormat, const CString& data) = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2001-11-13 23:34:12 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Open clipboard
|
|
|
|
/*!
|
|
|
|
Open the clipboard. Return true iff the clipboard could be
|
|
|
|
opened. If open() returns true then the client must call
|
|
|
|
close() at some later time; if it returns false then close()
|
|
|
|
must not be called. \c time should be the current time or
|
|
|
|
a time in the past when the open should effectively have taken
|
|
|
|
place.
|
|
|
|
*/
|
|
|
|
virtual bool open(Time time) const = 0;
|
2002-05-27 16:22:59 +00:00
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Close clipboard
|
|
|
|
/*!
|
|
|
|
Close the clipboard. close() must match a preceding successful
|
|
|
|
open(). This signals that the clipboard has been filled with
|
|
|
|
all the necessary data or all data has been read. It does not
|
|
|
|
mean the clipboard ownership should be released (if it was
|
|
|
|
taken).
|
|
|
|
*/
|
2002-05-27 16:22:59 +00:00
|
|
|
virtual void close() const = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Get time
|
|
|
|
/*!
|
|
|
|
Return the timestamp passed to the last successful open().
|
|
|
|
*/
|
2002-04-29 13:31:44 +00:00
|
|
|
virtual Time getTime() const = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Check for data
|
|
|
|
/*!
|
|
|
|
Return true iff the clipboard contains data in the given
|
|
|
|
format. Must be called between a successful open() and close().
|
|
|
|
*/
|
2001-11-13 23:34:12 +00:00
|
|
|
virtual bool has(EFormat) const = 0;
|
|
|
|
|
2002-07-29 16:07:26 +00:00
|
|
|
//! Get data
|
|
|
|
/*!
|
|
|
|
Return the data in the given format. Returns the empty string
|
|
|
|
if there is no data in that format. Must be called between
|
|
|
|
a successful open() and close().
|
|
|
|
*/
|
2001-11-13 23:34:12 +00:00
|
|
|
virtual CString get(EFormat) const = 0;
|
2002-07-29 16:07:26 +00:00
|
|
|
|
|
|
|
//@}
|
2001-11-13 23:34:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|