diff options
author | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-12 16:25:23 +0000 |
---|---|---|
committer | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-12 16:25:23 +0000 |
commit | 2b05317b8aa8edb15c794f5d389e71b1a50c331d (patch) | |
tree | 1bddb2c1799823c7b68ca0a2c57eabc19eed2733 /base/clipboard.h | |
parent | b6e09acf8ced26198871626c76bb5a3741cc51f1 (diff) | |
download | chromium_src-2b05317b8aa8edb15c794f5d389e71b1a50c331d.zip chromium_src-2b05317b8aa8edb15c794f5d389e71b1a50c331d.tar.gz chromium_src-2b05317b8aa8edb15c794f5d389e71b1a50c331d.tar.bz2 |
Basic implementation of the clipboard on the Mac.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/clipboard.h')
-rw-r--r-- | base/clipboard.h | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/base/clipboard.h b/base/clipboard.h index 3599241..047ba4c 100644 --- a/base/clipboard.h +++ b/base/clipboard.h @@ -27,8 +27,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef BASE_CLIPBOARD_H__ -#define BASE_CLIPBOARD_H__ +#ifndef BASE_CLIPBOARD_H_ +#define BASE_CLIPBOARD_H_ #include <string> #include <vector> @@ -37,56 +37,68 @@ #include "base/gfx/size.h" #include "base/shared_memory.h" +#if defined(OS_MACOSX) +@class NSString; +#endif + class Clipboard { public: +#if defined(OS_WIN) + typedef unsigned int FormatType; +#elif defined(OS_MACOSX) + typedef NSString *FormatType; +#endif + Clipboard(); ~Clipboard(); // Clears the clipboard. It is usually a good idea to clear the clipboard // before writing content to the clipboard. - void Clear() const; + void Clear(); // Adds UNICODE and ASCII text to the clipboard. - void WriteText(const std::wstring& text) const; + void WriteText(const std::wstring& text); // Adds HTML to the clipboard. The url parameter is optional, but especially // useful if the HTML fragment contains relative links - void WriteHTML(const std::wstring& markup, const std::string& src_url) const; + void WriteHTML(const std::wstring& markup, const std::string& src_url); // Adds a bookmark to the clipboard - void WriteBookmark(const std::wstring& title, const std::string& url) const; + void WriteBookmark(const std::wstring& title, const std::string& url); // Adds both a bookmark and an HTML hyperlink to the clipboard. It is a // convenience wrapper around WriteBookmark and WriteHTML. - void WriteHyperlink(const std::wstring& title, const std::string& url) const; + void WriteHyperlink(const std::wstring& title, const std::string& url); +#if defined(OS_WIN) // Adds a bitmap to the clipboard // This is the slowest way to copy a bitmap to the clipboard as we must first // memcpy the pixels into GDI and the blit the bitmap to the clipboard. // Pixel format is assumed to be 32-bit BI_RGB. - void WriteBitmap(const void* pixels, const gfx::Size& size) const; + void WriteBitmap(const void* pixels, const gfx::Size& size); // Adds a bitmap to the clipboard // This function requires read and write access to the bitmap, but does not // actually modify the shared memory region. // Pixel format is assumed to be 32-bit BI_RGB. void WriteBitmapFromSharedMemory(const SharedMemory& bitmap, - const gfx::Size& size) const; + const gfx::Size& size); // Adds a bitmap to the clipboard // This is the fastest way to copy a bitmap to the clipboard. The HBITMAP // may either be device-dependent or device-independent. - void WriteBitmapFromHandle(HBITMAP hbitmap, const gfx::Size& size) const; + void WriteBitmapFromHandle(HBITMAP hbitmap, const gfx::Size& size); // Used by WebKit to determine whether WebKit wrote the clipboard last - void WriteWebSmartPaste() const; + void WriteWebSmartPaste(); +#endif // Adds a file or group of files to the clipboard. - void WriteFile(const std::wstring& file) const; - void WriteFiles(const std::vector<std::wstring>& files) const; + void WriteFile(const std::wstring& file); + void WriteFiles(const std::vector<std::wstring>& files); // Tests whether the clipboard contains a certain format - bool IsFormatAvailable(unsigned int format) const; + bool IsFormatAvailable(FormatType format) const; // Reads UNICODE text from the clipboard, if available. void ReadText(std::wstring* result) const; @@ -106,6 +118,7 @@ class Clipboard { void ReadFiles(std::vector<std::wstring>* files) const; private: +#if defined(OS_WIN) static void MarkupToHTMLClipboardFormat(const std::wstring& markup, const std::string& src_url, std::string* html_fragment); @@ -119,8 +132,9 @@ class Clipboard { std::string* url); HWND clipboard_owner_; +#endif DISALLOW_EVIL_CONSTRUCTORS(Clipboard); }; -#endif // BASE_CLIPBOARD_H__ +#endif // BASE_CLIPBOARD_H_ |