DragImage.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #ifndef DragImage_h
  26. #define DragImage_h
  27. #include "FontRenderingMode.h"
  28. #include "ImageOrientation.h"
  29. #include "IntSize.h"
  30. #include "FloatSize.h"
  31. #include <wtf/Forward.h>
  32. #if PLATFORM(MAC)
  33. #include <wtf/RetainPtr.h>
  34. OBJC_CLASS NSImage;
  35. #elif PLATFORM(QT)
  36. QT_BEGIN_NAMESPACE
  37. class QPixmap;
  38. QT_END_NAMESPACE
  39. #elif PLATFORM(WIN)
  40. typedef struct HBITMAP__* HBITMAP;
  41. #elif PLATFORM(GTK) || PLATFORM(MANX)
  42. typedef struct _cairo_surface cairo_surface_t;
  43. #endif
  44. //We need to #define YOffset as it needs to be shared with WebKit
  45. #define DragLabelBorderYOffset 2
  46. namespace WebCore {
  47. class Image;
  48. class KURL;
  49. class Range;
  50. #if PLATFORM(MAC)
  51. typedef RetainPtr<NSImage> DragImageRef;
  52. #elif PLATFORM(QT)
  53. typedef QPixmap* DragImageRef;
  54. #elif PLATFORM(WIN)
  55. typedef HBITMAP DragImageRef;
  56. #elif PLATFORM(GTK) || PLATFORM(MANX)
  57. typedef cairo_surface_t* DragImageRef;
  58. #elif PLATFORM(EFL) || PLATFORM(BLACKBERRY)
  59. typedef void* DragImageRef;
  60. #endif
  61. IntSize dragImageSize(DragImageRef);
  62. //These functions should be memory neutral, eg. if they return a newly allocated image,
  63. //they should release the input image. As a corollary these methods don't guarantee
  64. //the input image ref will still be valid after they have been called
  65. DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size);
  66. DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
  67. DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta);
  68. DragImageRef createDragImageFromImage(Image*, RespectImageOrientationEnum = DoNotRespectImageOrientation);
  69. DragImageRef createDragImageIconForCachedImageFilename(const String&);
  70. DragImageRef createDragImageForLink(KURL&, const String& label, FontRenderingMode);
  71. void deleteDragImage(DragImageRef);
  72. }
  73. #endif //!DragImage_h