#include <app/Clipboard.h>
#include "Clipboard.h"
\class Clipboard
\brief Server-side representation of a clipboard.
*/
\param name The name of the clipboard.
*/
Clipboard::Clipboard(const char *name)
: fName(name),
fData(B_SIMPLE_DATA),
fDataSource(),
fCount(0),
fWatchingService()
{
}
*/
Clipboard::~Clipboard()
{
}
Also notifies all watchers that the clipboard data have changed.
\param data The new clipboard data.
\param dataSource The clipboards new data source.
*/
void
Clipboard::SetData(const BMessage *data, BMessenger dataSource)
{
fData = *data;
fDataSource = dataSource;
fCount++;
NotifyWatchers();
}
\return The clipboard's data.
*/
const BMessage *
Clipboard::Data() const
{
return &fData;
}
\return The clipboard's data source.
*/
BMessenger
Clipboard::DataSource() const
{
return fDataSource;
}
int32
Clipboard::Count() const
{
return fCount;
}
\param watcher The messenger referring to the new watcher.
\return \c true, if the watcher could be added successfully,
\c false otherwise.
*/
bool
Clipboard::AddWatcher(BMessenger watcher)
{
return fWatchingService.AddWatcher(watcher);
}
\param watcher The watcher to be removed.
\return \c true, if the supplied watcher was watching the clipboard,
\c false otherwise.
*/
bool
Clipboard::RemoveWatcher(BMessenger watcher)
{
return fWatchingService.RemoveWatcher(watcher);
}
to all associated watchers.
*/
void
Clipboard::NotifyWatchers()
{
BMessage message(B_CLIPBOARD_CHANGED);
fWatchingService.NotifyWatchers(&message, NULL);
}