1/*
2 * Copyright (C) 2007 Apple Inc.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef DragImage_h
27#define DragImage_h
28
29#include "FontRenderingMode.h"
30#include "ImageOrientation.h"
31#include "IntSize.h"
32#include "FloatSize.h"
33#include <wtf/Forward.h>
34
35#if PLATFORM(MAC)
36#include <wtf/RetainPtr.h>
37OBJC_CLASS NSImage;
38#elif PLATFORM(QT)
39QT_BEGIN_NAMESPACE
40class QPixmap;
41QT_END_NAMESPACE
42#elif PLATFORM(WIN)
43typedef struct HBITMAP__* HBITMAP;
44#elif PLATFORM(GTK)
45typedef struct _cairo_surface cairo_surface_t;
46#endif
47
48//We need to #define YOffset as it needs to be shared with WebKit
49#define DragLabelBorderYOffset 2
50
51namespace WebCore {
52
53    class Image;
54    class KURL;
55    class Range;
56
57#if PLATFORM(MAC)
58    typedef RetainPtr<NSImage> DragImageRef;
59#elif PLATFORM(QT)
60    typedef QPixmap* DragImageRef;
61#elif PLATFORM(WIN)
62    typedef HBITMAP DragImageRef;
63#elif PLATFORM(GTK)
64    typedef cairo_surface_t* DragImageRef;
65#elif PLATFORM(EFL) || PLATFORM(BLACKBERRY)
66    typedef void* DragImageRef;
67#endif
68
69    IntSize dragImageSize(DragImageRef);
70
71    //These functions should be memory neutral, eg. if they return a newly allocated image,
72    //they should release the input image.  As a corollary these methods don't guarantee
73    //the input image ref will still be valid after they have been called
74    DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size);
75    DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
76    DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta);
77
78    DragImageRef createDragImageFromImage(Image*, RespectImageOrientationEnum = DoNotRespectImageOrientation);
79    DragImageRef createDragImageIconForCachedImageFilename(const String&);
80    DragImageRef createDragImageForLink(KURL&, const String& label, FontRenderingMode);
81    void deleteDragImage(DragImageRef);
82}
83
84
85#endif //!DragImage_h
86