• Main Page
  • Classes
  • Files
  • File List

CMSWindowsClipboard.h

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

Generated on Thu May 23 2013 00:00:03 for Synergy by  doxygen 1.7.1