CMSWindowsClipboard.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CMSWINDOWSCLIPBOARD_H
00016 #define CMSWINDOWSCLIPBOARD_H
00017 
00018 #include "IClipboard.h"
00019 #include "stdvector.h"
00020 #define WIN32_LEAN_AND_MEAN
00021 #include <windows.h>
00022 
00023 class IMSWindowsClipboardConverter;
00024 
00026 class CMSWindowsClipboard : public IClipboard {
00027 public:
00028     CMSWindowsClipboard(HWND window);
00029     virtual ~CMSWindowsClipboard();
00030 
00032 
00044     bool                emptyUnowned();
00045 
00047     static bool         isOwnedBySynergy();
00048 
00049     // IClipboard overrides
00050     virtual bool        empty();
00051     virtual void        add(EFormat, const CString& data);
00052     virtual bool        open(Time) const;
00053     virtual void        close() const;
00054     virtual Time        getTime() const;
00055     virtual bool        has(EFormat) const;
00056     virtual CString     get(EFormat) const;
00057 
00058 private:
00059     void                clearConverters();
00060 
00061     UINT                convertFormatToWin32(EFormat) const;
00062     HANDLE              convertTextToWin32(const CString& data) const;
00063     CString             convertTextFromWin32(HANDLE) const;
00064 
00065     static UINT         getOwnershipFormat();
00066 
00067 private:
00068     typedef std::vector<IMSWindowsClipboardConverter*> ConverterList;
00069 
00070     HWND                m_window;
00071     mutable Time        m_time;
00072     ConverterList       m_converters;
00073     static UINT         s_ownershipFormat;
00074 };
00075 
00077 
00081 class IMSWindowsClipboardConverter : public IInterface {
00082 public:
00083     // accessors
00084 
00085     // return the clipboard format this object converts from/to
00086     virtual IClipboard::EFormat
00087                         getFormat() const = 0;
00088 
00089     // return the atom representing the win32 clipboard format that
00090     // this object converts from/to
00091     virtual UINT        getWin32Format() const = 0;
00092 
00093     // convert from the IClipboard format to the win32 clipboard format.
00094     // the input data must be in the IClipboard format returned by
00095     // getFormat().  the return data will be in the win32 clipboard
00096     // format returned by getWin32Format(), allocated by GlobalAlloc().
00097     virtual HANDLE      fromIClipboard(const CString&) const = 0;
00098 
00099     // convert from the win32 clipboard format to the IClipboard format
00100     // (i.e., the reverse of fromIClipboard()).
00101     virtual CString     toIClipboard(HANDLE data) const = 0;
00102 };
00103 
00104 #endif

Generated on Fri Nov 6 00:18:45 2009 for synergy-plus by  doxygen 1.4.7