2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / WebCore / dom / Clipboard.h
blob59ae02645f114e8d4a96081e0748f4f05dcfe8ba
1 /*
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef Clipboard_h
25 #define Clipboard_h
27 #include "CachedResourceHandle.h"
28 #include "ClipboardAccessPolicy.h"
29 #include "DragActions.h"
30 #include "DragImage.h"
31 #include "IntPoint.h"
32 #include "Node.h"
34 namespace WebCore {
36 // State available during IE's events for drag and drop and copy/paste
37 class Clipboard : public RefCounted<Clipboard> {
38 public:
39 virtual ~Clipboard() { }
41 // Is this operation a drag-drop or a copy-paste?
42 bool isForDragging() const { return m_forDragging; }
44 String dropEffect() const { return m_dropEffect; }
45 void setDropEffect(const String&);
46 String effectAllowed() const { return m_effectAllowed; }
47 void setEffectAllowed(const String&);
49 virtual void clearData(const String& type) = 0;
50 virtual void clearAllData() = 0;
51 virtual String getData(const String& type, bool& success) const = 0;
52 virtual bool setData(const String& type, const String& data) = 0;
54 // extensions beyond IE's API
55 virtual HashSet<String> types() const = 0;
57 IntPoint dragLocation() const { return m_dragLoc; }
58 CachedImage* dragImage() const { return m_dragImage.get(); }
59 virtual void setDragImage(CachedImage*, const IntPoint&) = 0;
60 Node* dragImageElement() { return m_dragImageElement.get(); }
61 virtual void setDragImageElement(Node*, const IntPoint&) = 0;
63 virtual DragImageRef createDragImage(IntPoint& dragLocation) const = 0;
64 virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0;
65 virtual void writeURL(const KURL&, const String&, Frame*) = 0;
66 virtual void writeRange(Range*, Frame*) = 0;
68 virtual bool hasData() = 0;
70 void setAccessPolicy(ClipboardAccessPolicy);
72 bool sourceOperation(DragOperation&) const;
73 bool destinationOperation(DragOperation&) const;
74 void setSourceOperation(DragOperation);
75 void setDestinationOperation(DragOperation);
77 void setDragHasStarted() { m_dragStarted = true; }
79 protected:
80 Clipboard(ClipboardAccessPolicy, bool isForDragging);
82 ClipboardAccessPolicy policy() const { return m_policy; }
83 bool dragStarted() const { return m_dragStarted; }
85 private:
86 ClipboardAccessPolicy m_policy;
87 String m_dropEffect;
88 String m_effectAllowed;
89 bool m_dragStarted;
91 protected:
92 bool m_forDragging;
93 IntPoint m_dragLoc;
94 CachedResourceHandle<CachedImage> m_dragImage;
95 RefPtr<Node> m_dragImageElement;
98 } // namespace WebCore
100 #endif // Clipboard_h