xref: /haiku/headers/os/app/Clipboard.h (revision 4231541414fdc493dc8e97d76e3c3d76def82a32)
1 /*
2  * Copyright 2007, Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Author:
6  *		Gabe Yoder, gyoder@stny.rr.com
7  */
8 #ifndef _CLIPBOARD_H
9 #define	_CLIPBOARD_H
10 
11 
12 #include <BeBuild.h>
13 #include <Locker.h>
14 #include <Messenger.h>
15 
16 class BMessage;
17 
18 
19 enum {
20 	B_CLIPBOARD_CHANGED = 'CLCH'
21 };
22 
23 class BClipboard {
24 	public:
25 		BClipboard(const char* name, bool transient = false);
26 		virtual ~BClipboard();
27 
28 		const char*	Name() const;
29 
30 		uint32		LocalCount() const;
31 		uint32		SystemCount() const;
32 		status_t	StartWatching(BMessenger target);
33 		status_t	StopWatching(BMessenger target);
34 
35 		bool		Lock();
36 		void		Unlock();
37 		bool		IsLocked() const;
38 
39 		status_t	Clear();
40 		status_t	Commit();
41 		status_t	Commit(bool failIfChanged);
42 		status_t	Revert();
43 
44 		BMessenger	DataSource() const;
45 		BMessage*	Data() const;
46 
47 	private:
48 		BClipboard(const BClipboard &);
49 		BClipboard	&operator=(const BClipboard &);
50 
51 		virtual	void _ReservedClipboard1();
52 		virtual	void _ReservedClipboard2();
53 		virtual	void _ReservedClipboard3();
54 
55 		bool		_AssertLocked() const;
56 		status_t	_DownloadFromSystem(bool force = false);
57 		status_t	_UploadToSystem();
58 
59 		uint32		_reserved0;
60 		BMessage*	fData;
61 		BLocker		fLock;
62 		BMessenger	fClipHandler;
63 		BMessenger	fDataSource;
64 		uint32		fCount;
65 		char*		fName;
66 		uint32		_reserved[4];
67 };
68 
69 extern BClipboard* be_clipboard;
70 
71 #endif	// _CLIPBOARD_H
72