1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: Clipboard.h 23 // Author: Gabe Yoder (gyoder@stny.rr.com) 24 // Description: BClipboard provides an interface to a system-wide clipboard 25 // storage area. 26 //------------------------------------------------------------------------------ 27 28 #ifndef _CLIPBOARD_H 29 #define _CLIPBOARD_H 30 31 // Standard Includes ----------------------------------------------------------- 32 33 // System Includes ------------------------------------------------------------- 34 #include <BeBuild.h> 35 #include <Messenger.h> 36 #include <Locker.h> 37 38 // Project Includes ------------------------------------------------------------ 39 40 // Local Includes -------------------------------------------------------------- 41 42 // Local Defines --------------------------------------------------------------- 43 44 // Globals --------------------------------------------------------------------- 45 class BMessage; 46 47 enum { 48 B_CLIPBOARD_CHANGED = 'CLCH' 49 }; 50 51 // BClipboard class --------------------------------------------------------------- 52 class BClipboard { 53 public: 54 BClipboard(const char *name, bool transient = false); 55 virtual ~BClipboard(); 56 57 const char *Name() const; 58 59 uint32 LocalCount() const; 60 uint32 SystemCount() const; 61 status_t StartWatching(BMessenger target); 62 status_t StopWatching(BMessenger target); 63 64 bool Lock(); 65 void Unlock(); 66 bool IsLocked() const; 67 68 status_t Clear(); 69 status_t Commit(); 70 status_t Revert(); 71 72 BMessenger DataSource() const; 73 BMessage *Data() const; 74 75 /*----- Private or reserved -----------------------------------------*/ 76 private: 77 BClipboard(const BClipboard &); 78 BClipboard &operator=(const BClipboard &); 79 80 virtual void _ReservedClipboard1(); 81 virtual void _ReservedClipboard2(); 82 virtual void _ReservedClipboard3(); 83 84 bool AssertLocked() const; 85 status_t DownloadFromSystem(bool force = false); 86 status_t UploadToSystem(); 87 88 uint32 fCount; 89 BMessage *fData; 90 BLocker fLock; 91 BMessenger fClipHandler; 92 BMessenger fDataSource; 93 uint32 fSystemCount; 94 char *fName; 95 uint32 _reserved[4]; 96 }; 97 98 //----- Global Clipboard ------------------------------------------------------- 99 100 extern _IMPEXP_BE BClipboard *be_clipboard; 101 102 //------------------------------------------------------------------------------ 103 104 #endif // _CLIPBOARD_H 105 106