xref: /haiku/headers/os/app/Clipboard.h (revision 2318b47802d763f671cad12088c69246200e0f1e)
1 /*
2  * Copyright 2007-2009, 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,
26 									bool transient = false);
27 	virtual						~BClipboard();
28 
29 			const char*			Name() const;
30 
31 			uint32				LocalCount() const;
32 			uint32				SystemCount() const;
33 			status_t			StartWatching(BMessenger target);
34 			status_t			StopWatching(BMessenger target);
35 
36 			bool				Lock();
37 			void				Unlock();
38 			bool				IsLocked() const;
39 
40 			status_t			Clear();
41 			status_t			Commit();
42 			status_t			Commit(bool failIfChanged);
43 			status_t			Revert();
44 
45 			BMessenger			DataSource() const;
46 			BMessage*			Data() const;
47 
48 private:
49 								BClipboard(const BClipboard&);
50 			BClipboard&			operator=(const BClipboard&);
51 
52 	virtual	void				_ReservedClipboard1();
53 	virtual	void				_ReservedClipboard2();
54 	virtual	void				_ReservedClipboard3();
55 
56 			bool				_AssertLocked() const;
57 			status_t			_DownloadFromSystem(bool force = false);
58 			status_t			_UploadToSystem();
59 
60 			uint32				_reserved0;
61 			BMessage*			fData;
62 			BLocker				fLock;
63 			BMessenger			fClipHandler;
64 			BMessenger			fDataSource;
65 			uint32				fCount;
66 			char*				fName;
67 			uint32				_reserved[4];
68 };
69 
70 extern BClipboard* be_clipboard;
71 
72 #endif	// _CLIPBOARD_H
73